diff --git a/.gitignore b/.gitignore
index 693a35c176..51f3d69d9f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,8 +34,6 @@ spring-security-openid/src/main/resources/application.properties
spring-all/*.log
-*.jar
-
SpringDataInjectionDemo/.mvn/wrapper/maven-wrapper.properties
spring-call-getters-using-reflection/.mvn/wrapper/maven-wrapper.properties
diff --git a/JGit/pom.xml b/JGit/pom.xml
index 6d505afcf3..4feb31b758 100644
--- a/JGit/pom.xml
+++ b/JGit/pom.xml
@@ -11,41 +11,42 @@
com.baeldung
parent-modules
1.0.0-SNAPSHOT
-
-
+
+
+
+
+ jgit-repository
+ https://repo.eclipse.org/content/groups/releases/
+
+
+
+
+
+
+ org.eclipse.jgit
+ org.eclipse.jgit
+ ${org.eclipse.jgit.version}
+
+
+ org.eclipse.jgit
+ org.eclipse.jgit.archive
+ ${org.eclipse.jgit.version}
+
+
+ commons-io
+ commons-io
+ ${commons-io.version}
+
+
+ org.slf4j
+ slf4j-simple
+ ${org.slf4j.version}
+
+
+
UTF-8
- 1.8
- 1.8
+ 4.5.0.201609210915-r
-
-
- jgit-repository
- https://repo.eclipse.org/content/groups/releases/
-
-
-
-
-
- org.eclipse.jgit
- org.eclipse.jgit
- 4.5.0.201609210915-r
-
-
- org.eclipse.jgit
- org.eclipse.jgit.archive
- 4.5.0.201609210915-r
-
-
- commons-io
- commons-io
- 2.5
-
-
- org.slf4j
- slf4j-simple
- 1.7.21
-
-
\ No newline at end of file
diff --git a/Twitter4J/pom.xml b/Twitter4J/pom.xml
index ae0efb487f..0b581a5d43 100644
--- a/Twitter4J/pom.xml
+++ b/Twitter4J/pom.xml
@@ -1,52 +1,52 @@
- 4.0.0
- com.mabsisa
- Twitter4J
- jar
- 1.0-SNAPSHOT
- Twitter4J
- http://maven.apache.org
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ 4.0.0
+ com.mabsisa
+ Twitter4J
+ jar
+ 1.0-SNAPSHOT
+ Twitter4J
+ http://maven.apache.org
+
com.baeldung
parent-modules
1.0.0-SNAPSHOT
-
-
-
- UTF-8
- UTF-8
- 1.8
-
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+
-
- org.twitter4j
- twitter4j-stream
- 4.0.6
-
+
+ org.twitter4j
+ twitter4j-stream
+ 4.0.6
+
-
+
- ${project.artifactId}
-
-
- src/main/resources
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
-
- **/ApplicationTest.java
-
-
-
-
-
+ ${project.artifactId}
+
+
+ src/main/resources
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+
+
+ **/ApplicationTest.java
+
+
+
+
+
diff --git a/activejdbc/README.md b/activejdbc/README.md
new file mode 100644
index 0000000000..0f4cefb8df
--- /dev/null
+++ b/activejdbc/README.md
@@ -0,0 +1,2 @@
+### Relevant Articles:
+- [Introduction to ActiveJDBC](http://www.baeldung.com/active-jdbc)
diff --git a/activejdbc/pom.xml b/activejdbc/pom.xml
index 3a3a711d05..f6e21edeb1 100644
--- a/activejdbc/pom.xml
+++ b/activejdbc/pom.xml
@@ -1,5 +1,5 @@
+ 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
activejdbc
@@ -7,20 +7,52 @@
jar
activejdbc
http://maven.apache.org
-
- UTF-8
- 1.4.13
- development.test,development
-
+
+
+ parent-modules
+ com.baeldung
+ 1.0.0-SNAPSHOT
+
+
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+ org.javalite
+ activejdbc
+ ${activejdbc.version}
+
+
+ opensymphony
+ oscache
+
+
+
+
+ mysql
+ mysql-connector-java
+ ${mysql.connector.version}
+
+
+ org.slf4j
+ slf4j-simple
+ ${org.slf4j.version}
+
+
+
org.apache.maven.plugins
maven-compiler-plugin
- 3.6.0
+ ${maven-compiler-plugin.version}
- 1.8
- 1.8
+ ${java.version}
+ ${java.version}
UTF-8
@@ -49,14 +81,14 @@
mysql
mysql-connector-java
- 5.1.34
+ ${mysql.connector.version}
org.apache.maven.plugins
maven-surefire-plugin
- 2.18.1
+ ${maven-surefire-plugin.version}
brief
true
@@ -73,35 +105,7 @@
-
-
- junit
- junit
- 4.12
- test
-
-
- org.javalite
- activejdbc
- ${activejdbc.version}
-
-
- opensymphony
- oscache
-
-
-
-
- mysql
- mysql-connector-java
- 5.1.34
-
-
- org.slf4j
- slf4j-simple
- 1.7.9
-
-
+
snapshots1
@@ -114,6 +118,7 @@
+
snapshots2
@@ -126,4 +131,13 @@
-
+
+
+ UTF-8
+ 1.4.13
+ development.test,development
+ 1.7.9
+ 5.1.34
+
+
+
\ No newline at end of file
diff --git a/akka-streams/pom.xml b/akka-streams/pom.xml
index b1471641f7..3142e4e68a 100644
--- a/akka-streams/pom.xml
+++ b/akka-streams/pom.xml
@@ -1,15 +1,15 @@
-
+ 4.0.0
+ akka-streams
+ akka-streams
+
parent-modules
com.baeldung
1.0.0-SNAPSHOT
- 4.0.0
- akka-streams
- akka-streams
@@ -23,6 +23,7 @@
${akkastreams.version}
+
2.5.2
diff --git a/algorithms/README.md b/algorithms/README.md
index 31cb8076d9..df445146d9 100644
--- a/algorithms/README.md
+++ b/algorithms/README.md
@@ -17,3 +17,7 @@
- [How to Calculate Levenshtein Distance in Java?](http://www.baeldung.com/java-levenshtein-distance)
- [How to Find the Kth Largest Element in Java](http://www.baeldung.com/java-kth-largest-element)
- [Multi-Swarm Optimization Algorithm in Java](http://www.baeldung.com/java-multi-swarm-algorithm)
+- [A Maze Solver in Java](http://www.baeldung.com/java-solve-maze)
+- [Create a Sudoku Solver in Java](http://www.baeldung.com/java-sudoku)
+- [Displaying Money Amounts in Words](http://www.baeldung.com/java-money-into-words)
+- [A Collaborative Filtering Recommendation System in Java](http://www.baeldung.com/java-collaborative-filtering-recommendations)
diff --git a/algorithms/pom.xml b/algorithms/pom.xml
index 8751cf45c0..fdc8931f04 100644
--- a/algorithms/pom.xml
+++ b/algorithms/pom.xml
@@ -1,17 +1,10 @@
+ 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
algorithms
0.0.1-SNAPSHOT
-
- 1.5.0
- 1.16.12
- 3.6.1
- 1.0.1
-
-
com.baeldung
parent-modules
@@ -33,12 +26,12 @@
io.jenetics
jenetics
- 3.7.0
+ ${io.jenetics.version}
org.jgrapht
jgrapht-core
- 1.0.1
+ ${org.jgrapht.core.version}
pl.allegro.finance
@@ -48,10 +41,11 @@
org.assertj
assertj-core
- 3.9.0
+ ${org.assertj.core.version}
test
+
@@ -63,6 +57,7 @@
+
@@ -82,4 +77,15 @@
+
+
+ 1.5.0
+ 1.16.12
+ 3.6.1
+ 1.0.1
+ 3.7.0
+ 1.0.1
+ 3.9.0
+
+
\ No newline at end of file
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/RunAlgorithm.java b/algorithms/src/main/java/com/baeldung/algorithms/RunAlgorithm.java
index 6ab7dbb4e5..c82883425d 100644
--- a/algorithms/src/main/java/com/baeldung/algorithms/RunAlgorithm.java
+++ b/algorithms/src/main/java/com/baeldung/algorithms/RunAlgorithm.java
@@ -6,6 +6,7 @@ import com.baeldung.algorithms.ga.annealing.SimulatedAnnealing;
import com.baeldung.algorithms.ga.ant_colony.AntColonyOptimization;
import com.baeldung.algorithms.ga.binary.SimpleGeneticAlgorithm;
import com.baeldung.algorithms.slope_one.SlopeOne;
+import com.baeldung.algorithms.pairsaddupnumber.FindPairs;
public class RunAlgorithm {
@@ -17,6 +18,7 @@ public class RunAlgorithm {
System.out.println("3 - Simple Genetic Algorithm");
System.out.println("4 - Ant Colony");
System.out.println("5 - Dijkstra");
+ System.out.println("6 - All pairs in an array that add up to a given sum");
int decision = in.nextInt();
switch (decision) {
case 1:
@@ -37,6 +39,12 @@ public class RunAlgorithm {
case 5:
System.out.println("Please run the DijkstraAlgorithmTest.");
break;
+ case 6:
+ final FindPairs findPairs = new FindPairs();
+ final int[] input = {1, 4, 3, 2, 1, 4, 4, 3, 3};
+ final int sum = 6;
+ findPairs.execute(input, sum);
+ break;
default:
System.out.println("Unknown option");
break;
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/pairsaddupnumber/DifferentPairs.java b/algorithms/src/main/java/com/baeldung/algorithms/pairsaddupnumber/DifferentPairs.java
new file mode 100644
index 0000000000..e86e1d5a22
--- /dev/null
+++ b/algorithms/src/main/java/com/baeldung/algorithms/pairsaddupnumber/DifferentPairs.java
@@ -0,0 +1,72 @@
+package com.baeldung.algorithms.pairsaddupnumber;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.IntStream;
+
+/**
+ * Find all different pairs of numbers in an array that add up to a given sum - Complexity O(n)
+ */
+public class DifferentPairs {
+
+ /**
+ * Show all different pairs using traditional "for" loop
+ *
+ * @param input - number's array
+ * @param sum - given sum
+ * @return - number's array with all existing pairs. This list will contain just one pair's element because
+ * the other one can be calculated with SUM - element_1 = element_2
+ */
+ public static List findPairsWithForLoop(int[] input, int sum) {
+ final List allDifferentPairs = new ArrayList<>();
+ // Aux. hash map
+ final Map pairs = new HashMap();
+ for (int i : input) {
+ if (pairs.containsKey(i)) {
+ if (pairs.get(i) != null) {
+ // Add pair to returned list
+ allDifferentPairs.add(i);
+ }
+ // Mark pair as added to prevent duplicates
+ pairs.put(sum - i, null);
+ } else if (!pairs.containsValue(i)) {
+ // Add pair to aux. hash map
+ pairs.put(sum - i, i);
+ }
+ }
+ return allDifferentPairs;
+ }
+
+ /**
+ * Show all different pairs using Java 8 stream API
+ *
+ * @param input - number's array
+ * @param sum - given sum
+ * @return - number's array with all existing pairs. This list will contain just one pair's element because
+ * the other one can be calculated with SUM - element_1 = element_2
+ */
+ public static List findPairsWithStreamApi(int[] input, int sum) {
+ final List allDifferentPairs = new ArrayList<>();
+ // Aux. hash map
+ final Map pairs = new HashMap();
+ IntStream.range(0, input.length).forEach(i -> {
+ if (pairs.containsKey(input[i])) {
+ if (pairs.get(input[i]) != null) {
+ // Add pair to returned list
+ allDifferentPairs.add(input[i]);
+ }
+ // Mark pair as added to prevent duplicates
+ pairs.put(sum - input[i], null);
+ } else if (!pairs.containsValue(input[i])) {
+ // Add pair to aux. hash map
+ pairs.put(sum - input[i], input[i]);
+ }
+ }
+ );
+ return allDifferentPairs;
+ }
+}
+
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/pairsaddupnumber/ExistingPairs.java b/algorithms/src/main/java/com/baeldung/algorithms/pairsaddupnumber/ExistingPairs.java
new file mode 100644
index 0000000000..6b10c73bcf
--- /dev/null
+++ b/algorithms/src/main/java/com/baeldung/algorithms/pairsaddupnumber/ExistingPairs.java
@@ -0,0 +1,51 @@
+package com.baeldung.algorithms.pairsaddupnumber;
+
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.IntStream;
+
+/**
+ * Find all existing pairs of numbers in an array that add up to a given sum - Complexity O(n^2) "Brute force"
+ */
+public class ExistingPairs {
+
+ /**
+ * Show all existing pairs using traditional "for" loop
+ *
+ * @param input - number's array
+ * @param sum - given sum
+ * @return - number's array with all existing pairs. This list will contain just one pair's element because
+ * the other one can be calculated with SUM - element_1 = element_2
+ */
+ public static List findPairsWithForLoop(int[] input, int sum) {
+ final List allExistingPairs = new ArrayList<>();
+ for (int i = 0; i < input.length; i++) {
+ for (int j = 0; j < input.length; j++) {
+ if (j != i && (input[i] + input[j]) == sum) {
+ allExistingPairs.add(input[i]);
+ }
+ }
+ }
+ return allExistingPairs;
+ }
+
+ /**
+ * Show all existing pairs using Java 8 stream API
+ *
+ * @param input - number's array
+ * @param sum - given sum
+ * @return - number's array with all existing pairs. This list will contain just one pair's element because
+ * the other one can be calculated with SUM - element_1 = element_2
+ */
+ public static List findPairsWithStreamApi(int[] input, int sum) {
+ final List allExistingPairs = new ArrayList<>();
+ IntStream.range(0, input.length).forEach(i ->
+ IntStream.range(0, input.length)
+ .filter(j -> i != j && input[i] + input[j] == sum)
+ .forEach(j -> allExistingPairs.add(input[i]))
+ );
+ return allExistingPairs;
+ }
+}
+
diff --git a/algorithms/src/main/java/com/baeldung/algorithms/pairsaddupnumber/FindPairs.java b/algorithms/src/main/java/com/baeldung/algorithms/pairsaddupnumber/FindPairs.java
new file mode 100644
index 0000000000..4b309332ae
--- /dev/null
+++ b/algorithms/src/main/java/com/baeldung/algorithms/pairsaddupnumber/FindPairs.java
@@ -0,0 +1,74 @@
+package com.baeldung.algorithms.pairsaddupnumber;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.IntStream;
+
+
+public class FindPairs {
+
+ public void execute(int[] input, int sum) {
+ final StringBuilder inputArray = new StringBuilder();
+ inputArray.append("{");
+ IntStream.range(0, input.length).forEach(i -> inputArray.append(input[i] + ", "));
+ inputArray.append("}");
+ System.out.println(" Given number array: " + inputArray.toString());
+ System.out.println(" Given sum: " + sum);
+ /* Call services */
+ getDifferentPairs(input, sum);
+ getExistingPairs(input, sum);
+ }
+
+ /**
+ * Print all existing pairs for the given inputs: input array & sum number
+ */
+ private static void getExistingPairs(int[] input, int sum) {
+ List pairs = new ArrayList<>();
+ System.out.println("~ All existing pairs ~");
+
+ /* Traditional FOR loop */
+ // Call method
+ pairs = ExistingPairs.findPairsWithForLoop(input, sum);
+ // Create a pretty printing
+ final StringBuilder output1 = new StringBuilder();
+ pairs.forEach((pair) -> output1.append("{" + pair + ", " + (sum - pair) + "}, "));
+ // Print result
+ System.out.println("Traditional \"for\" loop: " + output1.toString().substring(0, output1.length() - 2));
+
+ /* Java 8 stream API */
+ // Call the method
+ pairs = ExistingPairs.findPairsWithStreamApi(input, sum);
+ // Create a pretty printing
+ final StringBuilder output2 = new StringBuilder();
+ pairs.forEach((pair) -> output2.append("{" + pair + ", " + (sum - pair) + "}, "));
+ // Print result
+ System.out.println("Java 8 streams API: " + output2.toString().substring(0, output2.length() - 2));
+ }
+
+ /**
+ * Print all different pairs for the given inputs: input array & sum number
+ */
+ private static void getDifferentPairs(int[] input, int sum) {
+ List pairs = new ArrayList<>();
+ System.out.println("~ All different pairs ~");
+
+ /* Traditional FOR loop */
+ // Call method
+ pairs = DifferentPairs.findPairsWithForLoop(input, sum);
+ // Create a pretty printing
+ final StringBuilder output3 = new StringBuilder();
+ pairs.forEach((pair) -> output3.append("{" + pair + ", " + (sum - pair) + "}, "));
+ // Print result
+ System.out.println("Traditional \"for\" loop: " + output3.toString().substring(0, output3.length() - 2));
+
+ /* Java 8 stream API */
+ // Call method
+ pairs = DifferentPairs.findPairsWithStreamApi(input, sum);
+ // Create a pretty printing
+ final StringBuilder output4 = new StringBuilder();
+ pairs.forEach((pair) -> output4.append("{" + pair + ", " + (sum - pair) + "}, "));
+ // Print result
+ System.out.println("Java 8 streams API: " + output4.toString().substring(0, output4.length() - 2));
+ }
+}
+
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/pairsaddupnumber/DifferentPairsUnitTest.java b/algorithms/src/test/java/com/baeldung/algorithms/pairsaddupnumber/DifferentPairsUnitTest.java
new file mode 100644
index 0000000000..48fcfb871c
--- /dev/null
+++ b/algorithms/src/test/java/com/baeldung/algorithms/pairsaddupnumber/DifferentPairsUnitTest.java
@@ -0,0 +1,39 @@
+package com.baeldung.algorithms.pairsaddupnumber;
+
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class DifferentPairsUnitTest {
+
+ /* All different pairs */
+
+ @Test
+ public void whenTraditionalLoop_thenReturnAllDifferentPairs() {
+ /* Data */
+ final int[] input = {2, 4, 3, 3, 8};
+ final int sum = 6;
+ /* Call service */
+ final List pairs = DifferentPairs.findPairsWithForLoop(input, sum);
+ /* Check results */
+ assertThat(pairs).hasSize(2).contains(4,3).doesNotContain(8);
+ }
+
+ @Test
+ public void whenStreamApi_thenReturnAllDifferentPairs() {
+ /* Data */
+ final int[] input = {2, 4, 3, 3, 8};
+ final int sum = 6;
+ /* Call service */
+ final List pairs = DifferentPairs.findPairsWithStreamApi(input, sum);
+ /* Check results */
+ assertNotNull(pairs);
+ assertEquals(pairs.size(),2);
+ assertEquals(pairs.get(0), new Integer(4));
+ assertThat(pairs).hasSize(2).contains(4,3).doesNotContain(8);
+ }
+}
diff --git a/algorithms/src/test/java/com/baeldung/algorithms/pairsaddupnumber/ExistingPairsUnitTest.java b/algorithms/src/test/java/com/baeldung/algorithms/pairsaddupnumber/ExistingPairsUnitTest.java
new file mode 100644
index 0000000000..ac6d6cc885
--- /dev/null
+++ b/algorithms/src/test/java/com/baeldung/algorithms/pairsaddupnumber/ExistingPairsUnitTest.java
@@ -0,0 +1,34 @@
+package com.baeldung.algorithms.pairsaddupnumber;
+
+import org.junit.Test;
+import java.util.List;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+
+public class ExistingPairsUnitTest {
+
+ /* All existing pairs */
+
+ @Test
+ public void whenTraditionalLoop_thenReturnAllExistingPairs() {
+ /* Data */
+ final int[] input = {2, 4, 3, 3, 8};
+ final int sum = 6;
+ /* Call service */
+ final List pairs = ExistingPairs.findPairsWithForLoop(input, sum);
+ /* Check results */
+ assertThat(pairs).hasSize(4).contains(2,4,3,3).doesNotContain(8);
+ }
+
+ @Test
+ public void whenStreamApi_thenReturnAllExistingPairs() {
+ /* Data */
+ final int[] input = {2, 4, 3, 3, 8};
+ final int sum = 6;
+ /* Call service */
+ final List pairs = ExistingPairs.findPairsWithStreamApi(input, sum);
+ /* Check results */
+ assertThat(pairs).hasSize(4).contains(2,4,3,3).doesNotContain(8);
+ }
+}
diff --git a/animal-sniffer-mvn-plugin/pom.xml b/animal-sniffer-mvn-plugin/pom.xml
index 2356c7d5a2..ab7b38f6e0 100644
--- a/animal-sniffer-mvn-plugin/pom.xml
+++ b/animal-sniffer-mvn-plugin/pom.xml
@@ -1,57 +1,56 @@
- 4.0.0
- com.baeldung
- animal-sniffer-mvn-plugin
- jar
- 1.0-SNAPSHOT
- example-animal-sniffer-mvn-plugin
- http://maven.apache.org
-
-
- 3.7.0
-
-
-
-
- junit
- junit
- 3.8.1
- test
-
-
-
-
-
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
- org.codehaus.mojo
- animal-sniffer-maven-plugin
- 1.16
-
-
- org.codehaus.mojo.signature
- java16
- 1.0
-
-
-
-
- animal-sniffer
- verify
-
- check
-
-
-
-
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ 4.0.0
+ com.baeldung
+ animal-sniffer-mvn-plugin
+ jar
+ 1.0-SNAPSHOT
+ example-animal-sniffer-mvn-plugin
+ http://maven.apache.org
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+
+
+
+
+ org.codehaus.mojo
+ animal-sniffer-maven-plugin
+ ${animal-sniffer-maven-plugin.version}
+
+
+ org.codehaus.mojo.signature
+ java16
+ ${org.codehaus.mojo.signature.java16.version}
+
+
+
+
+ animal-sniffer
+ verify
+
+ check
+
+
+
+
+
+
+
+ 1.16
+ 1.0
+
\ No newline at end of file
diff --git a/annotations/annotation-processing/pom.xml b/annotations/annotation-processing/pom.xml
index b5219d57ba..39a644905d 100644
--- a/annotations/annotation-processing/pom.xml
+++ b/annotations/annotation-processing/pom.xml
@@ -1,8 +1,9 @@
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
+ annotation-processing
com.baeldung
@@ -11,40 +12,17 @@
../
- annotation-processing
-
-
- 1.0-rc2
- 3.7.0
-
-
-
com.google.auto.service
auto-service
${auto-service.version}
provided
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
- 1.8
- 1.8
-
-
-
-
-
-
+
+ 1.0-rc2
+
\ No newline at end of file
diff --git a/annotations/annotation-user/pom.xml b/annotations/annotation-user/pom.xml
index eb827b2ea5..5a00951a18 100644
--- a/annotations/annotation-user/pom.xml
+++ b/annotations/annotation-user/pom.xml
@@ -1,7 +1,8 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
+ annotation-user
annotations
@@ -10,16 +11,12 @@
../
- annotation-user
-
-
com.baeldung
annotation-processing
${project.parent.version}
-
\ No newline at end of file
diff --git a/annotations/pom.xml b/annotations/pom.xml
index 0ddc17f8a7..52508e5bfc 100644
--- a/annotations/pom.xml
+++ b/annotations/pom.xml
@@ -1,15 +1,15 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ annotations
+ pom
+
parent-modules
com.baeldung
1.0.0-SNAPSHOT
- 4.0.0
-
- annotations
- pom
annotation-processing
diff --git a/apache-bval/pom.xml b/apache-bval/pom.xml
index 1cc0a33702..f8a3b8279d 100644
--- a/apache-bval/pom.xml
+++ b/apache-bval/pom.xml
@@ -1,34 +1,37 @@
- 4.0.0
- apache-bval
- apache-bval
- 0.0.1-SNAPSHOT
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ apache-bval
+ apache-bval
+ 0.0.1-SNAPSHOT
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
-
-
- org.apache.bval
- bval-jsr
- ${bval.version}
-
-
- javax.validation
- validation-api
- 1.1.0.Final
-
-
- org.apache.bval
- bval-extras
- ${bval.version}
-
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+
+ org.apache.bval
+ bval-jsr
+ ${bval.version}
+
+
+ javax.validation
+ validation-api
+ ${javax.validation.validation-api.version}
+
+
+ org.apache.bval
+ bval-extras
+ ${bval.version}
+
+
+
+
+ 1.1.2
+ 1.1.0.Final
+
-
- 1.1.2
-
\ No newline at end of file
diff --git a/apache-cayenne/pom.xml b/apache-cayenne/pom.xml
index 52631e8594..fc16db3c81 100644
--- a/apache-cayenne/pom.xml
+++ b/apache-cayenne/pom.xml
@@ -1,42 +1,32 @@
- 4.0.0
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
- apache-cayenne
- 0.0.1-SNAPSHOT
- jar
+ apache-cayenne
+ 0.0.1-SNAPSHOT
+ jar
+ apache-cayenne
+ Introduction to Apache Cayenne
- apache-cayenne
- Introduction to Apache Cayenne
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
-
-
- UTF-8
- UTF-8
- 1.8
- 5.1.44
- 4.0.M5
- 4.12
-
-
-
-
- org.apache.cayenne
- cayenne-server
- ${cayenne.version}
-
-
- mysql
- mysql-connector-java
- ${mysql.connector.version}
- runtime
-
+
+
+ org.apache.cayenne
+ cayenne-server
+ ${cayenne.version}
+
+
+ mysql
+ mysql-connector-java
+ ${mysql.connector.version}
+ runtime
+
junit
@@ -46,14 +36,23 @@
-
-
+
+
org.apache.cayenne.plugins
cayenne-modeler-maven-plugin
${cayenne.version}
-
-
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 5.1.44
+ 4.0.M5
+ 4.12
+
diff --git a/apache-cayenne/src/test/java/com/baeldung/apachecayenne/CayenneAdvancedOperationTests.java b/apache-cayenne/src/test/java/com/baeldung/apachecayenne/CayenneAdvancedOperationIntegrationTest.java
similarity index 99%
rename from apache-cayenne/src/test/java/com/baeldung/apachecayenne/CayenneAdvancedOperationTests.java
rename to apache-cayenne/src/test/java/com/baeldung/apachecayenne/CayenneAdvancedOperationIntegrationTest.java
index cd563b6270..546b8fe45c 100644
--- a/apache-cayenne/src/test/java/com/baeldung/apachecayenne/CayenneAdvancedOperationTests.java
+++ b/apache-cayenne/src/test/java/com/baeldung/apachecayenne/CayenneAdvancedOperationIntegrationTest.java
@@ -19,7 +19,7 @@ import java.util.List;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-public class CayenneAdvancedOperationTests {
+public class CayenneAdvancedOperationIntegrationTest {
private static ObjectContext context = null;
@BeforeClass
diff --git a/apache-cayenne/src/test/java/com/baeldung/apachecayenne/CayenneOperationTests.java b/apache-cayenne/src/test/java/com/baeldung/apachecayenne/CayenneOperationIntegrationTest.java
similarity index 98%
rename from apache-cayenne/src/test/java/com/baeldung/apachecayenne/CayenneOperationTests.java
rename to apache-cayenne/src/test/java/com/baeldung/apachecayenne/CayenneOperationIntegrationTest.java
index 8a0d210d8d..85f06d5538 100644
--- a/apache-cayenne/src/test/java/com/baeldung/apachecayenne/CayenneOperationTests.java
+++ b/apache-cayenne/src/test/java/com/baeldung/apachecayenne/CayenneOperationIntegrationTest.java
@@ -16,7 +16,7 @@ import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-public class CayenneOperationTests {
+public class CayenneOperationIntegrationTest {
private static ObjectContext context = null;
@BeforeClass
diff --git a/apache-curator/README.md b/apache-curator/README.md
new file mode 100644
index 0000000000..9bda573292
--- /dev/null
+++ b/apache-curator/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles:
+
+- [Introduction to Apache Curator](http://www.baeldung.com/apache-curator)
diff --git a/apache-curator/pom.xml b/apache-curator/pom.xml
index 35549861c8..d867d7e74b 100644
--- a/apache-curator/pom.xml
+++ b/apache-curator/pom.xml
@@ -1,31 +1,18 @@
- 4.0.0
- apache-curator
- 0.0.1-SNAPSHOT
- jar
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ apache-curator
+ 0.0.1-SNAPSHOT
+ jar
+
com.baeldung
parent-modules
1.0.0-SNAPSHOT
-
-
- 4.0.1
- 3.4.11
- 2.9.4
-
- 3.6.1
- 1.7.0
-
-
-
-
-
+
-
org.apache.curator
curator-x-async
@@ -37,40 +24,44 @@
-
org.apache.curator
curator-recipes
${curator.version}
-
org.apache.zookeeper
zookeeper
${zookeeper.version}
-
com.fasterxml.jackson.core
jackson-databind
${jackson-databind.version}
-
-
org.assertj
assertj-core
${assertj.version}
test
-
com.jayway.awaitility
awaitility
${avaitility.version}
test
-
-
+
+
+
+ 4.0.1
+ 3.4.11
+ 2.9.4
+
+ 3.6.1
+ 1.7.0
+
+
+
\ No newline at end of file
diff --git a/apache-cxf/cxf-aegis/pom.xml b/apache-cxf/cxf-aegis/pom.xml
index 6d8aa85679..338860472c 100644
--- a/apache-cxf/cxf-aegis/pom.xml
+++ b/apache-cxf/cxf-aegis/pom.xml
@@ -1,15 +1,14 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
cxf-aegis
+
com.baeldung
apache-cxf
0.0.1-SNAPSHOT
-
- 3.1.8
-
+
org.apache.cxf
@@ -17,4 +16,9 @@
${cxf.version}
+
+
+ 3.1.8
+
+
diff --git a/apache-cxf/cxf-introduction/pom.xml b/apache-cxf/cxf-introduction/pom.xml
index 1b9ba22230..3c44734733 100644
--- a/apache-cxf/cxf-introduction/pom.xml
+++ b/apache-cxf/cxf-introduction/pom.xml
@@ -1,7 +1,7 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
cxf-introduction
@@ -11,32 +11,6 @@
0.0.1-SNAPSHOT
-
- 3.1.8
- 2.19.1
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
-
- com.baeldung.cxf.introduction.Server
-
-
-
- maven-surefire-plugin
- ${surefire.version}
-
-
- **/*LiveTest.java
-
-
-
-
-
-
org.apache.cxf
@@ -50,4 +24,21 @@
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+
+ com.baeldung.cxf.introduction.Server
+
+
+
+
+
+
+ 3.1.8
+ 2.19.1
+
+
diff --git a/apache-cxf/cxf-jaxrs-implementation/pom.xml b/apache-cxf/cxf-jaxrs-implementation/pom.xml
index 981e0ef7aa..ce35d67948 100644
--- a/apache-cxf/cxf-jaxrs-implementation/pom.xml
+++ b/apache-cxf/cxf-jaxrs-implementation/pom.xml
@@ -1,7 +1,7 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
cxf-jaxrs-implementation
@@ -11,34 +11,6 @@
0.0.1-SNAPSHOT
-
- UTF-8
- 3.1.8
- 4.5.2
- 2.19.1
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
-
- com.baeldung.cxf.jaxrs.implementation.RestfulServer
-
-
-
- maven-surefire-plugin
- ${surefire.version}
-
-
- **/*LiveTest.java
-
-
-
-
-
-
org.apache.cxf
@@ -62,4 +34,24 @@
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+
+ com.baeldung.cxf.jaxrs.implementation.RestfulServer
+
+
+
+
+
+
+ UTF-8
+ 3.1.8
+ 4.5.2
+ 2.19.1
+
+
diff --git a/apache-cxf/cxf-spring/pom.xml b/apache-cxf/cxf-spring/pom.xml
index 2cd700680b..a06165f4ad 100644
--- a/apache-cxf/cxf-spring/pom.xml
+++ b/apache-cxf/cxf-spring/pom.xml
@@ -1,8 +1,9 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
cxf-spring
war
+
com.baeldung
apache-cxf
@@ -52,15 +53,6 @@
false
-
- maven-surefire-plugin
- ${surefire.version}
-
-
- **/*LiveTest.java
-
-
-
@@ -102,24 +94,6 @@
-
-
- maven-surefire-plugin
- ${surefire.version}
-
-
- integration-test
-
- test
-
-
-
- none
-
-
-
-
-
@@ -130,7 +104,6 @@
3.1.8
4.3.4.RELEASE
3.1.0
-
2.6
2.19.1
1.6.1
diff --git a/apache-cxf/pom.xml b/apache-cxf/pom.xml
index 3bc3853f2b..5a864b18ef 100644
--- a/apache-cxf/pom.xml
+++ b/apache-cxf/pom.xml
@@ -1,5 +1,5 @@
+ 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
apache-cxf
@@ -19,10 +19,6 @@
cxf-aegis
-
- 1.5.0
-
-
install
@@ -35,4 +31,9 @@
+
+
+ 1.5.0
+
+
diff --git a/apache-fop/pom.xml b/apache-fop/pom.xml
index f7439dc244..d0c6984757 100644
--- a/apache-fop/pom.xml
+++ b/apache-fop/pom.xml
@@ -1,10 +1,9 @@
+ 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
apache-fop
0.1-SNAPSHOT
-
apache-fop
@@ -61,7 +60,7 @@
org.dbdoclet
herold
- 8.0.4
+ ${org.dbdoclet.herold.version}
@@ -69,7 +68,6 @@
jtidy
${jtidy.version}
-
@@ -82,47 +80,12 @@
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*ManualTest.java
-
-
- **/*IntegrationTest.java
- **/*LiveTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
-
1.1
4.3
8.0.2
r938
+ 8.0.4
\ No newline at end of file
diff --git a/apache-opennlp/pom.xml b/apache-opennlp/pom.xml
index be4d7e3e54..4095207aab 100644
--- a/apache-opennlp/pom.xml
+++ b/apache-opennlp/pom.xml
@@ -1,32 +1,40 @@
-
+
4.0.0
+ apache-opennlp
+ 1.0-SNAPSHOT
+ jar
+
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- apache-opennlp
- 1.0-SNAPSHOT
- jar
-
+
org.apache.opennlp
opennlp-tools
- 1.8.4
+ ${org.apache.opennlp.opennlp-tools.version}
org.assertj
assertj-core
- 3.9.0
+ ${org.assertj.version}
test
junit
junit
- 4.12
+ ${junit.version}
test
+
+
+ 3.9.0
+ 1.8.4
+
+
\ No newline at end of file
diff --git a/apache-opennlp/src/test/java/com/baeldung/apache/opennlp/LanguageDetectorAndTrainingDataTest.java b/apache-opennlp/src/test/java/com/baeldung/apache/opennlp/LanguageDetectorAndTrainingDataTest.java
index d9c18862e8..5eb649dae1 100644
--- a/apache-opennlp/src/test/java/com/baeldung/apache/opennlp/LanguageDetectorAndTrainingDataTest.java
+++ b/apache-opennlp/src/test/java/com/baeldung/apache/opennlp/LanguageDetectorAndTrainingDataTest.java
@@ -16,6 +16,7 @@ import opennlp.tools.util.ObjectStream;
import opennlp.tools.util.PlainTextByLineStream;
import opennlp.tools.util.TrainingParameters;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.tuple;
import org.junit.Test;
public class LanguageDetectorAndTrainingDataTest {
@@ -35,7 +36,9 @@ public class LanguageDetectorAndTrainingDataTest {
LanguageDetector ld = new LanguageDetectorME(model);
Language[] languages = ld.predictLanguages("estava em uma marcenaria na Rua Bruno");
- assertThat(Arrays.asList(languages).toString()).contains("pob (0.9999999950605625)", "ita (4.939427661577956E-9)", "spa (9.665954064665144E-15)",
- "fra (8.250349924885834E-25)");
+
+ assertThat(Arrays.asList(languages)).extracting("lang", "confidence").contains(tuple("pob", 0.9999999950605625),
+ tuple("ita", 4.939427661577956E-9), tuple("spa", 9.665954064665144E-15),
+ tuple("fra", 8.250349924885834E-25));
}
}
diff --git a/apache-poi/README.md b/apache-poi/README.md
index c052bc9bf6..862981991d 100644
--- a/apache-poi/README.md
+++ b/apache-poi/README.md
@@ -1,4 +1,4 @@
### Relevant Articles:
- [Microsoft Word Processing in Java with Apache POI](http://www.baeldung.com/java-microsoft-word-with-apache-poi)
- [Working with Microsoft Excel in Java](http://www.baeldung.com/java-microsoft-excel)
-- [Creating a MS PowerPoint Presentation in Java](https://github.com/eugenp/tutorials/tree/master/apache-poi)
+- [Creating a MS PowerPoint Presentation in Java](http://www.baeldung.com/apache-poi-slideshow)
diff --git a/apache-poi/pom.xml b/apache-poi/pom.xml
index 22c0cd156a..4874fe0b3e 100644
--- a/apache-poi/pom.xml
+++ b/apache-poi/pom.xml
@@ -1,5 +1,5 @@
+ 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
apache-poi
@@ -11,11 +11,6 @@
1.0.0-SNAPSHOT
-
- 3.15
- 1.0.6
-
-
org.apache.poi
@@ -34,4 +29,10 @@
+
+
+ 3.15
+ 1.0.6
+
+
diff --git a/apache-shiro/pom.xml b/apache-shiro/pom.xml
index 2c5ef86837..73fdcab9d2 100644
--- a/apache-shiro/pom.xml
+++ b/apache-shiro/pom.xml
@@ -3,7 +3,6 @@
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
apache-shiro
1.0-SNAPSHOT
@@ -11,15 +10,9 @@
org.springframework.boot
spring-boot-starter-parent
- 1.5.2.RELEASE
+ ${org.springframework.boot.spring-boot-starter-parent.version}
-
- 1.4.0
- 1.2.17
- 1.7.25
-
-
org.springframework.boot
@@ -57,7 +50,6 @@
${log4j-version}
runtime
-
@@ -74,5 +66,11 @@
-
+
+ 1.4.0
+ 1.2.17
+ 1.7.25
+ 1.5.2.RELEASE
+
+
\ No newline at end of file
diff --git a/apache-solrj/pom.xml b/apache-solrj/pom.xml
index ea696b024b..31639c4864 100644
--- a/apache-solrj/pom.xml
+++ b/apache-solrj/pom.xml
@@ -1,5 +1,5 @@
+ 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
apache-solrj
@@ -17,7 +17,12 @@
org.apache.solr
solr-solrj
- 6.4.0
+ ${org.apache.solr.solr-solrj.version}
+
+
+ 6.4.0
+
+
\ No newline at end of file
diff --git a/apache-spark/pom.xml b/apache-spark/pom.xml
index 1f95150ee7..3627f58147 100644
--- a/apache-spark/pom.xml
+++ b/apache-spark/pom.xml
@@ -1,44 +1,37 @@
- 4.0.0
+ 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
+ apache-spark
+ 1.0-SNAPSHOT
+ jar
+ apache-spark
+ http://maven.apache.org
- com.baeldung
- apache-spark
- 1.0-SNAPSHOT
- jar
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
- apache-spark
- http://maven.apache.org
+
+
+
+ org.apache.spark
+ spark-core_2.10
+ ${org.apache.spark.spark-core.version}
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
-
- UTF-8
-
+
+ UTF-8
+ 2.2.0
+
-
-
-
- org.apache.spark
- spark-core_2.10
- 2.2.0
-
-
- junit
- junit
- 3.8.1
- test
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
-
diff --git a/apache-thrift/pom.xml b/apache-thrift/pom.xml
index 91e51a7092..272bbb98d7 100644
--- a/apache-thrift/pom.xml
+++ b/apache-thrift/pom.xml
@@ -1,5 +1,5 @@
+ 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
apache-thrift
@@ -12,12 +12,6 @@
1.0.0-SNAPSHOT
-
- 1.8
- 0.10.0
- 0.1.11
-
-
org.apache.thrift
@@ -34,7 +28,7 @@
org.slf4j
slf4j-simple
- 1.7.12
+ ${org.slf4j.slf4j-simple.version}
test
@@ -61,4 +55,11 @@
+
+
+ 0.10.0
+ 0.1.11
+ 1.7.12
+
+
diff --git a/apache-tika/README.md b/apache-tika/README.md
new file mode 100644
index 0000000000..b92a7bebf1
--- /dev/null
+++ b/apache-tika/README.md
@@ -0,0 +1,3 @@
+## Relevant articles:
+
+- [Content Analysis with Apache Tika](http://www.baeldung.com/apache-tika)
diff --git a/apache-tika/pom.xml b/apache-tika/pom.xml
index 34013dee89..27bb851174 100644
--- a/apache-tika/pom.xml
+++ b/apache-tika/pom.xml
@@ -1,5 +1,5 @@
+ 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
apache-tika
@@ -11,10 +11,6 @@
1.0.0-SNAPSHOT
-
- 1.17
-
-
org.apache.tika
@@ -22,4 +18,9 @@
${tika.version}
+
+
+ 1.17
+
+
\ No newline at end of file
diff --git a/apache-velocity/pom.xml b/apache-velocity/pom.xml
index 69633ebbab..efacdff25a 100644
--- a/apache-velocity/pom.xml
+++ b/apache-velocity/pom.xml
@@ -1,11 +1,9 @@
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
com.baeldung
0.1-SNAPSHOT
apache-velocity
-
war
apache-velocity
@@ -15,15 +13,6 @@
1.0.0-SNAPSHOT
-
- 1.8
- 1.2
- 2.6
- 4.5.2
- 1.7
- 2.0
-
-
org.apache.velocity
@@ -48,6 +37,7 @@
+
apache-velocity
@@ -67,4 +57,13 @@
-
+
+
+ 1.2
+ 2.6
+ 4.5.2
+ 1.7
+ 2.0
+
+
+
\ No newline at end of file
diff --git a/apache-zookeeper/README.md b/apache-zookeeper/README.md
new file mode 100644
index 0000000000..6bddcfd5a8
--- /dev/null
+++ b/apache-zookeeper/README.md
@@ -0,0 +1,3 @@
+## Relevant articles:
+
+- [Getting Started with Java and Zookeeper](http://www.baeldung.com/java-zookeeper)
diff --git a/apache-zookeeper/pom.xml b/apache-zookeeper/pom.xml
index b08da534a5..7e1960ebb0 100644
--- a/apache-zookeeper/pom.xml
+++ b/apache-zookeeper/pom.xml
@@ -1,23 +1,28 @@
- 4.0.0
+ 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
+ apache-zookeeper
+ 0.0.1-SNAPSHOT
+ jar
+
+
com.baeldung
- apache-zookeeper
- 0.0.1-SNAPSHOT
- jar
+ parent-modules
+ 1.0.0-SNAPSHOT
+
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
+
+
+ org.apache.zookeeper
+ zookeeper
+ ${org.apache.zookeeper.version}
+
+
+
+
+ 3.4.11
+
-
-
- org.apache.zookeeper
- zookeeper
- 3.4.11
-
-
diff --git a/asciidoctor/pom.xml b/asciidoctor/pom.xml
index a602cd11b9..6843b4da42 100644
--- a/asciidoctor/pom.xml
+++ b/asciidoctor/pom.xml
@@ -1,26 +1,40 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ asciidoctor
+ asciidoctor
+
parent-modules
com.baeldung
1.0.0-SNAPSHOT
- 4.0.0
- asciidoctor
- asciidoctor
+
+
+ org.asciidoctor
+ asciidoctorj
+ ${asciidoctorj.version}
+
+
+ org.asciidoctor
+ asciidoctorj-pdf
+ ${asciidoctorj-pdf.version}
+
+
+
org.asciidoctor
asciidoctor-maven-plugin
- 1.5.5
+ ${asciidoctor-maven-plugin.version}
org.asciidoctor
asciidoctorj-pdf
- 1.5.0-alpha.15
+ ${asciidoctorj-pdf.plugin.version}
@@ -46,16 +60,11 @@
-
-
- org.asciidoctor
- asciidoctorj
- 1.5.4
-
-
- org.asciidoctor
- asciidoctorj-pdf
- 1.5.0-alpha.11
-
-
+
+ 1.5.5
+ 1.5.4
+ 1.5.0-alpha.11
+ 1.5.0-alpha.15
+
+
diff --git a/asm/pom.xml b/asm/pom.xml
index ac0a6ccc6f..8c3aa379db 100644
--- a/asm/pom.xml
+++ b/asm/pom.xml
@@ -1,37 +1,37 @@
+ 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.examples
asm
1.0
jar
-
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
org.ow2.asm
asm
- 5.2
+ ${asm.version}
org.ow2.asm
asm-util
- 5.2
+ ${asm.version}
-
-
- UTF-8
- 1.8
- 1.8
-
-
+
org.apache.maven.plugins
maven-jar-plugin
- 2.4
+ ${maven-jar-plugin.version}
@@ -45,11 +45,19 @@
org.apache.maven.plugins
maven-surefire-plugin
- 2.9
+ ${maven-surefire-plugin.version}
-javaagent:"C:\asm-1.0.jar"
+
+
+ UTF-8
+ 5.2
+ 2.4
+ 2.9
+
+
\ No newline at end of file
diff --git a/atomix/pom.xml b/atomix/pom.xml
index 80c573dd86..e41e60138d 100644
--- a/atomix/pom.xml
+++ b/atomix/pom.xml
@@ -15,32 +15,24 @@
io.atomix
atomix-all
- 1.0.0-rc9
+ ${atomix-all.version}
junit
junit
- 4.9
+ ${junit.version}
test
log4j
log4j
- 1.2.17
+ ${log4j.version}
-
-
-
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
-
+
+ 1.0.0-rc9
+ 1.2.17
+
diff --git a/autovalue/pom.xml b/autovalue/pom.xml
index 9e6aeff866..e5b0841807 100644
--- a/autovalue/pom.xml
+++ b/autovalue/pom.xml
@@ -1,5 +1,5 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
com.baeldung
autovalue
diff --git a/aws/README.md b/aws/README.md
index f179ddc3f6..3ec2f1d82b 100644
--- a/aws/README.md
+++ b/aws/README.md
@@ -3,5 +3,6 @@
- [AWS Lambda Using DynamoDB With Java](http://www.baeldung.com/aws-lambda-dynamodb-java)
- [AWS S3 with Java](http://www.baeldung.com/aws-s3-java)
- [AWS Lambda With Java](http://www.baeldung.com/java-aws-lambda)
-- [Managing EC2 Instances in Java] (http://www.baeldung.com/ec2-java)
+- [Managing EC2 Instances in Java](http://www.baeldung.com/ec2-java)
+- [http://www.baeldung.com/aws-s3-multipart-upload](https://github.com/eugenp/tutorials/tree/master/aws)
diff --git a/aws/native-libs/libsqlite4java-linux-amd64-1.0.392.so b/aws/native-libs/libsqlite4java-linux-amd64-1.0.392.so
new file mode 100644
index 0000000000..884615789b
Binary files /dev/null and b/aws/native-libs/libsqlite4java-linux-amd64-1.0.392.so differ
diff --git a/aws/native-libs/libsqlite4java-linux-i386-1.0.392.so b/aws/native-libs/libsqlite4java-linux-i386-1.0.392.so
new file mode 100644
index 0000000000..15e7469e38
Binary files /dev/null and b/aws/native-libs/libsqlite4java-linux-i386-1.0.392.so differ
diff --git a/aws/native-libs/libsqlite4java-osx-1.0.392.dylib b/aws/native-libs/libsqlite4java-osx-1.0.392.dylib
new file mode 100644
index 0000000000..0276162614
Binary files /dev/null and b/aws/native-libs/libsqlite4java-osx-1.0.392.dylib differ
diff --git a/aws/native-libs/sqlite4java-win32-x64-1.0.392.dll b/aws/native-libs/sqlite4java-win32-x64-1.0.392.dll
new file mode 100644
index 0000000000..70d258f29b
Binary files /dev/null and b/aws/native-libs/sqlite4java-win32-x64-1.0.392.dll differ
diff --git a/aws/native-libs/sqlite4java-win32-x86-1.0.392.dll b/aws/native-libs/sqlite4java-win32-x86-1.0.392.dll
new file mode 100644
index 0000000000..c988e5a697
Binary files /dev/null and b/aws/native-libs/sqlite4java-win32-x86-1.0.392.dll differ
diff --git a/aws/pom.xml b/aws/pom.xml
index c62b1b9913..7cd16db802 100644
--- a/aws/pom.xml
+++ b/aws/pom.xml
@@ -1,5 +1,5 @@
+ 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
aws
@@ -13,48 +13,30 @@
1.0.0-SNAPSHOT
-
- 2.5
- 1.3.0
- 1.1.0
- 2.8.0
- 1.11.290
- 4.12
- 2.8.9
- 3.8.0
- 1.11.86
- https://s3-us-west-2.amazonaws.com/dynamodb-local/release
-
-
-
com.amazonaws
aws-java-sdk
${aws-java-sdk.version}
-
junit
junit
${junit.version}
test
-
org.mockito
mockito-core
${mockito-core.version}
test
-
org.assertj
assertj-core
${assertj-core.version}
test
-
com.amazonaws
aws-lambda-java-core
@@ -66,7 +48,6 @@
-
com.amazonaws
aws-lambda-java-events
@@ -78,25 +59,33 @@
-
commons-io
commons-io
${commons-io.version}
-
com.google.code.gson
gson
${gson.version}
-
com.amazonaws
DynamoDBLocal
${dynamodblocal.version}
test
+
+
+ org.lucee
+ jets3t
+ ${jets3t-version}
+
+
+ org.lucee
+ commons-codec
+ ${commons-codec-version}
+
@@ -104,7 +93,7 @@
org.apache.maven.plugins
maven-shade-plugin
- 3.0.0
+ ${maven-shade-plugin.version}
false
@@ -121,7 +110,7 @@
org.apache.maven.plugins
maven-dependency-plugin
- 2.10
+ ${maven-dependency-plugin.version}
copy-dependencies
@@ -148,4 +137,21 @@
+
+ 2.5
+ 1.3.0
+ 1.1.0
+ 2.8.0
+ 1.11.290
+ 4.12
+ 2.8.9
+ 3.8.0
+ 1.11.86
+ https://s3-us-west-2.amazonaws.com/dynamodb-local/release
+ 1.10.L001
+ 0.9.4.0006L
+ 3.0.0
+ 2.10
+
+
\ No newline at end of file
diff --git a/aws/src/main/java/com/baeldung/sqs/SQSApplication.java b/aws/src/main/java/com/baeldung/sqs/SQSApplication.java
new file mode 100644
index 0000000000..978506a24f
--- /dev/null
+++ b/aws/src/main/java/com/baeldung/sqs/SQSApplication.java
@@ -0,0 +1,146 @@
+package com.baeldung.sqs;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.amazonaws.auth.AWSCredentials;
+import com.amazonaws.auth.AWSStaticCredentialsProvider;
+import com.amazonaws.auth.BasicAWSCredentials;
+import com.amazonaws.regions.Regions;
+import com.amazonaws.services.sqs.AmazonSQSClientBuilder;
+import com.amazonaws.services.sqs.model.CreateQueueRequest;
+import com.amazonaws.services.sqs.model.DeleteMessageRequest;
+import com.amazonaws.services.sqs.model.GetQueueAttributesRequest;
+import com.amazonaws.services.sqs.model.GetQueueAttributesResult;
+import com.amazonaws.services.sqs.model.MessageAttributeValue;
+import com.amazonaws.services.sqs.model.ReceiveMessageRequest;
+import com.amazonaws.services.sqs.model.SendMessageBatchRequest;
+import com.amazonaws.services.sqs.model.SendMessageRequest;
+import com.amazonaws.services.sqs.model.SetQueueAttributesRequest;
+import com.amazonaws.services.sqs.model.SendMessageBatchRequestEntry;
+import com.amazonaws.services.sqs.model.Message;
+import com.amazonaws.services.sqs.AmazonSQS;
+
+public class SQSApplication {
+
+ private static final AWSCredentials credentials;
+
+ static {
+ // put your accesskey and secretkey here
+ credentials = new BasicAWSCredentials(
+ "",
+ ""
+ );
+ }
+
+ public static void main(String[] args) {
+
+ // Set up the client
+ AmazonSQS sqs = AmazonSQSClientBuilder.standard()
+ .withCredentials(new AWSStaticCredentialsProvider(credentials))
+ .withRegion(Regions.US_EAST_1)
+ .build();
+
+ // Create a standard queue
+
+ CreateQueueRequest createStandardQueueRequest = new CreateQueueRequest("baeldung-queue");
+ String standardQueueUrl = sqs.createQueue(createStandardQueueRequest)
+ .getQueueUrl();
+
+ System.out.println(standardQueueUrl);
+
+ // Create a fifo queue
+
+ Map queueAttributes = new HashMap();
+ queueAttributes.put("FifoQueue", "true");
+ queueAttributes.put("ContentBasedDeduplication", "true");
+
+ CreateQueueRequest createFifoQueueRequest = new CreateQueueRequest("baeldung-queue.fifo").withAttributes(queueAttributes);
+ String fifoQueueUrl = sqs.createQueue(createFifoQueueRequest)
+ .getQueueUrl();
+
+ System.out.println(fifoQueueUrl);
+
+ // Set up a dead letter queue
+
+ String deadLetterQueueUrl = sqs.createQueue("baeldung-dead-letter-queue")
+ .getQueueUrl();
+
+ GetQueueAttributesResult deadLetterQueueAttributes = sqs.getQueueAttributes(new GetQueueAttributesRequest(deadLetterQueueUrl).withAttributeNames("QueueArn"));
+
+ String deadLetterQueueARN = deadLetterQueueAttributes.getAttributes()
+ .get("QueueArn");
+
+ SetQueueAttributesRequest queueAttributesRequest = new SetQueueAttributesRequest().withQueueUrl(standardQueueUrl)
+ .addAttributesEntry("RedrivePolicy", "{\"maxReceiveCount\":\"2\", " + "\"deadLetterTargetArn\":\"" + deadLetterQueueARN + "\"}");
+
+ sqs.setQueueAttributes(queueAttributesRequest);
+
+ // Send a message to a standard queue
+
+ Map messageAttributes = new HashMap<>();
+
+ messageAttributes.put("AttributeOne", new MessageAttributeValue().withStringValue("This is an attribute")
+ .withDataType("String"));
+
+ SendMessageRequest sendMessageStandardQueue = new SendMessageRequest().withQueueUrl(standardQueueUrl)
+ .withMessageBody("A simple message.")
+ .withDelaySeconds(30) // Message will arrive in the queue after 30 seconds. We can use this only in standard queues
+ .withMessageAttributes(messageAttributes);
+
+ sqs.sendMessage(sendMessageStandardQueue);
+
+ // Send a message to a fifo queue
+
+ SendMessageRequest sendMessageFifoQueue = new SendMessageRequest().withQueueUrl(fifoQueueUrl)
+ .withMessageBody("FIFO Queue")
+ .withMessageGroupId("baeldung-group-1")
+ .withMessageAttributes(messageAttributes);
+
+ sqs.sendMessage(sendMessageFifoQueue);
+
+ // Send multiple messages
+
+ List messageEntries = new ArrayList<>();
+ messageEntries.add(new SendMessageBatchRequestEntry().withId("id-1")
+ .withMessageBody("batch-1")
+ .withMessageGroupId("baeldung-group-1"));
+ messageEntries.add(new SendMessageBatchRequestEntry().withId("id-2")
+ .withMessageBody("batch-2")
+ .withMessageGroupId("baeldung-group-1"));
+
+ SendMessageBatchRequest sendMessageBatchRequest = new SendMessageBatchRequest(fifoQueueUrl, messageEntries);
+ sqs.sendMessageBatch(sendMessageBatchRequest);
+
+ // Read a message from a queue
+
+ ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest(fifoQueueUrl).withWaitTimeSeconds(10) // Long polling;
+ .withMaxNumberOfMessages(1); // Max is 10
+
+ List sqsMessages = sqs.receiveMessage(receiveMessageRequest)
+ .getMessages();
+
+ sqsMessages.get(0)
+ .getAttributes();
+ sqsMessages.get(0)
+ .getBody();
+
+ // Delete a message from a queue
+
+ sqs.deleteMessage(new DeleteMessageRequest().withQueueUrl(fifoQueueUrl)
+ .withReceiptHandle(sqsMessages.get(0)
+ .getReceiptHandle()));
+
+ // Monitoring
+ GetQueueAttributesRequest getQueueAttributesRequest = new GetQueueAttributesRequest(standardQueueUrl).withAttributeNames("All");
+ GetQueueAttributesResult getQueueAttributesResult = sqs.getQueueAttributes(getQueueAttributesRequest);
+ System.out.println(String.format("The number of messages on the queue: %s", getQueueAttributesResult.getAttributes()
+ .get("ApproximateNumberOfMessages")));
+ System.out.println(String.format("The number of messages in flight: %s", getQueueAttributesResult.getAttributes()
+ .get("ApproximateNumberOfMessagesNotVisible")));
+
+ }
+
+}
diff --git a/aws/src/test/java/com/baeldung/jets3t/JetS3tLiveTest.java b/aws/src/test/java/com/baeldung/jets3t/JetS3tLiveTest.java
new file mode 100644
index 0000000000..cf0b203e10
--- /dev/null
+++ b/aws/src/test/java/com/baeldung/jets3t/JetS3tLiveTest.java
@@ -0,0 +1,351 @@
+package com.baeldung.jets3t;
+
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jets3t.service.S3Service;
+import org.jets3t.service.ServiceException;
+import org.jets3t.service.impl.rest.httpclient.RestS3Service;
+import org.jets3t.service.model.S3Bucket;
+import org.jets3t.service.model.S3Object;
+import org.jets3t.service.model.StorageObject;
+import org.jets3t.service.security.AWSCredentials;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.*;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.stream.Collectors;
+
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+import static junit.framework.TestCase.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class JetS3tLiveTest {
+
+ private Log log = LogFactory.getLog(JetS3tLiveTest.class);
+
+ private static final String BucketName = "baeldung-barfoo";
+ private static final String TestString = "test string";
+ private static final String TestStringName = "string object";
+ private static final String TgtBucket = "baeldung-tgtbucket";
+
+ private static S3Service s3Service;
+
+ @BeforeClass
+ public static void connectS3() throws Exception {
+
+ // Replace with your keys
+ String awsAccessKey = "your access key";
+ String awsSecretKey = "your secret key";
+
+ // Create credentials
+ AWSCredentials awsCredentials = new AWSCredentials(awsAccessKey, awsSecretKey);
+
+ // Create service
+ s3Service = new RestS3Service(awsCredentials);
+ }
+
+ @Test
+ public void givenCreate_AndDeleteBucket_CountGoesUpThenDown() throws Exception {
+
+ // List buckets, get a count
+ S3Bucket[] myBuckets = s3Service.listAllBuckets();
+ int count = Arrays.stream(myBuckets).map(S3Bucket::getName).collect(Collectors.toList()).size();
+
+ // Create a bucket
+ S3Bucket bucket = createBucket();
+ assertNotNull(bucket);
+
+ // List again
+ myBuckets = s3Service.listAllBuckets();
+ int newCount = Arrays.stream(myBuckets).map(S3Bucket::getName).collect(Collectors.toList()).size();
+
+ // We should have one more
+ assertEquals((count + 1), newCount);
+
+ // Delete so next test doesn't fail
+ deleteBucket();
+
+ // Check the count again, just for laughs
+ myBuckets = s3Service.listAllBuckets();
+ newCount = Arrays.stream(myBuckets).map(S3Bucket::getName).collect(Collectors.toList()).size();
+ assertEquals(count, newCount);
+
+ }
+
+ private S3Bucket createBucket() throws Exception {
+ S3Bucket bucket = s3Service.createBucket(BucketName);
+ log.info(bucket);
+ return bucket;
+ }
+
+
+ private void deleteBucket() throws ServiceException {
+ s3Service.deleteBucket(BucketName);
+ }
+
+ @Test
+ public void givenString_Uploaded_StringInfoIsAvailable() throws Exception {
+
+ // Create a bucket
+ S3Bucket bucket = createBucket();
+ assertNotNull(bucket);
+
+ // Upload a string
+ uploadStringData();
+
+ // Get the details
+ StorageObject objectDetailsOnly = s3Service.getObjectDetails(BucketName, TestStringName);
+ log.info("Content type: " + objectDetailsOnly.getContentType() + " length: " + objectDetailsOnly.getContentLength());
+
+ // Delete it
+ deleteObject(TestStringName);
+
+ // For next test
+ deleteBucket();
+ }
+
+ private void uploadStringData() throws Exception {
+ S3Object stringObject = new S3Object(TestStringName, TestString);
+ s3Service.putObject(BucketName, stringObject);
+ log.info("Content type:" + stringObject.getContentType());
+ }
+
+ private void deleteObject(String objectName) throws ServiceException {
+ s3Service.deleteObject(BucketName, objectName);
+ }
+
+ @Test
+ public void givenStringUploaded_StringIsDownloaded() throws Exception {
+
+ // Get a bucket
+ S3Bucket bucket = createBucket();
+ assertNotNull(bucket);
+
+ uploadStringData();
+
+ // Download
+ S3Object stringObject = s3Service.getObject(BucketName, TestStringName);
+
+ // Process stream into a string
+ String downloadedString = new BufferedReader(new InputStreamReader(stringObject.getDataInputStream())).lines().collect(Collectors.joining("\n"));
+
+ // Verify
+ assertTrue(TestString.equals(downloadedString));
+
+
+ // Clean up for next test
+ deleteObject(TestStringName);
+ deleteBucket();
+ }
+
+ @Test
+ public void givenBinaryFileUploaded_FileIsDownloaded() throws Exception {
+
+ // get a bucket
+ S3Bucket bucket = createBucket();
+ assertNotNull(bucket);
+
+ // Put a binary file
+ S3Object fileObject = new S3Object(new File("src/test/resources/test.jpg"));
+ s3Service.putObject(BucketName, fileObject);
+
+ // Print info about type and name
+ log.info("Content type:" + fileObject.getContentType());
+ log.info("File object name is " + fileObject.getName());
+
+ // Download
+ S3Object newFileObject = s3Service.getObject(BucketName, "test.jpg");
+
+ // Save to a different name
+ File newFile = new File("src/test/resources/newtest.jpg");
+ Files.copy(newFileObject.getDataInputStream(), newFile.toPath(), REPLACE_EXISTING);
+
+
+ // Get hashes and compare
+ String origMD5 = getFileMD5("src/test/resources/test.jpg");
+ String newMD5 = getFileMD5("src/test/resources/newtest.jpg");
+ assertTrue(origMD5.equals(newMD5));
+
+ // Clean up
+ deleteObject("test.jpg");
+ deleteBucket();
+ }
+
+ // Get MD5 hash for a file
+ private String getFileMD5(String filename) throws IOException {
+ try (FileInputStream fis = new FileInputStream(new File(filename))) {
+ return DigestUtils.md5Hex(fis);
+ }
+ }
+
+
+
+ @Test
+ public void givenStreamDataUploaded_StreamDataIsDownloaded() throws Exception {
+
+ // get a bucket
+ S3Bucket bucket = createBucket();
+ assertNotNull(bucket);
+
+ ArrayList numbers = new ArrayList<>();
+ numbers.add(2);
+ numbers.add(3);
+ numbers.add(5);
+ numbers.add(7);
+
+ // Serialize ArrayList
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ ObjectOutputStream objectOutputStream = new ObjectOutputStream(bytes);
+ objectOutputStream.writeObject(numbers);
+
+ // Wrap bytes
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes.toByteArray());
+
+ // Create and populate object
+ S3Object streamObject = new S3Object("stream");
+ streamObject.setDataInputStream(byteArrayInputStream);
+ streamObject.setContentLength(byteArrayInputStream.available());
+ streamObject.setContentType("binary/octet-stream");
+
+ // Put it
+ s3Service.putObject(BucketName, streamObject);
+
+ // Get it
+ S3Object newStreamObject = s3Service.getObject(BucketName, "stream");
+
+ // Convert back to ArrayList
+ ObjectInputStream objectInputStream = new ObjectInputStream(newStreamObject.getDataInputStream());
+ ArrayList newNumbers = (ArrayList)objectInputStream.readObject();
+
+ assertEquals(2, (int)newNumbers.get(0));
+ assertEquals(3, (int)newNumbers.get(1));
+ assertEquals(5, (int)newNumbers.get(2));
+ assertEquals(7, (int)newNumbers.get(3));
+
+ // Clean up
+ deleteObject("stream");
+ deleteBucket();
+ }
+
+ @Test
+ public void whenFileCopied_CopyIsSame() throws Exception {
+
+ // get a bucket
+ S3Bucket bucket = createBucket();
+ assertNotNull(bucket);
+
+ // Put a binary file
+ S3Object fileObject = new S3Object(new File("src/test/resources/test.jpg"));
+ s3Service.putObject(BucketName, fileObject);
+
+
+ // Copy it
+ S3Object targetObject = new S3Object("testcopy.jpg");
+ s3Service.copyObject(BucketName, "test.jpg", BucketName, targetObject, false);
+
+
+ // Download
+ S3Object newFileObject = s3Service.getObject(BucketName, "testcopy.jpg");
+
+ // Save to a different name
+ File newFile = new File("src/test/resources/testcopy.jpg");
+ Files.copy(newFileObject.getDataInputStream(), newFile.toPath(), REPLACE_EXISTING);
+
+
+ // Get hashes and compare
+ String origMD5 = getFileMD5("src/test/resources/test.jpg");
+ String newMD5 = getFileMD5("src/test/resources/testcopy.jpg");
+ assertTrue(origMD5.equals(newMD5));
+
+ // Clean up
+ deleteObject("test.jpg");
+ deleteObject("testcopy.jpg");
+ deleteBucket();
+
+ }
+
+
+ @Test
+ public void whenFileRenamed_NewNameIsSame() throws Exception {
+
+ // get a bucket
+ S3Bucket bucket = createBucket();
+ assertNotNull(bucket);
+
+ // Put a binary file
+ S3Object fileObject = new S3Object(new File("src/test/resources/test.jpg"));
+ s3Service.putObject(BucketName, fileObject);
+
+
+ // Copy it
+ s3Service.renameObject(BucketName, "test.jpg", new S3Object("spidey.jpg"));
+
+
+ // Download
+ S3Object newFileObject = s3Service.getObject(BucketName, "spidey.jpg");
+
+ // Save to a different name
+ File newFile = new File("src/test/resources/spidey.jpg");
+ Files.copy(newFileObject.getDataInputStream(), newFile.toPath(), REPLACE_EXISTING);
+
+
+ // Get hashes and compare
+ String origMD5 = getFileMD5("src/test/resources/test.jpg");
+ String newMD5 = getFileMD5("src/test/resources/spidey.jpg");
+ assertTrue(origMD5.equals(newMD5));
+
+ // Clean up
+ deleteObject("test.jpg");
+ deleteObject("spidey.jpg");
+ deleteBucket();
+
+ }
+
+ @Test
+ public void whenFileMoved_NewInstanceIsSame() throws Exception {
+
+ // get a bucket
+ S3Bucket bucket = createBucket();
+ assertNotNull(bucket);
+
+ // create another bucket
+ S3Bucket tgtBucket = s3Service.createBucket(TgtBucket);
+
+
+ // Put a binary file
+ S3Object fileObject = new S3Object(new File("src/test/resources/test.jpg"));
+ s3Service.putObject(BucketName, fileObject);
+
+
+ // Copy it
+ s3Service.moveObject(BucketName, "test.jpg", TgtBucket,
+ new S3Object("spidey.jpg"), false);
+
+
+ // Download
+ S3Object newFileObject = s3Service.getObject(TgtBucket, "spidey.jpg");
+
+ // Save to a different name
+ File newFile = new File("src/test/resources/spidey.jpg");
+ Files.copy(newFileObject.getDataInputStream(), newFile.toPath(), REPLACE_EXISTING);
+
+
+ // Get hashes and compare
+ String origMD5 = getFileMD5("src/test/resources/test.jpg");
+ String newMD5 = getFileMD5("src/test/resources/spidey.jpg");
+ assertTrue(origMD5.equals(newMD5));
+
+ // Clean up
+ deleteBucket();
+
+ s3Service.deleteObject(TgtBucket, "spidey.jpg");
+ s3Service.deleteBucket(TgtBucket);
+ }
+
+
+}
diff --git a/axon/pom.xml b/axon/pom.xml
index 97fe607cad..8d5636277a 100644
--- a/axon/pom.xml
+++ b/axon/pom.xml
@@ -1,14 +1,14 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ axon
+
parent-modules
com.baeldung
1.0.0-SNAPSHOT
- 4.0.0
-
- axon
diff --git a/baeldung-pmd-rules.xml b/baeldung-pmd-rules.xml
new file mode 100644
index 0000000000..7625d68242
--- /dev/null
+++ b/baeldung-pmd-rules.xml
@@ -0,0 +1,10 @@
+
+
+ Baeldung custom PMD rules
+
+ Test does not follow Baeldung naming convention
+ 3
+
+
\ No newline at end of file
diff --git a/bootique/dependency-reduced-pom.xml b/bootique/dependency-reduced-pom.xml
deleted file mode 100644
index ab09cfb7b1..0000000000
--- a/bootique/dependency-reduced-pom.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
- bootique-parent
- io.bootique.parent
- 0.12
-
- 4.0.0
- com.baeldung.bootique
- bootique
- bootique
- 1.0-SNAPSHOT
- http://maven.apache.org
-
-
-
- maven-shade-plugin
-
-
-
-
-
- io.bootique
- bootique-test
- 0.23
- test
-
-
- junit
- junit
- 4.12
- test
-
-
- hamcrest-core
- org.hamcrest
-
-
-
-
-
-
-
- io.bootique.bom
- bootique-bom
- 0.23
- pom
- import
-
-
-
-
- com.baeldung.bootique.App
-
-
-
diff --git a/bootique/pom.xml b/bootique/pom.xml
index 28b716e104..89ef2b4b5b 100644
--- a/bootique/pom.xml
+++ b/bootique/pom.xml
@@ -1,66 +1,67 @@
- 4.0.0
- com.baeldung.bootique
- bootique
- jar
- 1.0-SNAPSHOT
- bootique
- http://maven.apache.org
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ 4.0.0
+ com.baeldung.bootique
+ bootique
+ jar
+ 1.0-SNAPSHOT
+ bootique
+ http://maven.apache.org
-
- com.baeldung.bootique.App
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
-
- io.bootique.parent
- bootique-parent
- 0.12
-
+
+
+
+ io.bootique.bom
+ bootique-bom
+ ${bootique-bom.version}
+ pom
+ import
+
+
+
-
-
-
- io.bootique.bom
- bootique-bom
- 0.23
- pom
- import
-
-
-
+
+
+ io.bootique.jersey
+ bootique-jersey
+ compile
+
+
+ io.bootique.logback
+ bootique-logback
+ compile
+
+
+ io.bootique
+ bootique-test
+ test
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
-
-
- io.bootique.jersey
- bootique-jersey
- compile
-
-
- io.bootique.logback
- bootique-logback
- compile
-
-
- io.bootique
- bootique-test
- test
-
-
- junit
- junit
- 4.12
- test
-
-
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+
+
+
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
-
-
-
+
+ com.baeldung.bootique.App
+ 0.23
+
\ No newline at end of file
diff --git a/camel-api/pom.xml b/camel-api/pom.xml
index 3f96e2209c..86f6713cd6 100644
--- a/camel-api/pom.xml
+++ b/camel-api/pom.xml
@@ -1,12 +1,12 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.example
spring-boot-camel
0.0.1-SNAPSHOT
Spring-Boot - Camel API
-
+
com.baeldung
parent-modules
@@ -45,14 +45,6 @@
spring-boot:run
-
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
- 1.8
- 1.8
-
-
org.springframework.boot
spring-boot-maven-plugin
@@ -71,7 +63,6 @@
UTF-8
3.7.0
- 2.19.1
2.19.1
1.5.4.RELEASE
diff --git a/cas/cas-secured-app/pom.xml b/cas/cas-secured-app/pom.xml
index d52597412e..1a9176ff3e 100644
--- a/cas/cas-secured-app/pom.xml
+++ b/cas/cas-secured-app/pom.xml
@@ -1,113 +1,91 @@
- 4.0.0
+ 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
+ cas-secured-app
+ 0.0.1-SNAPSHOT
+ jar
+ cas-secured-app
+ Demo project for Spring Boot
- com.baeldung
- cas-secured-app
- 0.0.1-SNAPSHOT
- jar
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.0.0.M7
+
+
- cas-secured-app
- Demo project for Spring Boot
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+ org.springframework.security
+ spring-security-cas
+
+
+ org.springframework.boot
+ spring-boot-starter-freemarker
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
-
- org.springframework.boot
- spring-boot-starter-parent
- 2.0.0.M7
-
-
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.security
+ spring-security-test
+ test
+
+
-
- UTF-8
- UTF-8
- 1.8
-
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
-
-
- org.springframework.boot
- spring-boot-starter-security
-
-
- org.springframework.security
- spring-security-cas
-
-
- org.springframework.boot
- spring-boot-starter-freemarker
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- org.springframework.boot
- spring-boot-devtools
- runtime
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.springframework.security
- spring-security-test
- test
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
- 3
- true
-
- **/*IntegrationTest.java
- **/*LongRunningUnitTest.java
- **/*ManualTest.java
- **/JdbcTest.java
- **/*LiveTest.java
-
-
-
-
-
-
-
-
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/milestone
-
- false
-
-
-
-
-
-
- spring-milestones
- Spring Milestones
- https://repo.spring.io/milestone
-
- false
-
-
-
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+ false
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+
diff --git a/cas/cas-server/pom.xml b/cas/cas-server/pom.xml
index 9cae9c487b..30e29b155f 100644
--- a/cas/cas-server/pom.xml
+++ b/cas/cas-server/pom.xml
@@ -8,12 +8,44 @@
war
1.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ ${org.springframework.boot.spring-boot-starter-parent.version}
+
+
+
+
+
+ org.apereo.cas
+ cas-server-webapp${app.server}
+ ${cas.version}
+ war
+ runtime
+
+
+ org.apereo.cas
+ cas-server-support-json-service-registry
+ ${cas.version}
+
+
+ org.apereo.cas
+ cas-server-support-jdbc
+ ${cas.version}
+
+
+ org.apereo.cas
+ cas-server-support-jdbc-drivers
+ ${cas.version}
+
+
+
com.rimerosolutions.maven.plugins
wrapper-maven-plugin
- 0.0.4
+ ${wrapper-maven-plugin.version}
true
MD5
@@ -31,7 +63,7 @@
org.apache.maven.plugins
maven-war-plugin
- 2.6
+ ${maven-war-plugin.version}
cas
false
@@ -52,50 +84,47 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.7.0
+ ${maven-compiler-plugin.version}
- 1.8
- 1.8
+ ${maven.compiler.source}
+ ${maven.compiler.target}
cas
-
-
- org.apereo.cas
- cas-server-webapp${app.server}
- ${cas.version}
- war
- runtime
-
-
- org.apereo.cas
- cas-server-support-json-service-registry
- ${cas.version}
-
-
- org.apereo.cas
- cas-server-support-jdbc
- ${cas.version}
-
-
- org.apereo.cas
- cas-server-support-jdbc-drivers
- ${cas.version}
-
-
-
-
- 5.1.4
- 1.5.3.RELEASE
-
- -tomcat
- 1.8
- 1.8
- UTF-8
-
+
+
+
+ false
+
+ pgp
+
+
+
+ com.github.s4u.plugins
+ pgpverify-maven-plugin
+ ${pgpverify-maven-plugin.version}
+
+
+
+ check
+
+
+
+
+ hkp://pool.sks-keyservers.net
+ ${settings.localRepository}/pgpkeys-cache
+ test
+ true
+ false
+
+
+
+
+
+
@@ -128,35 +157,19 @@
-
-
-
- false
-
- pgp
-
-
-
- com.github.s4u.plugins
- pgpverify-maven-plugin
- 1.1.0
-
-
-
- check
-
-
-
-
- hkp://pool.sks-keyservers.net
- ${settings.localRepository}/pgpkeys-cache
- test
- true
- false
-
-
-
-
-
-
-
+
+ 5.1.4
+ 1.5.3.RELEASE
+
+ -tomcat
+ 1.8
+ 1.8
+ UTF-8
+ 2.0.0.M7
+ 0.0.4
+ 2.6
+ 3.7.0
+ 1.1.0
+
+
+
\ No newline at end of file
diff --git a/cdi/pom.xml b/cdi/pom.xml
index da0672afde..74ba52ea8d 100644
--- a/cdi/pom.xml
+++ b/cdi/pom.xml
@@ -1,8 +1,7 @@
+ 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
cdi
1.0-SNAPSHOT
@@ -24,7 +23,6 @@
spring-context
${spring.version}
-
org.aspectj
aspectjweaver
@@ -35,50 +33,14 @@
weld-se-core
${weld-se-core.version}
-
org.springframework
spring-test
${spring.version}
test
-
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
4.3.4.RELEASE
1.8.9
diff --git a/checker-plugin/README.md b/checker-plugin/README.md
new file mode 100644
index 0000000000..f4534b09e8
--- /dev/null
+++ b/checker-plugin/README.md
@@ -0,0 +1,3 @@
+### Relevant articles
+
+- [The Checker Framework – Pluggable Type Systems for Java](http://www.baeldung.com/checker-framework)
diff --git a/checker-plugin/pom.xml b/checker-plugin/pom.xml
index bc7a669d4f..01d7a30bfd 100644
--- a/checker-plugin/pom.xml
+++ b/checker-plugin/pom.xml
@@ -8,48 +8,39 @@
checker-plugin
http://maven.apache.org
-
-
-
-
- ${org.checkerframework:jdk8:jar}
-
-
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
-
-
org.checkerframework
checker-qual
- 2.3.1
+ ${checker-qual.version}
org.checkerframework
checker
- 2.3.1
+ ${checker.version}
org.checkerframework
jdk8
- 2.3.1
+ ${jdk8.version}
org.checkerframework
compiler
- 2.3.1
+ ${checkerframework.compiler.version}
-
-
org.apache.maven.plugins
@@ -73,10 +64,10 @@
maven-compiler-plugin
- 3.6.1
+ ${maven-compiler-plugin.version}
- 1.8
- 1.8
+ ${maven.compiler.source}
+ ${maven.compiler.target}
@@ -111,4 +102,19 @@
+
+
+ ${org.checkerframework:jdk8:jar}
+
+
+ 2.3.1
+ 2.3.1
+ 2.3.1
+ 2.3.1
+ 1.8
+ 1.8
+
+
diff --git a/core-groovy/README.md b/core-groovy/README.md
index 5954a8ab7e..71788acdb7 100644
--- a/core-groovy/README.md
+++ b/core-groovy/README.md
@@ -2,3 +2,5 @@
## Relevant articles:
+- [JDBC with Groovy](http://www.baeldung.com/jdbc-groovy)
+- [Working with JSON in Groovy](http://www.baeldung.com/groovy-json)
diff --git a/core-groovy/pom.xml b/core-groovy/pom.xml
index 91cbe66e35..0126e96758 100644
--- a/core-groovy/pom.xml
+++ b/core-groovy/pom.xml
@@ -1,7 +1,7 @@
-
+
4.0.0
-
core-groovy
1.0-SNAPSHOT
jar
@@ -12,28 +12,21 @@
1.0.0-SNAPSHOT
-
-
- central
- http://jcenter.bintray.com
-
-
-
org.codehaus.groovy
groovy
- 2.4.13
+ ${groovy.version}
org.codehaus.groovy
groovy-all
- 2.4.13
+ ${groovy-all.version}
org.codehaus.groovy
groovy-sql
- 2.4.13
+ ${groovy-sql.version}
org.junit.jupiter
@@ -50,13 +43,13 @@
org.hsqldb
hsqldb
- 2.4.0
+ ${hsqldb.version}
test
org.spockframework
spock-core
- 1.1-groovy-2.4
+ ${spock-core.version}
test
@@ -66,7 +59,7 @@
org.codehaus.gmavenplus
gmavenplus-plugin
- 1.6
+ ${gmavenplus-plugin.version}
@@ -78,13 +71,9 @@
-
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
maven-failsafe-plugin
- 2.19.1
+ ${maven-failsafe-plugin.version}
org.junit.platform
@@ -110,6 +99,13 @@
+
+
+ central
+ http://jcenter.bintray.com
+
+
+
UTF-8
1.1.2
@@ -118,11 +114,17 @@
1.1.2
0.15
1.5.0
-
5.0.0
1.0.0
4.12.0
4.12
+ 2.4.13
+ 2.4.13
+ 2.4.13
+ 2.4.0
+ 1.1-groovy-2.4
+ 1.6
+ 2.19.1
diff --git a/core-groovy/src/test/groovy/com/baeldung/json/JsonParserTest.groovy b/core-groovy/src/test/groovy/com/baeldung/json/JsonParserTest.groovy
index c3842340a5..e65550a3be 100644
--- a/core-groovy/src/test/groovy/com/baeldung/json/JsonParserTest.groovy
+++ b/core-groovy/src/test/groovy/com/baeldung/json/JsonParserTest.groovy
@@ -24,7 +24,7 @@ class JsonParserTest extends Specification {
account.value == 15.6
}
- def 'Should parse to Account given Json String with date property' () {
+ /*def 'Should parse to Account given Json String with date property' () {
given:
def json = '{"id":"1234","value":15.6,"createdAt":"2018-01-01T00:00:00+0000"}'
when:
@@ -36,9 +36,9 @@ class JsonParserTest extends Specification {
account.value == 15.6
println account.createdAt
account.createdAt == Date.parse('yyyy-MM-dd', '2018-01-01')
- }
+ }*/
- def 'Should parse to Json given an Account object' () {
+ /*def 'Should parse to Json given an Account object' () {
given:
Account account = new Account(
id: '123',
@@ -50,7 +50,7 @@ class JsonParserTest extends Specification {
then:
json
json == '{"value":15.6,"createdAt":"2018-01-01T00:00:00+0000","id":"123"}'
- }
+ }*/
def 'Should prettify given a json string' () {
given:
diff --git a/core-java-8/README.md b/core-java-8/README.md
index 949577df19..cba83d28fb 100644
--- a/core-java-8/README.md
+++ b/core-java-8/README.md
@@ -43,3 +43,4 @@
- [Shuffling Collections In Java](http://www.baeldung.com/java-shuffle-collection)
- [Java 8 StringJoiner](http://www.baeldung.com/java-string-joiner)
- [Introduction to Spliterator in Java](http://www.baeldung.com/java-spliterator)
+- [Java 8 Math New Methods](http://www.baeldung.com/java-8-math)
diff --git a/core-java-8/pom.xml b/core-java-8/pom.xml
index 924773cd02..7b49772309 100644
--- a/core-java-8/pom.xml
+++ b/core-java-8/pom.xml
@@ -5,7 +5,6 @@
core-java-8
0.1.0-SNAPSHOT
jar
-
core-java-8
@@ -15,108 +14,91 @@
-
com.google.guava
guava
${guava.version}
-
org.apache.commons
commons-collections4
${commons-collections4.version}
-
commons-io
commons-io
${commons-io.version}
-
org.apache.commons
commons-lang3
${commons-lang3.version}
-
org.apache.commons
commons-math3
${commons-math3.version}
-
-
+
log4j
log4j
- 1.2.17
+ ${log4j.version}
-
commons-codec
commons-codec
${commons-codec.version}
-
-
+
org.projectlombok
lombok
${lombok.version}
provided
-
-
org.assertj
assertj-core
${assertj.version}
test
-
com.jayway.awaitility
awaitility
${avaitility.version}
test
-
- org.openjdk.jmh
- jmh-core
- 1.19
-
-
-
- org.openjdk.jmh
- jmh-generator-annprocess
- 1.19
-
-
-
- org.openjdk.jmh
- jmh-generator-bytecode
- 1.19
-
-
+ org.openjdk.jmh
+ jmh-core
+ ${jmh-core.version}
+
+
+ org.openjdk.jmh
+ jmh-generator-annprocess
+ ${jmh-generator.version}
+
+
+ org.openjdk.jmh
+ jmh-generator-bytecode
+ ${jmh-generator.version}
+
com.codepoetics
protonpack
${protonpack.version}
-
-
+
io.vavr
vavr
${vavr.version}
-
one.util
streamex
${streamex.version}
-
+
@@ -194,7 +176,7 @@
true
+ implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
org.baeldung.executable.ExecutableMavenJar
@@ -234,46 +216,9 @@
-
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*ManualTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
-
-
21.0
3.5
@@ -286,10 +231,11 @@
0.9.0
1.13
0.6.5
-
3.6.1
1.7.0
-
+ 1.19
+ 1.19
+
\ No newline at end of file
diff --git a/core-java-8/src/main/java/com/baeldung/java_8_features/Car.java b/core-java-8/src/main/java/com/baeldung/java_8_features/Car.java
new file mode 100644
index 0000000000..139475bc25
--- /dev/null
+++ b/core-java-8/src/main/java/com/baeldung/java_8_features/Car.java
@@ -0,0 +1,31 @@
+package com.baeldung.java_8_features;
+
+public class Car {
+
+ private String model;
+ private int topSpeed;
+
+ public Car(String model, int topSpeed) {
+ super();
+ this.model = model;
+ this.topSpeed = topSpeed;
+ }
+
+ public String getModel() {
+ return model;
+ }
+
+ public void setModel(String model) {
+ this.model = model;
+ }
+
+ public int getTopSpeed() {
+ return topSpeed;
+ }
+
+ public void setTopSpeed(int topSpeed) {
+ this.topSpeed = topSpeed;
+ }
+
+
+}
diff --git a/core-java-8/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java b/core-java-8/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java
index 4979338452..c2cc39c685 100644
--- a/core-java-8/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java
+++ b/core-java-8/src/test/java/com/baeldung/java8/Java8MaxMinUnitTest.java
@@ -1,6 +1,8 @@
package com.baeldung.java8;
+import com.baeldung.java_8_features.Car;
import com.baeldung.java_8_features.Person;
+
import org.junit.Test;
import java.util.Arrays;
@@ -44,4 +46,29 @@ public class Java8MaxMinUnitTest {
assertEquals("Should be Alex", alex, minByAge);
}
+ @Test
+ public void whenArrayIsOfIntegerThenMinUsesIntegerComparator() {
+ int[] integers = new int[] { 20, 98, 12, 7, 35 };
+
+ int min = Arrays.stream(integers)
+ .min()
+ .getAsInt();
+
+ assertEquals(7, min);
+ }
+
+ @Test
+ public void whenArrayIsOfCustomTypeThenMaxUsesCustomComparator() {
+ final Car porsche = new Car("Porsche 959", 319);
+ final Car ferrari = new Car("Ferrari 288 GTO", 303);
+ final Car bugatti = new Car("Bugatti Veyron 16.4 Super Sport", 415);
+ final Car mcLaren = new Car("McLaren F1", 355);
+ final Car[] fastCars = { porsche, ferrari, bugatti, mcLaren };
+
+ final Car maxBySpeed = Arrays.stream(fastCars)
+ .max(Comparator.comparing(Car::getTopSpeed))
+ .orElseThrow(NoSuchElementException::new);
+
+ assertEquals(bugatti, maxBySpeed);
+ }
}
diff --git a/core-java-8/src/test/java/com/baeldung/time/ElapsedTimeUnitTest.java b/core-java-8/src/test/java/com/baeldung/time/ElapsedTimeUnitTest.java
new file mode 100644
index 0000000000..1d92684ef4
--- /dev/null
+++ b/core-java-8/src/test/java/com/baeldung/time/ElapsedTimeUnitTest.java
@@ -0,0 +1,76 @@
+package com.baeldung.time;
+
+import static org.junit.Assert.assertEquals;
+
+import java.time.Duration;
+import java.time.Instant;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.lang3.time.StopWatch;
+import org.junit.Test;
+
+public class ElapsedTimeUnitTest {
+
+ @Test
+ public void givenRunningTask_whenMeasuringTimeWithCurrentTimeMillis_thenGetElapsedTime() throws InterruptedException {
+ long start = System.currentTimeMillis();
+
+ simulateRunningTask();
+
+ long finish = System.currentTimeMillis();
+
+ long timeElapsed = finish - start;
+
+ assertEquals(true, (2000L <= timeElapsed) && (timeElapsed <= 3000L));
+ }
+
+ @Test
+ public void giveRunningTask_whenMeasuringTimeWithNanoTime_thenGetElapsedTime() throws InterruptedException {
+ long start = System.nanoTime();
+
+ simulateRunningTask();
+
+ long finish = System.nanoTime();
+
+ long timeElapsed = finish - start;
+
+ assertEquals(true, (2000000000L <= timeElapsed) && (timeElapsed <= 3000000000L));
+ }
+
+ @Test
+ public void givenRunningTask_whenMeasuringTimeWithStopWatch_thenGetElapsedTime() throws InterruptedException {
+ StopWatch watch = new StopWatch();
+ watch.start();
+
+ simulateRunningTask();
+
+ watch.stop();
+
+ long timeElapsed = watch.getTime();
+
+ assertEquals(true, (2000L <= timeElapsed) && (timeElapsed <= 3000L));
+ }
+
+ @Test
+ public void givenRunningTask_whenMeasuringTimeWithInstantClass_thenGetElapsedTime() throws InterruptedException {
+ Instant start = Instant.now();
+
+ simulateRunningTask();
+
+ Instant finish = Instant.now();
+
+ long timeElapsed = Duration.between(start, finish).toMillis();
+
+ assertEquals(true, (2000L <= timeElapsed) && (timeElapsed <= 3000L));
+ }
+
+ /**
+ * Simulate task running for 2.5 seconds.
+ *
+ * @throws InterruptedException
+ */
+ private static void simulateRunningTask() throws InterruptedException {
+ TimeUnit.MILLISECONDS.sleep(2500); // 2.5 seconds
+
+ }
+}
diff --git a/core-java-9/README.md b/core-java-9/README.md
index 575376ccb7..d0758d585b 100644
--- a/core-java-9/README.md
+++ b/core-java-9/README.md
@@ -20,3 +20,6 @@
- [Compact Strings in Java 9](http://www.baeldung.com/java-9-compact-string)
- [Convert Date to LocalDate or LocalDateTime and Back](http://www.baeldung.com/java-date-to-localdate-and-localdatetime)
- [Java 9 Variable Handles Demistyfied](http://www.baeldung.com/java-variable-handles)
+- [Exploring the New HTTP Client in Java 9](http://www.baeldung.com/java-9-http-client)
+- [Method Handles in Java](http://www.baeldung.com/java-method-handles)
+- [Introduction to Chronicle Queue](http://www.baeldung.com/java-chronicle-queue)
diff --git a/core-java-9/compile-modules.sh b/core-java-9/compile-modules.sh
old mode 100644
new mode 100755
diff --git a/core-java-9/compile-simple-modules.sh b/core-java-9/compile-simple-modules.sh
new file mode 100755
index 0000000000..7d5c8c9362
--- /dev/null
+++ b/core-java-9/compile-simple-modules.sh
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+javac -d outDir --module-source-path src/simple-modules $(find src/simple-modules -name "*.java")
\ No newline at end of file
diff --git a/core-java-9/pom.xml b/core-java-9/pom.xml
index 0f43265916..1f92ee71f8 100644
--- a/core-java-9/pom.xml
+++ b/core-java-9/pom.xml
@@ -1,21 +1,18 @@
+ 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
core-java-9
0.2-SNAPSHOT
-
core-java-9
-
-
- apache.snapshots
- http://repository.apache.org/snapshots/
-
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
-
org.slf4j
slf4j-api
@@ -26,21 +23,18 @@
logback-classic
${ch.qos.logback.version}
-
org.hamcrest
hamcrest-library
${org.hamcrest.version}
test
-
junit
junit
${junit.version}
test
-
org.mockito
mockito-core
@@ -53,39 +47,34 @@
${awaitility.version}
test
-
-
core-java-9
-
-
org.apache.maven.plugins
maven-compiler-plugin
${maven-compiler-plugin.version}
- 1.9
- 1.9
+ ${maven.compiler.source}
+ ${maven.compiler.target}
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
-
-
+
+
+ apache.snapshots
+ http://repository.apache.org/snapshots/
+
+
+
UTF-8
-
+
1.7.21
1.2.1
@@ -98,6 +87,8 @@
4.12
1.10.19
1.7.0
+ 1.9
+ 1.9
diff --git a/core-java-9/run-simple-module-app.sh b/core-java-9/run-simple-module-app.sh
new file mode 100755
index 0000000000..70eaf51513
--- /dev/null
+++ b/core-java-9/run-simple-module-app.sh
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+java --module-path outDir -m main.app/com.baeldung.modules.main.MainApp
\ No newline at end of file
diff --git a/core-java-9/run-student-client.sh b/core-java-9/run-student-client.sh
old mode 100644
new mode 100755
diff --git a/core-java-9/src/simple-modules/hello.modules/com/baeldung/modules/hello/HelloInterface.java b/core-java-9/src/simple-modules/hello.modules/com/baeldung/modules/hello/HelloInterface.java
new file mode 100644
index 0000000000..58dca979b4
--- /dev/null
+++ b/core-java-9/src/simple-modules/hello.modules/com/baeldung/modules/hello/HelloInterface.java
@@ -0,0 +1,5 @@
+package com.baeldung.modules.hello;
+
+public interface HelloInterface {
+ public void sayHello();
+}
diff --git a/core-java-9/src/simple-modules/hello.modules/com/baeldung/modules/hello/HelloModules.java b/core-java-9/src/simple-modules/hello.modules/com/baeldung/modules/hello/HelloModules.java
new file mode 100644
index 0000000000..3686999fa3
--- /dev/null
+++ b/core-java-9/src/simple-modules/hello.modules/com/baeldung/modules/hello/HelloModules.java
@@ -0,0 +1,11 @@
+package com.baeldung.modules.hello;
+
+public class HelloModules implements HelloInterface {
+ public static void doSomething() {
+ System.out.println("Hello, Modules!");
+ }
+
+ public void sayHello() {
+ System.out.println("Hello!");
+ }
+}
diff --git a/core-java-9/src/simple-modules/hello.modules/module-info.java b/core-java-9/src/simple-modules/hello.modules/module-info.java
new file mode 100644
index 0000000000..d76271c355
--- /dev/null
+++ b/core-java-9/src/simple-modules/hello.modules/module-info.java
@@ -0,0 +1,4 @@
+module hello.modules {
+ exports com.baeldung.modules.hello;
+ provides com.baeldung.modules.hello.HelloInterface with com.baeldung.modules.hello.HelloModules;
+}
\ No newline at end of file
diff --git a/core-java-9/src/simple-modules/main.app/com/baeldung/modules/main/MainApp.java b/core-java-9/src/simple-modules/main.app/com/baeldung/modules/main/MainApp.java
new file mode 100644
index 0000000000..eb32cafa31
--- /dev/null
+++ b/core-java-9/src/simple-modules/main.app/com/baeldung/modules/main/MainApp.java
@@ -0,0 +1,12 @@
+package com.baeldung.modules.main;
+
+import com.baeldung.modules.hello.HelloModules;
+
+public class MainApp {
+ public static void main(String[] args) {
+ HelloModules.doSomething();
+
+ HelloModules module = new HelloModules();
+ module.sayHello();
+ }
+}
diff --git a/core-java-9/src/simple-modules/main.app/module-info.java b/core-java-9/src/simple-modules/main.app/module-info.java
new file mode 100644
index 0000000000..3d5917dc05
--- /dev/null
+++ b/core-java-9/src/simple-modules/main.app/module-info.java
@@ -0,0 +1,4 @@
+module main.app {
+ requires hello.modules;
+ uses com.baeldung.modules.hello.HelloInterface;
+}
\ No newline at end of file
diff --git a/core-java-concurrency/README.md b/core-java-concurrency/README.md
index 8122c71bcb..8192a8e301 100644
--- a/core-java-concurrency/README.md
+++ b/core-java-concurrency/README.md
@@ -34,3 +34,7 @@
- [Implementing a Runnable vs Extending a Thread](http://www.baeldung.com/java-runnable-vs-extending-thread)
- [How to Kill a Java Thread](http://www.baeldung.com/java-thread-stop)
- [ExecutorService - Waiting for Threads to Finish](http://www.baeldung.com/java-executor-wait-for-threads)
+- [wait and notify() Methods in Java](http://www.baeldung.com/java-wait-notify)
+- [Priority-based Job Scheduling in Java](http://www.baeldung.com/java-priority-job-schedule)
+- [A Custom Spring SecurityConfigurer](http://www.baeldung.com/spring-security-custom-configurer)
+- [Life Cycle of a Thread in Java](http://www.baeldung.com/java-thread-lifecycle)
diff --git a/core-java-concurrency/pom.xml b/core-java-concurrency/pom.xml
index bf858047e9..829c511143 100644
--- a/core-java-concurrency/pom.xml
+++ b/core-java-concurrency/pom.xml
@@ -5,7 +5,6 @@
core-java-concurrency
0.1.0-SNAPSHOT
jar
-
core-java-concurrency
@@ -15,57 +14,46 @@
-
com.google.guava
guava
${guava.version}
-
org.apache.commons
commons-collections4
${commons-collections4.version}
-
commons-io
commons-io
${commons-io.version}
-
org.apache.commons
commons-lang3
${commons-lang3.version}
-
org.apache.commons
commons-math3
${commons-math3.version}
-
-
-
-
org.assertj
assertj-core
${assertj.version}
test
-
com.jayway.awaitility
awaitility
${avaitility.version}
test
-
-
+
core-java-concurrency
@@ -92,7 +80,6 @@
-
org.apache.maven.plugins
maven-jar-plugin
@@ -141,7 +128,7 @@
true
+ implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
org.baeldung.executable.ExecutableMavenJar
@@ -181,46 +168,9 @@
-
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*ManualTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
-
-
21.0
3.5
@@ -228,10 +178,9 @@
2.5
4.1
4.01
-
3.6.1
1.7.0
-
+
diff --git a/core-java-concurrency/src/test/java/com/baeldung/concurrent/volatilekeyword/SharedObjectManualTest.java b/core-java-concurrency/src/test/java/com/baeldung/concurrent/volatilekeyword/SharedObjectManualTest.java
index 8770cb4e90..731ae887e1 100644
--- a/core-java-concurrency/src/test/java/com/baeldung/concurrent/volatilekeyword/SharedObjectManualTest.java
+++ b/core-java-concurrency/src/test/java/com/baeldung/concurrent/volatilekeyword/SharedObjectManualTest.java
@@ -1,55 +1,36 @@
package com.baeldung.concurrent.volatilekeyword;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
-import static junit.framework.Assert.assertEquals;
+import static org.junit.Assert.*;
public class SharedObjectManualTest {
- private SharedObject sharedObject;
- private int valueReadByThread2;
- private int valueReadByThread3;
-
- @Before
- public void setUp() {
- sharedObject = new SharedObject();
- }
-
@Test
public void whenOneThreadWrites_thenVolatileReadsFromMainMemory() throws InterruptedException {
+ SharedObject sharedObject = new SharedObject();
+
Thread writer = new Thread(() -> sharedObject.increamentCount());
writer.start();
-
+ Thread.sleep(100);
Thread readerOne = new Thread(() -> {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- valueReadByThread2 = sharedObject.getCount();
+ int valueReadByThread2 = sharedObject.getCount();
+ assertEquals(1, valueReadByThread2);
});
readerOne.start();
Thread readerTwo = new Thread(() -> {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- valueReadByThread3 = sharedObject.getCount();
+ int valueReadByThread3 = sharedObject.getCount();
+ assertEquals(1, valueReadByThread3);
});
readerTwo.start();
- assertEquals(1, valueReadByThread2);
- assertEquals(1, valueReadByThread3);
-
}
@Test
public void whenTwoThreadWrites_thenVolatileReadsFromMainMemory() throws InterruptedException {
+ SharedObject sharedObject = new SharedObject();
Thread writerOne = new Thread(() -> sharedObject.increamentCount());
writerOne.start();
Thread.sleep(100);
@@ -58,14 +39,17 @@ public class SharedObjectManualTest {
writerTwo.start();
Thread.sleep(100);
- Thread readerOne = new Thread(() -> valueReadByThread2 = sharedObject.getCount());
+ Thread readerOne = new Thread(() -> {
+ int valueReadByThread2 = sharedObject.getCount();
+ assertEquals(2, valueReadByThread2);
+ });
readerOne.start();
- Thread readerTwo = new Thread(() -> valueReadByThread3 = sharedObject.getCount());
+ Thread readerTwo = new Thread(() -> {
+ int valueReadByThread3 = sharedObject.getCount();
+ assertEquals(2, valueReadByThread3);
+ });
readerTwo.start();
- assertEquals(2, valueReadByThread2);
- assertEquals(2, valueReadByThread3);
-
}
}
diff --git a/core-java-io/README.md b/core-java-io/README.md
index 52485acfd5..84720e7b77 100644
--- a/core-java-io/README.md
+++ b/core-java-io/README.md
@@ -22,4 +22,6 @@
- [A Guide To NIO2 FileVisitor](http://www.baeldung.com/java-nio2-file-visitor)
- [A Guide To NIO2 File Attribute APIs](http://www.baeldung.com/java-nio2-file-attribute)
- [Introduction to the Java NIO2 File API](http://www.baeldung.com/java-nio-2-file-api)
-- [Zipping and Unzipping in Java](http://www.baeldung.com/java-compress-and-uncompress)
\ No newline at end of file
+- [Zipping and Unzipping in Java](http://www.baeldung.com/java-compress-and-uncompress)
+- [Java NIO2 Path API](http://www.baeldung.com/java-nio-2-path)
+- [A Guide to WatchService in Java NIO2](http://www.baeldung.com/java-nio2-watchservice)
diff --git a/core-java-io/pom.xml b/core-java-io/pom.xml
index b9fdca3502..9fcca6c590 100644
--- a/core-java-io/pom.xml
+++ b/core-java-io/pom.xml
@@ -1,14 +1,19 @@
-
+
4.0.0
com.baeldung
core-java-io
0.1.0-SNAPSHOT
jar
-
core-java-io
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
net.sourceforge.collections
@@ -20,69 +25,58 @@
guava
${guava.version}
-
org.apache.commons
commons-collections4
${commons-collections4.version}
-
commons-io
commons-io
${commons-io.version}
-
org.apache.commons
commons-lang3
${commons-lang3.version}
-
org.apache.commons
commons-math3
${commons-math3.version}
-
org.decimal4j
decimal4j
${decimal4j.version}
-
org.bouncycastle
bcprov-jdk15on
${bouncycastle.version}
-
org.unix4j
unix4j-command
${unix4j.version}
-
com.googlecode.grep4j
grep4j
${grep4j.version}
-
-
com.fasterxml.jackson.core
jackson-databind
${jackson.version}
-
log4j
log4j
- 1.2.17
+ ${log4j.version}
org.slf4j
@@ -112,23 +106,19 @@
${lombok.version}
provided
-
-
org.hamcrest
hamcrest-all
- 1.3
+ ${hamcrest-all.version}
test
-
junit
junit
${junit.version}
test
-
org.hamcrest
hamcrest-core
@@ -141,14 +131,12 @@
${org.hamcrest.version}
test
-
org.assertj
assertj-core
${assertj.version}
test
-
org.mockito
mockito-core
@@ -161,25 +149,21 @@
${avaitility.version}
test
-
commons-codec
commons-codec
${commons-codec.version}
-
org.javamoney
moneta
- 1.1
+ ${moneta.version}
-
org.owasp.esapi
esapi
- 2.1.0.1
+ ${esapi.version}
-
com.sun.messaging.mq
fscontext
@@ -203,17 +187,17 @@
org.openjdk.jmh
jmh-core
- 1.19
+ ${jmh-core.version}
org.openjdk.jmh
jmh-generator-annprocess
- 1.19
+ ${jmh-generator-annprocess.version}
org.hsqldb
hsqldb
- 2.4.0
+ ${hsqldb.version}
runtime
@@ -226,19 +210,7 @@
true
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
- 1.8
- 1.8
-
-
-
org.apache.maven.plugins
maven-surefire-plugin
@@ -252,7 +224,6 @@
true
-
org.springframework.boot
spring-boot-maven-plugin
@@ -268,11 +239,10 @@
-
org.codehaus.mojo
exec-maven-plugin
- 1.6.0
+ ${exec-maven-plugin.version}
java
com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed
@@ -280,25 +250,21 @@
-Xmx300m
-XX:+UseParallelGC
-classpath
-
+
com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed
-
org.apache.maven.plugins
maven-javadoc-plugin
- 3.0.0-M1
+ ${maven-javadoc-plugin.version}
- 1.8
- 1.8
+ ${maven.compiler.source}
+ ${maven.compiler.target}
-
-
-
@@ -348,7 +314,7 @@
java
-classpath
-
+
org.openjdk.jmh.Main
.*
@@ -397,5 +363,12 @@
3.7.0
2.19.1
+ 1.8
+ 1.8
+ 3.0.0-M1
+ 2.4.0
+ 2.1.0.1
+ 1.19
+
\ No newline at end of file
diff --git a/core-java-sun/pom.xml b/core-java-sun/pom.xml
index 11aa21f44d..aaffac5e38 100644
--- a/core-java-sun/pom.xml
+++ b/core-java-sun/pom.xml
@@ -4,11 +4,15 @@
core-java-sun
0.1.0-SNAPSHOT
jar
-
core-java-sun
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
net.sourceforge.collections
@@ -20,69 +24,58 @@
guava
${guava.version}
-
org.apache.commons
commons-collections4
${commons-collections4.version}
-
commons-io
commons-io
${commons-io.version}
-
org.apache.commons
commons-lang3
${commons-lang3.version}
-
org.apache.commons
commons-math3
${commons-math3.version}
-
org.decimal4j
decimal4j
${decimal4j.version}
-
org.bouncycastle
bcprov-jdk15on
${bouncycastle.version}
-
org.unix4j
unix4j-command
${unix4j.version}
-
com.googlecode.grep4j
grep4j
${grep4j.version}
-
-
com.fasterxml.jackson.core
jackson-databind
${jackson.version}
-
log4j
log4j
- 1.2.17
+ ${log4j.version}
org.slf4j
@@ -112,23 +105,19 @@
${lombok.version}
provided
-
-
org.hamcrest
hamcrest-all
- 1.3
+ ${hamcrest-all.version}
test
-
junit
junit
${junit.version}
test
-
org.hamcrest
hamcrest-core
@@ -141,14 +130,12 @@
${org.hamcrest.version}
test
-
org.assertj
assertj-core
${assertj.version}
test
-
org.mockito
mockito-core
@@ -161,25 +148,21 @@
${avaitility.version}
test
-
commons-codec
commons-codec
${commons-codec.version}
-
org.javamoney
moneta
- 1.1
+ ${moneta.version}
-
org.owasp.esapi
esapi
- 2.1.0.1
+ ${esapi.version}
-
com.sun.messaging.mq
fscontext
@@ -203,22 +186,22 @@
org.openjdk.jmh
jmh-core
- 1.19
+ ${jmh-core.version}
org.openjdk.jmh
jmh-generator-annprocess
- 1.19
+ ${jmh-generator.version}
org.springframework
spring-web
- 4.3.4.RELEASE
+ ${spring-web.version}
com.sun
tools
- 1.8.0
+ ${sun-tools.version}
system
${java.home}/../lib/tools.jar
@@ -232,33 +215,7 @@
true
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
- 1.8
- 1.8
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- **/*LiveTest.java
- **/*IntegrationTest.java
- **/*LongRunningUnitTest.java
- **/*ManualTest.java
-
-
-
-
-
org.apache.maven.plugins
maven-dependency-plugin
@@ -275,7 +232,6 @@
-
org.apache.maven.plugins
maven-jar-plugin
@@ -289,7 +245,6 @@
-
org.apache.maven.plugins
maven-assembly-plugin
@@ -313,7 +268,6 @@
-
org.apache.maven.plugins
maven-shade-plugin
@@ -333,7 +287,6 @@
-
com.jolira
onejar-maven-plugin
@@ -350,7 +303,6 @@
-
org.springframework.boot
spring-boot-maven-plugin
@@ -366,11 +318,10 @@
-
org.codehaus.mojo
exec-maven-plugin
- 1.6.0
+ ${exec-maven-plugin.version}
java
com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed
@@ -378,15 +329,12 @@
-Xmx300m
-XX:+UseParallelGC
-classpath
-
+
com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed
-
-
-
@@ -436,7 +384,7 @@
java
-classpath
-
+
org.openjdk.jmh.Main
.*
@@ -477,7 +425,6 @@
1.3
- 4.12
2.8.9
3.6.1
1.7.0
@@ -485,5 +432,8 @@
3.7.0
2.19.1
+ 1.8.0
+ 4.3.4.RELEASE
+
\ No newline at end of file
diff --git a/core-java/.gitignore b/core-java/.gitignore
index 3de4cc647e..374c8bf907 100644
--- a/core-java/.gitignore
+++ b/core-java/.gitignore
@@ -16,7 +16,6 @@
*.ear
# Files generated by integration tests
-*.txt
backup-pom.xml
/bin/
/temp
diff --git a/core-java/README.md b/core-java/README.md
index baf98a69fd..4eb98b1b33 100644
--- a/core-java/README.md
+++ b/core-java/README.md
@@ -141,5 +141,15 @@
- [Comparing Strings in Java](http://www.baeldung.com/java-compare-strings)
- [Guide to Inheritance in Java](http://www.baeldung.com/java-inheritance)
- [Guide to Externalizable Interface in Java](http://www.baeldung.com/java-externalizable)
-- [The “final” Keyword in Java](http://www.baeldung.com/java-final)
-
+- [The Observer Pattern in Java](https://github.com/eugenp/tutorials/tree/master/core-java)
+- [Flyweight Pattern in Java](http://www.baeldung.com/java-flyweight)
+- [Object Type Casting in Java](http://www.baeldung.com/java-type-casting)
+- [A Practical Guide to DecimalFormat](http://www.baeldung.com/java-decimalformat)
+- [How to Detect the OS Using Java](http://www.baeldung.com/java-detect-os)
+- [How to TDD a List Implementation in Java](http://www.baeldung.com/java-test-driven-list)
+- [ASCII Art in Java](http://www.baeldung.com/ascii-art-in-java)
+- [An Advanced Tagging Implementation with JPA](http://www.baeldung.com/jpa-tagging-advanced)
+- [Handling Daylight Savings Time in Java](http://www.baeldung.com/java-daylight-savings)
+- [Inheritance and Composition (Is-a vs Has-a relationship) in Java](http://www.baeldung.com/java-inheritance-composition)
+- [Finding Max/Min of a List or Collection](http://www.baeldung.com/java-collection-min-max)
+- [The "final" Keyword in Java](http://www.baeldung.com/java-final)
diff --git a/core-java/externalizable.txt b/core-java/externalizable.txt
new file mode 100644
index 0000000000..ddd3e143a8
Binary files /dev/null and b/core-java/externalizable.txt differ
diff --git a/core-java/pom.xml b/core-java/pom.xml
index e2983de9dd..460da8f1fe 100644
--- a/core-java/pom.xml
+++ b/core-java/pom.xml
@@ -5,11 +5,15 @@
core-java
0.1.0-SNAPSHOT
jar
-
core-java
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
net.sourceforge.collections
@@ -21,58 +25,48 @@
guava
${guava.version}
-
org.apache.commons
commons-collections4
${commons-collections4.version}
-
commons-io
commons-io
${commons-io.version}
-
org.apache.commons
commons-lang3
${commons-lang3.version}
-
org.apache.commons
commons-math3
${commons-math3.version}
-
org.decimal4j
decimal4j
${decimal4j.version}
-
org.bouncycastle
bcprov-jdk15on
${bouncycastle.version}
-
org.unix4j
unix4j-command
${unix4j.version}
-
com.googlecode.grep4j
grep4j
${grep4j.version}
-
-
com.fasterxml.jackson.core
jackson-databind
@@ -83,12 +77,11 @@
gson
${gson.version}
-
log4j
log4j
- 1.2.17
+ ${log4j.version}
org.slf4j
@@ -118,23 +111,19 @@
${lombok.version}
provided
-
-
org.hamcrest
hamcrest-all
- 1.3
+ ${hamcrest-all.version}
test
-
junit
junit
${junit.version}
test
-
org.hamcrest
hamcrest-core
@@ -147,14 +136,12 @@
${org.hamcrest.version}
test
-
org.assertj
assertj-core
${assertj.version}
test
-
org.mockito
mockito-core
@@ -167,25 +154,21 @@
${avaitility.version}
test
-
commons-codec
commons-codec
${commons-codec.version}
-
org.javamoney
moneta
- 1.1
+ ${javamoney.moneta.version}
-
org.owasp.esapi
esapi
- 2.1.0.1
+ ${esapi.version}
-
com.sun.messaging.mq
fscontext
@@ -209,28 +192,32 @@
org.openjdk.jmh
jmh-core
- 1.19
+ ${jmh-core.version}
org.openjdk.jmh
jmh-generator-annprocess
- 1.19
+ ${jmh-generator-annprocess.version}
-
- org.springframework
- spring-web
- 4.3.4.RELEASE
-
-
- org.springframework.boot
- spring-boot-starter
- 1.5.8.RELEASE
-
- org.hsqldb
- hsqldb
- 2.4.0
- runtime
+ org.springframework
+ spring-web
+ ${springframework.spring-web.version}
+
+
+ org.springframework.boot
+ spring-boot-starter
+ ${springframework.boot.spring-boot-starter.version}
+
+
+ com.h2database
+ h2
+ ${h2database.version}
+
+
+ javax.mail
+ mail
+ ${javax.mail.version}
@@ -244,17 +231,6 @@
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
- 1.8
- 1.8
-
-
-
org.apache.maven.plugins
maven-surefire-plugin
@@ -381,7 +357,7 @@
org.codehaus.mojo
exec-maven-plugin
- 1.6.0
+ ${exec-maven-plugin.version}
java
com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed
@@ -394,20 +370,17 @@
-
+
org.apache.maven.plugins
maven-javadoc-plugin
- 3.0.0-M1
+ ${maven-javadoc-plugin.version}
1.8
- 1.8
+ 1.8
-
-
-
@@ -447,7 +420,7 @@
run-benchmarks
-
+
none
exec
@@ -478,6 +451,7 @@
1.7.21
1.1.7
+ 1.2.17
22.0
@@ -496,10 +470,9 @@
1.13
0.6.5
0.9.0
-
+
1.3
- 4.12
2.8.9
3.6.1
1.7.0
@@ -507,5 +480,17 @@
3.7.0
2.19.1
+ 4.3.4.RELEASE
+ 1.5.8.RELEASE
+ 1.1
+ 1.3
+ 1.4.197
+ 2.1.0.1
+ 1.19
+ 1.19
+ 3.0.0-M1
+ 1.6.0
+ 1.5.0-b01
+
\ No newline at end of file
diff --git a/core-java/src/main/java/com/baeldung/assertion/Assertion.java b/core-java/src/main/java/com/baeldung/assertion/Assertion.java
new file mode 100644
index 0000000000..795728757c
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/assertion/Assertion.java
@@ -0,0 +1,26 @@
+package com.baeldung.assertion;
+
+/**
+ * Simple demonstration of using Java assert keyword.
+ */
+public class Assertion {
+
+ public static void main(String[] args) {
+ Assertion assertion = new Assertion();
+ assertion.setup();
+ }
+
+ public void setup() {
+ Object conn = getConnection();
+ assert conn != null : "Connection is null";
+
+ // continue with other setup ...
+ }
+
+ // Simulate failure to get a connection; using Object
+ // to avoid dependencies on JDBC or some other heavy
+ // 3rd party library
+ public Object getConnection() {
+ return null;
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/designpatterns/service/locator/Cache.java b/core-java/src/main/java/com/baeldung/designpatterns/service/locator/Cache.java
new file mode 100644
index 0000000000..847d8a71e0
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/designpatterns/service/locator/Cache.java
@@ -0,0 +1,39 @@
+package com.baeldung.designpatterns.service.locator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by Gebruiker on 4/20/2018.
+ */
+public class Cache {
+ private List services;
+
+ public Cache(){
+ services = new ArrayList();
+ }
+
+ public MessagingService getService(String serviceName){
+
+ for (MessagingService service : services) {
+ if(service.getServiceName().equalsIgnoreCase(serviceName)){
+ System.out.println("Returning cached " + serviceName + " object");
+ return service;
+ }
+ }
+ return null;
+ }
+
+ public void addService(MessagingService newService){
+ boolean exists = false;
+
+ for (MessagingService service : services) {
+ if(service.getServiceName().equalsIgnoreCase(newService.getServiceName())){
+ exists = true;
+ }
+ }
+ if(!exists){
+ services.add(newService);
+ }
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/designpatterns/service/locator/EmailService.java b/core-java/src/main/java/com/baeldung/designpatterns/service/locator/EmailService.java
new file mode 100644
index 0000000000..7ac7e05790
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/designpatterns/service/locator/EmailService.java
@@ -0,0 +1,15 @@
+package com.baeldung.designpatterns.service.locator;
+
+/**
+ * Created by Gebruiker on 4/20/2018.
+ */
+public class EmailService implements MessagingService {
+
+ public String getMessageBody() {
+ return "email message";
+ }
+
+ public String getServiceName() {
+ return "EmailService";
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/designpatterns/service/locator/InitialContext.java b/core-java/src/main/java/com/baeldung/designpatterns/service/locator/InitialContext.java
new file mode 100644
index 0000000000..d5234b39cd
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/designpatterns/service/locator/InitialContext.java
@@ -0,0 +1,17 @@
+package com.baeldung.designpatterns.service.locator;
+
+/**
+ * Created by Gebruiker on 4/20/2018.
+ */
+public class InitialContext {
+
+ public Object lookup(String serviceName) {
+
+ if (serviceName.equalsIgnoreCase("EmailService")) {
+ return new EmailService();
+ } else if (serviceName.equalsIgnoreCase("SMSService")) {
+ return new SMSService();
+ }
+ return null;
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/designpatterns/service/locator/Main.java b/core-java/src/main/java/com/baeldung/designpatterns/service/locator/Main.java
new file mode 100644
index 0000000000..787f7e708c
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/designpatterns/service/locator/Main.java
@@ -0,0 +1,22 @@
+package com.baeldung.designpatterns.service.locator;
+
+/**
+ * Created by Gebruiker on 4/20/2018.
+ */
+public class Main {
+
+ public static void main(String[] args) {
+
+ MessagingService service = ServiceLocator.getService("EmailService");
+ String email = service.getMessageBody();
+ System.out.println(email);
+
+ service = ServiceLocator.getService("SMSService");
+ String sms = service.getMessageBody();
+ System.out.println(sms);
+
+ service = ServiceLocator.getService("EmailService");
+ String newEmail = service.getMessageBody();
+ System.out.println(newEmail);
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/designpatterns/service/locator/MessagingService.java b/core-java/src/main/java/com/baeldung/designpatterns/service/locator/MessagingService.java
new file mode 100644
index 0000000000..5853dfd7f7
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/designpatterns/service/locator/MessagingService.java
@@ -0,0 +1,8 @@
+package com.baeldung.designpatterns.service.locator;
+
+public interface MessagingService {
+
+ String getMessageBody();
+
+ String getServiceName();
+}
diff --git a/core-java/src/main/java/com/baeldung/designpatterns/service/locator/SMSService.java b/core-java/src/main/java/com/baeldung/designpatterns/service/locator/SMSService.java
new file mode 100644
index 0000000000..87255ef658
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/designpatterns/service/locator/SMSService.java
@@ -0,0 +1,15 @@
+package com.baeldung.designpatterns.service.locator;
+
+/**
+ * Created by Gebruiker on 4/20/2018.
+ */
+public class SMSService implements MessagingService {
+
+ public String getMessageBody() {
+ return "sms message";
+ }
+
+ public String getServiceName() {
+ return "SMSService";
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/designpatterns/service/locator/ServiceLocator.java b/core-java/src/main/java/com/baeldung/designpatterns/service/locator/ServiceLocator.java
new file mode 100644
index 0000000000..7e1a2349a1
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/designpatterns/service/locator/ServiceLocator.java
@@ -0,0 +1,27 @@
+package com.baeldung.designpatterns.service.locator;
+
+/**
+ * Created by Gebruiker on 4/20/2018.
+ */
+public class ServiceLocator {
+
+ private static Cache cache;
+
+ static {
+ cache = new Cache();
+ }
+
+ public static MessagingService getService(String serviceName){
+
+ MessagingService service = cache.getService(serviceName);
+
+ if(service != null){
+ return service;
+ }
+
+ InitialContext context = new InitialContext();
+ MessagingService service1 = (MessagingService)context.lookup(serviceName);
+ cache.addService(service1);
+ return service1;
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/designpatterns/singleton/synchronization/DclSingleton.java b/core-java/src/main/java/com/baeldung/designpatterns/singleton/synchronization/DclSingleton.java
new file mode 100644
index 0000000000..e10f111a56
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/designpatterns/singleton/synchronization/DclSingleton.java
@@ -0,0 +1,38 @@
+package com.baeldung.designpatterns.singleton.synchronization;
+
+/**
+ * Double-checked locking design pattern applied to a singleton.
+ *
+ * @author Donato Rimenti
+ *
+ */
+public class DclSingleton {
+
+ /**
+ * Current instance of the singleton.
+ */
+ private static volatile DclSingleton instance;
+
+ /**
+ * Private constructor to avoid instantiation.
+ */
+ private DclSingleton() {
+ }
+
+ /**
+ * Returns the current instance of the singleton.
+ *
+ * @return the current instance of the singleton
+ */
+ public static DclSingleton getInstance() {
+ if (instance == null) {
+ synchronized (DclSingleton.class) {
+ if (instance == null) {
+ instance = new DclSingleton();
+ }
+ }
+ }
+ return instance;
+ }
+
+}
\ No newline at end of file
diff --git a/core-java/src/main/java/com/baeldung/designpatterns/singleton/synchronization/DraconianSingleton.java b/core-java/src/main/java/com/baeldung/designpatterns/singleton/synchronization/DraconianSingleton.java
new file mode 100644
index 0000000000..1d01c49b13
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/designpatterns/singleton/synchronization/DraconianSingleton.java
@@ -0,0 +1,34 @@
+package com.baeldung.designpatterns.singleton.synchronization;
+
+/**
+ * Draconian singleton. The method to get the instance is synchronized.
+ *
+ * @author Donato Rimenti
+ *
+ */
+public class DraconianSingleton {
+
+ /**
+ * Current instance of the singleton.
+ */
+ private static DraconianSingleton instance;
+
+ /**
+ * Private constructor to avoid instantiation.
+ */
+ private DraconianSingleton() {
+ }
+
+ /**
+ * Returns the current instance of the singleton.
+ *
+ * @return the current instance of the singleton
+ */
+ public static synchronized DraconianSingleton getInstance() {
+ if (instance == null) {
+ instance = new DraconianSingleton();
+ }
+ return instance;
+ }
+
+}
\ No newline at end of file
diff --git a/core-java/src/main/java/com/baeldung/designpatterns/singleton/synchronization/EarlyInitSingleton.java b/core-java/src/main/java/com/baeldung/designpatterns/singleton/synchronization/EarlyInitSingleton.java
new file mode 100644
index 0000000000..18c4b7cdce
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/designpatterns/singleton/synchronization/EarlyInitSingleton.java
@@ -0,0 +1,31 @@
+package com.baeldung.designpatterns.singleton.synchronization;
+
+/**
+ * Singleton with early initialization. Inlines the singleton instance
+ * initialization.
+ *
+ * @author Donato Rimenti
+ *
+ */
+public class EarlyInitSingleton {
+
+ /**
+ * Current instance of the singleton.
+ */
+ private static final EarlyInitSingleton INSTANCE = new EarlyInitSingleton();
+
+ /**
+ * Private constructor to avoid instantiation.
+ */
+ private EarlyInitSingleton() {
+ }
+
+ /**
+ * Returns the current instance of the singleton.
+ *
+ * @return the current instance of the singleton
+ */
+ public static EarlyInitSingleton getInstance() {
+ return INSTANCE;
+ }
+}
\ No newline at end of file
diff --git a/core-java/src/main/java/com/baeldung/designpatterns/singleton/synchronization/EnumSingleton.java b/core-java/src/main/java/com/baeldung/designpatterns/singleton/synchronization/EnumSingleton.java
new file mode 100644
index 0000000000..b7ff7f50b1
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/designpatterns/singleton/synchronization/EnumSingleton.java
@@ -0,0 +1,16 @@
+package com.baeldung.designpatterns.singleton.synchronization;
+
+/**
+ * Enum singleton pattern. Uses an enum to hold a reference to the singleton
+ * instance.
+ *
+ * @author Donato Rimenti
+ *
+ */
+public enum EnumSingleton {
+
+ /**
+ * Current instance of the singleton.
+ */
+ INSTANCE;
+}
\ No newline at end of file
diff --git a/core-java/src/main/java/com/baeldung/designpatterns/singleton/synchronization/InitOnDemandSingleton.java b/core-java/src/main/java/com/baeldung/designpatterns/singleton/synchronization/InitOnDemandSingleton.java
new file mode 100644
index 0000000000..d76bada786
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/designpatterns/singleton/synchronization/InitOnDemandSingleton.java
@@ -0,0 +1,41 @@
+package com.baeldung.designpatterns.singleton.synchronization;
+
+/**
+ * Initialization on demand singleton pattern. Uses a nested static class to
+ * hold a reference to the singleton instance.
+ *
+ * @author Donato Rimenti
+ *
+ */
+public class InitOnDemandSingleton {
+
+ /**
+ * Holder for a singleton instance.
+ *
+ * @author Donato Rimenti
+ *
+ */
+ private static class InstanceHolder {
+
+ /**
+ * Current instance of the singleton.
+ */
+ private static final InitOnDemandSingleton INSTANCE = new InitOnDemandSingleton();
+ }
+
+ /**
+ * Private constructor to avoid instantiation.
+ */
+ private InitOnDemandSingleton() {
+ }
+
+ /**
+ * Returns the current instance of the singleton.
+ *
+ * @return the current instance of the singleton
+ */
+ public static InitOnDemandSingleton getInstance() {
+ return InstanceHolder.INSTANCE;
+ }
+
+}
\ No newline at end of file
diff --git a/core-java/src/main/java/com/baeldung/jdbc/BatchProcessing.java b/core-java/src/main/java/com/baeldung/jdbc/BatchProcessing.java
index d5c53c3ffc..ad6a064c98 100644
--- a/core-java/src/main/java/com/baeldung/jdbc/BatchProcessing.java
+++ b/core-java/src/main/java/com/baeldung/jdbc/BatchProcessing.java
@@ -13,8 +13,8 @@ public class BatchProcessing {
public void getConnection(){
try {
- Class.forName("org.hsqldb.jdbcDriver");
- connection = DriverManager.getConnection("jdbc:hsqldb:file:C:\\EMPLOYEEDB", "SA", "");
+ Class.forName("org.h2.Driver");
+ connection = DriverManager.getConnection("jdbc:h2:mem:db", "SA", "");
connection.setAutoCommit(false);
} catch (Exception e) {
e.printStackTrace(System.out);
diff --git a/core-java/src/main/java/com/baeldung/keystore/JavaKeyStore.java b/core-java/src/main/java/com/baeldung/keystore/JavaKeyStore.java
new file mode 100644
index 0000000000..29cba37d43
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/keystore/JavaKeyStore.java
@@ -0,0 +1,92 @@
+package com.baeldung.keystore;
+
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.UnrecoverableEntryException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.util.Enumeration;
+
+/**
+ * Created by adi on 3/7/18.
+ */
+public class JavaKeyStore {
+
+ private KeyStore keyStore;
+
+ private String keyStoreName;
+ private String keyStoreType;
+ private String keyStorePassword;
+
+ JavaKeyStore(String keyStoreType, String keyStorePassword, String keyStoreName) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException {
+ this.keyStoreName = keyStoreName;
+ this.keyStoreType = keyStoreType;
+ this.keyStorePassword = keyStorePassword;
+ }
+
+ void createEmptyKeyStore() throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
+ if(keyStoreType ==null || keyStoreType.isEmpty()){
+ keyStoreType = KeyStore.getDefaultType();
+ }
+ keyStore = KeyStore.getInstance(keyStoreType);
+ //load
+ char[] pwdArray = keyStorePassword.toCharArray();
+ keyStore.load(null, pwdArray);
+
+ // Save the keyStore
+ FileOutputStream fos = new FileOutputStream(keyStoreName);
+ keyStore.store(fos, pwdArray);
+ fos.close();
+ }
+
+ void loadKeyStore() throws IOException, KeyStoreException, CertificateException, NoSuchAlgorithmException {
+ char[] pwdArray = keyStorePassword.toCharArray();
+ keyStore.load(new FileInputStream(keyStoreName), pwdArray);
+ }
+
+ void setEntry(String alias, KeyStore.SecretKeyEntry secretKeyEntry, KeyStore.ProtectionParameter protectionParameter) throws KeyStoreException {
+ keyStore.setEntry(alias, secretKeyEntry, protectionParameter);
+ }
+
+ KeyStore.Entry getEntry(String alias) throws UnrecoverableEntryException, NoSuchAlgorithmException, KeyStoreException {
+ KeyStore.ProtectionParameter protParam = new KeyStore.PasswordProtection(keyStorePassword.toCharArray());
+ return keyStore.getEntry(alias, protParam);
+ }
+
+ void setKeyEntry(String alias, PrivateKey privateKey, String keyPassword, Certificate[] certificateChain) throws KeyStoreException {
+ keyStore.setKeyEntry(alias, privateKey, keyPassword.toCharArray(), certificateChain);
+ }
+
+ void setCertificateEntry(String alias, Certificate certificate) throws KeyStoreException {
+ keyStore.setCertificateEntry(alias, certificate);
+ }
+
+ Certificate getCertificate(String alias) throws KeyStoreException {
+ return keyStore.getCertificate(alias);
+ }
+
+ void deleteEntry(String alias) throws KeyStoreException {
+ keyStore.deleteEntry(alias);
+ }
+
+ void deleteKeyStore() throws KeyStoreException, IOException {
+ Enumeration aliases = keyStore.aliases();
+ while (aliases.hasMoreElements()) {
+ String alias = aliases.nextElement();
+ keyStore.deleteEntry(alias);
+ }
+ keyStore = null;
+ Files.delete(Paths.get(keyStoreName));
+ }
+
+ KeyStore getKeyStore() {
+ return this.keyStore;
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/mail/EmailService.java b/core-java/src/main/java/com/baeldung/mail/EmailService.java
new file mode 100644
index 0000000000..e775b9f708
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/mail/EmailService.java
@@ -0,0 +1,80 @@
+package com.baeldung.mail;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.Properties;
+import javax.mail.*;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+
+public class EmailService {
+
+ private String host = "";
+ private int port = 0;
+ private String username = "";
+ private String password = "";
+
+
+ public EmailService(String host, int port, String username, String password) {
+
+ this.host = host;
+ this.port = port;
+ this.username = username;
+ this.password = password;
+
+ sendMail();
+ }
+
+ private void sendMail() {
+
+ Properties prop = new Properties();
+ prop.put("mail.smtp.auth", true);
+ prop.put("mail.smtp.starttls.enable", "true");
+ prop.put("mail.smtp.host", host);
+ prop.put("mail.smtp.port", port);
+ prop.put("mail.smtp.ssl.trust", host);
+
+ Session session = Session.getInstance(prop, new Authenticator() {
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(username, password);
+ }
+ });
+
+ try {
+
+ Message message = new MimeMessage(session);
+ message.setFrom(new InternetAddress("from@gmail.com"));
+ message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("to@gmail.com"));
+ message.setSubject("Mail Subject");
+
+ String msg = "This is my first email using JavaMailer";
+
+ MimeBodyPart mimeBodyPart = new MimeBodyPart();
+ mimeBodyPart.setContent(msg, "text/html");
+
+ MimeBodyPart attachmentBodyPart = new MimeBodyPart();
+ attachmentBodyPart.attachFile(new File("pom.xml"));
+
+ Multipart multipart = new MimeMultipart();
+ multipart.addBodyPart(mimeBodyPart);
+ multipart.addBodyPart(attachmentBodyPart);
+
+ message.setContent(multipart);
+
+ Transport.send(message);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void main(String ... args) {
+ new EmailService("smtp.mailtrap.io", 25, "87ba3d9555fae8", "91cb4379af43ed");
+ }
+
+}
diff --git a/core-java/src/main/java/com/baeldung/optionalparams/MultiVitamin.java b/core-java/src/main/java/com/baeldung/optionalparams/MultiVitamin.java
new file mode 100644
index 0000000000..709e74eac0
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/optionalparams/MultiVitamin.java
@@ -0,0 +1,50 @@
+package com.baeldung.optionalparams;
+
+public class MultiVitamin {
+
+ private String name; // required
+ private int vitaminA; // in mcg
+ private int vitaminC; // in mg
+ private int calcium; // in mg
+ private int iron; // in mg
+
+ public MultiVitamin(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getVitaminA() {
+ return vitaminA;
+ }
+
+ public void setVitaminA(int vitaminA) {
+ this.vitaminA = vitaminA;
+ }
+
+ public int getVitaminC() {
+ return vitaminC;
+ }
+
+ public void setVitaminC(int vitaminC) {
+ this.vitaminC = vitaminC;
+ }
+
+ public int getCalcium() {
+ return calcium;
+ }
+
+ public void setCalcium(int calcium) {
+ this.calcium = calcium;
+ }
+
+ public int getIron() {
+ return iron;
+ }
+
+ public void setIron(int iron) {
+ this.iron = iron;
+ }
+}
\ No newline at end of file
diff --git a/core-java/src/main/java/com/baeldung/optionalparams/MultiVitaminAllowingNulls.java b/core-java/src/main/java/com/baeldung/optionalparams/MultiVitaminAllowingNulls.java
new file mode 100644
index 0000000000..36d178783a
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/optionalparams/MultiVitaminAllowingNulls.java
@@ -0,0 +1,38 @@
+package com.baeldung.optionalparams;
+
+public class MultiVitaminAllowingNulls {
+
+ private String name; // required
+ private Integer vitaminA; // in mcg
+ private Integer vitaminC; // in mg
+ private Integer calcium; // in mg
+ private Integer iron; // in mg
+
+ public MultiVitaminAllowingNulls(String name, Integer vitaminA, Integer vitaminC, Integer calcium, Integer iron) {
+ this.name = name;
+ this.vitaminA = vitaminA;
+ this.vitaminC = vitaminC;
+ this.calcium = calcium;
+ this.iron = iron;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Integer getVitaminA() {
+ return vitaminA;
+ }
+
+ public Integer getVitaminC() {
+ return vitaminC;
+ }
+
+ public Integer getCalcium() {
+ return calcium;
+ }
+
+ public Integer getIron() {
+ return iron;
+ }
+}
\ No newline at end of file
diff --git a/core-java/src/main/java/com/baeldung/optionalparams/MultiVitaminOverloading.java b/core-java/src/main/java/com/baeldung/optionalparams/MultiVitaminOverloading.java
new file mode 100644
index 0000000000..e1d3032fd3
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/optionalparams/MultiVitaminOverloading.java
@@ -0,0 +1,56 @@
+package com.baeldung.optionalparams;
+
+public class MultiVitaminOverloading {
+
+ static final int DEFAULT_IRON_AMOUNT = 20;
+
+ private final String name; // required
+ private final int vitaminA; // in mcg
+ private final int vitaminC; // in mg
+ private final int calcium; // in mg
+ private final int iron; // in mg
+
+ public MultiVitaminOverloading(String name) {
+ this(name, 0);
+ }
+
+ public MultiVitaminOverloading(String name, int vitaminA) {
+ this(name, vitaminA, 0);
+ }
+
+ public MultiVitaminOverloading(String name, int vitaminA, int vitaminC) {
+ this(name, vitaminA, vitaminC, 0);
+ }
+
+ public MultiVitaminOverloading(String name, int vitaminA, int vitaminC, int calcium) {
+ this(name, vitaminA, vitaminC, calcium, DEFAULT_IRON_AMOUNT);
+ }
+
+ public MultiVitaminOverloading(String name, int vitaminA, int vitaminC, int calcium, int iron) {
+ this.name = name;
+ this.vitaminA = vitaminA;
+ this.vitaminC = vitaminC;
+ this.calcium = calcium;
+ this.iron = iron;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getVitaminA() {
+ return vitaminA;
+ }
+
+ public int getVitaminC() {
+ return vitaminC;
+ }
+
+ public int getCalcium() {
+ return calcium;
+ }
+
+ public int getIron() {
+ return iron;
+ }
+}
\ No newline at end of file
diff --git a/core-java/src/main/java/com/baeldung/optionalparams/MultiVitaminStaticFactoryMethods.java b/core-java/src/main/java/com/baeldung/optionalparams/MultiVitaminStaticFactoryMethods.java
new file mode 100644
index 0000000000..ca7ab0f6cf
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/optionalparams/MultiVitaminStaticFactoryMethods.java
@@ -0,0 +1,52 @@
+package com.baeldung.optionalparams;
+
+public class MultiVitaminStaticFactoryMethods {
+
+ static final int IRON_AMT_DEF = 20;
+ static final int IRON_AMT_MEN = 30;
+
+ static final int CALCIUM_AMT_DEF = 100;
+ static final int CALCIUM_AMT_WOMEN = 120;
+
+ private final String name; // required
+ private final int vitaminA; // in mcg
+ private final int vitaminC; // in mg
+ private final int calcium; // in mg
+ private final int iron; // in mg
+
+ public static MultiVitaminStaticFactoryMethods forMen(String name) {
+ return new MultiVitaminStaticFactoryMethods(name, 5000, 60, CALCIUM_AMT_DEF, IRON_AMT_MEN);
+ }
+
+ public static MultiVitaminStaticFactoryMethods forWomen(String name) {
+ return new MultiVitaminStaticFactoryMethods(name, 5000, 60, CALCIUM_AMT_WOMEN, IRON_AMT_DEF);
+ }
+
+ private MultiVitaminStaticFactoryMethods(String name, int vitaminA, int vitaminC, int calcium, int iron) {
+ this.name = name;
+ this.vitaminA = vitaminA;
+ this.vitaminC = vitaminC;
+ this.calcium = calcium;
+ this.iron = iron;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getVitaminA() {
+ return vitaminA;
+ }
+
+ public int getVitaminC() {
+ return vitaminC;
+ }
+
+ public int getCalcium() {
+ return calcium;
+ }
+
+ public int getIron() {
+ return iron;
+ }
+}
\ No newline at end of file
diff --git a/core-java/src/main/java/com/baeldung/optionalparams/MultiVitaminWithBuilder.java b/core-java/src/main/java/com/baeldung/optionalparams/MultiVitaminWithBuilder.java
new file mode 100644
index 0000000000..e1b2920e9a
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/optionalparams/MultiVitaminWithBuilder.java
@@ -0,0 +1,77 @@
+package com.baeldung.optionalparams;
+
+public class MultiVitaminWithBuilder {
+
+ private final String name; // required
+ private final int vitaminA; // in mcg
+ private final int vitaminC; // in mg
+ private final int calcium; // in mg
+ private final int iron; // in mg
+
+ private MultiVitaminWithBuilder(MultiVitaminBuilder builder) {
+ this.name = builder.name;
+ this.vitaminA = builder.vitaminA;
+ this.vitaminC = builder.vitaminC;
+ this.calcium = builder.calcium;
+ this.iron = builder.iron;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getVitaminA() {
+ return vitaminA;
+ }
+
+ public int getVitaminC() {
+ return vitaminC;
+ }
+
+ public int getCalcium() {
+ return calcium;
+ }
+
+ public int getIron() {
+ return iron;
+ }
+
+ public static class MultiVitaminBuilder {
+
+ private static final int ZERO = 0;
+
+ private final String name; // required
+ private int vitaminA = ZERO;
+ private int vitaminC = ZERO;
+ private int calcium = ZERO;
+ private int iron = ZERO;
+
+ public MultiVitaminBuilder(String name) {
+ this.name = name;
+ }
+
+ public MultiVitaminBuilder withVitaminA(int vitaminA) {
+ this.vitaminA = vitaminA;
+ return this;
+ }
+
+ public MultiVitaminBuilder withVitaminC(int vitaminC) {
+ this.vitaminC = vitaminC;
+ return this;
+ }
+
+ public MultiVitaminBuilder withCalcium(int calcium) {
+ this.calcium = calcium;
+ return this;
+ }
+
+ public MultiVitaminBuilder withIron(int iron) {
+ this.iron = iron;
+ return this;
+ }
+
+ public MultiVitaminWithBuilder build() {
+ return new MultiVitaminWithBuilder(this);
+ }
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java b/core-java/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java
new file mode 100644
index 0000000000..0e1746fc38
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java
@@ -0,0 +1,27 @@
+package com.baeldung.parameterpassing;
+
+public class NonPrimitives {
+ public static void main(String[] args) {
+ FooClass a = new FooClass(1);
+ FooClass b = new FooClass(1);
+
+ System.out.printf("Before Modification: a = %d and b = %d ", a.num, b.num);
+ modify(a, b);
+ System.out.printf("\nAfter Modification: a = %d and b = %d ", a.num, b.num);
+ }
+
+ public static void modify(FooClass a1, FooClass b1) {
+ a1.num++;
+
+ b1 = new FooClass(1);
+ b1.num++;
+ }
+}
+
+class FooClass {
+ public int num;
+
+ public FooClass(int num) {
+ this.num = num;
+ }
+}
\ No newline at end of file
diff --git a/core-java/src/main/java/com/baeldung/parameterpassing/Primitives.java b/core-java/src/main/java/com/baeldung/parameterpassing/Primitives.java
new file mode 100644
index 0000000000..f63229d7de
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/parameterpassing/Primitives.java
@@ -0,0 +1,17 @@
+package com.baeldung.parameterpassing;
+
+public class Primitives {
+ public static void main(String[] args) {
+ int x = 1;
+ int y = 2;
+
+ System.out.printf("Before Modification: x = %d and y = %d ", x, y);
+ modify(x, y);
+ System.out.printf("\nAfter Modification: x = %d and y = %d ", x, y);
+ }
+
+ public static void modify(int x1, int y1) {
+ x1 = 5;
+ y1 = 10;
+ }
+}
\ No newline at end of file
diff --git a/core-java/src/main/java/com/baeldung/system/ChatWindow.java b/core-java/src/main/java/com/baeldung/system/ChatWindow.java
new file mode 100644
index 0000000000..38bb9c63be
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/system/ChatWindow.java
@@ -0,0 +1,17 @@
+package com.baeldung.system;
+
+import java.awt.event.WindowEvent;
+
+/**
+ * Note: This class is not meant for unit-testing since it uses system
+ * features at low level and that it uses 'System' gc() which suggests
+ * JVM for garbage collection. But the usage below demonstrates how the
+ * method can be used.
+ */
+public class ChatWindow {
+ public void windowStateChanged(WindowEvent event) {
+ if (event.getNewState() == WindowEvent.WINDOW_DEACTIVATED ) {
+ System.gc(); // if it ends up running, great!
+ }
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/system/DateTimeService.java b/core-java/src/main/java/com/baeldung/system/DateTimeService.java
new file mode 100644
index 0000000000..ee13462d8a
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/system/DateTimeService.java
@@ -0,0 +1,16 @@
+package com.baeldung.system;
+
+import java.util.Date;
+
+public class DateTimeService {
+
+ // One hour from now
+ public long nowPlusOneHour() {
+ return System.currentTimeMillis() + 3600 * 1000L;
+ }
+
+ // Human-readable format
+ public String nowPrettyPrinted() {
+ return new Date(System.currentTimeMillis()).toString();
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/system/EnvironmentVariables.java b/core-java/src/main/java/com/baeldung/system/EnvironmentVariables.java
new file mode 100644
index 0000000000..53dc02a6f0
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/system/EnvironmentVariables.java
@@ -0,0 +1,7 @@
+package com.baeldung.system;
+
+public class EnvironmentVariables {
+ public String getPath() {
+ return System.getenv("PATH");
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/system/SystemErrDemo.java b/core-java/src/main/java/com/baeldung/system/SystemErrDemo.java
new file mode 100644
index 0000000000..0b1aeb95be
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/system/SystemErrDemo.java
@@ -0,0 +1,18 @@
+package com.baeldung.system;
+
+/**
+ * Note: This class is not meant for unit-testing since it uses system
+ * features at low level and that it uses 'System' standard error stream
+ * methods to show output on screen. Also unit-tests in CI environments
+ * don't have console output for user to see messages. But the usage below
+ * demonstrates how the methods can be used.
+ */
+public class SystemErrDemo {
+ public static void main(String[] args) {
+ // Print without 'hitting' return
+ System.err.print("some inline error message");
+
+ // Print and then 'hit' return
+ System.err.println("an error message having new line at the end");
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/system/SystemExitDemo.java b/core-java/src/main/java/com/baeldung/system/SystemExitDemo.java
new file mode 100644
index 0000000000..245d5724b8
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/system/SystemExitDemo.java
@@ -0,0 +1,24 @@
+package com.baeldung.system;
+
+/**
+ * Note: This class is not meant for unit-testing since it uses system
+ * features at low level and that it uses 'System' exit() which will
+ * exit the JVM. Also unit-tests in CI environments are not meant to
+ * exit unit tests like that. But the usage below demonstrates how the
+ * method can be used.
+ */
+public class SystemExitDemo {
+ public static void main(String[] args) {
+ boolean error = false;
+
+ // do something and set error value
+
+ if (error) {
+ System.exit(1); // error case exit
+ } else {
+ System.exit(0); // normal case exit
+ }
+
+ // Will not do anything after exit()
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/system/SystemOutDemo.java b/core-java/src/main/java/com/baeldung/system/SystemOutDemo.java
new file mode 100644
index 0000000000..474c4649c9
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/system/SystemOutDemo.java
@@ -0,0 +1,25 @@
+package com.baeldung.system;
+
+import java.io.FileNotFoundException;
+import java.io.PrintStream;
+
+/**
+ * Note: This class is not meant for unit-testing since it uses system
+ * features at low level and that it uses 'System' standard output stream
+ * methods to show output on screen. Also unit-tests in CI environments
+ * don't have console output for user to see messages. But the usage below
+ * demonstrates how the methods can be used.
+ */
+public class SystemOutDemo {
+
+ public static void main(String[] args) throws FileNotFoundException {
+ // Print without 'hitting' return
+ System.out.print("some inline message");
+
+ // Print and then 'hit' return
+ System.out.println("a message having new line at the end");
+
+ // Changes output stream to send messages to file.
+ System.setOut(new PrintStream("file.txt"));
+ }
+}
diff --git a/core-java/src/main/java/com/baeldung/system/UserCredentials.java b/core-java/src/main/java/com/baeldung/system/UserCredentials.java
new file mode 100644
index 0000000000..6f7debab24
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/system/UserCredentials.java
@@ -0,0 +1,35 @@
+package com.baeldung.system;
+
+import java.io.BufferedReader;
+import java.io.Console;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+/**
+ * Note: This class is not meant for unit-testing since it uses system
+ * features at low level and that it uses 'System' standard input stream
+ * methods to read text from user. Also unit-tests in CI environments
+ * don't have console input for user to type in text. But the usage below
+ * demonstrates how the methods can be used.
+ */
+public class UserCredentials {
+
+ public String readUsername(int length) throws IOException {
+ byte[] name = new byte[length];
+ System.in.read(name, 0, length); // by default, from the console
+ return new String(name);
+ }
+
+ public String readUsername() throws IOException {
+ BufferedReader reader =
+ new BufferedReader(new InputStreamReader(System.in));
+ return reader.readLine();
+ }
+
+ public String readUsernameWithPrompt() {
+ Console console = System.console();
+
+ return console == null ? null : // Console not available
+ console.readLine("%s", "Enter your name: ");
+ }
+}
diff --git a/core-java/src/main/resources/file.txt b/core-java/src/main/resources/file.txt
new file mode 100644
index 0000000000..558d8bbf35
--- /dev/null
+++ b/core-java/src/main/resources/file.txt
@@ -0,0 +1 @@
+baeldung.com
\ No newline at end of file
diff --git a/core-java/src/test/java/com/baeldung/array/converter/ArrayConvertToListTest.java b/core-java/src/test/java/com/baeldung/array/converter/ArrayConvertToListTest.java
new file mode 100644
index 0000000000..a5db46a9b6
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/array/converter/ArrayConvertToListTest.java
@@ -0,0 +1,116 @@
+package com.baeldung.array.converter;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+public class ArrayConvertToListTest {
+
+ @Test
+ public void givenAnStringArray_whenConvertArrayToList_thenListCreated() {
+ String[] flowers = { "Ageratum", "Allium", "Poppy", "Catmint" };
+ List flowerList = Arrays.asList(flowers);
+
+ assertNotNull(flowerList);
+ assertEquals(flowerList.size(), 4);
+ assertEquals(flowerList.get(0), "Ageratum");
+ assertEquals(flowerList.get(1), "Allium");
+ assertEquals(flowerList.get(2), "Poppy");
+ assertEquals(flowerList.get(3), "Catmint");
+ }
+
+ @Test
+ public void givenAnIntArray_whenConvertArrayToList_thenListWithOneElementCreated() {
+ int[] primitives = { 1, 2, 3, 4 };
+ List numbers = Arrays.asList(primitives);
+
+ assertNotNull(numbers);
+ assertEquals(numbers.size(), 1);
+ assertEquals(numbers.get(0), primitives);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void givenAnStringArray_whenConvertArrayToListAndAddAnElement_thenThrowUnsupportedOperationException() {
+ String[] flowers = { "Ageratum", "Allium", "Poppy", "Catmint" };
+ List flowerList = Arrays.asList(flowers);
+
+ assertNotNull(flowerList);
+ assertEquals(flowerList.size(), 4);
+ assertEquals(flowerList.get(0), "Ageratum");
+ assertEquals(flowerList.get(1), "Allium");
+ assertEquals(flowerList.get(2), "Poppy");
+ assertEquals(flowerList.get(3), "Catmint");
+
+ flowerList.add("Celosia");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void givenAnStringArray_whenConvertArrayToListAndRemoveAnElement_thenThrowUnsupportedOperationException() {
+ String[] flowers = { "Ageratum", "Allium", "Poppy", "Catmint" };
+ List flowerList = Arrays.asList(flowers);
+
+ assertNotNull(flowerList);
+ assertEquals(flowerList.size(), 4);
+ assertEquals(flowerList.get(0), "Ageratum");
+ assertEquals(flowerList.get(1), "Allium");
+ assertEquals(flowerList.get(2), "Poppy");
+ assertEquals(flowerList.get(3), "Catmint");
+
+ flowerList.remove("Poppy");
+ }
+
+ @Test
+ public void givenAnStringArray_whenCreateListFromArrayAndAddAnElement_thenListOk() {
+ String[] flowers = { "Ageratum", "Allium", "Poppy", "Catmint" };
+ List flowerList = Arrays.asList(flowers);
+
+ assertNotNull(flowerList);
+ assertEquals(flowerList.size(), 4);
+
+ assertEquals(flowerList.get(0), "Ageratum");
+ assertEquals(flowerList.get(1), "Allium");
+ assertEquals(flowerList.get(2), "Poppy");
+ assertEquals(flowerList.get(3), "Catmint");
+
+ List newflowerList = new ArrayList<>(flowerList);
+
+ assertNotNull(newflowerList);
+ assertEquals(newflowerList.size(), 4);
+ assertEquals(newflowerList.get(0), "Ageratum");
+ assertEquals(newflowerList.get(1), "Allium");
+ assertEquals(newflowerList.get(2), "Poppy");
+ assertEquals(newflowerList.get(3), "Catmint");
+
+ newflowerList.add("Celosia");
+
+ assertEquals(newflowerList.size(), 5);
+ assertEquals(newflowerList.get(4), "Celosia");
+ }
+
+ @Test
+ public void givenAnStringArray_whenIterateArrayAndAddTheElementsToNewListAndAddAnElement_thenListOk() {
+ String[] flowers = { "Ageratum", "Allium", "Poppy", "Catmint" };
+
+ List flowerList = new ArrayList<>();
+ for(String flower: flowers) {
+ flowerList.add(flower);
+ }
+
+ assertNotNull(flowerList);
+ assertEquals(flowerList.size(), 4);
+
+ assertEquals(flowerList.get(0), "Ageratum");
+ assertEquals(flowerList.get(1), "Allium");
+ assertEquals(flowerList.get(2), "Poppy");
+ assertEquals(flowerList.get(3), "Catmint");
+
+ flowerList.add("Celosia");
+
+ assertEquals(flowerList.size(), 5);
+ assertEquals(flowerList.get(4), "Celosia");
+ }
+}
diff --git a/core-java/src/test/java/com/baeldung/designpatterns/singleton/synchronization/SingletonSynchronizationUnitTest.java b/core-java/src/test/java/com/baeldung/designpatterns/singleton/synchronization/SingletonSynchronizationUnitTest.java
new file mode 100644
index 0000000000..2c1a3fe093
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/designpatterns/singleton/synchronization/SingletonSynchronizationUnitTest.java
@@ -0,0 +1,119 @@
+package com.baeldung.designpatterns.singleton.synchronization;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Unit tests for the singleton synchronization package with the same name.
+ *
+ * @author Donato Rimenti
+ *
+ */
+public class SingletonSynchronizationUnitTest {
+
+ /**
+ * Size of the thread pools used.
+ */
+ private static final int POOL_SIZE = 1_000;
+
+ /**
+ * Number of tasks to submit.
+ */
+ private static final int TASKS_TO_SUBMIT = 1_000_000;
+
+ /**
+ * Tests the thread-safety of {@link DraconianSingleton}.
+ */
+ @Test
+ public void givenDraconianSingleton_whenMultithreadInstancesEquals_thenTrue() {
+ ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);
+ Set resultSet = Collections.synchronizedSet(new HashSet());
+
+ // Submits the instantiation tasks.
+ for (int i = 0; i < TASKS_TO_SUBMIT; i++) {
+ executor.submit(() -> resultSet.add(DraconianSingleton.getInstance()));
+ }
+
+ // Since the instance of the object we inserted into the set is always
+ // the same, the size should be one.
+ Assert.assertEquals(1, resultSet.size());
+ }
+
+ /**
+ * Tests the thread-safety of {@link DclSingleton}.
+ */
+ @Test
+ public void givenDclSingleton_whenMultithreadInstancesEquals_thenTrue() {
+ ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);
+ Set resultSet = Collections.synchronizedSet(new HashSet());
+
+ // Submits the instantiation tasks.
+ for (int i = 0; i < TASKS_TO_SUBMIT; i++) {
+ executor.submit(() -> resultSet.add(DclSingleton.getInstance()));
+ }
+
+ // Since the instance of the object we inserted into the set is always
+ // the same, the size should be one.
+ Assert.assertEquals(1, resultSet.size());
+ }
+
+ /**
+ * Tests the thread-safety of {@link EarlyInitSingleton}.
+ */
+ @Test
+ public void givenEarlyInitSingleton_whenMultithreadInstancesEquals_thenTrue() {
+ ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);
+ Set resultSet = Collections.synchronizedSet(new HashSet());
+
+ // Submits the instantiation tasks.
+ for (int i = 0; i < TASKS_TO_SUBMIT; i++) {
+ executor.submit(() -> resultSet.add(EarlyInitSingleton.getInstance()));
+ }
+
+ // Since the instance of the object we inserted into the set is always
+ // the same, the size should be one.
+ Assert.assertEquals(1, resultSet.size());
+ }
+
+ /**
+ * Tests the thread-safety of {@link InitOnDemandSingleton}.
+ */
+ @Test
+ public void givenInitOnDemandSingleton_whenMultithreadInstancesEquals_thenTrue() {
+ ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);
+ Set resultSet = Collections.synchronizedSet(new HashSet());
+
+ // Submits the instantiation tasks.
+ for (int i = 0; i < TASKS_TO_SUBMIT; i++) {
+ executor.submit(() -> resultSet.add(InitOnDemandSingleton.getInstance()));
+ }
+
+ // Since the instance of the object we inserted into the set is always
+ // the same, the size should be one.
+ Assert.assertEquals(1, resultSet.size());
+ }
+
+ /**
+ * Tests the thread-safety of {@link EnumSingleton}.
+ */
+ @Test
+ public void givenEnumSingleton_whenMultithreadInstancesEquals_thenTrue() {
+ ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);
+ Set resultSet = Collections.synchronizedSet(new HashSet());
+
+ // Submits the instantiation tasks.
+ for (int i = 0; i < TASKS_TO_SUBMIT; i++) {
+ executor.submit(() -> resultSet.add(EnumSingleton.INSTANCE));
+ }
+
+ // Since the instance of the object we inserted into the set is always
+ // the same, the size should be one.
+ Assert.assertEquals(1, resultSet.size());
+ }
+}
diff --git a/core-java/src/test/java/com/baeldung/java/clock/ClockUnitTest.java b/core-java/src/test/java/com/baeldung/java/clock/ClockUnitTest.java
new file mode 100644
index 0000000000..e83ba7afc8
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/java/clock/ClockUnitTest.java
@@ -0,0 +1,159 @@
+package com.baeldung.java.clock;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.time.Clock;
+import java.time.Duration;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ClockUnitTest {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ClockUnitTest.class);
+
+ @Test
+ public void givenClock_withSytemUTC_retrievesInstant() {
+
+ Clock clockUTC = Clock.systemUTC();
+
+ assertEquals(clockUTC.getZone(), ZoneOffset.UTC);
+ assertEquals(clockUTC.instant().equals(null), false);
+
+ LOGGER.debug("UTC instant :: " + clockUTC.instant());
+ }
+
+ @Test
+ public void givenClock_withSytem_retrievesInstant() {
+
+ Clock clockSystem = Clock.system(ZoneId.of("Asia/Calcutta"));
+
+ assertEquals(clockSystem.getZone(), ZoneId.of("Asia/Calcutta"));
+ assertEquals(clockSystem.instant().equals(null), false);
+
+ LOGGER.debug("System zone :: " + clockSystem.getZone());
+ }
+
+ @Test
+ public void givenClock_withSytemDefaultZone_retrievesInstant() {
+
+ Clock clockSystemDefault = Clock.systemDefaultZone();
+
+ assertEquals(clockSystemDefault.getZone().equals(null), false);
+ assertEquals(clockSystemDefault.instant().equals(null), false);
+
+ LOGGER.debug("System Default instant :: " + clockSystemDefault.instant());
+ }
+
+ @Test
+ public void givenClock_withSytemUTC_retrievesTimeInMillis() {
+
+ Clock clockMillis = Clock.systemDefaultZone();
+
+ assertEquals(clockMillis.instant().equals(null), false);
+ assertTrue(clockMillis.millis() > 0);
+
+ LOGGER.debug("System Default millis :: " + clockMillis.millis());
+ }
+
+ @Test
+ public void givenClock_usingOffset_retrievesFutureDate() {
+
+ Clock baseClock = Clock.systemDefaultZone();
+
+ // result clock will be later than baseClock
+ Clock futureClock = Clock.offset(baseClock, Duration.ofHours(72));
+
+ assertEquals(futureClock.instant().equals(null), false);
+ assertTrue(futureClock.millis() > baseClock.millis());
+
+ LOGGER.debug("Future Clock instant :: " + futureClock.instant());
+ }
+
+ @Test
+ public void givenClock_usingOffset_retrievesPastDate() {
+ Clock baseClock = Clock.systemDefaultZone();
+
+ // result clock will be later than baseClock
+ Clock pastClock = Clock.offset(baseClock, Duration.ofHours(-72));
+
+ assertEquals(pastClock.instant().equals(null), false);
+ assertTrue(pastClock.millis() < baseClock.millis());
+
+ LOGGER.debug("Past Clock instant :: " + pastClock.instant());
+ }
+
+ @Test
+ public void givenClock_usingTick_retrievesInstant() {
+ Clock clockDefaultZone = Clock.systemDefaultZone();
+ Clock clocktick = Clock.tick(clockDefaultZone, Duration.ofSeconds(300));
+
+ assertEquals(clockDefaultZone.instant().equals(null), false);
+ assertEquals(clocktick.instant().equals(null), false);
+ assertTrue(clockDefaultZone.millis() > clocktick.millis());
+
+ LOGGER.debug("Clock Default Zone instant : " + clockDefaultZone.instant());
+ LOGGER.debug("Clock tick instant: " + clocktick.instant());
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void givenClock_usingTickDurationNegative_throwsException() {
+
+ Clock clockDefaultZone = Clock.systemDefaultZone();
+ Clock.tick(clockDefaultZone, Duration.ofSeconds(-300));
+
+ }
+
+ @Test
+ public void givenClock_usingTickSeconds_retrievesInstant() {
+ ZoneId zoneId = ZoneId.of("Asia/Calcutta");
+ Clock tickSeconds = Clock.tickSeconds(zoneId);
+
+ assertEquals(tickSeconds.instant().equals(null), false);
+ LOGGER.debug("Clock tick seconds instant :: " + tickSeconds.instant());
+
+ tickSeconds = Clock.tick(Clock.system(ZoneId.of("Asia/Calcutta")), Duration.ofSeconds(100));
+ assertEquals(tickSeconds.instant().equals(null), false);
+ }
+
+ @Test
+ public void givenClock_usingTickMinutes_retrievesInstant() {
+
+ Clock tickMinutes = Clock.tickMinutes(ZoneId.of("Asia/Calcutta"));
+
+ assertEquals(tickMinutes.instant().equals(null), false);
+ LOGGER.debug("Clock tick seconds instant :: " + tickMinutes.instant());
+
+ tickMinutes = Clock.tick(Clock.system(ZoneId.of("Asia/Calcutta")), Duration.ofMinutes(5));
+ assertEquals(tickMinutes.instant().equals(null), false);
+ }
+
+ @Test
+ public void givenClock_usingWithZone_retrievesInstant() {
+
+ ZoneId zoneSingapore = ZoneId.of("Asia/Singapore");
+ Clock clockSingapore = Clock.system(zoneSingapore);
+
+ assertEquals(clockSingapore.instant().equals(null), false);
+ LOGGER.debug("clockSingapore instant : " + clockSingapore.instant());
+
+ ZoneId zoneCalcutta = ZoneId.of("Asia/Calcutta");
+ Clock clockCalcutta = clockSingapore.withZone(zoneCalcutta);
+ assertEquals(clockCalcutta.instant().equals(null), false);
+ LOGGER.debug("clockCalcutta instant : " + clockSingapore.instant());
+ }
+
+ @Test
+ public void givenClock_usingGetZone_retrievesZoneId() {
+
+ Clock clockDefaultZone = Clock.systemDefaultZone();
+ ZoneId zone = clockDefaultZone.getZone();
+
+ assertEquals(zone.getId().equals(null), false);
+ LOGGER.debug("Default zone instant : " + clockDefaultZone.instant());
+ }
+}
diff --git a/core-java/src/test/java/com/baeldung/keystore/JavaKeyStoreTest.java b/core-java/src/test/java/com/baeldung/keystore/JavaKeyStoreTest.java
new file mode 100644
index 0000000000..ff1d337597
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/keystore/JavaKeyStoreTest.java
@@ -0,0 +1,205 @@
+package com.baeldung.keystore;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import sun.security.x509.AlgorithmId;
+import sun.security.x509.CertificateAlgorithmId;
+import sun.security.x509.CertificateSerialNumber;
+import sun.security.x509.CertificateValidity;
+import sun.security.x509.CertificateVersion;
+import sun.security.x509.CertificateX509Key;
+import sun.security.x509.X500Name;
+import sun.security.x509.X509CertImpl;
+import sun.security.x509.X509CertInfo;
+
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.security.InvalidKeyException;
+import java.security.KeyPair;
+import java.security.KeyPairGenerator;
+import java.security.KeyStore;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.SecureRandom;
+import java.security.SignatureException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.Date;
+
+/**
+ * Created by adi on 4/14/18.
+ */
+public class JavaKeyStoreTest {
+
+ private JavaKeyStore keyStore;
+
+ private static final String KEYSTORE_PWD = "abc123";
+ private static final String KEYSTORE_NAME = "myKeyStore";
+ private static final String KEY_STORE_TYPE = "JCEKS";
+
+ private static final String MY_SECRET_ENTRY = "mySecretEntry";
+ private static final String DN_NAME = "CN=test, OU=test, O=test, L=test, ST=test, C=CY";
+ private static final String SHA1WITHRSA = "SHA1withRSA";
+ private static final String MY_PRIVATE_KEY = "myPrivateKey";
+ private static final String MY_CERTIFICATE = "myCertificate";
+
+ @Before
+ public void setUp() throws Exception {
+ //using java cryptography extension keyStore instead of Keystore.getDefaultType
+ keyStore = new JavaKeyStore(KEY_STORE_TYPE, KEYSTORE_PWD, KEYSTORE_NAME);
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ if (keyStore.getKeyStore() != null) {
+ keyStore.deleteKeyStore();
+ }
+ }
+
+ @Test
+ public void givenNoKeyStore_whenCreateEmptyKeyStore_thenGetKeyStoreNotNull() throws Exception {
+ keyStore.createEmptyKeyStore();
+ KeyStore result = keyStore.getKeyStore();
+ Assert.assertNotNull(result);
+ }
+
+ @Test
+ public void givenEmptyKeystore_whenLoadKeyStore_thenKeyStoreLoadedAndSizeZero() throws Exception {
+ keyStore.createEmptyKeyStore();
+ keyStore.loadKeyStore();
+ KeyStore result = keyStore.getKeyStore();
+ Assert.assertNotNull(result);
+ Assert.assertTrue(result.size() == 0);
+ }
+
+ @Test
+ public void givenLoadedKeyStore_whenSetEntry_thenSizeIsOneAndGetKeyNotNull() throws Exception {
+ keyStore.createEmptyKeyStore();
+ keyStore.loadKeyStore();
+
+ KeyGenerator keygen = KeyGenerator.getInstance("HmacSHA256");
+ SecretKey secretKey = keygen.generateKey();
+ //ideally, password should be different for every key
+ KeyStore.ProtectionParameter protParam = new KeyStore.PasswordProtection(KEYSTORE_PWD.toCharArray());
+ KeyStore.SecretKeyEntry secretKeyEntry = new KeyStore.SecretKeyEntry(secretKey);
+ keyStore.setEntry(MY_SECRET_ENTRY, secretKeyEntry, protParam);
+
+ KeyStore result = keyStore.getKeyStore();
+ Assert.assertTrue(result.size() == 1);
+ KeyStore.Entry entry = keyStore.getEntry(MY_SECRET_ENTRY);
+ Assert.assertTrue(entry != null);
+ }
+
+ @Test
+ public void givenLoadedKeyStore_whenSetKeyEntry_thenSizeIsOneAndGetEntryNotNull() throws Exception {
+ keyStore.createEmptyKeyStore();
+ keyStore.loadKeyStore();
+
+ // Generate the key pair
+ KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
+ keyPairGenerator.initialize(1024);
+ KeyPair keyPair = keyPairGenerator.generateKeyPair();
+
+ // Generate a self signed certificate
+ X509Certificate certificate = generateSelfSignedCertificate(keyPair);
+
+ X509Certificate[] certificateChain = new X509Certificate[1];
+ certificateChain[0] = certificate;
+ keyStore.setKeyEntry(MY_PRIVATE_KEY, keyPair.getPrivate(), KEYSTORE_PWD, certificateChain);
+
+ KeyStore result = keyStore.getKeyStore();
+ Assert.assertTrue(result.size() == 1);
+ KeyStore.Entry entry = keyStore.getEntry(MY_PRIVATE_KEY);
+ Assert.assertTrue(entry != null);
+ }
+
+ @Test
+ public void givenLoadedKeyStore_whenSetCertificateEntry_thenSizeIsOneAndGetCertificateEntryNotNull() throws Exception {
+ keyStore.createEmptyKeyStore();
+ keyStore.loadKeyStore();
+
+ // Generate the key pair
+ KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
+ keyPairGenerator.initialize(1024);
+ KeyPair keyPair = keyPairGenerator.generateKeyPair();
+
+ // Generate a self signed certificate
+ X509Certificate certificate = generateSelfSignedCertificate(keyPair);
+
+ keyStore.setCertificateEntry(MY_CERTIFICATE, certificate);
+
+ KeyStore result = this.keyStore.getKeyStore();
+ Assert.assertTrue(result.size() == 1);
+ java.security.cert.Certificate resultCertificate = keyStore.getCertificate(MY_CERTIFICATE);
+ Assert.assertNotNull(resultCertificate);
+ }
+
+ @Test
+ public void givenLoadedKeyStoreWithOneEntry_whenDeleteEntry_thenKeyStoreSizeIsZero() throws Exception {
+ keyStore.createEmptyKeyStore();
+ keyStore.loadKeyStore();
+
+ KeyGenerator keygen = KeyGenerator.getInstance("HmacSHA256");
+ SecretKey secretKey = keygen.generateKey();
+ //ideally, password should be different for every key
+ KeyStore.ProtectionParameter protParam = new KeyStore.PasswordProtection(KEYSTORE_PWD.toCharArray());
+ KeyStore.SecretKeyEntry secretKeyEntry = new KeyStore.SecretKeyEntry(secretKey);
+ keyStore.setEntry(MY_SECRET_ENTRY, secretKeyEntry, protParam);
+
+ keyStore.deleteEntry(MY_SECRET_ENTRY);
+
+ KeyStore result = this.keyStore.getKeyStore();
+ Assert.assertTrue(result.size() == 0);
+ }
+
+ @Test
+ public void givenLoadedKeystore_whenDeleteKeyStore_thenKeyStoreIsNull() throws Exception {
+ keyStore.createEmptyKeyStore();
+ keyStore.loadKeyStore();
+
+ keyStore.deleteKeyStore();
+
+ KeyStore result = this.keyStore.getKeyStore();
+ Assert.assertTrue(result == null);
+ }
+
+ private X509Certificate generateSelfSignedCertificate(KeyPair keyPair) throws CertificateException, IOException, NoSuchProviderException, NoSuchAlgorithmException, InvalidKeyException, SignatureException {
+ X509CertInfo certInfo = new X509CertInfo();
+ // Serial number and version
+ certInfo.set(X509CertInfo.SERIAL_NUMBER, new CertificateSerialNumber(new BigInteger(64, new SecureRandom())));
+ certInfo.set(X509CertInfo.VERSION, new CertificateVersion(CertificateVersion.V3));
+
+ // Subject & Issuer
+ X500Name owner = new X500Name(DN_NAME);
+ certInfo.set(X509CertInfo.SUBJECT, owner);
+ certInfo.set(X509CertInfo.ISSUER, owner);
+
+ // Key and algorithm
+ certInfo.set(X509CertInfo.KEY, new CertificateX509Key(keyPair.getPublic()));
+ AlgorithmId algorithm = new AlgorithmId(AlgorithmId.sha1WithRSAEncryption_oid);
+ certInfo.set(X509CertInfo.ALGORITHM_ID, new CertificateAlgorithmId(algorithm));
+
+ // Validity
+ Date validFrom = new Date();
+ Date validTo = new Date(validFrom.getTime() + 50L * 365L * 24L * 60L * 60L * 1000L); //50 years
+ CertificateValidity validity = new CertificateValidity(validFrom, validTo);
+ certInfo.set(X509CertInfo.VALIDITY, validity);
+
+ // Create certificate and sign it
+ X509CertImpl cert = new X509CertImpl(certInfo);
+ cert.sign(keyPair.getPrivate(), SHA1WITHRSA);
+
+ // Since the SHA1withRSA provider may have a different algorithm ID to what we think it should be,
+ // we need to reset the algorithm ID, and resign the certificate
+ AlgorithmId actualAlgorithm = (AlgorithmId) cert.get(X509CertImpl.SIG_ALG);
+ certInfo.set(CertificateAlgorithmId.NAME + "." + CertificateAlgorithmId.ALGORITHM, actualAlgorithm);
+ X509CertImpl newCert = new X509CertImpl(certInfo);
+ newCert.sign(keyPair.getPrivate(), SHA1WITHRSA);
+
+ return newCert;
+ }
+}
\ No newline at end of file
diff --git a/core-java/src/test/java/com/baeldung/optionalparams/OptionalParamsUnitTest.java b/core-java/src/test/java/com/baeldung/optionalparams/OptionalParamsUnitTest.java
new file mode 100644
index 0000000000..4f3c31822b
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/optionalparams/OptionalParamsUnitTest.java
@@ -0,0 +1,96 @@
+package com.baeldung.optionalparams;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.math.BigDecimal;
+
+import org.assertj.core.util.Arrays;
+import org.junit.Test;
+
+public class OptionalParamsUnitTest {
+
+ @Test
+ public void whenCreateMultiVitaminWithOverloading_thenOk() {
+ MultiVitaminOverloading multiVitamin = new MultiVitaminOverloading("Default Multivitamin");
+
+ assertThat(multiVitamin.getName()).isEqualTo("Default Multivitamin");
+ assertThat(multiVitamin.getVitaminA()).isEqualTo(0);
+ assertThat(multiVitamin.getVitaminC()).isEqualTo(0);
+ assertThat(multiVitamin.getCalcium()).isEqualTo(0);
+ assertThat(multiVitamin.getIron()).isEqualTo(MultiVitaminOverloading.DEFAULT_IRON_AMOUNT);
+ }
+
+ @Test
+ public void whenCreateMultiVitaminWithStaticFactoryMethods_thenOk() {
+ MultiVitaminStaticFactoryMethods mensMultiVitamin = MultiVitaminStaticFactoryMethods.forMen("Complete for Men");
+
+ assertThat(mensMultiVitamin.getName()).isEqualTo("Complete for Men");
+ assertThat(mensMultiVitamin.getCalcium()).isEqualTo(MultiVitaminStaticFactoryMethods.CALCIUM_AMT_DEF);
+ assertThat(mensMultiVitamin.getIron()).isEqualTo(MultiVitaminStaticFactoryMethods.IRON_AMT_MEN);
+
+ MultiVitaminStaticFactoryMethods womensMultiVitamin = MultiVitaminStaticFactoryMethods.forWomen("Complete for Women");
+
+ assertThat(womensMultiVitamin.getName()).isEqualTo("Complete for Women");
+ assertThat(womensMultiVitamin.getCalcium()).isEqualTo(MultiVitaminStaticFactoryMethods.CALCIUM_AMT_WOMEN);
+ assertThat(womensMultiVitamin.getIron()).isEqualTo(MultiVitaminStaticFactoryMethods.IRON_AMT_DEF);
+ }
+
+ @Test
+ public void whenCreateMultiVitaminWithBuilder_thenOk() {
+ MultiVitaminWithBuilder vitamin = new MultiVitaminWithBuilder.MultiVitaminBuilder("Maximum Strength")
+ .withCalcium(100)
+ .withIron(200)
+ .withVitaminA(50)
+ .withVitaminC(1000)
+ .build();
+
+ assertThat(vitamin.getName()).isEqualTo("Maximum Strength");
+ assertThat(vitamin.getCalcium()).isEqualTo(100);
+ assertThat(vitamin.getIron()).isEqualTo(200);
+ assertThat(vitamin.getVitaminA()).isEqualTo(50);
+ assertThat(vitamin.getVitaminC()).isEqualTo(1000);
+ }
+
+ @Test
+ public void whenCreateMutliVitaminWithAccessors_thenOk() {
+ MultiVitamin vitamin = new MultiVitamin("Generic");
+ vitamin.setVitaminA(50);
+ vitamin.setVitaminC(1000);
+ vitamin.setCalcium(100);
+ vitamin.setIron(200);
+
+ assertThat(vitamin.getName()).isEqualTo("Generic");
+ assertThat(vitamin.getCalcium()).isEqualTo(100);
+ assertThat(vitamin.getIron()).isEqualTo(200);
+ assertThat(vitamin.getVitaminA()).isEqualTo(50);
+ assertThat(vitamin.getVitaminC()).isEqualTo(1000);
+ }
+
+ @Test
+ public void whenCreateMultiVitaminWithNulls_thenOk() {
+ MultiVitamin vitamin = new MultiVitamin(null);
+
+ assertThat(vitamin.getName()).isNull();
+ }
+
+ public void varArgsDemo() {
+ Object[] args = Arrays.array(Long.valueOf(1), Integer.valueOf(2), BigDecimal.valueOf(3));
+
+ processVarArgsWithCastingAntiPattern(args);
+ }
+
+ private void processVarArgsWithCastingAntiPattern(Object... args) {
+ String message = "processing %s as %s";
+
+ // never do this sort of thing
+ for (Object arg : args) {
+ if (arg instanceof Long) {
+ System.out.println(String.format(message, arg, "Long"));
+ } else if (arg instanceof Integer) {
+ System.out.println(String.format(message, arg, "Integer"));
+ } else if (arg instanceof BigDecimal) {
+ System.out.println(String.format(message, arg, "BigDecimal"));
+ }
+ }
+ }
+}
diff --git a/core-java/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java b/core-java/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java
new file mode 100644
index 0000000000..62f891d11b
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java
@@ -0,0 +1,37 @@
+package com.baeldung.parameterpassing;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class NonPrimitivesUnitTest {
+ @Test
+ public void whenModifyingObjects_thenOriginalObjectChanged() {
+ Foo a = new Foo(1);
+ Foo b = new Foo(1);
+
+ // Before Modification
+ Assert.assertEquals(a.num, 1);
+ Assert.assertEquals(b.num, 1);
+
+ modify(a, b);
+
+ // After Modification
+ Assert.assertEquals(a.num, 2);
+ Assert.assertEquals(b.num, 1);
+ }
+
+ public static void modify(Foo a1, Foo b1) {
+ a1.num++;
+
+ b1 = new Foo(1);
+ b1.num++;
+ }
+}
+
+class Foo {
+ public int num;
+
+ public Foo(int num) {
+ this.num = num;
+ }
+}
\ No newline at end of file
diff --git a/core-java/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java b/core-java/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java
new file mode 100644
index 0000000000..496cd1d205
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java
@@ -0,0 +1,28 @@
+package com.baeldung.parameterpassing;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class PrimitivesUnitTest {
+ @Test
+ public void whenModifyingPrimitives_thenOriginalValuesNotModified() {
+
+ int x = 1;
+ int y = 2;
+
+ // Before Modification
+ Assert.assertEquals(x, 1);
+ Assert.assertEquals(y, 2);
+
+ modify(x, y);
+
+ // After Modification
+ Assert.assertEquals(x, 1);
+ Assert.assertEquals(y, 2);
+ }
+
+ public static void modify(int x1, int y1) {
+ x1 = 5;
+ y1 = 10;
+ }
+}
diff --git a/core-java/src/test/java/com/baeldung/system/DateTimeServiceTest.java b/core-java/src/test/java/com/baeldung/system/DateTimeServiceTest.java
new file mode 100644
index 0000000000..587cd4ef20
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/system/DateTimeServiceTest.java
@@ -0,0 +1,15 @@
+package com.baeldung.system;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DateTimeServiceTest {
+
+ @Test
+ public void givenClass_whenCalledMethods_thenNotNullInResult() {
+ DateTimeService dateTimeService = new DateTimeService();
+
+ Assert.assertNotNull(dateTimeService.nowPlusOneHour());
+ Assert.assertNotNull(dateTimeService.nowPrettyPrinted());
+ }
+}
diff --git a/core-java/src/test/java/com/baeldung/system/EnvironmentVariablesTest.java b/core-java/src/test/java/com/baeldung/system/EnvironmentVariablesTest.java
new file mode 100644
index 0000000000..3722fea88f
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/system/EnvironmentVariablesTest.java
@@ -0,0 +1,14 @@
+package com.baeldung.system;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class EnvironmentVariablesTest {
+
+ @Test
+ public void givenEnvVars_whenReadPath_thenGetValueinResult() {
+ EnvironmentVariables environmentVariables = new EnvironmentVariables();
+
+ Assert.assertNotNull(environmentVariables.getPath());
+ }
+}
diff --git a/core-java/src/test/java/com/baeldung/system/SystemArrayCopyTest.java b/core-java/src/test/java/com/baeldung/system/SystemArrayCopyTest.java
new file mode 100644
index 0000000000..f54e3702c8
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/system/SystemArrayCopyTest.java
@@ -0,0 +1,27 @@
+package com.baeldung.system;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SystemArrayCopyTest {
+
+ @Test
+ public void givenTwoArraysAB_whenUseArrayCopy_thenArrayCopiedFromAToBInResult() {
+ int[] a = {34, 22, 44, 2, 55, 3};
+ int[] b = new int[a.length];
+
+ // copy all elements from a to b
+ System.arraycopy(a, 0, b, 0, a.length);
+ Assert.assertArrayEquals(a, b);
+ }
+
+ @Test
+ public void givenTwoArraysAB_whenUseArrayCopyPosition_thenArrayCopiedFromAToBInResult() {
+ int[] a = {34, 22, 44, 2, 55, 3};
+ int[] b = new int[a.length];
+
+ // copy 2 elements from a, starting at a[1] to b, starting at b[3]
+ System.arraycopy(a, 1, b, 3, 2);
+ Assert.assertArrayEquals(new int[] {0, 0, 0, 22, 44, 0}, b);
+ }
+}
diff --git a/core-java/src/test/java/com/baeldung/system/SystemNanoTest.java b/core-java/src/test/java/com/baeldung/system/SystemNanoTest.java
new file mode 100644
index 0000000000..bf6590da0a
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/system/SystemNanoTest.java
@@ -0,0 +1,16 @@
+package com.baeldung.system;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SystemNanoTest {
+
+ @Test
+ public void givenSystem_whenCalledNanoTime_thenGivesTimeinResult() {
+ long startTime = System.nanoTime();
+ // do something that takes time
+ long endTime = System.nanoTime();
+
+ Assert.assertTrue(endTime - startTime < 10000);
+ }
+}
diff --git a/core-java/src/test/java/com/baeldung/system/SystemPropertiesTest.java b/core-java/src/test/java/com/baeldung/system/SystemPropertiesTest.java
new file mode 100644
index 0000000000..4fca27f96c
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/system/SystemPropertiesTest.java
@@ -0,0 +1,56 @@
+package com.baeldung.system;
+
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import java.util.Properties;
+
+public class SystemPropertiesTest {
+
+ @Test
+ public void givenSystem_whenCalledGetProperty_thenReturnPropertyinResult() {
+ Assert.assertNotNull(System.getProperty("java.vm.vendor"));
+ }
+
+ @Test
+ public void givenSystem_whenCalledSetProperty_thenSetPropertyasResult() {
+
+ // set a particular property
+ System.setProperty("abckey", "abcvaluefoo");
+ Assert.assertEquals("abcvaluefoo", System.getProperty("abckey"));
+ }
+
+ @Test
+ public void givenSystem_whenCalledClearProperty_thenDeletePropertyasResult() {
+
+ // Delete a property
+ System.clearProperty("abckey");
+ Assert.assertNull(System.getProperty("abckey"));
+ }
+
+ @Test
+ public void givenSystem_whenCalledGetPropertyDefaultValue_thenReturnPropertyinResult() {
+
+ System.clearProperty("dbHost");
+ String myKey = System.getProperty("dbHost", "db.host.com");
+ Assert.assertEquals("db.host.com", myKey);
+ }
+
+ @Test
+ public void givenSystem_whenCalledGetProperties_thenReturnPropertiesinResult() {
+ Properties properties = System.getProperties();
+
+ Assert.assertNotNull(properties);
+ }
+
+ @Test
+ @Ignore
+ public void givenSystem_whenCalledClearProperties_thenDeleteAllPropertiesasResult() {
+
+ // Clears all system properties. Use with care!
+ System.getProperties().clear();
+
+ Assert.assertTrue(System.getProperties().isEmpty());
+ }
+}
diff --git a/core-java/yofile.txt b/core-java/yofile.txt
new file mode 100644
index 0000000000..ad56bf35f7
Binary files /dev/null and b/core-java/yofile.txt differ
diff --git a/core-java/yofile2.txt b/core-java/yofile2.txt
new file mode 100644
index 0000000000..8393b6e98b
Binary files /dev/null and b/core-java/yofile2.txt differ
diff --git a/core-kotlin/.gitignore b/core-kotlin/.gitignore
new file mode 100644
index 0000000000..ae3c172604
--- /dev/null
+++ b/core-kotlin/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/core-kotlin/README.md b/core-kotlin/README.md
index b8cea19c58..630d4c7436 100644
--- a/core-kotlin/README.md
+++ b/core-kotlin/README.md
@@ -21,3 +21,7 @@
- [Try-with-resources in Kotlin](http://www.baeldung.com/kotlin-try-with-resources)
- [HTTP Requests with Kotlin and khttp](http://www.baeldung.com/kotlin-khttp)
- [Kotlin Dependency Injection with Kodein](http://www.baeldung.com/kotlin-kodein-dependency-injection)
+- [Regular Expressions in Kotlin](http://www.baeldung.com/kotlin-regular-expressions)
+- [Objects in Kotlin](http://www.baeldung.com/kotlin-objects)
+- [Reading from a File in Kotlin](http://www.baeldung.com/kotlin-read-file)
+- [Guide to Kotlin @JvmField](http://www.baeldung.com/kotlin-jvm-field-annotation)
diff --git a/core-kotlin/pom.xml b/core-kotlin/pom.xml
index 36298ca084..d923ec698c 100644
--- a/core-kotlin/pom.xml
+++ b/core-kotlin/pom.xml
@@ -2,7 +2,6 @@
4.0.0
-
core-kotlin
1.0-SNAPSHOT
jar
@@ -21,6 +20,11 @@
+
+ org.apache.commons
+ commons-math3
+ ${commons-math3.version}
+
org.junit.jupiter
junit-jupiter-engine
@@ -33,12 +37,6 @@
${junit.platform.version}
test
-
- junit
- junit
- ${junit4.version}
- test
-
org.jetbrains.kotlin
kotlin-stdlib
@@ -46,13 +44,13 @@
org.jetbrains.kotlin
- kotlin-stdlib-jre8
+ kotlin-stdlib-jdk8
${kotlin-stdlib.version}
khttp
khttp
- 0.1.0
+ ${khttp.version}
org.jetbrains.kotlin
@@ -126,11 +124,11 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.7.0
+ ${maven-compiler-plugin.version}
- 1.8
- 1.8
-
+ ${maven.compiler.source}
+ ${maven.compiler.target}
+
@@ -160,13 +158,9 @@
-
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
maven-failsafe-plugin
- 2.19.1
+ ${maven-failsafe-plugin.version}
org.junit.platform
@@ -194,19 +188,22 @@
UTF-8
- 1.1.2
- 1.1.2
- 1.1.2
- 1.1.2
+ 1.2.31
+ 1.2.31
+ 1.2.31
+ 1.2.31
0.15
1.5.0
4.1.0
-
+ 0.1.0
+ 3.6.1
5.0.0
1.0.0
4.12.0
4.12
3.9.1
+ 1.8
+ 1.8
diff --git a/core-kotlin/src/main/kotlin/com/baeldung/filesystem/FileReader.kt b/core-kotlin/src/main/kotlin/com/baeldung/filesystem/FileReader.kt
index 05a2ac03bb..8539378c91 100644
--- a/core-kotlin/src/main/kotlin/com/baeldung/filesystem/FileReader.kt
+++ b/core-kotlin/src/main/kotlin/com/baeldung/filesystem/FileReader.kt
@@ -1,39 +1,20 @@
package com.baeldung.filesystem
-import java.io.BufferedReader
import java.io.File
-import java.io.InputStream
class FileReader {
- fun readFileLineByLineUsingForEachLine(fileName: String): List {
- val lineList = mutableListOf()
- File(fileName).forEachLine { line -> lineList.add(line) }
- return lineList
- }
+ fun readFileLineByLineUsingForEachLine(fileName: String) = File(fileName).forEachLine { println(it) }
- fun readFileAsLinesUsingUseLines(fileName: String): List {
- val lineList = mutableListOf()
- File(fileName).useLines { lines -> lineList.addAll(lines) }
- return lineList
- }
+ fun readFileAsLinesUsingUseLines(fileName: String): List = File(fileName)
+ .useLines { it.toList() }
- fun readFileAsLinesUsingBufferedReader(fileName: String): List {
- val bufferedReader: BufferedReader = File(fileName).bufferedReader()
- return bufferedReader.readLines()
- }
+ fun readFileAsLinesUsingBufferedReader(fileName: String): List = File(fileName).bufferedReader().readLines()
- fun readFileAsLinesUsingReadLines(fileName: String): List {
- return File(fileName).readLines()
- }
+ fun readFileAsLinesUsingReadLines(fileName: String): List = File(fileName).readLines()
- fun readFileAsTextUsingInputStream(fileName: String): String {
- val inputStream: InputStream = File(fileName).inputStream()
- return inputStream.readBytes().toString(Charsets.UTF_8)
- }
-
- fun readFileDirectlyAsText(fileName: String): String {
- return File(fileName).readText(Charsets.UTF_8)
- }
+ fun readFileAsTextUsingInputStream(fileName: String) =
+ File(fileName).inputStream().readBytes().toString(Charsets.UTF_8)
+ fun readFileDirectlyAsText(fileName: String): String = File(fileName).readText(Charsets.UTF_8)
}
\ No newline at end of file
diff --git a/core-kotlin/src/test/kotlin/com/baeldung/filesystem/FileReaderTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/filesystem/FileReaderTest.kt
index fd628b8448..67795dda14 100644
--- a/core-kotlin/src/test/kotlin/com/baeldung/filesystem/FileReaderTest.kt
+++ b/core-kotlin/src/test/kotlin/com/baeldung/filesystem/FileReaderTest.kt
@@ -11,9 +11,7 @@ internal class FileReaderTest {
@Test
fun whenReadFileLineByLineUsingForEachLine_thenCorrect() {
- val lines = fileReader.readFileLineByLineUsingForEachLine(fileName)
-
- assertTrue { lines.contains("Hello to Kotlin. Its:") }
+ fileReader.readFileLineByLineUsingForEachLine(fileName)
}
@Test
diff --git a/core-kotlin/src/test/kotlin/com/baeldung/filter/ChunkedTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/filter/ChunkedTest.kt
new file mode 100644
index 0000000000..20797cc633
--- /dev/null
+++ b/core-kotlin/src/test/kotlin/com/baeldung/filter/ChunkedTest.kt
@@ -0,0 +1,39 @@
+package com.baeldung.filter
+
+import org.junit.jupiter.api.Assertions.assertIterableEquals
+import org.junit.jupiter.api.Test
+
+internal class ChunkedTest {
+
+ @Test
+ fun givenDNAFragmentString_whenChunking_thenProduceListOfChunks() {
+ val dnaFragment = "ATTCGCGGCCGCCAA"
+
+ val fragments = dnaFragment.chunked(3)
+
+ assertIterableEquals(listOf("ATT", "CGC", "GGC", "CGC", "CAA"), fragments)
+ }
+
+ @Test
+ fun givenDNAString_whenChunkingWithTransformer_thenProduceTransformedList() {
+ val codonTable = mapOf("ATT" to "Isoleucine", "CAA" to "Glutamine", "CGC" to "Arginine", "GGC" to "Glycine")
+ val dnaFragment = "ATTCGCGGCCGCCAA"
+
+ val proteins = dnaFragment.chunked(3) { codon ->
+ codonTable[codon.toString()] ?: error("Unknown codon")
+ }
+
+ assertIterableEquals(listOf("Isoleucine", "Arginine", "Glycine", "Arginine", "Glutamine"), proteins)
+ }
+
+ @Test
+ fun givenListOfValues_whenChunking_thenProduceListOfArrays() {
+ val whole = listOf(1, 4, 7, 4753, 2, 34, 62, 76, 5868, 0)
+ val chunks = whole.chunked(6)
+
+ val expected = listOf(listOf(1, 4, 7, 4753, 2, 34), listOf(62, 76, 5868, 0))
+
+ assertIterableEquals(expected, chunks)
+ }
+
+}
\ No newline at end of file
diff --git a/core-kotlin/src/test/kotlin/com/baeldung/filter/DistinctTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/filter/DistinctTest.kt
new file mode 100644
index 0000000000..4cc6f647e1
--- /dev/null
+++ b/core-kotlin/src/test/kotlin/com/baeldung/filter/DistinctTest.kt
@@ -0,0 +1,71 @@
+package com.baeldung.filter
+
+import org.junit.jupiter.api.Assertions.assertIterableEquals
+import org.junit.jupiter.api.Test
+
+internal class DistinctTest {
+ data class SmallClass(val key: String, val num: Int)
+
+ @Test
+ fun whenApplyingDistinct_thenReturnListOfNoDuplicateValues() {
+ val array = arrayOf(1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 5, 6, 7, 8, 9)
+ val result = array.distinct()
+ val expected = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9)
+
+ assertIterableEquals(expected, result)
+ }
+
+ @Test
+ fun givenArrayOfClassObjects_whenApplyingDistinctOnClassProperty_thenReturnListDistinctOnThatValue() {
+
+ val original = arrayOf(
+ SmallClass("key1", 1),
+ SmallClass("key2", 2),
+ SmallClass("key3", 3),
+ SmallClass("key4", 3),
+ SmallClass("er", 9),
+ SmallClass("er", 10),
+ SmallClass("er", 11))
+
+ val actual = original.distinctBy { it.key }
+
+ val expected = listOf(
+ SmallClass("key1", 1),
+ SmallClass("key2", 2),
+ SmallClass("key3", 3),
+ SmallClass("key4", 3),
+ SmallClass("er", 9))
+
+
+ assertIterableEquals(expected, actual)
+ }
+
+ @Test
+ fun givenArrayOfClassObjects_whenApplyingComplicatedSelector_thenReturnFirstElementToMatchEachSelectorValue() {
+ val array = arrayOf(
+ SmallClass("key1", 1),
+ SmallClass("key2", 2),
+ SmallClass("key3", 3),
+ SmallClass("key4", 3),
+ SmallClass("er", 9),
+ SmallClass("er", 10),
+ SmallClass("er", 11),
+ SmallClass("er", 11),
+ SmallClass("er", 91),
+ SmallClass("blob", 22),
+ SmallClass("dob", 27),
+ SmallClass("high", 201_434_314))
+
+ val actual = array.distinctBy { Math.floor(it.num / 10.0) }
+
+ val expected = listOf(
+ SmallClass("key1", 1),
+ SmallClass("er", 10),
+ SmallClass("er", 91),
+ SmallClass("blob", 22),
+ SmallClass("high", 201_434_314))
+
+ assertIterableEquals(expected, actual)
+ }
+
+}
\ No newline at end of file
diff --git a/core-kotlin/src/test/kotlin/com/baeldung/filter/DropTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/filter/DropTest.kt
new file mode 100644
index 0000000000..7c2685f39b
--- /dev/null
+++ b/core-kotlin/src/test/kotlin/com/baeldung/filter/DropTest.kt
@@ -0,0 +1,53 @@
+package com.baeldung.filter
+
+import org.junit.jupiter.api.Assertions.assertIterableEquals
+import org.junit.jupiter.api.Test
+
+internal class DropTest {
+
+ @Test
+ fun whenDroppingFirstTwoItemsOfArray_thenTwoLess() {
+ val array = arrayOf(1, 2, 3, 4)
+ val result = array.drop(2)
+ val expected = listOf(3, 4)
+
+ assertIterableEquals(expected, result)
+ }
+
+ @Test
+ fun whenDroppingMoreItemsOfArray_thenEmptyList() {
+ val array = arrayOf(1, 2, 3, 4)
+ val result = array.drop(5)
+ val expected = listOf()
+
+ assertIterableEquals(expected, result)
+ }
+
+ @Test
+ fun givenArray_whenDroppingLastElement_thenReturnListWithoutLastElement() {
+ val array = arrayOf("1", "2", "3", "4")
+ val result = array.dropLast(1)
+ val expected = listOf("1", "2", "3")
+
+ assertIterableEquals(expected, result)
+ }
+
+ @Test
+ fun givenArrayOfFloats_whenDroppingLastUntilPredicateIsFalse_thenReturnSubsetListOfFloats() {
+ val array = arrayOf(1f, 1f, 1f, 1f, 1f, 2f, 1f, 1f, 1f)
+ val result = array.dropLastWhile { it == 1f }
+ val expected = listOf(1f, 1f, 1f, 1f, 1f, 2f)
+
+ assertIterableEquals(expected, result)
+ }
+
+ @Test
+ fun givenList_whenDroppingMoreThanAvailable_thenThrowException() {
+ val list = listOf('a', 'e', 'i', 'o', 'u')
+ val result = list.drop(6)
+ val expected: List = listOf()
+
+ assertIterableEquals(expected, result)
+ }
+
+}
\ No newline at end of file
diff --git a/core-kotlin/src/test/kotlin/com/baeldung/filter/FilterTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/filter/FilterTest.kt
new file mode 100644
index 0000000000..efe6354f25
--- /dev/null
+++ b/core-kotlin/src/test/kotlin/com/baeldung/filter/FilterTest.kt
@@ -0,0 +1,39 @@
+package com.baeldung.filter
+
+import org.apache.commons.math3.primes.Primes
+import org.junit.jupiter.api.Assertions.assertIterableEquals
+import org.junit.jupiter.api.Test
+import kotlin.test.assertTrue
+
+internal class FilterTest {
+
+ @Test
+ fun givenAscendingValueMap_whenFilteringOnValue_ThenReturnSubsetOfMap() {
+ val originalMap = mapOf("key1" to 1, "key2" to 2, "key3" to 3)
+ val filteredMap = originalMap.filter { it.value < 2 }
+ val expectedMap = mapOf("key1" to 1)
+
+ assertTrue { expectedMap == filteredMap }
+ }
+
+ @Test
+ fun givenSeveralCollections_whenFilteringToAccumulativeList_thenListContainsAllContents() {
+ val array1 = arrayOf(90, 92, 93, 94, 92, 95, 93)
+ val array2 = sequenceOf(51, 31, 83, 674_506_111, 256_203_161, 15_485_863)
+ val list1 = listOf(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
+ val primes = mutableListOf()
+
+ val expected = listOf(2, 3, 5, 7, 31, 83, 15_485_863, 256_203_161, 674_506_111)
+
+ val primeCheck = { num: Int -> Primes.isPrime(num) }
+
+ array1.filterTo(primes, primeCheck)
+ list1.filterTo(primes, primeCheck)
+ array2.filterTo(primes, primeCheck)
+
+ primes.sort()
+
+ assertIterableEquals(expected, primes)
+ }
+
+}
\ No newline at end of file
diff --git a/core-kotlin/src/test/kotlin/com/baeldung/filter/SliceTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/filter/SliceTest.kt
new file mode 100644
index 0000000000..dca167928d
--- /dev/null
+++ b/core-kotlin/src/test/kotlin/com/baeldung/filter/SliceTest.kt
@@ -0,0 +1,44 @@
+package com.baeldung.filter
+
+import org.junit.jupiter.api.Assertions.assertIterableEquals
+import org.junit.jupiter.api.Assertions.assertThrows
+import org.junit.jupiter.api.Test
+
+internal class SliceTest {
+
+ @Test
+ fun whenSlicingAnArrayWithDotRange_ThenListEqualsTheSlice() {
+ val original = arrayOf(1, 2, 3, 2, 1)
+ val actual = original.slice(1..3)
+ val expected = listOf(2, 3, 2)
+
+ assertIterableEquals(expected, actual)
+ }
+
+ @Test
+ fun whenSlicingAnArrayWithDownToRange_thenListMadeUpOfReverseSlice() {
+ val original = arrayOf(1, 2, 3, 2, 1)
+ val actual = original.slice(3 downTo 0)
+ val expected = listOf(2, 3, 2, 1)
+
+ assertIterableEquals(expected, actual)
+ }
+
+ @Test
+ fun whenSlicingBeyondTheRangeOfTheArray_thenContainManyNulls() {
+ val original = arrayOf(12, 3, 34, 4)
+ val actual = original.slice(3..8)
+ val expected = listOf(4, null, null, null, null, null)
+
+ assertIterableEquals(expected, actual)
+ }
+
+ @Test
+ fun whenSlicingBeyondRangeOfArrayWithStep_thenOutOfBoundsException() {
+ assertThrows(ArrayIndexOutOfBoundsException::class.java) {
+ val original = arrayOf(12, 3, 34, 4)
+ original.slice(3..8 step 2)
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/core-kotlin/src/test/kotlin/com/baeldung/filter/TakeTest.kt b/core-kotlin/src/test/kotlin/com/baeldung/filter/TakeTest.kt
new file mode 100644
index 0000000000..d021177de8
--- /dev/null
+++ b/core-kotlin/src/test/kotlin/com/baeldung/filter/TakeTest.kt
@@ -0,0 +1,38 @@
+package com.baeldung.filter
+
+import org.junit.jupiter.api.Assertions.assertIterableEquals
+import org.junit.jupiter.api.Test
+
+internal class TakeTest {
+
+ @Test
+ fun `given array of alternating types, when predicating on 'is String', then produce list of array up until predicate is false`() {
+ val originalArray = arrayOf("val1", 2, "val3", 4, "val5", 6)
+ val actualList = originalArray.takeWhile { it is String }
+ val expectedList = listOf("val1")
+
+ assertIterableEquals(expectedList, actualList)
+ }
+
+ @Test
+ fun `given array of alternating types, when taking 4 items, then produce list of first 4 items`() {
+ val originalArray = arrayOf("val1", 2, "val3", 4, "val5", 6)
+ val actualList = originalArray.take(4)
+ val expectedList = listOf("val1", 2, "val3", 4)
+
+ println(originalArray.drop(4))
+ println(actualList)
+
+ assertIterableEquals(expectedList, actualList)
+ }
+
+ @Test
+ fun `when taking more items than available, then return all elements`() {
+ val originalArray = arrayOf(1, 2)
+ val actual = originalArray.take(10)
+ val expected = listOf(1, 2)
+
+ assertIterableEquals(expected, actual)
+ }
+
+}
\ No newline at end of file
diff --git a/couchbase/README.md b/couchbase/README.md
index f124a0192c..9b76609593 100644
--- a/couchbase/README.md
+++ b/couchbase/README.md
@@ -5,6 +5,7 @@
- [Using Couchbase in a Spring Application](http://www.baeldung.com/couchbase-sdk-spring)
- [Asynchronous Batch Opereations in Couchbase](http://www.baeldung.com/async-batch-operations-in-couchbase)
- [Querying Couchbase with MapReduce Views](http://www.baeldung.com/couchbase-query-mapreduce-view)
+- [Querying Couchbase with N1QL](http://www.baeldung.com/n1ql-couchbase)
### Overview
This Maven project contains the Java code for the Couchbase entities and Spring services
diff --git a/couchbase/pom.xml b/couchbase/pom.xml
index c79ce853d0..c369a9e598 100644
--- a/couchbase/pom.xml
+++ b/couchbase/pom.xml
@@ -1,6 +1,6 @@
+ 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
couchbase-sdk
@@ -22,13 +22,11 @@
java-client
${couchbase.client.version}
-
- com.fasterxml.jackson.core
- jackson-databind
- ${jackson-version}
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson-version}
-
org.springframework
@@ -52,7 +50,6 @@
-
org.springframework
@@ -60,7 +57,6 @@
${spring-framework.version}
test
-
org.apache.commons
diff --git a/custom-pmd-0.0.1.jar b/custom-pmd-0.0.1.jar
new file mode 100644
index 0000000000..4ad6933865
Binary files /dev/null and b/custom-pmd-0.0.1.jar differ
diff --git a/custom-pmd/README.md b/custom-pmd/README.md
new file mode 100644
index 0000000000..065a1128f3
--- /dev/null
+++ b/custom-pmd/README.md
@@ -0,0 +1 @@
+## Custom PMD Rules
diff --git a/custom-pmd/pom.xml b/custom-pmd/pom.xml
new file mode 100644
index 0000000000..dcd068089b
--- /dev/null
+++ b/custom-pmd/pom.xml
@@ -0,0 +1,46 @@
+
+ 4.0.0
+ org.baeldung.pmd
+ custom-pmd
+ 0.0.1
+ jar
+ custom-pmd
+ http://maven.apache.org
+
+
+
+ net.sourceforge.pmd
+ pmd-core
+ ${pmdVersion}
+
+
+ net.sourceforge.pmd
+ pmd-java
+ ${pmdVersion}
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+ ${maven.compiler.source}
+ ${maven.compiler.target}
+
+
+
+
+
+
+ UTF-8
+ 3.7.0
+ 6.0.1
+ 1.8
+ 1.8
+
+
+
diff --git a/custom-pmd/src/main/java/org/baeldung/pmd/UnitTestNamingConventionRule.java b/custom-pmd/src/main/java/org/baeldung/pmd/UnitTestNamingConventionRule.java
new file mode 100644
index 0000000000..4136165b6f
--- /dev/null
+++ b/custom-pmd/src/main/java/org/baeldung/pmd/UnitTestNamingConventionRule.java
@@ -0,0 +1,32 @@
+package org.baeldung.pmd;
+
+import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
+import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+
+public class UnitTestNamingConventionRule extends AbstractJavaRule {
+
+ private static List allowedEndings = Arrays.asList(
+ "IntegrationTest",
+ "ManualTest",
+ "JdbcTest",
+ "LiveTest",
+ "UnitTest");
+
+ public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
+ String className = node.getImage();
+ Objects.requireNonNull(className);
+
+ if (className.endsWith("Test") || className.endsWith("Tests")) {
+ if (allowedEndings.stream()
+ .noneMatch(className::endsWith)) {
+ addViolation(data, node);
+ }
+ }
+
+ return data;
+ }
+}
diff --git a/data-structures/pom.xml b/data-structures/pom.xml
index 68174a41df..287e9f38aa 100644
--- a/data-structures/pom.xml
+++ b/data-structures/pom.xml
@@ -1,24 +1,26 @@
- 4.0.0
- com.baeldung
- data-structures
- 0.0.1-SNAPSHOT
+ 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
+ data-structures
+ 0.0.1-SNAPSHOT
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ ${exec-maven-plugin.version}
+
+
+
+
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
- ${exec-maven-plugin.version}
-
-
-
-
diff --git a/deeplearning4j/pom.xml b/deeplearning4j/pom.xml
index a39fabc3d6..8d9e8c6475 100644
--- a/deeplearning4j/pom.xml
+++ b/deeplearning4j/pom.xml
@@ -7,27 +7,28 @@
1.0-SNAPSHOT
deeplearning4j
-
- UTF-8
- 1.8
- 1.8
- 0.9.1
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
-
org.nd4j
nd4j-native-platform
${dl4j.version}
-
org.deeplearning4j
deeplearning4j-core
${dl4j.version}
-
+
+ UTF-8
+ 0.9.1
+
+
\ No newline at end of file
diff --git a/deltaspike/pom.xml b/deltaspike/pom.xml
index e81ad49a6d..87f532c3f3 100644
--- a/deltaspike/pom.xml
+++ b/deltaspike/pom.xml
@@ -1,6 +1,6 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
com.baeldung
deltaspike
@@ -8,7 +8,6 @@
war
deltaspike
A starter Java EE 7 webapp which uses DeltaSpike
-
http://wildfly.org
@@ -24,38 +23,15 @@
1.0.0-SNAPSHOT
-
-
-
- UTF-8
-
- 3.7.4
- 1.7.2
-
-
- 1.0.2.Final
-
-
- 8.2.2.Final
-
-
- 2.6
- 1.1.3
-
-
-
-
org.wildfly.bom
@@ -76,26 +52,26 @@
-
+
-
+
javax.enterprise
cdi-api
provided
-
+
org.jboss.spec.javax.annotation
jboss-annotations-api_1.2_spec
provided
-
org.jboss.resteasy
@@ -103,16 +79,16 @@
provided
-
+
org.hibernate.javax.persistence
hibernate-jpa-2.1-api
provided
-
+
org.jboss.spec.javax.ejb
jboss-ejb-api_3.2_spec
@@ -134,8 +110,8 @@
-
+
org.jboss.spec.javax.faces
jboss-jsf-api_2.2_spec
@@ -144,16 +120,16 @@
-
+
org.hibernate
hibernate-jpamodelgen
provided
-
+
org.hibernate
hibernate-validator-annotation-processor
@@ -161,8 +137,8 @@
-
+
org.jboss.arquillian.junit
arquillian-junit-container
@@ -211,16 +187,15 @@
-
+
${project.artifactId}
maven-war-plugin
${war.plugin.version}
-
+
false
@@ -252,10 +227,10 @@
-
-
+
+
default
true
@@ -275,10 +250,10 @@
-
-
+
+
arq-wildfly-managed
@@ -290,4 +265,23 @@
+
+
+
+
+ UTF-8
+ 3.7.4
+ 1.7.2
+
+ 1.0.2.Final
+
+ 8.2.2.Final
+
+ 2.6
+ 1.1.3
+
+
diff --git a/disruptor/pom.xml b/disruptor/pom.xml
index 33eb7bb50a..cc914cff7e 100644
--- a/disruptor/pom.xml
+++ b/disruptor/pom.xml
@@ -1,11 +1,10 @@
+ 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
disruptor
0.1.0-SNAPSHOT
jar
-
disruptor
@@ -15,20 +14,17 @@
-
org.apache.commons
commons-lang3
${commons-lang3.version}
-
com.lmax
disruptor
${disruptor.version}
-
@@ -39,9 +35,7 @@
true
-
-
org.apache.maven.plugins
maven-dependency-plugin
@@ -58,7 +52,6 @@
-
org.apache.maven.plugins
maven-jar-plugin
@@ -72,7 +65,6 @@
-
org.apache.maven.plugins
maven-assembly-plugin
@@ -96,7 +88,6 @@
-
org.apache.maven.plugins
maven-shade-plugin
@@ -109,7 +100,7 @@
true
+ implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
org.baeldung.executable.ExecutableMavenJar
@@ -117,7 +108,6 @@
-
com.jolira
onejar-maven-plugin
@@ -134,43 +124,13 @@
-
-
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
-
-
- json
-
-
-
-
-
-
-
-
3.5
3.3.6
-
6.10
3.6.1
diff --git a/dozer/pom.xml b/dozer/pom.xml
index 00ac2d5675..0b7f85ddb4 100644
--- a/dozer/pom.xml
+++ b/dozer/pom.xml
@@ -1,11 +1,9 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
-
com.baeldung
dozer
1.0
-
dozer
@@ -15,19 +13,16 @@
-
org.apache.commons
commons-lang3
${commons-lang3.version}
-
net.sf.dozer
dozer
${dozer.version}
-
diff --git a/drools/pom.xml b/drools/pom.xml
index 5f228802fa..c1e8b34b06 100644
--- a/drools/pom.xml
+++ b/drools/pom.xml
@@ -2,18 +2,13 @@
4.0.0
-
drools
+
com.baeldung
parent-modules
1.0.0-SNAPSHOT
-
- 4.4.6
- 7.4.1.Final
- 3.13
-
@@ -32,7 +27,6 @@
drools-decisiontables
${drools-version}
-
org.drools
drools-core
@@ -48,40 +42,23 @@
poi
${apache-poi-version}
-
org.apache.poi
poi-ooxml
${apache-poi-version}
-
org.springframework
spring-core
- 4.3.6.RELEASE
+ ${spring-core.version}
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
- 3
- true
-
- **/*IntegrationTest.java
- **/*LongRunningUnitTest.java
- **/*ManualTest.java
- **/JdbcTest.java
- **/*LiveTest.java
-
-
-
-
-
+
+ 4.4.6
+ 7.4.1.Final
+ 3.13
+ 4.3.6.RELEASE
+
diff --git a/dubbo/pom.xml b/dubbo/pom.xml
index af242e5905..81ff921f2a 100644
--- a/dubbo/pom.xml
+++ b/dubbo/pom.xml
@@ -1,6 +1,7 @@
4.0.0
+ dubbo
parent-modules
@@ -8,7 +9,29 @@
1.0.0-SNAPSHOT
- dubbo
+
+
+ com.alibaba
+ dubbo
+ ${dubbo.version}
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+ org.apache.zookeeper
+ zookeeper
+ ${zookeeper.version}
+
+
+ com.101tec
+ zkclient
+ ${zkclient.version}
+
+
UTF-8
@@ -20,54 +43,4 @@
2.19.1
-
-
- com.alibaba
- dubbo
- ${dubbo.version}
-
-
- junit
- junit
- 4.12
- test
-
-
-
- org.apache.zookeeper
- zookeeper
- ${zookeeper.version}
-
-
-
- com.101tec
- zkclient
- ${zkclient.version}
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
- maven-surefire-plugin
- ${surefire.version}
-
-
- **/*LiveTest.java
-
-
-
-
-
-
diff --git a/ejb/ejb-client/pom.xml b/ejb/ejb-client/pom.xml
index ca8ec55f12..83dd0aef30 100755
--- a/ejb/ejb-client/pom.xml
+++ b/ejb/ejb-client/pom.xml
@@ -1,7 +1,10 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
+ ejb-client
+ EJB3 Client Maven
+ EJB3 Client Maven
com.baeldung.ejb
@@ -9,10 +12,6 @@
1.0-SNAPSHOT
- ejb-client
- EJB3 Client Maven
- EJB3 Client Maven
-
org.wildfly
@@ -25,7 +24,6 @@
ejb-remote
ejb
-
@@ -42,5 +40,5 @@
-
+
\ No newline at end of file
diff --git a/ejb/ejb-remote/pom.xml b/ejb/ejb-remote/pom.xml
index beb182ff8b..b8f1f0dcc0 100755
--- a/ejb/ejb-remote/pom.xml
+++ b/ejb/ejb-remote/pom.xml
@@ -2,6 +2,8 @@
4.0.0
+ ejb-remote
+ ejb
com.baeldung.ejb
@@ -9,9 +11,6 @@
1.0-SNAPSHOT
- ejb-remote
- ejb
-
javax
@@ -21,7 +20,6 @@
-
@@ -70,7 +68,7 @@
org.wildfly.plugins
wildfly-maven-plugin
- 1.1.0.Alpha5
+ ${wildfly-maven-plugin.version}
127.0.0.1
9990
@@ -82,14 +80,12 @@
-
7.0
1.6.1
+ 1.1.0.Alpha5
-
-
-
+
\ No newline at end of file
diff --git a/ejb/ejb-session-beans/pom.xml b/ejb/ejb-session-beans/pom.xml
index b89ff6ed15..6afd7f2c6d 100644
--- a/ejb/ejb-session-beans/pom.xml
+++ b/ejb/ejb-session-beans/pom.xml
@@ -1,21 +1,12 @@
- 4.0.0
-
- com.baeldung.ejb
- ejb
- 1.0-SNAPSHOT
-
- ejb-session-beans
-
-
- UTF-8
- 1.1.12.Final
- 2.2.6
- 1.1.12.Final
- 1.0.0.Final
- 4.12
- 7.0
-
+ 4.0.0
+ ejb-session-beans
+
+
+ com.baeldung.ejb
+ ejb
+ 1.0-SNAPSHOT
+
@@ -30,29 +21,23 @@
-
javax
javaee-api
${javaee-api.version}
provided
-
-
junit
junit
- 4.12
+ ${junit.version}
test
-
-
org.jboss.arquillian.junit
arquillian-junit-container
test
-
@@ -65,7 +50,7 @@
org.jboss.arquillian.container
arquillian-glassfish-embedded-3.1
- 1.0.0.CR4
+ ${arquillian-glassfish-embedded-3.1.version}
test
@@ -80,14 +65,6 @@
-
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
maven-war-plugin
2.4
@@ -95,12 +72,18 @@
false
-
- maven-surefire-plugin
- 2.17
-
-
-
+
+
+ UTF-8
+ 1.1.12.Final
+ 2.2.6
+ 1.1.12.Final
+ 1.0.0.Final
+ 4.12
+ 7.0
+ 1.0.0.CR4
+
+
\ No newline at end of file
diff --git a/ejb/pom.xml b/ejb/pom.xml
index 78e40a7b7c..e61c2a0b7b 100755
--- a/ejb/pom.xml
+++ b/ejb/pom.xml
@@ -1,6 +1,6 @@
+ 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.ejb
ejb
@@ -15,6 +15,56 @@
1.0.0-SNAPSHOT
+
+ ejb-remote
+ ejb-client
+ ejb-session-beans
+
+
+
+
+
+ com.baeldung.ejb
+ ejb-remote
+ ${ejb-remote.version}
+ ejb
+
+
+ com.baeldung.ejb
+ ejb-session-beans
+ ${ejb-session-beans.version}
+ ejb
+
+
+ javax
+ javaee-api
+ ${javaee-api.version}
+ provided
+
+
+ org.wildfly
+ wildfly-ejb-client-bom
+ ${wildfly-ejb-client-bom.version}
+ pom
+ import
+
+
+
+
+
+
+
+
+ maven-ejb-plugin
+ ${maven-ejb-plugin.version}
+
+ ${ejbVersion}
+
+
+
+
+
+
jboss-public-repository-group
@@ -32,54 +82,20 @@
-
-
-
- com.baeldung.ejb
- ejb-remote
- 1.0-SNAPSHOT
- ejb
-
-
- com.baeldung.ejb
- ejb-session-beans
- 1.0-SNAPSHOT
- ejb
-
-
- javax
- javaee-api
- 7.0
- provided
-
+
+ UTF-8
+ UTF-8
+ 1.8
+ 2.5.7
+ 3.4.11
+ 0.10
+ 2.19.1
+ 1.0-SNAPSHOT
+ 1.0-SNAPSHOT
+ 7.0
+ 2.4
+ 3.2
+ 10.1.0.Final
+
-
- org.wildfly
- wildfly-ejb-client-bom
- 10.1.0.Final
- pom
- import
-
-
-
-
-
-
-
-
- maven-ejb-plugin
- 2.4
-
- 3.2
-
-
-
-
-
-
-
- ejb-remote
- ejb-client
- ejb-session-beans
-
\ No newline at end of file
diff --git a/ejb/wildfly/pom.xml b/ejb/wildfly/pom.xml
index d4843f9fc9..ad73f4817e 100644
--- a/ejb/wildfly/pom.xml
+++ b/ejb/wildfly/pom.xml
@@ -1,81 +1,93 @@
- 4.0.0
- com.baeldung.wildfly
- wildfly-example
- 0.0.1-SNAPSHOT
- pom
+ 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.wildfly
+ wildfly-example
+ 0.0.1-SNAPSHOT
+ pom
-
- 1.8
- 1.8
- UTF-8
-
-
- widlfly-web
- wildfly-ear
- wildfly-jpa
- wildfly-ejb-interfaces
- wildfly-ejb
-
+
+ com.baeldung.ejb
+ ejb
+ 1.0-SNAPSHOT
+
+
+
+ widlfly-web
+ wildfly-ear
+ wildfly-jpa
+ wildfly-ejb-interfaces
+ wildfly-ejb
+
+
+
+
+
+
+
+ javax
+ javaee-api
+ ${javaee-api.version}
+ provided
+
+
+
+ org.wildfly.bom
+ wildfly-javaee7
+ ${wildfly-javaee7.version}
+ import
+ pom
+
+
+
+ org.hibernate
+ hibernate-core
+ ${hibernate-core.version}
+ provided
+
+
+
+ com.baeldung.wildfly
+ wildlfy-ear
+ ${wildlfy.version}
+ ear
+
+
+
+ com.baeldung.wildfly
+ wildlfy-web
+ ${wildlfy.version}
+ war
+
+
+
+ com.baeldung.wildfly
+ wildlfy-jpa
+ ${wildlfy.version}
+
+
+
+ com.baeldung.wildfly
+ wildfly-ejb
+ ${wildlfy.version}
+
+
+
+ com.baeldung.wildfly
+ wildfly-ejb-interfaces
+ ${wildlfy.version}
+
+
+
+
+
+ 1.8
+ 1.8
+ UTF-8
+ 7.0
+ 10.1.0.Final
+ 5.2.3.Final
+ 0.0.1-SNAPSHOT
+
-
-
-
-
-
- javax
- javaee-api
- 7.0
- provided
-
-
-
- org.wildfly.bom
- wildfly-javaee7
- 10.1.0.Final
- import
- pom
-
-
-
- org.hibernate
- hibernate-core
- 5.2.3.Final
- provided
-
-
-
- com.baeldung.wildfly
- wildlfy-ear
- 0.0.1-SNAPSHOT
- ear
-
-
-
- com.baeldung.wildfly
- wildlfy-web
- 0.0.1-SNAPSHOT
- war
-
-
-
- com.baeldung.wildfly
- wildlfy-jpa
- 0.0.1-SNAPSHOT
-
-
-
- com.baeldung.wildfly
- wildfly-ejb
- 0.0.1-SNAPSHOT
-
-
-
- com.baeldung.wildfly
- wildfly-ejb-interfaces
- 0.0.1-SNAPSHOT
-
-
-
\ No newline at end of file
diff --git a/ejb/wildfly/widlfly-web/pom.xml b/ejb/wildfly/widlfly-web/pom.xml
index 2e316dedd9..a337e8ef60 100644
--- a/ejb/wildfly/widlfly-web/pom.xml
+++ b/ejb/wildfly/widlfly-web/pom.xml
@@ -1,39 +1,40 @@
- 4.0.0
-
- com.baeldung.wildfly
- wildfly-example
- 0.0.1-SNAPSHOT
-
- widlfly-web
- war
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ widlfly-web
+ war
-
-
-
- javax
- javaee-api
- 7.0
- provided
-
-
-
- com.baeldung.wildfly
- wildfly-jpa
- 0.0.1-SNAPSHOT
-
-
-
- com.baeldung.wildfly
- wildfly-ejb-interfaces
- 0.0.1-SNAPSHOT
-
-
-
- com.baeldung.wildfly
- wildfly-ejb
- 0.0.1-SNAPSHOT
-
-
+
+ com.baeldung.wildfly
+ wildfly-example
+ 0.0.1-SNAPSHOT
+
+
+
+
+
+ javax
+ javaee-api
+ ${javaee-api.version}
+ provided
+
+
+
+ com.baeldung.wildfly
+ wildfly-jpa
+ ${wildlfy.version}
+
+
+
+ com.baeldung.wildfly
+ wildfly-ejb-interfaces
+ ${wildlfy.version}
+
+
+
+ com.baeldung.wildfly
+ wildfly-ejb
+ ${wildlfy.version}
+
+
\ No newline at end of file
diff --git a/ejb/wildfly/wildfly-ear/pom.xml b/ejb/wildfly/wildfly-ear/pom.xml
index 6beb387227..f264594652 100644
--- a/ejb/wildfly/wildfly-ear/pom.xml
+++ b/ejb/wildfly/wildfly-ear/pom.xml
@@ -1,62 +1,63 @@
- 4.0.0
-
- com.baeldung.wildfly
- wildfly-example
- 0.0.1-SNAPSHOT
-
- wildfly-ear
- ear
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ wildfly-ear
+ ear
-
-
-
- com.baeldung.wildfly
- widlfly-web
- 0.0.1-SNAPSHOT
- war
-
-
-
- com.baeldung.wildfly
- wildfly-jpa
- 0.0.1-SNAPSHOT
-
-
-
- com.baeldung.wildfly
- wildfly-ejb
-
-
-
- com.baeldung.wildfly
- wildfly-ejb-interfaces
-
-
+
+ com.baeldung.wildfly
+ wildfly-example
+ 0.0.1-SNAPSHOT
+
-
-
-
- maven-ear-plugin
- 2.10.1
-
- lib/
- 7
-
-
- com.baeldung.wildfly
- widlfly-web
- /wildfly
-
-
-
-
-
- org.wildfly.plugins
- wildfly-maven-plugin
- 1.2.0.Final
-
-
-
+
+
+
+ com.baeldung.wildfly
+ widlfly-web
+ ${wildlfy.version}
+ war
+
+
+
+ com.baeldung.wildfly
+ wildfly-jpa
+ ${wildlfy.version}
+
+
+
+ com.baeldung.wildfly
+ wildfly-ejb
+
+
+
+ com.baeldung.wildfly
+ wildfly-ejb-interfaces
+
+
+
+
+
+
+ maven-ear-plugin
+ 2.10.1
+
+ lib/
+ 7
+
+
+ com.baeldung.wildfly
+ widlfly-web
+ /wildfly
+
+
+
+
+
+ org.wildfly.plugins
+ wildfly-maven-plugin
+ 1.2.0.Final
+
+
+
\ No newline at end of file
diff --git a/ejb/wildfly/wildfly-ejb-interfaces/pom.xml b/ejb/wildfly/wildfly-ejb-interfaces/pom.xml
index e4d2eee0c6..61a630b899 100644
--- a/ejb/wildfly/wildfly-ejb-interfaces/pom.xml
+++ b/ejb/wildfly/wildfly-ejb-interfaces/pom.xml
@@ -1,26 +1,32 @@
- 4.0.0
-
- com.baeldung.wildfly
- wildfly-example
- 0.0.1-SNAPSHOT
-
- wildfly-ejb-interfaces
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ wildfly-ejb-interfaces
+
+
+ com.baeldung.wildfly
+ wildfly-example
+ 0.0.1-SNAPSHOT
+
+
+
+
+
+ javax.ejb
+ javax.ejb-api
+ ${javax.ejb-api.version}
+ provided
+
+
+
+ com.baeldung.wildfly
+ wildfly-jpa
+ ${wildlfy.version}
+
+
+
+
+ 3.2
+
-
-
-
- javax.ejb
- javax.ejb-api
- 3.2
- provided
-
-
-
- com.baeldung.wildfly
- wildfly-jpa
- 0.0.1-SNAPSHOT
-
-
\ No newline at end of file
diff --git a/ejb/wildfly/wildfly-ejb/pom.xml b/ejb/wildfly/wildfly-ejb/pom.xml
index 9d4464dafa..900f93c0ba 100644
--- a/ejb/wildfly/wildfly-ejb/pom.xml
+++ b/ejb/wildfly/wildfly-ejb/pom.xml
@@ -1,49 +1,50 @@
- 4.0.0
-
- com.baeldung.wildfly
- wildfly-example
- 0.0.1-SNAPSHOT
-
- wildfly-ejb
- ejb
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ wildfly-ejb
+ ejb
-
-
-
- javax.ejb
- javax.ejb-api
- 3.2
- provided
-
-
-
- javax
- javaee-api
- provided
-
-
-
- org.hibernate
- hibernate-core
-
-
-
- com.baeldung.wildfly
- wildfly-ejb-interfaces
-
-
+
+ com.baeldung.wildfly
+ wildfly-example
+ 0.0.1-SNAPSHOT
+
-
-
-
- org.apache.maven.plugins
- maven-ejb-plugin
-
- 3.2
-
-
-
-
+
+
+
+ javax.ejb
+ javax.ejb-api
+ 3.2
+ provided
+
+
+
+ javax
+ javaee-api
+ provided
+
+
+
+ org.hibernate
+ hibernate-core
+
+
+
+ com.baeldung.wildfly
+ wildfly-ejb-interfaces
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-ejb-plugin
+
+ 3.2
+
+
+
+
\ No newline at end of file
diff --git a/ejb/wildfly/wildfly-jpa/pom.xml b/ejb/wildfly/wildfly-jpa/pom.xml
index e6f8b32e17..18e86b1b31 100644
--- a/ejb/wildfly/wildfly-jpa/pom.xml
+++ b/ejb/wildfly/wildfly-jpa/pom.xml
@@ -1,20 +1,22 @@
- 4.0.0
-
- com.baeldung.wildfly
- wildfly-example
- 0.0.1-SNAPSHOT
-
- wildfly-jpa
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ wildfly-jpa
+
+
+ com.baeldung.wildfly
+ wildfly-example
+ 0.0.1-SNAPSHOT
+
+
+
+
+
+
+ org.hibernate
+ hibernate-core
+ provided
+
+
-
-
-
-
- org.hibernate
- hibernate-core
- provided
-
-
\ No newline at end of file
diff --git a/enterprise-patterns/pom.xml b/enterprise-patterns/pom.xml
index 1c8f5a1b4d..07842b8981 100644
--- a/enterprise-patterns/pom.xml
+++ b/enterprise-patterns/pom.xml
@@ -1,14 +1,10 @@
+ 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.enterprise.patterns
enterprise-patterns-parent
pom
-
- spring-dispatcher-servlet
-
com.baeldung
@@ -16,4 +12,8 @@
1.0.0-SNAPSHOT
+
+ spring-dispatcher-servlet
+
+
diff --git a/ethereumj/pom.xml b/ethereumj/pom.xml
index 8b6d3677c9..611b7b09eb 100644
--- a/ethereumj/pom.xml
+++ b/ethereumj/pom.xml
@@ -1,5 +1,7 @@
-
+
4.0.0
com.baeldung.ethereumj
ethereumj
@@ -23,7 +25,6 @@
-
org.springframework.boot
@@ -33,28 +34,24 @@
org.springframework.boot
spring-boot-starter-tomcat
-
org.springframework.boot
spring-boot-starter-test
test
-
org.ethereum
ethereumj-core
- 1.5.0-RELEASE
+ ${ethereumj-core.version}
-
org.web3j
core
- 3.3.1
+ ${web3j.core.version}
-
javax.servlet
@@ -63,7 +60,7 @@
com.fasterxml.jackson.core
jackson-databind
- 2.5.0
+ ${jackson-databind.version}
@@ -77,40 +74,13 @@
ethereumj
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- none
-
-
- */EthControllerTestOne.java
-
-
-
-
-
-
-
-
-
-
UTF-8
1.8
8.5.4
+ 1.5.0-RELEASE
+ 3.3.1
+ 2.5.0
\ No newline at end of file
diff --git a/feign/pom.xml b/feign/pom.xml
index 78e1bbcf4c..ffcde60c54 100644
--- a/feign/pom.xml
+++ b/feign/pom.xml
@@ -1,7 +1,8 @@
-
+
4.0.0
-
com.baeldung.feign
feign-client
@@ -12,13 +13,6 @@
..
-
- UTF-8
- 9.4.0
- 1.16.12
- 1.4.2.RELEASE
-
-
io.github.openfeign
@@ -60,4 +54,11 @@
+
+ UTF-8
+ 9.4.0
+ 1.16.12
+ 1.4.2.RELEASE
+
+
diff --git a/flips/pom.xml b/flips/pom.xml
index ecc2af4a47..be9f584114 100644
--- a/flips/pom.xml
+++ b/flips/pom.xml
@@ -1,50 +1,42 @@
4.0.0
-
flips
flips
0.0.1-SNAPSHOT
jar
-
flips
-
- UTF-8
- 1.8
- 1.8
-
+
+ parent-boot-5
+ com.baeldung
+ 0.0.1-SNAPSHOT
+ ../parent-boot-5
+
-
org.springframework.boot
spring-boot-starter-web
- 1.5.10.RELEASE
+ ${spring-boot-starter-web.version}
-
org.springframework.boot
spring-boot-starter-test
- 1.5.9.RELEASE
+ ${spring-boot-starter-test.version}
-
com.github.feature-flip
flips-web
- 1.0.1
+ ${flips-web.version}
-
org.projectlombok
lombok
- 1.16.18
+ ${lombok.version}
provided
-
-
-
@@ -62,4 +54,15 @@
+
+
+ UTF-8
+ 1.8
+ 1.8
+ 1.5.10.RELEASE
+ 1.5.9.RELEASE
+ 1.0.1
+ 1.16.18
+
+
diff --git a/flyway/pom.xml b/flyway/pom.xml
index 84009e4579..3637f1de28 100644
--- a/flyway/pom.xml
+++ b/flyway/pom.xml
@@ -2,10 +2,8 @@
4.0.0
-
flyway
jar
-
flyway
Flyway Callbacks Demo
@@ -16,30 +14,21 @@
../parent-boot-5
-
- UTF-8
- UTF-8
- 1.8
-
-
org.flywaydb
flyway-core
- 5.0.2
+ ${flyway-core.version}
-
org.springframework.boot
spring-boot-starter-jdbc
-
mysql
mysql-connector-java
- 6.0.3
+ ${mysql-connector-java.version}
-
com.h2database
h2
@@ -57,7 +46,7 @@
org.flywaydb
flyway-maven-plugin
- 5.0.2
+ ${flyway-maven-plugin.version}
com.h2database
@@ -73,4 +62,13 @@
+
+ UTF-8
+ UTF-8
+ 1.8
+ 5.0.2
+ 6.0.3
+ 5.0.2
+
+
diff --git a/geotools/pom.xml b/geotools/pom.xml
index d0eb787be8..9347d17fc1 100644
--- a/geotools/pom.xml
+++ b/geotools/pom.xml
@@ -1,20 +1,24 @@
+ 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
geotools
0.0.1-SNAPSHOT
jar
-
geotools
http://maven.apache.org
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
junit
junit
- 4.12
+ ${junit.version}
test
@@ -33,6 +37,7 @@
${geotools-swing.version}
+
maven2-repository.dev.java.net
@@ -53,21 +58,8 @@
http://repo.opengeo.org
-
-
-
- true
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
-
-
+
+
15.2
15.2
15.2
diff --git a/google-cloud/README.md b/google-cloud/README.md
index 6022796a0e..87ca17eac4 100644
--- a/google-cloud/README.md
+++ b/google-cloud/README.md
@@ -1,7 +1,7 @@
## Google Cloud Tutorial Project
### Relevant Article:
-- [Intro to Google Cloud Storage With Java](http://www.baeldung.com/intro-to-google-cloud-storage-with-java/)
+- [Intro to Google Cloud Storage With Java](http://www.baeldung.com/java-google-cloud-storage)
### Overview
This Maven project contains the Java code for the article linked above.
diff --git a/google-cloud/pom.xml b/google-cloud/pom.xml
index 0f1eff36f8..b6e54e33c1 100644
--- a/google-cloud/pom.xml
+++ b/google-cloud/pom.xml
@@ -1,6 +1,6 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
google-cloud
0.1-SNAPSHOT
@@ -18,7 +18,7 @@
com.google.cloud
google-cloud-storage
- 1.16.0
+ ${google-cloud-storage.version}
org.projectlombok
@@ -31,8 +31,8 @@
1.16.18
- 1.8
UTF-8
+ 1.16.0
diff --git a/gradle/README.md b/gradle/README.md
index 5fc7b40e3f..229466dfec 100644
--- a/gradle/README.md
+++ b/gradle/README.md
@@ -2,3 +2,5 @@
- [Introduction to Gradle](http://www.baeldung.com/gradle)
- [Writing Custom Gradle Plugins](http://www.baeldung.com/gradle-create-plugin)
- [Creating a Fat Jar in Gradle](http://www.baeldung.com/gradle-fat-jar)
+- [A Custom Task in Gradle](http://www.baeldung.com/gradle-custom-task)
+- [Kotlin Dependency Injection with Kodein](http://www.baeldung.com/kotlin-kodein-dependency-injection)
diff --git a/graphql/graphql-java/pom.xml b/graphql/graphql-java/pom.xml
index c031ddc694..27d2cebf26 100644
--- a/graphql/graphql-java/pom.xml
+++ b/graphql/graphql-java/pom.xml
@@ -1,29 +1,33 @@
- 4.0.0
+ 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.graphql
+ graphql-java
+ 1.0
+ graphql-java
- com.baeldung.graphql
- graphql-java
- 1.0
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
- graphql-java
+
+
+ com.graphql-java
+ graphql-java-annotations
+ ${graphql-java-annotations.version}
+
+
+ io.ratpack
+ ratpack-core
+ ${ratpack-core.version}
+
+
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
+
+ 3.0.3
+ 1.4.6
+
-
-
- com.graphql-java
- graphql-java-annotations
- 3.0.3
-
-
- io.ratpack
- ratpack-core
- 1.4.6
-
-
\ No newline at end of file
diff --git a/grpc/pom.xml b/grpc/pom.xml
index 074075b5cc..ad563f16fd 100644
--- a/grpc/pom.xml
+++ b/grpc/pom.xml
@@ -1,19 +1,18 @@
4.0.0
-
grpc
grpc-demo
0.0.1-SNAPSHOT
jar
-
grpc-demo
http://maven.apache.org
-
- UTF-8
- 1.5.0
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
@@ -34,23 +33,24 @@
junit
junit
- 4.12
+ ${junit.version}
test
+
kr.motd.maven
os-maven-plugin
- 1.5.0.Final
+ ${os-maven-plugin.version}
org.xolstice.maven.plugins
protobuf-maven-plugin
- 0.5.0
+ ${protobuf-maven-plugin.version}
com.google.protobuf:protoc:3.3.0:exe:${os.detected.classifier}
@@ -71,4 +71,12 @@
+
+
+ UTF-8
+ 1.5.0
+ 1.5.0.Final
+ 0.5.0
+
+
diff --git a/gson/pom.xml b/gson/pom.xml
index 24162bb72b..3e0bafee2c 100644
--- a/gson/pom.xml
+++ b/gson/pom.xml
@@ -1,10 +1,9 @@
+ 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
gson
0.1-SNAPSHOT
-
gson
@@ -14,15 +13,12 @@
-
-
joda-time
joda-time
${joda-time.version}
-
com.google.guava
guava
@@ -33,27 +29,22 @@
commons-io
${commons-io.version}
-
org.apache.commons
commons-collections4
${commons-collections4.version}
-
org.apache.commons
commons-lang3
${commons-lang3.version}
-
-
com.google.code.gson
gson
${gson.version}
-
@@ -69,14 +60,12 @@
2.8.0
-
19.0
3.5
4.1
2.5
2.9.6
-
\ No newline at end of file
diff --git a/guava-modules/guava-18/pom.xml b/guava-modules/guava-18/pom.xml
index f8dbf5657e..d2ddcc3fac 100644
--- a/guava-modules/guava-18/pom.xml
+++ b/guava-modules/guava-18/pom.xml
@@ -1,8 +1,7 @@
+ 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
guava-18
0.1.0-SNAPSHOT
@@ -11,7 +10,7 @@
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
+ ../../
@@ -25,4 +24,5 @@
18.0
+
\ No newline at end of file
diff --git a/guava-modules/guava-19/pom.xml b/guava-modules/guava-19/pom.xml
index 4a23bf7aec..225dc9e9e3 100644
--- a/guava-modules/guava-19/pom.xml
+++ b/guava-modules/guava-19/pom.xml
@@ -1,8 +1,7 @@
+ 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
guava-19
0.1.0-SNAPSHOT
diff --git a/guava-modules/guava-21/pom.xml b/guava-modules/guava-21/pom.xml
index f5432fb7df..42b66d84c8 100644
--- a/guava-modules/guava-21/pom.xml
+++ b/guava-modules/guava-21/pom.xml
@@ -1,9 +1,7 @@
-
4.0.0
-
guava-21
1.0-SNAPSHOT
@@ -11,22 +9,26 @@
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
-
+ ../../
+
com.google.guava
guava
- 21.0
+ ${guava.version}
org.jooq
jool
- 0.9.12
+ ${jool.version}
+
+ 21.0
+ 0.9.12
+
\ No newline at end of file
diff --git a/guava/README.md b/guava/README.md
index af02bba809..bb4e225649 100644
--- a/guava/README.md
+++ b/guava/README.md
@@ -31,3 +31,5 @@
- [Guide to Mathematical Utilities in Guava](http://www.baeldung.com/guava-math)
- [Bloom Filter in Java using Guava](http://www.baeldung.com/guava-bloom-filter)
- [Using Guava CountingOutputStream](http://www.baeldung.com/guava-counting-outputstream)
+- [Hamcrest Text Matchers](http://www.baeldung.com/hamcrest-text-matchers)
+- [Quick Guide to the Guava RateLimiter](http://www.baeldung.com/guava-rate-limiter)
diff --git a/guava/pom.xml b/guava/pom.xml
index e2538d090b..3ad3220f21 100644
--- a/guava/pom.xml
+++ b/guava/pom.xml
@@ -1,10 +1,9 @@
+ 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
guava
0.1.0-SNAPSHOT
-
guava
@@ -14,37 +13,29 @@
-
-
com.google.guava
guava
${guava.version}
-
org.apache.commons
commons-collections4
${commons-collections4.version}
-
org.apache.commons
commons-lang3
${commons-lang3.version}
-
-
org.assertj
assertj-core
${assertj.version}
test
-
-
diff --git a/guest/core-java-9/pom.xml b/guest/core-java-9/pom.xml
index 0e227798af..f8e2dcce85 100644
--- a/guest/core-java-9/pom.xml
+++ b/guest/core-java-9/pom.xml
@@ -1,27 +1,40 @@
- 4.0.0
- com.stackify
- core-java-9
- 0.0.1-SNAPSHOT
-
-
+ 4.0.0
+ com.stackify
+ core-java-9
+ 0.0.1-SNAPSHOT
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+ ../../
+
+
+
junit
junit
- 4.12
+ ${junit.version}
-
-
-
-
- maven-compiler-plugin
- 3.7.0
-
- 1.9
- 1.9
-
-
-
-
+
+
+
+
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+ ${maven.compiler.source}
+ ${maven.compiler.target}
+
+
+
+
+
+
+ 1.9
+ 1.9
+
+
\ No newline at end of file
diff --git a/guest/core-java/pom.xml b/guest/core-java/pom.xml
index eda3846c1f..c3042ca94a 100644
--- a/guest/core-java/pom.xml
+++ b/guest/core-java/pom.xml
@@ -1,21 +1,28 @@
- 4.0.0
- com.stackify
- core-java
- 0.0.1-SNAPSHOT
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ com.stackify
+ core-java
+ 0.0.1-SNAPSHOT
-
-
- junit
- junit
- 4.12
-
-
- org.apache.logging.log4j
- log4j-core
- ${log4j2.version}
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+ ../../
+
+
+
+
+ junit
+ junit
+ ${junit.version}
+
+
+ org.apache.logging.log4j
+ log4j-core
+ ${log4j2.version}
+
org.hamcrest
hamcrest-core
@@ -34,22 +41,11 @@
${org.hamcrest.version}
test
-
+
+
+
+ 2.8.2
+ 1.3
+
-
-
-
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
-
-
- 2.8.2
- 1.3
-
\ No newline at end of file
diff --git a/guest/deep-jsf/pom.xml b/guest/deep-jsf/pom.xml
index 68801ba010..bd02b145d0 100644
--- a/guest/deep-jsf/pom.xml
+++ b/guest/deep-jsf/pom.xml
@@ -6,7 +6,12 @@
deep-jsf
0.0.1-SNAPSHOT
war
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+ ../../
+
false
@@ -24,17 +29,6 @@
deep-jsf
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
\ No newline at end of file
diff --git a/guest/junit5-example/pom.xml b/guest/junit5-example/pom.xml
index 37c71e77af..a63ccdee35 100644
--- a/guest/junit5-example/pom.xml
+++ b/guest/junit5-example/pom.xml
@@ -1,68 +1,65 @@
- 4.0.0
- junit5-example
- junit5-example
- 0.0.1-SNAPSHOT
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ junit5-example
+ junit5-example
+ 0.0.1-SNAPSHOT
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+ ../../
+
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ 5.0.0-M4
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ 5.0.0-M4
+
-
-
- org.junit.jupiter
- junit-jupiter-engine
- 5.0.0-M4
-
-
- org.junit.jupiter
- junit-jupiter-params
- 5.0.0-M4
-
+
+ org.junit.vintage
+ junit-vintage-engine
+ 4.12.0-M4
+
-
- org.junit.vintage
- junit-vintage-engine
- 4.12.0-M4
-
+
+ com.h2database
+ h2
+ 1.4.195
+
-
- com.h2database
- h2
- 1.4.195
-
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.8.2
+
-
- org.apache.logging.log4j
- log4j-core
- 2.8.2
-
+
-
-
-
-
-
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
- maven-surefire-plugin
- 2.19.1
-
-
- org.junit.platform
- junit-platform-surefire-provider
- 1.0.0-M4
-
-
-
-
- math
-
-
-
-
-
+
+
+
+ maven-surefire-plugin
+ 2.19.1
+
+
+ org.junit.platform
+ junit-platform-surefire-provider
+ 1.0.0-M4
+
+
+
+
+ math
+
+
+
+
+
\ No newline at end of file
diff --git a/guest/log4j2-example/pom.xml b/guest/log4j2-example/pom.xml
index 43f1d106f0..760af88a06 100644
--- a/guest/log4j2-example/pom.xml
+++ b/guest/log4j2-example/pom.xml
@@ -1,56 +1,51 @@
- 4.0.0
- log4j2-example
- log4j2-example
- 0.0.1-SNAPSHOT
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ log4j2-example
+ log4j2-example
+ 0.0.1-SNAPSHOT
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+ ../../
+
+
+
+
+ org.apache.logging.log4j
+ log4j-core
+ ${log4j-core.version}
+
-
-
-
- org.apache.logging.log4j
- log4j-core
- ${log4j-core.version}
-
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson.version}
+
-
-
- com.fasterxml.jackson.core
- jackson-databind
- ${jackson.version}
-
+
+ junit
+ junit
+ 4.12
+
+
-
- junit
- junit
- 4.12
-
-
+
+
+
+ src/main/resources/
+
+ **/*.java
+
+
+
+
-
-
-
- src/main/resources/
-
- **/*.java
-
-
-
-
-
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
-
-
-
- 2.8.8.1
- 2.8.2
-
+
+ 2.8.8.1
+ 2.8.2
+
\ No newline at end of file
diff --git a/guest/logback-example/pom.xml b/guest/logback-example/pom.xml
index 8ad406fc89..d913db26bd 100644
--- a/guest/logback-example/pom.xml
+++ b/guest/logback-example/pom.xml
@@ -1,41 +1,32 @@
- 4.0.0
- com.stackify
- logback-example
- 0.0.1-SNAPSHOT
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ com.stackify
+ logback-example
+ 0.0.1-SNAPSHOT
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+ ../../
+
+
+
+ ch.qos.logback
+ logback-classic
+ 1.2.3
+
-
-
- ch.qos.logback
- logback-classic
- 1.2.3
-
+
+ junit
+ junit
+ 4.12
+
-
- junit
- junit
- 4.12
-
-
-
- org.codehaus.janino
- janino
- 3.0.7
-
-
-
-
-
-
-
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
-
+
+ org.codehaus.janino
+ janino
+ 3.0.7
+
+
\ No newline at end of file
diff --git a/guest/memory-leaks/pom.xml b/guest/memory-leaks/pom.xml
index 82361779e2..0bb201dd2f 100644
--- a/guest/memory-leaks/pom.xml
+++ b/guest/memory-leaks/pom.xml
@@ -1,39 +1,36 @@
- 4.0.0
- com.baeldung
- memory-leaks
- 0.0.1-SNAPSHOT
+ 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
+ memory-leaks
+ 0.0.1-SNAPSHOT
-
-
- junit
- junit
- 4.12
-
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+ ../../
+
-
-
-
- src/main/resources/
-
- **/*.java
-
-
-
- src/test/resources/
-
-
-
-
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
-
+
+
+ junit
+ junit
+ ${junit.version}
+
+
+
+
+
+
+ src/main/resources/
+
+ **/*.java
+
+
+
+ src/test/resources/
+
+
+
\ No newline at end of file
diff --git a/guest/remote-debugging/pom.xml b/guest/remote-debugging/pom.xml
index 8540347e40..6e077fce56 100644
--- a/guest/remote-debugging/pom.xml
+++ b/guest/remote-debugging/pom.xml
@@ -2,7 +2,6 @@
4.0.0
-
com.stackify
java-remote-debugging
0.0.1-SNAPSHOT
@@ -11,28 +10,19 @@
org.springframework.boot
spring-boot-starter-parent
- 1.5.8.RELEASE
+ ${spring-boot-starter-parent.version}
-
- UTF-8
- UTF-8
- 1.8
-
-
-
org.springframework.boot
spring-boot-starter-web
-
org.springframework.boot
spring-boot-starter-tomcat
-
@@ -45,4 +35,10 @@
+
+ UTF-8
+ UTF-8
+ 1.5.8.RELEASE
+
+
diff --git a/guest/spring-mvc/pom.xml b/guest/spring-mvc/pom.xml
index 1f695a75a7..169b216ff9 100644
--- a/guest/spring-mvc/pom.xml
+++ b/guest/spring-mvc/pom.xml
@@ -2,19 +2,17 @@
4.0.0
-
com.stackify.guest
spring-mvc
0.0.1-SNAPSHOT
jar
-
spring-mvc
Spring MVC sample project
org.springframework.boot
spring-boot-starter-parent
- 2.0.0.M5
+ ${spring-boot-starter-parent.version}
@@ -39,6 +37,7 @@
+
spring-milestones
@@ -53,7 +52,7 @@
UTF-8
UTF-8
- 1.8
+ 2.0.0.M5
diff --git a/guest/spring-security/pom.xml b/guest/spring-security/pom.xml
index c41637bfc2..16e946d108 100644
--- a/guest/spring-security/pom.xml
+++ b/guest/spring-security/pom.xml
@@ -3,21 +3,19 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
-
com.stackify.guest
spring-security
1.0-SNAPSHOT
+ spring-security
+ Spring Security Sample Project
org.springframework.boot
spring-boot-starter-parent
- 2.0.0.M6
+ ${spring-boot-starter-parent.version}
- spring-security
- Spring Security Sample Project
-
org.springframework.boot
@@ -30,7 +28,7 @@
org.thymeleaf
thymeleaf-spring5
- 3.0.8.RELEASE
+ ${thymeleaf-spring5.version}
org.springframework.boot
@@ -57,6 +55,7 @@
+
spring-milestones
@@ -71,7 +70,8 @@
UTF-8
UTF-8
- 1.8
+ 3.0.8.RELEASE
+ 2.0.0.M6
\ No newline at end of file
diff --git a/guest/thread-pools/pom.xml b/guest/thread-pools/pom.xml
index 4588f3da4c..56173b1285 100644
--- a/guest/thread-pools/pom.xml
+++ b/guest/thread-pools/pom.xml
@@ -1,28 +1,27 @@
- 4.0.0
- com.stackify
- thread-pools
- 0.0.1-SNAPSHOT
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ com.stackify
+ thread-pools
+ 0.0.1-SNAPSHOT
-
-
- ch.qos.logback
- logback-classic
- 1.2.3
-
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+ ../../
+
+
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback-classic.version}
+
+
+
+
+ 1.2.3
+
-
-
-
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
-
\ No newline at end of file
diff --git a/guest/tomcat-app/pom.xml b/guest/tomcat-app/pom.xml
index 2a4bf8ef59..f3447b08c3 100644
--- a/guest/tomcat-app/pom.xml
+++ b/guest/tomcat-app/pom.xml
@@ -1,63 +1,58 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.stackify
tomcat-app
0.0.1-SNAPSHOT
war
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+ ../../
+
+
org.glassfish.jersey.containers
jersey-container-servlet
- 2.25.1
+ ${jersey-container-servlet.version}
org.glassfish.jersey.media
jersey-media-moxy
- 2.25.1
+ ${jersey-media-moxy.version}
io.rest-assured
rest-assured
- 3.0.3
+ ${rest-assured.version}
junit
junit
- 4.12
+ ${junit.version}
-
com.h2database
h2
- 1.4.195
+ ${h2database.version}
-
org.apache.logging.log4j
log4j-core
- 2.8.2
+ ${log4j-core.version}
-
net.bull.javamelody
javamelody-core
- 1.69.0
+ ${javamelody-core.version}
-
-
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
maven-war-plugin
3.0.0
@@ -67,4 +62,15 @@
+
+
+ 1.2.3
+ 2.25.1
+ 1.4.195
+ 3.0.3
+ 2.8.2
+ 1.69.0
+ 2.25.1
+
+
\ No newline at end of file
diff --git a/guest/webservices/rest-client/pom.xml b/guest/webservices/rest-client/pom.xml
index 016fa54af7..84f4eaf3c0 100644
--- a/guest/webservices/rest-client/pom.xml
+++ b/guest/webservices/rest-client/pom.xml
@@ -1,27 +1,32 @@
- 4.0.0
- com.stackify
- rest-client
- 0.0.1-SNAPSHOT
- war
-
-
-
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
- maven-war-plugin
- 2.6
-
- WebContent
- false
-
-
-
-
+ 4.0.0
+ com.stackify
+ rest-client
+ 0.0.1-SNAPSHOT
+ war
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+ ../../../
+
+
+
+
+
+ maven-war-plugin
+ ${maven-war-plugin.version}
+
+ WebContent
+ false
+
+
+
+
+
+
+ 2.6
+
+
\ No newline at end of file
diff --git a/guest/webservices/rest-server/pom.xml b/guest/webservices/rest-server/pom.xml
index 69d370965f..955afdd82c 100644
--- a/guest/webservices/rest-server/pom.xml
+++ b/guest/webservices/rest-server/pom.xml
@@ -1,51 +1,58 @@
- 4.0.0
- com.stackify
- rest-server
- 0.0.1-SNAPSHOT
- war
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ com.stackify
+ rest-server
+ 0.0.1-SNAPSHOT
+ war
-
-
- org.glassfish.jersey.containers
- jersey-container-servlet
- 2.25.1
-
-
- org.glassfish.jersey.media
- jersey-media-moxy
- 2.25.1
-
-
- io.rest-assured
- rest-assured
- 3.0.3
-
-
- junit
- junit
- 4.12
-
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+ ../../../
+
+
+
+
+ org.glassfish.jersey.containers
+ jersey-container-servlet
+ ${jersey-container-servlet.version}
+
+
+ org.glassfish.jersey.media
+ jersey-media-moxy
+ ${jersey-media-moxy.version}
+
+
+ io.rest-assured
+ rest-assured
+ ${rest-assured.version}
+
+
+ junit
+ junit
+ ${junit.version}
+
+
+
+
+
+
+ maven-war-plugin
+ ${maven-war-plugin.version}
+
+ WebContent
+
+
+
+
+
+
+ 3.0.0
+ 2.25.1
+ 3.0.3
+ 2.25.1
+
-
-
-
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
- maven-war-plugin
- 3.0.0
-
- WebContent
-
-
-
-
\ No newline at end of file
diff --git a/guest/webservices/spring-rest-service/pom.xml b/guest/webservices/spring-rest-service/pom.xml
index 11082cf17b..74b76ee725 100644
--- a/guest/webservices/spring-rest-service/pom.xml
+++ b/guest/webservices/spring-rest-service/pom.xml
@@ -1,48 +1,59 @@
- 4.0.0
- com.stackify
- spring-rest-service
- 0.0.1-SNAPSHOT
- war
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ com.stackify
+ spring-rest-service
+ 0.0.1-SNAPSHOT
+ war
-
- org.springframework.boot
- spring-boot-starter-parent
- 1.5.4.RELEASE
-
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ ${spring-boot-starter-parent.version}
+
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-hateoas
-
-
- io.springfox
- springfox-swagger2
- 2.7.0
-
-
- io.springfox
- springfox-swagger-ui
- 2.7.0
-
-
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-hateoas
+
+
+ io.springfox
+ springfox-swagger2
+ ${springfox-swagger2.version}
+
+
+ io.springfox
+ springfox-swagger-ui
+ ${springfox-swagger-ui.version}
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ ${maven.compiler.source}
+ ${maven.compiler.target}
+
+
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.5.4.RELEASE
+ 2.7.0
+ 2.7.0
+ 1.8
+ 1.8
+
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
- 1.8
- 1.8
-
-
-
-
\ No newline at end of file
diff --git a/guice/pom.xml b/guice/pom.xml
index 17b599a379..ba0ed39c4a 100644
--- a/guice/pom.xml
+++ b/guice/pom.xml
@@ -1,11 +1,12 @@
+ 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.examples.guice
guice
1.0-SNAPSHOT
jar
+ guice
com.baeldung
@@ -20,9 +21,10 @@
${guice.version}
+
UTF-8
4.1.0
- guice
+
diff --git a/handling-spring-static-resources/pom.xml b/handling-spring-static-resources/pom.xml
index 65a6e120a0..a3c714514e 100644
--- a/handling-spring-static-resources/pom.xml
+++ b/handling-spring-static-resources/pom.xml
@@ -1,13 +1,11 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
-
com.baeldung
spring-static-resources
0.1.0-SNAPSHOT
war
-
spring-static-resources
@@ -18,7 +16,6 @@
-
org.springframework.security
spring-security-web
diff --git a/hazelcast/pom.xml b/hazelcast/pom.xml
index 2811bf8b12..aa7faa07cf 100644
--- a/hazelcast/pom.xml
+++ b/hazelcast/pom.xml
@@ -1,5 +1,5 @@
+ 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
hazelcast
@@ -18,13 +18,11 @@
hazelcast
${hazelcast.version}
-
com.hazelcast
hazelcast-client
${hazelcast.version}
-
diff --git a/hbase/pom.xml b/hbase/pom.xml
index 5fe47fcdc7..ff4aa15130 100644
--- a/hbase/pom.xml
+++ b/hbase/pom.xml
@@ -1,14 +1,14 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ hbase
+
parent-modules
com.baeldung
1.0.0-SNAPSHOT
- 4.0.0
-
- hbase
@@ -34,5 +34,4 @@
1.3.1
-
\ No newline at end of file
diff --git a/hibernate5/pom.xml b/hibernate5/pom.xml
index 31fe10ee97..6ed13b8ae4 100644
--- a/hibernate5/pom.xml
+++ b/hibernate5/pom.xml
@@ -1,27 +1,21 @@
- 4.0.0
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
- com.baeldung
- hibernate5
- 0.0.1-SNAPSHOT
- hibernate5
- http://maven.apache.org
-
- UTF-8
-
- 3.7.0
- 5.2.12.Final
- 6.0.6
- 2.2.3
-
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ 4.0.0
+ com.baeldung
+ hibernate5
+ 0.0.1-SNAPSHOT
+ hibernate5
+ http://maven.apache.org
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
org.hibernate
hibernate-core
@@ -30,18 +24,18 @@
junit
junit
- 4.12
+ ${junit.version}
org.assertj
assertj-core
- 3.8.0
+ ${assertj-core.version}
test
com.h2database
h2
- 1.4.196
+ ${h2database.version}
org.hibernate
@@ -58,8 +52,9 @@
mariaDB4j
${mariaDB4j.version}
-
-
+
+
+
hibernate5
@@ -67,33 +62,17 @@
true
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
- 1.8
- 1.8
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- 3
- true
-
- **/*IntegrationTest.java
- **/*LiveTest.java
-
-
-
-
-
-
-
+
+
+ UTF-8
+
+ 3.7.0
+ 5.2.12.Final
+ 6.0.6
+ 2.2.3
+ 1.4.196
+ 3.8.0
+
+
diff --git a/httpclient/pom.xml b/httpclient/pom.xml
index b7567e0c4b..af50f38ebe 100644
--- a/httpclient/pom.xml
+++ b/httpclient/pom.xml
@@ -1,10 +1,9 @@
+ 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
httpclient
0.1-SNAPSHOT
-
httpclient
@@ -14,23 +13,18 @@
-
-
com.google.guava
guava
${guava.version}
-
org.apache.commons
commons-lang3
${commons-lang3.version}
-
-
org.apache.httpcomponents
httpclient
@@ -42,7 +36,6 @@
-
org.apache.httpcomponents
fluent-hc
@@ -54,19 +47,16 @@
-
org.apache.httpcomponents
httpmime
${httpclient.version}
-
commons-codec
commons-codec
${commons-codec.version}
-
org.apache.httpcomponents
httpasyncclient
@@ -78,15 +68,12 @@
-
com.github.tomakehurst
wiremock
${wiremock.version}
test
-
-
@@ -97,7 +84,6 @@
true
-
@@ -136,22 +122,17 @@
-
19.0
3.5
1.10
4.1.2
-
2.5.1
-
4.4.5
4.5.3
-
1.6.1
-
\ No newline at end of file
diff --git a/hystrix/pom.xml b/hystrix/pom.xml
index 19da678eb7..8e4a9b28b7 100644
--- a/hystrix/pom.xml
+++ b/hystrix/pom.xml
@@ -1,6 +1,5 @@
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
hystrix
1.0
@@ -13,23 +12,6 @@
../parent-boot-5
-
-
-
-
- 1.5.8
- 0.20.7
-
-
- 1.3
-
-
- 2.6
- 2.7
- 1.5.8
- 1.5.8
-
-
org.springframework.boot
@@ -59,7 +41,7 @@
hystrix-metrics-event-stream
${hystrix-metrics-event-stream.version}
-
com.netflix.rxjava
@@ -79,39 +61,17 @@
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
+
+
+ 1.5.8
+ 0.20.7
+
+ 1.3
+
+ 2.6
+ 2.7
+ 1.5.8
+ 1.5.8
+
diff --git a/image-processing/pom.xml b/image-processing/pom.xml
index 2e4063964e..51444a7812 100644
--- a/image-processing/pom.xml
+++ b/image-processing/pom.xml
@@ -1,17 +1,11 @@
+ 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
image-processing
1.0-SNAPSHOT
-
- 1.3.5
- 1.51h
-
-
com.baeldung
parent-modules
@@ -40,17 +34,23 @@
commons-logging
-
+
com.twelvemonkeys.imageio
imageio-core
- 3.3.2
-
+ ${imageio.version}
+
com.twelvemonkeys.imageio
imageio-bmp
- 3.3.2
+ ${imageio.version}
+
+ 1.3.5
+ 1.51h
+ 3.3.2
+
+
\ No newline at end of file
diff --git a/immutables/pom.xml b/immutables/pom.xml
index 884ebc0c61..987dce934d 100644
--- a/immutables/pom.xml
+++ b/immutables/pom.xml
@@ -1,8 +1,7 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
-
immutables
1.0.0-SNAPSHOT
@@ -37,4 +36,5 @@
3.6.1
0.9.6
+
\ No newline at end of file
diff --git a/influxdb/pom.xml b/influxdb/pom.xml
index 05a8e00fa0..92c47d2082 100644
--- a/influxdb/pom.xml
+++ b/influxdb/pom.xml
@@ -1,6 +1,6 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
influxdb
0.1-SNAPSHOT
@@ -28,17 +28,12 @@
${lombok.version}
provided
-
-
-
- 1.8
UTF-8
2.8
1.16.18
-
diff --git a/jackson/pom.xml b/jackson/pom.xml
index 2587e61ac1..fb2d48d4af 100644
--- a/jackson/pom.xml
+++ b/jackson/pom.xml
@@ -1,10 +1,9 @@
+ 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
jackson
0.1-SNAPSHOT
-
jackson
@@ -14,9 +13,7 @@
-
-
com.google.guava
guava
@@ -113,7 +110,6 @@
${assertj.version}
test
-
@@ -124,13 +120,11 @@
true
-
2.9.4
-
19.0
3.5
@@ -142,7 +136,6 @@
3.0.1
3.6.1
-
diff --git a/java-difference-date/pom.xml b/java-difference-date/pom.xml
index ac3f0fa3b5..ad66623581 100644
--- a/java-difference-date/pom.xml
+++ b/java-difference-date/pom.xml
@@ -1,21 +1,19 @@
- 4.0.0
+ 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
+ java-difference-date
+ 0.0.1-SNAPSHOT
+ jar
+ java-difference-date
+ Difference between two dates in java
- com.baeldung
- java-difference-date
- 0.0.1-SNAPSHOT
- jar
-
- java-difference-date
- Difference between two dates in java
-
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
@@ -36,24 +34,10 @@
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
-
-
- 1.8
4.12
2.9.9
1.5.1
+
diff --git a/java-lite/README.md b/java-lite/README.md
index 13dcd5f8c3..a4e2edd49f 100644
--- a/java-lite/README.md
+++ b/java-lite/README.md
@@ -1,3 +1,4 @@
### Relevant Articles:
- [A Guide to JavaLite – Building a RESTful CRUD application](http://www.baeldung.com/javalite-rest)
+- [Introduction to ActiveWeb](http://www.baeldung.com/activeweb)
diff --git a/java-lite/pom.xml b/java-lite/pom.xml
index d7950487ca..7c0ed1c780 100644
--- a/java-lite/pom.xml
+++ b/java-lite/pom.xml
@@ -1,8 +1,7 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
-
org.baeldung
java-lite
1.0-SNAPSHOT
@@ -14,15 +13,40 @@
1.0.0-SNAPSHOT
-
- 9.4.8.v20171121
- 1.4.13
- 1.15
- 5.1.45
- 1.7.0
- 1.8.2
- 4.12
-
+
+
+ org.javalite
+ activeweb
+ ${activeweb.version}
+
+
+
+ mysql
+ mysql-connector-java
+ ${mysql.connector.java.version}
+
+
+
+ com.sun
+ tools
+ ${sun.tools.version}
+ system
+ ${java.home}/../lib/tools.jar
+
+
+
+ org.javalite
+ activeweb-testing
+ ${activeweb-testing.version}
+ test
+
+
+
+ junit
+ junit
+ ${junit.version}
+
+
@@ -69,39 +93,14 @@
-
-
- org.javalite
- activeweb
- ${activeweb.version}
-
-
-
- mysql
- mysql-connector-java
- ${mysql.connector.java.version}
-
-
-
- com.sun
- tools
- ${sun.tools.version}
- system
- ${java.home}/../lib/tools.jar
-
-
-
- org.javalite
- activeweb-testing
- 1.15
- test
-
-
-
- junit
- junit
- ${junit.version}
-
-
+
+ 9.4.8.v20171121
+ 1.4.13
+ 1.15
+ 5.1.45
+ 1.7.0
+ 1.8.2
+ 1.15
+
\ No newline at end of file
diff --git a/java-rmi/pom.xml b/java-rmi/pom.xml
index 7c08968cbf..1543e24fbd 100644
--- a/java-rmi/pom.xml
+++ b/java-rmi/pom.xml
@@ -1,20 +1,19 @@
- 4.0.0
+ 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.rmi
+ java-rmi
+ 1.0-SNAPSHOT
+ jar
- com.baeldung.rmi
- java-rmi
- 1.0-SNAPSHOT
- jar
-
-
+
com.baeldung
parent-modules
1.0.0-SNAPSHOT
-
-
-
- UTF-8
-
-
+
+
+
+ UTF-8
+
+
diff --git a/java-spi/exchange-rate-api/pom.xml b/java-spi/exchange-rate-api/pom.xml
index 27651533a9..4dd9eb195c 100644
--- a/java-spi/exchange-rate-api/pom.xml
+++ b/java-spi/exchange-rate-api/pom.xml
@@ -1,10 +1,9 @@
4.0.0
-
exchange-rate-api
jar
-
+
com.baeldung
java-spi
diff --git a/java-spi/exchange-rate-app/pom.xml b/java-spi/exchange-rate-app/pom.xml
index 7e64cf7438..42a41a5355 100644
--- a/java-spi/exchange-rate-app/pom.xml
+++ b/java-spi/exchange-rate-app/pom.xml
@@ -1,14 +1,13 @@
4.0.0
-
exchange-rate-app
jar
com.baeldung
java-spi
- 1.0.0-SNAPSHOT
+ 1.0.0-SNAPSHOT
diff --git a/java-spi/exchange-rate-impl/pom.xml b/java-spi/exchange-rate-impl/pom.xml
index ec22791351..f44140ab0e 100644
--- a/java-spi/exchange-rate-impl/pom.xml
+++ b/java-spi/exchange-rate-impl/pom.xml
@@ -1,7 +1,6 @@
4.0.0
-
exchange-rate-impl
jar
diff --git a/java-spi/pom.xml b/java-spi/pom.xml
index 9bcf6ab174..4b9500ffcd 100644
--- a/java-spi/pom.xml
+++ b/java-spi/pom.xml
@@ -1,7 +1,6 @@
4.0.0
-
java-spi
pom
diff --git a/java-vavr-stream/pom.xml b/java-vavr-stream/pom.xml
index ca3807cd15..093d8763e3 100644
--- a/java-vavr-stream/pom.xml
+++ b/java-vavr-stream/pom.xml
@@ -1,20 +1,29 @@
-
+
4.0.0
com.baeldung.samples
java-vavr-stream
1.0
jar
-
- UTF-8
- 1.8
- 1.8
-
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
io.vavr
vavr
- 0.9.2
+ ${io.vavr.version}
+
+
+ UTF-8
+ 0.9.2
+
+
\ No newline at end of file
diff --git a/java-websocket/pom.xml b/java-websocket/pom.xml
index 402e3057c6..461182e504 100644
--- a/java-websocket/pom.xml
+++ b/java-websocket/pom.xml
@@ -1,35 +1,37 @@
- 4.0.0
- com.baeldung
- java-websocket
- war
- 0.0.1-SNAPSHOT
- java-websocket Maven Webapp
- http://maven.apache.org
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ 4.0.0
+ com.baeldung
+ java-websocket
+ war
+ 0.0.1-SNAPSHOT
+ java-websocket Maven Webapp
+ http://maven.apache.org
-
- UTF-8
-
-
com.baeldung
parent-modules
1.0.0-SNAPSHOT
-
+
-
-
- javax.websocket
- javax.websocket-api
- 1.1
- provided
-
-
- com.google.code.gson
- gson
- 2.8.0
-
-
+
+
+ javax.websocket
+ javax.websocket-api
+ ${javax.websocket-api.version}
+ provided
+
+
+ com.google.code.gson
+ gson
+ ${gson.version}
+
+
+
+
+ UTF-8
+ 1.1
+ 2.8.0
+
diff --git a/javafx/.gitignore b/javafx/.gitignore
new file mode 100644
index 0000000000..dfbd063287
--- /dev/null
+++ b/javafx/.gitignore
@@ -0,0 +1,6 @@
+# Created by .ignore support plugin (hsz.mobi)
+.idea
+classes
+target
+*.iml
+out
\ No newline at end of file
diff --git a/javafx/README.md b/javafx/README.md
new file mode 100644
index 0000000000..66c81f17ad
--- /dev/null
+++ b/javafx/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles:
+-[Introduction to JavaFX](http://www.baeldung.com/javafx)
+
diff --git a/javafx/pom.xml b/javafx/pom.xml
new file mode 100644
index 0000000000..b2de708be1
--- /dev/null
+++ b/javafx/pom.xml
@@ -0,0 +1,13 @@
+
+
+ 4.0.0
+ javafx
+
+
+ parent-modules
+ com.baeldung
+ 1.0.0-SNAPSHOT
+
+
+
\ No newline at end of file
diff --git a/core-java/src/main/java/com/baeldung/javafx/Main.java b/javafx/src/main/java/com/baeldung/Main.java
similarity index 96%
rename from core-java/src/main/java/com/baeldung/javafx/Main.java
rename to javafx/src/main/java/com/baeldung/Main.java
index f68121b394..59e24209b5 100644
--- a/core-java/src/main/java/com/baeldung/javafx/Main.java
+++ b/javafx/src/main/java/com/baeldung/Main.java
@@ -1,4 +1,4 @@
-package com.baeldung.javafx;
+package com.baeldung;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
diff --git a/core-java/src/main/java/com/baeldung/javafx/model/Person.java b/javafx/src/main/java/com/baeldung/model/Person.java
similarity index 97%
rename from core-java/src/main/java/com/baeldung/javafx/model/Person.java
rename to javafx/src/main/java/com/baeldung/model/Person.java
index dd473e84b4..0b915832ce 100644
--- a/core-java/src/main/java/com/baeldung/javafx/model/Person.java
+++ b/javafx/src/main/java/com/baeldung/model/Person.java
@@ -1,4 +1,4 @@
-package com.baeldung.javafx.model;
+package com.baeldung.model;
import javafx.beans.property.*;
diff --git a/core-java/src/main/java/com/baeldung/javafx/view/SearchController.java b/javafx/src/main/java/com/baeldung/view/SearchController.java
similarity index 96%
rename from core-java/src/main/java/com/baeldung/javafx/view/SearchController.java
rename to javafx/src/main/java/com/baeldung/view/SearchController.java
index f506981714..430580f8b5 100644
--- a/core-java/src/main/java/com/baeldung/javafx/view/SearchController.java
+++ b/javafx/src/main/java/com/baeldung/view/SearchController.java
@@ -1,7 +1,7 @@
-package com.baeldung.javafx.view;
+package com.baeldung.view;
-import com.baeldung.javafx.model.Person;
+import com.baeldung.model.Person;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.concurrent.Task;
@@ -11,7 +11,6 @@ import javafx.scene.control.*;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.VBox;
-import java.util.List;
import java.util.stream.Collectors;
public class SearchController {
diff --git a/core-java/src/main/resources/SearchController.fxml b/javafx/src/main/resources/SearchController.fxml
similarity index 93%
rename from core-java/src/main/resources/SearchController.fxml
rename to javafx/src/main/resources/SearchController.fxml
index a894b0260b..5e83024d03 100644
--- a/core-java/src/main/resources/SearchController.fxml
+++ b/javafx/src/main/resources/SearchController.fxml
@@ -7,7 +7,7 @@
diff --git a/core-java/src/main/resources/search.css b/javafx/src/main/resources/search.css
similarity index 100%
rename from core-java/src/main/resources/search.css
rename to javafx/src/main/resources/search.css
diff --git a/javax-servlets/README.md b/javax-servlets/README.md
index d6bc6db8b8..ff2256b3c0 100644
--- a/javax-servlets/README.md
+++ b/javax-servlets/README.md
@@ -1,2 +1,3 @@
### Relevant Articles:
- [Introduction to Java Servlets](http://www.baeldung.com/intro-to-servlets)
+- [An MVC Example with Servlets and JSP](http://www.baeldung.com/mvc-servlet-jsp)
diff --git a/javax-servlets/pom.xml b/javax-servlets/pom.xml
index 7407666309..69d952da9c 100644
--- a/javax-servlets/pom.xml
+++ b/javax-servlets/pom.xml
@@ -1,9 +1,7 @@
+ 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
javax-servlets
1.0-SNAPSHOT
@@ -13,10 +11,7 @@
1.0.0-SNAPSHOT
-
-
-
javax.servlet
javax.servlet-api
@@ -34,12 +29,18 @@
-
+
+ org.springframework
+ spring-test
+ ${spring-test.version}
+ test
+
3.1.0
4.5.3
+ 5.0.5.RELEASE
\ No newline at end of file
diff --git a/javaxval/README.md b/javaxval/README.md
index c6a6eb7345..3153546c7d 100644
--- a/javaxval/README.md
+++ b/javaxval/README.md
@@ -8,3 +8,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
### Relevant Articles:
- [Java Bean Validation Basics](http://www.baeldung.com/javax-validation)
- [Validating Container Elements with Bean Validation 2.0](http://www.baeldung.com/bean-validation-container-elements)
+- [Method Constraints with Bean Validation 2.0](http://www.baeldung.com/javax-validation-method-constraints)
diff --git a/javaxval/bin/pom.xml b/javaxval/bin/pom.xml
index 68e65e4d02..a16072bb1a 100644
--- a/javaxval/bin/pom.xml
+++ b/javaxval/bin/pom.xml
@@ -1,5 +1,5 @@
+ 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
javaxval
@@ -7,7 +7,7 @@
-
+
javax.validation
validation-api
diff --git a/javaxval/pom.xml b/javaxval/pom.xml
index a05ee43aaf..5de77ed26b 100644
--- a/javaxval/pom.xml
+++ b/javaxval/pom.xml
@@ -1,19 +1,10 @@
+ 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
javaxval
0.1-SNAPSHOT
-
- 2.0.1.Final
- 6.0.7.Final
- 3.0.0
- 2.2.6
- 5.0.2.RELEASE
-
-
-
com.baeldung
parent-modules
@@ -21,25 +12,21 @@
-
org.hibernate
hibernate-validator
${hibernate-validator.version}
-
org.hibernate
hibernate-validator-annotation-processor
${hibernate-validator.version}
-
javax.el
javax.el-api
${javax.el-api.version}
-
org.glassfish.web
javax.el
@@ -55,7 +42,14 @@
spring-test
${org.springframework.version}
-
+
+ 2.0.1.Final
+ 6.0.7.Final
+ 3.0.0
+ 2.2.6
+ 5.0.2.RELEASE
+
+
\ No newline at end of file
diff --git a/jaxb/pom.xml b/jaxb/pom.xml
index 8c9a430929..26d7c8d362 100644
--- a/jaxb/pom.xml
+++ b/jaxb/pom.xml
@@ -1,12 +1,11 @@
+ 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
jaxb
0.0.1-SNAPSHOT
jaxb
-
com.baeldung
parent-modules
@@ -19,30 +18,26 @@
jaxb-runtime
${jaxb.version}
-
org.glassfish.jaxb
jaxb-core
${jaxb.version}
-
com.sun.istack
istack-commons-runtime
- 3.0.2
+ ${istack-commons-runtime.version}
-
commons-io
commons-io
- 2.5
+ ${commons-io.version}
-
org.apache.commons
commons-lang3
- 3.5
+ ${commons-lang3.version}
@@ -60,7 +55,7 @@
org.eclipse.m2e
lifecycle-mapping
- 1.0.0
+ ${lifecycle-mapping-plugin.version}
@@ -75,7 +70,7 @@
-
+
@@ -116,13 +111,13 @@
-
@@ -133,6 +128,10 @@
2.3
+ 3.0.2
+ 2.5
+ 3.5
+ 1.0.0
\ No newline at end of file
diff --git a/jee-7/pom.xml b/jee-7/pom.xml
index f1d50f55c6..62e2132de5 100644
--- a/jee-7/pom.xml
+++ b/jee-7/pom.xml
@@ -1,427 +1,435 @@
- 4.0.0
+ 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
+ jee-7
+ 1.0-SNAPSHOT
+ war
+ JavaEE 7 Arquillian Archetype Sample
- com.baeldung
- jee-7
- 1.0-SNAPSHOT
- war
- JavaEE 7 Arquillian Archetype Sample
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+ ${maven.min.version}
+
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
+
+
+
+ org.jboss.arquillian
+ arquillian-bom
+ ${arquillian_core.version}
+ import
+ pom
+
+
+ org.jboss.arquillian.extension
+ arquillian-drone-bom
+ ${arquillian-drone-bom.version}
+ pom
+ import
+
+
+
-
- 1.8
- 3.0.0
+
+
+ javax
+ javaee-api
+ ${javaee_api.version}
+ provided
+
- 7.0
- 1.1.11.Final
- 8.2.1.Final
- 1.7.0
- 1.4.6.Final
- 3.0.19.Final
- 4.1.1
- 1.0.4
- 1.13
- 2.25
- 1.0.0.Final
+
+ org.jboss.arquillian.junit
+ arquillian-junit-container
+ test
+
+
+ org.jboss.arquillian.graphene
+ graphene-webdriver
+ ${graphene-webdriver.version}
+ pom
+ test
+
+
+ com.jayway.awaitility
+ awaitility
+ ${awaitility.version}
+ test
+
- 2.6
- 4.2.3.RELEASE
-
+
+ org.jboss.shrinkwrap.resolver
+ shrinkwrap-resolver-impl-maven
+ test
+ jar
+
-
- ${maven.min.version}
-
+
+ org.jboss.shrinkwrap.resolver
+ shrinkwrap-resolver-impl-maven-archive
+ test
+
+
+ org.apache.httpcomponents
+ httpclient
+ ${httpclient.version}
+
+
+ commons-io
+ commons-io
+ ${commons-io.version}
+
+
+ com.sun.faces
+ jsf-api
+ ${com.sun.faces.jsf.version}
+
+
+ com.sun.faces
+ jsf-impl
+ ${com.sun.faces.jsf.version}
+
+
+ javax.servlet
+ jstl
+ ${jstl.version}
+
+
+ javax.servlet
+ javax.servlet-api
+ ${javax.servlet-api.version}
+
+
+ javax.servlet.jsp
+ jsp-api
+ ${jsp-api.version}
+ provided
+
+
+ taglibs
+ standard
+ ${taglibs.standard.version}
+
-
-
-
- org.jboss.arquillian
- arquillian-bom
- ${arquillian_core.version}
- import
- pom
-
-
- org.jboss.arquillian.extension
- arquillian-drone-bom
- 2.0.1.Final
- pom
- import
-
-
-
+
+ javax.mvc
+ javax.mvc-api
+ 20160715
+
+
+ org.glassfish.ozark
+ ozark
+ ${ozark.version}
+
-
-
- javax
- javaee-api
- ${javaee_api.version}
- provided
-
+
+ org.springframework.security
+ spring-security-web
+ ${org.springframework.security.version}
+
-
- org.jboss.arquillian.junit
- arquillian-junit-container
- test
-
-
- org.jboss.arquillian.graphene
- graphene-webdriver
- 2.1.0.Final
- pom
- test
-
-
- com.jayway.awaitility
- awaitility
- ${awaitility.version}
- test
-
+
+ org.springframework.security
+ spring-security-config
+ ${org.springframework.security.version}
+
+
+ org.springframework.security
+ spring-security-taglibs
+ ${org.springframework.security.version}
+
+
-
- org.jboss.shrinkwrap.resolver
- shrinkwrap-resolver-impl-maven
- test
- jar
-
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ ${maven-war-plugin.version}
+
+ webapp
+ false
+
+
+
+
-
- org.jboss.shrinkwrap.resolver
- shrinkwrap-resolver-impl-maven-archive
- test
-
-
- org.apache.httpcomponents
- httpclient
- 4.5
-
-
- commons-io
- commons-io
- 2.4
-
-
- com.sun.faces
- jsf-api
- 2.2.14
-
-
- com.sun.faces
- jsf-impl
- 2.2.14
-
-
- javax.servlet
- jstl
- 1.2
-
-
- javax.servlet
- javax.servlet-api
- 3.1.0
-
-
- javax.servlet.jsp
- jsp-api
- 2.2
- provided
-
-
- taglibs
- standard
- 1.1.2
-
+
+
+ wildfly-managed-arquillian
+
+ true
+
+
+ standalone-full.xml
+ ${project.build.directory}/wildfly-${version.wildfly}
+
+
+
+ io.undertow
+ undertow-websockets-jsr
+ ${undertow-websockets-jsr.version}
+ test
+
+
+ org.jboss.resteasy
+ resteasy-client
+ ${resteasy.version}
+ test
+
+
+ org.jboss.resteasy
+ resteasy-jaxb-provider
+ ${resteasy.version}
+ test
+
+
+ org.jboss.resteasy
+ resteasy-json-p-provider
+ ${resteasy.version}
+ test
+
+
+ org.wildfly
+ wildfly-arquillian-container-managed
+ ${wildfly.version}
+ test
+
+
-
- javax.mvc
- javax.mvc-api
- 20160715
-
-
- org.glassfish.ozark
- ozark
- 20160715
-
+
+
+
+
+ maven-dependency-plugin
+ ${maven-dependency-plugin.version}
+
+ ${maven.test.skip}
+
+
+
+ unpack
+ process-test-classes
+
+ unpack
+
+
+
+
+ org.wildfly
+ wildfly-dist
+ ${wildfly.version}
+ zip
+ false
+ ${project.build.directory}
+
+
+
+
+
+
+
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+
+
+ ${project.build.directory}/wildfly-${wildfly.version}
+
+
+
+
+
+
+
+
+ wildfly-remote-arquillian
+
+
+ io.undertow
+ undertow-websockets-jsr
+ ${undertow-websockets-jsr.version}
+ test
+
+
+ org.jboss.resteasy
+ resteasy-client
+ ${resteasy.version}
+ test
+
+
+ org.jboss.resteasy
+ resteasy-jaxb-provider
+ ${resteasy.version}
+ test
+
+
+ org.jboss.resteasy
+ resteasy-json-p-provider
+ ${resteasy.version}
+ test
+
+
+ org.wildfly
+ wildfly-arquillian-container-remote
+ ${wildfly.version}
+ test
+
+
+
+
+ glassfish-embedded-arquillian
+
+
+ org.glassfish.main.extras
+ glassfish-embedded-all
+ ${glassfish-embedded-all.version}
+ test
+
+
+ org.glassfish
+ javax.json
+ ${javax.json.version}
+ test
+
+
+ org.glassfish.tyrus
+ tyrus-client
+ ${tyrus.version}
+ test
+
+
+ org.glassfish.tyrus
+ tyrus-container-grizzly-client
+ ${tyrus.version}
+ test
+
+
+ org.glassfish.jersey.core
+ jersey-client
+ ${jersey.version}
+ test
+
+
+ org.jboss.arquillian.container
+ arquillian-glassfish-embedded-3.1
+ ${arquillian-glassfish.version}
+ test
+
+
+
+
+ glassfish-remote-arquillian
+
+
+ org.glassfish
+ javax.json
+ ${javax.json.version}
+ test
+
+
+ org.glassfish.tyrus
+ tyrus-client
+ ${tyrus.version}
+ test
+
+
+ org.glassfish.tyrus
+ tyrus-container-grizzly-client
+ ${tyrus.version}
+ test
+
+
+ org.glassfish.jersey.core
+ jersey-client
+ ${jersey.version}
+ test
+
+
+ org.glassfish.jersey.media
+ jersey-media-json-jackson
+ ${jersey.version}
+ test
+
+
+ org.glassfish.jersey.media
+ jersey-media-json-processing
+ ${jersey.version}
+ test
+
+
+ org.jboss.arquillian.container
+ arquillian-glassfish-remote-3.1
+ ${arquillian-glassfish.version}
+ test
+
+
+
+
+ webdriver-chrome
+
+ true
+
+
+ chrome
+
+
+
+ webdriver-firefox
+
+ firefox
+
+
+
-
- org.springframework.security
- spring-security-web
- ${org.springframework.security.version}
-
+
+
+ bintray-mvc-spec-maven
+ bintray
+ http://dl.bintray.com/mvc-spec/maven
+
+ true
+
+
+ false
+
+
+
-
- org.springframework.security
- spring-security-config
- ${org.springframework.security.version}
-
-
- org.springframework.security
- spring-security-taglibs
- ${org.springframework.security.version}
-
-
+
+ 1.8
+ 3.0.0
+ 7.0
+ 1.1.11.Final
+ 8.2.1.Final
+ 1.7.0
+ 1.4.6.Final
+ 3.0.19.Final
+ 4.1.1
+ 1.0.4
+ 1.13
+ 2.25
+ 1.0.0.Final
+ 2.6
+ 4.2.3.RELEASE
+ 2.17
+ 1.1.2
+ 2.4
+ 2.2.14
+ 4.5
+ 2.0.1.Final
+ 3.1.0
+ 2.1.0.Final
+ 2.8
+ 1.2
+ 2.2
+ 20160715
+
-
-
-
- org.apache.maven.plugins
- maven-war-plugin
- ${maven-war-plugin.version}
-
- webapp
- false
-
-
-
-
-
-
-
-
- wildfly-managed-arquillian
-
- true
-
-
- standalone-full.xml
- ${project.build.directory}/wildfly-${version.wildfly}
-
-
-
- io.undertow
- undertow-websockets-jsr
- ${undertow-websockets-jsr.version}
- test
-
-
- org.jboss.resteasy
- resteasy-client
- ${resteasy.version}
- test
-
-
- org.jboss.resteasy
- resteasy-jaxb-provider
- ${resteasy.version}
- test
-
-
- org.jboss.resteasy
- resteasy-json-p-provider
- ${resteasy.version}
- test
-
-
- org.wildfly
- wildfly-arquillian-container-managed
- ${wildfly.version}
- test
-
-
-
-
-
-
- maven-dependency-plugin
- 2.8
-
- ${maven.test.skip}
-
-
-
- unpack
- process-test-classes
-
- unpack
-
-
-
-
- org.wildfly
- wildfly-dist
- ${wildfly.version}
- zip
- false
- ${project.build.directory}
-
-
-
-
-
-
-
- maven-surefire-plugin
- 2.17
-
-
- ${project.build.directory}/wildfly-${wildfly.version}
-
-
-
-
-
-
-
-
- wildfly-remote-arquillian
-
-
- io.undertow
- undertow-websockets-jsr
- ${undertow-websockets-jsr.version}
- test
-
-
- org.jboss.resteasy
- resteasy-client
- ${resteasy.version}
- test
-
-
- org.jboss.resteasy
- resteasy-jaxb-provider
- ${resteasy.version}
- test
-
-
- org.jboss.resteasy
- resteasy-json-p-provider
- ${resteasy.version}
- test
-
-
- org.wildfly
- wildfly-arquillian-container-remote
- ${wildfly.version}
- test
-
-
-
-
- glassfish-embedded-arquillian
-
-
- org.glassfish.main.extras
- glassfish-embedded-all
- ${glassfish-embedded-all.version}
- test
-
-
- org.glassfish
- javax.json
- ${javax.json.version}
- test
-
-
- org.glassfish.tyrus
- tyrus-client
- ${tyrus.version}
- test
-
-
- org.glassfish.tyrus
- tyrus-container-grizzly-client
- ${tyrus.version}
- test
-
-
- org.glassfish.jersey.core
- jersey-client
- ${jersey.version}
- test
-
-
- org.jboss.arquillian.container
- arquillian-glassfish-embedded-3.1
- ${arquillian-glassfish.version}
- test
-
-
-
-
- glassfish-remote-arquillian
-
-
- org.glassfish
- javax.json
- ${javax.json.version}
- test
-
-
- org.glassfish.tyrus
- tyrus-client
- ${tyrus.version}
- test
-
-
- org.glassfish.tyrus
- tyrus-container-grizzly-client
- ${tyrus.version}
- test
-
-
- org.glassfish.jersey.core
- jersey-client
- ${jersey.version}
- test
-
-
- org.glassfish.jersey.media
- jersey-media-json-jackson
- ${jersey.version}
- test
-
-
- org.glassfish.jersey.media
- jersey-media-json-processing
- ${jersey.version}
- test
-
-
- org.jboss.arquillian.container
- arquillian-glassfish-remote-3.1
- ${arquillian-glassfish.version}
- test
-
-
-
-
- webdriver-chrome
-
- true
-
-
- chrome
-
-
-
-
- webdriver-firefox
-
- firefox
-
-
-
-
-
-
- bintray-mvc-spec-maven
- bintray
- http://dl.bintray.com/mvc-spec/maven
-
- true
-
-
- false
-
-
-
diff --git a/jee-7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/pom.xml b/jee-7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/pom.xml
index de69efa43a..6a0dd05180 100644
--- a/jee-7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/pom.xml
+++ b/jee-7/src/main/java/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/pom.xml
@@ -1,57 +1,52 @@
- 4.0.0
- com.baeldung.javaeeannotations
- JavaEEAnnotationsSample
- 0.0.1-SNAPSHOT
- war
- JavaEEAnnotationsSample
- JavaEEAnnotationsSample
-
-
-
-
- javax.annotation
- javax.annotation-api
- 1.3
-
-
-
- javax.servlet
- javax.servlet-api
- 3.1.0
-
-
-
- javax.servlet.jsp
- jsp-api
- 2.1
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
- org.apache.maven.plugins
- maven-war-plugin
- 2.4
-
- src/main/webapp
- SpringFieldConstructorInjection
- false
-
-
-
-
- JavaEEAnnotationsSample
-
+ 4.0.0
+ com.baeldung.javaeeannotations
+ JavaEEAnnotationsSample
+ 0.0.1-SNAPSHOT
+ war
+ JavaEEAnnotationsSample
+ JavaEEAnnotationsSample
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+
+ javax.annotation
+ javax.annotation-api
+ 1.3
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.1.0
+
+
+
+ javax.servlet.jsp
+ jsp-api
+ 2.1
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ 2.4
+
+ src/main/webapp
+ SpringFieldConstructorInjection
+ false
+
+
+
+
+ JavaEEAnnotationsSample
+
\ No newline at end of file
diff --git a/jenkins/hello-world/pom.xml b/jenkins/hello-world/pom.xml
index 15cf2f8e34..8c6d691b29 100644
--- a/jenkins/hello-world/pom.xml
+++ b/jenkins/hello-world/pom.xml
@@ -5,7 +5,7 @@
org.jenkins-ci.plugins
plugin
2.33
-
+
jenkins-hello-world
1.0-SNAPSHOT
diff --git a/jersey/pom.xml b/jersey/pom.xml
index 0c8b6b9281..b41ea1f340 100644
--- a/jersey/pom.xml
+++ b/jersey/pom.xml
@@ -1,63 +1,59 @@
- 4.0.0
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ 4.0.0
+ com.baeldung
+ jersey
+ 0.0.1-SNAPSHOT
+ war
- com.baeldung
- jersey
- 0.0.1-SNAPSHOT
- war
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
+
+
+ org.glassfish.jersey.core
+ jersey-server
+ ${jersey.version}
+
+
+ org.glassfish.jersey.core
+ jersey-client
+ ${jersey.version}
+
+
+ org.glassfish.jersey.bundles
+ jaxrs-ri
+ ${jersey.version}
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+
+
-
- 2.26
- 1.7.25
- 3.2.0
-
+
+ jersey
+
+
+ maven-war-plugin
+ ${maven-war-plugin.version}
+
+ false
+
+
+
+
-
- jersey
-
-
- maven-war-plugin
- ${maven-war-plugin.version}
-
- false
-
-
-
-
-
-
-
- org.glassfish.jersey.core
- jersey-server
- ${jersey.version}
-
-
- org.glassfish.jersey.core
- jersey-client
- ${jersey.version}
-
-
- org.glassfish.jersey.bundles
- jaxrs-ri
- ${jersey.version}
-
-
- org.slf4j
- slf4j-api
- ${slf4j.version}
-
-
-
-
-
+
+ 2.26
+ 1.7.25
+ 3.2.0
+
diff --git a/jgroups/README.md b/jgroups/README.md
index bb2813c3d6..0921fa98a1 100644
--- a/jgroups/README.md
+++ b/jgroups/README.md
@@ -1,7 +1,7 @@
## Reliable Messaging with JGroups Tutorial Project
### Relevant Article:
-- [Reliable Messaging with JGroups](http://www.baeldung.com/reliable-messaging-with-jgroups/)
+- [Reliable Messaging with JGroups](http://www.baeldung.com/jgroups)
### Overview
This Maven project contains the Java code for the article linked above.
diff --git a/jgroups/pom.xml b/jgroups/pom.xml
index 0e5971875e..6340e41565 100644
--- a/jgroups/pom.xml
+++ b/jgroups/pom.xml
@@ -1,6 +1,6 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
jgroups
0.1-SNAPSHOT
@@ -18,19 +18,18 @@
org.jgroups
jgroups
- 4.0.10.Final
+ ${jgroups.version}
-
commons-cli
commons-cli
- 1.4
+ ${commons-cli.version}
- 1.8
UTF-8
+ 4.0.10.Final
diff --git a/jhipster/jhipster-microservice/car-app/pom.xml b/jhipster/jhipster-microservice/car-app/pom.xml
index 5fd7febd07..77e214234e 100644
--- a/jhipster/jhipster-microservice/car-app/pom.xml
+++ b/jhipster/jhipster-microservice/car-app/pom.xml
@@ -47,8 +47,8 @@
3.1.3
v6.10.0
-
-
+
+
${project.build.directory}/test-results
0.0.20
@@ -454,7 +454,7 @@
-
+
@@ -657,9 +657,9 @@
src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml
org.h2.Driver
jdbc:h2:file:./target/h2db/db/carapp
-
+
carapp
-
+
hibernate:spring:com.car.app.domain?dialect=org.hibernate.dialect.H2Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
true
debug
@@ -708,7 +708,7 @@
org.apache.maven.plugins
maven-war-plugin
-
+
@@ -747,7 +747,7 @@
org.apache.maven.plugins
maven-war-plugin
-
+
org.springframework.boot
diff --git a/jhipster/jhipster-microservice/dealer-app/pom.xml b/jhipster/jhipster-microservice/dealer-app/pom.xml
index 359783ef81..beada8f064 100644
--- a/jhipster/jhipster-microservice/dealer-app/pom.xml
+++ b/jhipster/jhipster-microservice/dealer-app/pom.xml
@@ -47,8 +47,8 @@
3.1.3
v6.10.0
-
-
+
+
0.0.20
${project.build.directory}/test-results
@@ -679,7 +679,7 @@
-
+
diff --git a/jhipster/jhipster-microservice/gateway-app/pom.xml b/jhipster/jhipster-microservice/gateway-app/pom.xml
index 32aa432279..d90addf51b 100644
--- a/jhipster/jhipster-microservice/gateway-app/pom.xml
+++ b/jhipster/jhipster-microservice/gateway-app/pom.xml
@@ -49,8 +49,8 @@
3.1.3
v6.10.0
-
-
+
+
0.0.20
${project.build.directory}/test-results
@@ -736,7 +736,7 @@
-
+
diff --git a/jhipster/jhipster-monolithic/pom.xml b/jhipster/jhipster-monolithic/pom.xml
index eb4c2ca2d3..fc8e8353b4 100644
--- a/jhipster/jhipster-monolithic/pom.xml
+++ b/jhipster/jhipster-monolithic/pom.xml
@@ -51,8 +51,8 @@
v6.10.0
4.3.0
-
-
+
+
${project.build.directory}/test-results
0.0.20
@@ -63,21 +63,22 @@
src/main/webapp/content/**/*.*,
src/main/webapp/bower_components/**/*.*,
- src/main/webapp/i18n/*.js, target/www/**/*.*
+ src/main/webapp/i18n/*.js, target/www/**/*.*
+
S3437,UndocumentedApi,BoldAndItalicTagsCheck
-
src/main/webapp/app/**/*.*
Web:BoldAndItalicTagsCheck
-
src/main/java/**/*
squid:S3437
-
src/main/java/**/*
squid:UndocumentedApi
@@ -128,7 +129,7 @@
com.jayway.jsonpath
json-path
test
-
@@ -392,8 +393,8 @@
spring-boot:run
-
org.eclipse.m2e
@@ -412,7 +413,7 @@
-
+
@@ -426,7 +427,7 @@
-
+
@@ -483,11 +484,11 @@
target/gatling/results
src/test/gatling/bodies
src/test/gatling/simulations
-
true
-
@@ -533,13 +534,15 @@
You are running an older version of
Maven. JHipster requires at least Maven
- ${maven.version}
+ ${maven.version}
+
[${maven.version},)
You are running an older version of
Java. JHipster requires at least JDK
- ${java.version}
+ ${java.version}
+
[${java.version}.0,)
@@ -588,7 +591,7 @@
org.apache.maven.plugins
maven-surefire-plugin
-
alphabetical
@@ -608,12 +611,12 @@
prepare-agent
-
${project.testresult.directory}/coverage/jacoco/jacoco.exec
-
post-unit-test
@@ -659,9 +662,9 @@
src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml
org.h2.Driver
jdbc:h2:file:./target/h2db/db/baeldung
-
+
baeldung
-
+
hibernate:spring:com.baeldung.domain?dialect=org.hibernate.dialect.H2Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
true
debug
@@ -678,7 +681,7 @@
true
true
-
@@ -862,11 +865,11 @@
-
cc
@@ -927,7 +930,7 @@
true
true
true
-
@@ -983,7 +986,7 @@
-
IDE
@@ -994,32 +997,5 @@
-
- integration
-
- true
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*IntTest.java
-
-
-
-
-
-
-
-
diff --git a/jjwt/pom.xml b/jjwt/pom.xml
index cd2dd9f97e..51d4dcf1c0 100644
--- a/jjwt/pom.xml
+++ b/jjwt/pom.xml
@@ -1,13 +1,11 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
-
io.jsonwebtoken
jjwtfun
0.0.1-SNAPSHOT
jar
-
jjwtfun
Exercising the JJWT
@@ -18,10 +16,6 @@
../parent-boot-5
-
- 0.7.0
-
-
org.springframework.boot
@@ -45,39 +39,8 @@
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
-
+
+ 0.7.0
+
+
diff --git a/jmeter/pom.xml b/jmeter/pom.xml
index 977e3bbc94..bb5769ef57 100644
--- a/jmeter/pom.xml
+++ b/jmeter/pom.xml
@@ -1,12 +1,10 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
-
jmeter
0.0.1-SNAPSHOT
jar
-
jmeter
Intro to Performance testing using JMeter
@@ -17,13 +15,6 @@
../parent-boot-5
-
- UTF-8
- UTF-8
- 1.8
- 2.6.0
-
-
org.springframework.boot
@@ -66,4 +57,12 @@
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 2.6.0
+
+
diff --git a/jmh/pom.xml b/jmh/pom.xml
index ef5c3f1bbf..2b82b7a9d5 100644
--- a/jmh/pom.xml
+++ b/jmh/pom.xml
@@ -8,36 +8,33 @@
jmh
http://maven.apache.org
-
- UTF-8
- UTF-8
- 1.8
- 1.6
- 1.6
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
org.openjdk.jmh
jmh-core
- 1.19
+ ${openjdk.jmh.version}
org.openjdk.jmh
jmh-generator-annprocess
- 1.19
+ ${openjdk.jmh.version}
junit
junit
- 3.8.1
+ ${junit.version}
test
-
com.google.guava
guava
- 21.0
+ ${guava.version}
@@ -57,4 +54,11 @@
+
+ UTF-8
+ UTF-8
+ 21.0
+ 1.19
+
+
\ No newline at end of file
diff --git a/jooby/pom.xml b/jooby/pom.xml
index 1935c646ee..8d4ed186aa 100644
--- a/jooby/pom.xml
+++ b/jooby/pom.xml
@@ -1,56 +1,58 @@
- 4.0.0
- jooby
- com.baeldung.jooby
- 1.0
- jooby
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ 4.0.0
+ jooby
+ com.baeldung.jooby
+ 1.0
+ jooby
-
- org.jooby
- modules
- 1.1.3
-
+
+ org.jooby
+ modules
+ ${jooby.modules.version}
+
-
- 1.1.3
- com.baeldung.jooby.App
-
+
+
+ org.jooby
+ jooby-netty
+
+
+ org.jooby
+ jooby-jedis
+ ${jooby-jedis.version}
+
+
+ ch.qos.logback
+ logback-classic
+
+
+ junit
+ junit
+ test
+
+
+ io.rest-assured
+ rest-assured
+ test
+
+
-
-
- org.jooby
- jooby-netty
-
-
- org.jooby
- jooby-jedis
- 1.1.3
-
-
- ch.qos.logback
- logback-classic
-
-
- junit
- junit
- test
-
-
- io.rest-assured
- rest-assured
- test
-
-
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+
+
+
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
-
-
-
+
+ 1.1.3
+ com.baeldung.jooby.App
+ 1.1.3
+ 1.1.3
+
diff --git a/jpa-storedprocedure/pom.xml b/jpa-storedprocedure/pom.xml
index cbda37a7b3..e6cfe153d5 100644
--- a/jpa-storedprocedure/pom.xml
+++ b/jpa-storedprocedure/pom.xml
@@ -1,8 +1,7 @@
+ 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
jpa-storedprocedure
1.0
@@ -14,14 +13,6 @@
1.0.0-SNAPSHOT
-
- 7.0
- 5.2.5.Final
- 6.0.5
- 2.5
- 2.19.1
-
-
JpaStoredProcedure
@@ -29,7 +20,7 @@
maven-assembly-plugin
${project.basedir}
-
jar-with-dependencies
@@ -40,36 +31,36 @@
-
-
javax
javaee-api
${jee.version}
provided
-
org.hibernate
hibernate-entitymanager
${hibernate.version}
-
-
mysql
mysql-connector-java
${mysql.version}
-
commons-io
commons-io
${commons-io.version}
-
+
+ 7.0
+ 5.2.5.Final
+ 6.0.5
+ 2.5
+
+
\ No newline at end of file
diff --git a/jsf/pom.xml b/jsf/pom.xml
index 5f4e2c69c1..ae97a71244 100644
--- a/jsf/pom.xml
+++ b/jsf/pom.xml
@@ -1,19 +1,19 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ jsf
+ 0.1-SNAPSHOT
+ war
+
parent-modules
com.baeldung
1.0.0-SNAPSHOT
- 4.0.0
- jsf
- 0.1-SNAPSHOT
- war
-
com.sun.faces
jsf-api
@@ -29,17 +29,13 @@
javax.el-api
${javax.el.version}
-
-
javax.servlet
jstl
${jstl.version}
-
-
org.springframework
spring-web
@@ -78,6 +74,7 @@
${javax.servlet.version}
+
@@ -106,6 +103,6 @@
2.6
-
+
\ No newline at end of file
diff --git a/json-path/pom.xml b/json-path/pom.xml
index 0f8ff3bd31..18bbb5af33 100644
--- a/json-path/pom.xml
+++ b/json-path/pom.xml
@@ -1,5 +1,5 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
json-path
0.0.1-SNAPSHOT
diff --git a/json/pom.xml b/json/pom.xml
index 7c74d425af..5d05b73489 100644
--- a/json/pom.xml
+++ b/json/pom.xml
@@ -1,5 +1,5 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.baeldung
json
@@ -12,7 +12,6 @@
-
org.everit.json
org.everit.json.schema
@@ -24,13 +23,11 @@
-
com.alibaba
fastjson
${fastjson.version}
-
org.json
json
@@ -42,4 +39,5 @@
1.4.1
1.2.21
+
diff --git a/jsonb/pom.xml b/jsonb/pom.xml
index 5058d89c31..f9db831fe3 100644
--- a/jsonb/pom.xml
+++ b/jsonb/pom.xml
@@ -1,106 +1,110 @@
- 4.0.0
+ 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
+ json-b
+ 0.0.1-SNAPSHOT
+ jar
+ json-b
+ json-b sample project
- com.baeldung
- json-b
- 0.0.1-SNAPSHOT
- jar
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
- json-b
- json-b sample project
-
-
- yasson
-
- true
-
-
-
-
- org.eclipse
- yasson
- ${yasson.version}
-
-
- org.glassfish
- javax.json
- ${javax.json.version}
-
-
-
-
- johnzon
-
-
-
- org.apache.geronimo.specs
- geronimo-json_1.1_spec
- ${geronimo-json_1.1_spec.version}
-
-
- org.apache.johnzon
- johnzon-jsonb
- ${johnzon.version}
-
-
-
-
-
-
- javax.json.bind
- javax.json.bind-api
- ${jsonb-api.version}
-
-
-
- org.apache.commons
- commons-collections4
- ${commons-collections4.version}
- test
-
+
+
+ javax.json.bind
+ javax.json.bind-api
+ ${jsonb-api.version}
+
+
+
+ org.apache.commons
+ commons-collections4
+ ${commons-collections4.version}
+ test
+
-
- org.junit.jupiter
- junit-jupiter-api
- ${junit.jupiter.version}
-
-
- org.junit.jupiter
- junit-jupiter-engine
- ${junit.jupiter.version}
- test
-
-
- org.junit.platform
- junit-platform-surefire-provider
- ${junit.platform.version}
- test
-
-
- org.junit.platform
- junit-platform-runner
- ${junit.platform.version}
- test
-
+
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit.jupiter.version}
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit.jupiter.version}
+ test
+
+
+ org.junit.platform
+ junit-platform-surefire-provider
+ ${junit.platform.version}
+ test
+
+
+ org.junit.platform
+ junit-platform-runner
+ ${junit.platform.version}
+ test
+
+
-
+
+
+ yasson
+
+ true
+
+
+
+
+ org.eclipse
+ yasson
+ ${yasson.version}
+
+
+ org.glassfish
+ javax.json
+ ${javax.json.version}
+
+
+
+
+ johnzon
+
+
+
+ org.apache.geronimo.specs
+ geronimo-json_1.1_spec
+ ${geronimo-json_1.1_spec.version}
+
+
+ org.apache.johnzon
+ johnzon-jsonb
+ ${johnzon.version}
+
+
+
+
-
- UTF-8
- UTF-8
- 1.8
- 1.8
- 1.0.0
- 5.0.0
- 2.20
- 1.0
- 1.1.3
- 1.0
- 1.0.1
- 1.1.2
- 4.1
-
+
+ UTF-8
+ UTF-8
+ 1.8
+ 1.8
+ 1.0.0
+ 5.0.0
+ 1.0
+ 1.1.3
+ 1.0
+ 1.0.1
+ 1.1.2
+ 4.1
+
\ No newline at end of file
diff --git a/jsoup/pom.xml b/jsoup/pom.xml
index 8bbb4a46dc..a914b7c6ba 100644
--- a/jsoup/pom.xml
+++ b/jsoup/pom.xml
@@ -1,14 +1,16 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
+ jsoup
+ jar
+
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- jsoup
- jar
+
org.jsoup
@@ -16,7 +18,9 @@
${jsoup.version}
+
1.10.2
+
diff --git a/jws/pom.xml b/jws/pom.xml
index 6b15e2dc14..4199021060 100644
--- a/jws/pom.xml
+++ b/jws/pom.xml
@@ -1,12 +1,10 @@
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
com.example
jws
war
0.0.1-SNAPSHOT
-
jws-example
@@ -15,13 +13,6 @@
1.0.0-SNAPSHOT
-
- 3.0.2
- 3.0.0
- 7.0
- 7.0
-
-
javax.jnlp
@@ -37,7 +28,6 @@
system
${project.basedir}/java-core-samples-lib/jardiff.jar
-
@@ -63,7 +53,6 @@
-
org.apache.maven.plugins
maven-war-plugin
@@ -89,4 +78,11 @@
${project.artifactId}
+
+ 3.0.2
+ 3.0.0
+ 7.0
+ 7.0
+
+
diff --git a/libraries-data/pom.xml b/libraries-data/pom.xml
index 4727ca2222..c0e90a51b2 100644
--- a/libraries-data/pom.xml
+++ b/libraries-data/pom.xml
@@ -2,14 +2,16 @@
4.0.0
+ libraries-data
+ libraries-data
+ jar
+
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- libraries-data
- libraries-data
- jar
+
com.esotericsoftware
@@ -65,24 +67,35 @@
test
test
+
+ org.apache.ignite
+ ignite-core
+ ${ignite.version}
+
+
+ org.apache.ignite
+ ignite-spring-data
+ ${ignite.version}
+
+
+ org.apache.ignite
+ ignite-indexing
+ ${ignite.version}
+
+
+ com.google.code.gson
+ gson
+ ${gson.version}
+
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
- 1.8
- 1.8
-
-
maven-antrun-plugin
- 1.8
+ ${maven-antrun-plugin.version}
generateMithra
@@ -128,11 +141,10 @@
-
org.codehaus.mojo
build-helper-maven-plugin
- 3.0.0
+ ${build-helper-maven-plugin.version}
add-source
@@ -162,7 +174,7 @@
-
+
@@ -173,6 +185,7 @@
https://repository.apache.org/content/groups/staging
+
4.0.1
1.4.196
@@ -181,5 +194,10 @@
3.7.0
5.0
1.0.0
+ 2.4.0
+ 2.8.2
+ 1.8
+ 3.0.0
+
\ No newline at end of file
diff --git a/libraries-data/src/main/java/com/baeldung/ignite/cache/CustomLifecycleBean.java b/libraries-data/src/main/java/com/baeldung/ignite/cache/CustomLifecycleBean.java
new file mode 100644
index 0000000000..0b603dcee0
--- /dev/null
+++ b/libraries-data/src/main/java/com/baeldung/ignite/cache/CustomLifecycleBean.java
@@ -0,0 +1,14 @@
+package com.baeldung.ignite.cache;
+
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.lifecycle.LifecycleBean;
+import org.apache.ignite.lifecycle.LifecycleEventType;
+
+public class CustomLifecycleBean implements LifecycleBean {
+ @Override
+ public void onLifecycleEvent(LifecycleEventType lifecycleEventType) throws IgniteException {
+ if (lifecycleEventType == LifecycleEventType.AFTER_NODE_START) {
+ //do something right after the Ignite node starts
+ }
+ }
+}
diff --git a/libraries-data/src/main/java/com/baeldung/ignite/cache/IgniteCacheExample.java b/libraries-data/src/main/java/com/baeldung/ignite/cache/IgniteCacheExample.java
new file mode 100644
index 0000000000..8c40b8f312
--- /dev/null
+++ b/libraries-data/src/main/java/com/baeldung/ignite/cache/IgniteCacheExample.java
@@ -0,0 +1,58 @@
+package com.baeldung.ignite.cache;
+
+import com.baeldung.ignite.model.Employee;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.configuration.IgniteConfiguration;
+
+import java.util.List;
+
+public class IgniteCacheExample {
+
+ public static void main(String[] args) {
+
+ Ignite ignite = Ignition.ignite();
+
+ IgniteCache cache = ignite.cache("baeldungCache");
+
+ cache.put(1, "baeldung cache value");
+
+ String message = cache.get(1);
+ }
+
+ private static void getObjectFromCache(Ignite ignite) {
+
+ IgniteCache cache = ignite.getOrCreateCache("baeldungCache");
+
+ cache.put(1, new Employee(1, "John", true));
+ cache.put(2, new Employee(2, "Anna", false));
+ cache.put(3, new Employee(3, "George", true));
+
+ Employee employee = cache.get(1);
+ }
+
+ private static void getFromCacheWithSQl(Ignite ignite) {
+
+ IgniteCache cache = ignite.cache("baeldungCache");
+
+ SqlFieldsQuery sql = new SqlFieldsQuery(
+ "select name from Employee where isEmployed = 'true'");
+
+ QueryCursor> cursor = cache.query(sql);
+
+ for (List> row : cursor) {
+ System.out.println(row.get(0));
+ }
+ }
+
+ private static void customInitialization() {
+
+ IgniteConfiguration configuration = new IgniteConfiguration();
+ configuration.setLifecycleBeans(new CustomLifecycleBean());
+ Ignite ignite = Ignition.start(configuration);
+ }
+
+}
diff --git a/libraries-data/src/main/java/com/baeldung/ignite/jdbc/IgniteJDBC.java b/libraries-data/src/main/java/com/baeldung/ignite/jdbc/IgniteJDBC.java
new file mode 100644
index 0000000000..de144711b3
--- /dev/null
+++ b/libraries-data/src/main/java/com/baeldung/ignite/jdbc/IgniteJDBC.java
@@ -0,0 +1,58 @@
+package com.baeldung.ignite.jdbc;
+
+import java.sql.*;
+
+/**
+ * Created by Gebruiker on 3/14/2018.
+ */
+public class IgniteJDBC {
+
+ public static void main(String[] args) throws ClassNotFoundException, SQLException {
+
+ Class.forName("org.apache.ignite.IgniteJdbcThinDriver");
+
+ Connection conn = DriverManager.getConnection("jdbc:ignite:thin://127.0.0.1/");
+
+ createDatabaseTables(conn);
+
+ insertData(conn);
+
+ getData(conn);
+ }
+
+ private static void createDatabaseTables(Connection conn) throws SQLException {
+
+ Statement sql = conn.createStatement();
+ sql.executeUpdate("CREATE TABLE Employee (" +
+ " id INTEGER PRIMARY KEY, name VARCHAR, isEmployed timyint(1)) " +
+ " WITH \"template=replicated\"");
+
+ sql.executeUpdate("CREATE INDEX idx_employee_name ON Employee (name)");
+ }
+
+ private static void insertData(Connection conn) throws SQLException {
+
+ PreparedStatement sql =
+ conn.prepareStatement("INSERT INTO Employee (id, name, isEmployed) VALUES (?, ?, ?)");
+ sql.setLong(1, 1);
+ sql.setString(2, "James");
+ sql.setBoolean(3, true);
+ sql.executeUpdate();
+
+ sql.setLong(1, 2);
+ sql.setString(2, "Monica");
+ sql.setBoolean(3, false);
+ sql.executeUpdate();
+ }
+
+ private static void getData(Connection conn) throws SQLException {
+
+ Statement sql = conn.createStatement();
+ ResultSet rs = sql.executeQuery("SELECT e.name, e.isEmployed " +
+ " FROM Employee e " +
+ " WHERE e.isEmployed = TRUE ");
+
+ while (rs.next())
+ System.out.println(rs.getString(1) + ", " + rs.getString(2));
+ }
+}
diff --git a/libraries-data/src/main/java/com/baeldung/ignite/model/Employee.java b/libraries-data/src/main/java/com/baeldung/ignite/model/Employee.java
new file mode 100644
index 0000000000..21f5ef89d0
--- /dev/null
+++ b/libraries-data/src/main/java/com/baeldung/ignite/model/Employee.java
@@ -0,0 +1,48 @@
+package com.baeldung.ignite.model;
+
+
+public class Employee {
+
+ private Integer id;
+ private String name;
+ private boolean isEmployed;
+
+ public Employee(Integer id, String name, boolean isEmployed) {
+ this.id = id;
+ this.name = name;
+ this.isEmployed = isEmployed;
+ }
+
+ 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 boolean isEmployed() {
+ return isEmployed;
+ }
+
+ public void setEmployed(boolean employed) {
+ isEmployed = employed;
+ }
+
+ @Override
+ public String toString() {
+ return "Employee{" +
+ "id=" + id +
+ ", name='" + name + '\'' +
+ ", isEmployed=" + isEmployed +
+ '}';
+ }
+}
diff --git a/libraries-data/src/main/java/com/baeldung/ignite/spring/IgniteApp.java b/libraries-data/src/main/java/com/baeldung/ignite/spring/IgniteApp.java
new file mode 100644
index 0000000000..c181cdbb3c
--- /dev/null
+++ b/libraries-data/src/main/java/com/baeldung/ignite/spring/IgniteApp.java
@@ -0,0 +1,53 @@
+package com.baeldung.ignite.spring;
+
+import com.baeldung.ignite.spring.config.SpringDataConfig;
+import com.baeldung.ignite.spring.dto.EmployeeDTO;
+import com.baeldung.ignite.spring.repository.EmployeeRepository;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+import java.util.List;
+
+/**
+ * Created by Gebruiker on 4/12/2018.
+ */
+public class IgniteApp {
+
+ public static void main (String[] args) {
+ AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
+ context.register(SpringDataConfig.class);
+ context.refresh();
+
+ EmployeeRepository repository = context.getBean(EmployeeRepository.class);
+
+ EmployeeDTO employeeDTO = new EmployeeDTO();
+ employeeDTO.setId(1);
+ employeeDTO.setName("John");
+ employeeDTO.setEmployed(true);
+
+ repository.save(employeeDTO.getId(), employeeDTO);
+
+ EmployeeDTO employee = repository.getEmployeeDTOById(employeeDTO.getId());
+ System.out.println(employee);
+ }
+
+ private void getUsingTheCache(Integer employeeId) {
+
+ Ignite ignite = Ignition.ignite();
+
+ IgniteCache cache = ignite.cache("baeldungCache");
+
+ EmployeeDTO employeeDTO = cache.get(employeeId);
+
+ System.out.println(employeeDTO);
+
+ SqlFieldsQuery sql = new SqlFieldsQuery(
+ "select * from EmployeeDTO where isEmployed = 'true'");
+
+ QueryCursor> cursor = cache.query(sql);
+ }
+}
diff --git a/libraries-data/src/main/java/com/baeldung/ignite/spring/config/SpringDataConfig.java b/libraries-data/src/main/java/com/baeldung/ignite/spring/config/SpringDataConfig.java
new file mode 100644
index 0000000000..7627c91bc6
--- /dev/null
+++ b/libraries-data/src/main/java/com/baeldung/ignite/spring/config/SpringDataConfig.java
@@ -0,0 +1,29 @@
+package com.baeldung.ignite.spring.config;
+
+import com.baeldung.ignite.spring.dto.EmployeeDTO;
+import com.baeldung.ignite.spring.repository.EmployeeRepository;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.springdata.repository.config.EnableIgniteRepositories;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@EnableIgniteRepositories(basePackageClasses = EmployeeRepository.class)
+@ComponentScan(basePackages = "com.baeldung.ignite.spring.repository")
+public class SpringDataConfig {
+
+ @Bean
+ public Ignite igniteInstance() {
+ IgniteConfiguration config = new IgniteConfiguration();
+
+ CacheConfiguration cache = new CacheConfiguration("baeldungCache");
+
+ cache.setIndexedTypes(Integer.class, EmployeeDTO.class);
+ config.setCacheConfiguration(cache);
+ return Ignition.start(config);
+ }
+}
diff --git a/libraries-data/src/main/java/com/baeldung/ignite/spring/dto/EmployeeDTO.java b/libraries-data/src/main/java/com/baeldung/ignite/spring/dto/EmployeeDTO.java
new file mode 100644
index 0000000000..5dbf860fe7
--- /dev/null
+++ b/libraries-data/src/main/java/com/baeldung/ignite/spring/dto/EmployeeDTO.java
@@ -0,0 +1,48 @@
+package com.baeldung.ignite.spring.dto;
+
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+
+import java.io.Serializable;
+
+public class EmployeeDTO implements Serializable {
+
+ @QuerySqlField(index = true)
+ private Integer id;
+ @QuerySqlField(index = true)
+ private String name;
+ @QuerySqlField(index = true)
+ private boolean isEmployed;
+
+ 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 boolean isEmployed() {
+ return isEmployed;
+ }
+
+ public void setEmployed(boolean employed) {
+ isEmployed = employed;
+ }
+
+ @Override
+ public String toString() {
+ return "EmployeeDTO{" +
+ "id=" + id +
+ ", name='" + name + '\'' +
+ ", isEmployed=" + isEmployed +
+ '}';
+ }
+}
diff --git a/libraries-data/src/main/java/com/baeldung/ignite/spring/repository/EmployeeRepository.java b/libraries-data/src/main/java/com/baeldung/ignite/spring/repository/EmployeeRepository.java
new file mode 100644
index 0000000000..cdcd23a58a
--- /dev/null
+++ b/libraries-data/src/main/java/com/baeldung/ignite/spring/repository/EmployeeRepository.java
@@ -0,0 +1,13 @@
+package com.baeldung.ignite.spring.repository;
+
+import com.baeldung.ignite.spring.dto.EmployeeDTO;
+import org.apache.ignite.springdata.repository.IgniteRepository;
+import org.apache.ignite.springdata.repository.config.RepositoryConfig;
+import org.springframework.stereotype.Repository;
+
+@Repository
+@RepositoryConfig(cacheName = "baeldungCache")
+public interface EmployeeRepository extends IgniteRepository {
+
+ EmployeeDTO getEmployeeDTOById(Integer id);
+}
diff --git a/libraries-data/src/main/java/com/baeldung/ignite/stream/CacheConfig.java b/libraries-data/src/main/java/com/baeldung/ignite/stream/CacheConfig.java
new file mode 100644
index 0000000000..2b0f71e0b9
--- /dev/null
+++ b/libraries-data/src/main/java/com/baeldung/ignite/stream/CacheConfig.java
@@ -0,0 +1,24 @@
+package com.baeldung.ignite.stream;
+
+import com.baeldung.ignite.model.Employee;
+import org.apache.ignite.configuration.CacheConfiguration;
+
+import javax.cache.configuration.FactoryBuilder;
+import javax.cache.expiry.CreatedExpiryPolicy;
+import javax.cache.expiry.Duration;
+import java.util.concurrent.TimeUnit;
+
+
+public class CacheConfig {
+
+ public static CacheConfiguration employeeCache() {
+
+ CacheConfiguration config = new CacheConfiguration<>("baeldungEmployees");
+
+ config.setIndexedTypes(Integer.class, Employee.class);
+ config.setExpiryPolicyFactory(FactoryBuilder.factoryOf(
+ new CreatedExpiryPolicy(new Duration(TimeUnit.SECONDS, 5))));
+
+ return config;
+ }
+}
\ No newline at end of file
diff --git a/libraries-data/src/main/java/com/baeldung/ignite/stream/IgniteStream.java b/libraries-data/src/main/java/com/baeldung/ignite/stream/IgniteStream.java
new file mode 100644
index 0000000000..839da36c22
--- /dev/null
+++ b/libraries-data/src/main/java/com/baeldung/ignite/stream/IgniteStream.java
@@ -0,0 +1,44 @@
+package com.baeldung.ignite.stream;
+
+import com.baeldung.ignite.model.Employee;
+import com.google.gson.Gson;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.stream.StreamTransformer;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class IgniteStream {
+
+ public static void main(String[] args) throws Exception {
+
+ Ignition.setClientMode(true);
+ Ignite ignite = Ignition.start();
+
+ IgniteCache cache = ignite.getOrCreateCache(CacheConfig.employeeCache());
+ IgniteDataStreamer streamer = ignite.dataStreamer(cache.getName());
+ streamer.allowOverwrite(true);
+
+ streamer.receiver(StreamTransformer.from((e, arg) -> {
+
+ Employee employee = e.getValue();
+ employee.setEmployed(true);
+ e.setValue(employee);
+
+ return null;
+ }));
+
+ Path path = Paths.get(IgniteStream.class.getResource("employees.txt").toURI());
+
+ Files.lines(path)
+ .forEach(line -> {
+ Employee employee = new Gson().fromJson(line, Employee.class);
+ streamer.addData(employee.getId(), employee);
+ });
+
+ }
+}
diff --git a/libraries-data/src/main/resources/employee.txt b/libraries-data/src/main/resources/employee.txt
new file mode 100644
index 0000000000..6c476f39fa
--- /dev/null
+++ b/libraries-data/src/main/resources/employee.txt
@@ -0,0 +1,3 @@
+{id:"1", name="John", isEmployed: "true"}
+{id:"1", name="Anna", isEmployed: "false"}
+{id:"1", name="George", isEmployed: "true"}
\ No newline at end of file
diff --git a/libraries/README.md b/libraries/README.md
index fbb6da3a31..1bb3799075 100644
--- a/libraries/README.md
+++ b/libraries/README.md
@@ -59,11 +59,21 @@
- [Intro to JDO Queries 2/2](http://www.baeldung.com/jdo-queries)
- [Guide to google-http-client](http://www.baeldung.com/google-http-client)
- [Interact with Google Sheets from Java](http://www.baeldung.com/google-sheets-java-client)
-- [Programatically Create, Configure, and Run a Tomcat Server] (http://www.baeldung.com/tomcat-programmatic-setup)
+- [Programatically Create, Configure, and Run a Tomcat Server](http://www.baeldung.com/tomcat-programmatic-setup)
- [A Docker Guide for Java](http://www.baeldung.com/docker-java-api)
- [Exceptions in Netty](http://www.baeldung.com/netty-exception-handling)
- [Creating and Configuring Jetty 9 Server in Java](http://www.baeldung.com/jetty-java-programmatic)
-- [Introduction to Akka Actors in Java] (http://www.baeldung.com/akka-actors-java)
+- [Introduction To OpenCSV](http://www.baeldung.com/opencsv)
+- [Introduction to Akka Actors in Java](http://www.baeldung.com/akka-actors-java)
+- [Asynchronous HTTP with async-http-client in Java](https://github.com/eugenp/tutorials/tree/master/libraries)
+- [Introduction to Smooks](http://www.baeldung.com/smooks)
+- [WebSockets with AsyncHttpClient](http://www.baeldung.com/async-http-client-websockets)
+- [A Guide to Infinispan in Java](http://www.baeldung.com/infinispan)
+- [Introduction to OpenCSV](http://www.baeldung.com/opencsv)
+- [A Guide to Unirest](http://www.baeldung.com/unirest)
+- [Introduction to Akka Actors in Java](http://www.baeldung.com/akka-actors-java)
+- [A Guide to Apache Commons Collections CollectionUtils](http://www.baeldung.com/apache-commons-collection-utils)
+- [A Guide to Byte Buddy](http://www.baeldung.com/byte-buddy)
The libraries module contains examples related to small libraries that are relatively easy to use and does not require any separate module of its own.
diff --git a/libraries/pom.xml b/libraries/pom.xml
index 3a43c12c41..f4bf994a58 100644
--- a/libraries/pom.xml
+++ b/libraries/pom.xml
@@ -11,20 +11,20 @@
-
+
com.typesafe.akka
akka-actor_2.12
- 2.5.11
+ ${typesafe-akka.version}
com.typesafe.akka
akka-testkit_2.12
- 2.5.11
+ ${typesafe-akka.version}
test
-
+
org.asynchttpclient
@@ -43,6 +43,12 @@
cglib
${cglib.version}
+
+
+ com.opencsv
+ opencsv
+ ${opencsv.version}
+
commons-beanutils
commons-beanutils
@@ -668,7 +674,7 @@
milyn-smooks-all
${smooks.version}
-
+
com.mashape.unirest
unirest-java
${unirest.version}
@@ -680,8 +686,14 @@
fugue
4.5.1
+
+
+ org.jctools
+ jctools-core
+ ${jctools.version}
+
-
+
maven2-repository.dev.java.net
@@ -720,7 +732,7 @@
maven-failsafe-plugin
- 2.20
+ ${maven-failsafe-plugin.version}
chromedriver
@@ -780,14 +792,41 @@
-
+
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.2
+
+
+ package
+
+ shade
+
+
+ benchmarks
+
+
+ org.openjdk.jmh.Main
+
+
+
+
+
+ *:*
+
+ META-INF/*.SF
+ META-INF/*.DSA
+ META-INF/*.RSA
+
+
+
+
+
+
@@ -858,9 +897,13 @@
8.5.24
2.2.0
9.1.5.Final
+ 4.1
1.4.9
+ 2.1.2
1.10.L001
0.9.4.0006L
+ 2.1.2
+ 2.5.11
-
+
\ No newline at end of file
diff --git a/libraries/src/main/java/com/baeldung/jctools/MpmcBenchmark.java b/libraries/src/main/java/com/baeldung/jctools/MpmcBenchmark.java
new file mode 100644
index 0000000000..7b754bf709
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/jctools/MpmcBenchmark.java
@@ -0,0 +1,73 @@
+package com.baeldung.jctools;
+
+import org.jctools.queues.MpmcArrayQueue;
+import org.jctools.queues.atomic.MpmcAtomicArrayQueue;
+import org.openjdk.jmh.annotations.*;
+import org.openjdk.jmh.infra.Control;
+
+import java.util.Queue;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+@BenchmarkMode(Mode.SampleTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Fork(1)
+@Warmup(iterations = 1)
+@Measurement(iterations = 3)
+@State(Scope.Group)
+public class MpmcBenchmark {
+
+ public static final String PARAM_UNSAFE = "MpmcArrayQueue";
+ public static final String PARAM_AFU = "MpmcAtomicArrayQueue";
+ public static final String PARAM_JDK = "ArrayBlockingQueue";
+
+ public static final int PRODUCER_THREADS_NUMBER = 32;
+ public static final int CONSUMER_THREADS_NUMBER = 32;
+
+ public static final String GROUP_NAME = "MyGroup";
+
+ public static final int CAPACITY = 128;
+
+ @Param({PARAM_UNSAFE, PARAM_AFU, PARAM_JDK})
+ public volatile String implementation;
+
+ public volatile Queue queue;
+
+ @Setup(Level.Trial)
+ public void setUp() {
+ switch (implementation) {
+ case PARAM_UNSAFE:
+ queue = new MpmcArrayQueue<>(CAPACITY);
+ break;
+ case PARAM_AFU:
+ queue = new MpmcAtomicArrayQueue<>(CAPACITY);
+ break;
+ case PARAM_JDK:
+ queue = new ArrayBlockingQueue<>(CAPACITY);
+ break;
+ default:
+ throw new UnsupportedOperationException("Unsupported implementation " + implementation);
+ }
+ }
+
+
+ @Benchmark
+ @Group(GROUP_NAME)
+ @GroupThreads(PRODUCER_THREADS_NUMBER)
+ public void write(Control control) {
+ //noinspection StatementWithEmptyBody
+ while (!control.stopMeasurement && !queue.offer(1L)) {
+ // Is intentionally left blank
+ }
+ }
+
+ @Benchmark
+ @Group(GROUP_NAME)
+ @GroupThreads(CONSUMER_THREADS_NUMBER)
+ public void read(Control control) {
+ //noinspection StatementWithEmptyBody
+ while (!control.stopMeasurement && queue.poll() == null) {
+ // Is intentionally left blank
+ }
+ }
+}
diff --git a/libraries/src/main/java/com/baeldung/jctools/README.md b/libraries/src/main/java/com/baeldung/jctools/README.md
new file mode 100644
index 0000000000..3c1b3c1c1e
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/jctools/README.md
@@ -0,0 +1,7 @@
+## How to build and run the JMH benchmark
+
+Execute the following from the project's root:
+```bash
+mvn clean install
+java -jar ./target/benchmarks.jar MpmcBenchmark -si true
+```
\ No newline at end of file
diff --git a/libraries/src/main/java/com/baeldung/jnats/NatsClient.java b/libraries/src/main/java/com/baeldung/jnats/NatsClient.java
index cdd1e764ef..c592727cd1 100644
--- a/libraries/src/main/java/com/baeldung/jnats/NatsClient.java
+++ b/libraries/src/main/java/com/baeldung/jnats/NatsClient.java
@@ -1,31 +1,35 @@
package com.baeldung.jnats;
-import io.nats.client.*;
-
-import java.io.IOException;
-import java.util.*;
-
+import io.nats.client.AsyncSubscription;
+import io.nats.client.Connection;
+import io.nats.client.Message;
+import io.nats.client.Nats;
+import io.nats.client.Options;
+import io.nats.client.Subscription;
+import io.nats.client.SyncSubscription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class NatsClient {
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
- private String serverURI;
+public final class NatsClient {
- private Connection natsConnection;
+ private final String serverURI;
- private Map subscriptions = new HashMap<>();
+ private final Connection natsConnection;
+
+ private final Map subscriptions = new HashMap<>();
private final static Logger log = LoggerFactory.getLogger(NatsClient.class);
- public NatsClient() {
+ NatsClient() {
this.serverURI = "jnats://localhost:4222";
natsConnection = initConnection(serverURI);
}
-
public NatsClient(String serverURI) {
-
if ((serverURI != null) && (!serverURI.isEmpty())) {
this.serverURI = serverURI;
} else {
@@ -40,59 +44,33 @@ public class NatsClient {
natsConnection.close();
}
-
private Connection initConnection(String uri) {
try {
-
Options options = new Options.Builder()
- .errorCb(new ExceptionHandler() {
- @Override
- public void onException(NATSException ex) {
- log.error("Connection Exception: ", ex);
- }
- })
- .disconnectedCb(new DisconnectedCallback() {
- @Override
- public void onDisconnect(ConnectionEvent event) {
- log.error("Channel disconnected: {}", event.getConnection());
- }
- })
- .reconnectedCb(new ReconnectedCallback() {
- @Override
- public void onReconnect(ConnectionEvent event) {
- log.error("Reconnected to server: {}", event.getConnection());
- }
- })
+ .errorCb(ex -> log.error("Connection Exception: ", ex))
+ .disconnectedCb(event -> log.error("Channel disconnected: {}", event.getConnection()))
+ .reconnectedCb(event -> log.error("Reconnected to server: {}", event.getConnection()))
.build();
return Nats.connect(uri, options);
-
} catch (IOException ioe) {
log.error("Error connecting to NATs! ", ioe);
return null;
}
}
-
- public void publishMessage(String topic, String replyTo, String message) {
+ void publishMessage(String topic, String replyTo, String message) {
try {
- // Simple Publisher
natsConnection.publish(topic, replyTo, message.getBytes());
} catch (IOException ioe) {
log.error("Error publishing message: {} to {} ", message, topic, ioe);
}
}
-
public void subscribeAsync(String topic) {
- // Simple Async Subscriber
- AsyncSubscription subscription = natsConnection.subscribe(topic, new MessageHandler() {
- @Override
- public void onMessage(Message msg) {
- log.info("Received message on {}", msg.getSubject());
- }
- });
+ AsyncSubscription subscription = natsConnection.subscribe(
+ topic, msg -> log.info("Received message on {}", msg.getSubject()));
if (subscription == null) {
log.error("Error subscribing to {}", topic);
@@ -101,13 +79,11 @@ public class NatsClient {
}
}
- public SyncSubscription subscribeSync(String topic) {
- // Simple Sync Subscriber
+ SyncSubscription subscribeSync(String topic) {
return natsConnection.subscribe(topic);
}
public void unsubscribe(String topic) {
-
try {
Subscription subscription = subscriptions.get(topic);
@@ -116,15 +92,12 @@ public class NatsClient {
} else {
log.error("{} not found. Unable to unsubscribe.", topic);
}
-
} catch (IOException ioe) {
log.error("Error unsubscribing from {} ", topic, ioe);
}
}
-
- public Message makeRequest(String topic, String request) {
-
+ Message makeRequest(String topic, String request) {
try {
return natsConnection.request(topic, request.getBytes(), 100);
} catch (IOException | InterruptedException ioe) {
@@ -133,7 +106,7 @@ public class NatsClient {
}
}
- public void installReply(String topic, String reply) {
+ void installReply(String topic, String reply) {
natsConnection.subscribe(topic, message -> {
try {
natsConnection.publish(message.getReplyTo(), reply.getBytes());
@@ -143,8 +116,7 @@ public class NatsClient {
});
}
- public SyncSubscription joinQueueGroup(String topic, String queue) {
+ SyncSubscription joinQueueGroup(String topic, String queue) {
return natsConnection.subscribe(topic, queue);
}
-
}
diff --git a/libraries/src/main/java/com/baeldung/netty/CalculatorOperationHandler.java b/libraries/src/main/java/com/baeldung/netty/CalculatorOperationHandler.java
new file mode 100644
index 0000000000..4d4cba259b
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/netty/CalculatorOperationHandler.java
@@ -0,0 +1,49 @@
+package com.baeldung.netty;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+import io.netty.handler.codec.http.*;
+import io.netty.util.CharsetUtil;
+
+public class CalculatorOperationHandler extends SimpleChannelInboundHandler {
+
+ protected void channelRead0(ChannelHandlerContext ctx, Operation msg) throws Exception {
+ Long result = calculateEndpoint(msg);
+ sendHttpResponse(ctx, new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.CREATED), result.toString());
+ ctx.fireChannelRead(result);
+ }
+
+ private long calculateEndpoint(Operation operation) {
+
+ String operator = operation.getOperator().toLowerCase().trim();
+ switch (operator) {
+ case "add":
+ return operation.getNumber1() + operation.getNumber2();
+ case "multiply":
+ return operation.getNumber1() * operation.getNumber2();
+ default:
+ throw new IllegalArgumentException("Operation not defined");
+ }
+ }
+
+ public static void sendHttpResponse(ChannelHandlerContext ctx, FullHttpResponse res, String content) {
+
+ // Generate an error page if response getStatus code is not OK (200).
+ ByteBuf buf = Unpooled.copiedBuffer(content, CharsetUtil.UTF_8);
+ res.content().writeBytes(buf);
+
+ HttpUtil.setContentLength(res, res.content().readableBytes());
+
+ ctx.channel().writeAndFlush(res);
+ }
+
+ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
+ throws Exception {
+
+ sendHttpResponse(ctx, new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.INTERNAL_SERVER_ERROR), "Operation not defined");
+ ctx.fireExceptionCaught(cause);
+ }
+
+}
diff --git a/libraries/src/main/java/com/baeldung/netty/HttpMessageHandler.java b/libraries/src/main/java/com/baeldung/netty/HttpMessageHandler.java
new file mode 100644
index 0000000000..58a81432b6
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/netty/HttpMessageHandler.java
@@ -0,0 +1,40 @@
+package com.baeldung.netty;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+import io.netty.handler.codec.http.FullHttpRequest;
+import io.netty.handler.codec.http.HttpHeaders;
+import io.netty.handler.codec.http.HttpMethod;
+
+public class HttpMessageHandler extends SimpleChannelInboundHandler {
+
+ protected void channelRead0(ChannelHandlerContext ctx, FullHttpRequest msg) throws Exception {
+
+ String uri = msg.uri();
+ HttpMethod httpMethod = msg.method();
+ HttpHeaders headers = msg.headers();
+
+ if (HttpMethod.GET == httpMethod) {
+
+ String[] uriComponents = uri.split("[?]");
+ String endpoint = uriComponents[0];
+ String[] queryParams = uriComponents[1].split("&");
+
+ if ("/calculate".equalsIgnoreCase(endpoint)) {
+
+ String[] firstQueryParam = queryParams[0].split("=");
+ String[] secondQueryParam = queryParams[1].split("=");
+
+ Integer a = Integer.valueOf(firstQueryParam[1]);
+ Integer b = Integer.valueOf(secondQueryParam[1]);
+ String operator = headers.get("operator");
+
+ Operation operation = new Operation(a, b, operator);
+ ctx.fireChannelRead(operation);
+ }
+ } else {
+ throw new UnsupportedOperationException("HTTP method not supported");
+ }
+
+ }
+}
diff --git a/libraries/src/main/java/com/baeldung/netty/Operation.java b/libraries/src/main/java/com/baeldung/netty/Operation.java
new file mode 100644
index 0000000000..136316ed7c
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/netty/Operation.java
@@ -0,0 +1,49 @@
+package com.baeldung.netty;
+
+import java.io.Serializable;
+
+public class Operation implements Serializable {
+
+ private Integer number1;
+ private Integer number2;
+ private String operator;
+
+ public Operation(Integer number1, Integer number2, String operator) {
+ this.number1 = number1;
+ this.number2 = number2;
+ this.operator = operator;
+ }
+
+ public Integer getNumber1() {
+ return number1;
+ }
+
+ public void setNumber1(Integer number1) {
+ this.number1 = number1;
+ }
+
+ public Integer getNumber2() {
+ return number2;
+ }
+
+ public void setNumber2(Integer number2) {
+ this.number2 = number2;
+ }
+
+ public String getOperator() {
+ return operator;
+ }
+
+ public void setOperator(String operator) {
+ this.operator = operator;
+ }
+
+ @Override
+ public String toString() {
+ return "Operation{" +
+ "number1=" + number1 +
+ ", number2=" + number2 +
+ ", operator='" + operator + '\'' +
+ '}';
+ }
+}
diff --git a/libraries/src/main/java/com/baeldung/opencsv/Application.java b/libraries/src/main/java/com/baeldung/opencsv/Application.java
new file mode 100644
index 0000000000..fd7e4d82d4
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/opencsv/Application.java
@@ -0,0 +1,108 @@
+package com.baeldung.opencsv;
+
+import com.baeldung.opencsv.beans.NamedColumnBean;
+import com.baeldung.opencsv.beans.SimplePositionBean;
+import com.baeldung.opencsv.examples.sync.BeanExamples;
+import com.baeldung.opencsv.examples.sync.CsvReaderExamples;
+import com.baeldung.opencsv.examples.sync.CsvWriterExamples;
+import com.baeldung.opencsv.helpers.Helpers;
+
+import java.io.Reader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+public class Application {
+
+ /*
+ * Bean Examples.
+ */
+
+ public static String simpleSyncPositionBeanExample() {
+ Path path = null;
+ try {
+ path = Helpers.twoColumnCsvPath();
+ } catch (Exception ex) {
+ Helpers.err(ex);
+ }
+ return BeanExamples.beanBuilderExample(path, SimplePositionBean.class).toString();
+ }
+
+ public static String namedSyncColumnBeanExample() {
+ Path path = null;
+ try {
+ path = Helpers.namedColumnCsvPath();
+ } catch (Exception ex) {
+ Helpers.err(ex);
+ }
+ return BeanExamples.beanBuilderExample(path, NamedColumnBean.class).toString();
+ }
+
+ public static String writeSyncCsvFromBeanExample() {
+ Path path = null;
+ try {
+ path = Helpers.fileOutBeanPath();
+ } catch (Exception ex) {
+ Helpers.err(ex);
+ }
+ return BeanExamples.writeCsvFromBean(path);
+ }
+
+ /*
+ * CSV Reader Examples.
+ */
+
+ public static String oneByOneSyncExample() {
+ Reader reader = null;
+ try {
+ reader = Files.newBufferedReader(Helpers.twoColumnCsvPath());
+ } catch (Exception ex) {
+ Helpers.err(ex);
+ }
+ return CsvReaderExamples.oneByOne(reader).toString();
+ }
+
+ public static String readAllSyncExample() {
+ Reader reader = null;
+ try {
+ reader = Files.newBufferedReader(Helpers.twoColumnCsvPath());
+ } catch (Exception ex) {
+ Helpers.err(ex);
+ }
+ return CsvReaderExamples.readAll(reader).toString();
+ }
+
+ /*
+ * CSV Writer Examples.
+ */
+
+
+ public static String csvWriterSyncOneByOne() {
+ Path path = null;
+ try {
+ path = Helpers.fileOutOnePath();
+ } catch (Exception ex) {
+ Helpers.err(ex);
+ }
+ return CsvWriterExamples.csvWriterOneByOne(Helpers.fourColumnCsvString(), path);
+ }
+
+ public static String csvWriterSyncAll() {
+ Path path = null;
+ try {
+ path = Helpers.fileOutAllPath();
+ } catch (Exception ex) {
+ Helpers.err(ex);
+ }
+ return CsvWriterExamples.csvWriterAll(Helpers.fourColumnCsvString(), path);
+ }
+
+ public static void main(String[] args) {
+ simpleSyncPositionBeanExample();
+ namedSyncColumnBeanExample();
+ writeSyncCsvFromBeanExample();
+ oneByOneSyncExample();
+ readAllSyncExample();
+ csvWriterSyncOneByOne();
+ csvWriterSyncAll();
+ }
+}
diff --git a/libraries/src/main/java/com/baeldung/opencsv/Constants.java b/libraries/src/main/java/com/baeldung/opencsv/Constants.java
new file mode 100644
index 0000000000..f7978acf24
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/opencsv/Constants.java
@@ -0,0 +1,17 @@
+package com.baeldung.opencsv;
+
+public class Constants {
+
+ public static final String GENERIC_EXCEPTION = "EXCEPTION ENCOUNTERED: ";
+ public static final String GENERIC_SUCCESS = "SUCCESS";
+
+ public static final String TWO_COLUMN_CSV = "csv/twoColumn.csv";
+ public static final String FOUR_COLUMN_CSV = "csv/fourColumn.csv";
+ public static final String NAMED_COLUMN_CSV = "csv/namedColumn.csv";
+
+ public static final String CSV_All = "csv/writtenAll.csv";
+ public static final String CSV_BEAN = "csv/writtenBean.csv";
+ public static final String CSV_ONE = "csv/writtenOneByOne.csv";
+
+
+}
diff --git a/libraries/src/main/java/com/baeldung/opencsv/beans/CsvBean.java b/libraries/src/main/java/com/baeldung/opencsv/beans/CsvBean.java
new file mode 100644
index 0000000000..af9caaae12
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/opencsv/beans/CsvBean.java
@@ -0,0 +1,3 @@
+package com.baeldung.opencsv.beans;
+
+public class CsvBean { }
diff --git a/libraries/src/main/java/com/baeldung/opencsv/beans/NamedColumnBean.java b/libraries/src/main/java/com/baeldung/opencsv/beans/NamedColumnBean.java
new file mode 100644
index 0000000000..d9e5f96333
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/opencsv/beans/NamedColumnBean.java
@@ -0,0 +1,31 @@
+package com.baeldung.opencsv.beans;
+
+import com.opencsv.bean.CsvBindByName;
+
+public class NamedColumnBean extends CsvBean {
+
+ @CsvBindByName(column = "name")
+ private String name;
+
+ //Automatically infer column name as Age
+ @CsvBindByName
+ private int age;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+
+}
diff --git a/libraries/src/main/java/com/baeldung/opencsv/beans/SimplePositionBean.java b/libraries/src/main/java/com/baeldung/opencsv/beans/SimplePositionBean.java
new file mode 100644
index 0000000000..799006e2f9
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/opencsv/beans/SimplePositionBean.java
@@ -0,0 +1,29 @@
+package com.baeldung.opencsv.beans;
+
+import com.opencsv.bean.CsvBindByPosition;
+
+public class SimplePositionBean extends CsvBean {
+
+ @CsvBindByPosition(position = 0)
+ private String exampleColOne;
+
+ @CsvBindByPosition(position = 1)
+ private String exampleColTwo;
+
+ public String getExampleColOne() {
+ return exampleColOne;
+ }
+
+ private void setExampleColOne(String exampleColOne) {
+ this.exampleColOne = exampleColOne;
+ }
+
+ public String getExampleColTwo() {
+ return exampleColTwo;
+ }
+
+ private void setExampleCsvTwo (String exampleColTwo) {
+ this.exampleColTwo = exampleColTwo;
+ }
+
+}
diff --git a/libraries/src/main/java/com/baeldung/opencsv/beans/WriteExampleBean.java b/libraries/src/main/java/com/baeldung/opencsv/beans/WriteExampleBean.java
new file mode 100644
index 0000000000..f145f67f11
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/opencsv/beans/WriteExampleBean.java
@@ -0,0 +1,40 @@
+package com.baeldung.opencsv.beans;
+
+public class WriteExampleBean extends CsvBean {
+
+ private String colA;
+
+ private String colB;
+
+ private String colC;
+
+ public WriteExampleBean(String colA, String colB, String colC) {
+ this.colA = colA;
+ this.colB = colB;
+ this.colC = colC;
+ }
+
+ public String getColA() {
+ return colA;
+ }
+
+ public void setColA(String colA) {
+ this.colA = colA;
+ }
+
+ public String getColB() {
+ return colB;
+ }
+
+ public void setColB(String colB) {
+ this.colB = colB;
+ }
+
+ public String getColC() {
+ return colC;
+ }
+
+ public void setColC(String colC) {
+ this.colC = colC;
+ }
+}
diff --git a/libraries/src/main/java/com/baeldung/opencsv/examples/sync/BeanExamples.java b/libraries/src/main/java/com/baeldung/opencsv/examples/sync/BeanExamples.java
new file mode 100644
index 0000000000..76d044ca60
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/opencsv/examples/sync/BeanExamples.java
@@ -0,0 +1,61 @@
+package com.baeldung.opencsv.examples.sync;
+
+import com.baeldung.opencsv.beans.CsvBean;
+import com.baeldung.opencsv.beans.WriteExampleBean;
+import com.baeldung.opencsv.helpers.Helpers;
+import com.baeldung.opencsv.pojos.CsvTransfer;
+import com.opencsv.CSVWriter;
+import com.opencsv.bean.*;
+
+import java.io.FileWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+
+public class BeanExamples {
+
+ public static List beanBuilderExample(Path path, Class clazz) {
+ CsvTransfer csvTransfer = new CsvTransfer();
+ try {
+ ColumnPositionMappingStrategy ms = new ColumnPositionMappingStrategy();
+ ms.setType(clazz);
+
+ Reader reader = Files.newBufferedReader(path);
+ CsvToBean cb = new CsvToBeanBuilder(reader)
+ .withType(clazz)
+ .withMappingStrategy(ms)
+ .build();
+
+ csvTransfer.setCsvList(cb.parse());
+ reader.close();
+
+ } catch (Exception ex) {
+ Helpers.err(ex);
+ }
+ return csvTransfer.getCsvList();
+ }
+
+ public static String writeCsvFromBean(Path path) {
+ try {
+ Writer writer = new FileWriter(path.toString());
+
+ StatefulBeanToCsv sbc = new StatefulBeanToCsvBuilder(writer)
+ .withSeparator(CSVWriter.DEFAULT_SEPARATOR)
+ .build();
+
+ List list = new ArrayList<>();
+ list.add(new WriteExampleBean("Test1", "sfdsf", "fdfd"));
+ list.add(new WriteExampleBean("Test2", "ipso", "facto"));
+
+ sbc.write(list);
+ writer.close();
+
+ } catch (Exception ex) {
+ Helpers.err(ex);
+ }
+ return Helpers.readFile(path);
+ }
+}
\ No newline at end of file
diff --git a/libraries/src/main/java/com/baeldung/opencsv/examples/sync/CsvReaderExamples.java b/libraries/src/main/java/com/baeldung/opencsv/examples/sync/CsvReaderExamples.java
new file mode 100644
index 0000000000..bacfdcff3d
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/opencsv/examples/sync/CsvReaderExamples.java
@@ -0,0 +1,63 @@
+package com.baeldung.opencsv.examples.sync;
+
+import com.baeldung.opencsv.helpers.Helpers;
+import com.opencsv.CSVParser;
+import com.opencsv.CSVParserBuilder;
+import com.opencsv.CSVReader;
+import com.opencsv.CSVReaderBuilder;
+
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+
+public class CsvReaderExamples {
+
+ public static List readAll(Reader reader) {
+
+ CSVParser parser = new CSVParserBuilder()
+ .withSeparator(',')
+ .withIgnoreQuotations(true)
+ .build();
+
+ CSVReader csvReader = new CSVReaderBuilder(reader)
+ .withSkipLines(0)
+ .withCSVParser(parser)
+ .build();
+
+ List list = new ArrayList<>();
+ try {
+ list = csvReader.readAll();
+ reader.close();
+ csvReader.close();
+ } catch (Exception ex) {
+ Helpers.err(ex);
+ }
+ return list;
+ }
+
+ public static List oneByOne(Reader reader) {
+ List list = new ArrayList<>();
+ try {
+ CSVParser parser = new CSVParserBuilder()
+ .withSeparator(',')
+ .withIgnoreQuotations(true)
+ .build();
+
+ CSVReader csvReader = new CSVReaderBuilder(reader)
+ .withSkipLines(0)
+ .withCSVParser(parser)
+ .build();
+
+ String[] line;
+ while ((line = csvReader.readNext()) != null) {
+ list.add(line);
+ }
+ reader.close();
+ csvReader.close();
+ } catch (Exception ex) {
+ Helpers.err(ex);
+ }
+ return list;
+ }
+
+}
diff --git a/libraries/src/main/java/com/baeldung/opencsv/examples/sync/CsvWriterExamples.java b/libraries/src/main/java/com/baeldung/opencsv/examples/sync/CsvWriterExamples.java
new file mode 100644
index 0000000000..6f52160ba8
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/opencsv/examples/sync/CsvWriterExamples.java
@@ -0,0 +1,35 @@
+package com.baeldung.opencsv.examples.sync;
+
+import com.baeldung.opencsv.helpers.Helpers;
+import com.opencsv.CSVWriter;
+
+import java.io.FileWriter;
+import java.nio.file.Path;
+import java.util.List;
+
+public class CsvWriterExamples {
+
+ public static String csvWriterOneByOne(List stringArray, Path path) {
+ try {
+ CSVWriter writer = new CSVWriter(new FileWriter(path.toString()));
+ for (String[] array : stringArray) {
+ writer.writeNext(array);
+ }
+ writer.close();
+ } catch (Exception ex) {
+ Helpers.err(ex);
+ }
+ return Helpers.readFile(path);
+ }
+
+ public static String csvWriterAll(List stringArray, Path path) {
+ try {
+ CSVWriter writer = new CSVWriter(new FileWriter(path.toString()));
+ writer.writeAll(stringArray);
+ writer.close();
+ } catch (Exception ex) {
+ Helpers.err(ex);
+ }
+ return Helpers.readFile(path);
+ }
+}
\ No newline at end of file
diff --git a/libraries/src/main/java/com/baeldung/opencsv/helpers/Helpers.java b/libraries/src/main/java/com/baeldung/opencsv/helpers/Helpers.java
new file mode 100644
index 0000000000..9a46fbc495
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/opencsv/helpers/Helpers.java
@@ -0,0 +1,108 @@
+package com.baeldung.opencsv.helpers;
+
+import com.baeldung.opencsv.Constants;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Helpers {
+
+ /**
+ * Write Files
+ */
+
+ public static Path fileOutAllPath() throws URISyntaxException {
+ URI uri = ClassLoader.getSystemResource(Constants.CSV_All).toURI();
+ return Paths.get(uri);
+ }
+
+ public static Path fileOutBeanPath() throws URISyntaxException {
+ URI uri = ClassLoader.getSystemResource(Constants.CSV_BEAN).toURI();
+ return Paths.get(uri);
+ }
+
+ public static Path fileOutOnePath() throws URISyntaxException {
+ URI uri = ClassLoader.getSystemResource(Constants.CSV_ONE).toURI();
+ return Paths.get(uri);
+ }
+
+ /**
+ * Read Files
+ */
+
+ public static Path twoColumnCsvPath() throws URISyntaxException {
+ URI uri = ClassLoader.getSystemResource(Constants.TWO_COLUMN_CSV).toURI();
+ return Paths.get(uri);
+ }
+
+ public static Path fourColumnCsvPath() throws URISyntaxException {
+ URI uri = ClassLoader.getSystemResource(Constants.FOUR_COLUMN_CSV).toURI();
+ return Paths.get(uri);
+ }
+
+ public static Path namedColumnCsvPath() throws URISyntaxException {
+ URI uri = ClassLoader.getSystemResource(Constants.NAMED_COLUMN_CSV).toURI();
+ return Paths.get(uri);
+ }
+
+ /**
+ * Simple File Reader
+ */
+
+ public static String readFile(Path path) {
+ String response = "";
+ try {
+ FileReader fr = new FileReader(path.toString());
+ BufferedReader br = new BufferedReader(fr);
+ String strLine;
+ StringBuffer sb = new StringBuffer();
+ while ((strLine = br.readLine()) != null) {
+ sb.append(strLine);
+ }
+ response = sb.toString();
+ System.out.println(response);
+ fr.close();
+ br.close();
+ } catch (Exception ex) {
+ Helpers.err(ex);
+ }
+ return response;
+ }
+
+ /**
+ * Dummy Data for Writing.
+ */
+
+ public static List twoColumnCsvString() {
+ List list = new ArrayList<>();
+ list.add(new String[]{"ColA", "ColB"});
+ list.add(new String[]{"A", "B"});
+ return list;
+ }
+
+ public static List fourColumnCsvString() {
+ List list = new ArrayList<>();
+ list.add(new String[]{"ColA", "ColB", "ColC", "ColD"});
+ list.add(new String[]{"A", "B", "A", "B"});
+ list.add(new String[]{"BB", "AB", "AA", "B"});
+ return list;
+ }
+
+ /**
+ * Message Helpers
+ */
+
+ public static void print(String msg) {
+ System.out.println(msg);
+ }
+
+ public static void err(Exception ex) {
+ System.out.println(Constants.GENERIC_EXCEPTION + " " + ex);
+ }
+}
diff --git a/libraries/src/main/java/com/baeldung/opencsv/pojos/CsvTransfer.java b/libraries/src/main/java/com/baeldung/opencsv/pojos/CsvTransfer.java
new file mode 100644
index 0000000000..79366e3d20
--- /dev/null
+++ b/libraries/src/main/java/com/baeldung/opencsv/pojos/CsvTransfer.java
@@ -0,0 +1,38 @@
+package com.baeldung.opencsv.pojos;
+
+import com.baeldung.opencsv.beans.CsvBean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CsvTransfer {
+
+ private List csvStringList;
+
+ private List csvList;
+
+ public CsvTransfer() {}
+
+ public List getCsvStringList() {
+ if (csvStringList != null) return csvStringList;
+ return new ArrayList();
+ }
+
+ public void addLine(String[] line) {
+ if (this.csvList == null) this.csvStringList = new ArrayList<>();
+ this.csvStringList.add(line);
+ }
+
+ public void setCsvStringList(List csvStringList) {
+ this.csvStringList = csvStringList;
+ }
+
+ public void setCsvList(List csvList) {
+ this.csvList = csvList;
+ }
+
+ public List getCsvList() {
+ if (csvList != null) return csvList;
+ return new ArrayList();
+ }
+}
\ No newline at end of file
diff --git a/libraries/src/main/resources/csv/fourColumn.csv b/libraries/src/main/resources/csv/fourColumn.csv
new file mode 100644
index 0000000000..51a69fd1a0
--- /dev/null
+++ b/libraries/src/main/resources/csv/fourColumn.csv
@@ -0,0 +1,5 @@
+ColA,ColB,ColC,ColD
+A,B,B,B
+C,D,W,W
+G,G,E,E
+G,F,Q,Q
diff --git a/libraries/src/main/resources/csv/namedColumn.csv b/libraries/src/main/resources/csv/namedColumn.csv
new file mode 100644
index 0000000000..279b743600
--- /dev/null
+++ b/libraries/src/main/resources/csv/namedColumn.csv
@@ -0,0 +1,5 @@
+name,age
+adam,1000
+martin,27
+gigi,41
+seraphine,30
\ No newline at end of file
diff --git a/libraries/src/main/resources/csv/twoColumn.csv b/libraries/src/main/resources/csv/twoColumn.csv
new file mode 100644
index 0000000000..3eab8e8a64
--- /dev/null
+++ b/libraries/src/main/resources/csv/twoColumn.csv
@@ -0,0 +1,5 @@
+ColA,ColB
+A,B
+C,D
+G,G
+G,F
diff --git a/libraries/src/main/resources/csv/writtenAll.csv b/libraries/src/main/resources/csv/writtenAll.csv
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/libraries/src/main/resources/csv/writtenBean.csv b/libraries/src/main/resources/csv/writtenBean.csv
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/libraries/src/main/resources/csv/writtenOneByOne.csv b/libraries/src/main/resources/csv/writtenOneByOne.csv
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/libraries/src/test/java/com/baeldung/jctools/JCToolsUnitTest.java b/libraries/src/test/java/com/baeldung/jctools/JCToolsUnitTest.java
new file mode 100644
index 0000000000..4a9d0fadb2
--- /dev/null
+++ b/libraries/src/test/java/com/baeldung/jctools/JCToolsUnitTest.java
@@ -0,0 +1,86 @@
+package com.baeldung.jctools;
+
+import org.jctools.queues.SpscArrayQueue;
+import org.jctools.queues.SpscChunkedArrayQueue;
+import org.junit.Test;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.IntConsumer;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.fail;
+
+public class JCToolsUnitTest {
+
+ @Test
+ public void givenMultipleProducers_whenSpscQueueUsed_thenNoWarningOccurs() throws InterruptedException {
+ SpscArrayQueue queue = new SpscArrayQueue(2);
+
+ Thread producer1 = new Thread(() -> {
+ queue.offer(1);
+ });
+ producer1.start();
+ producer1.join();
+
+ Thread producer2 = new Thread(() -> {
+ queue.offer(2);
+ });
+ producer2.start();
+ producer2.join();
+
+ Set fromQueue = new HashSet<>();
+ Thread consumer = new Thread(() -> queue.drain(fromQueue::add));
+ consumer.start();
+ consumer.join();
+
+ assertThat(fromQueue).containsOnly(1, 2);
+ }
+
+ @Test
+ public void whenQueueIsFull_thenNoMoreElementsCanBeAdded() throws InterruptedException {
+ SpscChunkedArrayQueue queue = new SpscChunkedArrayQueue<>(8, 16);
+ assertThat(queue.capacity()).isEqualTo(16);
+
+ CountDownLatch startConsuming = new CountDownLatch(1);
+ CountDownLatch awakeProducer = new CountDownLatch(1);
+ AtomicReference error = new AtomicReference<>();
+ Thread producer = new Thread(() -> {
+ IntStream.range(0, queue.capacity()).forEach(i -> {
+ assertThat(queue.offer(i)).isTrue();
+ });
+ assertThat(queue.offer(queue.capacity())).isFalse();
+ startConsuming.countDown();
+ try {
+ awakeProducer.await();
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+
+ assertThat(queue.offer(queue.capacity())).isTrue();
+ });
+ producer.setUncaughtExceptionHandler((t, e) -> {
+ error.set(e);
+ startConsuming.countDown();
+ });
+ producer.start();
+
+ startConsuming.await();
+
+ if (error.get() != null) {
+ fail("Producer's assertion failed", error.get());
+ }
+
+ Set fromQueue = new HashSet<>();
+ queue.drain(fromQueue::add);
+ awakeProducer.countDown();
+ producer.join();
+ queue.drain(fromQueue::add);
+
+ assertThat(fromQueue).containsAll(IntStream.range(0, 17).boxed().collect(Collectors.toSet()));
+ }
+}
diff --git a/libraries/src/test/java/com/baeldung/jets3t/JetS3tLiveTest.java b/libraries/src/test/java/com/baeldung/jets3t/JetS3tLiveTest.java
index 3b0cc9b4c1..cf0b203e10 100644
--- a/libraries/src/test/java/com/baeldung/jets3t/JetS3tLiveTest.java
+++ b/libraries/src/test/java/com/baeldung/jets3t/JetS3tLiveTest.java
@@ -15,6 +15,7 @@ import org.junit.Test;
import java.io.*;
import java.nio.file.Files;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Collectors;
@@ -191,14 +192,25 @@ public class JetS3tLiveTest {
S3Bucket bucket = createBucket();
assertNotNull(bucket);
- // Create a stream
- ByteArrayInputStream testStream = new ByteArrayInputStream("test stream".getBytes());
+ ArrayList numbers = new ArrayList<>();
+ numbers.add(2);
+ numbers.add(3);
+ numbers.add(5);
+ numbers.add(7);
+
+ // Serialize ArrayList
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ ObjectOutputStream objectOutputStream = new ObjectOutputStream(bytes);
+ objectOutputStream.writeObject(numbers);
+
+ // Wrap bytes
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes.toByteArray());
// Create and populate object
S3Object streamObject = new S3Object("stream");
- streamObject.setDataInputStream(testStream);
- streamObject.setContentLength(testStream.available());
- streamObject.setContentType("text/plain");
+ streamObject.setDataInputStream(byteArrayInputStream);
+ streamObject.setContentLength(byteArrayInputStream.available());
+ streamObject.setContentType("binary/octet-stream");
// Put it
s3Service.putObject(BucketName, streamObject);
@@ -206,11 +218,14 @@ public class JetS3tLiveTest {
// Get it
S3Object newStreamObject = s3Service.getObject(BucketName, "stream");
- // Convert back to string
- String testString = new BufferedReader(new InputStreamReader(newStreamObject.getDataInputStream()))
- .lines().collect(Collectors.joining("\n"));
+ // Convert back to ArrayList
+ ObjectInputStream objectInputStream = new ObjectInputStream(newStreamObject.getDataInputStream());
+ ArrayList newNumbers = (ArrayList)objectInputStream.readObject();
- assertTrue("test stream".equals(testString));
+ assertEquals(2, (int)newNumbers.get(0));
+ assertEquals(3, (int)newNumbers.get(1));
+ assertEquals(5, (int)newNumbers.get(2));
+ assertEquals(7, (int)newNumbers.get(3));
// Clean up
deleteObject("stream");
diff --git a/libraries/src/test/java/com/baeldung/netty/EmbeddedChannelUnitTest.java b/libraries/src/test/java/com/baeldung/netty/EmbeddedChannelUnitTest.java
new file mode 100644
index 0000000000..2818bb96a2
--- /dev/null
+++ b/libraries/src/test/java/com/baeldung/netty/EmbeddedChannelUnitTest.java
@@ -0,0 +1,89 @@
+package com.baeldung.netty;
+
+import java.nio.charset.Charset;
+
+import static org.assertj.core.api.Assertions.*;
+
+import org.assertj.core.api.Assertions;
+import org.junit.Test;
+
+import io.netty.channel.embedded.EmbeddedChannel;
+import io.netty.handler.codec.http.DefaultFullHttpRequest;
+import io.netty.handler.codec.http.FullHttpRequest;
+import io.netty.handler.codec.http.FullHttpResponse;
+import io.netty.handler.codec.http.HttpMethod;
+import io.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.handler.codec.http.HttpVersion;
+
+public class EmbeddedChannelUnitTest {
+
+ @Test
+ public void givenTwoChannelHandlers_testPipeline() {
+
+ final FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET,
+ "/calculate?a=10&b=5");
+ httpRequest.headers().add("Operator", "Add");
+
+ EmbeddedChannel channel = new EmbeddedChannel(new HttpMessageHandler(), new CalculatorOperationHandler());
+
+ channel.pipeline().addFirst(new HttpMessageHandler()).addLast(new CalculatorOperationHandler());
+
+ // send HTTP request to server and check that the message is on the inbound pipeline
+ assertThat(channel.writeInbound(httpRequest)).isTrue();
+
+ long inboundChannelResponse = channel.readInbound();
+ assertThat(inboundChannelResponse).isEqualTo(15);
+
+ // we should have an outbound message in the form of a HTTP response
+ assertThat(channel.outboundMessages().size()).isEqualTo(1);
+ // Object response = channel.readOutbound();
+
+ FullHttpResponse httpResponse = channel.readOutbound();
+ String httpResponseContent = httpResponse.content().toString(Charset.defaultCharset());
+ assertThat(httpResponseContent).isEqualTo("15");
+ }
+
+ @Test
+ public void givenTwoChannelHandlers_testExceptionHandlingInHttpMessageHandler() {
+
+ EmbeddedChannel channel = new EmbeddedChannel(new HttpMessageHandler(), new CalculatorOperationHandler());
+
+ final FullHttpRequest wrongHttpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST,
+ "/calculate?a=10&b=5");
+ wrongHttpRequest.headers().add("Operator", "Add");
+
+ assertThatThrownBy(() -> {
+ // send invalid HTTP request to server and expect and error
+ channel.pipeline().fireChannelRead(wrongHttpRequest);
+ channel.checkException();
+ }).isInstanceOf(UnsupportedOperationException.class)
+ .hasMessage("HTTP method not supported");
+
+ FullHttpResponse errorHttpResponse = channel.readOutbound();
+ String errorHttpResponseContent = errorHttpResponse.content().toString(Charset.defaultCharset());
+ assertThat(errorHttpResponseContent).isEqualToIgnoringCase("Operation not defined");
+ assertThat(errorHttpResponse.status()).isEqualTo(HttpResponseStatus.INTERNAL_SERVER_ERROR);
+ }
+
+ @Test
+ public void givenTwoChannelHandlers_testExceptionHandlingInCalculatorOperationHandler() {
+ EmbeddedChannel channel = new EmbeddedChannel(new HttpMessageHandler(), new CalculatorOperationHandler());
+
+ final FullHttpRequest wrongHttpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET,
+ "/calculate?a=10&b=5");
+ wrongHttpRequest.headers().add("Operator", "Invalid_operation");
+
+ // the HttpMessageHandler does not handle the exception and throws it down the pipeline
+ assertThatThrownBy(() -> {
+ channel.writeInbound(wrongHttpRequest);
+ }).isInstanceOf(IllegalArgumentException.class)
+ .hasMessage("Operation not defined");
+
+ // the outbound message is a HTTP response with the status code 500
+ FullHttpResponse errorHttpResponse = channel.readOutbound();
+ String errorHttpResponseContent = errorHttpResponse.content().toString(Charset.defaultCharset());
+ assertThat(errorHttpResponseContent).isEqualToIgnoringCase("Operation not defined");
+ assertThat(errorHttpResponse.status()).isEqualTo(HttpResponseStatus.INTERNAL_SERVER_ERROR);
+ }
+
+}
diff --git a/libraries/src/test/java/com/baeldung/opencsv/OpenCsvTest.java b/libraries/src/test/java/com/baeldung/opencsv/OpenCsvTest.java
new file mode 100644
index 0000000000..394b3fba4f
--- /dev/null
+++ b/libraries/src/test/java/com/baeldung/opencsv/OpenCsvTest.java
@@ -0,0 +1,66 @@
+package com.baeldung.opencsv;
+
+import com.baeldung.opencsv.helpers.Helpers;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class OpenCsvTest {
+
+ private Object testReadCsv(Object result) {
+ assert (result != null);
+ assert (result instanceof String);
+ assert (!((String) result).isEmpty());
+ System.out.println(result);
+ return result;
+ }
+
+ private Object testWriteCsv(Object result) {
+ assert (result instanceof String);
+ assert (!((String) result).isEmpty());
+ return result;
+ }
+
+ @Before
+ public void setup() {
+ }
+
+ @Test
+ public void positionExampleTest() {
+ testReadCsv(Application.simpleSyncPositionBeanExample());
+ }
+
+ @Test
+ public void namedColumnExampleTest() {
+ testReadCsv(Application.namedSyncColumnBeanExample());
+ }
+
+ @Test
+ public void writeCsvUsingBeanBuilderTest() {
+ testWriteCsv(Application.writeSyncCsvFromBeanExample());
+ }
+
+ @Test
+ public void oneByOneExampleTest() {
+ testReadCsv(Application.oneByOneSyncExample());
+ }
+
+ @Test
+ public void readAllExampleTest() {
+ testReadCsv(Application.readAllSyncExample());
+ }
+
+ @Test
+ public void csvWriterOneByOneTest() {
+ testWriteCsv(Application.csvWriterSyncOneByOne());
+ }
+
+ @Test
+ public void csvWriterAllTest() {
+ testWriteCsv(Application.csvWriterSyncAll());
+ }
+
+ @After
+ public void close() {
+ }
+}
\ No newline at end of file
diff --git a/libraries/src/test/resources/csv/fourColumn.csv b/libraries/src/test/resources/csv/fourColumn.csv
new file mode 100644
index 0000000000..51a69fd1a0
--- /dev/null
+++ b/libraries/src/test/resources/csv/fourColumn.csv
@@ -0,0 +1,5 @@
+ColA,ColB,ColC,ColD
+A,B,B,B
+C,D,W,W
+G,G,E,E
+G,F,Q,Q
diff --git a/libraries/src/test/resources/csv/namedColumn.csv b/libraries/src/test/resources/csv/namedColumn.csv
new file mode 100644
index 0000000000..279b743600
--- /dev/null
+++ b/libraries/src/test/resources/csv/namedColumn.csv
@@ -0,0 +1,5 @@
+name,age
+adam,1000
+martin,27
+gigi,41
+seraphine,30
\ No newline at end of file
diff --git a/libraries/src/test/resources/csv/twoColumn.csv b/libraries/src/test/resources/csv/twoColumn.csv
new file mode 100644
index 0000000000..3eab8e8a64
--- /dev/null
+++ b/libraries/src/test/resources/csv/twoColumn.csv
@@ -0,0 +1,5 @@
+ColA,ColB
+A,B
+C,D
+G,G
+G,F
diff --git a/libraries/src/test/resources/csv/writtenAll.csv b/libraries/src/test/resources/csv/writtenAll.csv
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/libraries/src/test/resources/csv/writtenBean.csv b/libraries/src/test/resources/csv/writtenBean.csv
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/libraries/src/test/resources/csv/writtenOneByOne.csv b/libraries/src/test/resources/csv/writtenOneByOne.csv
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/linkrest/pom.xml b/linkrest/pom.xml
index 0363f0bc4c..5a8b39e7df 100644
--- a/linkrest/pom.xml
+++ b/linkrest/pom.xml
@@ -1,81 +1,80 @@
- 4.0.0
- com.baeldung
- linkrest
- 0.0.1-SNAPSHOT
- war
+ 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
+ linkrest
+ 0.0.1-SNAPSHOT
+ war
-
-
- com.nhl.link.rest
- link-rest
- ${linkrest.version}
-
-
- org.glassfish.jersey.containers
- jersey-container-servlet
- ${jersey.version}
-
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+
+ com.nhl.link.rest
+ link-rest
+ ${linkrest.version}
+
+
+ org.glassfish.jersey.containers
+ jersey-container-servlet
+ ${jersey.version}
+
+
org.glassfish.jersey.media
jersey-media-moxy
${jersey.version}
-
+
com.h2database
h2
${h2.version}
-
+
-
-
-
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
- maven-war-plugin
- 2.6
-
- WebContent
- false
-
-
-
- org.apache.cayenne.plugins
- cayenne-maven-plugin
- ${cayenne.version}
+
+
+
+ maven-war-plugin
+ ${maven-war-plugin.version}
+
+ WebContent
+ false
+
+
+
+ org.apache.cayenne.plugins
+ cayenne-maven-plugin
+ ${cayenne.version}
-
-
-
+
+
+
-
-
-
- cgen
-
-
-
-
-
- org.apache.cayenne.plugins
- cayenne-modeler-maven-plugin
- ${cayenne.version}
-
+
+
+
+ cgen
+
+
+
+
+
+ org.apache.cayenne.plugins
+ cayenne-modeler-maven-plugin
+ ${cayenne.version}
+
+
+
+
+
+ 2.9
+ 4.0.B1
+ 1.4.196
+ 2.25.1
+
-
-
-
- 2.9
- 4.0.B1
- 1.4.196
- 2.25.1
-
\ No newline at end of file
diff --git a/logging-modules/log-mdc/pom.xml b/logging-modules/log-mdc/pom.xml
index 5551585372..16eeff43cf 100644
--- a/logging-modules/log-mdc/pom.xml
+++ b/logging-modules/log-mdc/pom.xml
@@ -1,5 +1,5 @@
+ 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
log-mdc
@@ -12,7 +12,7 @@
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
+ ../../
diff --git a/logging-modules/log4j/pom.xml b/logging-modules/log4j/pom.xml
index 6a3fbde393..5e2f413e09 100644
--- a/logging-modules/log4j/pom.xml
+++ b/logging-modules/log4j/pom.xml
@@ -1,8 +1,7 @@
+ 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
log4j
1.0-SNAPSHOT
@@ -11,7 +10,7 @@
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
+ ../../
diff --git a/logging-modules/log4j2/pom.xml b/logging-modules/log4j2/pom.xml
index 46b8b80597..651e1e7d1f 100644
--- a/logging-modules/log4j2/pom.xml
+++ b/logging-modules/log4j2/pom.xml
@@ -1,8 +1,7 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
-
log4j2
@@ -56,8 +55,6 @@
-
-
2.9.3
1.4.193
diff --git a/logging-modules/logback/pom.xml b/logging-modules/logback/pom.xml
index cd0d3758cc..2ffcd0dbf8 100644
--- a/logging-modules/logback/pom.xml
+++ b/logging-modules/logback/pom.xml
@@ -1,21 +1,13 @@
4.0.0
-
logback
logback
0.1-SNAPSHOT
-
- UTF-8
- 1.2.3
- 0.1.5
- 2.9.3
-
-
com.baeldung
parent-modules
@@ -47,5 +39,11 @@
+
+ UTF-8
+ 1.2.3
+ 0.1.5
+ 2.9.3
+
diff --git a/lombok/pom.xml b/lombok/pom.xml
index bea05b38f3..d11cffb34b 100644
--- a/lombok/pom.xml
+++ b/lombok/pom.xml
@@ -1,10 +1,9 @@
4.0.0
-
lombok
lombok
0.1-SNAPSHOT
@@ -16,7 +15,6 @@
-
org.projectlombok
lombok
@@ -24,17 +22,14 @@
${lombok.version}
provided
-
org.hibernate.javax.persistence
hibernate-jpa-2.1-api
${hibernate-jpa-2.1-api.version}
-
-
lombok
@@ -65,25 +60,20 @@
false
-
+
-
-
UTF-8
1.16.18
-
1.0.0.Final
-
1.16.10.0
diff --git a/lucene/pom.xml b/lucene/pom.xml
index 6659d9ac32..b8786fadc7 100644
--- a/lucene/pom.xml
+++ b/lucene/pom.xml
@@ -1,35 +1,46 @@
- 4.0.0
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
- lucene
- 0.0.1-SNAPSHOT
- lucene
- An Apache Lucene demo application
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ lucene
+ 0.0.1-SNAPSHOT
+ lucene
+ An Apache Lucene demo application
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
-
- org.apache.lucene
- lucene-core
- 7.1.0
-
+
+
+ org.apache.lucene
+ lucene-core
+ ${lucene.version}
+
+
+ org.apache.lucene
+ lucene-queryparser
+ ${lucene.version}
+
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+
+
+ UTF-8
+
+ 1.16.18
+
+ 1.0.0.Final
+
+ 1.16.10.0
+ 7.1.0
+
-
- org.apache.lucene
- lucene-queryparser
- 7.1.0
-
-
-
- junit
- junit
- 4.12
- test
-
-
\ No newline at end of file
diff --git a/mapstruct/pom.xml b/mapstruct/pom.xml
index ba67ccc2df..be105b8aa8 100644
--- a/mapstruct/pom.xml
+++ b/mapstruct/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="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4.0.0
mapstruct
mapstruct
@@ -14,10 +14,6 @@
1.0.0-SNAPSHOT
-
- 1.1.0.Final
- 4.3.4.RELEASE
-
org.mapstruct
@@ -36,6 +32,7 @@
test
+
mapstruct
@@ -44,8 +41,8 @@
maven-compiler-plugin
${maven-compiler-plugin.version}
- 1.8
- 1.8
+ ${maven.compiler.source}
+ ${maven.compiler.target}
org.mapstruct
@@ -58,39 +55,11 @@
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
+
+ 1.1.0.Final
+ 4.3.4.RELEASE
+ 1.8
+ 1.8
+
diff --git a/maven/README.md b/maven/README.md
new file mode 100644
index 0000000000..7c3779143a
--- /dev/null
+++ b/maven/README.md
@@ -0,0 +1,9 @@
+### Relevant Articles
+
+- [Guide to the Core Maven Plugins](http://www.baeldung.com/core-maven-plugins)
+- [Maven Resources Plugin](http://www.baeldung.com/maven-resources-plugin)
+- [Maven Compiler Plugin](http://www.baeldung.com/maven-compiler-plugin)
+- [Quick Guide to the Maven Surefire Plugin](http://www.baeldung.com/maven-surefire-plugin)
+- [The Maven Failsafe Plugin](http://www.baeldung.com/maven-failsafe-plugin)
+- [The Maven Verifier Plugin](http://www.baeldung.com/maven-verifier-plugin)
+- [The Maven Clean Plugin](http://www.baeldung.com/maven-clean-plugin)
diff --git a/maven/pom.xml b/maven/pom.xml
index d21b138762..fb7233e7e9 100644
--- a/maven/pom.xml
+++ b/maven/pom.xml
@@ -1,5 +1,5 @@
+ 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
@@ -11,21 +11,11 @@
1.0.0-SNAPSHOT
-
- 3.0.2
- 3.7.0
- 2.21.0
- 2.21.0
- 1.1
- 3.0.0
- Baeldung
-
-
junit
junit
- 4.12
+ ${junit.version}
test
@@ -52,8 +42,8 @@
maven-compiler-plugin
${maven.compiler.version}
- 1.8
- 1.8
+ ${maven.compiler.source}
+ ${maven.compiler.target}
-Xlint:unchecked
@@ -113,4 +103,17 @@
+
+
+ 3.0.2
+ 3.7.0
+ 2.21.0
+ 2.21.0
+ 1.1
+ 3.0.0
+ Baeldung
+ 1.8
+ 1.8
+
+
\ No newline at end of file
diff --git a/mesos-marathon/pom.xml b/mesos-marathon/pom.xml
index b0060a260e..2b7a238ee8 100644
--- a/mesos-marathon/pom.xml
+++ b/mesos-marathon/pom.xml
@@ -1,8 +1,7 @@
+ 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
mesos-marathon
0.0.1-SNAPSHOT
diff --git a/metrics/pom.xml b/metrics/pom.xml
index 25ce452d7a..e3868eddef 100644
--- a/metrics/pom.xml
+++ b/metrics/pom.xml
@@ -2,6 +2,7 @@
4.0.0
+ metrics
parent-modules
@@ -9,17 +10,6 @@
1.0.0-SNAPSHOT
- metrics
-
-
-
- 3.1.2
- 3.1.0
- 0.12.17
- 0.12.0.RELEASE
- 2.0.0.M5
-
-
io.dropwizard.metrics
@@ -81,18 +71,18 @@
com.fasterxml.jackson.core
jackson-databind
- 2.9.1
+ ${fasterxml.jackson.version}
com.fasterxml.jackson.dataformat
jackson-dataformat-smile
- 2.9.1
+ ${fasterxml.jackson.version}
com.netflix.spectator
spectator-api
- 0.57.1
+ ${spectator-api.version}
@@ -119,4 +109,14 @@
+
+ 3.1.2
+ 3.1.0
+ 0.12.17
+ 0.12.0.RELEASE
+ 2.0.0.M5
+ 2.9.1
+ 0.57.1
+
+
diff --git a/metrics/src/test/java/com/baeldung/metrics/servo/MetricTypeTest.java b/metrics/src/test/java/com/baeldung/metrics/servo/MetricTypeManualTest.java
similarity index 99%
rename from metrics/src/test/java/com/baeldung/metrics/servo/MetricTypeTest.java
rename to metrics/src/test/java/com/baeldung/metrics/servo/MetricTypeManualTest.java
index 237092b1c3..d810de155a 100644
--- a/metrics/src/test/java/com/baeldung/metrics/servo/MetricTypeTest.java
+++ b/metrics/src/test/java/com/baeldung/metrics/servo/MetricTypeManualTest.java
@@ -32,7 +32,7 @@ import com.netflix.servo.monitor.StepCounter;
import com.netflix.servo.monitor.Stopwatch;
import com.netflix.servo.stats.StatsConfig;
-public class MetricTypeTest {
+public class MetricTypeManualTest {
@Test
public void givenDefaultCounter_whenManipulate_thenCountValid() {
diff --git a/microprofile/README.md b/microprofile/README.md
new file mode 100644
index 0000000000..1a28487e89
--- /dev/null
+++ b/microprofile/README.md
@@ -0,0 +1,3 @@
+### Relevant articles:
+
+- [Building Microservices with Eclipse MicroProfile](http://www.baeldung.com/eclipse-microprofile)
diff --git a/microprofile/pom.xml b/microprofile/pom.xml
index ce8a2d13ca..27d234b73a 100644
--- a/microprofile/pom.xml
+++ b/microprofile/pom.xml
@@ -3,27 +3,22 @@
xmlns="http://maven.apache.org/POM/4.0.0"
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
microprofile
1.0-SNAPSHOT
war
-
- UTF-8
- UTF-8
- 1.8
- 1.8
- library
- ${project.build.directory}/${app.name}-service.jar
- runnable
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
org.eclipse.microprofile
microprofile
- 1.2
+ ${microprofile.version}
provided
pom
@@ -41,12 +36,12 @@
net.wasdev.wlp.maven.plugins
liberty-maven-plugin
- 2.1.2
+ ${liberty-maven-plugin.version}
io.openliberty
openliberty-runtime
- 17.0.0.4
+ ${openliberty-runtime.version}
zip
${basedir}/src/main/liberty/config/server.xml
@@ -84,4 +79,15 @@
+
+ UTF-8
+ UTF-8
+ library
+ ${project.build.directory}/${app.name}-service.jar
+ runnable
+ 1.2
+ 2.1.2
+ 17.0.0.4
+
+
diff --git a/muleesb/pom.xml b/muleesb/pom.xml
index 2c88bf83da..a3b9869eb4 100644
--- a/muleesb/pom.xml
+++ b/muleesb/pom.xml
@@ -1,79 +1,75 @@
- 4.0.0
- com.mycompany
- muleesb
- 1.0.0-SNAPSHOT
- mule
- Mule muleesb Application
+ 4.0.0
+ com.mycompany
+ muleesb
+ 1.0.0-SNAPSHOT
+ mule
+ Mule muleesb Application
-
- UTF-8
- UTF-8
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
- 3.8.1
- 1.2
- 1.3.6
- 3.9.0
-
-
-
-
-
- org.mule.tools.maven
- mule-app-maven-plugin
- ${mule.tools.version}
- true
-
- true
-
-
-
- org.mule.tools
- muleesb-maven-plugin
- 1.0
-
- 3.7.0
- /home/abir/AnypointStudio/workspace/variablescopetest
-
-
-
- deploy
-
- start
-
-
-
-
-
- org.codehaus.mojo
- build-helper-maven-plugin
- 1.7
-
-
- add-resource
- generate-resources
-
- add-resource
-
-
-
-
- src/main/app/
-
-
- mappings/
-
-
- src/main/api/
-
-
-
-
-
-
-
+
+
+
+ org.mule.tools.maven
+ mule-app-maven-plugin
+ ${mule.tools.version}
+ true
+
+ true
+
+
+
+ org.mule.tools
+ muleesb-maven-plugin
+ 1.0
+
+ 3.7.0
+ /home/abir/AnypointStudio/workspace/variablescopetest
+
+
+
+ deploy
+
+ start
+
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 1.7
+
+
+ add-resource
+ generate-resources
+
+ add-resource
+
+
+
+
+ src/main/app/
+
+
+ mappings/
+
+
+ src/main/api/
+
+
+
+
+
+
+
com.mulesoft.munit.tools
munit-maven-plugin
${munit.version}
@@ -96,89 +92,89 @@
-
+
src/test/munit
-
+
src/test/resources
-
-
-
-
- org.mule.modules
- mule-module-spring-config
- ${mule.version}
- provided
-
-
-
- org.mule.transports
- mule-transport-file
- ${mule.version}
- provided
-
-
- org.mule.transports
- mule-transport-http
- ${mule.version}
- provided
-
-
- org.mule.transports
- mule-transport-jdbc
- ${mule.version}
- provided
-
-
- org.mule.transports
- mule-transport-jms
- ${mule.version}
- provided
-
-
- org.mule.transports
- mule-transport-vm
- ${mule.version}
- provided
-
-
-
- org.mule.modules
- mule-module-scripting
- ${mule.version}
- provided
-
-
- org.mule.modules
- mule-module-xml
- ${mule.version}
- provided
-
-
-
- org.mule.tests
- mule-tests-functional
- ${mule.version}
- test
-
-
- org.mule.modules
- mule-module-apikit
- ${mule.version}
- provided
-
-
+
+
+
+
+ org.mule.modules
+ mule-module-spring-config
+ ${mule.version}
+ provided
+
+
+
+ org.mule.transports
+ mule-transport-file
+ ${mule.version}
+ provided
+
+
+ org.mule.transports
+ mule-transport-http
+ ${mule.version}
+ provided
+
+
+ org.mule.transports
+ mule-transport-jdbc
+ ${mule.version}
+ provided
+
+
+ org.mule.transports
+ mule-transport-jms
+ ${mule.version}
+ provided
+
+
+ org.mule.transports
+ mule-transport-vm
+ ${mule.version}
+ provided
+
+
+
+ org.mule.modules
+ mule-module-scripting
+ ${mule.version}
+ provided
+
+
+ org.mule.modules
+ mule-module-xml
+ ${mule.version}
+ provided
+
+
+
+ org.mule.tests
+ mule-tests-functional
+ ${mule.version}
+ test
+
+
+ org.mule.modules
+ mule-module-apikit
+ ${mule.version}
+ provided
+
+
com.mulesoft.munit
mule-munit-support
${mule.munit.support.version}
test
-
+
com.mulesoft.munit
munit-runner
${munit.version}
@@ -186,29 +182,40 @@
-
-
- Central
- Central
- http://repo1.maven.org/maven2/
- default
-
-
- mulesoft-releases
- MuleSoft Releases Repository
- http://repository.mulesoft.org/releases/
- default
-
-
-
-
- mulesoft-release
- mulesoft release repository
- default
- http://repository.mulesoft.org/releases/
-
- false
-
-
-
+
+
+ Central
+ Central
+ http://repo1.maven.org/maven2/
+ default
+
+
+ mulesoft-releases
+ MuleSoft Releases Repository
+ http://repository.mulesoft.org/releases/
+ default
+
+
+
+
+
+ mulesoft-release
+ mulesoft release repository
+ default
+ http://repository.mulesoft.org/releases/
+
+ false
+
+
+
+
+
+ UTF-8
+ UTF-8
+ 3.8.1
+ 1.2
+ 1.3.6
+ 3.9.0
+
+
diff --git a/mustache/pom.xml b/mustache/pom.xml
index 1c64dbdb0b..88d87758cd 100644
--- a/mustache/pom.xml
+++ b/mustache/pom.xml
@@ -1,178 +1,161 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- 4.0.0
- mustache
- 0.0.1-SNAPSHOT
- jar
- mustache
+ 4.0.0
+ mustache
+ 0.0.1-SNAPSHOT
+ jar
+ mustache
-
- org.springframework.boot
- spring-boot-starter-parent
- 1.5.4.RELEASE
-
-
-
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.4.RELEASE
+
+
+
-
-
- com.github.spullara.mustache.java
- compiler
- ${mustache.compiler.api.version}
-
+
+
+ com.github.spullara.mustache.java
+ compiler
+ ${mustache.compiler.api.version}
+
-
- org.assertj
- assertj-core
- ${assertj.version}
-
+
+ org.assertj
+ assertj-core
+ ${assertj.version}
+
-
- log4j
- log4j
- ${log4j.version}
-
+
+ log4j
+ log4j
+ ${log4j.version}
+
-
- org.springframework.boot
- spring-boot-starter-mustache
-
+
+ org.springframework.boot
+ spring-boot-starter-mustache
+
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.webjars
- bootstrap
- 3.3.7
-
-
- org.fluttercode.datafactory
- datafactory
- 0.8
-
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.webjars
+ bootstrap
+ ${webjars.bootstrap.version}
+
+
+ org.fluttercode.datafactory
+ datafactory
+ ${datafactory.version}
+
-
- junit
- junit
- ${junit.version}
- test
-
+
+ junit
+ junit
+ ${junit.version}
+ test
+
-
+
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
- 3
- true
-
- **/*IntegrationTest.java
- **/*LongRunningUnitTest.java
- **/*ManualTest.java
- **/JdbcTest.java
- **/*LiveTest.java
-
-
-
-
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
-
+
+
+ integration
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ integration-test
+
+ test
+
+
+
+ **/*LiveTest.java
+ **/AutoconfigurationTest.java
+
+
+ **/*IntegrationTest.java
+
+
+
+
+
+
+ json
+
+
+
+
+
+
+
+ autoconfiguration
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ integration-test
+
+ test
+
+
+
+ **/*LiveTest.java
+ **/*IntegrationTest.java
+
+
+ **/AutoconfigurationTest.java
+
+
+
+
+
+
+ json
+
+
+
+
+
+
+
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*LiveTest.java
- **/AutoconfigurationTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
- autoconfiguration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*LiveTest.java
- **/*IntegrationTest.java
-
-
- **/AutoconfigurationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
+
+ 0.9.2
+ 3.7.0
+ 1.2.16
+ 4.12
+ UTF-8
-
- 0.9.2
- 3.7.0
- 1.2.16
- 4.12
-
- UTF-8
-
-
+
3.7.0
2.19.1
-
- 1.8
-
+ 0.8
+ 3.3.7
+ 1.8
+
\ No newline at end of file
diff --git a/mvn-wrapper/pom.xml b/mvn-wrapper/pom.xml
index 209c4b9403..6fb9bfeffc 100644
--- a/mvn-wrapper/pom.xml
+++ b/mvn-wrapper/pom.xml
@@ -1,12 +1,10 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
-
mvn-wrapper
0.0.1-SNAPSHOT
jar
-
mvn-wrapper
Setting up the Maven Wrapper
@@ -17,12 +15,6 @@
../parent-boot-5
-
- UTF-8
- UTF-8
- 1.8
-
-
org.springframework.boot
@@ -42,4 +34,10 @@
+
+
+ UTF-8
+ UTF-8
+
+
diff --git a/mybatis/pom.xml b/mybatis/pom.xml
index 32039b01e6..b167d94ed8 100644
--- a/mybatis/pom.xml
+++ b/mybatis/pom.xml
@@ -1,8 +1,7 @@
+ 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
mybatis
1.0.0-SNAPSHOT
@@ -13,10 +12,6 @@
1.0.0-SNAPSHOT
-
- 10.13.1.1
- 3.2.2
-
org.apache.derby
@@ -30,4 +25,9 @@
+
+ 10.13.1.1
+ 3.2.2
+
+
\ No newline at end of file
diff --git a/noexception/pom.xml b/noexception/pom.xml
index 64c0591fda..c825449452 100644
--- a/noexception/pom.xml
+++ b/noexception/pom.xml
@@ -1,7 +1,6 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
-
com.baeldung
noexception
1.0
@@ -17,7 +16,12 @@
com.machinezoo.noexception
noexception
- 1.1.0
+ ${noexception.version}
+
+
+ 1.1.0
+
+
diff --git a/orientdb/pom.xml b/orientdb/pom.xml
index 3d3cb36a91..317c469005 100644
--- a/orientdb/pom.xml
+++ b/orientdb/pom.xml
@@ -1,12 +1,10 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
-
orientdb
0.0.1-SNAPSHOT
jar
-
intro-orientdb
introduction to the OrientDB Java APIs
@@ -16,15 +14,6 @@
1.0.0-SNAPSHOT
-
- UTF-8
- UTF-8
- 1.8
- 2.2.31
- 2.6.0
- 4.12
-
-
com.orientechnologies
@@ -54,4 +43,15 @@
test
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 2.2.31
+ 2.6.0
+ 4.12
+
+
diff --git a/orika/pom.xml b/orika/pom.xml
index d1f38a6016..1a54440ffe 100644
--- a/orika/pom.xml
+++ b/orika/pom.xml
@@ -1,9 +1,10 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
com.baeldung
orika
1.0
+ orika
com.baeldung
@@ -11,20 +12,16 @@
1.0.0-SNAPSHOT
-
- 1.5.0
-
-
- orika
-
-
ma.glasnost.orika
orika-core
${orika-core.version}
-
+
+ 1.5.0
+
+
diff --git a/osgi/pom.xml b/osgi/pom.xml
index e6ef9c3192..704a738d24 100644
--- a/osgi/pom.xml
+++ b/osgi/pom.xml
@@ -3,15 +3,9 @@
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
-
osgi-intro
pom
1.0-SNAPSHOT
-
- osgi-intro-sample-activator
- osgi-intro-sample-service
- osgi-intro-sample-client
-
com.baeldung
@@ -20,33 +14,34 @@
..
+
+ osgi-intro-sample-activator
+ osgi-intro-sample-service
+ osgi-intro-sample-client
+
+
-
${project.groupId}
osgi-intro-client
${project.version}
-
${project.groupId}
osgi-intro-service
${project.version}
-
${project.groupId}
osgi-intro-gxyz
${project.version}
-
${project.groupId}
osgi-intro-mapquest
${project.version}
-
com.squareup.okhttp3
okhttp
diff --git a/out/production/main180/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/pom.xml b/out/production/main180/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/pom.xml
index de69efa43a..2835f6f416 100644
--- a/out/production/main180/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/pom.xml
+++ b/out/production/main180/com/baeldung/javaeeannotations/JavaEEAnnotationsSample/pom.xml
@@ -1,57 +1,48 @@
- 4.0.0
- com.baeldung.javaeeannotations
- JavaEEAnnotationsSample
- 0.0.1-SNAPSHOT
- war
- JavaEEAnnotationsSample
- JavaEEAnnotationsSample
-
-
-
-
- javax.annotation
- javax.annotation-api
- 1.3
-
-
-
- javax.servlet
- javax.servlet-api
- 3.1.0
-
-
-
- javax.servlet.jsp
- jsp-api
- 2.1
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
- org.apache.maven.plugins
- maven-war-plugin
- 2.4
-
- src/main/webapp
- SpringFieldConstructorInjection
- false
-
-
-
-
- JavaEEAnnotationsSample
-
+ 4.0.0
+ com.baeldung.javaeeannotations
+ JavaEEAnnotationsSample
+ 0.0.1-SNAPSHOT
+ war
+ JavaEEAnnotationsSample
+ JavaEEAnnotationsSample
+
+
+
+
+ javax.annotation
+ javax.annotation-api
+ 1.3
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.1.0
+
+
+
+ javax.servlet.jsp
+ jsp-api
+ 2.1
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ 2.4
+
+ src/main/webapp
+ SpringFieldConstructorInjection
+ false
+
+
+
+
+ JavaEEAnnotationsSample
+
\ No newline at end of file
diff --git a/parent-boot-5/pom.xml b/parent-boot-5/pom.xml
index 0e3936a73a..32bb2eab04 100644
--- a/parent-boot-5/pom.xml
+++ b/parent-boot-5/pom.xml
@@ -1,5 +1,5 @@
+ 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
parent-boot-5
@@ -8,21 +8,11 @@
Parent Boot 5
Parent for all spring boot 1.5 modules
-
- UTF-8
- UTF-8
- 1.8
- 3.0.6
-
- 2.20.1
- 3.7.0
-
-
- spring-boot-starter-parent
org.springframework.boot
+ spring-boot-starter-parent
1.5.10.RELEASE
-
+
@@ -30,7 +20,7 @@
junit
junit
test
-
+
io.rest-assured
rest-assured
@@ -52,7 +42,7 @@
org.apache.maven.plugins
maven-surefire-plugin
- ${maven-surefire-plugin.version}
+ ${maven-surefire-plugin.version}
3
true
@@ -67,13 +57,66 @@
org.apache.maven.plugins
maven-compiler-plugin
- ${maven-compiler-plugin.version}
+ ${maven-compiler-plugin.version}
- 1.8
- 1.8
+ ${maven.compiler.source}
+ ${maven.compiler.target}
-
+
+
+
+ integration
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ integration-test
+
+ test
+
+
+
+ **/*ManualTest.java
+ **/*LiveTest.java
+ **/AutoconfigurationTest.java
+ **/*UnitTest.java
+
+
+ **/*IntegrationTest.java
+ */EthControllerTestOne.java
+ **/*IntTest.java
+ **/*EntryPointsTest.java
+
+
+
+
+
+
+ json
+
+
+
+
+
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 3.0.6
+
+ 2.20.1
+ 3.7.0
+ 1.8
+ 1.8
+
+
\ No newline at end of file
diff --git a/patterns/README.md b/patterns/README.md
index 26099ae34f..f00e7c351d 100644
--- a/patterns/README.md
+++ b/patterns/README.md
@@ -2,4 +2,5 @@
- [A Guide to the Front Controller Pattern in Java](http://www.baeldung.com/java-front-controller-pattern)
- [Introduction to Intercepting Filter Pattern in Java](http://www.baeldung.com/intercepting-filter-pattern-in-java)
- [Implementing the Template Method Pattern in Java](http://www.baeldung.com/java-template-method-pattern)
+- [Chain of Responsibility Design Pattern in Java](http://www.baeldung.com/chain-of-responsibility-pattern)
diff --git a/patterns/behavioral-patterns/pom.xml b/patterns/behavioral-patterns/pom.xml
index 3c40520ce1..03b138dfc4 100644
--- a/patterns/behavioral-patterns/pom.xml
+++ b/patterns/behavioral-patterns/pom.xml
@@ -7,11 +7,11 @@
jar
com.baeldung.patterns
- patterns-parent
- 1.0.0-SNAPSHOT
- ..
-
-
+ patterns-parent
+ 1.0.0-SNAPSHOT
+ ..
+
+
junit
@@ -20,18 +20,9 @@
test
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.7.0
-
-
-
UTF-8
1.8
1.8
-
+
\ No newline at end of file
diff --git a/patterns/facade/README.md b/patterns/facade/README.md
new file mode 100644
index 0000000000..cb44bf4bc4
--- /dev/null
+++ b/patterns/facade/README.md
@@ -0,0 +1,2 @@
+### Relevant Articles:
+- [Facade Design Pattern in Java](http://www.baeldung.com/java-facade-pattern)
diff --git a/patterns/facade/pom.xml b/patterns/facade/pom.xml
new file mode 100644
index 0000000000..573e557eb6
--- /dev/null
+++ b/patterns/facade/pom.xml
@@ -0,0 +1,28 @@
+
+
+ 4.0.0
+ com.baeldung.pattern.facade
+ pattern.facade
+ 1.0
+ jar
+
+ com.baeldung.patterns
+ patterns-parent
+ 1.0.0-SNAPSHOT
+ ..
+
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
+ UTF-8
+ 1.8
+ 1.8
+
+
\ No newline at end of file
diff --git a/patterns/facade/src/main/java/com/baeldung/pattern/facade/CarEngineFacade.java b/patterns/facade/src/main/java/com/baeldung/pattern/facade/CarEngineFacade.java
new file mode 100644
index 0000000000..91f9b79738
--- /dev/null
+++ b/patterns/facade/src/main/java/com/baeldung/pattern/facade/CarEngineFacade.java
@@ -0,0 +1,32 @@
+package com.baeldung.pattern.facade;
+
+import com.baeldung.pattern.facade.carsystem.*;
+
+public class CarEngineFacade {
+ private static final Integer DEFAULT_COOLING_TEMP = 90;
+ private static final Integer MAX_ALLOWED_TEMP = 50;
+ private FuelInjector fuelInjector = new FuelInjector();
+ private AirFlowController airFlowController = new AirFlowController();
+ private Starter starter = new Starter();
+ private CoolingController coolingController = new CoolingController();
+ private CatalyticConverter catalyticConverter = new CatalyticConverter();
+
+ public void startEngine(){
+ fuelInjector.on();
+ airFlowController.takeAir();
+ fuelInjector.on();
+ fuelInjector.inject();
+ starter.start();
+ coolingController.setTemperatureUpperLimit(DEFAULT_COOLING_TEMP);
+ coolingController.run();
+ catalyticConverter.on();
+ }
+
+ public void stopEngine(){
+ fuelInjector.off();
+ catalyticConverter.off();
+ coolingController.cool(MAX_ALLOWED_TEMP);
+ coolingController.stop();
+ airFlowController.off();
+ }
+}
diff --git a/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/AirFlowController.java b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/AirFlowController.java
new file mode 100644
index 0000000000..5ee846ea31
--- /dev/null
+++ b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/AirFlowController.java
@@ -0,0 +1,19 @@
+package com.baeldung.pattern.facade.carsystem;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AirFlowController {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AirFlowController.class);
+ private AirFlowMeter airFlowMeter = new AirFlowMeter();
+
+ public void takeAir() {
+ airFlowMeter.getMeasurements();
+ LOGGER.info("Air provided!");
+ }
+
+ public void off() {
+ LOGGER.info("Air controller switched off.");
+ }
+}
diff --git a/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/AirFlowMeter.java b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/AirFlowMeter.java
new file mode 100644
index 0000000000..b47f9cfc4a
--- /dev/null
+++ b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/AirFlowMeter.java
@@ -0,0 +1,13 @@
+package com.baeldung.pattern.facade.carsystem;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AirFlowMeter {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AirFlowMeter.class);
+
+ public void getMeasurements() {
+ LOGGER.info("Getting air measurements...");
+ }
+}
diff --git a/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/CatalyticConverter.java b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/CatalyticConverter.java
new file mode 100644
index 0000000000..7d637cd444
--- /dev/null
+++ b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/CatalyticConverter.java
@@ -0,0 +1,17 @@
+package com.baeldung.pattern.facade.carsystem;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CatalyticConverter {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(CatalyticConverter.class);
+
+ public void on() {
+ LOGGER.info("Catalytic Converter switched on!");
+ }
+
+ public void off() {
+ LOGGER.info("Catalytic Converter switched off!");
+ }
+}
diff --git a/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/CoolingController.java b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/CoolingController.java
new file mode 100644
index 0000000000..ae556e685c
--- /dev/null
+++ b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/CoolingController.java
@@ -0,0 +1,34 @@
+package com.baeldung.pattern.facade.carsystem;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CoolingController {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CoolingController.class);
+ private static final Integer DEFAULT_RADIATOR_SPEED = 10;
+
+ private Integer temperatureUpperLimit;
+ private Radiator radiator = new Radiator();
+ private TemperatureSensor temperatureSensor = new TemperatureSensor();
+
+ public void setTemperatureUpperLimit(Integer temperatureUpperLimit) {
+ LOGGER.info("Setting temperature upper limit to {}", temperatureUpperLimit);
+ this.temperatureUpperLimit = temperatureUpperLimit;
+ }
+
+ public void run() {
+ LOGGER.info("Cooling Controller ready!");
+ radiator.setSpeed(DEFAULT_RADIATOR_SPEED);
+ }
+
+ public void cool(Integer maxAllowedTemp) {
+ LOGGER.info("Scheduled cooling with maximum allowed temperature {}", maxAllowedTemp);
+ temperatureSensor.getTemperature();
+ radiator.on();
+ }
+
+ public void stop() {
+ LOGGER.info("Stopping Cooling Controller...");
+ radiator.off();
+ }
+}
diff --git a/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/FuelInjector.java b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/FuelInjector.java
new file mode 100644
index 0000000000..c7905745e4
--- /dev/null
+++ b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/FuelInjector.java
@@ -0,0 +1,23 @@
+package com.baeldung.pattern.facade.carsystem;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FuelInjector {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FuelInjector.class);
+
+ private FuelPump fuelPump = new FuelPump();
+
+ public void on(){
+ LOGGER.info("Fuel injector ready to inject fuel.");
+ }
+
+ public void inject() {
+ fuelPump.pump();
+ LOGGER.info("Fuel injected.");
+ }
+
+ public void off() {
+ LOGGER.info("Stopping Fuel injector...");
+ }
+}
diff --git a/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/FuelPump.java b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/FuelPump.java
new file mode 100644
index 0000000000..900358f8ff
--- /dev/null
+++ b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/FuelPump.java
@@ -0,0 +1,13 @@
+package com.baeldung.pattern.facade.carsystem;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FuelPump {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(FuelPump.class);
+
+ public void pump() {
+ LOGGER.info("Fuel Pump is pumping fuel...");
+ }
+}
diff --git a/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/Radiator.java b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/Radiator.java
new file mode 100644
index 0000000000..6ca6cef9d9
--- /dev/null
+++ b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/Radiator.java
@@ -0,0 +1,21 @@
+package com.baeldung.pattern.facade.carsystem;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Radiator {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(Radiator.class);
+
+ public void on(){
+ LOGGER.info("Radiator switched on!");
+ }
+
+ public void off(){
+ LOGGER.info("Radiator switched off!");
+ }
+
+ public void setSpeed(Integer speed){
+ LOGGER.info("Setting radiator speed to {}",speed);
+ }
+}
diff --git a/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/Starter.java b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/Starter.java
new file mode 100644
index 0000000000..b1f45a0be8
--- /dev/null
+++ b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/Starter.java
@@ -0,0 +1,13 @@
+package com.baeldung.pattern.facade.carsystem;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Starter {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(Starter.class);
+
+ public void start() {
+ LOGGER.info("Starting...");
+ }
+}
diff --git a/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/TemperatureSensor.java b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/TemperatureSensor.java
new file mode 100644
index 0000000000..d6a94858b4
--- /dev/null
+++ b/patterns/facade/src/main/java/com/baeldung/pattern/facade/carsystem/TemperatureSensor.java
@@ -0,0 +1,13 @@
+package com.baeldung.pattern.facade.carsystem;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TemperatureSensor {
+ private static final Logger LOGGER = LoggerFactory.getLogger(TemperatureSensor.class);
+
+ public void getTemperature(){
+ LOGGER.info("Getting temperature from the sensor...");
+ }
+
+}
diff --git a/patterns/facade/src/test/java/com/baeldung/pattern/facade/CarEngineFacadeTest.java b/patterns/facade/src/test/java/com/baeldung/pattern/facade/CarEngineFacadeTest.java
new file mode 100644
index 0000000000..79c159319d
--- /dev/null
+++ b/patterns/facade/src/test/java/com/baeldung/pattern/facade/CarEngineFacadeTest.java
@@ -0,0 +1,85 @@
+package com.baeldung.pattern.facade;
+
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.spi.ILoggingEvent;
+import ch.qos.logback.core.AppenderBase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+public class CarEngineFacadeTest {
+
+
+ private InMemoryCustomTestAppender appender;
+
+
+ @Before
+ public void setUp() {
+ appender = new InMemoryCustomTestAppender();
+ }
+
+ @After
+ public void tearDown() {
+ appender.stop();
+ }
+
+
+ @Test
+ public void whenStartEngine_thenAllNecessaryActionsPerformed() {
+ CarEngineFacade carEngineFacade = new CarEngineFacade();
+ carEngineFacade.startEngine();
+ assertTrue(appender.logContains("Fuel injector ready to inject fuel."));
+ assertTrue(appender.logContains("Getting air measurements..."));
+ assertTrue(appender.logContains("Air provided!"));
+ assertTrue(appender.logContains("Fuel injector ready to inject fuel."));
+ assertTrue(appender.logContains("Fuel Pump is pumping fuel..."));
+ assertTrue(appender.logContains("Fuel injected."));
+ assertTrue(appender.logContains("Starting..."));
+ assertTrue(appender.logContains("Setting temperature upper limit to 90"));
+ assertTrue(appender.logContains("Cooling Controller ready!"));
+ assertTrue(appender.logContains("Setting radiator speed to 10"));
+ assertTrue(appender.logContains("Catalytic Converter switched on!"));
+ }
+
+
+ @Test
+ public void whenStopEngine_thenAllNecessaryActionsPerformed() {
+ CarEngineFacade carEngineFacade = new CarEngineFacade();
+ carEngineFacade.stopEngine();
+ assertTrue(appender.logContains("Stopping Fuel injector..."));
+ assertTrue(appender.logContains("Catalytic Converter switched off!"));
+ assertTrue(appender.logContains("Scheduled cooling with maximum allowed temperature 50"));
+ assertTrue(appender.logContains("Getting temperature from the sensor..."));
+ assertTrue(appender.logContains("Radiator switched on!"));
+ assertTrue(appender.logContains("Stopping Cooling Controller..."));
+ assertTrue(appender.logContains("Radiator switched off!"));
+ assertTrue(appender.logContains("Air controller switched off."));
+ }
+
+ private class InMemoryCustomTestAppender extends AppenderBase {
+
+ private List logs = new ArrayList<>();
+
+ public InMemoryCustomTestAppender() {
+ ((Logger) LoggerFactory.getLogger("root")).addAppender(this);
+ start();
+ }
+
+ @Override
+ protected void append(ILoggingEvent eventObject) {
+ logs.add(eventObject);
+ }
+
+ public boolean logContains(String message) {
+ return logs.stream().anyMatch(event -> event.getFormattedMessage().equals(message));
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/patterns/front-controller/pom.xml b/patterns/front-controller/pom.xml
index b746d5dc6c..877277a062 100644
--- a/patterns/front-controller/pom.xml
+++ b/patterns/front-controller/pom.xml
@@ -1,49 +1,39 @@
- 4.0.0
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ front-controller
+ war
- front-controller
- war
+
+ patterns-parent
+ com.baeldung.patterns
+ 1.0.0-SNAPSHOT
+ ..
+
-
- patterns-parent
- com.baeldung.patterns
- 1.0.0-SNAPSHOT
- ..
-
+
+
+ javax.servlet
+ javax.servlet-api
+
+
-
-
- javax.servlet
- javax.servlet-api
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
- org.apache.maven.plugins
- maven-war-plugin
-
-
- org.eclipse.jetty
- jetty-maven-plugin
-
-
- /front-controller
-
-
-
-
-
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+
+
+ org.eclipse.jetty
+ jetty-maven-plugin
+
+
+ /front-controller
+
+
+
+
+
diff --git a/patterns/intercepting-filter/pom.xml b/patterns/intercepting-filter/pom.xml
index b26b993d69..b9916d9157 100644
--- a/patterns/intercepting-filter/pom.xml
+++ b/patterns/intercepting-filter/pom.xml
@@ -1,61 +1,61 @@
- 4.0.0
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
- intercepting-filter
- war
+ intercepting-filter
+ war
-
- com.baeldung.patterns
- patterns-parent
- 1.0.0-SNAPSHOT
- ..
-
+
+ com.baeldung.patterns
+ patterns-parent
+ 1.0.0-SNAPSHOT
+ ..
+
-
-
- javax.servlet
- javax.servlet-api
-
-
- org.slf4j
- slf4j-api
- ${slf4j.version}
-
-
+
+
+ javax.servlet
+ javax.servlet-api
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+
+
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
- org.apache.maven.plugins
- maven-war-plugin
-
- false
-
-
-
- org.eclipse.jetty
- jetty-maven-plugin
-
-
- /
-
-
-
-
-
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.7.0
+
+ 1.8
+ 1.8
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+
+ false
+
+
+
+ org.eclipse.jetty
+ jetty-maven-plugin
+
+
+ /
+
+
+
+
+
-
- 1.7.21
-
+
+ 1.7.21
+
diff --git a/patterns/pom.xml b/patterns/pom.xml
index 1462952e37..7ee2c749be 100644
--- a/patterns/pom.xml
+++ b/patterns/pom.xml
@@ -1,16 +1,10 @@
+ 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.patterns
patterns-parent
pom
-
- front-controller
- intercepting-filter
- behavioral-patterns
-
com.baeldung
@@ -19,6 +13,12 @@
..
+
+ front-controller
+ intercepting-filter
+ behavioral-patterns
+
+
@@ -52,4 +52,5 @@
3.0.0
9.4.0.v20161208
+
\ No newline at end of file
diff --git a/pdf/pom.xml b/pdf/pom.xml
index bd4d35fcbf..01b2e15652 100644
--- a/pdf/pom.xml
+++ b/pdf/pom.xml
@@ -1,27 +1,17 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4.0.0
+ pdf
+ pdf
+ http://maven.apache.org
+
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- pdf
- pdf
- http://maven.apache.org
-
-
- UTF-8
- 2.0.3
- 1.6
- 5.5.10
- 5.5.10
- 3.15
- 1.8
- 3.15
-
@@ -82,4 +72,16 @@
+
+
+ UTF-8
+ 2.0.3
+ 1.6
+ 5.5.10
+ 5.5.10
+ 3.15
+ 1.8
+ 3.15
+
+
diff --git a/persistence-modules/README.md b/persistence-modules/README.md
index f05a822c30..dde4558387 100644
--- a/persistence-modules/README.md
+++ b/persistence-modules/README.md
@@ -7,3 +7,5 @@
- [Introduction to Hibernate Search](http://www.baeldung.com/hibernate-search)
- [Bootstrapping Hibernate 5 with Spring](http://www.baeldung.com/hibernate-5-spring)
- [Introduction to Lettuce – the Java Redis Client](http://www.baeldung.com/java-redis-lettuce)
+- [A Simple Tagging Implementation with JPA](http://www.baeldung.com/jpa-tagging)
+- [A Guide to Jdbi](http://www.baeldung.com/jdbi)
diff --git a/persistence-modules/java-cassandra/pom.xml b/persistence-modules/java-cassandra/pom.xml
index 81e072c3a7..015fdc84de 100644
--- a/persistence-modules/java-cassandra/pom.xml
+++ b/persistence-modules/java-cassandra/pom.xml
@@ -1,19 +1,18 @@
+ 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
cassandra-java-client
1.0.0-SNAPSHOT
-
cassandra-java-client
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
-
-
+ ../../
+
+
@@ -41,48 +40,11 @@
java-cassandra
-
-
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
+
UTF-8
-
19.0
-
3.1.2
3.1.1.0
diff --git a/persistence-modules/java-cockroachdb/pom.xml b/persistence-modules/java-cockroachdb/pom.xml
index 2b6f9651bc..a1924b674a 100644
--- a/persistence-modules/java-cockroachdb/pom.xml
+++ b/persistence-modules/java-cockroachdb/pom.xml
@@ -1,7 +1,10 @@
-
+ 4.0.0
+ com.baeldung
+ java-cockroachdb
+ 1.0-SNAPSHOT
parent-modules
@@ -10,16 +13,6 @@
../../
- 4.0.0
-
- com.baeldung
- java-cockroachdb
- 1.0-SNAPSHOT
-
-
- 42.1.4
-
-
org.postgresql
@@ -28,41 +21,6 @@
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*ManualTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
-
Central
@@ -71,4 +29,9 @@
default
+
+
+ 42.1.4
+
+
\ No newline at end of file
diff --git a/persistence-modules/java-jdbi/pom.xml b/persistence-modules/java-jdbi/pom.xml
index 392f0bdcbf..a823141bc5 100644
--- a/persistence-modules/java-jdbi/pom.xml
+++ b/persistence-modules/java-jdbi/pom.xml
@@ -1,8 +1,11 @@
-
+ 4.0.0
+ java-jdbi
+ 1.0-SNAPSHOT
+
parent-modules
com.baeldung
@@ -10,21 +13,16 @@
../../
- 4.0.0
-
- java-jdbi
- 1.0-SNAPSHOT
-
org.jdbi
jdbi3-core
- 3.1.0
+ ${jdbi3-core.version}
org.hsqldb
hsqldb
- 2.4.0
+ ${hsqldb.version}
test
@@ -37,4 +35,10 @@
default
+
+
+ 3.1.0
+ 2.4.0
+
+
\ No newline at end of file
diff --git a/persistence-modules/java-mongodb/pom.xml b/persistence-modules/java-mongodb/pom.xml
index 9784b2c5a8..ba8fabb9a5 100644
--- a/persistence-modules/java-mongodb/pom.xml
+++ b/persistence-modules/java-mongodb/pom.xml
@@ -1,6 +1,6 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4.0.0
com.baeldung
@@ -11,9 +11,9 @@
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
-
-
+ ../../
+
+
@@ -32,41 +32,6 @@
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*ManualTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
-
1.8
1.8
diff --git a/persistence-modules/liquibase/pom.xml b/persistence-modules/liquibase/pom.xml
index a70483437f..a18ced0d71 100644
--- a/persistence-modules/liquibase/pom.xml
+++ b/persistence-modules/liquibase/pom.xml
@@ -1,42 +1,31 @@
-
+
+ 4.0.0
+ liquibase
+
parent-modules
com.baeldung
1.0.0-SNAPSHOT
- ../../
+ ../../
- 4.0.0
-
- liquibase
mysql
mysql-connector-java
- 5.1.6
+ ${mysql-connector-java.version}
baeldung-liquibase-demo
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.7.0
-
- 1.8
- 1.8
-
-
-
org.liquibase
liquibase-maven-plugin
- 3.4.2
+ ${liquibase-maven-plugin.version}
liquibase/liquibase.properties
liquibase/db-changelog.xml
@@ -45,4 +34,9 @@
+
+ 5.1.6
+ 3.4.2
+
+
\ No newline at end of file
diff --git a/persistence-modules/querydsl/pom.xml b/persistence-modules/querydsl/pom.xml
index c2943875f1..4c20d673a3 100644
--- a/persistence-modules/querydsl/pom.xml
+++ b/persistence-modules/querydsl/pom.xml
@@ -1,13 +1,11 @@
+ 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
querydsl
0.1-SNAPSHOT
jar
-
querydsl
http://maven.apache.org
@@ -15,23 +13,9 @@
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
+ ../../
-
- UTF-8
- 1.8
- 4.3.4.RELEASE
- 5.2.5.Final
- 1.0.0.Final
- 4.1.4
- 2.3.4
- 1.6
- 1.4
-
- 1.1.3
-
-
@@ -128,8 +112,6 @@
-
-
@@ -164,39 +146,17 @@
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
+
+ UTF-8
+ 1.8
+ 4.3.4.RELEASE
+ 5.2.5.Final
+ 1.0.0.Final
+ 4.1.4
+ 2.3.4
+ 1.6
+ 1.4
+ 1.1.3
+
\ No newline at end of file
diff --git a/persistence-modules/redis/pom.xml b/persistence-modules/redis/pom.xml
index 1f27faa09a..7f7aeda4ad 100644
--- a/persistence-modules/redis/pom.xml
+++ b/persistence-modules/redis/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="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4.0.0
com.baeldung
@@ -15,7 +15,7 @@
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
+ ../../
diff --git a/persistence-modules/solr/pom.xml b/persistence-modules/solr/pom.xml
index 966bd8755b..34a9722af3 100644
--- a/persistence-modules/solr/pom.xml
+++ b/persistence-modules/solr/pom.xml
@@ -1,5 +1,5 @@
+ 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
@@ -12,7 +12,7 @@
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
+ ../../
diff --git a/persistence-modules/spring-data-cassandra/pom.xml b/persistence-modules/spring-data-cassandra/pom.xml
index 1358210a45..540b7ad7b9 100644
--- a/persistence-modules/spring-data-cassandra/pom.xml
+++ b/persistence-modules/spring-data-cassandra/pom.xml
@@ -1,33 +1,19 @@
+ 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-data-cassandra
0.0.1-SNAPSHOT
jar
-
spring-data-cassandra
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
+ ../../
-
- UTF-8
-
- 4.3.4.RELEASE
- 1.3.2.RELEASE
- 2.1.5
- 2.1.9.2
- 2.1.9.2
- 2.0-0
- 19.0
-
-
org.springframework.data
@@ -88,38 +74,15 @@
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
+
+ UTF-8
+ 4.3.4.RELEASE
+ 1.3.2.RELEASE
+ 2.1.5
+ 2.1.9.2
+ 2.1.9.2
+ 2.0-0
+ 19.0
+
+
diff --git a/persistence-modules/spring-data-dynamodb/pom.xml b/persistence-modules/spring-data-dynamodb/pom.xml
index c3ea9abf08..b115c0e087 100644
--- a/persistence-modules/spring-data-dynamodb/pom.xml
+++ b/persistence-modules/spring-data-dynamodb/pom.xml
@@ -1,5 +1,5 @@
+ 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-dynamodb
@@ -15,20 +15,6 @@
../../parent-boot-5
-
-
- com.baeldung.Application
- 4.3.4.RELEASE
- 4.5.2
- 4.4.1
- 1.11.64
- 3.3.7-1
- 1.0.392
- 1.11.106
- 1.11.86
- https://s3-us-west-2.amazonaws.com/dynamodb-local/release
-
-
@@ -50,22 +36,18 @@
org.springframework.boot
spring-boot-starter-actuator
-
org.springframework.boot
spring-boot-starter-security
-
io.dropwizard.metrics
metrics-core
-
com.h2database
h2
-
org.springframework.boot
spring-boot-starter
@@ -79,13 +61,11 @@
org.springframework.boot
spring-boot-starter-mail
-
org.webjars
bootstrap
${bootstrap.version}
-
com.amazonaws
aws-java-sdk-dynamodb
@@ -108,7 +88,7 @@
${httpclient.version}
-
+
com.amazonaws
@@ -170,7 +150,6 @@
-
org.apache.maven.plugins
maven-war-plugin
@@ -194,9 +173,7 @@
-
-
@@ -241,4 +218,19 @@
+
+
+
+ com.baeldung.Application
+ 4.3.4.RELEASE
+ 4.5.2
+ 4.4.1
+ 1.11.64
+ 3.3.7-1
+ 1.0.392
+ 1.11.106
+ 1.11.86
+ https://s3-us-west-2.amazonaws.com/dynamodb-local/release
+
+
diff --git a/persistence-modules/spring-data-eclipselink/pom.xml b/persistence-modules/spring-data-eclipselink/pom.xml
index 65793fd1e0..524175fcd4 100644
--- a/persistence-modules/spring-data-eclipselink/pom.xml
+++ b/persistence-modules/spring-data-eclipselink/pom.xml
@@ -1,80 +1,79 @@
- 4.0.0
+ 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-data-eclipselink
+ 1.0.0-SNAPSHOT
+ spring-data-eclipselink
- com.baeldung
- spring-data-eclipselink
- 1.0.0-SNAPSHOT
-
- spring-data-eclipselink
-
-
+
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
+ ../../
-
- UTF-8
- UTF-8
- 1.8
- 1.5.9.RELEASE
- 2.7.0
- 1.4.196
-
-
-
-
+
+
org.springframework.boot
spring-boot-dependencies
${spring.version}
pom
import
-
- org.springframework.boot
- spring-boot-starter-data-jpa
- ${spring.version}
-
-
- org.hibernate
- hibernate-entitymanager
-
-
- org.hibernate
- hibernate-core
-
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- ${spring.version}
- test
-
-
- org.eclipse.persistence
- org.eclipse.persistence.jpa
- ${eclipselink.version}
-
-
- com.h2database
- h2
- runtime
- ${h2.version}
-
-
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+ ${spring.version}
+
+
+ org.hibernate
+ hibernate-entitymanager
+
+
+ org.hibernate
+ hibernate-core
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ ${spring.version}
+ test
+
+
+ org.eclipse.persistence
+ org.eclipse.persistence.jpa
+ ${eclipselink.version}
+
+
+ com.h2database
+ h2
+ runtime
+ ${h2.version}
+
+
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
- ${spring.version}
-
-
-
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ ${spring.version}
+
+
+
+
+
+
+ UTF-8
+ UTF-8
+ 1.8
+ 1.5.9.RELEASE
+ 2.7.0
+ 1.4.196
+
diff --git a/persistence-modules/spring-data-gemfire/pom.xml b/persistence-modules/spring-data-gemfire/pom.xml
index 3f7fcd03e5..479eb0c55f 100644
--- a/persistence-modules/spring-data-gemfire/pom.xml
+++ b/persistence-modules/spring-data-gemfire/pom.xml
@@ -1,8 +1,7 @@
+ 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-data-gemfire
1.0.0-SNAPSHOT
@@ -12,17 +11,9 @@
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
+ ../../
-
- 1.7.4.RELEASE
- 7.0.1
- 1.0
- 4.3.0.RELEASE
- 4.3.0.RELEASE
-
-
org.springframework.data
@@ -76,4 +67,12 @@
+
+ 1.7.4.RELEASE
+ 7.0.1
+ 1.0
+ 4.3.0.RELEASE
+ 4.3.0.RELEASE
+
+
\ No newline at end of file
diff --git a/persistence-modules/spring-data-neo4j/pom.xml b/persistence-modules/spring-data-neo4j/pom.xml
index bdd51e9659..3405e98edb 100644
--- a/persistence-modules/spring-data-neo4j/pom.xml
+++ b/persistence-modules/spring-data-neo4j/pom.xml
@@ -1,5 +1,5 @@
+ 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
@@ -10,7 +10,7 @@
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
+ ../../
@@ -117,48 +117,9 @@
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
-
- 1.8
- 1.8
- 1.8
UTF-8
UTF-8
-
1.1.1
3.1.0
4.1.6.RELEASE
diff --git a/persistence-modules/spring-data-redis/pom.xml b/persistence-modules/spring-data-redis/pom.xml
index 0b9075147d..55f1124531 100644
--- a/persistence-modules/spring-data-redis/pom.xml
+++ b/persistence-modules/spring-data-redis/pom.xml
@@ -1,5 +1,5 @@
+ 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
@@ -11,20 +11,9 @@
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
+ ../../
-
- UTF-8
- 5.0.3.RELEASE
- 2.0.3.RELEASE
- 3.2.4
- 2.9.0
- 0.10.0
- 2.0.3.RELEASE
-
-
-
org.springframework.data
@@ -75,12 +64,22 @@
nosqlunit-redis
${nosqlunit.version}
-
+
- org.springframework.data
- spring-data-commons
- ${spring-data-commons.version}
-
+ org.springframework.data
+ spring-data-commons
+ ${spring-data-commons.version}
+
+
+ UTF-8
+ 5.0.3.RELEASE
+ 2.0.3.RELEASE
+ 3.2.4
+ 2.9.0
+ 0.10.0
+ 2.0.3.RELEASE
+
+
diff --git a/persistence-modules/spring-data-solr/pom.xml b/persistence-modules/spring-data-solr/pom.xml
index e24d8314ba..e687ee5f1f 100644
--- a/persistence-modules/spring-data-solr/pom.xml
+++ b/persistence-modules/spring-data-solr/pom.xml
@@ -1,5 +1,5 @@
+ 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
@@ -12,15 +12,9 @@
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
+ ../../
-
- UTF-8
- 4.3.4.RELEASE
- 2.0.5.RELEASE
-
-
org.springframework
@@ -51,4 +45,10 @@
+
+ UTF-8
+ 4.3.4.RELEASE
+ 2.0.5.RELEASE
+
+
\ No newline at end of file
diff --git a/persistence-modules/spring-hibernate-3/pom.xml b/persistence-modules/spring-hibernate-3/pom.xml
index f1873a84d3..3233dd11fe 100644
--- a/persistence-modules/spring-hibernate-3/pom.xml
+++ b/persistence-modules/spring-hibernate-3/pom.xml
@@ -1,37 +1,31 @@
+ 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-hibernate-3
0.1-SNAPSHOT
-
spring-hibernate-3
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
+ ../../
-
-
org.springframework
spring-context
${org.springframework.version}
-
-
org.springframework
spring-orm
${org.springframework.version}
-
org.hibernate
hibernate-core
@@ -48,43 +42,35 @@
${mysql-connector-java.version}
runtime
-
org.apache.tomcat
tomcat-dbcp
${tomcat-dbcp.version}
-
com.h2database
h2
${h2.version}
-
-
com.google.guava
guava
${guava.version}
-
-
org.apache.commons
commons-lang3
${commons-lang3.version}
test
-
org.springframework
spring-test
${org.springframework.version}
test
-
@@ -95,72 +81,29 @@
true
-
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
-
4.3.4.RELEASE
4.2.0.RELEASE
3.21.0-GA
-
3.6.10.Final
5.1.40
8.5.8
1.4.193
-
5.3.3.Final
-
19.0
3.5
-
4.4.5
4.5.2
-
2.9.0
-
2.7
1.6.1
-
diff --git a/persistence-modules/spring-hibernate-5/README.md b/persistence-modules/spring-hibernate-5/README.md
index 01a1ad7121..d48723ac31 100644
--- a/persistence-modules/spring-hibernate-5/README.md
+++ b/persistence-modules/spring-hibernate-5/README.md
@@ -2,3 +2,4 @@
- [Guide to @Immutable Annotation in Hibernate](http://www.baeldung.com/hibernate-immutable)
- [Hibernate Many to Many Annotation Tutorial](http://www.baeldung.com/hibernate-many-to-many)
+- [Programmatic Transactions in the Spring TestContext Framework](http://www.baeldung.com/spring-test-programmatic-transactions)
diff --git a/persistence-modules/spring-hibernate-5/pom.xml b/persistence-modules/spring-hibernate-5/pom.xml
index 86e952c0e4..de66d9e6f7 100644
--- a/persistence-modules/spring-hibernate-5/pom.xml
+++ b/persistence-modules/spring-hibernate-5/pom.xml
@@ -1,17 +1,16 @@
+ 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-hibernate-5
0.1-SNAPSHOT
-
spring-hibernate-5
com.baeldung
parent-modules
1.0.0-SNAPSHOT
- ../../
+ ../../
@@ -126,8 +125,8 @@
hsqldb
${hsqldb.version}
-
-
+
+
mysql
mysql-connector-java
${mysql-connector-java.version}
@@ -149,58 +148,28 @@
true
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
- 1.8
- 1.8
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
5.0.2.RELEASE
-
- 1.10.6.RELEASE
-
+ 1.10.6.RELEASE
4.2.1.RELEASE
1.10.6.RELEASE
-
5.2.10.Final
5.8.2.Final
- 8.0.7-dmr
+ 8.0.7-dmr
9.0.0.M26
1.1
2.3.4
1.4.195
-
1.7.21
1.1.7
-
+
5.4.0.Final
2.2.5
@@ -209,14 +178,11 @@
21.0
3.5
-
1.3
4.12
-
4.4.1
4.5
-
2.9.0
diff --git a/persistence-modules/spring-jpa/pom.xml b/persistence-modules/spring-jpa/pom.xml
index bc0b2381f3..065b29b26b 100644
--- a/persistence-modules/spring-jpa/pom.xml
+++ b/persistence-modules/spring-jpa/pom.xml
@@ -1,203 +1,192 @@
- 4.0.0
+ 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-jpa
+ 0.1-SNAPSHOT
+ war
+ spring-jpa
- com.baeldung
- spring-jpa
- 0.1-SNAPSHOT
- war
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+ ../../
+
- spring-jpa
+
+
+
+ org.springframework
+ spring-orm
+ ${org.springframework.version}
+
+
+ commons-logging
+ commons-logging
+
+
+
+
+ org.springframework
+ spring-context
+ ${org.springframework.version}
+
+
+ org.springframework
+ spring-webmvc
+ ${org.springframework.version}
+
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
- ../../
-
+
-
+
+ org.hibernate
+ hibernate-entitymanager
+ ${hibernate.version}
+
+
+ org.hibernate
+ hibernate-ehcache
+ ${hibernate.version}
+
+
+ xml-apis
+ xml-apis
+ ${xml-apis.version}
+
+
+ org.javassist
+ javassist
+ ${javassist.version}
+
+
+ mysql
+ mysql-connector-java
+ ${mysql-connector-java.version}
+ runtime
+
+
+ org.springframework.data
+ spring-data-jpa
+ ${spring-data-jpa.version}
+
+
+ com.h2database
+ h2
+ ${h2.version}
+
-
+
-
- org.springframework
- spring-orm
- ${org.springframework.version}
-
-
- commons-logging
- commons-logging
-
-
-
-
- org.springframework
- spring-context
- ${org.springframework.version}
-
-
- org.springframework
- spring-webmvc
- ${org.springframework.version}
-
+
+ org.hibernate
+ hibernate-validator
+ ${hibernate-validator.version}
+
+
+ javax.el
+ javax.el-api
+ ${javax.el-api.version}
+
-
-
-
- org.hibernate
- hibernate-entitymanager
- ${hibernate.version}
-
-
- org.hibernate
- hibernate-ehcache
- ${hibernate.version}
-
-
- xml-apis
- xml-apis
- ${xml-apis.version}
-
-
- org.javassist
- javassist
- ${javassist.version}
-
-
- mysql
- mysql-connector-java
- ${mysql-connector-java.version}
- runtime
-
-
- org.springframework.data
- spring-data-jpa
- ${spring-data-jpa.version}
-
-
- com.h2database
- h2
- ${h2.version}
-
-
-
-
-
- org.hibernate
- hibernate-validator
- ${hibernate-validator.version}
-
-
- javax.el
- javax.el-api
- ${javax.el-api.version}
-
-
-
-
- javax.servlet
- jstl
- ${javax.servlet.jstl.version}
-
-
- javax.servlet
- servlet-api
+
+
+ javax.servlet
+ jstl
+ ${javax.servlet.jstl.version}
+
+
+ javax.servlet
+ servlet-api
provided
- ${javax.servlet.servlet-api.version}
-
+ ${javax.servlet.servlet-api.version}
+
-
+
-
- com.google.guava
- guava
- ${guava.version}
-
+
+ com.google.guava
+ guava
+ ${guava.version}
+
org.assertj
assertj-core
${assertj.version}
-
+
-
- org.apache.commons
- commons-lang3
- ${commons-lang3.version}
- test
-
+
+ org.apache.commons
+ commons-lang3
+ ${commons-lang3.version}
+ test
+
-
- org.springframework
- spring-test
- ${org.springframework.version}
- test
-
+
+ org.springframework
+ spring-test
+ ${org.springframework.version}
+ test
+
-
+
-
- spring-jpa
-
-
- src/main/resources
- true
-
-
+
+ spring-jpa
+
+
+ src/main/resources
+ true
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ ${maven-war-plugin.version}
+
+ src/main/webapp
+ false
+
+
+
+
-
+
+
+ 4.3.8.RELEASE
+ 3.21.0-GA
-
- org.apache.maven.plugins
- maven-war-plugin
- ${maven-war-plugin.version}
-
- src/main/webapp
- false
-
-
+
+ 5.2.10.Final
+ 6.0.6
+ 1.11.3.RELEASE
+ 1.4.195
-
+
+ 1.2
+ 2.5
-
+
+ 5.4.1.Final
+ 1.4.01
+ 2.2.5
-
-
- 4.3.8.RELEASE
- 3.21.0-GA
+
+ 21.0
+ 3.5
+ 3.8.0
+ 4.4.5
+ 4.5.2
+ 2.9.0
-
- 5.2.10.Final
- 6.0.6
- 1.11.3.RELEASE
- 1.4.195
-
-
- 1.2
- 2.5
-
-
- 5.4.1.Final
- 1.4.01
- 2.2.5
-
-
- 21.0
- 3.5
- 3.8.0
-
- 4.4.5
- 4.5.2
-
- 2.9.0
-
-
- 2.7
- 1.6.1
- 2.6
-
-
+
+ 2.7
+ 1.6.1
+ 2.6
+
\ No newline at end of file
diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/config/PersistenceConfig.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/config/PersistenceConfig.java
new file mode 100644
index 0000000000..99f50abf4c
--- /dev/null
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/config/PersistenceConfig.java
@@ -0,0 +1,28 @@
+package com.baeldung.jdbc.autogenkey.config;
+
+import javax.sql.DataSource;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.env.Environment;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+
+@Configuration
+public class PersistenceConfig {
+
+ @Bean
+ public DataSource dataSource(Environment env) {
+ return new EmbeddedDatabaseBuilder()
+ .setType(EmbeddedDatabaseType.H2)
+ .addScript("autogenkey-schema.sql")
+ .build();
+ }
+
+ @Bean
+ public JdbcTemplate jdbcTemplate(DataSource dataSource) {
+ return new JdbcTemplate(dataSource);
+ }
+
+}
diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java
new file mode 100644
index 0000000000..cf0dbe4681
--- /dev/null
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java
@@ -0,0 +1,38 @@
+package com.baeldung.jdbc.autogenkey.repository;
+
+import java.sql.PreparedStatement;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.GeneratedKeyHolder;
+import org.springframework.jdbc.support.KeyHolder;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class MessageRepositoryJDBCTemplate {
+
+ @Autowired
+ JdbcTemplate jdbcTemplate;
+
+ final String INSERT_MESSAGE_SQL = "insert into sys_message (message) values(?) ";
+
+ public long insert(final String message) {
+
+ KeyHolder keyHolder = new GeneratedKeyHolder();
+
+ jdbcTemplate.update(connection -> {
+ PreparedStatement ps = connection.prepareStatement(INSERT_MESSAGE_SQL);
+ ps.setString(1, message);
+ return ps;
+ }, keyHolder);
+
+ return (long) keyHolder.getKey();
+ }
+
+ final String SELECT_BY_ID = "select message from sys_message where id = ?";
+
+ public String getMessageById(long id) {
+ return this.jdbcTemplate.queryForObject(SELECT_BY_ID, String.class, new Object[] { id });
+ }
+
+}
diff --git a/persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java b/persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java
new file mode 100644
index 0000000000..022ea29ed6
--- /dev/null
+++ b/persistence-modules/spring-jpa/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java
@@ -0,0 +1,29 @@
+package com.baeldung.jdbc.autogenkey.repository;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class MessageRepositorySimpleJDBCInsert {
+
+ SimpleJdbcInsert messageInsert;
+
+ @Autowired
+ public MessageRepositorySimpleJDBCInsert(DataSource dataSource) {
+ messageInsert = new SimpleJdbcInsert(dataSource).withTableName("sys_message").usingGeneratedKeyColumns("id");
+ }
+
+ public long insert(String message) {
+ Map parameters = new HashMap(1);
+ parameters.put("message", message);
+ Number newId = messageInsert.executeAndReturnKey(parameters);
+ return (long) newId;
+ }
+
+}
diff --git a/persistence-modules/spring-jpa/src/main/resources/autogenkey-schema.sql b/persistence-modules/spring-jpa/src/main/resources/autogenkey-schema.sql
new file mode 100644
index 0000000000..925b27143c
--- /dev/null
+++ b/persistence-modules/spring-jpa/src/main/resources/autogenkey-schema.sql
@@ -0,0 +1,5 @@
+CREATE TABLE IF NOT EXISTS sys_message (
+ id bigint(20) NOT NULL AUTO_INCREMENT,
+ message varchar(100) NOT NULL,
+ PRIMARY KEY (id)
+);
\ No newline at end of file
diff --git a/persistence-modules/spring-jpa/src/test/java/com/baeldung/jdbc/autogenkey/GetAutoGenKeyByJDBC.java b/persistence-modules/spring-jpa/src/test/java/com/baeldung/jdbc/autogenkey/GetAutoGenKeyByJDBC.java
new file mode 100644
index 0000000000..aa4d061997
--- /dev/null
+++ b/persistence-modules/spring-jpa/src/test/java/com/baeldung/jdbc/autogenkey/GetAutoGenKeyByJDBC.java
@@ -0,0 +1,49 @@
+package com.baeldung.jdbc.autogenkey;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.jdbc.autogenkey.repository.MessageRepositoryJDBCTemplate;
+import com.baeldung.jdbc.autogenkey.repository.MessageRepositorySimpleJDBCInsert;
+
+@RunWith(SpringRunner.class)
+public class GetAutoGenKeyByJDBC {
+
+ @Configuration
+ @ComponentScan(basePackages = { "com.baeldung.jdbc.autogenkey" })
+ public static class SpringConfig {
+
+ }
+
+ @Autowired
+ MessageRepositorySimpleJDBCInsert messageRepositorySimpleJDBCInsert;
+
+ @Autowired
+ MessageRepositoryJDBCTemplate messageRepositoryJDBCTemplate;
+
+ final String MESSAGE_CONTENT = "Test";
+
+ @Test
+ public void insertJDBC_whenLoadMessageByKey_thenGetTheSameMessage() {
+ long key = messageRepositoryJDBCTemplate.insert(MESSAGE_CONTENT);
+ String loadedMessage = messageRepositoryJDBCTemplate.getMessageById(key);
+
+ assertEquals(MESSAGE_CONTENT, loadedMessage);
+
+ }
+
+ @Test
+ public void insertSimpleInsert_whenLoadMessageKey_thenGetTheSameMessage() {
+ long key = messageRepositorySimpleJDBCInsert.insert(MESSAGE_CONTENT);
+ String loadedMessage = messageRepositoryJDBCTemplate.getMessageById(key);
+
+ assertEquals(MESSAGE_CONTENT, loadedMessage);
+ }
+
+}
diff --git a/pmd/custom-pmd-0.0.1.jar b/pmd/custom-pmd-0.0.1.jar
new file mode 100644
index 0000000000..f7ae74ae2e
Binary files /dev/null and b/pmd/custom-pmd-0.0.1.jar differ
diff --git a/pom.xml b/pom.xml
index 8b91a8e8df..0326c3e0b8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,32 +1,13 @@
-
+
4.0.0
com.baeldung
parent-modules
1.0.0-SNAPSHOT
-
parent-modules
pom
-
- UTF-8
- refs/heads/master
- true
- false
- false
-
- 4.12
- 1.3
- 2.8.9
-
- 1.7.21
- 1.1.7
-
- 2.21.0
- 3.7.0
- 1.6.0
-
-
parent-boot-5
asm
@@ -47,29 +28,22 @@
autovalue
axon
bootique
-
cdi
-
+
core-java
core-java-io
core-java-8
+
core-groovy
core-java-concurrency
-
couchbase
-
deltaspike
dozer
-
ethereumj
-
-
-
+
feign
flips
-
-
-
+
geotools
testing-modules/groovy-spock
google-cloud
@@ -80,20 +54,17 @@
guava-modules/guava-21
guice
disruptor
-
handling-spring-static-resources
hazelcast
hbase
httpclient
hystrix
-
-
+
immutables
influxdb
-
jackson
-
+
vavr
java-lite
java-rmi
@@ -101,9 +72,10 @@
javax-servlets
javaxval
jaxb
+ javafx
jgroups
jee-7
-
+
jjwt
jpa-storedprocedure
jsf
@@ -112,8 +84,7 @@
jsoup
testing-modules/junit-5
jws
-
- libraries
+
libraries-data
linkrest
logging-modules/log-mdc
@@ -121,9 +92,8 @@
logging-modules/log4j2
logging-modules/logback
lombok
-
mapstruct
-
+ metrics
maven
mesos-marathon
testing-modules/mockito
@@ -135,14 +105,10 @@
orientdb
osgi
orika
-
patterns
pdf
protobuffer
-
persistence-modules/querydsl
-
-
reactor-core
persistence-modules/redis
testing-modules/rest-assured
@@ -157,7 +123,7 @@
spring-5
spring-5-reactive
spring-5-mvc
-
+ spring-5-security
spring-activiti
spring-akka
spring-amqp
@@ -196,7 +162,7 @@
spring-integration
spring-jenkins-pipeline
spring-jersey
-
+
spring-jms
spring-jooq
persistence-modules/spring-jpa
@@ -256,21 +222,15 @@
spring-reactor
spring-vertx
spring-jinq
-
spring-rest-embedded-tomcat
-
-
testing-modules/testing
testing-modules/testng
-
video-tutorials
-
xml
xmlunit-2
struts-2
apache-velocity
apache-solrj
-
rabbitmq
vertx
persistence-modules/spring-data-gemfire
@@ -287,7 +247,7 @@
lucene
vraptor
persistence-modules/java-cockroachdb
- spring-security-thymeleaf
+ spring-security-thymeleaf
persistence-modules/java-jdbi
jersey
java-spi
@@ -351,7 +311,6 @@
-
org.codehaus.mojo
exec-maven-plugin
@@ -360,7 +319,6 @@
maven
-
org.apache.maven.plugins
maven-surefire-plugin
@@ -377,7 +335,6 @@
-
org.apache.maven.plugins
maven-compiler-plugin
@@ -387,9 +344,84 @@
1.8
-
+
+ org.apache.maven.plugins
+ maven-pmd-plugin
+ 3.9.0
+
+
+ org.baeldung.pmd
+ custom-pmd
+ 0.0.1
+
+
+
+ 5
+ true
+ false
+ true
+ true
+ true
+ UTF-8
+ 1.8
+
+ ${tutorialsproject.basedir}/baeldung-pmd-rules.xml
+
+
+
+
+ compile
+
+ check
+
+
+
+
+
+ org.commonjava.maven.plugins
+ directory-maven-plugin
+ 0.3.1
+
+
+ directories
+
+ directory-of
+
+ validate
+
+ tutorialsproject.basedir
+
+ com.baeldung
+ parent-modules
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-install-plugin
+ 2.5.1
+
+ org.baeldung.pmd
+ custom-pmd
+ 0.0.1
+ jar
+ ${tutorialsproject.basedir}/custom-pmd-0.0.1.jar
+ true
+
+
+
+ install-jar-lib
+
+ install-file
+
+ validate
+
+
+
-
+
com.vackosar.gitflowincrementalbuilder
@@ -397,7 +429,91 @@
3.4
-
+
-
-
+
+
+
+ integration
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ integration-test
+
+ test
+
+
+
+ **/*ManualTest.java
+ **/*LiveTest.java
+
+
+ **/*IntegrationTest.java
+
+
+
+
+
+
+ json
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jxr-plugin
+ 2.3
+
+
+
+
+
+ UTF-8
+ refs/heads/master
+ true
+ false
+ false
+
+ 4.12
+ 1.3
+ 2.8.9
+
+ 1.7.21
+ 1.1.7
+
+ 2.21.0
+ 3.7.0
+ 1.6.0
+ 1.8
+ 1.2.17
+ 1.1
+ 2.1.0.1
+ 1.19
+ 1.19
+ 1.3
+ 1.6.0
+ 2.19.1
+ 2.5
+ 1.4
+ 2.6
+ 3.1.0
+ 1.2
+ 2.3.1
+ 1.9.13
+ 1.2
+ 2.5.0
+ 1.3
+
+
+
\ No newline at end of file
diff --git a/protobuffer/pom.xml b/protobuffer/pom.xml
index 52838f5de9..919a49e67d 100644
--- a/protobuffer/pom.xml
+++ b/protobuffer/pom.xml
@@ -1,14 +1,14 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ protobuffer
+
parent-modules
com.baeldung
1.0.0-SNAPSHOT
- 4.0.0
-
- protobuffer
diff --git a/rabbitmq/pom.xml b/rabbitmq/pom.xml
index 151f214a91..391d7933ea 100644
--- a/rabbitmq/pom.xml
+++ b/rabbitmq/pom.xml
@@ -1,13 +1,12 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4.0.0
com.baeldung
rabbitmq
0.1-SNAPSHOT
-
rabbitmq
http://maven.apache.org
@@ -21,12 +20,13 @@
com.rabbitmq
amqp-client
- 3.6.6
+ ${amqp-client.version}
UTF-8
+ 3.6.6
\ No newline at end of file
diff --git a/ratpack/pom.xml b/ratpack/pom.xml
index 3f953b3ed0..bf43168b02 100644
--- a/ratpack/pom.xml
+++ b/ratpack/pom.xml
@@ -8,13 +8,6 @@
ratpack
http://maven.apache.org
-
- UTF-8
- 1.8
- 1.8
- 1.4.6
-
-
com.baeldung
parent-modules
@@ -22,14 +15,12 @@
-
io.ratpack
ratpack-spring-boot-starter
${ratpack.version}
pom
-
io.ratpack
ratpack-core
@@ -59,18 +50,17 @@
com.h2database
h2
- 1.4.193
+ ${h2database.version}
-
org.apache.httpcomponents
httpclient
- 4.5.3
+ ${httpclient.version}
org.apache.httpcomponents
httpcore
- 4.4.6
+ ${httpcore.version}
@@ -83,4 +73,14 @@
+
+ UTF-8
+ 1.8
+ 1.8
+ 1.4.6
+ 4.5.3
+ 4.4.6
+ 1.4.193
+
+
diff --git a/reactor-core/README.md b/reactor-core/README.md
index 9d952ec84c..6f90e59894 100644
--- a/reactor-core/README.md
+++ b/reactor-core/README.md
@@ -1,3 +1,4 @@
### Relevant articles
- [Intro To Reactor Core](http://www.baeldung.com/reactor-core)
+- [Combining Publishers in Project Reactor](http://www.baeldung.com/reactor-combine-streams)
diff --git a/reactor-core/pom.xml b/reactor-core/pom.xml
index d387471d56..41c42cac28 100644
--- a/reactor-core/pom.xml
+++ b/reactor-core/pom.xml
@@ -1,5 +1,5 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.baeldung
@@ -13,7 +13,6 @@
-
io.projectreactor
reactor-core
@@ -26,13 +25,12 @@
${assertj.version}
test
-
-
+
io.projectreactor
- reactor-test
+ reactor-test
${reactor-core.version}
- test
-
+ test
+
diff --git a/reactor-core/src/test/java/com/baeldung/reactor/core/CombiningPublishersTest.java b/reactor-core/src/test/java/com/baeldung/reactor/core/CombiningPublishersTest.java
index 41769b1b35..5a0dcef5ba 100644
--- a/reactor-core/src/test/java/com/baeldung/reactor/core/CombiningPublishersTest.java
+++ b/reactor-core/src/test/java/com/baeldung/reactor/core/CombiningPublishersTest.java
@@ -32,7 +32,7 @@ public class CombiningPublishersTest {
}
- @Test
+ /*@Test
public void givenFluxes_whenMergeWithDelayedElementsIsInvoked_thenMergeWithDelayedElements() {
Flux fluxOfIntegers = Flux.merge(
evenNumbers.delayElements(Duration.ofMillis(2000L)),
@@ -46,7 +46,7 @@ public class CombiningPublishersTest {
.expectNext(4)
.expectComplete()
.verify();
- }
+ }*/
@Test
public void givenFluxes_whenConcatIsInvoked_thenConcat() {
diff --git a/rest-with-spark-java/pom.xml b/rest-with-spark-java/pom.xml
index 2364154fdc..ffdb86ebca 100644
--- a/rest-with-spark-java/pom.xml
+++ b/rest-with-spark-java/pom.xml
@@ -1,38 +1,47 @@
- 4.0.0
-
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ 4.0.0
com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
- com.baeldung
- rest-with-spark-java
- 1.0-SNAPSHOT
- rest-with-spark-java
- http://maven.apache.org
-
-
- junit
- junit
- 3.8.1
- test
-
-
- com.sparkjava
- spark-core
- 2.5.4
-
-
- com.fasterxml.jackson.core
- jackson-core
- 2.8.6
-
-
- com.fasterxml.jackson.core
- jackson-databind
- 2.8.6
-
-
+ rest-with-spark-java
+ 1.0-SNAPSHOT
+ rest-with-spark-java
+ http://maven.apache.org
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+
+ junit
+ junit
+ ${junit.version}
+ test
+
+
+ com.sparkjava
+ spark-core
+ ${spark-core.version}
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ ${jackson-core.version}
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${jackson-databind.version}
+
+
+
+
+ 2.5.4
+ 2.8.6
+ 2.8.6
+
+
diff --git a/resteasy/bin/pom.xml b/resteasy/bin/pom.xml
index 2e1f839a55..f8cdc20360 100644
--- a/resteasy/bin/pom.xml
+++ b/resteasy/bin/pom.xml
@@ -1,6 +1,6 @@
+ 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
@@ -14,6 +14,12 @@
1.6.1
+
+ com.baeldung
+ resteasy-tutorial
+ 1.0
+
+
RestEasyTutorial
@@ -73,66 +79,5 @@
commons-io
${commons-io.version}
-
-
-
-
- live
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*IntegrationTest.java
-
-
- **/*LiveTest.java
-
-
-
-
-
-
- json
-
-
-
-
- org.codehaus.cargo
- cargo-maven2-plugin
- ${cargo-maven2-plugin.version}
-
- false
-
-
-
- start-server
- pre-integration-test
-
- start
-
-
-
- stop-server
- post-integration-test
-
- stop
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/resteasy/pom.xml b/resteasy/pom.xml
index 94be91243a..61c099f110 100644
--- a/resteasy/pom.xml
+++ b/resteasy/pom.xml
@@ -1,6 +1,6 @@
+ 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
@@ -14,12 +14,6 @@
1.0.0-SNAPSHOT
-
- 3.0.19.Final
- 2.5
- 1.6.1
-
-
RestEasyTutorial
@@ -44,9 +38,7 @@
-
-
org.jboss.resteasy
resteasy-servlet-initializer
@@ -93,9 +85,7 @@
live
-
-
org.apache.maven.plugins
maven-surefire-plugin
@@ -146,9 +136,15 @@
-
+
+
+ 3.0.19.Final
+ 2.5
+ 1.6.1
+
+
\ No newline at end of file
diff --git a/rule-engines/easy-rules/pom.xml b/rule-engines/easy-rules/pom.xml
index 78edc09d1a..8399eff8a2 100644
--- a/rule-engines/easy-rules/pom.xml
+++ b/rule-engines/easy-rules/pom.xml
@@ -1,24 +1,24 @@
- 4.0.0
+ 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.easyrules
- easy-rules
- 1.0
+ com.baeldung.easyrules
+ easy-rules
+ 1.0
- easy-rules
+ easy-rules
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
-
-
- org.jeasy
- easy-rules-core
- 3.0.0
-
-
+
+
+ org.jeasy
+ easy-rules-core
+ 3.0.0
+
+
\ No newline at end of file
diff --git a/rule-engines/openl-tablets/pom.xml b/rule-engines/openl-tablets/pom.xml
index e983d4e566..8e3f1965b5 100644
--- a/rule-engines/openl-tablets/pom.xml
+++ b/rule-engines/openl-tablets/pom.xml
@@ -1,29 +1,29 @@
- 4.0.0
+ 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.openltablets
- openl-tablets
- 1.0
+ com.baeldung.openltablets
+ openl-tablets
+ 1.0
- openl-tablets
+ openl-tablets
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
-
-
- org.openl
- org.openl.core
- 5.19.4
-
-
- org.openl.rules
- org.openl.rules
- 5.19.4
-
-
+
+
+ org.openl
+ org.openl.core
+ 5.19.4
+
+
+ org.openl.rules
+ org.openl.rules
+ 5.19.4
+
+
\ No newline at end of file
diff --git a/rule-engines/rulebook/pom.xml b/rule-engines/rulebook/pom.xml
index 711bee8c91..675776eb6f 100644
--- a/rule-engines/rulebook/pom.xml
+++ b/rule-engines/rulebook/pom.xml
@@ -1,24 +1,24 @@
- 4.0.0
+ 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.rulebook
- rulebook
- 1.0
+ com.baeldung.rulebook
+ rulebook
+ 1.0
- rulebook
+ rulebook
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
-
-
-
- com.deliveredtechnologies
- rulebook-core
- 0.6.2
-
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
+
+
+ com.deliveredtechnologies
+ rulebook-core
+ 0.6.2
+
+
\ No newline at end of file
diff --git a/rxjava/README.md b/rxjava/README.md
index c29217a80d..b92e7deaae 100644
--- a/rxjava/README.md
+++ b/rxjava/README.md
@@ -10,3 +10,7 @@
- [Schedulers in RxJava](http://www.baeldung.com/rxjava-schedulers)
- [Mathematical and Aggregate Operators in RxJava](http://www.baeldung.com/rxjava-math)
- [Combining Observables in RxJava](http://www.baeldung.com/rxjava-combine-observables)
+- [RxJava 2 – Flowable](http://www.baeldung.com/rxjava-2-flowable)
+- [RxJava StringObservable](http://www.baeldung.com/rxjava-string)
+- [RxJava Maybe](http://www.baeldung.com/rxjava-maybe)
+- [Introduction to RxRelay for RxJava](http://www.baeldung.com/rx-relay)
diff --git a/rxjava/pom.xml b/rxjava/pom.xml
index 9a07aba2a3..41f2c3f6f6 100644
--- a/rxjava/pom.xml
+++ b/rxjava/pom.xml
@@ -1,6 +1,6 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
rxjava
@@ -36,7 +36,7 @@
rxjava-string
1.1.1
-
+
junit
junit
@@ -50,17 +50,17 @@
1.7.0
- com.github.davidmoten
- rxjava-jdbc
- ${rx.java.jdbc.version}
-
-
- com.h2database
- h2
- ${h2.version}
- runtime
-
-
+ com.github.davidmoten
+ rxjava-jdbc
+ ${rx.java.jdbc.version}
+
+
+ com.h2database
+ h2
+ ${h2.version}
+ runtime
+
+
org.assertj
assertj-core
${assertj.version}
@@ -79,7 +79,7 @@
- 3.8.0
+ 3.8.0
1.2.5
0.7.11
1.4.196
diff --git a/saas/pom.xml b/saas/pom.xml
index b76b27011a..6b34b99a5d 100644
--- a/saas/pom.xml
+++ b/saas/pom.xml
@@ -1,84 +1,88 @@
- 4.0.0
- com.baeldung
- saas
- 0.1.0-SNAPSHOT
- jar
- saas
+ 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
+ saas
+ 0.1.0-SNAPSHOT
+ jar
+ saas
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
-
-
- com.atlassian.jira
- jira-rest-java-client-core
- 4.0.0
-
-
- com.atlassian.fugue
- fugue
- 2.6.1
-
-
- com.google.guava
- guava
- 19.0
-
+
+
+ com.atlassian.jira
+ jira-rest-java-client-core
+ ${jira-rest-java-client-core.version}
+
+
+ com.atlassian.fugue
+ fugue
+ ${atlassian.fugue.version}
+
+
+ com.google.guava
+ guava
+ ${guava.version}
+
+
-
+
+ saas
+
+
+ src/main/resources
+ true
+
+
-
- saas
-
-
- src/main/resources
- true
-
-
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ ${maven-compiler-plugin.version}
+
+ 1.8
+ 1.8
+
+
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- ${maven-compiler-plugin.version}
-
- 1.8
- 1.8
-
-
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.6.0
+
+ java
+ com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed
+
+ -Xmx300m
+ -XX:+UseParallelGC
+ -classpath
+
+ com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed
+
+
+
+
+
-
- org.codehaus.mojo
- exec-maven-plugin
- 1.6.0
-
- java
- com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed
-
- -Xmx300m
- -XX:+UseParallelGC
- -classpath
-
- com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed
-
-
-
-
+
+
+ atlassian-public
+ https://packages.atlassian.com/maven/repository/public
+
+
+
+
+
+ 3.7.0
+ 4.0.0
+ 2.6.1
+ 19.0
+
-
-
-
- atlassian-public
- https://packages.atlassian.com/maven/repository/public
-
-
-
-
- 3.7.0
-
\ No newline at end of file
diff --git a/spark-java/pom.xml b/spark-java/pom.xml
index 67f4765f38..d8243345c5 100644
--- a/spark-java/pom.xml
+++ b/spark-java/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="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4.0.0
com.baeldung
spark-java
@@ -15,22 +15,24 @@
1.0.0-SNAPSHOT
-
- UTF-8
- 1.8
- 1.8
-
com.sparkjava
spark-core
- 2.5.4
+ ${sparkjava.spark-core.version}
com.google.code.gson
gson
- 2.8.0
+ ${google.code.gson.version}
+
+
+ UTF-8
+ 2.5.4
+ 2.8.0
+
+
diff --git a/spring-4/README.md b/spring-4/README.md
index 0c62173b6a..9855a9254d 100644
--- a/spring-4/README.md
+++ b/spring-4/README.md
@@ -1,2 +1,3 @@
### Relevant Articles:
- [Guide to Flips For Spring](http://www.baeldung.com/guide-to-flips-for-spring/)
+- [A Guide to Flips for Spring](http://www.baeldung.com/flips-spring)
diff --git a/spring-4/pom.xml b/spring-4/pom.xml
index 8a57888e56..c81469d3eb 100644
--- a/spring-4/pom.xml
+++ b/spring-4/pom.xml
@@ -1,45 +1,40 @@
4.0.0
-
spring-4
spring-4
0.0.1-SNAPSHOT
jar
-
spring-4
-
- UTF-8
- 1.8
- 1.8
-
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.10.RELEASE
+
+
-
org.springframework.boot
spring-boot-starter-web
- 1.5.10.RELEASE
+ ${spring-boot-starter-web.version}
-
org.springframework.boot
spring-boot-starter-test
- 1.5.9.RELEASE
+ ${spring-boot-starter-test.version}
-
com.github.feature-flip
flips-web
- 1.0.1
+ ${flips-web.version}
-
org.projectlombok
lombok
- 1.16.18
+ ${lombok.version}
provided
@@ -59,4 +54,14 @@
+
+
+ UTF-8
+ 1.5.10.RELEASE
+ 1.5.9.RELEASE
+ 1.0.1
+ 1.16.18
+ 1.8
+
+
diff --git a/spring-5-mvc/pom.xml b/spring-5-mvc/pom.xml
index 850661836b..06ddfb82d9 100644
--- a/spring-5-mvc/pom.xml
+++ b/spring-5-mvc/pom.xml
@@ -2,12 +2,10 @@
4.0.0
-
com.baeldung
spring-5-mvc
0.0.1-SNAPSHOT
jar
-
spring-5-mvc
spring 5 MVC sample project about new features
@@ -36,8 +34,6 @@
org.springframework.boot
spring-boot-starter-web
-
-
org.apache.commons
@@ -51,8 +47,7 @@
org.slf4j
jcl-over-slf4j
-
-
+
org.jetbrains.kotlin
kotlin-stdlib-jre8
@@ -67,9 +62,7 @@
com.fasterxml.jackson.module
jackson-module-kotlin
-
-
org.springframework.boot
spring-boot-devtools
@@ -80,7 +73,6 @@
h2
runtime
-
org.springframework
spring-test
@@ -90,20 +82,17 @@
spring-boot-starter-test
test
-
junit
junit
test
-
com.jayway.restassured
rest-assured
${rest-assured.version}
test
-
@@ -160,7 +149,6 @@
-
diff --git a/spring-5-reactive-client/pom.xml b/spring-5-reactive-client/pom.xml
index 8e84c0f364..e9e7c7c3e3 100644
--- a/spring-5-reactive-client/pom.xml
+++ b/spring-5-reactive-client/pom.xml
@@ -6,7 +6,6 @@
spring-5-reactive-client
0.0.1-SNAPSHOT
jar
-
spring-5-reactive-client
spring 5 sample project about new features
@@ -14,7 +13,7 @@
org.springframework.boot
spring-boot-starter-parent
2.0.0.M7
-
+
@@ -43,7 +42,7 @@
javax.json.bind
javax.json.bind-api
-
+
@@ -56,7 +55,7 @@
-
+
org.apache.geronimo.specs
geronimo-json_1.1_spec
@@ -98,7 +97,7 @@
org.apache.commons
commons-collections4
- 4.1
+ ${commons-collections4.version}
test
@@ -196,6 +195,7 @@
1.1.3
1.0
1.0
+ 4.1
diff --git a/spring-5-reactive/pom.xml b/spring-5-reactive/pom.xml
index 96378c60de..d17026af47 100644
--- a/spring-5-reactive/pom.xml
+++ b/spring-5-reactive/pom.xml
@@ -1,12 +1,12 @@
-
+
4.0.0
com.baeldung
spring-5-reactive
0.0.1-SNAPSHOT
jar
-
spring-5-reactive
spring 5 sample project about new features
@@ -14,7 +14,7 @@
org.springframework.boot
spring-boot-starter-parent
2.0.0.RELEASE
-
+
@@ -47,7 +47,7 @@
org.springframework.boot
spring-boot-starter-actuator
-
+
@@ -60,13 +60,13 @@
-
-
- org.projectlombok
- lombok
- compile
-
-
+
+
+ org.projectlombok
+ lombok
+ compile
+
+
org.apache.geronimo.specs
geronimo-json_1.1_spec
@@ -108,7 +108,7 @@
org.apache.commons
commons-collections4
- 4.1
+ ${commons-collections4.version}
test
@@ -184,7 +184,7 @@
1.1.3
1.0
1.0
+ 4.1
-
diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/filters/ExampleHandlerFilterFunction.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/filters/ExampleHandlerFilterFunction.java
new file mode 100644
index 0000000000..36b3c2ff6e
--- /dev/null
+++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/filters/ExampleHandlerFilterFunction.java
@@ -0,0 +1,22 @@
+package com.baeldung.reactive.filters;
+
+import org.springframework.web.reactive.function.server.HandlerFilterFunction;
+import org.springframework.web.reactive.function.server.HandlerFunction;
+import org.springframework.web.reactive.function.server.ServerRequest;
+import org.springframework.web.reactive.function.server.ServerResponse;
+import reactor.core.publisher.Mono;
+
+import static org.springframework.http.HttpStatus.FORBIDDEN;
+
+public class ExampleHandlerFilterFunction implements HandlerFilterFunction {
+
+ @Override
+ public Mono filter(ServerRequest serverRequest, HandlerFunction handlerFunction) {
+ if (serverRequest.pathVariable("name").equalsIgnoreCase("test")) {
+ return ServerResponse.status(FORBIDDEN).build();
+ }
+ return handlerFunction.handle(serverRequest);
+ }
+
+}
+
diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/filters/ExampleWebFilter.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/filters/ExampleWebFilter.java
new file mode 100644
index 0000000000..8fe3550a7e
--- /dev/null
+++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/filters/ExampleWebFilter.java
@@ -0,0 +1,17 @@
+package com.baeldung.reactive.filters;
+
+import org.springframework.stereotype.Component;
+import org.springframework.web.server.ServerWebExchange;
+import org.springframework.web.server.WebFilter;
+import org.springframework.web.server.WebFilterChain;
+import reactor.core.publisher.Mono;
+
+@Component
+public class ExampleWebFilter implements WebFilter {
+
+ @Override
+ public Mono filter(ServerWebExchange serverWebExchange, WebFilterChain webFilterChain) {
+ serverWebExchange.getResponse().getHeaders().add("web-filter", "web-filter-test");
+ return webFilterChain.filter(serverWebExchange);
+ }
+}
diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/filters/PlayerHandler.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/filters/PlayerHandler.java
new file mode 100644
index 0000000000..20a08570ae
--- /dev/null
+++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/filters/PlayerHandler.java
@@ -0,0 +1,17 @@
+package com.baeldung.reactive.filters;
+
+import org.springframework.stereotype.Component;
+import org.springframework.web.reactive.function.server.ServerRequest;
+import org.springframework.web.reactive.function.server.ServerResponse;
+import reactor.core.publisher.Mono;
+
+import static org.springframework.web.reactive.function.server.ServerResponse.ok;
+
+@Component
+class PlayerHandler {
+
+ Mono getName(ServerRequest request) {
+ Mono name = Mono.just(request.pathVariable("name"));
+ return ok().body(name, String.class);
+ }
+}
diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/filters/PlayerRouter.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/filters/PlayerRouter.java
new file mode 100644
index 0000000000..753991782c
--- /dev/null
+++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/filters/PlayerRouter.java
@@ -0,0 +1,20 @@
+package com.baeldung.reactive.filters;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.reactive.function.server.RouterFunction;
+import org.springframework.web.reactive.function.server.RouterFunctions;
+import org.springframework.web.reactive.function.server.ServerResponse;
+
+import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
+
+@Configuration
+public class PlayerRouter {
+
+ @Bean
+ public RouterFunction route(PlayerHandler playerHandler) {
+ return RouterFunctions
+ .route(GET("/players/{name}"), playerHandler::getName)
+ .filter(new ExampleHandlerFilterFunction());
+ }
+}
diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/filters/UserController.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/filters/UserController.java
new file mode 100644
index 0000000000..38c9210f88
--- /dev/null
+++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/filters/UserController.java
@@ -0,0 +1,15 @@
+package com.baeldung.reactive.filters;
+
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RestController;
+import reactor.core.publisher.Mono;
+
+@RestController
+public class UserController {
+
+ @GetMapping(path = "/users/{name}")
+ public Mono getName(@PathVariable String name) {
+ return Mono.just(name);
+ }
+}
diff --git a/spring-5-reactive/src/test/java/com/baeldung/reactive/filters/PlayerHandlerTest.java b/spring-5-reactive/src/test/java/com/baeldung/reactive/filters/PlayerHandlerTest.java
new file mode 100644
index 0000000000..8189802248
--- /dev/null
+++ b/spring-5-reactive/src/test/java/com/baeldung/reactive/filters/PlayerHandlerTest.java
@@ -0,0 +1,39 @@
+package com.baeldung.reactive.filters;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.reactive.server.EntityExchangeResult;
+import org.springframework.test.web.reactive.server.WebTestClient;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class PlayerHandlerTest {
+
+ @Autowired
+ private WebTestClient webTestClient;
+
+ @Test
+ public void whenPlayerNameIsBaeldung_thenWebFilterIsApplied() {
+ EntityExchangeResult result = webTestClient.get().uri("/players/baeldung")
+ .exchange()
+ .expectStatus().isOk()
+ .expectBody(String.class)
+ .returnResult();
+
+ assertEquals(result.getResponseBody(), "baeldung");
+ assertEquals(result.getResponseHeaders().getFirst("web-filter"), "web-filter-test");
+ }
+
+ @Test
+ public void whenPlayerNameIsTest_thenHandlerFilterFunctionIsApplied() {
+ webTestClient.get().uri("/players/test")
+ .exchange()
+ .expectStatus().isForbidden();
+ }
+
+}
\ No newline at end of file
diff --git a/spring-5-reactive/src/test/java/com/baeldung/reactive/filters/UserControllerTest.java b/spring-5-reactive/src/test/java/com/baeldung/reactive/filters/UserControllerTest.java
new file mode 100644
index 0000000000..d32a9d478f
--- /dev/null
+++ b/spring-5-reactive/src/test/java/com/baeldung/reactive/filters/UserControllerTest.java
@@ -0,0 +1,38 @@
+package com.baeldung.reactive.filters;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.reactive.server.EntityExchangeResult;
+import org.springframework.test.web.reactive.server.WebTestClient;
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class UserControllerTest {
+
+ @Autowired
+ private WebTestClient webTestClient;
+
+ @Test
+ public void whenUserNameIsBaeldung_thenWebFilterIsApplied() {
+ EntityExchangeResult result = webTestClient.get().uri("/users/baeldung")
+ .exchange()
+ .expectStatus().isOk()
+ .expectBody(String.class)
+ .returnResult();
+
+ assertEquals(result.getResponseBody(), "baeldung");
+ assertEquals(result.getResponseHeaders().getFirst("web-filter"), "web-filter-test");
+ }
+
+ @Test
+ public void whenUserNameIsTest_thenHandlerFilterFunctionIsNotApplied() {
+ webTestClient.get().uri("/users/test")
+ .exchange()
+ .expectStatus().isOk();
+ }
+}
\ No newline at end of file
diff --git a/spring-5-security/pom.xml b/spring-5-security/pom.xml
index 72d2b0133c..c9b16f8b88 100644
--- a/spring-5-security/pom.xml
+++ b/spring-5-security/pom.xml
@@ -5,7 +5,6 @@
spring-5-security
0.0.1-SNAPSHOT
jar
-
spring-5-security
spring 5 security sample project
@@ -18,22 +17,22 @@
-
- org.springframework.boot
- spring-boot-starter-security
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-thymeleaf
-
-
- org.thymeleaf.extras
- thymeleaf-extras-springsecurity4
-
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+
+
+ org.thymeleaf.extras
+ thymeleaf-extras-springsecurity4
+
@@ -66,6 +65,10 @@
org.springframework.boot
spring-boot-maven-plugin
+
+ com.baeldung.passwordstorage.PasswordStorageApplication
+ JAR
+
diff --git a/spring-5/README.md b/spring-5/README.md
index 1ac3cf4577..d37927cfc7 100644
--- a/spring-5/README.md
+++ b/spring-5/README.md
@@ -12,6 +12,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
- [Spring 5 Functional Bean Registration](http://www.baeldung.com/spring-5-functional-beans)
- [The SpringJUnitConfig and SpringJUnitWebConfig Annotations in Spring 5](http://www.baeldung.com/spring-5-junit-config)
- [Spring Security 5 for Reactive Applications](http://www.baeldung.com/spring-security-5-reactive)
-- [Spring 5 Testing with @EnabledIf Annotation](http://www.baeldung.com/sring-5-enabledif)
+- [Spring 5 Testing with @EnabledIf Annotation](http://www.baeldung.com/spring-5-enabledIf)
- [Introduction to Spring REST Docs](http://www.baeldung.com/spring-rest-docs)
- [Spring Security 5 – OAuth2 Login](http://www.baeldung.com/spring-security-5-oauth2-login)
+- [Spring ResponseStatusException](http://www.baeldung.com/spring-response-status-exception)
diff --git a/spring-5/pom.xml b/spring-5/pom.xml
index f8bad72c51..67a6930569 100644
--- a/spring-5/pom.xml
+++ b/spring-5/pom.xml
@@ -1,185 +1,184 @@
- 4.0.0
+ 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-5
- 0.0.1-SNAPSHOT
- jar
+ com.baeldung
+ spring-5
+ 0.0.1-SNAPSHOT
+ jar
+ spring-5
+ spring 5 sample project about new features
- spring-5
- spring 5 sample project about new features
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.0.0.RELEASE
+
+
-
- org.springframework.boot
- spring-boot-starter-parent
- 2.0.0.RELEASE
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter-data-jpa
-
-
- org.springframework.boot
- spring-boot-starter-security
-
-
- org.springframework.boot
- spring-boot-starter-validation
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-webflux
-
+
- org.springframework.boot
- spring-boot-starter-hateoas
-
-
- org.projectreactor
- reactor-spring
- ${reactor-spring.version}
-
-
- javax.json.bind
- javax.json.bind-api
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- org.apache.geronimo.specs
- geronimo-json_1.1_spec
- ${geronimo-json_1.1_spec.version}
-
-
- org.apache.johnzon
- johnzon-jsonb
-
-
-
- org.apache.commons
- commons-lang3
-
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-webflux
+
+
+ org.springframework.boot
+ spring-boot-starter-hateoas
+
+
+ org.projectreactor
+ reactor-spring
+ ${reactor-spring.version}
+
+
+ javax.json.bind
+ javax.json.bind-api
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.geronimo.specs
+ geronimo-json_1.1_spec
+ ${geronimo-json_1.1_spec.version}
+
+
+ org.apache.johnzon
+ johnzon-jsonb
+
+
+
+ org.apache.commons
+ commons-lang3
+
-
+
-
- org.springframework.boot
- spring-boot-devtools
- runtime
-
-
- com.h2database
- h2
- runtime
-
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+
+
+ com.h2database
+ h2
+ runtime
+
-
- org.springframework
- spring-test
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.springframework.security
- spring-security-test
- test
-
+
+ org.springframework
+ spring-test
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.security
+ spring-security-test
+ test
+
-
- org.apache.commons
- commons-collections4
- 4.1
- test
-
+
+ org.apache.commons
+ commons-collections4
+ 4.1
+ test
+
-
- org.junit.jupiter
- junit-jupiter-api
-
-
- org.junit.jupiter
- junit-jupiter-engine
- test
-
-
- org.junit.platform
- junit-platform-surefire-provider
- ${junit.platform.version}
- test
-
-
- org.junit.platform
- junit-platform-runner
- ${junit.platform.version}
- test
-
+
+ org.junit.jupiter
+ junit-jupiter-api
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.platform
+ junit-platform-surefire-provider
+ ${junit.platform.version}
+ test
+
+
+ org.junit.platform
+ junit-platform-runner
+ ${junit.platform.version}
+ test
+
org.springframework.restdocs
spring-restdocs-mockmvc
test
-
+
org.springframework.restdocs
spring-restdocs-webtestclient
test
-
+
org.springframework.restdocs
spring-restdocs-restassured
test
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
- com.baeldung.Spring5Application
- JAR
-
-
+
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- 3
- true
- methods
- true
-
- **/*IntegrationTest.java
- **/*LiveTest.java
-
-
-
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ com.baeldung.Spring5Application
+ JAR
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ 3
+ true
+ methods
+ true
+
+ **/*IntegrationTest.java
+ **/*LiveTest.java
+
+
+
org.asciidoctor
asciidoctor-maven-plugin
@@ -203,20 +202,20 @@
-
-
+
+
-
- UTF-8
- UTF-8
- 1.8
- 1.0.0
- 2.20
- 5.0.2.RELEASE
- 1.0.1.RELEASE
- 1.0
- 1.5.6
- ${project.build.directory}/generated-snippets
-
+
+ UTF-8
+ UTF-8
+ 1.8
+ 1.0.0
+ 2.20
+ 5.0.2.RELEASE
+ 1.0.1.RELEASE
+ 1.0
+ 1.5.6
+ ${project.build.directory}/generated-snippets
+
diff --git a/spring-5/src/main/java/com/baeldung/assertions/Car.java b/spring-5/src/main/java/com/baeldung/assertions/Car.java
new file mode 100644
index 0000000000..abff27f0b0
--- /dev/null
+++ b/spring-5/src/main/java/com/baeldung/assertions/Car.java
@@ -0,0 +1,124 @@
+package com.baeldung.assertions;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.util.Assert;
+
+public class Car {
+ private String state = "stop";
+
+ public void drive(int speed) {
+ Assert.isTrue(speed > 0, "speed must be positive");
+ this.state = "drive";
+ // ...
+ if (!(speed > 0)) {
+ throw new IllegalArgumentException("speed must be >0");
+ }
+ }
+
+ public void stop() {
+ this.state = "stop";
+ }
+
+ public void fuel() {
+ Assert.state(this.state.equals("stop"), "car must be stopped");
+ // ...
+ }
+
+ public void fuelwithSupplier() {
+ Assert.state(this.state.equals("stop"), () -> "car must be stopped");
+ // ...
+ }
+
+ public void сhangeOil(String oil) {
+ Assert.notNull(oil, "oil mustn't be null");
+ // ...
+ }
+
+ public void replaceBattery(CarBattery carBattery) {
+ Assert.isNull(carBattery.getCharge(), "to replace battery the charge must be null");
+ // ...
+ }
+
+ public void сhangeEngine(Engine engine) {
+ Assert.isInstanceOf(ToyotaEngine.class, engine);
+ // ...
+ }
+
+ public void repairEngine(Engine engine) {
+ Assert.isAssignable(Engine.class, ToyotaEngine.class);
+ // ...
+ }
+
+ public void startWithHasLength(String key) {
+ Assert.hasLength(key, "key must not be null and must not the empty");
+ // ...
+ }
+
+ public void startWithHasText(String key) {
+ Assert.hasText(key, "key must not be null and must contain at least one non-whitespace character");
+ // ...
+ }
+
+ public void startWithNotContain(String key) {
+ Assert.doesNotContain(key, "123", "key must not contain 123");
+ // ...
+ }
+
+ public void repair(Collection repairParts) {
+ Assert.notEmpty(repairParts, "collection of repairParts mustn't be empty");
+ // ...
+ }
+
+ public void repair(Map repairParts) {
+ Assert.notEmpty(repairParts, "map of repairParts mustn't be empty");
+ // ...
+ }
+
+ public void repair(String[] repairParts) {
+ Assert.notEmpty(repairParts, "array of repairParts must not be empty");
+ // ...
+ }
+
+ public void repairWithNoNull(String[] repairParts) {
+ Assert.noNullElements(repairParts, "array of repairParts must not contain null elements");
+ // ...
+ }
+
+ public static void main(String[] args) {
+ Car car = new Car();
+
+ car.drive(50);
+
+ car.stop();
+
+ car.fuel();
+
+ car.сhangeOil("oil");
+
+ CarBattery carBattery = new CarBattery();
+ car.replaceBattery(carBattery);
+
+ car.сhangeEngine(new ToyotaEngine());
+
+ car.startWithHasLength(" ");
+ car.startWithHasText("t");
+ car.startWithNotContain("132");
+
+ List repairPartsCollection = new ArrayList();
+ repairPartsCollection.add("part");
+ car.repair(repairPartsCollection);
+
+ Map repairPartsMap = new HashMap();
+ repairPartsMap.put("1", "part");
+ car.repair(repairPartsMap);
+
+ String[] repairPartsArray = { "part" };
+ car.repair(repairPartsArray);
+
+ }
+}
diff --git a/spring-5/src/main/java/com/baeldung/assertions/CarBattery.java b/spring-5/src/main/java/com/baeldung/assertions/CarBattery.java
new file mode 100644
index 0000000000..a75457a7ec
--- /dev/null
+++ b/spring-5/src/main/java/com/baeldung/assertions/CarBattery.java
@@ -0,0 +1,13 @@
+package com.baeldung.assertions;
+
+public class CarBattery {
+ private String charge;
+
+ public String getCharge() {
+ return charge;
+ }
+
+ public void setCharge(String charge) {
+ this.charge = charge;
+ }
+}
diff --git a/spring-5/src/main/java/com/baeldung/assertions/Engine.java b/spring-5/src/main/java/com/baeldung/assertions/Engine.java
new file mode 100644
index 0000000000..40cc161ee4
--- /dev/null
+++ b/spring-5/src/main/java/com/baeldung/assertions/Engine.java
@@ -0,0 +1,4 @@
+package com.baeldung.assertions;
+
+public class Engine {
+}
diff --git a/spring-5/src/main/java/com/baeldung/assertions/ToyotaEngine.java b/spring-5/src/main/java/com/baeldung/assertions/ToyotaEngine.java
new file mode 100644
index 0000000000..21af8df55f
--- /dev/null
+++ b/spring-5/src/main/java/com/baeldung/assertions/ToyotaEngine.java
@@ -0,0 +1,5 @@
+package com.baeldung.assertions;
+
+public class ToyotaEngine extends Engine {
+
+}
diff --git a/spring-5/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java b/spring-5/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java
new file mode 100644
index 0000000000..cf0dbe4681
--- /dev/null
+++ b/spring-5/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositoryJDBCTemplate.java
@@ -0,0 +1,38 @@
+package com.baeldung.jdbc.autogenkey.repository;
+
+import java.sql.PreparedStatement;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.GeneratedKeyHolder;
+import org.springframework.jdbc.support.KeyHolder;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class MessageRepositoryJDBCTemplate {
+
+ @Autowired
+ JdbcTemplate jdbcTemplate;
+
+ final String INSERT_MESSAGE_SQL = "insert into sys_message (message) values(?) ";
+
+ public long insert(final String message) {
+
+ KeyHolder keyHolder = new GeneratedKeyHolder();
+
+ jdbcTemplate.update(connection -> {
+ PreparedStatement ps = connection.prepareStatement(INSERT_MESSAGE_SQL);
+ ps.setString(1, message);
+ return ps;
+ }, keyHolder);
+
+ return (long) keyHolder.getKey();
+ }
+
+ final String SELECT_BY_ID = "select message from sys_message where id = ?";
+
+ public String getMessageById(long id) {
+ return this.jdbcTemplate.queryForObject(SELECT_BY_ID, String.class, new Object[] { id });
+ }
+
+}
diff --git a/spring-5/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java b/spring-5/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java
new file mode 100644
index 0000000000..022ea29ed6
--- /dev/null
+++ b/spring-5/src/main/java/com/baeldung/jdbc/autogenkey/repository/MessageRepositorySimpleJDBCInsert.java
@@ -0,0 +1,29 @@
+package com.baeldung.jdbc.autogenkey.repository;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class MessageRepositorySimpleJDBCInsert {
+
+ SimpleJdbcInsert messageInsert;
+
+ @Autowired
+ public MessageRepositorySimpleJDBCInsert(DataSource dataSource) {
+ messageInsert = new SimpleJdbcInsert(dataSource).withTableName("sys_message").usingGeneratedKeyColumns("id");
+ }
+
+ public long insert(String message) {
+ Map parameters = new HashMap(1);
+ parameters.put("message", message);
+ Number newId = messageInsert.executeAndReturnKey(parameters);
+ return (long) newId;
+ }
+
+}
diff --git a/spring-5/src/main/resources/autogenkey-db.properties b/spring-5/src/main/resources/autogenkey-db.properties
new file mode 100644
index 0000000000..3e1a088dc1
--- /dev/null
+++ b/spring-5/src/main/resources/autogenkey-db.properties
@@ -0,0 +1,9 @@
+spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_ON_EXIT=FALSE
+spring.datasource.username=sa
+spring.datasource.password=
+spring.datasource.driverClassName=org.h2.Driver
+spring.jpa.hibernate.ddl-auto=create
+spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
+
+spring.datasource.initialize=true
+spring.datasource.schema=classpath:autogenkey-schema.sql
diff --git a/spring-5/src/main/resources/autogenkey-schema.sql b/spring-5/src/main/resources/autogenkey-schema.sql
new file mode 100644
index 0000000000..925b27143c
--- /dev/null
+++ b/spring-5/src/main/resources/autogenkey-schema.sql
@@ -0,0 +1,5 @@
+CREATE TABLE IF NOT EXISTS sys_message (
+ id bigint(20) NOT NULL AUTO_INCREMENT,
+ message varchar(100) NOT NULL,
+ PRIMARY KEY (id)
+);
\ No newline at end of file
diff --git a/spring-5/src/test/java/com/baeldung/jdbc/autogenkey/GetAutoGenKeyByJDBC.java b/spring-5/src/test/java/com/baeldung/jdbc/autogenkey/GetAutoGenKeyByJDBC.java
new file mode 100644
index 0000000000..c52e18ef7f
--- /dev/null
+++ b/spring-5/src/test/java/com/baeldung/jdbc/autogenkey/GetAutoGenKeyByJDBC.java
@@ -0,0 +1,53 @@
+package com.baeldung.jdbc.autogenkey;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.jdbc.autogenkey.repository.MessageRepositoryJDBCTemplate;
+import com.baeldung.jdbc.autogenkey.repository.MessageRepositorySimpleJDBCInsert;
+
+@RunWith(SpringRunner.class)
+public class GetAutoGenKeyByJDBC {
+
+ @Configuration
+ @EnableAutoConfiguration
+ @PropertySource("classpath:autogenkey-db.properties")
+ @ComponentScan(basePackages = { "com.baeldung.jdbc.autogenkey.repository" })
+ public static class SpringConfig {
+
+ }
+
+ @Autowired
+ MessageRepositorySimpleJDBCInsert messageRepositorySimpleJDBCInsert;
+
+ @Autowired
+ MessageRepositoryJDBCTemplate messageRepositoryJDBCTemplate;
+
+ final String MESSAGE_CONTENT = "Test";
+
+ @Test
+ public void insertJDBC_whenLoadMessageByKey_thenGetTheSameMessage() {
+ long key = messageRepositoryJDBCTemplate.insert(MESSAGE_CONTENT);
+ String loadedMessage = messageRepositoryJDBCTemplate.getMessageById(key);
+
+ assertEquals(MESSAGE_CONTENT, loadedMessage);
+
+ }
+
+ @Test
+ public void insertSimpleInsert_whenLoadMessageKey_thenGetTheSameMessage() {
+ long key = messageRepositorySimpleJDBCInsert.insert(MESSAGE_CONTENT);
+ String loadedMessage = messageRepositoryJDBCTemplate.getMessageById(key);
+
+ assertEquals(MESSAGE_CONTENT, loadedMessage);
+ }
+
+}
diff --git a/spring-5/src/test/resources/logback-test.xml b/spring-5/src/test/resources/logback-test.xml
new file mode 100644
index 0000000000..84f8e4706a
--- /dev/null
+++ b/spring-5/src/test/resources/logback-test.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-activiti/pom.xml b/spring-activiti/pom.xml
index 92d9618b65..5b6911a450 100644
--- a/spring-activiti/pom.xml
+++ b/spring-activiti/pom.xml
@@ -2,12 +2,10 @@
4.0.0
-
com.example
spring-activiti
0.0.1-SNAPSHOT
jar
-
spring-activiti
Demo project for Spring Boot
@@ -15,17 +13,9 @@
org.springframework.boot
spring-boot-starter-parent
1.5.4.RELEASE
-
+
-
- com.example.activitiwithspring.ActivitiWithSpringApplication
- UTF-8
- UTF-8
- 1.8
- 6.0.0
-
-
org.activiti
@@ -80,5 +70,12 @@
+
+ com.example.activitiwithspring.ActivitiWithSpringApplication
+ UTF-8
+ UTF-8
+ 6.0.0
+ 1.8
+
diff --git a/spring-akka/pom.xml b/spring-akka/pom.xml
index 5efd111c35..d68e8c211b 100644
--- a/spring-akka/pom.xml
+++ b/spring-akka/pom.xml
@@ -1,11 +1,10 @@
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ 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-akka
0.1-SNAPSHOT
-
spring-akka
@@ -15,30 +14,24 @@
-
org.springframework
spring-context
-
com.typesafe.akka
akka-actor_2.11
${akka.version}
-
org.springframework
spring-test
test
-
-
-
org.springframework
spring-framework-bom
@@ -46,46 +39,9 @@
pom
import
-
-
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
-
4.3.4.RELEASE
2.4.14
diff --git a/spring-all/pom.xml b/spring-all/pom.xml
index b04ffae9c8..ac66ecdad8 100644
--- a/spring-all/pom.xml
+++ b/spring-all/pom.xml
@@ -1,10 +1,9 @@
+ 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-all
0.1-SNAPSHOT
-
spring-all
war
@@ -20,9 +19,7 @@
com.fasterxml.jackson.core
jackson-databind
-
-
org.springframework
spring-web
@@ -49,17 +46,12 @@
spring-shell
${org.springframework.shell.version}
-
-
-
org.springframework
spring-aspects
-
-
org.hibernate
hibernate-core
@@ -78,36 +70,28 @@
org.hsqldb
hsqldb
-
-
org.hibernate
hibernate-validator
-
-
javax.servlet
javax.servlet-api
provided
-
javax.servlet
jstl
runtime
-
-
com.google.guava
guava
${guava.version}
-
net.sf.jasperreports
jasperreports
@@ -119,23 +103,18 @@
-
-
org.springframework
spring-test
test
-
-
org.assertj
assertj-core
${assertj.version}
test
-
org.hamcrest
hamcrest-core
@@ -146,13 +125,11 @@
hamcrest-library
test
-
org.mockito
mockito-core
test
-
org.easymock
easymock
@@ -164,7 +141,6 @@
ehcache
${ehcache.version}
-
org.apache.logging.log4j
log4j-api
@@ -175,13 +151,10 @@
log4j-core
${log4j.version}
-
-
-
org.springframework
spring-framework-bom
@@ -189,19 +162,16 @@
pom
import
-
org.springframework
spring-core
${org.springframework.version}
-
org.springframework.boot
spring-boot-starter-thymeleaf
-
+
-
@@ -212,9 +182,7 @@
true
-
-
org.apache.maven.plugins
maven-war-plugin
@@ -222,48 +190,11 @@
false
-
-
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
-
-
- org.baeldung.sample.App
+ org.baeldung.sample.App
4.3.4.RELEASE
4.2.0.RELEASE
diff --git a/spring-amqp-simple/pom.xml b/spring-amqp-simple/pom.xml
index 0cf4ad0e47..f3dfbccaec 100644
--- a/spring-amqp-simple/pom.xml
+++ b/spring-amqp-simple/pom.xml
@@ -1,7 +1,11 @@
+ 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-amqp-simple
+ 1.0.0-SNAPSHOT
+ Spring AMQP Simple App
parent-boot-5
@@ -10,11 +14,6 @@
../parent-boot-5
- com.baeldung
- spring-amqp-simple
- 1.0.0-SNAPSHOT
- Spring AMQP Simple App
-
org.springframework.boot
diff --git a/spring-amqp/pom.xml b/spring-amqp/pom.xml
index 37a1d9e394..a11261084a 100755
--- a/spring-amqp/pom.xml
+++ b/spring-amqp/pom.xml
@@ -1,12 +1,10 @@
+ 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
springamqp
0.1-SNAPSHOT
jar
-
springamqp
Introduction to Spring-AMQP
@@ -16,10 +14,6 @@
1.0.0-SNAPSHOT
-
- UTF-8
-
-
org.springframework.amqp
@@ -37,4 +31,9 @@
springamqp
+
+
+ UTF-8
+
+
diff --git a/spring-aop/pom.xml b/spring-aop/pom.xml
index 0e8dbe46ce..7cdf9bd7cc 100644
--- a/spring-aop/pom.xml
+++ b/spring-aop/pom.xml
@@ -1,5 +1,5 @@
+ 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-aop
diff --git a/spring-apache-camel/pom.xml b/spring-apache-camel/pom.xml
index df907a34de..4c963fc32c 100644
--- a/spring-apache-camel/pom.xml
+++ b/spring-apache-camel/pom.xml
@@ -1,5 +1,5 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
org.apache.camel
spring-apache-camel
@@ -14,20 +14,12 @@
1.0.0-SNAPSHOT
-
- 2.18.1
- 4.3.4.RELEASE
- 1.8
-
-
-
org.apache.camel
camel-core
${env.camel.version}
-
org.apache.camel
camel-spring
@@ -39,13 +31,11 @@
-
org.apache.camel
camel-stream
${env.camel.version}
-
org.springframework
spring-context
@@ -56,8 +46,13 @@
camel-spring-javaconfig
${env.camel.version}
-
+
+ 2.18.1
+ 4.3.4.RELEASE
+ 1.8
+
+
diff --git a/spring-batch/pom.xml b/spring-batch/pom.xml
index f72024d32b..d274c046e2 100644
--- a/spring-batch/pom.xml
+++ b/spring-batch/pom.xml
@@ -1,12 +1,10 @@
+ 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-batch
0.1-SNAPSHOT
jar
-
spring-batch
http://maven.apache.org
@@ -16,14 +14,6 @@
1.0.0-SNAPSHOT
-
- UTF-8
- 5.0.3.RELEASE
- 4.0.0.RELEASE
- 3.15.1
- 4.1
-
-
@@ -64,4 +54,13 @@
+
+
+ UTF-8
+ 5.0.3.RELEASE
+ 4.0.0.RELEASE
+ 3.15.1
+ 4.1
+
+
diff --git a/spring-bom/README.md b/spring-bom/README.md
index 10e3502d11..d056216a2e 100644
--- a/spring-bom/README.md
+++ b/spring-bom/README.md
@@ -1,3 +1,3 @@
### Relevant Articles:
-- [Spring with Maven BOM]
+- [Spring with Maven BOM](http://www.baeldung.com/spring-maven-bom)
diff --git a/spring-bom/pom.xml b/spring-bom/pom.xml
index 306632eb21..ddecb9dc0d 100644
--- a/spring-bom/pom.xml
+++ b/spring-bom/pom.xml
@@ -1,27 +1,26 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4.0.0
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
com.baeldung
spring-bom
1.0.0-SNAPSHOT
spring-bom
http://maven.apache.org
-
- UTF-8
-
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
+
org.springframework
spring-framework-bom
- 4.3.8.RELEASE
+ ${spring-framework-bom.version}
pom
import
@@ -37,4 +36,10 @@
spring-web
+
+
+ UTF-8
+ 4.3.8.RELEASE
+
+
diff --git a/spring-boot-admin/pom.xml b/spring-boot-admin/pom.xml
index 9c1eeeabff..d285a01ec5 100644
--- a/spring-boot-admin/pom.xml
+++ b/spring-boot-admin/pom.xml
@@ -11,11 +11,6 @@
1.0.0-SNAPSHOT
-
- UTF-8
- 1.5.8.RELEASE
-
-
spring-boot-admin-server
spring-boot-admin-client
@@ -33,4 +28,9 @@
+
+ UTF-8
+ 1.5.8.RELEASE
+
+
\ No newline at end of file
diff --git a/spring-boot-admin/spring-boot-admin-server/pom.xml b/spring-boot-admin/spring-boot-admin-server/pom.xml
index f28b7a3dc9..d5c2e19f37 100644
--- a/spring-boot-admin/spring-boot-admin-server/pom.xml
+++ b/spring-boot-admin/spring-boot-admin-server/pom.xml
@@ -2,11 +2,9 @@
4.0.0
-
spring-boot-admin-server
0.0.1-SNAPSHOT
jar
-
spring-boot-admin-server
Spring Boot Admin Server
@@ -31,7 +29,7 @@
spring-boot-starter
-
+
de.codecentric
spring-boot-admin-server
@@ -43,7 +41,7 @@
${spring-boot-admin-server.version}
-
+
de.codecentric
spring-boot-admin-server-ui-login
@@ -57,17 +55,17 @@
com.hazelcast
hazelcast
-
+
de.codecentric
spring-boot-admin-starter-client
${spring-boot-admin-starter-client.version}
-
-
-
-
-
+
+
+
+
+
org.springframework.boot
spring-boot-starter-test
diff --git a/spring-boot-bootstrap/pom.xml b/spring-boot-bootstrap/pom.xml
index eb97d6d426..1ec9af8189 100644
--- a/spring-boot-bootstrap/pom.xml
+++ b/spring-boot-bootstrap/pom.xml
@@ -1,13 +1,10 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
-
org.baeldung
spring-boot-bootstrap
- 0.0.1-SNAPSHOT
jar
-
spring-boot-bootstrap
Demo project for Spring Boot
@@ -17,7 +14,7 @@
0.0.1-SNAPSHOT
../parent-boot-5
-
+
-
- UTF-8
- UTF-8
- 1.8
-
-
org.springframework.boot
@@ -64,72 +55,25 @@
org.springframework.boot
spring-boot-starter-security
-
-
org.springframework.boot
spring-boot-starter-test
test
-
io.rest-assured
rest-assured
3.0.3
test
-
javax.servlet
javax.servlet-api
4.0.0
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*LiveTest.java
- **/AutoconfigurationTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
autoconfiguration
@@ -165,5 +109,10 @@
+
+ UTF-8
+ UTF-8
+ 1.8
+
diff --git a/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml b/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml
index d5946900ae..6ae6572ca9 100644
--- a/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml
+++ b/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml
@@ -1,11 +1,16 @@
+ 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
greeter-spring-boot-autoconfigure
0.0.1-SNAPSHOT
-
+
+ parent-boot-5
+ com.baeldung
+ 0.0.1-SNAPSHOT
+ ../../parent-boot-5
+
UTF-8
1.5.2.RELEASE
@@ -19,13 +24,13 @@
spring-boot
${spring-boot.version}
-
+
org.springframework.boot
spring-boot-autoconfigure
${spring-boot.version}
-
+
org.springframework.boot
spring-boot-configuration-processor
diff --git a/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml b/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml
index e90e6ca280..9db76759ec 100644
--- a/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml
+++ b/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml
@@ -1,5 +1,5 @@
+ 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
@@ -18,7 +18,7 @@
-
+
com.baeldung
greeter-spring-boot-starter
diff --git a/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml b/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml
index 9b8858a8ab..e771cbaa8d 100644
--- a/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml
+++ b/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml
@@ -1,11 +1,16 @@
+ 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
greeter-spring-boot-starter
0.0.1-SNAPSHOT
-
+
+ parent-boot-5
+ com.baeldung
+ 0.0.1-SNAPSHOT
+ ../../parent-boot-5
+
UTF-8
0.0.1-SNAPSHOT
diff --git a/spring-boot-custom-starter/greeter/pom.xml b/spring-boot-custom-starter/greeter/pom.xml
index e2048bf5c7..6143992088 100644
--- a/spring-boot-custom-starter/greeter/pom.xml
+++ b/spring-boot-custom-starter/greeter/pom.xml
@@ -1,9 +1,14 @@
+ 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
greeter
0.0.1-SNAPSHOT
-
+
+ parent-boot-5
+ com.baeldung
+ 0.0.1-SNAPSHOT
+ ../../parent-boot-5
+
\ No newline at end of file
diff --git a/spring-boot-custom-starter/pom.xml b/spring-boot-custom-starter/pom.xml
index cc9724bad1..1bc0e14d8e 100644
--- a/spring-boot-custom-starter/pom.xml
+++ b/spring-boot-custom-starter/pom.xml
@@ -1,5 +1,5 @@
+ 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-custom-starter
@@ -10,11 +10,7 @@
com.baeldung
parent-modules
1.0.0-SNAPSHOT
-
-
-
- UTF-8
-
+
greeter
@@ -23,4 +19,8 @@
greeter-spring-boot-sample-app
+
+ UTF-8
+
+
\ No newline at end of file
diff --git a/spring-boot-gradle/README.md b/spring-boot-gradle/README.md
new file mode 100644
index 0000000000..f96aa9ccf8
--- /dev/null
+++ b/spring-boot-gradle/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles:
+
+- [Spring Boot: Configuring a Main Class](http://www.baeldung.com/spring-boot-main-class)
diff --git a/spring-boot-gradle/build.gradle b/spring-boot-gradle/build.gradle
new file mode 100644
index 0000000000..e602c485a9
--- /dev/null
+++ b/spring-boot-gradle/build.gradle
@@ -0,0 +1,44 @@
+buildscript {
+ ext {
+ springBootVersion = '2.0.0.RELEASE'
+ }
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
+ }
+}
+
+apply plugin: 'java'
+apply plugin: 'eclipse'
+apply plugin: 'org.springframework.boot'
+apply plugin: 'io.spring.dependency-management'
+
+group = 'org.baeldung'
+version = '0.0.1-SNAPSHOT'
+sourceCompatibility = 1.8
+
+repositories {
+ mavenCentral()
+}
+
+
+dependencies {
+ compile('org.springframework.boot:spring-boot-starter')
+ testCompile('org.springframework.boot:spring-boot-starter-test')
+}
+
+springBoot {
+ mainClassName = 'org.baeldung.DemoApplication'
+}
+
+bootJar {
+// This is overridden by the mainClassName in springBoot{} and added here for reference purposes.
+ mainClassName = 'org.baeldung.DemoApplication'
+
+// This block serves the same purpose as the above thus commented out. Added here for reference purposes
+// manifest {
+// attributes 'Start-Class': 'org.baeldung.DemoApplication'
+// }
+}
diff --git a/spring-boot-gradle/gradle/wrapper/gradle-wrapper.jar b/spring-boot-gradle/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000000..1ce6e58f1c
Binary files /dev/null and b/spring-boot-gradle/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/spring-boot-gradle/gradle/wrapper/gradle-wrapper.properties b/spring-boot-gradle/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000000..44d9d03d80
--- /dev/null
+++ b/spring-boot-gradle/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Tue Feb 06 12:27:20 CET 2018
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip
diff --git a/spring-boot-gradle/gradlew b/spring-boot-gradle/gradlew
new file mode 100755
index 0000000000..4453ccea33
--- /dev/null
+++ b/spring-boot-gradle/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save ( ) {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/spring-boot-gradle/gradlew.bat b/spring-boot-gradle/gradlew.bat
new file mode 100644
index 0000000000..e95643d6a2
--- /dev/null
+++ b/spring-boot-gradle/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/spring-boot-gradle/settings.gradle b/spring-boot-gradle/settings.gradle
new file mode 100644
index 0000000000..0a383dd840
--- /dev/null
+++ b/spring-boot-gradle/settings.gradle
@@ -0,0 +1 @@
+rootProject.name = 'demo'
diff --git a/spring-boot-gradle/src/main/java/org/baeldung/DemoApplication.java b/spring-boot-gradle/src/main/java/org/baeldung/DemoApplication.java
new file mode 100644
index 0000000000..f8df823f25
--- /dev/null
+++ b/spring-boot-gradle/src/main/java/org/baeldung/DemoApplication.java
@@ -0,0 +1,12 @@
+package org.baeldung;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class DemoApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(DemoApplication.class, args);
+ }
+}
diff --git a/spring-boot-gradle/src/main/resources/application.properties b/spring-boot-gradle/src/main/resources/application.properties
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/spring-boot-gradle/src/test/java/org/baeldung/DemoApplicationTests.java b/spring-boot-gradle/src/test/java/org/baeldung/DemoApplicationTests.java
new file mode 100644
index 0000000000..b24bfb2cb6
--- /dev/null
+++ b/spring-boot-gradle/src/test/java/org/baeldung/DemoApplicationTests.java
@@ -0,0 +1,16 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class DemoApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-boot-keycloak/pom.xml b/spring-boot-keycloak/pom.xml
index 741e2313b4..d2df261b2f 100644
--- a/spring-boot-keycloak/pom.xml
+++ b/spring-boot-keycloak/pom.xml
@@ -1,88 +1,83 @@
- 4.0.0
+ 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.keycloak
+ spring-boot-keycloak
+ 0.0.1
+ jar
+ spring-boot-keycloak
+ This is a simple application demonstrating integration between Keycloak and Spring Boot.
- com.baeldung.keycloak
- spring-boot-keycloak
- 0.0.1
- jar
+
+ com.baeldung
+ parent-boot-5
+ 0.0.1-SNAPSHOT
+ ../parent-boot-5
+
- spring-boot-keycloak
- This is a simple application demonstrating integration between Keycloak and Spring Boot.
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ org.keycloak
+ keycloak-spring-boot-starter
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
-
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.hsqldb
+ hsqldb
+ runtime
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+
+
+
+
+
+ org.keycloak.bom
+ keycloak-adapter-bom
+ ${keycloak-adapter-bom.version}
+ pom
+ import
+
+
+
- com.baeldung
- parent-boot-5
- 0.0.1-SNAPSHOT
- ../parent-boot-5
-
-
-
-
- UTF-8
- UTF-8
- 1.8
-
-
-
-
- org.springframework.boot
- spring-boot-starter
-
-
- org.keycloak
- keycloak-spring-boot-starter
-
-
- org.springframework.boot
- spring-boot-starter-data-jpa
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.springframework.boot
- spring-boot-starter-security
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.hsqldb
- hsqldb
- runtime
-
-
- org.springframework.boot
- spring-boot-starter-thymeleaf
-
-
-
-
-
- org.keycloak.bom
- keycloak-adapter-bom
- 3.3.0.Final
- pom
- import
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+ UTF-8
+ UTF-8
+ 3.3.0.Final
+
diff --git a/spring-boot-property-exp/pom.xml b/spring-boot-property-exp/pom.xml
index 1a1e31385e..abf9f45d1c 100644
--- a/spring-boot-property-exp/pom.xml
+++ b/spring-boot-property-exp/pom.xml
@@ -1,7 +1,7 @@
-
+
4.0.0
spring-boot-property-exp
-
com.baeldung
spring-boot-property-exp
0.0.1-SNAPSHOT
@@ -13,13 +13,13 @@
1.0.0-SNAPSHOT
-
- UTF-8
-
-
property-exp-default-config
property-exp-custom-config
+
+ UTF-8
+
+
diff --git a/spring-boot-property-exp/property-exp-default-config/pom.xml b/spring-boot-property-exp/property-exp-default-config/pom.xml
index 5dc47d287d..e4cbaebf56 100644
--- a/spring-boot-property-exp/property-exp-default-config/pom.xml
+++ b/spring-boot-property-exp/property-exp-default-config/pom.xml
@@ -1,16 +1,17 @@
4.0.0
property-exp-default
-
+
com.baeldung
property-exp-default-config
0.0.1-SNAPSHOT
jar
- org.springframework.boot
- spring-boot-starter-parent
- 1.5.10.RELEASE
+ parent-boot-5
+ com.baeldung
+ 0.0.1-SNAPSHOT
+ ../../parent-boot-5
diff --git a/spring-boot-security/README.md b/spring-boot-security/README.md
index a0ddb8de7b..a79e7de610 100644
--- a/spring-boot-security/README.md
+++ b/spring-boot-security/README.md
@@ -6,3 +6,6 @@
### CURL commands
- curl -X POST -u baeldung-admin:baeldung -d grant_type=client_credentials -d username=baeldung-admin -d password=baeldung http://localhost:8080/oauth/token
+
+### Relevant Articles:
+- [Spring Boot Security Auto-Configuration](http://www.baeldung.com/spring-boot-security-autoconfiguration)
diff --git a/spring-boot-security/pom.xml b/spring-boot-security/pom.xml
index c1ec14ff64..8763c210c8 100644
--- a/spring-boot-security/pom.xml
+++ b/spring-boot-security/pom.xml
@@ -1,77 +1,74 @@
- 4.0.0
+ 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-security
+ 0.0.1-SNAPSHOT
+ jar
+ spring-boot-security
+ Spring Boot Security Auto-Configuration
- com.baeldung
- spring-boot-security
- 0.0.1-SNAPSHOT
- jar
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
- spring-boot-security
- Spring Boot Security Auto-Configuration
+
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ 1.5.9.RELEASE
+ pom
+ import
+
+
+
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
-
-
-
- org.springframework.boot
- spring-boot-dependencies
- 1.5.9.RELEASE
- pom
- import
-
-
-
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+ org.springframework.security.oauth
+ spring-security-oauth2
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
-
- UTF-8
- UTF-8
- 1.8
-
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.springframework.security
+ spring-security-test
+ test
+
+
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter-security
-
-
- org.springframework.security.oauth
- spring-security-oauth2
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
- org.springframework.security
- spring-security-test
- test
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+ UTF-8
+ UTF-8
+
diff --git a/spring-boot/README.MD b/spring-boot/README.MD
index e78756cf08..080c4d6353 100644
--- a/spring-boot/README.MD
+++ b/spring-boot/README.MD
@@ -1,4 +1,4 @@
-###The Course
+### The Course
The "REST With Spring" Classes: http://bit.ly/restwithspring
### Relevant Articles:
@@ -32,3 +32,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
- [Spring Data Java 8 Support](http://www.baeldung.com/spring-data-java-8)
- [A Quick Guide to Maven Wrapper](http://www.baeldung.com/maven-wrapper)
- [An Introduction to Kong](http://www.baeldung.com/kong)
+- [Spring Boot Customize Whitelabel Error Page](http://www.baeldung.com/spring-boot-custom-error-page)
+- [Spring Boot: Configuring a Main Class](http://www.baeldung.com/spring-boot-main-class)
+
diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml
index f10fe5a909..127ac455e1 100644
--- a/spring-boot/pom.xml
+++ b/spring-boot/pom.xml
@@ -1,5 +1,5 @@
+ 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
@@ -58,23 +58,17 @@
org.springframework.boot
spring-boot-starter-tomcat
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
io.dropwizard.metrics
@@ -134,7 +128,7 @@
mysql
mysql-connector-java
- 6.0.6
+ ${mysql-connector-java.version}
@@ -200,39 +194,6 @@
-
- integration
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- integration-test
-
- test
-
-
-
- **/*LiveTest.java
- **/AutoconfigurationTest.java
-
-
- **/*IntegrationTest.java
-
-
-
-
-
-
- json
-
-
-
-
-
-
autoconfiguration
@@ -281,6 +242,7 @@
1.4.194
2.4.1.Final
1.9.0
+ 6.0.6
\ No newline at end of file
diff --git a/spring-boot/src/main/java/com/baeldung/bootcustomfilters/SpringBootFiltersApplication.java b/spring-boot/src/main/java/com/baeldung/bootcustomfilters/SpringBootFiltersApplication.java
new file mode 100644
index 0000000000..c4653932c0
--- /dev/null
+++ b/spring-boot/src/main/java/com/baeldung/bootcustomfilters/SpringBootFiltersApplication.java
@@ -0,0 +1,17 @@
+package com.baeldung.bootcustomfilters;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * Boot application
+ * @author hemant
+ *
+ */
+@SpringBootApplication
+public class SpringBootFiltersApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringBootFiltersApplication.class, args);
+ }
+}
diff --git a/spring-boot/src/main/java/com/baeldung/bootcustomfilters/controller/UserController.java b/spring-boot/src/main/java/com/baeldung/bootcustomfilters/controller/UserController.java
new file mode 100644
index 0000000000..9dfab1192d
--- /dev/null
+++ b/spring-boot/src/main/java/com/baeldung/bootcustomfilters/controller/UserController.java
@@ -0,0 +1,34 @@
+package com.baeldung.bootcustomfilters.controller;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.baeldung.bootcustomfilters.model.User;
+
+/**
+ * Rest controller for User
+ * @author hemant
+ *
+ */
+@RestController
+@RequestMapping("/users")
+public class UserController {
+
+ private static final Logger LOG = LoggerFactory.getLogger(UserController.class);
+
+ @RequestMapping("")
+ public List getAllUsers() {
+ LOG.info("Fetching all the users");
+ return Arrays.asList(
+ new User(UUID.randomUUID().toString(), "User1", "user1@test.com"),
+ new User(UUID.randomUUID().toString(), "User1", "user1@test.com"),
+ new User(UUID.randomUUID().toString(), "User1", "user1@test.com"));
+ }
+
+}
diff --git a/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/RequestResponseLoggingFilter.java b/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/RequestResponseLoggingFilter.java
new file mode 100644
index 0000000000..e42ea7d2dd
--- /dev/null
+++ b/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/RequestResponseLoggingFilter.java
@@ -0,0 +1,50 @@
+package com.baeldung.bootcustomfilters.filters;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+
+/**
+ * A servlet filter to log request and response
+ * The logging implementation is pretty native and for demonstration only
+ * @author hemant
+ *
+ */
+@Component
+@Order(2)
+public class RequestResponseLoggingFilter implements Filter {
+
+ private final static Logger LOG = LoggerFactory.getLogger(RequestResponseLoggingFilter.class);
+
+ @Override
+ public void init(final FilterConfig filterConfig) throws ServletException {
+ LOG.info("Initializing filter :{}", this);
+ }
+
+ @Override
+ public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain)
+ throws IOException, ServletException {
+ HttpServletRequest req = (HttpServletRequest) request;
+ HttpServletResponse res = (HttpServletResponse) response;
+ LOG.info("Logging Request {} : {}", req.getMethod(), req.getRequestURI());
+ chain.doFilter(request, response);
+ LOG.info("Logging Response :{}", res.getContentType());
+ }
+
+ @Override
+ public void destroy() {
+ LOG.warn("Destructing filter :{}", this);
+ }
+}
diff --git a/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/TransactionFilter.java b/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/TransactionFilter.java
new file mode 100644
index 0000000000..d92b723e73
--- /dev/null
+++ b/spring-boot/src/main/java/com/baeldung/bootcustomfilters/filters/TransactionFilter.java
@@ -0,0 +1,47 @@
+package com.baeldung.bootcustomfilters.filters;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Component;
+
+/**
+ * A filter to create transaction before and commit it once request completes
+ * The current implemenatation is just for demo
+ * @author hemant
+ *
+ */
+@Component
+@Order(1)
+public class TransactionFilter implements Filter {
+
+ private final static Logger LOG = LoggerFactory.getLogger(TransactionFilter.class);
+
+ @Override
+ public void init(final FilterConfig filterConfig) throws ServletException {
+ LOG.info("Initializing filter :{}", this);
+ }
+
+ @Override
+ public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException {
+ HttpServletRequest req = (HttpServletRequest) request;
+ LOG.info("Starting Transaction for req :{}", req.getRequestURI());
+ chain.doFilter(request, response);
+ LOG.info("Committing Transaction for req :{}", req.getRequestURI());
+ }
+
+ @Override
+ public void destroy() {
+ LOG.warn("Destructing filter :{}", this);
+ }
+}
diff --git a/spring-boot/src/main/java/com/baeldung/bootcustomfilters/model/User.java b/spring-boot/src/main/java/com/baeldung/bootcustomfilters/model/User.java
new file mode 100644
index 0000000000..ab8e6c8206
--- /dev/null
+++ b/spring-boot/src/main/java/com/baeldung/bootcustomfilters/model/User.java
@@ -0,0 +1,45 @@
+package com.baeldung.bootcustomfilters.model;
+
+/**
+ * User model
+ * @author hemant
+ *
+ */
+public class User {
+
+ private String id;
+ private String name;
+ private String email;
+
+ public User(String id, String name, String email) {
+ super();
+ this.id = id;
+ this.name = name;
+ this.email = email;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+}
diff --git a/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/MyErrorController.java b/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/MyErrorController.java
index d0c548e7bb..caa335ed23 100644
--- a/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/MyErrorController.java
+++ b/spring-boot/src/main/java/com/baeldung/errorhandling/controllers/MyErrorController.java
@@ -15,19 +15,21 @@ public class MyErrorController implements ErrorController {
@RequestMapping(value = "/error")
public String handleError(HttpServletRequest request) {
+
+ Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
- Integer statusCode =
- Integer.valueOf(request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE).toString());
+ if (status != null) {
+
+ Integer statusCode = Integer.valueOf(status.toString());
- if(statusCode == HttpStatus.NOT_FOUND.value()) {
- return "error-404";
- }
- else if(statusCode == HttpStatus.INTERNAL_SERVER_ERROR.value()) {
- return "error-500";
- }
- else {
- return "error";
+ if(statusCode == HttpStatus.NOT_FOUND.value()) {
+ return "error-404";
+ }
+ else if(statusCode == HttpStatus.INTERNAL_SERVER_ERROR.value()) {
+ return "error-500";
+ }
}
+ return "error";
}
@Override
diff --git a/spring-boot/src/main/java/com/baeldung/shutdown/Application.java b/spring-boot/src/main/java/com/baeldung/shutdown/Application.java
index 964e092c10..3d9c71a7b9 100644
--- a/spring-boot/src/main/java/com/baeldung/shutdown/Application.java
+++ b/spring-boot/src/main/java/com/baeldung/shutdown/Application.java
@@ -34,12 +34,9 @@ public class Application {
ConfigurableApplicationContext ctx = new SpringApplicationBuilder(Application.class).web(false).run();
- int exitCode = SpringApplication.exit(ctx, new ExitCodeGenerator() {
- @Override
- public int getExitCode() {
- // return the error code
- return 0;
- }
+ int exitCode = SpringApplication.exit(ctx, () -> {
+ // return the error code
+ return 0;
});
System.out.println("Exit Spring Boot");
diff --git a/spring-boot/src/main/java/org/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java b/spring-boot/src/main/java/org/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java
index 451abdfc37..be33d64c5d 100644
--- a/spring-boot/src/main/java/org/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java
+++ b/spring-boot/src/main/java/org/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java
@@ -1,10 +1,10 @@
package org.baeldung.common.resources;
+import org.springframework.boot.ExitCodeGenerator;
+
import java.util.Objects;
import java.util.concurrent.ExecutorService;
-import org.springframework.boot.ExitCodeGenerator;
-
public class ExecutorServiceExitCodeGenerator implements ExitCodeGenerator {
private ExecutorService executorService;
@@ -14,16 +14,15 @@ public class ExecutorServiceExitCodeGenerator implements ExitCodeGenerator {
@Override
public int getExitCode() {
- int returnCode = 0;
try {
if (!Objects.isNull(executorService)) {
executorService.shutdownNow();
- returnCode = 1;
+ return 1;
}
- } catch (SecurityException ex) {
- returnCode = 0;
- }
- return returnCode;
- }
+ return 0;
+ } catch (SecurityException ex) {
+ return 0;
+ }
+ }
}
diff --git a/spring-boot/src/main/java/org/baeldung/model/User.java b/spring-boot/src/main/java/org/baeldung/model/User.java
index 61936584c4..eb886338a0 100644
--- a/spring-boot/src/main/java/org/baeldung/model/User.java
+++ b/spring-boot/src/main/java/org/baeldung/model/User.java
@@ -15,6 +15,14 @@ public class User {
private String name;
private Integer status;
+ public User() {
+ }
+
+ public User(String name, Integer status) {
+ this.name = name;
+ this.status = status;
+ }
+
public Integer getId() {
return id;
}
diff --git a/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java b/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java
index c9a06b5bab..a5cf6a0c24 100644
--- a/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java
+++ b/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java
@@ -1,10 +1,20 @@
package org.baeldung.repository;
import org.baeldung.model.User;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+import java.util.Collection;
+import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Stream;
@@ -21,4 +31,54 @@ public interface UserRepository extends JpaRepository {
@Async
CompletableFuture findOneByStatus(Integer status);
+ @Query("SELECT u FROM User u WHERE u.status = 1")
+ Collection findAllActiveUsers();
+
+ @Query(value = "SELECT * FROM USERS u WHERE u.status = 1", nativeQuery = true)
+ Collection findAllActiveUsersNative();
+
+ @Query("SELECT u FROM User u WHERE u.status = ?1")
+ User findUserByStatus(Integer status);
+
+ @Query(value = "SELECT * FROM Users u WHERE u.status = ?1", nativeQuery = true)
+ User findUserByStatusNative(Integer status);
+
+ @Query("SELECT u FROM User u WHERE u.status = ?1 and u.name = ?2")
+ User findUserByStatusAndName(Integer status, String name);
+
+ @Query("SELECT u FROM User u WHERE u.status = :status and u.name = :name")
+ User findUserByStatusAndNameNamedParams(@Param("status") Integer status, @Param("name") String name);
+
+ @Query(value = "SELECT * FROM Users u WHERE u.status = :status AND u.name = :name", nativeQuery = true)
+ User findUserByStatusAndNameNamedParamsNative(@Param("status") Integer status, @Param("name") String name);
+
+ @Query("SELECT u FROM User u WHERE u.status = :status and u.name = :name")
+ User findUserByUserStatusAndUserName(@Param("status") Integer userStatus, @Param("name") String userName);
+
+ @Query("SELECT u FROM User u WHERE u.name like ?1%")
+ User findUserByNameLike(String name);
+
+ @Query("SELECT u FROM User u WHERE u.name like :name%")
+ User findUserByNameLikeNamedParam(@Param("name") String name);
+
+ @Query(value = "SELECT * FROM users u WHERE u.name LIKE ?1%", nativeQuery = true)
+ User findUserByNameLikeNative(String name);
+
+ @Query(value = "SELECT u FROM User u")
+ List findAllUsers(Sort sort);
+
+ @Query(value = "SELECT u FROM User u ORDER BY id")
+ Page findAllUsersWithPagination(Pageable pageable);
+
+ @Query(value = "SELECT * FROM Users ORDER BY id \n-- #pageable\n", countQuery = "SELECT count(*) FROM Users", nativeQuery = true)
+ Page findAllUsersWithPaginationNative(Pageable pageable);
+
+ @Modifying
+ @Query("update User u set u.status = :status where u.name = :name")
+ int updateUserSetStatusForName(@Param("status") Integer status, @Param("name") String name);
+
+ @Modifying
+ @Query(value = "UPDATE Users u SET u.status = ? WHERE u.name = ?", nativeQuery = true)
+ int updateUserSetStatusForNameNative(Integer status, String name);
+
}
diff --git a/spring-boot/src/main/resources/templates/error-404.html b/spring-boot/src/main/resources/templates/error-404.html
index 3d3adaefa6..cf68032596 100644
--- a/spring-boot/src/main/resources/templates/error-404.html
+++ b/spring-boot/src/main/resources/templates/error-404.html
@@ -1,7 +1,14 @@
+
+
+
+
-Sorry we couldn't find the resource you are looking for
-Go Home
+
+
+
Sorry, we couldn't find the page you were looking for.
+
Go Home
+
-
+