diff --git a/algorithms-modules/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/maximumsubarray/KadaneAlgorithm.java b/algorithms-modules/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/maximumsubarray/KadaneAlgorithm.java
index 202912a1af..15e813f680 100644
--- a/algorithms-modules/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/maximumsubarray/KadaneAlgorithm.java
+++ b/algorithms-modules/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/maximumsubarray/KadaneAlgorithm.java
@@ -5,7 +5,7 @@ import org.slf4j.LoggerFactory;
public class KadaneAlgorithm {
- private Logger logger = LoggerFactory.getLogger(BruteForceAlgorithm.class.getName());
+ private Logger logger = LoggerFactory.getLogger(KadaneAlgorithm.class.getName());
public int maxSubArraySum(int[] arr) {
@@ -14,15 +14,15 @@ public class KadaneAlgorithm {
int end = 0;
int maxSoFar = arr[0], maxEndingHere = arr[0];
+
for (int i = 1; i < size; i++) {
-
- if (arr[i] > maxEndingHere + arr[i]) {
- start = i;
+ maxEndingHere = maxEndingHere + arr[i];
+ if (arr[i] > maxEndingHere) {
maxEndingHere = arr[i];
- } else {
- maxEndingHere = maxEndingHere + arr[i];
+ if (maxSoFar < maxEndingHere) {
+ start = i;
+ }
}
-
if (maxSoFar < maxEndingHere) {
maxSoFar = maxEndingHere;
end = i;
diff --git a/algorithms-modules/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/maximumsubarray/KadaneAlgorithmUnitTest.java b/algorithms-modules/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/maximumsubarray/KadaneAlgorithmUnitTest.java
index 8dcc81bc5b..b0ce689645 100644
--- a/algorithms-modules/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/maximumsubarray/KadaneAlgorithmUnitTest.java
+++ b/algorithms-modules/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/maximumsubarray/KadaneAlgorithmUnitTest.java
@@ -7,7 +7,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
class KadaneAlgorithmUnitTest {
@Test
- void givenArrayWithNegativeNumberWhenMaximumSubarrayThenReturns6() {
+ void givenArrayWithNegativeNumberWhenMaximumSubarrayThenReturnsExpectedResult() {
//given
int[] arr = new int[] { -3, 1, -8, 4, -1, 2, 1, -5, 5 };
//when
@@ -27,7 +27,7 @@ class KadaneAlgorithmUnitTest {
//then
assertEquals(-1, maxSum);
}
-
+
@Test
void givenArrayWithAllPosiitveNumbersWhenMaximumSubarrayThenReturnsExpectedResult() {
//given
@@ -39,4 +39,15 @@ class KadaneAlgorithmUnitTest {
assertEquals(10, maxSum);
}
+ @Test
+ void givenArrayToTestStartIndexWhenMaximumSubarrayThenReturnsExpectedResult() {
+ //given
+ int[] arr = new int[] { 1, 2, -1, 3, -6, -2 };
+ //when
+ KadaneAlgorithm algorithm = new KadaneAlgorithm();
+ int maxSum = algorithm.maxSubArraySum(arr);
+ //then
+ assertEquals(5, maxSum);
+ }
+
}
\ No newline at end of file
diff --git a/algorithms-modules/algorithms-miscellaneous-7/README.md b/algorithms-modules/algorithms-miscellaneous-7/README.md
index ab07d655f9..82d9df9292 100644
--- a/algorithms-modules/algorithms-miscellaneous-7/README.md
+++ b/algorithms-modules/algorithms-miscellaneous-7/README.md
@@ -3,4 +3,5 @@
- [Algorithm to Identify and Validate a Credit Card Number](https://www.baeldung.com/java-validate-cc-number)
- [Find the N Most Frequent Elements in a Java Array](https://www.baeldung.com/java-n-most-frequent-elements-array)
- [Getting Pixel Array From Image in Java](https://www.baeldung.com/java-getting-pixel-array-from-image)
+- [Calculate Distance Between Two Coordinates in Java](https://www.baeldung.com/java-find-distance-between-points)
- More articles: [[<-- prev]](/algorithms-miscellaneous-6)
diff --git a/apache-cxf-modules/cxf-spring/pom.xml b/apache-cxf-modules/cxf-spring/pom.xml
index 1c87ae4bfb..67a61e8200 100644
--- a/apache-cxf-modules/cxf-spring/pom.xml
+++ b/apache-cxf-modules/cxf-spring/pom.xml
@@ -43,19 +43,19 @@
com.sun.xml.ws
jaxws-ri
- 2.3.3
+ ${jaxws-ri.version}
pom
javax.servlet
javax.servlet-api
- 4.0.1
+ ${javax.servlet-api.version}
provided
javax.servlet
jstl
- 1.2
+ ${jstl.version}
@@ -117,7 +117,9 @@
5.3.25
1.6.1
- 3.3.2
+ 1.2
+ 4.0.1
+ 2.3.3
\ No newline at end of file
diff --git a/apache-httpclient4/pom.xml b/apache-httpclient4/pom.xml
index 21c675db35..f4c213687e 100644
--- a/apache-httpclient4/pom.xml
+++ b/apache-httpclient4/pom.xml
@@ -241,8 +241,6 @@
4.4.16
4.5.14
5.11.2
-
- 3.3.2
\ No newline at end of file
diff --git a/apache-libraries-2/pom.xml b/apache-libraries-2/pom.xml
index 618ff4a188..d188204208 100644
--- a/apache-libraries-2/pom.xml
+++ b/apache-libraries-2/pom.xml
@@ -21,7 +21,6 @@
-
2.0.1.Final
diff --git a/apache-velocity/pom.xml b/apache-velocity/pom.xml
index a562ebeec0..f4b6de8872 100644
--- a/apache-velocity/pom.xml
+++ b/apache-velocity/pom.xml
@@ -63,7 +63,6 @@
4.5.2
1.7
2.0
- 3.3.2
\ No newline at end of file
diff --git a/asm/pom.xml b/asm/pom.xml
index f1e60d2560..4edfe86ae5 100644
--- a/asm/pom.xml
+++ b/asm/pom.xml
@@ -49,7 +49,6 @@
5.2
- 2.4
\ No newline at end of file
diff --git a/aws-modules/aws-s3-update-object/pom.xml b/aws-modules/aws-s3-update-object/pom.xml
index 574a63977b..3cf7b657b0 100644
--- a/aws-modules/aws-s3-update-object/pom.xml
+++ b/aws-modules/aws-s3-update-object/pom.xml
@@ -1,6 +1,7 @@
-
+
4.0.0
aws-s3-update-object
0.0.1-SNAPSHOT
diff --git a/aws-modules/aws-s3/README.md b/aws-modules/aws-s3/README.md
index 3389fdf454..59c9f893d9 100644
--- a/aws-modules/aws-s3/README.md
+++ b/aws-modules/aws-s3/README.md
@@ -8,4 +8,5 @@ This module contains articles about Simple Storage Service (S3) on AWS
- [Multipart Uploads in Amazon S3 with Java](https://www.baeldung.com/aws-s3-multipart-upload)
- [Using the JetS3t Java Client With Amazon S3](https://www.baeldung.com/jets3t-amazon-s3)
- [Check if a Specified Key Exists in a Given S3 Bucket Using Java](https://www.baeldung.com/java-aws-s3-check-specified-key-exists)
-- [Listing All AWS S3 Objects in a Bucket Using Java](https://www.baeldung.com/java-aws-s3-list-bucket-objects)
\ No newline at end of file
+- [Listing All AWS S3 Objects in a Bucket Using Java](https://www.baeldung.com/java-aws-s3-list-bucket-objects)
+- [Update an Existing Amazon S3 Object Using Java](https://www.baeldung.com/java-update-amazon-s3-object)
diff --git a/aws-modules/aws-s3/pom.xml b/aws-modules/aws-s3/pom.xml
index 157aeb671d..e2bc04964a 100644
--- a/aws-modules/aws-s3/pom.xml
+++ b/aws-modules/aws-s3/pom.xml
@@ -1,7 +1,7 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
aws-s3
0.1.0-SNAPSHOT
diff --git a/azure/pom.xml b/azure/pom.xml
index aae84db0c6..6a06282a71 100644
--- a/azure/pom.xml
+++ b/azure/pom.xml
@@ -122,7 +122,6 @@
${azure.containerRegistry}.azurecr.io
1.1.0
1.1.0
- 3.3.2
\ No newline at end of file
diff --git a/core-groovy-modules/pom.xml b/core-groovy-modules/pom.xml
index 6faa7f94c8..4fdaf3ee7a 100644
--- a/core-groovy-modules/pom.xml
+++ b/core-groovy-modules/pom.xml
@@ -27,6 +27,7 @@
2.7.1
2.3-groovy-3.0
2.1.0
+ 2.21.0
diff --git a/core-java-modules/core-java-14/pom.xml b/core-java-modules/core-java-14/pom.xml
index 9f48c0b8b2..55c50b2a5c 100644
--- a/core-java-modules/core-java-14/pom.xml
+++ b/core-java-modules/core-java-14/pom.xml
@@ -48,7 +48,6 @@
14
- 3.8.1
3.0.0-M3
diff --git a/core-java-modules/core-java-15/pom.xml b/core-java-modules/core-java-15/pom.xml
index 059e2cc8f3..3ac45d26ba 100644
--- a/core-java-modules/core-java-15/pom.xml
+++ b/core-java-modules/core-java-15/pom.xml
@@ -53,7 +53,6 @@
15
- 3.8.1
3.0.0-M3
diff --git a/core-java-modules/core-java-17/src/test/java/com/baeldung/multipleorwithif/MultipleOrWithIfUnitTest.java b/core-java-modules/core-java-17/src/test/java/com/baeldung/multipleorwithif/MultipleOrWithIfUnitTest.java
new file mode 100644
index 0000000000..09b8d3c2b1
--- /dev/null
+++ b/core-java-modules/core-java-17/src/test/java/com/baeldung/multipleorwithif/MultipleOrWithIfUnitTest.java
@@ -0,0 +1,126 @@
+package com.baeldung.multipleorwithif;
+
+import static java.time.Month.DECEMBER;
+import static java.time.Month.NOVEMBER;
+import static java.time.Month.OCTOBER;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.in;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.time.Month;
+import java.util.List;
+import java.util.Random;
+import java.util.Set;
+import java.util.function.Predicate;
+
+import org.junit.jupiter.api.Test;
+
+class MultipleOrWithIfUnitTest {
+
+ private final Random rand = new Random();
+
+ final Set months = Set.of(OCTOBER, NOVEMBER, DECEMBER);
+
+ @Test
+ public void givenIfStatement_whenMultipleOrOperator_thenAssert() {
+ assertTrue(multipleOrOperatorIf(monthIn()));
+ assertFalse(multipleOrOperatorIf(monthNotIn()));
+ }
+
+ boolean multipleOrOperatorIf(Month month) {
+ if (month == OCTOBER || month == NOVEMBER || month == DECEMBER) {
+ return true;
+ }
+ return false;
+ }
+
+ @Test
+ public void givenSwitch_whenMultipleCase_thenBreakAndAssert() {
+ assertTrue(switchMonth(monthIn()));
+ assertFalse(switchMonth(monthNotIn()));
+ }
+
+ boolean switchMonth(Month month) {
+ return switch (month) {
+ case OCTOBER, NOVEMBER, DECEMBER -> true;
+ default -> false;
+ };
+ }
+
+ @Test
+ public void givenAllowedValuesList_whenContains_thenAssert() {
+ assertTrue(contains(monthIn()));
+ assertFalse(contains(monthNotIn()));
+ }
+
+ @Test
+ public void givenPredicates_whenTestMultipleOr_thenAssert() {
+ assertTrue(predicateWithIf(monthIn()));
+ assertFalse(predicateWithIf(monthNotIn()));
+ }
+
+ @Test
+ public void givenInputList_whenFilterWithPredicate_thenAssert() {
+
+ List list = List.of(monthIn(), monthIn(), monthNotIn());
+
+ list.stream()
+ .filter(this::predicateWithIf)
+ .forEach(m -> assertThat(m, is(in(months))));
+ }
+
+ Predicate orPredicate() {
+ Predicate predicate = x -> x == OCTOBER;
+ Predicate predicate1 = x -> x == NOVEMBER;
+ Predicate predicate2 = x -> x == DECEMBER;
+
+ return predicate.or(predicate1)
+ .or(predicate2);
+ }
+
+ boolean predicateWithIf(Month month) {
+ if (orPredicate().test(month)) {
+ return true;
+ }
+ return false;
+ }
+
+ @Test
+ public void givenContainsInSetPredicate_whenTestPredicate_thenAssert() {
+ Predicate collectionPredicate = this::contains;
+
+ assertTrue(collectionPredicate.test(monthIn()));
+ assertFalse(collectionPredicate.test(monthNotIn()));
+ }
+
+ @Test
+ public void givenInputList_whenFilterWithContains_thenAssert() {
+
+ List monthList = List.of(monthIn(), monthIn(), monthNotIn());
+
+ monthList.stream()
+ .filter(this::contains)
+ .forEach(m -> assertThat(m, is(in(months))));
+ }
+
+ private boolean contains(Month month) {
+ if (months.contains(month)) {
+ return true;
+ }
+ return false;
+ }
+
+ private Month monthIn() {
+ return Month.of(rand.ints(10, 13)
+ .findFirst()
+ .orElse(10));
+ }
+
+ private Month monthNotIn() {
+ return Month.of(rand.ints(1, 10)
+ .findFirst()
+ .orElse(1));
+ }
+}
\ No newline at end of file
diff --git a/core-java-modules/core-java-9-new-features/pom.xml b/core-java-modules/core-java-9-new-features/pom.xml
index 6821c9c340..9c897f1cea 100644
--- a/core-java-modules/core-java-9-new-features/pom.xml
+++ b/core-java-modules/core-java-9-new-features/pom.xml
@@ -152,7 +152,6 @@
4.0.2
1.9
1.9
- 3.2.0
\ No newline at end of file
diff --git a/core-java-modules/core-java-arrays-operations-advanced/README.md b/core-java-modules/core-java-arrays-operations-advanced/README.md
index e3465c9fa3..b379958f37 100644
--- a/core-java-modules/core-java-arrays-operations-advanced/README.md
+++ b/core-java-modules/core-java-arrays-operations-advanced/README.md
@@ -13,3 +13,4 @@ This module contains articles about advanced operations on arrays in Java. They
- [Performance of System.arraycopy() vs. Arrays.copyOf()](https://www.baeldung.com/java-system-arraycopy-arrays-copyof-performance)
- [Slicing Arrays in Java](https://www.baeldung.com/java-slicing-arrays)
- [Combining Two or More Byte Arrays](https://www.baeldung.com/java-concatenate-byte-arrays)
+- [Calculating the Sum of Two Arrays in Java](https://www.baeldung.com/java-sum-arrays-element-wise)
diff --git a/core-java-modules/core-java-collections-conversions-2/README.md b/core-java-modules/core-java-collections-conversions-2/README.md
index efd01c46ee..e8d008104c 100644
--- a/core-java-modules/core-java-collections-conversions-2/README.md
+++ b/core-java-modules/core-java-collections-conversions-2/README.md
@@ -13,4 +13,5 @@ This module contains articles about conversions among Collection types and array
- [Combining Two Lists Into a Map in Java](https://www.baeldung.com/java-combine-two-lists-into-map)
- [Convert a List of Strings to a List of Integers](https://www.baeldung.com/java-convert-list-strings-to-integers)
- [Convert List to Long[] Array in Java](https://www.baeldung.com/java-convert-list-object-to-long-array)
+- [Get the First n Elements of a List Into an Array](https://www.baeldung.com/java-take-start-elements-list-array)
- More articles: [[<-- prev]](../core-java-collections-conversions)
diff --git a/core-java-modules/core-java-collections-list-5/pom.xml b/core-java-modules/core-java-collections-list-5/pom.xml
index bcdb6824ed..2b4b0041b3 100644
--- a/core-java-modules/core-java-collections-list-5/pom.xml
+++ b/core-java-modules/core-java-collections-list-5/pom.xml
@@ -1,7 +1,7 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
core-java-collections-list-5
core-java-collections-list-5
diff --git a/core-java-modules/core-java-collections-maps-3/README.md b/core-java-modules/core-java-collections-maps-3/README.md
index 68df2b9556..0d07bde8c1 100644
--- a/core-java-modules/core-java-collections-maps-3/README.md
+++ b/core-java-modules/core-java-collections-maps-3/README.md
@@ -9,4 +9,5 @@ This module contains articles about Map data structures in Java.
- [Collections.synchronizedMap vs. ConcurrentHashMap](https://www.baeldung.com/java-synchronizedmap-vs-concurrenthashmap)
- [Java HashMap Load Factor](https://www.baeldung.com/java-hashmap-load-factor)
- [Converting Java Properties to HashMap](https://www.baeldung.com/java-convert-properties-to-hashmap)
+- [Get Values and Keys as ArrayList From a HashMap](https://www.baeldung.com/java-values-keys-arraylists-hashmap)
- More articles: [[<-- prev]](/core-java-modules/core-java-collections-maps-2)
diff --git a/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/producerconsumer/DataQueue.java b/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/producerconsumer/DataQueue.java
index 8867ddeb63..8b6f02b529 100644
--- a/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/producerconsumer/DataQueue.java
+++ b/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/producerconsumer/DataQueue.java
@@ -58,4 +58,8 @@ public class DataQueue {
return queue.poll();
}
}
+
+ public Integer getSize() {
+ return queue.size();
+ }
}
diff --git a/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/producerconsumer/Producer.java b/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/producerconsumer/Producer.java
index 5ca60a29e4..069476bbd1 100644
--- a/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/producerconsumer/Producer.java
+++ b/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/producerconsumer/Producer.java
@@ -1,12 +1,13 @@
package com.baeldung.producerconsumer;
+import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Logger;
public class Producer implements Runnable {
private static final Logger log = Logger.getLogger(Producer.class.getCanonicalName());
private final DataQueue dataQueue;
-
private static int idSequence = 0;
+ final ReentrantLock lock = new ReentrantLock();
public Producer(DataQueue dataQueue) {
this.dataQueue = dataQueue;
@@ -19,22 +20,38 @@ public class Producer implements Runnable {
public void produce() {
while (dataQueue.runFlag) {
- while (dataQueue.isFull() && dataQueue.runFlag) {
- try {
- dataQueue.waitOnFull();
- } catch (InterruptedException e) {
- e.printStackTrace();
+
+ try {
+ lock.lock();
+
+ while (dataQueue.isFull() && dataQueue.runFlag) {
+ try {
+ dataQueue.waitOnFull();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ break;
+ }
+ }
+
+ if (!dataQueue.runFlag) {
break;
}
- }
- if (!dataQueue.runFlag) {
- break;
- }
- Message message = generateMessage();
- dataQueue.add(message);
- dataQueue.notifyAllForEmpty();
+ Message message = generateMessage();
+ dataQueue.add(message);
+ dataQueue.notifyAllForEmpty();
+
+ log.info("Size of the queue is: " + dataQueue.getSize());
+
+ }
+ finally{
+ lock.unlock();
+ }
+
+ //Sleeping on random time to make it realistic
+ ThreadUtil.sleep((long) (Math.random() * 100));
}
+
log.info("Producer Stopped");
}
@@ -43,9 +60,6 @@ public class Producer implements Runnable {
log.info(String.format("[%s] Generated Message. Id: %d, Data: %f%n",
Thread.currentThread().getName(), message.getId(), message.getData()));
- //Sleeping on random time to make it realistic
- ThreadUtil.sleep((long) (message.getData() * 100));
-
return message;
}
diff --git a/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/producerconsumer/ProducerConsumerDemonstrator.java b/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/producerconsumer/ProducerConsumerDemonstrator.java
index 96d7b9f865..eac026536d 100644
--- a/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/producerconsumer/ProducerConsumerDemonstrator.java
+++ b/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/producerconsumer/ProducerConsumerDemonstrator.java
@@ -36,8 +36,8 @@ public class ProducerConsumerDemonstrator {
public static void demoMultipleProducersAndMultipleConsumers() {
DataQueue dataQueue = new DataQueue(MAX_QUEUE_CAPACITY);
- int producerCount = 3;
- int consumerCount = 3;
+ int producerCount = 5;
+ int consumerCount = 5;
List threads = new ArrayList<>();
Producer producer = new Producer(dataQueue);
for(int i = 0; i < producerCount; i++) {
@@ -45,6 +45,7 @@ public class ProducerConsumerDemonstrator {
producerThread.start();
threads.add(producerThread);
}
+
Consumer consumer = new Consumer(dataQueue);
for(int i = 0; i < consumerCount; i++) {
Thread consumerThread = new Thread(consumer);
@@ -52,8 +53,8 @@ public class ProducerConsumerDemonstrator {
threads.add(consumerThread);
}
- // let threads run for two seconds
- sleep(2000);
+ // let threads run for ten seconds
+ sleep(10000);
// Stop threads
producer.stop();
diff --git a/core-java-modules/core-java-concurrency-basic/README.md b/core-java-modules/core-java-concurrency-basic/README.md
index e5c061710c..a133beb1fe 100644
--- a/core-java-modules/core-java-concurrency-basic/README.md
+++ b/core-java-modules/core-java-concurrency-basic/README.md
@@ -11,4 +11,5 @@ This module contains articles about basic Java concurrency
- [Runnable vs. Callable in Java](https://www.baeldung.com/java-runnable-callable)
- [What Is Thread-Safety and How to Achieve It?](https://www.baeldung.com/java-thread-safety)
- [How to Get Notified When a Task Completes in Java Executors](https://www.baeldung.com/java-executors-task-completed-notification)
+- [Difference Between Future, CompletableFuture, and Rxjava’s Observable](https://www.baeldung.com/java-future-completablefuture-rxjavas-observable)
- [[Next -->]](/core-java-modules/core-java-concurrency-basic-2)
diff --git a/core-java-modules/core-java-conditionals/pom.xml b/core-java-modules/core-java-conditionals/pom.xml
index 2a1290c98e..811f183e99 100644
--- a/core-java-modules/core-java-conditionals/pom.xml
+++ b/core-java-modules/core-java-conditionals/pom.xml
@@ -37,20 +37,19 @@
--enable-preview
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${surefire.plugin.version}
-
- --enable-preview
-
-
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${surefire.plugin.version}
+
+ --enable-preview
+
+
14
- 3.8.1
14
3.0.0-M3
diff --git a/core-java-modules/core-java-date-operations-3/pom.xml b/core-java-modules/core-java-date-operations-3/pom.xml
index 19760ca357..9b7be18b85 100644
--- a/core-java-modules/core-java-date-operations-3/pom.xml
+++ b/core-java-modules/core-java-date-operations-3/pom.xml
@@ -12,7 +12,7 @@
core-java-modules
0.0.1-SNAPSHOT
-
+
joda-time
@@ -25,7 +25,7 @@
${commons-lang3.version}
-
+
2.12.5
3.12.0
diff --git a/core-java-modules/core-java-datetime-conversion/README.md b/core-java-modules/core-java-datetime-conversion/README.md
index 98c2d6694b..d3a3dae728 100644
--- a/core-java-modules/core-java-datetime-conversion/README.md
+++ b/core-java-modules/core-java-datetime-conversion/README.md
@@ -9,3 +9,4 @@ This module contains articles about converting between Java date and time object
- [Convert Between java.time.Instant and java.sql.Timestamp](https://www.baeldung.com/java-time-instant-to-java-sql-timestamp)
- [Convert Between LocalDateTime and ZonedDateTime](https://www.baeldung.com/java-localdatetime-zoneddatetime)
- [Conversion From 12-Hour Time to 24-Hour Time in Java](https://www.baeldung.com/java-convert-time-format)
+- [Convert Epoch Time to LocalDate and LocalDateTime](https://www.baeldung.com/java-convert-epoch-localdate)
diff --git a/core-java-modules/core-java-io/pom.xml b/core-java-modules/core-java-io/pom.xml
index 8364f36874..59952c2d9e 100644
--- a/core-java-modules/core-java-io/pom.xml
+++ b/core-java-modules/core-java-io/pom.xml
@@ -132,7 +132,6 @@
2.8.0
0.1.5
- 3.3.0
4.4.2
2.1.2
2.0.1
diff --git a/core-java-modules/core-java-jar/pom.xml b/core-java-modules/core-java-jar/pom.xml
index ec88abe444..a46299c669 100644
--- a/core-java-modules/core-java-jar/pom.xml
+++ b/core-java-modules/core-java-jar/pom.xml
@@ -275,7 +275,6 @@
1.1
3.0.0-M1
- 3.0.2
1.4.4
3.1.1
3.3.0
diff --git a/core-java-modules/core-java-lang-6/pom.xml b/core-java-modules/core-java-lang-6/pom.xml
index 86121e0a7f..53ef36a898 100644
--- a/core-java-modules/core-java-lang-6/pom.xml
+++ b/core-java-modules/core-java-lang-6/pom.xml
@@ -1,7 +1,7 @@
+ 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.core-java-modules
diff --git a/core-java-modules/core-java-lang-oop-inheritance/README.md b/core-java-modules/core-java-lang-oop-inheritance/README.md
index c87bdf13d7..430f88e717 100644
--- a/core-java-modules/core-java-lang-oop-inheritance/README.md
+++ b/core-java-modules/core-java-lang-oop-inheritance/README.md
@@ -12,3 +12,4 @@ This module contains articles about inheritance in Java
- [Guide to Inheritance in Java](https://www.baeldung.com/java-inheritance)
- [Object Type Casting in Java](https://www.baeldung.com/java-type-casting)
- [Variable and Method Hiding in Java](https://www.baeldung.com/java-variable-method-hiding)
+- [Inner Classes Vs. Subclasses in Java](https://www.baeldung.com/java-inner-classes-vs-subclasses)
diff --git a/core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/modulo/ModuloUnitTest.java b/core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/modulo/ModuloUnitTest.java
index 8b3685adf3..0a9418cb17 100644
--- a/core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/modulo/ModuloUnitTest.java
+++ b/core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/modulo/ModuloUnitTest.java
@@ -1,54 +1,77 @@
package com.baeldung.modulo;
+import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
import static org.assertj.core.api.Java6Assertions.*;
public class ModuloUnitTest {
- @Test
- public void whenIntegerDivision_thenLosesRemainder(){
- assertThat(11 / 4).isEqualTo(2);
- }
-
- @Test
- public void whenDoubleDivision_thenKeepsRemainder(){
- assertThat(11 / 4.0).isEqualTo(2.75);
- }
-
- @Test
- public void whenModulo_thenReturnsRemainder(){
- assertThat(11 % 4).isEqualTo(3);
- }
-
- @Test(expected = ArithmeticException.class)
- public void whenDivisionByZero_thenArithmeticException(){
- double result = 1 / 0;
- }
-
- @Test(expected = ArithmeticException.class)
- public void whenModuloByZero_thenArithmeticException(){
- double result = 1 % 0;
- }
-
- @Test
- public void whenDivisorIsOddAndModulusIs2_thenResultIs1(){
- assertThat(3 % 2).isEqualTo(1);
- }
-
- @Test
- public void whenDivisorIsEvenAndModulusIs2_thenResultIs0(){
- assertThat(4 % 2).isEqualTo(0);
- }
-
- @Test
- public void whenItemsIsAddedToCircularQueue_thenNoArrayIndexOutOfBounds(){
- int QUEUE_CAPACITY= 10;
- int[] circularQueue = new int[QUEUE_CAPACITY];
- int itemsInserted = 0;
- for (int value = 0; value < 1000; value++) {
- int writeIndex = ++itemsInserted % QUEUE_CAPACITY;
- circularQueue[writeIndex] = value;
+ @Test
+ public void whenIntegerDivision_thenLosesRemainder() {
+ assertThat(11 / 4).isEqualTo(2);
+ }
+
+ @Test
+ public void whenDoubleDivision_thenKeepsRemainder() {
+ assertThat(11 / 4.0).isEqualTo(2.75);
+ }
+
+ @Test
+ public void whenModulo_thenReturnsRemainder() {
+ assertThat(11 % 4).isEqualTo(3);
+ }
+
+ @Test(expected = ArithmeticException.class)
+ public void whenDivisionByZero_thenArithmeticException() {
+ double result = 1 / 0;
+ }
+
+ @Test(expected = ArithmeticException.class)
+ public void whenModuloByZero_thenArithmeticException() {
+ double result = 1 % 0;
+ }
+
+ @Test
+ public void whenDivisorIsOddAndModulusIs2_thenResultIs1() {
+ assertThat(3 % 2).isEqualTo(1);
+ }
+
+ @Test
+ public void whenDivisorIsEvenAndModulusIs2_thenResultIs0() {
+ assertThat(4 % 2).isEqualTo(0);
+ }
+
+ @Test
+ public void whenDividendIsNegativeAndModulusIs2_thenResultIsNegative() {
+ assertEquals(-1, -9 % 2);
+ }
+
+ @Test
+ public void whenDividendIsNegativeAndRemainderIsCheckedForNegativeValue_thenResultIsPositive() {
+ int remainder = -9 % 2;
+
+ if (remainder < 0) {
+ remainder += 2;
+ }
+ assertEquals(1, remainder);
+ }
+
+ @Test
+ public void whenDividendIsNegativeAndUsesMathClass_thenResultIsPositive() {
+ int remainder = Math.floorMod(-9, 2);
+ assertEquals(1, remainder);
+ }
+
+ @Test
+ public void whenItemsIsAddedToCircularQueue_thenNoArrayIndexOutOfBounds() {
+ int QUEUE_CAPACITY = 10;
+ int[] circularQueue = new int[QUEUE_CAPACITY];
+ int itemsInserted = 0;
+ for (int value = 0; value < 1000; value++) {
+ int writeIndex = ++itemsInserted % QUEUE_CAPACITY;
+ circularQueue[writeIndex] = value;
+ }
}
- }
}
diff --git a/core-java-modules/core-java-regex-2/src/test/java/com/baeldung/regex/indexesofmatches/IndexesOfMatchesUnitTest.java b/core-java-modules/core-java-regex-2/src/test/java/com/baeldung/regex/indexesofmatches/IndexesOfMatchesUnitTest.java
new file mode 100644
index 0000000000..7fb2afcdea
--- /dev/null
+++ b/core-java-modules/core-java-regex-2/src/test/java/com/baeldung/regex/indexesofmatches/IndexesOfMatchesUnitTest.java
@@ -0,0 +1,75 @@
+package com.baeldung.regex.indexesofmatches;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.junit.jupiter.api.Test;
+
+public class IndexesOfMatchesUnitTest {
+ private static final String INPUT = "This line contains , , and .";
+
+ @Test
+ void whenUsingNorCharClass_thenGetExpectedTexts() {
+ Pattern pattern = Pattern.compile("<[^>]*>");
+ Matcher matcher = pattern.matcher(INPUT);
+ List result = new ArrayList<>();
+ while (matcher.find()) {
+ result.add(matcher.group());
+ }
+ assertThat(result).containsExactly("", "", "");
+ }
+
+ @Test
+ void whenCallingMatcherEnd_thenGetIndexesAfterTheMatchSequence() {
+ Pattern pattern = Pattern.compile("456");
+ Matcher matcher = pattern.matcher("0123456789");
+ String result = null;
+ int startIdx = -1;
+ int endIdx = -1;
+ if (matcher.find()) {
+ result = matcher.group();
+ startIdx = matcher.start();
+ endIdx = matcher.end();
+ }
+ assertThat(result).isEqualTo("456");
+ assertThat(startIdx).isEqualTo(4);
+ assertThat(endIdx).isEqualTo(7);
+ }
+
+ @Test
+ void whenUsingMatcherStartAndEnd_thenGetIndexesOfMatches() {
+ Pattern pattern = Pattern.compile("<[^>]*>");
+ Matcher matcher = pattern.matcher(INPUT);
+ List result = new ArrayList<>();
+ Map indexesOfMatches = new LinkedHashMap<>();
+ while (matcher.find()) {
+ result.add(matcher.group());
+ indexesOfMatches.put(matcher.start(), matcher.end());
+ }
+ assertThat(result).containsExactly("", "", "");
+ assertThat(indexesOfMatches.entrySet()).map(entry -> INPUT.substring(entry.getKey(), entry.getValue()))
+ .containsExactly("", "", "");
+ }
+
+ @Test
+ void whenUsingMatcherStartAndEndWithGroupIdx_thenGetIndexesOfMatches() {
+ Pattern pattern = Pattern.compile("<([^>]*)>");
+ Matcher matcher = pattern.matcher(INPUT);
+ List result = new ArrayList<>();
+ Map indexesOfMatches = new LinkedHashMap<>();
+ while (matcher.find()) {
+ result.add(matcher.group(1));
+ indexesOfMatches.put(matcher.start(1), matcher.end(1));
+ }
+ assertThat(result).containsExactly("the first value", "the second value", "the third value");
+
+ assertThat(indexesOfMatches.entrySet()).map(entry -> INPUT.substring(entry.getKey(), entry.getValue()))
+ .containsExactly("the first value", "the second value", "the third value");
+ }
+}
\ No newline at end of file
diff --git a/core-java-modules/core-java-regex-2/src/test/java/com/baeldung/regex/squarebrackets/ExtractTextBetweenSquareBracketsUnitTest.java b/core-java-modules/core-java-regex-2/src/test/java/com/baeldung/regex/squarebrackets/ExtractTextBetweenSquareBracketsUnitTest.java
new file mode 100644
index 0000000000..2ea80a1f69
--- /dev/null
+++ b/core-java-modules/core-java-regex-2/src/test/java/com/baeldung/regex/squarebrackets/ExtractTextBetweenSquareBracketsUnitTest.java
@@ -0,0 +1,98 @@
+package com.baeldung.regex.squarebrackets;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.junit.jupiter.api.Test;
+
+import com.google.common.collect.Lists;
+
+public class ExtractTextBetweenSquareBracketsUnitTest {
+ static final String INPUT1 = "some text [THE IMPORTANT MESSAGE] something else";
+ static final String EXPECTED1 = "THE IMPORTANT MESSAGE";
+
+ static final String INPUT2 = "[La La Land], [The last Emperor], and [Life of Pi] are all great movies.";
+ static final List EXPECTED2 = Lists.newArrayList("La La Land", "The last Emperor", "Life of Pi");
+
+ @Test
+ void whenUsingDotStarOnInput1_thenGetExpectedResult() {
+ String result = null;
+ String rePattern = "\\[(.*)]";
+ Pattern p = Pattern.compile(rePattern);
+ Matcher m = p.matcher(INPUT1);
+ if (m.find()) {
+ result = m.group(1);
+ }
+ assertThat(result).isEqualTo(EXPECTED1);
+ }
+
+ @Test
+ void whenUsingCharClassOnInput1_thenGetExpectedResult() {
+ String result = null;
+ String rePattern = "\\[([^]]*)";
+ Pattern p = Pattern.compile(rePattern);
+ Matcher m = p.matcher(INPUT1);
+ if (m.find()) {
+ result = m.group(1);
+ }
+ assertThat(result).isEqualTo(EXPECTED1);
+ }
+
+ @Test
+ void whenUsingSplitOnInput1_thenGetExpectedResult() {
+ String[] strArray = INPUT1.split("[\\[\\]]", -1);
+ String result = strArray.length == 3 ? strArray[1] : null;
+
+ assertThat(result).isEqualTo(EXPECTED1);
+ }
+
+ @Test
+ void whenUsingSplitWithLimit_thenGetExpectedResult() {
+ String[] strArray = "[THE IMPORTANT MESSAGE]".split("[\\[\\]]");
+ assertThat(strArray).hasSize(2)
+ .containsExactly("", "THE IMPORTANT MESSAGE");
+
+ strArray = "[THE IMPORTANT MESSAGE]".split("[\\[\\]]", -1);
+ assertThat(strArray).hasSize(3)
+ .containsExactly("", "THE IMPORTANT MESSAGE", "");
+ }
+
+ @Test
+ void whenUsingNonGreedyOnInput2_thenGetExpectedResult() {
+ List result = new ArrayList<>();
+ String rePattern = "\\[(.*?)]";
+ Pattern p = Pattern.compile(rePattern);
+ Matcher m = p.matcher(INPUT2);
+ while (m.find()) {
+ result.add(m.group(1));
+ }
+ assertThat(result).isEqualTo(EXPECTED2);
+ }
+
+ @Test
+ void whenUsingCharClassOnInput2_thenGetExpectedResult() {
+ List result = new ArrayList<>();
+ String rePattern = "\\[([^]]*)";
+ Pattern p = Pattern.compile(rePattern);
+ Matcher m = p.matcher(INPUT2);
+ while (m.find()) {
+ result.add(m.group(1));
+ }
+ assertThat(result).isEqualTo(EXPECTED2);
+ }
+
+ @Test
+ void whenUsingSplitInput2_thenGetExpectedResult() {
+ List result = new ArrayList<>();
+ String[] strArray = INPUT2.split("[\\[\\]]", -1);
+ for (int i = 1; i < strArray.length; i += 2) {
+ result.add(strArray[i]);
+ }
+ assertThat(result).isEqualTo(EXPECTED2);
+ }
+
+}
\ No newline at end of file
diff --git a/core-java-modules/core-java-scanner/pom.xml b/core-java-modules/core-java-scanner/pom.xml
index f149f51955..bb5c7dca78 100644
--- a/core-java-modules/core-java-scanner/pom.xml
+++ b/core-java-modules/core-java-scanner/pom.xml
@@ -1,7 +1,7 @@
+ 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
core-java-scanner
core-java-scanner
diff --git a/core-java-modules/core-java-streams-4/pom.xml b/core-java-modules/core-java-streams-4/pom.xml
index 0b9b3569f1..e832cc1616 100644
--- a/core-java-modules/core-java-streams-4/pom.xml
+++ b/core-java-modules/core-java-streams-4/pom.xml
@@ -115,7 +115,6 @@
3.23.1
- 3.1
12
12
1.2.5
diff --git a/core-java-modules/core-java-streams-5/pom.xml b/core-java-modules/core-java-streams-5/pom.xml
index abbdb504c1..dc97d81b3d 100644
--- a/core-java-modules/core-java-streams-5/pom.xml
+++ b/core-java-modules/core-java-streams-5/pom.xml
@@ -69,7 +69,6 @@
- 3.1
12
12
0.10.2
diff --git a/core-java-modules/core-java-streams-maps/pom.xml b/core-java-modules/core-java-streams-maps/pom.xml
index 66e1fedd87..6b04897a29 100644
--- a/core-java-modules/core-java-streams-maps/pom.xml
+++ b/core-java-modules/core-java-streams-maps/pom.xml
@@ -58,7 +58,6 @@
- 3.1
1.8
1.8
diff --git a/core-java-modules/core-java-string-operations-6/pom.xml b/core-java-modules/core-java-string-operations-6/pom.xml
index 0ec32d91b1..ca9a7a9297 100644
--- a/core-java-modules/core-java-string-operations-6/pom.xml
+++ b/core-java-modules/core-java-string-operations-6/pom.xml
@@ -1,7 +1,7 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
core-java-string-operations-6
core-java-string-operations-6
diff --git a/core-java-modules/core-java-string-operations/pom.xml b/core-java-modules/core-java-string-operations/pom.xml
index 577736a324..601d0341a3 100644
--- a/core-java-modules/core-java-string-operations/pom.xml
+++ b/core-java-modules/core-java-string-operations/pom.xml
@@ -15,30 +15,20 @@
- javax.xml.bind
- jaxb-api
- 2.4.0-b180725.0427
+ jakarta.xml.bind
+ jakarta.xml.bind-api
+ ${jakarta.xml.bind-api.version}
org.apache.commons
commons-lang3
${commons-lang3.version}
-
- org.openjdk.jmh
- jmh-core
- ${jmh-core.version}
-
log4j
log4j
${log4j.version}
-
- org.openjdk.jmh
- jmh-generator-annprocess
- ${jmh-generator.version}
-
commons-codec
commons-codec
@@ -57,7 +47,8 @@
- 1.15
+ 1.16.0
+ 4.0.0
\ No newline at end of file
diff --git a/core-java-modules/core-java-string-operations/src/test/java/com/baeldung/base64encodinganddecoding/StringToByteArrayUnitTest.java b/core-java-modules/core-java-string-operations/src/test/java/com/baeldung/base64encodinganddecoding/StringToByteArrayUnitTest.java
index 6f8a17e316..491574f0f1 100644
--- a/core-java-modules/core-java-string-operations/src/test/java/com/baeldung/base64encodinganddecoding/StringToByteArrayUnitTest.java
+++ b/core-java-modules/core-java-string-operations/src/test/java/com/baeldung/base64encodinganddecoding/StringToByteArrayUnitTest.java
@@ -2,7 +2,7 @@ package com.baeldung.base64encodinganddecoding;
import org.junit.Test;
-import javax.xml.bind.DatatypeConverter;
+import jakarta.xml.bind.DatatypeConverter;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
diff --git a/di-modules/avaje/pom.xml b/di-modules/avaje/pom.xml
index 7ffe14bd72..49162c518e 100644
--- a/di-modules/avaje/pom.xml
+++ b/di-modules/avaje/pom.xml
@@ -1,37 +1,37 @@
- 4.0.0
- com.baeldung
- inject-intro
- 0.0.1-SNAPSHOT
- avaje-inject-intro
-
- 11
- 11
- 9.5
-
-
-
- io.avaje
- avaje-inject
- ${avaje.inject.version}
-
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ com.baeldung
+ inject-intro
+ 0.0.1-SNAPSHOT
+ avaje-inject-intro
+
+ 11
+ 11
+ 9.5
+
+
+
+ io.avaje
+ avaje-inject
+ ${avaje.inject.version}
+
-
- io.avaje
- avaje-inject-test
- ${avaje.inject.version}
- test
-
+
+ io.avaje
+ avaje-inject-test
+ ${avaje.inject.version}
+ test
+
-
-
- io.avaje
- avaje-inject-generator
- ${avaje.inject.version}
- provided
- true
-
-
+
+
+ io.avaje
+ avaje-inject-generator
+ ${avaje.inject.version}
+ provided
+ true
+
+
\ No newline at end of file
diff --git a/disruptor/pom.xml b/disruptor/pom.xml
index 75e783e935..b3b065d67e 100644
--- a/disruptor/pom.xml
+++ b/disruptor/pom.xml
@@ -119,7 +119,6 @@
3.3.6
2.4.3
- 3.0.2
1.4.4
diff --git a/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/date/JacksonDateUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/date/JacksonDateUnitTest.java
index 047d53ab62..4dc9e40292 100644
--- a/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/date/JacksonDateUnitTest.java
+++ b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/date/JacksonDateUnitTest.java
@@ -20,6 +20,7 @@ import org.joda.time.DateTimeZone;
import org.junit.Test;
import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.util.StdDateFormat;
@@ -67,6 +68,8 @@ public class JacksonDateUnitTest {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.findAndRegisterModules();
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ objectMapper.enable(SerializationFeature.WRITE_DATES_WITH_ZONE_ID);
+ objectMapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE);
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC"));
String converted = objectMapper.writeValueAsString(now);
diff --git a/jackson-modules/jackson-polymorphic-deserialization/pom.xml b/jackson-modules/jackson-polymorphic-deserialization/pom.xml
index afa9cab82f..0d88c19500 100644
--- a/jackson-modules/jackson-polymorphic-deserialization/pom.xml
+++ b/jackson-modules/jackson-polymorphic-deserialization/pom.xml
@@ -1,7 +1,7 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
jackson-polymorphic-deserialization
jackson-polymorphic-deserialization
diff --git a/java-websocket/pom.xml b/java-websocket/pom.xml
index 7c5c006aa9..d529b32022 100644
--- a/java-websocket/pom.xml
+++ b/java-websocket/pom.xml
@@ -30,7 +30,6 @@
1.1
2.8.0
- 3.3.2
\ No newline at end of file
diff --git a/javaxval/README.md b/javaxval/README.md
index 7420580f8e..be8c3b51b7 100644
--- a/javaxval/README.md
+++ b/javaxval/README.md
@@ -3,7 +3,7 @@
This module contains articles about Bean Validation.
### Relevant Articles:
-- [Java Bean Validation Basics](https://www.baeldung.com/javax-validation)
+- [Java Bean Validation Basics](https://www.baeldung.com/java-validation)
- [Validating Container Elements with Jakarta Bean Validation 3.0](https://www.baeldung.com/bean-validation-container-elements)
- [Validations for Enum Types](https://www.baeldung.com/javax-validations-enums)
- [Javax BigDecimal Validation](https://www.baeldung.com/javax-bigdecimal-validation)
diff --git a/jersey/pom.xml b/jersey/pom.xml
index 005fa85077..c2b37f7118 100644
--- a/jersey/pom.xml
+++ b/jersey/pom.xml
@@ -100,7 +100,6 @@
3.1.1
- 3.3.2
\ No newline at end of file
diff --git a/jhipster-modules/jhipster-microservice/car-app/pom.xml b/jhipster-modules/jhipster-microservice/car-app/pom.xml
index f345688939..9ecf471bc2 100644
--- a/jhipster-modules/jhipster-microservice/car-app/pom.xml
+++ b/jhipster-modules/jhipster-microservice/car-app/pom.xml
@@ -1,5 +1,7 @@
-
+
4.0.0
@@ -45,8 +47,8 @@
3.1.3
v6.10.0
-
-
+
+
${project.build.directory}/test-results
0.0.20
@@ -440,7 +442,7 @@
-
+
@@ -634,9 +636,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
@@ -683,7 +685,7 @@
org.apache.maven.plugins
maven-war-plugin
-
+
@@ -722,7 +724,7 @@
org.apache.maven.plugins
maven-war-plugin
-
+
org.springframework.boot
diff --git a/jhipster-modules/jhipster-microservice/dealer-app/pom.xml b/jhipster-modules/jhipster-microservice/dealer-app/pom.xml
index 056bd60f33..33a238c96c 100644
--- a/jhipster-modules/jhipster-microservice/dealer-app/pom.xml
+++ b/jhipster-modules/jhipster-microservice/dealer-app/pom.xml
@@ -1,5 +1,7 @@
-
+
4.0.0
@@ -44,8 +46,8 @@
3.1.3
v6.10.0
-
-
+
+
${project.build.directory}/test-results
0.0.20
@@ -439,7 +441,7 @@
-
+
@@ -633,9 +635,9 @@
src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml
org.h2.Driver
jdbc:h2:file:./target/h2db/db/dealerapp
-
+
dealerapp
-
+
hibernate:spring:com.dealer.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
@@ -682,7 +684,7 @@
org.apache.maven.plugins
maven-war-plugin
-
+
@@ -721,7 +723,7 @@
org.apache.maven.plugins
maven-war-plugin
-
+
org.springframework.boot
diff --git a/jhipster-modules/jhipster-microservice/gateway-app/pom.xml b/jhipster-modules/jhipster-microservice/gateway-app/pom.xml
index b90f22f009..3956475380 100644
--- a/jhipster-modules/jhipster-microservice/gateway-app/pom.xml
+++ b/jhipster-modules/jhipster-microservice/gateway-app/pom.xml
@@ -1,5 +1,7 @@
-
+
4.0.0
@@ -48,8 +50,8 @@
3.1.3
v6.10.0
-
-
+
+
${project.build.directory}/test-results
0.0.20
@@ -481,7 +483,7 @@
-
+
@@ -497,7 +499,7 @@
-
+
@@ -691,9 +693,9 @@
src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml
org.h2.Driver
jdbc:h2:file:./target/h2db/db/gateway
-
+
gateway
-
+
hibernate:spring:com.gateway.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
diff --git a/jmh/pom.xml b/jmh/pom.xml
index e5e0f46044..e8a88bf301 100644
--- a/jmh/pom.xml
+++ b/jmh/pom.xml
@@ -83,10 +83,8 @@
- 3.3.0
0.17
3.5.0
- 3.11.0
\ No newline at end of file
diff --git a/jsf/pom.xml b/jsf/pom.xml
index 81030537fb..09dea98f65 100644
--- a/jsf/pom.xml
+++ b/jsf/pom.xml
@@ -76,8 +76,6 @@
2.2.14
3.0.0
-
- 3.3.1
1.3.1
diff --git a/json-modules/json-2/README.md b/json-modules/json-2/README.md
index a29484d9fc..f41a7047fa 100644
--- a/json-modules/json-2/README.md
+++ b/json-modules/json-2/README.md
@@ -13,5 +13,6 @@ This module contains articles about JSON.
- [Getting a Value in JSONObject](https://www.baeldung.com/java-jsonobject-get-value)
- [Pretty-Print a JSON in Java](https://www.baeldung.com/java-json-pretty-print)
- [Remove Whitespaces From a JSON in Java](https://www.baeldung.com/java-json-minify-remove-whitespaces)
+- [Programmatic Generation of JSON Schemas in Java](https://www.baeldung.com/java-json-schema-create-automatically)
- More Articles: [[<-- prev]](/json-modules/json)
diff --git a/json-modules/json-arrays/README.md b/json-modules/json-arrays/README.md
new file mode 100644
index 0000000000..f119467046
--- /dev/null
+++ b/json-modules/json-arrays/README.md
@@ -0,0 +1,2 @@
+## Relevant Articles
+- [How to Check if a Value Exists in a JSON Array for a Particular Key](https://www.baeldung.com/java-json-array-check-key-value-pair)
diff --git a/json-modules/json-conversion/pom.xml b/json-modules/json-conversion/pom.xml
index 1af13cbbcb..365c6d2ac9 100644
--- a/json-modules/json-conversion/pom.xml
+++ b/json-modules/json-conversion/pom.xml
@@ -1,7 +1,7 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.baeldung
json-conversion
diff --git a/jws/pom.xml b/jws/pom.xml
index 2f01f90721..12aa76127c 100644
--- a/jws/pom.xml
+++ b/jws/pom.xml
@@ -61,8 +61,4 @@
-
- 3.0.2
-
-
diff --git a/kubernetes-modules/jkube-demo/pom.xml b/kubernetes-modules/jkube-demo/pom.xml
index 7bb662c4a3..6fedc0f24a 100644
--- a/kubernetes-modules/jkube-demo/pom.xml
+++ b/kubernetes-modules/jkube-demo/pom.xml
@@ -1,6 +1,7 @@
-
+
4.0.0
com.baeldung
diff --git a/libraries-data-2/pom.xml b/libraries-data-2/pom.xml
index e19067daa3..0620dd69ea 100644
--- a/libraries-data-2/pom.xml
+++ b/libraries-data-2/pom.xml
@@ -92,7 +92,7 @@
suanshu
${suanshu.version}
- -->
+ -->
org.derive4j
derive4j
@@ -162,7 +162,7 @@
-
+
2.22.2
- 3.8.1
- 3.0.0
+ 3.11.0
+ 3.1.0
1.8
1.2.17
1.36
1.36
- 2.21.0
+ 3.1.2
4.4
2.13.0
2.6
3.13.0
1.5.0
- 3.3.2
+ 3.4.0
4.0.1
1.2
2.3.3
@@ -1292,16 +1292,16 @@
1.9.2
5.9.2
1.3.2
- 0.3.1
- 2.5.2
+ 1.0
+ 3.1.1
0.0.1
3.12.2
- 3.0.0
- 3.19.0
+ 3.3.0
+ 3.21.0
1.18.28
2.1.214
32.1.2-jre
- 3.2.2
+ 3.3.0
diff --git a/quarkus-modules/quarkus-vs-springboot/spring-project/pom.xml b/quarkus-modules/quarkus-vs-springboot/spring-project/pom.xml
index df3eca8a4f..74deab3558 100644
--- a/quarkus-modules/quarkus-vs-springboot/spring-project/pom.xml
+++ b/quarkus-modules/quarkus-vs-springboot/spring-project/pom.xml
@@ -255,7 +255,6 @@
1.17.2
11
0.12.1
- 3.10.1
11
11
3.1.0
diff --git a/saas-modules/sentry-servlet/pom.xml b/saas-modules/sentry-servlet/pom.xml
index 4f9e37ebd5..70f6876dee 100644
--- a/saas-modules/sentry-servlet/pom.xml
+++ b/saas-modules/sentry-servlet/pom.xml
@@ -46,6 +46,5 @@
6.11.0
1.10.4
- 3.3.2
\ No newline at end of file
diff --git a/saas-modules/slack/pom.xml b/saas-modules/slack/pom.xml
index 326167c055..d9e7abb4a2 100644
--- a/saas-modules/slack/pom.xml
+++ b/saas-modules/slack/pom.xml
@@ -55,7 +55,6 @@
1.4
- 2.4
\ No newline at end of file
diff --git a/security-modules/pom.xml b/security-modules/pom.xml
index b779c0d46d..864b1a7fcc 100644
--- a/security-modules/pom.xml
+++ b/security-modules/pom.xml
@@ -25,8 +25,4 @@
sql-injection-samples
-
- 3.3.2
-
-
diff --git a/server-modules/undertow/pom.xml b/server-modules/undertow/pom.xml
index 42a46d9508..a73771485c 100644
--- a/server-modules/undertow/pom.xml
+++ b/server-modules/undertow/pom.xml
@@ -46,7 +46,6 @@
1.4.18.Final
- 3.0.2
\ No newline at end of file
diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml
index a2febc8156..f87446b413 100644
--- a/spring-boot-modules/pom.xml
+++ b/spring-boot-modules/pom.xml
@@ -44,7 +44,7 @@
spring-boot-graphql
spring-boot-groovy
-
+ spring-boot-jasypt
spring-boot-jsp
spring-boot-keycloak
spring-boot-keycloak-2
@@ -91,6 +91,7 @@
spring-boot-3-native
spring-boot-3-observation
spring-boot-3-test-pitfalls
+ spring-boot-3-testcontainers
spring-boot-resilience4j
spring-boot-properties
spring-boot-properties-2
@@ -119,8 +120,4 @@
-
- 3.3.2
-
-
diff --git a/spring-boot-modules/spring-boot-3-testcontainers/README.md b/spring-boot-modules/spring-boot-3-testcontainers/README.md
new file mode 100644
index 0000000000..5616cce48b
--- /dev/null
+++ b/spring-boot-modules/spring-boot-3-testcontainers/README.md
@@ -0,0 +1 @@
+## Relevant Articles
diff --git a/spring-boot-modules/spring-boot-3-testcontainers/pom.xml b/spring-boot-modules/spring-boot-3-testcontainers/pom.xml
new file mode 100644
index 0000000000..173fb8795c
--- /dev/null
+++ b/spring-boot-modules/spring-boot-3-testcontainers/pom.xml
@@ -0,0 +1,102 @@
+
+
+ 4.0.0
+ spring-boot-3-testcontainers
+ 0.0.1-SNAPSHOT
+ spring-boot-3-testcontainers
+ Testcontainer Improvements in Spring Boot 3
+
+
+ com.baeldung
+ parent-boot-3
+ 0.0.1-SNAPSHOT
+ ../../parent-boot-3
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+
+
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+
+
+
+ org.springframework.boot
+ spring-boot-testcontainers
+
+
+
+ org.testcontainers
+ mongodb
+ ${testcontainers.version}
+ test
+
+
+ org.testcontainers
+ testcontainers
+ ${testcontainers.version}
+ test
+
+
+ org.testcontainers
+ junit-jupiter
+ ${testcontainers.version}
+ test
+
+
+
+ io.rest-assured
+ rest-assured
+ ${rest-assured.version}
+ test
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+ 3.0.0-M7
+ 1.18.3
+ 5.3.1
+
+
+
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/Application.java b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/Application.java
new file mode 100644
index 0000000000..9a00bfebf2
--- /dev/null
+++ b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/Application.java
@@ -0,0 +1,14 @@
+package com.baeldung.testcontainers;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
+
+@SpringBootApplication
+public class Application {
+
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+
+}
diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharacter.java b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharacter.java
new file mode 100644
index 0000000000..4780a2f66a
--- /dev/null
+++ b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharacter.java
@@ -0,0 +1,13 @@
+package com.baeldung.testcontainers.support;
+
+import java.util.UUID;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+@Document("characters")
+public record MiddleEarthCharacter(@Id String id, String name, String race) {
+ public MiddleEarthCharacter(String name, String race) {
+ this(UUID.randomUUID().toString(), name, race);
+ }
+}
diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharactersController.java b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharactersController.java
new file mode 100644
index 0000000000..3b7bfddbef
--- /dev/null
+++ b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharactersController.java
@@ -0,0 +1,30 @@
+package com.baeldung.testcontainers.support;
+
+import java.util.List;
+
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("characters")
+public class MiddleEarthCharactersController {
+ private final MiddleEarthCharactersRepository repository;
+
+ public MiddleEarthCharactersController(MiddleEarthCharactersRepository repository) {
+ this.repository = repository;
+ }
+
+ @GetMapping
+ public List findByRace(@RequestParam String race) {
+ return repository.findAllByRace(race);
+ }
+
+ @PostMapping
+ public MiddleEarthCharacter save(@RequestBody MiddleEarthCharacter character) {
+ return repository.save(character);
+ }
+}
diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharactersRepository.java b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharactersRepository.java
new file mode 100644
index 0000000000..a668650670
--- /dev/null
+++ b/spring-boot-modules/spring-boot-3-testcontainers/src/main/java/com/baeldung/testcontainers/support/MiddleEarthCharactersRepository.java
@@ -0,0 +1,11 @@
+package com.baeldung.testcontainers.support;
+
+import java.util.List;
+
+import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface MiddleEarthCharactersRepository extends MongoRepository {
+ List findAllByRace(String race);
+}
diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/DynamicPropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/DynamicPropertiesIntegrationTest.java
new file mode 100644
index 0000000000..8689b10110
--- /dev/null
+++ b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/DynamicPropertiesIntegrationTest.java
@@ -0,0 +1,59 @@
+package com.baeldung.testcontainers;
+
+import static io.restassured.RestAssured.when;
+import static org.hamcrest.Matchers.hasItems;
+import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT;
+import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_CLASS;
+
+import java.util.List;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.DynamicPropertyRegistry;
+import org.springframework.test.context.DynamicPropertySource;
+import org.testcontainers.containers.MongoDBContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+import org.testcontainers.utility.DockerImageName;
+
+import com.baeldung.testcontainers.support.MiddleEarthCharacter;
+import com.baeldung.testcontainers.support.MiddleEarthCharactersRepository;
+
+@Testcontainers
+@SpringBootTest(webEnvironment = DEFINED_PORT)
+@DirtiesContext(classMode = AFTER_CLASS)
+class DynamicPropertiesIntegrationTest {
+ @Container
+ static MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("mongo:4.0.10"));
+
+ @DynamicPropertySource
+ static void setProperties(DynamicPropertyRegistry registry) {
+ registry.add("spring.data.mongodb.uri", mongoDBContainer::getReplicaSetUrl);
+ }
+
+ @Autowired
+ private MiddleEarthCharactersRepository repository;
+
+ @BeforeEach
+ void beforeEach() {
+ repository.deleteAll();
+ }
+
+ @Test
+ void whenRequestingHobbits_thenReturnFrodoAndSam() {
+ repository.saveAll(List.of(
+ new MiddleEarthCharacter("Frodo", "hobbit"),
+ new MiddleEarthCharacter("Samwise", "hobbit"),
+ new MiddleEarthCharacter("Aragon", "human"),
+ new MiddleEarthCharacter("Gandalf", "wizzard")
+ ));
+
+ when().get("/characters?race=hobbit")
+ .then().statusCode(200)
+ .and().body("name", hasItems("Frodo", "Samwise"));
+ }
+
+}
diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/LocalDevApplication.java b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/LocalDevApplication.java
new file mode 100644
index 0000000000..a94c0f772a
--- /dev/null
+++ b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/LocalDevApplication.java
@@ -0,0 +1,29 @@
+package com.baeldung.testcontainers;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.devtools.restart.RestartScope;
+import org.springframework.boot.test.context.TestConfiguration;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.springframework.context.annotation.Bean;
+import org.testcontainers.containers.MongoDBContainer;
+import org.testcontainers.utility.DockerImageName;
+
+class LocalDevApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.from(Application::main)
+ .with(LocalDevTestcontainersConfig.class)
+ .run(args);
+ }
+
+ @TestConfiguration(proxyBeanMethods = false)
+ static class LocalDevTestcontainersConfig {
+ @Bean
+ @RestartScope
+ @ServiceConnection
+ public MongoDBContainer mongoDBContainer() {
+ return new MongoDBContainer(DockerImageName.parse("mongo:4.0.10"));
+ }
+ }
+
+}
diff --git a/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/ServiceConnectionIntegrationTest.java b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/ServiceConnectionIntegrationTest.java
new file mode 100644
index 0000000000..500d6d2e61
--- /dev/null
+++ b/spring-boot-modules/spring-boot-3-testcontainers/src/test/java/com/baeldung/testcontainers/ServiceConnectionIntegrationTest.java
@@ -0,0 +1,55 @@
+package com.baeldung.testcontainers;
+
+import static io.restassured.RestAssured.when;
+import static org.hamcrest.Matchers.hasItems;
+import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT;
+import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_CLASS;
+
+import java.util.List;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.springframework.test.annotation.DirtiesContext;
+import org.testcontainers.containers.MongoDBContainer;
+import org.testcontainers.junit.jupiter.Container;
+import org.testcontainers.junit.jupiter.Testcontainers;
+import org.testcontainers.utility.DockerImageName;
+
+import com.baeldung.testcontainers.support.MiddleEarthCharacter;
+import com.baeldung.testcontainers.support.MiddleEarthCharactersRepository;
+
+@Testcontainers
+@SpringBootTest(webEnvironment = DEFINED_PORT)
+@DirtiesContext(classMode = AFTER_CLASS)
+class ServiceConnectionIntegrationTest {
+
+ @Container
+ @ServiceConnection
+ static MongoDBContainer mongoDBContainer = new MongoDBContainer(DockerImageName.parse("mongo:4.0.10"));
+
+ @Autowired
+ private MiddleEarthCharactersRepository repository;
+
+ @BeforeEach
+ void beforeEach() {
+ repository.deleteAll();
+ }
+
+ @Test
+ void whenRequestingHobbits_thenReturnFrodoAndSam() {
+ repository.saveAll(List.of(
+ new MiddleEarthCharacter("Frodo", "hobbit"),
+ new MiddleEarthCharacter("Samwise", "hobbit"),
+ new MiddleEarthCharacter("Aragon", "human"),
+ new MiddleEarthCharacter("Gandalf", "wizzard")
+ ));
+
+ when().get("/characters?race=hobbit")
+ .then().statusCode(200)
+ .and().body("name", hasItems("Frodo", "Samwise"));
+ }
+
+}
diff --git a/spring-boot-modules/spring-boot-3/pom.xml b/spring-boot-modules/spring-boot-3/pom.xml
index 32c69801ca..3b3f9dbdb0 100644
--- a/spring-boot-modules/spring-boot-3/pom.xml
+++ b/spring-boot-modules/spring-boot-3/pom.xml
@@ -1,7 +1,7 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
spring-boot-3
0.0.1-SNAPSHOT
diff --git a/spring-boot-modules/spring-boot-artifacts/pom.xml b/spring-boot-modules/spring-boot-artifacts/pom.xml
index dedeb0ab2a..e39ddb5af1 100644
--- a/spring-boot-modules/spring-boot-artifacts/pom.xml
+++ b/spring-boot-modules/spring-boot-artifacts/pom.xml
@@ -193,7 +193,6 @@
2.2.4
3.1.7
4.5.8
- 2.18
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-basic-customization/pom.xml b/spring-boot-modules/spring-boot-basic-customization/pom.xml
index 4b1009d38a..581a7fec06 100644
--- a/spring-boot-modules/spring-boot-basic-customization/pom.xml
+++ b/spring-boot-modules/spring-boot-basic-customization/pom.xml
@@ -86,5 +86,4 @@
com.baeldung.changeport.CustomApplication
-
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-documentation/pom.xml b/spring-boot-modules/spring-boot-documentation/pom.xml
index 587ad8473b..513c5678d5 100644
--- a/spring-boot-modules/spring-boot-documentation/pom.xml
+++ b/spring-boot-modules/spring-boot-documentation/pom.xml
@@ -92,7 +92,6 @@
- 3.3.2
2.2.11
0.12.1
0.8.0
diff --git a/spring-boot-modules/spring-boot-jasypt/pom.xml b/spring-boot-modules/spring-boot-jasypt/pom.xml
index 8595b9c639..b83162fb04 100644
--- a/spring-boot-modules/spring-boot-jasypt/pom.xml
+++ b/spring-boot-modules/spring-boot-jasypt/pom.xml
@@ -50,4 +50,11 @@
2.0.0
+
+
+ spring-milestone
+ Spring Milestone
+ https://repo.spring.io/milestone
+
+
\ No newline at end of file
diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/ImmutableCredentials.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/ImmutableCredentials.java
index 72c45afbb2..d7e948ca9a 100644
--- a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/ImmutableCredentials.java
+++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/ImmutableCredentials.java
@@ -1,6 +1,7 @@
package com.baeldung.configurationproperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.context.properties.bind.ConstructorBinding;
@ConfigurationProperties(prefix = "mail.credentials")
public class ImmutableCredentials {
@@ -9,12 +10,19 @@ public class ImmutableCredentials {
private final String username;
private final String password;
+ @ConstructorBinding
public ImmutableCredentials(String authMethod, String username, String password) {
this.authMethod = authMethod;
this.username = username;
this.password = password;
}
+ public ImmutableCredentials(String username, String password) {
+ this.username = username;
+ this.password = password;
+ this.authMethod = "Default";
+ }
+
public String getAuthMethod() {
return authMethod;
}
diff --git a/spring-boot-modules/spring-boot-resilience4j/src/test/java/com/baeldung/resilience4j/eventendpoints/ResilientAppControllerIntegrationTest.java b/spring-boot-modules/spring-boot-resilience4j/src/test/java/com/baeldung/resilience4j/eventendpoints/ResilientAppControllerIntegrationTest.java
index b4378a9248..a1173f40ae 100644
--- a/spring-boot-modules/spring-boot-resilience4j/src/test/java/com/baeldung/resilience4j/eventendpoints/ResilientAppControllerIntegrationTest.java
+++ b/spring-boot-modules/spring-boot-resilience4j/src/test/java/com/baeldung/resilience4j/eventendpoints/ResilientAppControllerIntegrationTest.java
@@ -31,9 +31,13 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;
+/**
+ * This was failing as a unit test in integrated environment
+ * probably due to parallel execution of tests.
+ */
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
-class ResilientAppControllerIntegrationTest {
+class ResilientAppControllerManualTest {
private final Logger LOGGER = LoggerFactory.getLogger(getClass());
diff --git a/spring-boot-modules/spring-boot-telegram/README.md b/spring-boot-modules/spring-boot-telegram/README.md
new file mode 100644
index 0000000000..4cd6560bc0
--- /dev/null
+++ b/spring-boot-modules/spring-boot-telegram/README.md
@@ -0,0 +1,2 @@
+## Relevant Articles
+- [Creating a Telegram Bot with Spring Boot](https://www.baeldung.com/spring-boot-telegram-bot)
diff --git a/spring-boot-modules/spring-boot-testing-spock/pom.xml b/spring-boot-modules/spring-boot-testing-spock/pom.xml
index c82d88ccfb..db78143cb8 100644
--- a/spring-boot-modules/spring-boot-testing-spock/pom.xml
+++ b/spring-boot-modules/spring-boot-testing-spock/pom.xml
@@ -96,7 +96,6 @@
com.baeldung.boot.Application
2.4-M1-groovy-4.0
3.0.0
- 3.10.1
2.17.1
diff --git a/spring-boot-modules/spring-boot-testing/pom.xml b/spring-boot-modules/spring-boot-testing/pom.xml
index 2098ac767d..41783ebd7d 100644
--- a/spring-boot-modules/spring-boot-testing/pom.xml
+++ b/spring-boot-modules/spring-boot-testing/pom.xml
@@ -121,7 +121,6 @@
2.2.4
2.4-M1-groovy-4.0
3.0.0
- 3.10.1
0.7.2
2.5.0
2.17.1
diff --git a/spring-boot-rest/pom.xml b/spring-boot-rest/pom.xml
index 74d46f0651..d4d7cd9c1a 100644
--- a/spring-boot-rest/pom.xml
+++ b/spring-boot-rest/pom.xml
@@ -163,7 +163,6 @@
com.baeldung.SpringBootRestApplication
1.4.11.1
3.1.0
- 3.3.2
2.3.7
diff --git a/spring-cloud-modules/spring-cloud-zuul-fallback/pom.xml b/spring-cloud-modules/spring-cloud-zuul-fallback/pom.xml
index ff62a99a00..fcf216cd6e 100644
--- a/spring-cloud-modules/spring-cloud-zuul-fallback/pom.xml
+++ b/spring-cloud-modules/spring-cloud-zuul-fallback/pom.xml
@@ -22,7 +22,6 @@
2020.0.3
2.2.7.RELEASE
- 3.1.1
\ No newline at end of file
diff --git a/spring-core-4/pom.xml b/spring-core-4/pom.xml
index 492a2ec5a2..2d11cc701b 100644
--- a/spring-core-4/pom.xml
+++ b/spring-core-4/pom.xml
@@ -84,7 +84,6 @@
4.0.2
4.0.0
1.3.2
- 3.3.2
1.10.0
diff --git a/spring-core/pom.xml b/spring-core/pom.xml
index d1c155b92a..e369bc24d0 100644
--- a/spring-core/pom.xml
+++ b/spring-core/pom.xml
@@ -88,7 +88,6 @@
1.5.2.RELEASE
1.10.19
1.3.2
- 3.3.2
\ No newline at end of file
diff --git a/spring-di/pom.xml b/spring-di/pom.xml
index cf3703096c..af0601deb6 100644
--- a/spring-di/pom.xml
+++ b/spring-di/pom.xml
@@ -149,7 +149,6 @@
1.5.2.RELEASE
1.10.19
1.9.5
- 3.3.2
\ No newline at end of file
diff --git a/spring-ejb-modules/wildfly/pom.xml b/spring-ejb-modules/wildfly/pom.xml
index f122e99001..412fa1b244 100644
--- a/spring-ejb-modules/wildfly/pom.xml
+++ b/spring-ejb-modules/wildfly/pom.xml
@@ -16,11 +16,6 @@
- widlfly-web
- wildfly-ear
- wildfly-jpa
- wildfly-ejb-interfaces
- wildfly-ejb
wildfly-mdb
diff --git a/spring-ejb-modules/wildfly/widlfly-web/pom.xml b/spring-ejb-modules/wildfly/widlfly-web/pom.xml
deleted file mode 100644
index 46c3f7d0bc..0000000000
--- a/spring-ejb-modules/wildfly/widlfly-web/pom.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
- 4.0.0
- widlfly-web
- widlfly-web
- war
-
-
- com.baeldung.wildfly
- wildfly
- 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}
-
-
-
-
- 3.3.2
-
-
\ No newline at end of file
diff --git a/spring-ejb-modules/wildfly/widlfly-web/src/main/java/TestEJBServlet.java b/spring-ejb-modules/wildfly/widlfly-web/src/main/java/TestEJBServlet.java
deleted file mode 100644
index 57376e9c4a..0000000000
--- a/spring-ejb-modules/wildfly/widlfly-web/src/main/java/TestEJBServlet.java
+++ /dev/null
@@ -1,41 +0,0 @@
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.List;
-
-import javax.ejb.EJB;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import model.User;
-import wildfly.beans.UserBeanLocal;
-
-/**
- * Servlet implementation class TestEJBServlet
- */
-public class TestEJBServlet extends HttpServlet {
-
- @EJB
- private UserBeanLocal userBean;
-
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- List users = userBean.getUsers();
-
- PrintWriter out = response.getWriter();
-
- out.println("");
- out.println("");
- for (User user : users) {
- out.print(user.getUsername());
- out.print(" " + user.getEmail() + "
");
- }
- out.println("");
- out.println("");
- }
-
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- doGet(request, response);
- }
-}
diff --git a/spring-ejb-modules/wildfly/widlfly-web/src/main/java/TestJPAServlet.java b/spring-ejb-modules/wildfly/widlfly-web/src/main/java/TestJPAServlet.java
deleted file mode 100644
index 609366c53a..0000000000
--- a/spring-ejb-modules/wildfly/widlfly-web/src/main/java/TestJPAServlet.java
+++ /dev/null
@@ -1,54 +0,0 @@
-
-import java.io.IOException;
-import java.util.List;
-
-import javax.annotation.Resource;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.Query;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.transaction.UserTransaction;
-
-import model.User;
-
-/**
- * Servlet implementation class TestJPAServlet
- */
-public class TestJPAServlet extends HttpServlet {
- private static final long serialVersionUID = 1L;
- @PersistenceContext(unitName = "wildfly-jpa")
- EntityManager em;
-
- @Resource
- UserTransaction tx;
-
- /**
- * @see HttpServlet#HttpServlet()
- */
- public TestJPAServlet() {
- super();
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
- */
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- Query q = em.createNamedQuery("User.findAll");
- List users = q.getResultList();
- response.getWriter()
- .append("JPA users returned: " + users.size());
- }
-
- /**
- * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
- */
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- // TODO Auto-generated method stub
- doGet(request, response);
- }
-
-}
diff --git a/spring-ejb-modules/wildfly/widlfly-web/src/main/resources/logback.xml b/spring-ejb-modules/wildfly/widlfly-web/src/main/resources/logback.xml
deleted file mode 100644
index 7d900d8ea8..0000000000
--- a/spring-ejb-modules/wildfly/widlfly-web/src/main/resources/logback.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/spring-ejb-modules/wildfly/widlfly-web/src/main/webapp/WEB-INF/web.xml b/spring-ejb-modules/wildfly/widlfly-web/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index 5b3f664443..0000000000
--- a/spring-ejb-modules/wildfly/widlfly-web/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
- widlfly-web
-
- index.html
- index.htm
- index.jsp
- default.html
- default.htm
- default.jsp
-
-
-
- TestJPAServlet
- TestJPAServlet
- TestJPAServlet
-
-
- TestJPAServlet
- /TestJPAServlet
-
-
-
- TestEJBServlet
- TestEJBServlet
- TestEJBServlet
-
-
- TestEJBServlet
- /TestEJBServlet
-
-
\ No newline at end of file
diff --git a/spring-ejb-modules/wildfly/wildfly-ear/pom.xml b/spring-ejb-modules/wildfly/wildfly-ear/pom.xml
deleted file mode 100644
index da321cb9eb..0000000000
--- a/spring-ejb-modules/wildfly/wildfly-ear/pom.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
- 4.0.0
- wildfly-ear
- wildfly-ear
- ear
-
-
- com.baeldung.wildfly
- wildfly
- 0.0.1-SNAPSHOT
-
-
-
-
-
- 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
- ${maven-ear-plugin.version}
-
- lib/
- ${defaultLibBundleDir.version}
-
-
- com.baeldung.wildfly
- widlfly-web
- /wildfly
-
-
-
-
-
- org.wildfly.plugins
- wildfly-maven-plugin
- ${wildfly-maven-plugin.version}
-
-
-
-
-
- 2.10.1
- 1.2.0.Final
- 7
-
-
-
\ No newline at end of file
diff --git a/spring-ejb-modules/wildfly/wildfly-ejb-interfaces/pom.xml b/spring-ejb-modules/wildfly/wildfly-ejb-interfaces/pom.xml
deleted file mode 100644
index bc9159b667..0000000000
--- a/spring-ejb-modules/wildfly/wildfly-ejb-interfaces/pom.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
- 4.0.0
- wildfly-ejb-interfaces
- wildfly-ejb-interfaces
-
-
- com.baeldung.wildfly
- wildfly
- 0.0.1-SNAPSHOT
-
-
-
-
-
- javax.ejb
- javax.ejb-api
- ${javax.ejb-api.version}
- provided
-
-
-
- com.baeldung.wildfly
- wildfly-jpa
- ${wildlfy.version}
-
-
-
-
- 3.2
-
-
-
\ No newline at end of file
diff --git a/spring-ejb-modules/wildfly/wildfly-ejb-interfaces/src/main/java/wildfly/beans/UserBeanLocal.java b/spring-ejb-modules/wildfly/wildfly-ejb-interfaces/src/main/java/wildfly/beans/UserBeanLocal.java
deleted file mode 100644
index 16930cb5b9..0000000000
--- a/spring-ejb-modules/wildfly/wildfly-ejb-interfaces/src/main/java/wildfly/beans/UserBeanLocal.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package wildfly.beans;
-
-import java.util.List;
-
-import javax.ejb.Local;
-
-import model.User;
-
-@Local
-public interface UserBeanLocal {
-
- List getUsers();
-}
diff --git a/spring-ejb-modules/wildfly/wildfly-ejb-interfaces/src/main/java/wildfly/beans/UserBeanRemote.java b/spring-ejb-modules/wildfly/wildfly-ejb-interfaces/src/main/java/wildfly/beans/UserBeanRemote.java
deleted file mode 100644
index 5b57d4283f..0000000000
--- a/spring-ejb-modules/wildfly/wildfly-ejb-interfaces/src/main/java/wildfly/beans/UserBeanRemote.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package wildfly.beans;
-
-import java.util.List;
-
-import javax.ejb.Remote;
-
-import model.User;
-
-@Remote
-public interface UserBeanRemote {
-
- List getUsers();
-}
diff --git a/spring-ejb-modules/wildfly/wildfly-ejb-interfaces/src/main/resources/logback.xml b/spring-ejb-modules/wildfly/wildfly-ejb-interfaces/src/main/resources/logback.xml
deleted file mode 100644
index 7d900d8ea8..0000000000
--- a/spring-ejb-modules/wildfly/wildfly-ejb-interfaces/src/main/resources/logback.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/spring-ejb-modules/wildfly/wildfly-ejb/pom.xml b/spring-ejb-modules/wildfly/wildfly-ejb/pom.xml
deleted file mode 100644
index 36574bf984..0000000000
--- a/spring-ejb-modules/wildfly/wildfly-ejb/pom.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
- 4.0.0
- wildfly-ejb
- wildfly-ejb
- ejb
-
-
- com.baeldung.wildfly
- wildfly
- 0.0.1-SNAPSHOT
-
-
-
-
-
- javax.ejb
- javax.ejb-api
- ${ejb.version}
- provided
-
-
-
- javax
- javaee-api
- provided
-
-
-
- org.hibernate
- hibernate-core
-
-
-
- com.baeldung.wildfly
- wildfly-ejb-interfaces
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-ejb-plugin
-
- ${ejb.version}
-
-
-
-
-
-
- 3.2
-
-
-
\ No newline at end of file
diff --git a/spring-ejb-modules/wildfly/wildfly-ejb/src/main/java/wildfly/beans/UserBean.java b/spring-ejb-modules/wildfly/wildfly-ejb/src/main/java/wildfly/beans/UserBean.java
deleted file mode 100644
index 07e3cbcb32..0000000000
--- a/spring-ejb-modules/wildfly/wildfly-ejb/src/main/java/wildfly/beans/UserBean.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package wildfly.beans;
-
-import java.util.List;
-
-import javax.ejb.Stateless;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-
-import model.User;
-
-/**
- * Session Bean implementation class UserBean
- */
-@Stateless
-public class UserBean implements UserBeanRemote, UserBeanLocal {
- @PersistenceContext(unitName = "wildfly-jpa")
- private EntityManager em;
-
- @Override
- public List getUsers() {
- return em.createNamedQuery("User.findAll")
- .getResultList();
- }
-}
diff --git a/spring-ejb-modules/wildfly/wildfly-ejb/src/main/resources/logback.xml b/spring-ejb-modules/wildfly/wildfly-ejb/src/main/resources/logback.xml
deleted file mode 100644
index 7d900d8ea8..0000000000
--- a/spring-ejb-modules/wildfly/wildfly-ejb/src/main/resources/logback.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/spring-ejb-modules/wildfly/wildfly-jpa/pom.xml b/spring-ejb-modules/wildfly/wildfly-jpa/pom.xml
deleted file mode 100644
index 603e337510..0000000000
--- a/spring-ejb-modules/wildfly/wildfly-jpa/pom.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
- 4.0.0
- wildfly-jpa
- wildfly-jpa
-
-
- com.baeldung.wildfly
- wildfly
- 0.0.1-SNAPSHOT
-
-
-
-
-
-
- org.hibernate
- hibernate-core
- provided
-
-
-
-
\ No newline at end of file
diff --git a/spring-ejb-modules/wildfly/wildfly-jpa/src/main/java/model/User.java b/spring-ejb-modules/wildfly/wildfly-jpa/src/main/java/model/User.java
deleted file mode 100644
index 3a3f95bf8c..0000000000
--- a/spring-ejb-modules/wildfly/wildfly-jpa/src/main/java/model/User.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package model;
-
-import java.io.Serializable;
-import javax.persistence.*;
-
-/**
- * The persistent class for the users database table.
- *
- */
-@Entity
-@Table(name = "users")
-@NamedQuery(name = "User.findAll", query = "SELECT u FROM User u")
-public class User implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Id
- private String username;
-
- private String email;
-
- @Column(name = "postal_number")
- private Integer postalNumber;
-
- public User() {
- }
-
- public String getUsername() {
- return this.username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getEmail() {
- return this.email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public Integer getPostalNumber() {
- return this.postalNumber;
- }
-
- public void setPostalNumber(Integer postalNumber) {
- this.postalNumber = postalNumber;
- }
-
-}
\ No newline at end of file
diff --git a/spring-ejb-modules/wildfly/wildfly-jpa/src/main/resources/META-INF/persistence.xml b/spring-ejb-modules/wildfly/wildfly-jpa/src/main/resources/META-INF/persistence.xml
deleted file mode 100644
index 2aa6bc2cd7..0000000000
--- a/spring-ejb-modules/wildfly/wildfly-jpa/src/main/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
- java:/H2DS
- model.User
-
-
-
-
-
-
-
-
diff --git a/spring-ejb-modules/wildfly/wildfly-jpa/src/main/resources/data.sql b/spring-ejb-modules/wildfly/wildfly-jpa/src/main/resources/data.sql
deleted file mode 100644
index 03eafa534e..0000000000
--- a/spring-ejb-modules/wildfly/wildfly-jpa/src/main/resources/data.sql
+++ /dev/null
@@ -1 +0,0 @@
-INSERT INTO users (username, email, postal_number) VALUES ('user1', 'user1@baeldung.com', 1000), ('user2', 'user2@baeldung.com', 2);
\ No newline at end of file
diff --git a/spring-ejb-modules/wildfly/wildfly-jpa/src/main/resources/logback.xml b/spring-ejb-modules/wildfly/wildfly-jpa/src/main/resources/logback.xml
deleted file mode 100644
index 7d900d8ea8..0000000000
--- a/spring-ejb-modules/wildfly/wildfly-jpa/src/main/resources/logback.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml
index 8912cad674..49c44f88f2 100644
--- a/spring-exceptions/pom.xml
+++ b/spring-exceptions/pom.xml
@@ -181,7 +181,6 @@
2.7
1.6.1
- 3.3.2
\ No newline at end of file
diff --git a/spring-jersey/pom.xml b/spring-jersey/pom.xml
index 17d527ca6a..32f75aa676 100644
--- a/spring-jersey/pom.xml
+++ b/spring-jersey/pom.xml
@@ -221,7 +221,6 @@
4.5.5
2.27.2
1.5.10.RELEASE
- 3.3.2
\ No newline at end of file
diff --git a/spring-katharsis/pom.xml b/spring-katharsis/pom.xml
index 82be0555c3..b836a42bca 100644
--- a/spring-katharsis/pom.xml
+++ b/spring-katharsis/pom.xml
@@ -135,7 +135,6 @@
3.0.2
0.9.10
1.6.1
- 3.3.2
\ No newline at end of file
diff --git a/spring-mobile/pom.xml b/spring-mobile/pom.xml
index 0c279c0d62..a7effc31be 100644
--- a/spring-mobile/pom.xml
+++ b/spring-mobile/pom.xml
@@ -58,7 +58,6 @@
1.1.5.RELEASE
11
11
- 3.3.2
\ No newline at end of file
diff --git a/spring-pulsar/pom.xml b/spring-pulsar/pom.xml
index 4c2fc0d9b4..df1959c84e 100644
--- a/spring-pulsar/pom.xml
+++ b/spring-pulsar/pom.xml
@@ -1,6 +1,7 @@
-
+
4.0.0
spring-pulsar
0.0.1-SNAPSHOT
diff --git a/spring-reactive-modules/spring-5-data-reactive-2/pom.xml b/spring-reactive-modules/spring-5-data-reactive-2/pom.xml
index e5447ac038..3d88e672eb 100644
--- a/spring-reactive-modules/spring-5-data-reactive-2/pom.xml
+++ b/spring-reactive-modules/spring-5-data-reactive-2/pom.xml
@@ -1,7 +1,7 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
spring-5-data-reactive-2
spring-5-data-reactive-2
@@ -13,7 +13,6 @@
1.0.0-SNAPSHOT
-
8
8
diff --git a/spring-security-modules/spring-security-web-mvc-custom/pom.xml b/spring-security-modules/spring-security-web-mvc-custom/pom.xml
index f21c6dbe40..41f24050b2 100644
--- a/spring-security-modules/spring-security-web-mvc-custom/pom.xml
+++ b/spring-security-modules/spring-security-web-mvc-custom/pom.xml
@@ -172,7 +172,6 @@
- 3.2.2
1.6.1
1.3.2
diff --git a/spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/SecurityController3.java b/spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/GetUserWithAuthenticationController.java
similarity index 89%
rename from spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/SecurityController3.java
rename to spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/GetUserWithAuthenticationController.java
index 2dcb98286b..4f9b24cf36 100644
--- a/spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/SecurityController3.java
+++ b/spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/GetUserWithAuthenticationController.java
@@ -8,9 +8,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
-public class SecurityController3 {
+public class GetUserWithAuthenticationController {
- public SecurityController3() {
+ public GetUserWithAuthenticationController() {
super();
}
diff --git a/spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/SecurityController4.java b/spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/GetUserWithAuthenticationPrincipalAnnotationController.java
similarity index 87%
rename from spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/SecurityController4.java
rename to spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/GetUserWithAuthenticationPrincipalAnnotationController.java
index 93a2bfcacd..912b4c178c 100644
--- a/spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/SecurityController4.java
+++ b/spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/GetUserWithAuthenticationPrincipalAnnotationController.java
@@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
-public class SecurityController4 {
+public class GetUserWithAuthenticationPrincipalAnnotationController {
@GetMapping("/user")
public String getUser(@AuthenticationPrincipal UserDetails userDetails) {
diff --git a/spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/SecurityController.java b/spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/GetUserWithPrincipalController.java
similarity index 85%
rename from spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/SecurityController.java
rename to spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/GetUserWithPrincipalController.java
index ece442430f..ed3ea5b25d 100644
--- a/spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/SecurityController.java
+++ b/spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/GetUserWithPrincipalController.java
@@ -8,9 +8,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
-public class SecurityController {
+public class GetUserWithPrincipalController {
- public SecurityController() {
+ public GetUserWithPrincipalController() {
super();
}
diff --git a/spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/SecurityController1.java b/spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/GetUserWithSecurityContextHolderController.java
similarity index 92%
rename from spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/SecurityController1.java
rename to spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/GetUserWithSecurityContextHolderController.java
index 1951e04dcb..c63271ef77 100644
--- a/spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/SecurityController1.java
+++ b/spring-security-modules/spring-security-web-rest-custom/src/main/java/com/baeldung/web/controller/GetUserWithSecurityContextHolderController.java
@@ -11,12 +11,12 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
-public class SecurityController1 {
+public class GetUserWithSecurityContextHolderController {
@Autowired
private ApplicationEventPublisher eventPublisher;
- public SecurityController1() {
+ public GetUserWithSecurityContextHolderController() {
super();
}
diff --git a/spring-shell/pom.xml b/spring-shell/pom.xml
index 506884b413..952920fd1e 100644
--- a/spring-shell/pom.xml
+++ b/spring-shell/pom.xml
@@ -39,7 +39,6 @@
1.2.0.RELEASE
- 3.3.2
\ No newline at end of file
diff --git a/spring-web-modules/spring-thymeleaf-attributes/accessing-session-attributes/pom.xml b/spring-web-modules/spring-thymeleaf-attributes/accessing-session-attributes/pom.xml
index 38d019c683..d4fff21605 100644
--- a/spring-web-modules/spring-thymeleaf-attributes/accessing-session-attributes/pom.xml
+++ b/spring-web-modules/spring-thymeleaf-attributes/accessing-session-attributes/pom.xml
@@ -1,84 +1,84 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
- 4.0.0
+ 4.0.0
- com.baeldung.spring-thymeleaf-attributes.module
- accessing-session-attributes
- 0.0.1-SNAPSHOT
- war
-
-
- com.baeldung.spring-thymeleaf-attributes
- spring-thymeleaf-attributes
+ com.baeldung.spring-thymeleaf-attributes.module
+ accessing-session-attributes
0.0.1-SNAPSHOT
- ../pom.xml
-
+ war
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-thymeleaf
- ${spring.boot.starter.thymeleaf}
-
-
-
- org.junit.jupiter
- junit-jupiter-engine
- ${junit.jupiter.engine.version}
- test
-
-
- org.mockito
- mockito-core
- ${mockito.version}
- test
-
-
- org.mockito
- mockito-junit-jupiter
- ${mockito.version}
- test
-
-
- org.junit.jupiter
- junit-jupiter-api
- ${junit.jupiter.engine.version}
- test
-
-
+
+ com.baeldung.spring-thymeleaf-attributes
+ spring-thymeleaf-attributes
+ 0.0.1-SNAPSHOT
+ ../pom.xml
+
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- -Dfile.encoding="UTF-8" -Xdebug
- -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
-
-
-
-
-
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+ ${spring.boot.starter.thymeleaf}
+
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit.jupiter.engine.version}
+ test
+
+
+ org.mockito
+ mockito-core
+ ${mockito.version}
+ test
+
+
+ org.mockito
+ mockito-junit-jupiter
+ ${mockito.version}
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit.jupiter.engine.version}
+ test
+
+
-
- com.baeldung.accesing_session_attributes.SpringWebApplicationInitializer
- UTF-8
- UTF-8
- UTF-8
- true
- true
- 5.9.3
- 5.3.1
- 3.1.1.RELEASE
- 3.1.1
-
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+ -Dfile.encoding="UTF-8" -Xdebug
+ -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
+
+
+
+
+
+
+
+ com.baeldung.accesing_session_attributes.SpringWebApplicationInitializer
+ UTF-8
+ UTF-8
+ UTF-8
+ true
+ true
+ 5.9.3
+ 5.3.1
+ 3.1.1.RELEASE
+ 3.1.1
+
\ No newline at end of file
diff --git a/spring-websockets/pom.xml b/spring-websockets/pom.xml
index c13d1cff33..a28ef8749a 100644
--- a/spring-websockets/pom.xml
+++ b/spring-websockets/pom.xml
@@ -44,8 +44,4 @@
-
- 3.3.2
-
-
\ No newline at end of file
diff --git a/testing-modules/cucumber/pom.xml b/testing-modules/cucumber/pom.xml
index ffa5c0d250..6d178b86a3 100644
--- a/testing-modules/cucumber/pom.xml
+++ b/testing-modules/cucumber/pom.xml
@@ -124,7 +124,6 @@
14
6.10.3
5.4.0
- 2.22.2
3.141.59
4.3.1
0.40
diff --git a/testing-modules/testing-libraries-2/pom.xml b/testing-modules/testing-libraries-2/pom.xml
index d74ede07db..4cc3ea8428 100644
--- a/testing-modules/testing-libraries-2/pom.xml
+++ b/testing-modules/testing-libraries-2/pom.xml
@@ -1,6 +1,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
testing-libraries-2
testing-libraries-2
diff --git a/testing-modules/zerocode/pom.xml b/testing-modules/zerocode/pom.xml
index 15ef45be63..c0aa370096 100644
--- a/testing-modules/zerocode/pom.xml
+++ b/testing-modules/zerocode/pom.xml
@@ -91,7 +91,6 @@
- 3.0.0-M5
3.0.0-M5
8
8
diff --git a/vaadin/pom.xml b/vaadin/pom.xml
index 777ab2551c..aa37a2392a 100644
--- a/vaadin/pom.xml
+++ b/vaadin/pom.xml
@@ -187,7 +187,6 @@
local
mytheme
3.0.0
- 3.3.2
\ No newline at end of file
diff --git a/web-modules/blade/pom.xml b/web-modules/blade/pom.xml
index 0733556c20..2748c05663 100644
--- a/web-modules/blade/pom.xml
+++ b/web-modules/blade/pom.xml
@@ -112,7 +112,6 @@
4.5.6
4.5.6
4.4.10
- 3.0.0-M3
0.7
3.1.0
diff --git a/web-modules/javax-servlets-2/pom.xml b/web-modules/javax-servlets-2/pom.xml
index 81616e0055..9ba12352fd 100644
--- a/web-modules/javax-servlets-2/pom.xml
+++ b/web-modules/javax-servlets-2/pom.xml
@@ -22,6 +22,11 @@
commons-fileupload
${commons-fileupload.version}
+
+ org.apache.commons
+ commons-text
+ ${commons-text.version}
+
javax.servlet
@@ -76,6 +81,16 @@
+
+ org.eclipse.jetty
+ jetty-maven-plugin
+ ${jetty-maven-plugin.version}
+
+
+ /
+
+
+
@@ -84,6 +99,8 @@
1.49
5.3.20
2.22.2
+ 10.0.4
+ 1.10.0
\ No newline at end of file
diff --git a/web-modules/javax-servlets-2/src/main/java/com/baeldung/setparam/LanguageServlet.java b/web-modules/javax-servlets-2/src/main/java/com/baeldung/setparam/LanguageServlet.java
new file mode 100644
index 0000000000..983066ec51
--- /dev/null
+++ b/web-modules/javax-servlets-2/src/main/java/com/baeldung/setparam/LanguageServlet.java
@@ -0,0 +1,21 @@
+package com.baeldung.setparam;
+
+import java.io.IOException;
+import java.util.Locale;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.*;
+
+@WebServlet(name = "LanguageServlet", urlPatterns = "/setparam/lang")
+public class LanguageServlet extends HttpServlet {
+
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+
+ SetParameterRequestWrapper requestWrapper = new SetParameterRequestWrapper(request);
+ requestWrapper.setParameter("locale", Locale.getDefault().getLanguage());
+ request.getRequestDispatcher("/setparam/3rd_party_module.jsp").forward(requestWrapper, response);
+ }
+
+}
\ No newline at end of file
diff --git a/web-modules/javax-servlets-2/src/main/java/com/baeldung/setparam/SanitizeParametersFilter.java b/web-modules/javax-servlets-2/src/main/java/com/baeldung/setparam/SanitizeParametersFilter.java
new file mode 100644
index 0000000000..3f93591bd9
--- /dev/null
+++ b/web-modules/javax-servlets-2/src/main/java/com/baeldung/setparam/SanitizeParametersFilter.java
@@ -0,0 +1,17 @@
+package com.baeldung.setparam;
+
+import java.io.IOException;
+import javax.servlet.*;
+import javax.servlet.annotation.WebFilter;
+import javax.servlet.http.HttpServletRequest;
+
+@WebFilter(urlPatterns = { "/setparam/with-sanitize.jsp" })
+public class SanitizeParametersFilter implements Filter {
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
+ HttpServletRequest httpReq = (HttpServletRequest) request;
+ chain.doFilter(new SanitizeParametersRequestWrapper(httpReq), response);
+ }
+
+}
\ No newline at end of file
diff --git a/web-modules/javax-servlets-2/src/main/java/com/baeldung/setparam/SanitizeParametersRequestWrapper.java b/web-modules/javax-servlets-2/src/main/java/com/baeldung/setparam/SanitizeParametersRequestWrapper.java
new file mode 100644
index 0000000000..e4c2870ca6
--- /dev/null
+++ b/web-modules/javax-servlets-2/src/main/java/com/baeldung/setparam/SanitizeParametersRequestWrapper.java
@@ -0,0 +1,46 @@
+package com.baeldung.setparam;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+import org.apache.commons.text.StringEscapeUtils;
+
+public class SanitizeParametersRequestWrapper extends HttpServletRequestWrapper {
+
+ private final Map sanitizedMap;
+
+ public SanitizeParametersRequestWrapper(HttpServletRequest request) {
+ super(request);
+ sanitizedMap = Collections.unmodifiableMap(
+ request.getParameterMap().entrySet().stream()
+ .collect(Collectors.toMap(
+ Map.Entry::getKey,
+ entry -> Arrays.stream(entry.getValue())
+ .map(StringEscapeUtils::escapeHtml4)
+ .toArray(String[]::new)
+ )));
+ }
+
+ @Override
+ public Map getParameterMap() {
+ return sanitizedMap;
+ }
+
+ @Override
+ public String[] getParameterValues(String name) {
+ return Optional.ofNullable(getParameterMap().get(name))
+ .map(values -> Arrays.copyOf(values, values.length))
+ .orElse(null);
+ }
+
+ @Override
+ public String getParameter(String name) {
+ return Optional.ofNullable(getParameterValues(name))
+ .map(values -> values[0])
+ .orElse(null);
+ }
+
+}
\ No newline at end of file
diff --git a/web-modules/javax-servlets-2/src/main/java/com/baeldung/setparam/SetParameterRequestWrapper.java b/web-modules/javax-servlets-2/src/main/java/com/baeldung/setparam/SetParameterRequestWrapper.java
new file mode 100644
index 0000000000..7b2ab4597c
--- /dev/null
+++ b/web-modules/javax-servlets-2/src/main/java/com/baeldung/setparam/SetParameterRequestWrapper.java
@@ -0,0 +1,40 @@
+package com.baeldung.setparam;
+
+import java.util.*;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+public class SetParameterRequestWrapper extends HttpServletRequestWrapper {
+
+ private final Map paramMap;
+
+ public SetParameterRequestWrapper(HttpServletRequest request) {
+ super(request);
+ paramMap = new HashMap<>(request.getParameterMap());
+ }
+
+ @Override
+ public Map getParameterMap() {
+ return Collections.unmodifiableMap(paramMap);
+ }
+
+ @Override
+ public String[] getParameterValues(String name) {
+ return Optional.ofNullable(getParameterMap().get(name))
+ .map(values -> Arrays.copyOf(values, values.length))
+ .orElse(null);
+ }
+
+ @Override
+ public String getParameter(String name) {
+ return Optional.ofNullable(getParameterValues(name))
+ .map(values -> values[0])
+ .orElse(null);
+ }
+
+ public void setParameter(String name, String value) {
+ paramMap.put(name, new String[] {value});
+ }
+
+}
\ No newline at end of file
diff --git a/web-modules/javax-servlets-2/src/main/webapp/setparam/3rd_party_module.jsp b/web-modules/javax-servlets-2/src/main/webapp/setparam/3rd_party_module.jsp
new file mode 100644
index 0000000000..9ab4fd2c00
--- /dev/null
+++ b/web-modules/javax-servlets-2/src/main/webapp/setparam/3rd_party_module.jsp
@@ -0,0 +1,13 @@
+<%@ page import="java.util.*"%>
+
+
+ 3rd party Module
+
+
+ <%
+ String localeStr = request.getParameter("locale");
+ Locale currentLocale = (localeStr != null ? new Locale(localeStr) : null);
+ %>
+ The language you have selected: <%=currentLocale != null ? currentLocale.getDisplayLanguage(currentLocale) : " None"%>
+
+
\ No newline at end of file
diff --git a/web-modules/javax-servlets-2/src/main/webapp/setparam/with-sanitize.jsp b/web-modules/javax-servlets-2/src/main/webapp/setparam/with-sanitize.jsp
new file mode 100644
index 0000000000..68704d6133
--- /dev/null
+++ b/web-modules/javax-servlets-2/src/main/webapp/setparam/with-sanitize.jsp
@@ -0,0 +1,10 @@
+
+
+ Sanitized request parameter
+
+
+ The text below comes from request parameter "input":
+
+ <%=request.getParameter("input")%>
+
+
\ No newline at end of file
diff --git a/web-modules/javax-servlets-2/src/main/webapp/setparam/without-sanitize.jsp b/web-modules/javax-servlets-2/src/main/webapp/setparam/without-sanitize.jsp
new file mode 100644
index 0000000000..f5437164ef
--- /dev/null
+++ b/web-modules/javax-servlets-2/src/main/webapp/setparam/without-sanitize.jsp
@@ -0,0 +1,10 @@
+
+
+ Non sanitized request parameter
+
+
+ The text below comes from request parameter "input":
+
+ <%=request.getParameter("input")%>
+
+
\ No newline at end of file
diff --git a/web-modules/javax-servlets-2/src/test/java/com/baeldung/setparam/LanguageServletIntegrationTest.java b/web-modules/javax-servlets-2/src/test/java/com/baeldung/setparam/LanguageServletIntegrationTest.java
new file mode 100644
index 0000000000..893ba06ce4
--- /dev/null
+++ b/web-modules/javax-servlets-2/src/test/java/com/baeldung/setparam/LanguageServletIntegrationTest.java
@@ -0,0 +1,34 @@
+package com.baeldung.setparam;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Locale;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
+import org.junit.Test;
+
+public class LanguageServletIntegrationTest {
+
+ @Test
+ public void whenGetRequestUsingHttpClient_thenResponseBodyContainsDefaultLanguage() throws Exception {
+
+ // When
+ HttpClient client = HttpClientBuilder.create().build();
+ HttpGet method = new HttpGet("http://localhost:8080/setparam/lang");
+ HttpResponse httpResponse = client.execute(method);
+
+ // Then
+ Locale defaultLocale = Locale.getDefault();
+ String expectedLanguage = defaultLocale.getDisplayLanguage(defaultLocale);
+
+ HttpEntity entity = httpResponse.getEntity();
+ String responseBody = EntityUtils.toString(entity, "UTF-8");
+ assertTrue(responseBody.contains("The language you have selected: " + expectedLanguage));
+ }
+
+}
diff --git a/web-modules/javax-servlets-2/src/test/java/com/baeldung/setparam/SanitizeParametersRequestIntegrationTest.java b/web-modules/javax-servlets-2/src/test/java/com/baeldung/setparam/SanitizeParametersRequestIntegrationTest.java
new file mode 100644
index 0000000000..047d5431f6
--- /dev/null
+++ b/web-modules/javax-servlets-2/src/test/java/com/baeldung/setparam/SanitizeParametersRequestIntegrationTest.java
@@ -0,0 +1,40 @@
+package com.baeldung.setparam;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class SanitizeParametersRequestIntegrationTest {
+
+ private static String PARAM_INPUT;
+
+ @BeforeClass
+ public static void init() throws UnsupportedEncodingException {
+ PARAM_INPUT = URLEncoder.encode("", "UTF-8");
+ }
+
+ @Test
+ public void whenInputParameterContainsXss_thenResponseBodyContainsSanitizedValue() throws Exception {
+
+ // When
+ HttpClient client = HttpClientBuilder.create().build();
+ HttpGet method = new HttpGet(String.format("http://localhost:8080/setparam/with-sanitize.jsp?input=%s", PARAM_INPUT));
+ HttpResponse httpResponse = client.execute(method);
+
+ // Then
+ HttpEntity entity = httpResponse.getEntity();
+ String responseBody = EntityUtils.toString(entity, "UTF-8");
+ assertTrue(responseBody.contains("<script>alert('Hello');</script>"));
+ }
+
+}
\ No newline at end of file
diff --git a/web-modules/javax-servlets-2/src/test/java/com/baeldung/setparam/SanitizeParametersRequestWrapperUnitTest.java b/web-modules/javax-servlets-2/src/test/java/com/baeldung/setparam/SanitizeParametersRequestWrapperUnitTest.java
new file mode 100644
index 0000000000..4f246e0953
--- /dev/null
+++ b/web-modules/javax-servlets-2/src/test/java/com/baeldung/setparam/SanitizeParametersRequestWrapperUnitTest.java
@@ -0,0 +1,60 @@
+package com.baeldung.setparam;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class SanitizeParametersRequestWrapperUnitTest {
+
+ private String NEW_VALUE = "NEW VALUE";
+
+ private Map parameterMap;
+
+ @Mock
+ private HttpServletRequest request;
+
+ @Before
+ public void initBeforeEachTest() {
+ parameterMap = new HashMap<>();
+ parameterMap.put("input", new String[] {""});
+ when(request.getParameterMap()).thenReturn(parameterMap);
+ }
+
+ @Test
+ public void whenGetParameterViaWrapper_thenParameterReturnedIsSanitized() {
+ SanitizeParametersRequestWrapper wrapper = new SanitizeParametersRequestWrapper(request);
+ String actualValue = wrapper.getParameter("input");
+
+ assertEquals(actualValue, "<script>alert('Hello');</script>");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void whenPutValueToWrapperParameterMap_thenThrowsUnsupportedOperationException() {
+ SanitizeParametersRequestWrapper wrapper = new SanitizeParametersRequestWrapper(request);
+ Map wrapperParamMap = wrapper.getParameterMap();
+ wrapperParamMap.put("input", new String[] {NEW_VALUE});
+ }
+
+ @Test
+ public void whenSetValueToWrapperParametersStringArray_thenThe2ndCallShouldNotEqualToNewValue() {
+ SanitizeParametersRequestWrapper wrapper = new SanitizeParametersRequestWrapper(request);
+ String[] firstCallValues = wrapper.getParameterValues("input");
+
+ firstCallValues[0] = NEW_VALUE;
+ String[] secondCallValues = wrapper.getParameterValues("input");
+ assertNotEquals(firstCallValues, secondCallValues);
+ }
+
+}
\ No newline at end of file
diff --git a/web-modules/javax-servlets-2/src/test/java/com/baeldung/setparam/SetParameterRequestWrapperUnitTest.java b/web-modules/javax-servlets-2/src/test/java/com/baeldung/setparam/SetParameterRequestWrapperUnitTest.java
new file mode 100644
index 0000000000..32343abb93
--- /dev/null
+++ b/web-modules/javax-servlets-2/src/test/java/com/baeldung/setparam/SetParameterRequestWrapperUnitTest.java
@@ -0,0 +1,61 @@
+package com.baeldung.setparam;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class SetParameterRequestWrapperUnitTest {
+
+ private String NEW_VALUE = "NEW VALUE";
+
+ private Map parameterMap;
+
+ @Mock
+ private HttpServletRequest request;
+
+ @Before
+ public void initBeforeEachTest() {
+ parameterMap = new HashMap<>();
+ parameterMap.put("input", new String[] {"inputValue"});
+ when(request.getParameterMap()).thenReturn(parameterMap);
+ }
+
+ @Test
+ public void whenSetParameterViaWrapper_thenGetParameterShouldReturnTheSameValue() {
+ SetParameterRequestWrapper wrapper = new SetParameterRequestWrapper(request);
+ wrapper.setParameter("newInput", "newInputValue");
+ String actualValue = wrapper.getParameter("newInput");
+
+ assertEquals(actualValue, "newInputValue");
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void whenPutValueToWrapperParameterMap_thenThrowsUnsupportedOperationException() {
+ SetParameterRequestWrapper wrapper = new SetParameterRequestWrapper(request);
+ Map wrapperParamMap = wrapper.getParameterMap();
+ wrapperParamMap.put("input", new String[] {NEW_VALUE});
+ }
+
+ @Test
+ public void whenSetValueToWrapperParametersStringArray_thenThe2ndCallShouldNotEqualToNewValue() {
+ SetParameterRequestWrapper wrapper = new SetParameterRequestWrapper(request);
+ String[] firstCallValues = wrapper.getParameterValues("input");
+
+ firstCallValues[0] = NEW_VALUE;
+ String[] secondCallValues = wrapper.getParameterValues("input");
+ assertNotEquals(firstCallValues, secondCallValues);
+ }
+
+}
\ No newline at end of file
diff --git a/web-modules/javax-servlets-2/src/test/java/com/baeldung/setparam/UnsanitizedParametersRequestIntegrationTest.java b/web-modules/javax-servlets-2/src/test/java/com/baeldung/setparam/UnsanitizedParametersRequestIntegrationTest.java
new file mode 100644
index 0000000000..a00944b6a4
--- /dev/null
+++ b/web-modules/javax-servlets-2/src/test/java/com/baeldung/setparam/UnsanitizedParametersRequestIntegrationTest.java
@@ -0,0 +1,42 @@
+package com.baeldung.setparam;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class UnsanitizedParametersRequestIntegrationTest {
+
+ private static final String TAG_SCRIPT = "";
+
+ private static String PARAM_INPUT;
+
+ @BeforeClass
+ public static void init() throws UnsupportedEncodingException {
+ PARAM_INPUT = URLEncoder.encode(TAG_SCRIPT, "UTF-8");
+ }
+
+ @Test
+ public void whenInputParameterContainsXss_thenResponseBodyContainsUnsanitizedValue() throws Exception {
+
+ // When
+ HttpClient client = HttpClientBuilder.create().build();
+ HttpGet method = new HttpGet(String.format("http://localhost:8080/setparam/without-sanitize.jsp?input=%s", PARAM_INPUT));
+ HttpResponse httpResponse = client.execute(method);
+
+ // Then
+ HttpEntity entity = httpResponse.getEntity();
+ String responseBody = EntityUtils.toString(entity, "UTF-8");
+ assertTrue(responseBody.contains(TAG_SCRIPT));
+ }
+
+}
\ No newline at end of file
diff --git a/web-modules/pom.xml b/web-modules/pom.xml
index 8c3d3456b6..2dcec681ad 100644
--- a/web-modules/pom.xml
+++ b/web-modules/pom.xml
@@ -26,7 +26,7 @@
jee-7
jooby
linkrest
- ninja
+
ratpack
diff --git a/web-modules/wicket/pom.xml b/web-modules/wicket/pom.xml
index 9348e15cdb..244d176e25 100644
--- a/web-modules/wicket/pom.xml
+++ b/web-modules/wicket/pom.xml
@@ -84,7 +84,6 @@
7.5.0
9.2.13.v20150730
- 3.3.1
\ No newline at end of file