Merge branch 'eugenp:master' into PR-6865
This commit is contained in:
		
						commit
						e521083c14
					
				| @ -5,7 +5,7 @@ import org.slf4j.LoggerFactory; | |||||||
| 
 | 
 | ||||||
| public class KadaneAlgorithm { | public class KadaneAlgorithm { | ||||||
| 
 | 
 | ||||||
|     private Logger logger = LoggerFactory.getLogger(BruteForceAlgorithm.class.getName()); |     private Logger logger = LoggerFactory.getLogger(KadaneAlgorithm.class.getName()); | ||||||
| 
 | 
 | ||||||
|     public int maxSubArraySum(int[] arr) { |     public int maxSubArraySum(int[] arr) { | ||||||
| 
 | 
 | ||||||
| @ -14,15 +14,15 @@ public class KadaneAlgorithm { | |||||||
|         int end = 0; |         int end = 0; | ||||||
| 
 | 
 | ||||||
|         int maxSoFar = arr[0], maxEndingHere = arr[0]; |         int maxSoFar = arr[0], maxEndingHere = arr[0]; | ||||||
|  | 
 | ||||||
|         for (int i = 1; i < size; i++) { |         for (int i = 1; i < size; i++) { | ||||||
| 
 |  | ||||||
|             if (arr[i] > maxEndingHere + arr[i]) { |  | ||||||
|                 start = i; |  | ||||||
|                 maxEndingHere = arr[i]; |  | ||||||
|             } else { |  | ||||||
|             maxEndingHere = maxEndingHere + arr[i]; |             maxEndingHere = maxEndingHere + arr[i]; | ||||||
|  |             if (arr[i] > maxEndingHere) { | ||||||
|  |                 maxEndingHere = arr[i]; | ||||||
|  |                 if (maxSoFar < maxEndingHere) { | ||||||
|  |                     start = i; | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
| 
 |  | ||||||
|             if (maxSoFar < maxEndingHere) { |             if (maxSoFar < maxEndingHere) { | ||||||
|                 maxSoFar = maxEndingHere; |                 maxSoFar = maxEndingHere; | ||||||
|                 end = i; |                 end = i; | ||||||
|  | |||||||
| @ -7,7 +7,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; | |||||||
| class KadaneAlgorithmUnitTest { | class KadaneAlgorithmUnitTest { | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     void givenArrayWithNegativeNumberWhenMaximumSubarrayThenReturns6() { |     void givenArrayWithNegativeNumberWhenMaximumSubarrayThenReturnsExpectedResult() { | ||||||
|         //given |         //given | ||||||
|         int[] arr = new int[] { -3, 1, -8, 4, -1, 2, 1, -5, 5 }; |         int[] arr = new int[] { -3, 1, -8, 4, -1, 2, 1, -5, 5 }; | ||||||
|         //when |         //when | ||||||
| @ -39,4 +39,15 @@ class KadaneAlgorithmUnitTest { | |||||||
|         assertEquals(10, maxSum); |         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); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
| } | } | ||||||
| @ -3,4 +3,5 @@ | |||||||
| - [Algorithm to Identify and Validate a Credit Card Number](https://www.baeldung.com/java-validate-cc-number) | - [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) | - [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) | - [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) | - More articles: [[<-- prev]](/algorithms-miscellaneous-6) | ||||||
|  | |||||||
| @ -43,19 +43,19 @@ | |||||||
|         <dependency> |         <dependency> | ||||||
|             <groupId>com.sun.xml.ws</groupId> |             <groupId>com.sun.xml.ws</groupId> | ||||||
|             <artifactId>jaxws-ri</artifactId> |             <artifactId>jaxws-ri</artifactId> | ||||||
|             <version>2.3.3</version> |             <version>${jaxws-ri.version}</version> | ||||||
|             <type>pom</type> |             <type>pom</type> | ||||||
|         </dependency> |         </dependency> | ||||||
|         <dependency> |         <dependency> | ||||||
|             <groupId>javax.servlet</groupId> |             <groupId>javax.servlet</groupId> | ||||||
|             <artifactId>javax.servlet-api</artifactId> |             <artifactId>javax.servlet-api</artifactId> | ||||||
|             <version>4.0.1</version> |             <version>${javax.servlet-api.version}</version> | ||||||
|             <scope>provided</scope> |             <scope>provided</scope> | ||||||
|         </dependency> |         </dependency> | ||||||
|         <dependency> |         <dependency> | ||||||
|             <groupId>javax.servlet</groupId> |             <groupId>javax.servlet</groupId> | ||||||
|             <artifactId>jstl</artifactId> |             <artifactId>jstl</artifactId> | ||||||
|             <version>1.2</version> |             <version>${jstl.version}</version> | ||||||
|         </dependency> |         </dependency> | ||||||
|     </dependencies> |     </dependencies> | ||||||
| 
 | 
 | ||||||
| @ -117,7 +117,9 @@ | |||||||
|     <properties> |     <properties> | ||||||
|         <spring.version>5.3.25</spring.version> |         <spring.version>5.3.25</spring.version> | ||||||
|         <cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version> |         <cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version> | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |         <jstl.version>1.2</jstl.version> | ||||||
|  |         <javax.servlet-api.version>4.0.1</javax.servlet-api.version> | ||||||
|  |         <jaxws-ri.version>2.3.3</jaxws-ri.version> | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -241,8 +241,6 @@ | |||||||
|         <httpcore.version>4.4.16</httpcore.version> |         <httpcore.version>4.4.16</httpcore.version> | ||||||
|         <httpclient.version>4.5.14</httpclient.version> |         <httpclient.version>4.5.14</httpclient.version> | ||||||
|         <mockserver.version>5.11.2</mockserver.version> |         <mockserver.version>5.11.2</mockserver.version> | ||||||
|         <!-- maven plugins --> |  | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |  | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -21,7 +21,6 @@ | |||||||
|         </dependency> |         </dependency> | ||||||
|     </dependencies> |     </dependencies> | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     <properties> |     <properties> | ||||||
|         <javax.validation.validation-api.version>2.0.1.Final</javax.validation.validation-api.version> |         <javax.validation.validation-api.version>2.0.1.Final</javax.validation.validation-api.version> | ||||||
|     </properties> |     </properties> | ||||||
|  | |||||||
| @ -63,7 +63,6 @@ | |||||||
|         <org.apache.httpcomponents.version>4.5.2</org.apache.httpcomponents.version> |         <org.apache.httpcomponents.version>4.5.2</org.apache.httpcomponents.version> | ||||||
|         <velocity-version>1.7</velocity-version> |         <velocity-version>1.7</velocity-version> | ||||||
|         <velocity-tools-version>2.0</velocity-tools-version> |         <velocity-tools-version>2.0</velocity-tools-version> | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |  | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -49,7 +49,6 @@ | |||||||
| 
 | 
 | ||||||
|     <properties> |     <properties> | ||||||
|         <asm.version>5.2</asm.version> |         <asm.version>5.2</asm.version> | ||||||
|         <maven-jar-plugin.version>2.4</maven-jar-plugin.version> |  | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -1,5 +1,6 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | <project xmlns="http://maven.apache.org/POM/4.0.0" | ||||||
|  |     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"> |     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||||||
|     <modelVersion>4.0.0</modelVersion> |     <modelVersion>4.0.0</modelVersion> | ||||||
|     <artifactId>aws-s3-update-object</artifactId> |     <artifactId>aws-s3-update-object</artifactId> | ||||||
|  | |||||||
| @ -9,3 +9,4 @@ This module contains articles about Simple Storage Service (S3) on AWS | |||||||
| - [Using the JetS3t Java Client With Amazon S3](https://www.baeldung.com/jets3t-amazon-s3) | - [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) | - [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) | - [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) | ||||||
|  | |||||||
| @ -122,7 +122,6 @@ | |||||||
|         <docker.image.prefix>${azure.containerRegistry}.azurecr.io</docker.image.prefix> |         <docker.image.prefix>${azure.containerRegistry}.azurecr.io</docker.image.prefix> | ||||||
|         <docker-maven-plugin.version>1.1.0</docker-maven-plugin.version> |         <docker-maven-plugin.version>1.1.0</docker-maven-plugin.version> | ||||||
|         <azure-webapp-maven-plugin.version>1.1.0</azure-webapp-maven-plugin.version> |         <azure-webapp-maven-plugin.version>1.1.0</azure-webapp-maven-plugin.version> | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |  | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -27,6 +27,7 @@ | |||||||
|         <hsqldb.version>2.7.1</hsqldb.version> |         <hsqldb.version>2.7.1</hsqldb.version> | ||||||
|         <spock-core.version>2.3-groovy-3.0</spock-core.version> |         <spock-core.version>2.3-groovy-3.0</spock-core.version> | ||||||
|         <gmavenplus-plugin.version>2.1.0</gmavenplus-plugin.version> |         <gmavenplus-plugin.version>2.1.0</gmavenplus-plugin.version> | ||||||
|  |         <maven-failsafe-plugin.version>2.21.0</maven-failsafe-plugin.version> | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
|  | |||||||
| @ -48,7 +48,6 @@ | |||||||
| 
 | 
 | ||||||
|     <properties> |     <properties> | ||||||
|         <maven.compiler.release>14</maven.compiler.release> |         <maven.compiler.release>14</maven.compiler.release> | ||||||
|         <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version> |  | ||||||
|         <surefire.plugin.version>3.0.0-M3</surefire.plugin.version> |         <surefire.plugin.version>3.0.0-M3</surefire.plugin.version> | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -53,7 +53,6 @@ | |||||||
| 
 | 
 | ||||||
|     <properties> |     <properties> | ||||||
|         <maven.compiler.release>15</maven.compiler.release> |         <maven.compiler.release>15</maven.compiler.release> | ||||||
|         <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version> |  | ||||||
|         <surefire.plugin.version>3.0.0-M3</surefire.plugin.version> |         <surefire.plugin.version>3.0.0-M3</surefire.plugin.version> | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -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<Month> 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<Month> list = List.of(monthIn(), monthIn(), monthNotIn()); | ||||||
|  | 
 | ||||||
|  |         list.stream() | ||||||
|  |           .filter(this::predicateWithIf) | ||||||
|  |           .forEach(m -> assertThat(m, is(in(months)))); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     Predicate<Month> orPredicate() { | ||||||
|  |         Predicate<Month> predicate = x -> x == OCTOBER; | ||||||
|  |         Predicate<Month> predicate1 = x -> x == NOVEMBER; | ||||||
|  |         Predicate<Month> 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<Month> collectionPredicate = this::contains; | ||||||
|  | 
 | ||||||
|  |         assertTrue(collectionPredicate.test(monthIn())); | ||||||
|  |         assertFalse(collectionPredicate.test(monthNotIn())); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Test | ||||||
|  |     public void givenInputList_whenFilterWithContains_thenAssert() { | ||||||
|  | 
 | ||||||
|  |         List<Month> 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)); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -152,7 +152,6 @@ | |||||||
|         <awaitility.version>4.0.2</awaitility.version> |         <awaitility.version>4.0.2</awaitility.version> | ||||||
|         <maven.compiler.source>1.9</maven.compiler.source> |         <maven.compiler.source>1.9</maven.compiler.source> | ||||||
|         <maven.compiler.target>1.9</maven.compiler.target> |         <maven.compiler.target>1.9</maven.compiler.target> | ||||||
|         <maven-jar-plugin.version>3.2.0</maven-jar-plugin.version> |  | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -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) | - [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) | - [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) | - [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) | ||||||
|  | |||||||
| @ -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) | - [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 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) | - [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) | - More articles: [[<-- prev]](../core-java-collections-conversions) | ||||||
|  | |||||||
| @ -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) | - [Collections.synchronizedMap vs. ConcurrentHashMap](https://www.baeldung.com/java-synchronizedmap-vs-concurrenthashmap) | ||||||
| - [Java HashMap Load Factor](https://www.baeldung.com/java-hashmap-load-factor) | - [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) | - [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) | - More articles: [[<-- prev]](/core-java-modules/core-java-collections-maps-2) | ||||||
|  | |||||||
| @ -58,4 +58,8 @@ public class DataQueue { | |||||||
|             return queue.poll(); |             return queue.poll(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     public Integer getSize() { | ||||||
|  |         return queue.size(); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,12 +1,13 @@ | |||||||
| package com.baeldung.producerconsumer; | package com.baeldung.producerconsumer; | ||||||
| 
 | 
 | ||||||
|  | import java.util.concurrent.locks.ReentrantLock; | ||||||
| import java.util.logging.Logger; | import java.util.logging.Logger; | ||||||
| 
 | 
 | ||||||
| public class Producer implements Runnable { | public class Producer implements Runnable { | ||||||
|     private static final Logger log = Logger.getLogger(Producer.class.getCanonicalName()); |     private static final Logger log = Logger.getLogger(Producer.class.getCanonicalName()); | ||||||
|     private final DataQueue dataQueue; |     private final DataQueue dataQueue; | ||||||
| 
 |  | ||||||
|     private static int idSequence = 0; |     private static int idSequence = 0; | ||||||
|  |     final ReentrantLock lock = new ReentrantLock(); | ||||||
| 
 | 
 | ||||||
|     public Producer(DataQueue dataQueue) { |     public Producer(DataQueue dataQueue) { | ||||||
|         this.dataQueue = dataQueue; |         this.dataQueue = dataQueue; | ||||||
| @ -19,6 +20,10 @@ public class Producer implements Runnable { | |||||||
| 
 | 
 | ||||||
|     public void produce() { |     public void produce() { | ||||||
|         while (dataQueue.runFlag) { |         while (dataQueue.runFlag) { | ||||||
|  | 
 | ||||||
|  |             try { | ||||||
|  |                 lock.lock(); | ||||||
|  | 
 | ||||||
|                 while (dataQueue.isFull() && dataQueue.runFlag) { |                 while (dataQueue.isFull() && dataQueue.runFlag) { | ||||||
|                     try { |                     try { | ||||||
|                         dataQueue.waitOnFull(); |                         dataQueue.waitOnFull(); | ||||||
| @ -27,14 +32,26 @@ public class Producer implements Runnable { | |||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  | 
 | ||||||
|                 if (!dataQueue.runFlag) { |                 if (!dataQueue.runFlag) { | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|  | 
 | ||||||
|                 Message message = generateMessage(); |                 Message message = generateMessage(); | ||||||
|                 dataQueue.add(message); |                 dataQueue.add(message); | ||||||
|                 dataQueue.notifyAllForEmpty(); |                 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"); |         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", |         log.info(String.format("[%s] Generated Message. Id: %d, Data: %f%n", | ||||||
|                 Thread.currentThread().getName(), message.getId(), message.getData())); |                 Thread.currentThread().getName(), message.getId(), message.getData())); | ||||||
| 
 | 
 | ||||||
|         //Sleeping on random time to make it realistic |  | ||||||
|         ThreadUtil.sleep((long) (message.getData() * 100)); |  | ||||||
| 
 |  | ||||||
|         return message; |         return message; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -36,8 +36,8 @@ public class ProducerConsumerDemonstrator { | |||||||
| 
 | 
 | ||||||
|     public static void demoMultipleProducersAndMultipleConsumers() { |     public static void demoMultipleProducersAndMultipleConsumers() { | ||||||
|         DataQueue dataQueue = new DataQueue(MAX_QUEUE_CAPACITY); |         DataQueue dataQueue = new DataQueue(MAX_QUEUE_CAPACITY); | ||||||
|         int producerCount = 3; |         int producerCount = 5; | ||||||
|         int consumerCount = 3; |         int consumerCount = 5; | ||||||
|         List<Thread> threads = new ArrayList<>(); |         List<Thread> threads = new ArrayList<>(); | ||||||
|         Producer producer = new Producer(dataQueue); |         Producer producer = new Producer(dataQueue); | ||||||
|         for(int i = 0; i < producerCount; i++) { |         for(int i = 0; i < producerCount; i++) { | ||||||
| @ -45,6 +45,7 @@ public class ProducerConsumerDemonstrator { | |||||||
|             producerThread.start(); |             producerThread.start(); | ||||||
|             threads.add(producerThread); |             threads.add(producerThread); | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|         Consumer consumer = new Consumer(dataQueue); |         Consumer consumer = new Consumer(dataQueue); | ||||||
|         for(int i = 0; i < consumerCount; i++) { |         for(int i = 0; i < consumerCount; i++) { | ||||||
|             Thread consumerThread = new Thread(consumer); |             Thread consumerThread = new Thread(consumer); | ||||||
| @ -52,8 +53,8 @@ public class ProducerConsumerDemonstrator { | |||||||
|             threads.add(consumerThread); |             threads.add(consumerThread); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // let threads run for two seconds |         // let threads run for ten seconds | ||||||
|         sleep(2000); |         sleep(10000); | ||||||
| 
 | 
 | ||||||
|         // Stop threads |         // Stop threads | ||||||
|         producer.stop(); |         producer.stop(); | ||||||
|  | |||||||
| @ -11,4 +11,5 @@ This module contains articles about basic Java concurrency | |||||||
| - [Runnable vs. Callable in Java](https://www.baeldung.com/java-runnable-callable) | - [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) | - [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) | - [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) | - [[Next -->]](/core-java-modules/core-java-concurrency-basic-2) | ||||||
|  | |||||||
| @ -50,7 +50,6 @@ | |||||||
| 
 | 
 | ||||||
|     <properties> |     <properties> | ||||||
|         <maven.compiler.source.version>14</maven.compiler.source.version> |         <maven.compiler.source.version>14</maven.compiler.source.version> | ||||||
|         <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version> |  | ||||||
|         <maven.compiler.target.version>14</maven.compiler.target.version> |         <maven.compiler.target.version>14</maven.compiler.target.version> | ||||||
|         <surefire.plugin.version>3.0.0-M3</surefire.plugin.version> |         <surefire.plugin.version>3.0.0-M3</surefire.plugin.version> | ||||||
|     </properties> |     </properties> | ||||||
|  | |||||||
| @ -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 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) | - [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) | - [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) | ||||||
|  | |||||||
| @ -132,7 +132,6 @@ | |||||||
|         <!-- Mime Type Libraries --> |         <!-- Mime Type Libraries --> | ||||||
|         <tika.version>2.8.0</tika.version> |         <tika.version>2.8.0</tika.version> | ||||||
|         <jmime-magic.version>0.1.5</jmime-magic.version> |         <jmime-magic.version>0.1.5</jmime-magic.version> | ||||||
|         <maven-jar-plugin.version>3.3.0</maven-jar-plugin.version> |  | ||||||
|         <fscontext.version>4.4.2</fscontext.version> |         <fscontext.version>4.4.2</fscontext.version> | ||||||
|         <jakarta-activation-api.version>2.1.2</jakarta-activation-api.version> |         <jakarta-activation-api.version>2.1.2</jakarta-activation-api.version> | ||||||
|         <angus-activation.version>2.0.1</angus-activation.version> |         <angus-activation.version>2.0.1</angus-activation.version> | ||||||
|  | |||||||
| @ -275,7 +275,6 @@ | |||||||
|         <!-- maven plugins --> |         <!-- maven plugins --> | ||||||
|         <javamoney.moneta.version>1.1</javamoney.moneta.version> |         <javamoney.moneta.version>1.1</javamoney.moneta.version> | ||||||
|         <maven-javadoc-plugin.version>3.0.0-M1</maven-javadoc-plugin.version> |         <maven-javadoc-plugin.version>3.0.0-M1</maven-javadoc-plugin.version> | ||||||
|         <maven-jar-plugin.version>3.0.2</maven-jar-plugin.version> |  | ||||||
|         <onejar-maven-plugin.version>1.4.4</onejar-maven-plugin.version> |         <onejar-maven-plugin.version>1.4.4</onejar-maven-plugin.version> | ||||||
|         <maven-shade-plugin.version>3.1.1</maven-shade-plugin.version> |         <maven-shade-plugin.version>3.1.1</maven-shade-plugin.version> | ||||||
|         <maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version> |         <maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version> | ||||||
|  | |||||||
| @ -12,3 +12,4 @@ This module contains articles about inheritance in Java | |||||||
| - [Guide to Inheritance in Java](https://www.baeldung.com/java-inheritance) | - [Guide to Inheritance in Java](https://www.baeldung.com/java-inheritance) | ||||||
| - [Object Type Casting in Java](https://www.baeldung.com/java-type-casting) | - [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) | - [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) | ||||||
|  | |||||||
| @ -1,48 +1,71 @@ | |||||||
| package com.baeldung.modulo; | package com.baeldung.modulo; | ||||||
| 
 | 
 | ||||||
|  | import static org.junit.Assert.assertEquals; | ||||||
|  | 
 | ||||||
| import org.junit.Test; | import org.junit.Test; | ||||||
| import static org.assertj.core.api.Java6Assertions.*; | import static org.assertj.core.api.Java6Assertions.*; | ||||||
| 
 | 
 | ||||||
| public class ModuloUnitTest { | public class ModuloUnitTest { | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|   public void whenIntegerDivision_thenLosesRemainder(){ |     public void whenIntegerDivision_thenLosesRemainder() { | ||||||
|         assertThat(11 / 4).isEqualTo(2); |         assertThat(11 / 4).isEqualTo(2); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|   public void whenDoubleDivision_thenKeepsRemainder(){ |     public void whenDoubleDivision_thenKeepsRemainder() { | ||||||
|         assertThat(11 / 4.0).isEqualTo(2.75); |         assertThat(11 / 4.0).isEqualTo(2.75); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|   public void whenModulo_thenReturnsRemainder(){ |     public void whenModulo_thenReturnsRemainder() { | ||||||
|         assertThat(11 % 4).isEqualTo(3); |         assertThat(11 % 4).isEqualTo(3); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test(expected = ArithmeticException.class) |     @Test(expected = ArithmeticException.class) | ||||||
|   public void whenDivisionByZero_thenArithmeticException(){ |     public void whenDivisionByZero_thenArithmeticException() { | ||||||
|         double result = 1 / 0; |         double result = 1 / 0; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test(expected = ArithmeticException.class) |     @Test(expected = ArithmeticException.class) | ||||||
|   public void whenModuloByZero_thenArithmeticException(){ |     public void whenModuloByZero_thenArithmeticException() { | ||||||
|         double result = 1 % 0; |         double result = 1 % 0; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|   public void whenDivisorIsOddAndModulusIs2_thenResultIs1(){ |     public void whenDivisorIsOddAndModulusIs2_thenResultIs1() { | ||||||
|         assertThat(3 % 2).isEqualTo(1); |         assertThat(3 % 2).isEqualTo(1); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|   public void whenDivisorIsEvenAndModulusIs2_thenResultIs0(){ |     public void whenDivisorIsEvenAndModulusIs2_thenResultIs0() { | ||||||
|         assertThat(4 % 2).isEqualTo(0); |         assertThat(4 % 2).isEqualTo(0); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|   public void whenItemsIsAddedToCircularQueue_thenNoArrayIndexOutOfBounds(){ |     public void whenDividendIsNegativeAndModulusIs2_thenResultIsNegative() { | ||||||
|     int QUEUE_CAPACITY= 10; |         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[] circularQueue = new int[QUEUE_CAPACITY]; | ||||||
|         int itemsInserted = 0; |         int itemsInserted = 0; | ||||||
|         for (int value = 0; value < 1000; value++) { |         for (int value = 0; value < 1000; value++) { | ||||||
|  | |||||||
| @ -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 <the first value>, <the second value>, and <the third value>."; | ||||||
|  | 
 | ||||||
|  |     @Test | ||||||
|  |     void whenUsingNorCharClass_thenGetExpectedTexts() { | ||||||
|  |         Pattern pattern = Pattern.compile("<[^>]*>"); | ||||||
|  |         Matcher matcher = pattern.matcher(INPUT); | ||||||
|  |         List<String> result = new ArrayList<>(); | ||||||
|  |         while (matcher.find()) { | ||||||
|  |             result.add(matcher.group()); | ||||||
|  |         } | ||||||
|  |         assertThat(result).containsExactly("<the first value>", "<the second value>", "<the third value>"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @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<String> result = new ArrayList<>(); | ||||||
|  |         Map<Integer, Integer> indexesOfMatches = new LinkedHashMap<>(); | ||||||
|  |         while (matcher.find()) { | ||||||
|  |             result.add(matcher.group()); | ||||||
|  |             indexesOfMatches.put(matcher.start(), matcher.end()); | ||||||
|  |         } | ||||||
|  |         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>"); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Test | ||||||
|  |     void whenUsingMatcherStartAndEndWithGroupIdx_thenGetIndexesOfMatches() { | ||||||
|  |         Pattern pattern = Pattern.compile("<([^>]*)>"); | ||||||
|  |         Matcher matcher = pattern.matcher(INPUT); | ||||||
|  |         List<String> result = new ArrayList<>(); | ||||||
|  |         Map<Integer, Integer> 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"); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -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<String> 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<String> 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<String> 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<String> 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); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -115,7 +115,6 @@ | |||||||
|     <properties> |     <properties> | ||||||
|         <!-- testing --> |         <!-- testing --> | ||||||
|         <assertj.version>3.23.1</assertj.version> |         <assertj.version>3.23.1</assertj.version> | ||||||
|         <maven-compiler-plugin.version>3.1</maven-compiler-plugin.version> |  | ||||||
|         <maven.compiler.source>12</maven.compiler.source> |         <maven.compiler.source>12</maven.compiler.source> | ||||||
|         <maven.compiler.target>12</maven.compiler.target> |         <maven.compiler.target>12</maven.compiler.target> | ||||||
|         <rx.java.version>1.2.5</rx.java.version> |         <rx.java.version>1.2.5</rx.java.version> | ||||||
|  | |||||||
| @ -69,7 +69,6 @@ | |||||||
| 
 | 
 | ||||||
|     <properties> |     <properties> | ||||||
|         <!-- testing --> |         <!-- testing --> | ||||||
|         <maven-compiler-plugin.version>3.1</maven-compiler-plugin.version> |  | ||||||
|         <maven.compiler.source>12</maven.compiler.source> |         <maven.compiler.source>12</maven.compiler.source> | ||||||
|         <maven.compiler.target>12</maven.compiler.target> |         <maven.compiler.target>12</maven.compiler.target> | ||||||
|         <vavr.version>0.10.2</vavr.version> |         <vavr.version>0.10.2</vavr.version> | ||||||
|  | |||||||
| @ -58,7 +58,6 @@ | |||||||
| 
 | 
 | ||||||
|     <properties> |     <properties> | ||||||
|         <!-- testing --> |         <!-- testing --> | ||||||
|         <maven-compiler-plugin.version>3.1</maven-compiler-plugin.version> |  | ||||||
|         <maven.compiler.source>1.8</maven.compiler.source> |         <maven.compiler.source>1.8</maven.compiler.source> | ||||||
|         <maven.compiler.target>1.8</maven.compiler.target> |         <maven.compiler.target>1.8</maven.compiler.target> | ||||||
|     </properties> |     </properties> | ||||||
|  | |||||||
| @ -15,30 +15,20 @@ | |||||||
| 
 | 
 | ||||||
|     <dependencies> |     <dependencies> | ||||||
|         <dependency> |         <dependency> | ||||||
|             <groupId>javax.xml.bind</groupId> |             <groupId>jakarta.xml.bind</groupId> | ||||||
|             <artifactId>jaxb-api</artifactId> |             <artifactId>jakarta.xml.bind-api</artifactId> | ||||||
|             <version>2.4.0-b180725.0427</version> |             <version>${jakarta.xml.bind-api.version}</version> | ||||||
|         </dependency> |         </dependency> | ||||||
|         <dependency> |         <dependency> | ||||||
|             <groupId>org.apache.commons</groupId> |             <groupId>org.apache.commons</groupId> | ||||||
|             <artifactId>commons-lang3</artifactId> |             <artifactId>commons-lang3</artifactId> | ||||||
|             <version>${commons-lang3.version}</version> |             <version>${commons-lang3.version}</version> | ||||||
|         </dependency> |         </dependency> | ||||||
|         <dependency> |  | ||||||
|             <groupId>org.openjdk.jmh</groupId> |  | ||||||
|             <artifactId>jmh-core</artifactId> |  | ||||||
|             <version>${jmh-core.version}</version> |  | ||||||
|         </dependency> |  | ||||||
|         <dependency> |         <dependency> | ||||||
|             <groupId>log4j</groupId> |             <groupId>log4j</groupId> | ||||||
|             <artifactId>log4j</artifactId> |             <artifactId>log4j</artifactId> | ||||||
|             <version>${log4j.version}</version> |             <version>${log4j.version}</version> | ||||||
|         </dependency> |         </dependency> | ||||||
|         <dependency> |  | ||||||
|             <groupId>org.openjdk.jmh</groupId> |  | ||||||
|             <artifactId>jmh-generator-annprocess</artifactId> |  | ||||||
|             <version>${jmh-generator.version}</version> |  | ||||||
|         </dependency> |  | ||||||
|         <dependency> |         <dependency> | ||||||
|             <groupId>commons-codec</groupId> |             <groupId>commons-codec</groupId> | ||||||
|             <artifactId>commons-codec</artifactId> |             <artifactId>commons-codec</artifactId> | ||||||
| @ -57,7 +47,8 @@ | |||||||
|     </build> |     </build> | ||||||
| 
 | 
 | ||||||
|     <properties> |     <properties> | ||||||
|         <commons-codec.version>1.15</commons-codec.version> |         <commons-codec.version>1.16.0</commons-codec.version> | ||||||
|  |         <jakarta.xml.bind-api.version>4.0.0</jakarta.xml.bind-api.version> | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -2,7 +2,7 @@ package com.baeldung.base64encodinganddecoding; | |||||||
| 
 | 
 | ||||||
| import org.junit.Test; | import org.junit.Test; | ||||||
| 
 | 
 | ||||||
| import javax.xml.bind.DatatypeConverter; | import jakarta.xml.bind.DatatypeConverter; | ||||||
| import java.io.UnsupportedEncodingException; | import java.io.UnsupportedEncodingException; | ||||||
| import java.nio.charset.StandardCharsets; | import java.nio.charset.StandardCharsets; | ||||||
| import java.util.Arrays; | import java.util.Arrays; | ||||||
|  | |||||||
| @ -119,7 +119,6 @@ | |||||||
|         <disruptor.version>3.3.6</disruptor.version> |         <disruptor.version>3.3.6</disruptor.version> | ||||||
|         <!-- testing --> |         <!-- testing --> | ||||||
|         <maven-shade-plugin.version>2.4.3</maven-shade-plugin.version> |         <maven-shade-plugin.version>2.4.3</maven-shade-plugin.version> | ||||||
|         <maven-jar-plugin.version>3.0.2</maven-jar-plugin.version> |  | ||||||
|         <onejar-maven-plugin.version>1.4.4</onejar-maven-plugin.version> |         <onejar-maven-plugin.version>1.4.4</onejar-maven-plugin.version> | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -20,6 +20,7 @@ import org.joda.time.DateTimeZone; | |||||||
| import org.junit.Test; | import org.junit.Test; | ||||||
| 
 | 
 | ||||||
| import com.fasterxml.jackson.core.JsonProcessingException; | import com.fasterxml.jackson.core.JsonProcessingException; | ||||||
|  | import com.fasterxml.jackson.databind.DeserializationFeature; | ||||||
| import com.fasterxml.jackson.databind.ObjectMapper; | import com.fasterxml.jackson.databind.ObjectMapper; | ||||||
| import com.fasterxml.jackson.databind.SerializationFeature; | import com.fasterxml.jackson.databind.SerializationFeature; | ||||||
| import com.fasterxml.jackson.databind.util.StdDateFormat; | import com.fasterxml.jackson.databind.util.StdDateFormat; | ||||||
| @ -67,6 +68,8 @@ public class JacksonDateUnitTest { | |||||||
|         ObjectMapper objectMapper = new ObjectMapper(); |         ObjectMapper objectMapper = new ObjectMapper(); | ||||||
|         objectMapper.findAndRegisterModules(); |         objectMapper.findAndRegisterModules(); | ||||||
|         objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); |         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")); |         ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC")); | ||||||
|         String converted = objectMapper.writeValueAsString(now); |         String converted = objectMapper.writeValueAsString(now); | ||||||
|       |       | ||||||
|  | |||||||
| @ -30,7 +30,6 @@ | |||||||
|     <properties> |     <properties> | ||||||
|         <javax.websocket-api.version>1.1</javax.websocket-api.version> |         <javax.websocket-api.version>1.1</javax.websocket-api.version> | ||||||
|         <gson.version>2.8.0</gson.version> |         <gson.version>2.8.0</gson.version> | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |  | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -3,7 +3,7 @@ | |||||||
| This module contains articles about Bean Validation. | This module contains articles about Bean Validation. | ||||||
| 
 | 
 | ||||||
| ### Relevant Articles:  | ### 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) | - [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) | - [Validations for Enum Types](https://www.baeldung.com/javax-validations-enums) | ||||||
| - [Javax BigDecimal Validation](https://www.baeldung.com/javax-bigdecimal-validation) | - [Javax BigDecimal Validation](https://www.baeldung.com/javax-bigdecimal-validation) | ||||||
|  | |||||||
| @ -100,7 +100,6 @@ | |||||||
| 
 | 
 | ||||||
|     <properties> |     <properties> | ||||||
|         <jersey.version>3.1.1</jersey.version> |         <jersey.version>3.1.1</jersey.version> | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |  | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -1,5 +1,7 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | <project xmlns="http://maven.apache.org/POM/4.0.0" | ||||||
|  |     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||||
|  |     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||||||
|     <modelVersion>4.0.0</modelVersion> |     <modelVersion>4.0.0</modelVersion> | ||||||
| 
 | 
 | ||||||
|     <parent> |     <parent> | ||||||
| @ -45,8 +47,8 @@ | |||||||
|         <metrics-spring.version>3.1.3</metrics-spring.version> |         <metrics-spring.version>3.1.3</metrics-spring.version> | ||||||
|         <node.version>v6.10.0</node.version> |         <node.version>v6.10.0</node.version> | ||||||
|         <!-- These remain empty unless the corresponding profile is active --> |         <!-- These remain empty unless the corresponding profile is active --> | ||||||
|         <profile.no-liquibase /> |         <profile.no-liquibase/> | ||||||
|         <profile.swagger /> |         <profile.swagger/> | ||||||
|         <!-- Sonar properties --> |         <!-- Sonar properties --> | ||||||
|         <project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory> |         <project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory> | ||||||
|         <prometheus-simpleclient.version>0.0.20</prometheus-simpleclient.version> |         <prometheus-simpleclient.version>0.0.20</prometheus-simpleclient.version> | ||||||
| @ -440,7 +442,7 @@ | |||||||
|                                         </goals> |                                         </goals> | ||||||
|                                     </pluginExecutionFilter> |                                     </pluginExecutionFilter> | ||||||
|                                     <action> |                                     <action> | ||||||
|                                         <ignore /> |                                         <ignore/> | ||||||
|                                     </action> |                                     </action> | ||||||
|                                 </pluginExecution> |                                 </pluginExecution> | ||||||
|                             </pluginExecutions> |                             </pluginExecutions> | ||||||
| @ -634,9 +636,9 @@ | |||||||
|                     <diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile> |                     <diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile> | ||||||
|                     <driver>org.h2.Driver</driver> |                     <driver>org.h2.Driver</driver> | ||||||
|                     <url>jdbc:h2:file:./target/h2db/db/carapp</url> |                     <url>jdbc:h2:file:./target/h2db/db/carapp</url> | ||||||
|                     <defaultSchemaName /> |                     <defaultSchemaName/> | ||||||
|                     <username>carapp</username> |                     <username>carapp</username> | ||||||
|                     <password /> |                     <password/> | ||||||
|                     <referenceUrl>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</referenceUrl> |                     <referenceUrl>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</referenceUrl> | ||||||
|                     <verbose>true</verbose> |                     <verbose>true</verbose> | ||||||
|                     <logging>debug</logging> |                     <logging>debug</logging> | ||||||
| @ -683,7 +685,7 @@ | |||||||
|                     <plugin> |                     <plugin> | ||||||
|                         <groupId>org.apache.maven.plugins</groupId> |                         <groupId>org.apache.maven.plugins</groupId> | ||||||
|                         <artifactId>maven-war-plugin</artifactId> |                         <artifactId>maven-war-plugin</artifactId> | ||||||
|                         <configuration /> |                         <configuration/> | ||||||
|                     </plugin> |                     </plugin> | ||||||
|                 </plugins> |                 </plugins> | ||||||
|             </build> |             </build> | ||||||
| @ -722,7 +724,7 @@ | |||||||
|                     <plugin> |                     <plugin> | ||||||
|                         <groupId>org.apache.maven.plugins</groupId> |                         <groupId>org.apache.maven.plugins</groupId> | ||||||
|                         <artifactId>maven-war-plugin</artifactId> |                         <artifactId>maven-war-plugin</artifactId> | ||||||
|                         <configuration /> |                         <configuration/> | ||||||
|                     </plugin> |                     </plugin> | ||||||
|                     <plugin> |                     <plugin> | ||||||
|                         <groupId>org.springframework.boot</groupId> |                         <groupId>org.springframework.boot</groupId> | ||||||
|  | |||||||
| @ -1,5 +1,7 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | <project xmlns="http://maven.apache.org/POM/4.0.0" | ||||||
|  |     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||||
|  |     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||||||
|     <modelVersion>4.0.0</modelVersion> |     <modelVersion>4.0.0</modelVersion> | ||||||
| 
 | 
 | ||||||
|     <parent> |     <parent> | ||||||
| @ -44,8 +46,8 @@ | |||||||
|         <metrics-spring.version>3.1.3</metrics-spring.version> |         <metrics-spring.version>3.1.3</metrics-spring.version> | ||||||
|         <node.version>v6.10.0</node.version> |         <node.version>v6.10.0</node.version> | ||||||
|         <!-- These remain empty unless the corresponding profile is active --> |         <!-- These remain empty unless the corresponding profile is active --> | ||||||
|         <profile.no-liquibase /> |         <profile.no-liquibase/> | ||||||
|         <profile.swagger /> |         <profile.swagger/> | ||||||
|         <!-- Sonar properties --> |         <!-- Sonar properties --> | ||||||
|         <project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory> |         <project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory> | ||||||
|         <prometheus-simpleclient.version>0.0.20</prometheus-simpleclient.version> |         <prometheus-simpleclient.version>0.0.20</prometheus-simpleclient.version> | ||||||
| @ -439,7 +441,7 @@ | |||||||
|                                         </goals> |                                         </goals> | ||||||
|                                     </pluginExecutionFilter> |                                     </pluginExecutionFilter> | ||||||
|                                     <action> |                                     <action> | ||||||
|                                         <ignore /> |                                         <ignore/> | ||||||
|                                     </action> |                                     </action> | ||||||
|                                 </pluginExecution> |                                 </pluginExecution> | ||||||
|                             </pluginExecutions> |                             </pluginExecutions> | ||||||
| @ -633,9 +635,9 @@ | |||||||
|                     <diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile> |                     <diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile> | ||||||
|                     <driver>org.h2.Driver</driver> |                     <driver>org.h2.Driver</driver> | ||||||
|                     <url>jdbc:h2:file:./target/h2db/db/dealerapp</url> |                     <url>jdbc:h2:file:./target/h2db/db/dealerapp</url> | ||||||
|                     <defaultSchemaName /> |                     <defaultSchemaName/> | ||||||
|                     <username>dealerapp</username> |                     <username>dealerapp</username> | ||||||
|                     <password /> |                     <password/> | ||||||
|                     <referenceUrl>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</referenceUrl> |                     <referenceUrl>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</referenceUrl> | ||||||
|                     <verbose>true</verbose> |                     <verbose>true</verbose> | ||||||
|                     <logging>debug</logging> |                     <logging>debug</logging> | ||||||
| @ -682,7 +684,7 @@ | |||||||
|                     <plugin> |                     <plugin> | ||||||
|                         <groupId>org.apache.maven.plugins</groupId> |                         <groupId>org.apache.maven.plugins</groupId> | ||||||
|                         <artifactId>maven-war-plugin</artifactId> |                         <artifactId>maven-war-plugin</artifactId> | ||||||
|                         <configuration /> |                         <configuration/> | ||||||
|                     </plugin> |                     </plugin> | ||||||
|                 </plugins> |                 </plugins> | ||||||
|             </build> |             </build> | ||||||
| @ -721,7 +723,7 @@ | |||||||
|                     <plugin> |                     <plugin> | ||||||
|                         <groupId>org.apache.maven.plugins</groupId> |                         <groupId>org.apache.maven.plugins</groupId> | ||||||
|                         <artifactId>maven-war-plugin</artifactId> |                         <artifactId>maven-war-plugin</artifactId> | ||||||
|                         <configuration /> |                         <configuration/> | ||||||
|                     </plugin> |                     </plugin> | ||||||
|                     <plugin> |                     <plugin> | ||||||
|                         <groupId>org.springframework.boot</groupId> |                         <groupId>org.springframework.boot</groupId> | ||||||
|  | |||||||
| @ -1,5 +1,7 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | <project xmlns="http://maven.apache.org/POM/4.0.0" | ||||||
|  |     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||||||
|  |     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||||||
|     <modelVersion>4.0.0</modelVersion> |     <modelVersion>4.0.0</modelVersion> | ||||||
| 
 | 
 | ||||||
|     <parent> |     <parent> | ||||||
| @ -48,8 +50,8 @@ | |||||||
|         <metrics-spring.version>3.1.3</metrics-spring.version> |         <metrics-spring.version>3.1.3</metrics-spring.version> | ||||||
|         <node.version>v6.10.0</node.version> |         <node.version>v6.10.0</node.version> | ||||||
|         <!-- These remain empty unless the corresponding profile is active --> |         <!-- These remain empty unless the corresponding profile is active --> | ||||||
|         <profile.no-liquibase /> |         <profile.no-liquibase/> | ||||||
|         <profile.swagger /> |         <profile.swagger/> | ||||||
|         <!-- Sonar properties --> |         <!-- Sonar properties --> | ||||||
|         <project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory> |         <project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory> | ||||||
|         <prometheus-simpleclient.version>0.0.20</prometheus-simpleclient.version> |         <prometheus-simpleclient.version>0.0.20</prometheus-simpleclient.version> | ||||||
| @ -481,7 +483,7 @@ | |||||||
|                                         </goals> |                                         </goals> | ||||||
|                                     </pluginExecutionFilter> |                                     </pluginExecutionFilter> | ||||||
|                                     <action> |                                     <action> | ||||||
|                                         <ignore /> |                                         <ignore/> | ||||||
|                                     </action> |                                     </action> | ||||||
|                                 </pluginExecution> |                                 </pluginExecution> | ||||||
|                                 <pluginExecution> |                                 <pluginExecution> | ||||||
| @ -497,7 +499,7 @@ | |||||||
|                                         </goals> |                                         </goals> | ||||||
|                                     </pluginExecutionFilter> |                                     </pluginExecutionFilter> | ||||||
|                                     <action> |                                     <action> | ||||||
|                                         <ignore /> |                                         <ignore/> | ||||||
|                                     </action> |                                     </action> | ||||||
|                                 </pluginExecution> |                                 </pluginExecution> | ||||||
|                             </pluginExecutions> |                             </pluginExecutions> | ||||||
| @ -691,9 +693,9 @@ | |||||||
|                     <diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile> |                     <diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile> | ||||||
|                     <driver>org.h2.Driver</driver> |                     <driver>org.h2.Driver</driver> | ||||||
|                     <url>jdbc:h2:file:./target/h2db/db/gateway</url> |                     <url>jdbc:h2:file:./target/h2db/db/gateway</url> | ||||||
|                     <defaultSchemaName /> |                     <defaultSchemaName/> | ||||||
|                     <username>gateway</username> |                     <username>gateway</username> | ||||||
|                     <password /> |                     <password/> | ||||||
|                     <referenceUrl>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</referenceUrl> |                     <referenceUrl>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</referenceUrl> | ||||||
|                     <verbose>true</verbose> |                     <verbose>true</verbose> | ||||||
|                     <logging>debug</logging> |                     <logging>debug</logging> | ||||||
|  | |||||||
| @ -83,10 +83,8 @@ | |||||||
|     </build> |     </build> | ||||||
| 
 | 
 | ||||||
|     <properties> |     <properties> | ||||||
|         <maven-jar-plugin.version>3.3.0</maven-jar-plugin.version> |  | ||||||
|         <jol-core.version>0.17</jol-core.version> |         <jol-core.version>0.17</jol-core.version> | ||||||
|         <maven-assembly-plugin.version>3.5.0</maven-assembly-plugin.version> |         <maven-assembly-plugin.version>3.5.0</maven-assembly-plugin.version> | ||||||
|         <maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version> |  | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -76,8 +76,6 @@ | |||||||
|         <!-- JSF --> |         <!-- JSF --> | ||||||
|         <com.sun.faces.version>2.2.14</com.sun.faces.version> |         <com.sun.faces.version>2.2.14</com.sun.faces.version> | ||||||
|         <javax.el.version>3.0.0</javax.el.version> |         <javax.el.version>3.0.0</javax.el.version> | ||||||
|         <!-- Maven War plugin --> |  | ||||||
|         <maven-war-plugin.version>3.3.1</maven-war-plugin.version> |  | ||||||
|         <!-- Other --> |         <!-- Other --> | ||||||
|         <javax.annotation-api.version>1.3.1</javax.annotation-api.version> |         <javax.annotation-api.version>1.3.1</javax.annotation-api.version> | ||||||
|     </properties> |     </properties> | ||||||
|  | |||||||
| @ -13,5 +13,6 @@ This module contains articles about JSON. | |||||||
| - [Getting a Value in JSONObject](https://www.baeldung.com/java-jsonobject-get-value) | - [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) | - [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) | - [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) | - More Articles: [[<-- prev]](/json-modules/json) | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								json-modules/json-arrays/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								json-modules/json-arrays/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -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) | ||||||
| @ -61,8 +61,4 @@ | |||||||
|         </plugins> |         </plugins> | ||||||
|     </build> |     </build> | ||||||
| 
 | 
 | ||||||
|     <properties> |  | ||||||
|         <maven-jar-plugin.version>3.0.2</maven-jar-plugin.version> |  | ||||||
|     </properties> |  | ||||||
| 
 |  | ||||||
| </project> | </project> | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> | <?xml version="1.0" encoding="UTF-8"?> | ||||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | <project xmlns="http://maven.apache.org/POM/4.0.0" | ||||||
|  |     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"> |     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||||||
|     <modelVersion>4.0.0</modelVersion> |     <modelVersion>4.0.0</modelVersion> | ||||||
|     <parent> |     <parent> | ||||||
|  | |||||||
| @ -73,7 +73,6 @@ | |||||||
|     <properties> |     <properties> | ||||||
|         <jetty.version>9.4.27.v20200227</jetty.version> |         <jetty.version>9.4.27.v20200227</jetty.version> | ||||||
|         <alpn.version>8.1.11.v20170118</alpn.version> |         <alpn.version>8.1.11.v20170118</alpn.version> | ||||||
|         <maven-war-plugin.version>3.2.2</maven-war-plugin.version> |  | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -291,7 +291,6 @@ | |||||||
|         <quartz.version>2.3.0</quartz.version> |         <quartz.version>2.3.0</quartz.version> | ||||||
|         <javaassist.version>3.29.2-GA</javaassist.version> |         <javaassist.version>3.29.2-GA</javaassist.version> | ||||||
|         <jool.version>0.9.12</jool.version> |         <jool.version>0.9.12</jool.version> | ||||||
|         <maven-jar-plugin.version>3.0.2</maven-jar-plugin.version> |  | ||||||
|         <commons-net.version>3.6</commons-net.version> |         <commons-net.version>3.6</commons-net.version> | ||||||
|         <commonsio.version>2.6</commonsio.version> |         <commonsio.version>2.6</commonsio.version> | ||||||
|     </properties> |     </properties> | ||||||
|  | |||||||
| @ -24,5 +24,4 @@ | |||||||
|         <maven.compiler.target>11</maven.compiler.target> |         <maven.compiler.target>11</maven.compiler.target> | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| </project> | </project> | ||||||
| @ -45,7 +45,6 @@ | |||||||
| 
 | 
 | ||||||
|     </dependencies> |     </dependencies> | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     <properties> |     <properties> | ||||||
|         <java.version>1.8</java.version> |         <java.version>1.8</java.version> | ||||||
|     </properties> |     </properties> | ||||||
|  | |||||||
| @ -22,8 +22,4 @@ | |||||||
|         <module>rest-express</module> |         <module>rest-express</module> | ||||||
|     </modules> |     </modules> | ||||||
| 
 | 
 | ||||||
|     <properties> |  | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |  | ||||||
|     </properties> |  | ||||||
| 
 |  | ||||||
| </project> | </project> | ||||||
| @ -144,7 +144,6 @@ | |||||||
|         <Syntaxe.version>1.0</Syntaxe.version> |         <Syntaxe.version>1.0</Syntaxe.version> | ||||||
|         <repoexpress-mongodb.version>0.4.8</repoexpress-mongodb.version> |         <repoexpress-mongodb.version>0.4.8</repoexpress-mongodb.version> | ||||||
|         <junit4.version>4.11</junit4.version> |         <junit4.version>4.11</junit4.version> | ||||||
|         <exec-maven-plugin.version>1.2.1</exec-maven-plugin.version> |  | ||||||
|         <maven-shade-plugin.version>2.4.1</maven-shade-plugin.version> |         <maven-shade-plugin.version>2.4.1</maven-shade-plugin.version> | ||||||
|         <versions-maven-plugin.version>2.0</versions-maven-plugin.version> |         <versions-maven-plugin.version>2.0</versions-maven-plugin.version> | ||||||
|     </properties> |     </properties> | ||||||
|  | |||||||
| @ -217,6 +217,8 @@ | |||||||
|         <munit.version>1.3.6</munit.version> |         <munit.version>1.3.6</munit.version> | ||||||
|         <build-helper-maven-plugin.version>1.10</build-helper-maven-plugin.version> |         <build-helper-maven-plugin.version>1.10</build-helper-maven-plugin.version> | ||||||
|         <mule-maven-plugin.version>2.2.1</mule-maven-plugin.version> |         <mule-maven-plugin.version>2.2.1</mule-maven-plugin.version> | ||||||
|  |         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> | ||||||
|  |         <maven-install-plugin.version>2.5.2</maven-install-plugin.version> | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -9,3 +9,4 @@ | |||||||
| - [Get the Number of Rows in a ResultSet](https://www.baeldung.com/java-resultset-number-of-rows) | - [Get the Number of Rows in a ResultSet](https://www.baeldung.com/java-resultset-number-of-rows) | ||||||
| - [Converting a JDBC ResultSet to JSON in Java](https://www.baeldung.com/java-jdbc-convert-resultset-to-json) | - [Converting a JDBC ResultSet to JSON in Java](https://www.baeldung.com/java-jdbc-convert-resultset-to-json) | ||||||
| - [Guide to MicroStream](https://www.baeldung.com/microstream-intro) | - [Guide to MicroStream](https://www.baeldung.com/microstream-intro) | ||||||
|  | - [Executing SQL Script File in Java](https://www.baeldung.com/java-run-sql-script) | ||||||
|  | |||||||
| @ -166,7 +166,6 @@ | |||||||
|         <javassist.version>3.27.0-GA</javassist.version> |         <javassist.version>3.27.0-GA</javassist.version> | ||||||
|         <jaxb.version>2.3.1</jaxb.version> |         <jaxb.version>2.3.1</jaxb.version> | ||||||
|         <log4jdbc.version>2.0.0</log4jdbc.version> |         <log4jdbc.version>2.0.0</log4jdbc.version> | ||||||
|         <maven-jar-plugin.version>3.0.2</maven-jar-plugin.version> |  | ||||||
|         <maven.compiler.version>3.8.1</maven.compiler.version> |         <maven.compiler.version>3.8.1</maven.compiler.version> | ||||||
|         <maven.version>3.8.1</maven.version> |         <maven.version>3.8.1</maven.version> | ||||||
|         <mysql.version>8.0.19</mysql.version> |         <mysql.version>8.0.19</mysql.version> | ||||||
|  | |||||||
| @ -156,7 +156,6 @@ | |||||||
|     <properties> |     <properties> | ||||||
|         <eclipselink.version>4.0.1</eclipselink.version> |         <eclipselink.version>4.0.1</eclipselink.version> | ||||||
|         <javax.persistence-api.version>2.2</javax.persistence-api.version> |         <javax.persistence-api.version>2.2</javax.persistence-api.version> | ||||||
|         <maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version> |  | ||||||
|         <maven-processor-plugin.version>3.3.3</maven-processor-plugin.version> |         <maven-processor-plugin.version>3.3.3</maven-processor-plugin.version> | ||||||
|         <build-helper-maven-plugin.version>3.0.0</build-helper-maven-plugin.version> |         <build-helper-maven-plugin.version>3.0.0</build-helper-maven-plugin.version> | ||||||
|         <querydsl.version>5.0.0</querydsl.version> |         <querydsl.version>5.0.0</querydsl.version> | ||||||
|  | |||||||
| @ -88,7 +88,6 @@ | |||||||
|         <eclipselink.version>2.7.4</eclipselink.version> |         <eclipselink.version>2.7.4</eclipselink.version> | ||||||
|         <mysql.version>8.0.21</mysql.version> |         <mysql.version>8.0.21</mysql.version> | ||||||
|         <javax.persistence-api.version>2.2</javax.persistence-api.version> |         <javax.persistence-api.version>2.2</javax.persistence-api.version> | ||||||
|         <maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version> |  | ||||||
|         <maven-processor-plugin.version>3.3.3</maven-processor-plugin.version> |         <maven-processor-plugin.version>3.3.3</maven-processor-plugin.version> | ||||||
|         <build-helper-maven-plugin.version>3.0.0</build-helper-maven-plugin.version> |         <build-helper-maven-plugin.version>3.0.0</build-helper-maven-plugin.version> | ||||||
|         <h2.version>2.1.214</h2.version> |         <h2.version>2.1.214</h2.version> | ||||||
|  | |||||||
							
								
								
									
										22
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								pom.xml
									
									
									
									
									
								
							| @ -474,6 +474,7 @@ | |||||||
|                 <module>apache-spark</module> |                 <module>apache-spark</module> | ||||||
| 
 | 
 | ||||||
|                 <module>jenkins-modules</module> |                 <module>jenkins-modules</module> | ||||||
|  |                 <module>jhipster-6</module> | ||||||
|                 <module>jhipster-modules</module> |                 <module>jhipster-modules</module> | ||||||
|             </modules> |             </modules> | ||||||
|         </profile> |         </profile> | ||||||
| @ -632,6 +633,7 @@ | |||||||
|                 <module>apache-spark</module> |                 <module>apache-spark</module> | ||||||
| 
 | 
 | ||||||
|                 <module>jenkins-modules</module> |                 <module>jenkins-modules</module> | ||||||
|  |                 <module>jhipster-6</module> | ||||||
|                 <module>jhipster-modules</module> |                 <module>jhipster-modules</module> | ||||||
|             </modules> |             </modules> | ||||||
| 
 | 
 | ||||||
| @ -786,7 +788,6 @@ | |||||||
|                 <module>guava-modules</module> |                 <module>guava-modules</module> | ||||||
|                 <module>kubernetes-modules</module> |                 <module>kubernetes-modules</module> | ||||||
|                 <module>libraries-concurrency</module> |                 <module>libraries-concurrency</module> | ||||||
|                 <module>jhipster-6</module> |  | ||||||
|                 <module>libraries-testing</module> |                 <module>libraries-testing</module> | ||||||
|                 <module>maven-modules</module> |                 <module>maven-modules</module> | ||||||
|                 <module>optaplanner</module> |                 <module>optaplanner</module> | ||||||
| @ -1058,7 +1059,6 @@ | |||||||
|                 <module>guava-modules</module> |                 <module>guava-modules</module> | ||||||
|                 <module>kubernetes-modules</module> |                 <module>kubernetes-modules</module> | ||||||
|                 <module>libraries-concurrency</module> |                 <module>libraries-concurrency</module> | ||||||
|                 <module>jhipster-6</module> |  | ||||||
|                 <module>libraries-testing</module> |                 <module>libraries-testing</module> | ||||||
|                 <module>maven-modules</module> |                 <module>maven-modules</module> | ||||||
|                 <module>optaplanner</module> |                 <module>optaplanner</module> | ||||||
| @ -1270,19 +1270,19 @@ | |||||||
| 
 | 
 | ||||||
|         <!-- plugins --> |         <!-- plugins --> | ||||||
|         <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version> |         <maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version> | ||||||
|         <maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version> |         <maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version> | ||||||
|         <exec-maven-plugin.version>3.0.0</exec-maven-plugin.version> |         <exec-maven-plugin.version>3.1.0</exec-maven-plugin.version> | ||||||
|         <java.version>1.8</java.version> |         <java.version>1.8</java.version> | ||||||
|         <log4j.version>1.2.17</log4j.version> |         <log4j.version>1.2.17</log4j.version> | ||||||
|         <jmh-core.version>1.36</jmh-core.version> |         <jmh-core.version>1.36</jmh-core.version> | ||||||
|         <jmh-generator.version>1.36</jmh-generator.version> |         <jmh-generator.version>1.36</jmh-generator.version> | ||||||
|         <maven-failsafe-plugin.version>2.21.0</maven-failsafe-plugin.version> |         <maven-failsafe-plugin.version>3.1.2</maven-failsafe-plugin.version> | ||||||
|         <commons-collections4.version>4.4</commons-collections4.version> |         <commons-collections4.version>4.4</commons-collections4.version> | ||||||
|         <commons-io.version>2.13.0</commons-io.version> |         <commons-io.version>2.13.0</commons-io.version> | ||||||
|         <commons-lang.version>2.6</commons-lang.version> |         <commons-lang.version>2.6</commons-lang.version> | ||||||
|         <commons-lang3.version>3.13.0</commons-lang3.version> |         <commons-lang3.version>3.13.0</commons-lang3.version> | ||||||
|         <commons-cli.version>1.5.0</commons-cli.version> |         <commons-cli.version>1.5.0</commons-cli.version> | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |         <maven-war-plugin.version>3.4.0</maven-war-plugin.version> | ||||||
|         <javax.servlet-api.version>4.0.1</javax.servlet-api.version> |         <javax.servlet-api.version>4.0.1</javax.servlet-api.version> | ||||||
|         <jstl-api.version>1.2</jstl-api.version> |         <jstl-api.version>1.2</jstl-api.version> | ||||||
|         <javax.servlet.jsp-api.version>2.3.3</javax.servlet.jsp-api.version> |         <javax.servlet.jsp-api.version>2.3.3</javax.servlet.jsp-api.version> | ||||||
| @ -1292,16 +1292,16 @@ | |||||||
|         <junit-platform.version>1.9.2</junit-platform.version> |         <junit-platform.version>1.9.2</junit-platform.version> | ||||||
|         <junit-jupiter.version>5.9.2</junit-jupiter.version> |         <junit-jupiter.version>5.9.2</junit-jupiter.version> | ||||||
|         <junit-platform-surefire-provider.version>1.3.2</junit-platform-surefire-provider.version> |         <junit-platform-surefire-provider.version>1.3.2</junit-platform-surefire-provider.version> | ||||||
|         <directory-maven-plugin.version>0.3.1</directory-maven-plugin.version> |         <directory-maven-plugin.version>1.0</directory-maven-plugin.version> | ||||||
|         <maven-install-plugin.version>2.5.2</maven-install-plugin.version> |         <maven-install-plugin.version>3.1.1</maven-install-plugin.version> | ||||||
|         <custom-pmd.version>0.0.1</custom-pmd.version> |         <custom-pmd.version>0.0.1</custom-pmd.version> | ||||||
|         <gitflow-incremental-builder.version>3.12.2</gitflow-incremental-builder.version> |         <gitflow-incremental-builder.version>3.12.2</gitflow-incremental-builder.version> | ||||||
|         <maven-jxr-plugin.version>3.0.0</maven-jxr-plugin.version> |         <maven-jxr-plugin.version>3.3.0</maven-jxr-plugin.version> | ||||||
|         <maven-pmd-plugin.version>3.19.0</maven-pmd-plugin.version> |         <maven-pmd-plugin.version>3.21.0</maven-pmd-plugin.version> | ||||||
|         <lombok.version>1.18.28</lombok.version> |         <lombok.version>1.18.28</lombok.version> | ||||||
|         <h2.version>2.1.214</h2.version> |         <h2.version>2.1.214</h2.version> | ||||||
|         <guava.version>32.1.2-jre</guava.version> |         <guava.version>32.1.2-jre</guava.version> | ||||||
|         <maven-jar-plugin.version>3.2.2</maven-jar-plugin.version> |         <maven-jar-plugin.version>3.3.0</maven-jar-plugin.version> | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
|  | |||||||
| @ -255,7 +255,6 @@ | |||||||
|         <testcontainers-bom.version>1.17.2</testcontainers-bom.version> |         <testcontainers-bom.version>1.17.2</testcontainers-bom.version> | ||||||
|         <java.version>11</java.version> |         <java.version>11</java.version> | ||||||
|         <spring-native.version>0.12.1</spring-native.version> |         <spring-native.version>0.12.1</spring-native.version> | ||||||
|         <maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version> |  | ||||||
|         <maven.compiler.source.version>11</maven.compiler.source.version> |         <maven.compiler.source.version>11</maven.compiler.source.version> | ||||||
|         <maven.compiler.target.version>11</maven.compiler.target.version> |         <maven.compiler.target.version>11</maven.compiler.target.version> | ||||||
|         <maven-surefire-plugin.version>3.1.0</maven-surefire-plugin.version> |         <maven-surefire-plugin.version>3.1.0</maven-surefire-plugin.version> | ||||||
|  | |||||||
| @ -46,6 +46,5 @@ | |||||||
|     <properties> |     <properties> | ||||||
|         <sentry.version>6.11.0</sentry.version> |         <sentry.version>6.11.0</sentry.version> | ||||||
|         <cargo-maven3-plugin.version>1.10.4</cargo-maven3-plugin.version> |         <cargo-maven3-plugin.version>1.10.4</cargo-maven3-plugin.version> | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |  | ||||||
|     </properties> |     </properties> | ||||||
| </project> | </project> | ||||||
| @ -55,7 +55,6 @@ | |||||||
| 
 | 
 | ||||||
|     <properties> |     <properties> | ||||||
|         <slack.version>1.4</slack.version> |         <slack.version>1.4</slack.version> | ||||||
|         <maven-jar-plugin.version>2.4</maven-jar-plugin.version> |  | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -25,8 +25,4 @@ | |||||||
|         <module>sql-injection-samples</module> |         <module>sql-injection-samples</module> | ||||||
|     </modules> |     </modules> | ||||||
| 
 | 
 | ||||||
|     <properties> |  | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |  | ||||||
|     </properties> |  | ||||||
| 
 |  | ||||||
| </project> | </project> | ||||||
|  | |||||||
| @ -46,7 +46,6 @@ | |||||||
|     <properties> |     <properties> | ||||||
|         <undertow-servlet.version>1.4.18.Final</undertow-servlet.version> |         <undertow-servlet.version>1.4.18.Final</undertow-servlet.version> | ||||||
|         <!--<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version> --> |         <!--<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version> --> | ||||||
|         <maven-jar-plugin.version>3.0.2</maven-jar-plugin.version> |  | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -44,7 +44,7 @@ | |||||||
|         <module>spring-boot-graphql</module> |         <module>spring-boot-graphql</module> | ||||||
|         <module>spring-boot-groovy</module> |         <module>spring-boot-groovy</module> | ||||||
|         <!-- <module>spring-boot-gradle</module> --> <!-- Not a maven project --> |         <!-- <module>spring-boot-gradle</module> --> <!-- Not a maven project --> | ||||||
|         <!--<module>spring-boot-jasypt</module>--> <!-- Fixing in JAVA-24011 --> |         <module>spring-boot-jasypt</module> | ||||||
|         <module>spring-boot-jsp</module> |         <module>spring-boot-jsp</module> | ||||||
|         <module>spring-boot-keycloak</module> |         <module>spring-boot-keycloak</module> | ||||||
|         <module>spring-boot-keycloak-2</module> |         <module>spring-boot-keycloak-2</module> | ||||||
| @ -91,6 +91,7 @@ | |||||||
|         <module>spring-boot-3-native</module> |         <module>spring-boot-3-native</module> | ||||||
|         <module>spring-boot-3-observation</module> |         <module>spring-boot-3-observation</module> | ||||||
|         <module>spring-boot-3-test-pitfalls</module> |         <module>spring-boot-3-test-pitfalls</module> | ||||||
|  |         <module>spring-boot-3-testcontainers</module> | ||||||
|         <module>spring-boot-resilience4j</module> |         <module>spring-boot-resilience4j</module> | ||||||
|         <module>spring-boot-properties</module> |         <module>spring-boot-properties</module> | ||||||
|         <module>spring-boot-properties-2</module> |         <module>spring-boot-properties-2</module> | ||||||
| @ -119,8 +120,4 @@ | |||||||
|         </dependencies> |         </dependencies> | ||||||
|     </dependencyManagement> |     </dependencyManagement> | ||||||
| 
 | 
 | ||||||
|     <properties> |  | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |  | ||||||
|     </properties> |  | ||||||
| 
 |  | ||||||
| </project> | </project> | ||||||
|  | |||||||
| @ -0,0 +1 @@ | |||||||
|  | ## Relevant Articles | ||||||
							
								
								
									
										102
									
								
								spring-boot-modules/spring-boot-3-testcontainers/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										102
									
								
								spring-boot-modules/spring-boot-3-testcontainers/pom.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,102 @@ | |||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <project xmlns="http://maven.apache.org/POM/4.0.0" | ||||||
|  |          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"> | ||||||
|  |     <modelVersion>4.0.0</modelVersion> | ||||||
|  |     <artifactId>spring-boot-3-testcontainers</artifactId> | ||||||
|  |     <version>0.0.1-SNAPSHOT</version> | ||||||
|  |     <name>spring-boot-3-testcontainers</name> | ||||||
|  |     <description>Testcontainer Improvements in Spring Boot 3</description> | ||||||
|  | 
 | ||||||
|  |     <parent> | ||||||
|  |         <groupId>com.baeldung</groupId> | ||||||
|  |         <artifactId>parent-boot-3</artifactId> | ||||||
|  |         <version>0.0.1-SNAPSHOT</version> | ||||||
|  |         <relativePath>../../parent-boot-3</relativePath> | ||||||
|  |     </parent> | ||||||
|  | 
 | ||||||
|  |     <dependencies> | ||||||
|  | 
 | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>org.springframework.boot</groupId> | ||||||
|  |             <artifactId>spring-boot-starter</artifactId> | ||||||
|  |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>org.springframework.boot</groupId> | ||||||
|  |             <artifactId>spring-boot-starter-web</artifactId> | ||||||
|  |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>org.springframework.boot</groupId> | ||||||
|  |             <artifactId>spring-boot-devtools</artifactId> | ||||||
|  |             <scope>runtime</scope> | ||||||
|  |             <optional>true</optional> | ||||||
|  |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>org.springframework.boot</groupId> | ||||||
|  |             <artifactId>spring-boot-starter-test</artifactId> | ||||||
|  |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>org.springframework.boot</groupId> | ||||||
|  |             <artifactId>spring-boot-starter-data-mongodb</artifactId> | ||||||
|  |         </dependency> | ||||||
|  | 
 | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>org.springframework.boot</groupId> | ||||||
|  |             <artifactId>spring-boot-testcontainers</artifactId> | ||||||
|  |         </dependency> | ||||||
|  | 
 | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>org.testcontainers</groupId> | ||||||
|  |             <artifactId>mongodb</artifactId> | ||||||
|  |             <version>${testcontainers.version}</version> | ||||||
|  |             <scope>test</scope> | ||||||
|  |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>org.testcontainers</groupId> | ||||||
|  |             <artifactId>testcontainers</artifactId> | ||||||
|  |             <version>${testcontainers.version}</version> | ||||||
|  |             <scope>test</scope> | ||||||
|  |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>org.testcontainers</groupId> | ||||||
|  |             <artifactId>junit-jupiter</artifactId> | ||||||
|  |             <version>${testcontainers.version}</version> | ||||||
|  |             <scope>test</scope> | ||||||
|  |         </dependency> | ||||||
|  | 
 | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>io.rest-assured</groupId> | ||||||
|  |             <artifactId>rest-assured</artifactId> | ||||||
|  |             <version>${rest-assured.version}</version> | ||||||
|  |             <scope>test</scope> | ||||||
|  |         </dependency> | ||||||
|  |     </dependencies> | ||||||
|  | 
 | ||||||
|  |     <build> | ||||||
|  |         <pluginManagement> | ||||||
|  |             <plugins> | ||||||
|  |                 <plugin> | ||||||
|  |                     <groupId>org.apache.maven.plugins</groupId> | ||||||
|  |                     <artifactId>maven-compiler-plugin</artifactId> | ||||||
|  |                 </plugin> | ||||||
|  |                 <plugin> | ||||||
|  |                     <groupId>org.springframework.boot</groupId> | ||||||
|  |                     <artifactId>spring-boot-maven-plugin</artifactId> | ||||||
|  |                 </plugin> | ||||||
|  |             </plugins> | ||||||
|  |         </pluginManagement> | ||||||
|  |         <plugins> | ||||||
|  |             <plugin> | ||||||
|  |                 <groupId>org.springframework.boot</groupId> | ||||||
|  |                 <artifactId>spring-boot-maven-plugin</artifactId> | ||||||
|  |             </plugin> | ||||||
|  |         </plugins> | ||||||
|  |     </build> | ||||||
|  | 
 | ||||||
|  |     <properties> | ||||||
|  |         <maven-surefire-plugin.version>3.0.0-M7</maven-surefire-plugin.version> | ||||||
|  |         <testcontainers.version>1.18.3</testcontainers.version> | ||||||
|  |         <rest-assured.version>5.3.1</rest-assured.version> | ||||||
|  |     </properties> | ||||||
|  | 
 | ||||||
|  | </project> | ||||||
| @ -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); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -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); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -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<MiddleEarthCharacter> findByRace(@RequestParam String race) { | ||||||
|  |         return repository.findAllByRace(race); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @PostMapping | ||||||
|  |     public MiddleEarthCharacter save(@RequestBody MiddleEarthCharacter character) { | ||||||
|  |         return repository.save(character); | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -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<MiddleEarthCharacter, String> { | ||||||
|  |     List<MiddleEarthCharacter> findAllByRace(String race); | ||||||
|  | } | ||||||
| @ -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")); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -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")); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -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")); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -193,7 +193,6 @@ | |||||||
|         <git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version> |         <git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version> | ||||||
|         <subethasmtp.version>3.1.7</subethasmtp.version> |         <subethasmtp.version>3.1.7</subethasmtp.version> | ||||||
|         <httpclient.version>4.5.8</httpclient.version> |         <httpclient.version>4.5.8</httpclient.version> | ||||||
|         <maven-failsafe-plugin.version>2.18</maven-failsafe-plugin.version> |  | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -86,5 +86,4 @@ | |||||||
|         <start-class>com.baeldung.changeport.CustomApplication</start-class> |         <start-class>com.baeldung.changeport.CustomApplication</start-class> | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| </project> | </project> | ||||||
| @ -92,7 +92,6 @@ | |||||||
|     </build> |     </build> | ||||||
| 
 | 
 | ||||||
|     <properties> |     <properties> | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |  | ||||||
|         <swagger-core.version>2.2.11</swagger-core.version> |         <swagger-core.version>2.2.11</swagger-core.version> | ||||||
|         <springwolf-kafka.version>0.12.1</springwolf-kafka.version> |         <springwolf-kafka.version>0.12.1</springwolf-kafka.version> | ||||||
|         <springwolf-ui.version>0.8.0</springwolf-ui.version> |         <springwolf-ui.version>0.8.0</springwolf-ui.version> | ||||||
|  | |||||||
| @ -50,4 +50,11 @@ | |||||||
|         <jasypt.version>2.0.0</jasypt.version> |         <jasypt.version>2.0.0</jasypt.version> | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
|  |     <repositories> | ||||||
|  |         <repository> | ||||||
|  |             <id>spring-milestone</id> | ||||||
|  |             <name>Spring Milestone</name> | ||||||
|  |             <url>https://repo.spring.io/milestone</url> | ||||||
|  |         </repository> | ||||||
|  |     </repositories> | ||||||
| </project> | </project> | ||||||
| @ -1,6 +1,7 @@ | |||||||
| package com.baeldung.configurationproperties; | package com.baeldung.configurationproperties; | ||||||
| 
 | 
 | ||||||
| import org.springframework.boot.context.properties.ConfigurationProperties; | import org.springframework.boot.context.properties.ConfigurationProperties; | ||||||
|  | import org.springframework.boot.context.properties.bind.ConstructorBinding; | ||||||
| 
 | 
 | ||||||
| @ConfigurationProperties(prefix = "mail.credentials") | @ConfigurationProperties(prefix = "mail.credentials") | ||||||
| public class ImmutableCredentials { | public class ImmutableCredentials { | ||||||
| @ -9,12 +10,19 @@ public class ImmutableCredentials { | |||||||
|     private final String username; |     private final String username; | ||||||
|     private final String password; |     private final String password; | ||||||
| 
 | 
 | ||||||
|  |     @ConstructorBinding | ||||||
|     public ImmutableCredentials(String authMethod, String username, String password) { |     public ImmutableCredentials(String authMethod, String username, String password) { | ||||||
|         this.authMethod = authMethod; |         this.authMethod = authMethod; | ||||||
|         this.username = username; |         this.username = username; | ||||||
|         this.password = password; |         this.password = password; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public ImmutableCredentials(String username, String password) { | ||||||
|  |         this.username = username; | ||||||
|  |         this.password = password; | ||||||
|  |         this.authMethod = "Default"; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public String getAuthMethod() { |     public String getAuthMethod() { | ||||||
|         return authMethod; |         return authMethod; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -31,9 +31,13 @@ import org.springframework.http.HttpStatus; | |||||||
| import org.springframework.http.ResponseEntity; | import org.springframework.http.ResponseEntity; | ||||||
| import org.springframework.test.annotation.DirtiesContext; | 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) | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||||||
| @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) | @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) | ||||||
| class ResilientAppControllerIntegrationTest { | class ResilientAppControllerManualTest { | ||||||
| 
 | 
 | ||||||
|   private final Logger LOGGER = LoggerFactory.getLogger(getClass()); |   private final Logger LOGGER = LoggerFactory.getLogger(getClass()); | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								spring-boot-modules/spring-boot-telegram/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								spring-boot-modules/spring-boot-telegram/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | |||||||
|  | ## Relevant Articles | ||||||
|  | - [Creating a Telegram Bot with Spring Boot](https://www.baeldung.com/spring-boot-telegram-bot) | ||||||
| @ -96,7 +96,6 @@ | |||||||
|         <start-class>com.baeldung.boot.Application</start-class> |         <start-class>com.baeldung.boot.Application</start-class> | ||||||
|         <spock.version>2.4-M1-groovy-4.0</spock.version> |         <spock.version>2.4-M1-groovy-4.0</spock.version> | ||||||
|         <gmavenplus-plugin.version>3.0.0</gmavenplus-plugin.version> |         <gmavenplus-plugin.version>3.0.0</gmavenplus-plugin.version> | ||||||
|         <maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version> |  | ||||||
|         <log4j2.version>2.17.1</log4j2.version> |         <log4j2.version>2.17.1</log4j2.version> | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -121,7 +121,6 @@ | |||||||
|         <git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version> |         <git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version> | ||||||
|         <spock.version>2.4-M1-groovy-4.0</spock.version> |         <spock.version>2.4-M1-groovy-4.0</spock.version> | ||||||
|         <gmavenplus-plugin.version>3.0.0</gmavenplus-plugin.version> |         <gmavenplus-plugin.version>3.0.0</gmavenplus-plugin.version> | ||||||
|         <maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version> |  | ||||||
|         <redis.version>0.7.2</redis.version> |         <redis.version>0.7.2</redis.version> | ||||||
|         <spring-boot.version>2.5.0</spring-boot.version> |         <spring-boot.version>2.5.0</spring-boot.version> | ||||||
|         <log4j2.version>2.17.1</log4j2.version> |         <log4j2.version>2.17.1</log4j2.version> | ||||||
|  | |||||||
| @ -163,7 +163,6 @@ | |||||||
|         <start-class>com.baeldung.SpringBootRestApplication</start-class> |         <start-class>com.baeldung.SpringBootRestApplication</start-class> | ||||||
|         <xstream.version>1.4.11.1</xstream.version> |         <xstream.version>1.4.11.1</xstream.version> | ||||||
|         <modelmapper.version>3.1.0</modelmapper.version> |         <modelmapper.version>3.1.0</modelmapper.version> | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |  | ||||||
|         <jaxb-runtime.version>2.3.7</jaxb-runtime.version> |         <jaxb-runtime.version>2.3.7</jaxb-runtime.version> | ||||||
|     </properties> |     </properties> | ||||||
| </project> | </project> | ||||||
|  | |||||||
| @ -22,7 +22,6 @@ | |||||||
|     <properties> |     <properties> | ||||||
|         <spring-cloud-dependencies.version>2020.0.3</spring-cloud-dependencies.version> |         <spring-cloud-dependencies.version>2020.0.3</spring-cloud-dependencies.version> | ||||||
|         <spring-cloud-netflix-zuul.version>2.2.7.RELEASE</spring-cloud-netflix-zuul.version> |         <spring-cloud-netflix-zuul.version>2.2.7.RELEASE</spring-cloud-netflix-zuul.version> | ||||||
|         <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version> |  | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -84,7 +84,6 @@ | |||||||
|         <awaitility.version>4.0.2</awaitility.version> |         <awaitility.version>4.0.2</awaitility.version> | ||||||
|         <servlet-api.version>4.0.0</servlet-api.version> |         <servlet-api.version>4.0.0</servlet-api.version> | ||||||
|         <annotation-api.version>1.3.2</annotation-api.version> |         <annotation-api.version>1.3.2</annotation-api.version> | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |  | ||||||
|         <apache-commons-text.version>1.10.0</apache-commons-text.version> |         <apache-commons-text.version>1.10.0</apache-commons-text.version> | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -88,7 +88,6 @@ | |||||||
|         <spring-boot.version>1.5.2.RELEASE</spring-boot.version> |         <spring-boot.version>1.5.2.RELEASE</spring-boot.version> | ||||||
|         <mockito.version>1.10.19</mockito.version> |         <mockito.version>1.10.19</mockito.version> | ||||||
|         <annotation-api.version>1.3.2</annotation-api.version> |         <annotation-api.version>1.3.2</annotation-api.version> | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |  | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -149,7 +149,6 @@ | |||||||
|         <spring-boot.version>1.5.2.RELEASE</spring-boot.version> |         <spring-boot.version>1.5.2.RELEASE</spring-boot.version> | ||||||
|         <mockito.version>1.10.19</mockito.version> |         <mockito.version>1.10.19</mockito.version> | ||||||
|         <aspectjweaver.version>1.9.5</aspectjweaver.version> |         <aspectjweaver.version>1.9.5</aspectjweaver.version> | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |  | ||||||
|     </properties> |     </properties> | ||||||
| 
 | 
 | ||||||
| </project> | </project> | ||||||
| @ -16,11 +16,6 @@ | |||||||
|     </parent> |     </parent> | ||||||
| 
 | 
 | ||||||
|     <modules> |     <modules> | ||||||
|         <module>widlfly-web</module> |  | ||||||
|         <module>wildfly-ear</module> |  | ||||||
|         <module>wildfly-jpa</module> |  | ||||||
|         <module>wildfly-ejb-interfaces</module> |  | ||||||
|         <module>wildfly-ejb</module> |  | ||||||
|         <module>wildfly-mdb</module> |         <module>wildfly-mdb</module> | ||||||
|     </modules> |     </modules> | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,47 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> |  | ||||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" |  | ||||||
|     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |  | ||||||
|     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |  | ||||||
|     <modelVersion>4.0.0</modelVersion> |  | ||||||
|     <artifactId>widlfly-web</artifactId> |  | ||||||
|     <name>widlfly-web</name> |  | ||||||
|     <packaging>war</packaging> |  | ||||||
| 
 |  | ||||||
|     <parent> |  | ||||||
|         <groupId>com.baeldung.wildfly</groupId> |  | ||||||
|         <artifactId>wildfly</artifactId> |  | ||||||
|         <version>0.0.1-SNAPSHOT</version> |  | ||||||
|     </parent> |  | ||||||
| 
 |  | ||||||
|     <dependencies> |  | ||||||
|         <!-- Dependency for java ee --> |  | ||||||
|         <dependency> |  | ||||||
|             <groupId>javax</groupId> |  | ||||||
|             <artifactId>javaee-api</artifactId> |  | ||||||
|             <version>${javaee-api.version}</version> |  | ||||||
|             <scope>provided</scope> |  | ||||||
|         </dependency> |  | ||||||
|         <!-- Dependency for JPA module --> |  | ||||||
|         <dependency> |  | ||||||
|             <groupId>com.baeldung.wildfly</groupId> |  | ||||||
|             <artifactId>wildfly-jpa</artifactId> |  | ||||||
|             <version>${wildlfy.version}</version> |  | ||||||
|         </dependency> |  | ||||||
|         <!-- Dependency for EJB interface module --> |  | ||||||
|         <dependency> |  | ||||||
|             <groupId>com.baeldung.wildfly</groupId> |  | ||||||
|             <artifactId>wildfly-ejb-interfaces</artifactId> |  | ||||||
|             <version>${wildlfy.version}</version> |  | ||||||
|         </dependency> |  | ||||||
|         <!-- Dependency for EJB interface module --> |  | ||||||
|         <dependency> |  | ||||||
|             <groupId>com.baeldung.wildfly</groupId> |  | ||||||
|             <artifactId>wildfly-ejb</artifactId> |  | ||||||
|             <version>${wildlfy.version}</version> |  | ||||||
|         </dependency> |  | ||||||
|     </dependencies> |  | ||||||
| 
 |  | ||||||
|     <properties> |  | ||||||
|         <maven-war-plugin.version>3.3.2</maven-war-plugin.version> |  | ||||||
|     </properties> |  | ||||||
| </project> |  | ||||||
| @ -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<User> users = userBean.getUsers(); |  | ||||||
| 
 |  | ||||||
|         PrintWriter out = response.getWriter(); |  | ||||||
| 
 |  | ||||||
|         out.println("<html>"); |  | ||||||
|         out.println("<body>"); |  | ||||||
|         for (User user : users) { |  | ||||||
|             out.print(user.getUsername()); |  | ||||||
|             out.print(" " + user.getEmail() + " <br>"); |  | ||||||
|         } |  | ||||||
|         out.println("</body>"); |  | ||||||
|         out.println("</html>"); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { |  | ||||||
|         doGet(request, response); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @ -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<User> 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); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
| } |  | ||||||
| @ -1,13 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> |  | ||||||
| <configuration> |  | ||||||
|     <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> |  | ||||||
|         <encoder> |  | ||||||
|             <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n |  | ||||||
|             </pattern> |  | ||||||
|         </encoder> |  | ||||||
|     </appender> |  | ||||||
| 
 |  | ||||||
|     <root level="INFO"> |  | ||||||
|         <appender-ref ref="STDOUT" /> |  | ||||||
|     </root> |  | ||||||
| </configuration> |  | ||||||
| @ -1,35 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> |  | ||||||
| <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |  | ||||||
| 	xmlns="http://java.sun.com/xml/ns/javaee" |  | ||||||
| 	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" |  | ||||||
| 	version="2.5"> |  | ||||||
| 	<display-name>widlfly-web</display-name> |  | ||||||
| 	<welcome-file-list> |  | ||||||
| 		<welcome-file>index.html</welcome-file> |  | ||||||
| 		<welcome-file>index.htm</welcome-file> |  | ||||||
| 		<welcome-file>index.jsp</welcome-file> |  | ||||||
| 		<welcome-file>default.html</welcome-file> |  | ||||||
| 		<welcome-file>default.htm</welcome-file> |  | ||||||
| 		<welcome-file>default.jsp</welcome-file> |  | ||||||
| 	</welcome-file-list> |  | ||||||
| 	<servlet> |  | ||||||
| 		<description></description> |  | ||||||
| 		<display-name>TestJPAServlet</display-name> |  | ||||||
| 		<servlet-name>TestJPAServlet</servlet-name> |  | ||||||
| 		<servlet-class>TestJPAServlet</servlet-class> |  | ||||||
| 	</servlet> |  | ||||||
| 	<servlet-mapping> |  | ||||||
| 		<servlet-name>TestJPAServlet</servlet-name> |  | ||||||
| 		<url-pattern>/TestJPAServlet</url-pattern> |  | ||||||
| 	</servlet-mapping> |  | ||||||
| 	<servlet> |  | ||||||
| 		<description></description> |  | ||||||
| 		<display-name>TestEJBServlet</display-name> |  | ||||||
| 		<servlet-name>TestEJBServlet</servlet-name> |  | ||||||
| 		<servlet-class>TestEJBServlet</servlet-class> |  | ||||||
| 	</servlet> |  | ||||||
| 	<servlet-mapping> |  | ||||||
| 		<servlet-name>TestEJBServlet</servlet-name> |  | ||||||
| 		<url-pattern>/TestEJBServlet</url-pattern> |  | ||||||
| 	</servlet-mapping> |  | ||||||
| </web-app> |  | ||||||
| @ -1,73 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> |  | ||||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" |  | ||||||
|     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |  | ||||||
|     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |  | ||||||
|     <modelVersion>4.0.0</modelVersion> |  | ||||||
|     <artifactId>wildfly-ear</artifactId> |  | ||||||
|     <name>wildfly-ear</name> |  | ||||||
|     <packaging>ear</packaging> |  | ||||||
| 
 |  | ||||||
|     <parent> |  | ||||||
|         <groupId>com.baeldung.wildfly</groupId> |  | ||||||
|         <artifactId>wildfly</artifactId> |  | ||||||
|         <version>0.0.1-SNAPSHOT</version> |  | ||||||
|     </parent> |  | ||||||
| 
 |  | ||||||
|     <dependencies> |  | ||||||
|         <!-- Dependency for web module --> |  | ||||||
|         <dependency> |  | ||||||
|             <groupId>com.baeldung.wildfly</groupId> |  | ||||||
|             <artifactId>widlfly-web</artifactId> |  | ||||||
|             <version>${wildlfy.version}</version> |  | ||||||
|             <type>war</type> |  | ||||||
|         </dependency> |  | ||||||
|         <!-- Dependency for web module --> |  | ||||||
|         <dependency> |  | ||||||
|             <groupId>com.baeldung.wildfly</groupId> |  | ||||||
|             <artifactId>wildfly-jpa</artifactId> |  | ||||||
|             <version>${wildlfy.version}</version> |  | ||||||
|         </dependency> |  | ||||||
|         <!-- Dependency for EJB --> |  | ||||||
|         <dependency> |  | ||||||
|             <groupId>com.baeldung.wildfly</groupId> |  | ||||||
|             <artifactId>wildfly-ejb</artifactId> |  | ||||||
|         </dependency> |  | ||||||
|         <!-- Dependency for EJB --> |  | ||||||
|         <dependency> |  | ||||||
|             <groupId>com.baeldung.wildfly</groupId> |  | ||||||
|             <artifactId>wildfly-ejb-interfaces</artifactId> |  | ||||||
|         </dependency> |  | ||||||
|     </dependencies> |  | ||||||
| 
 |  | ||||||
|     <build> |  | ||||||
|         <plugins> |  | ||||||
|             <plugin> |  | ||||||
|                 <artifactId>maven-ear-plugin</artifactId> |  | ||||||
|                 <version>${maven-ear-plugin.version}</version> |  | ||||||
|                 <configuration> |  | ||||||
|                     <defaultLibBundleDir>lib/</defaultLibBundleDir> |  | ||||||
|                     <version>${defaultLibBundleDir.version}</version> |  | ||||||
|                     <modules> |  | ||||||
|                         <webModule> |  | ||||||
|                             <groupId>com.baeldung.wildfly</groupId> |  | ||||||
|                             <artifactId>widlfly-web</artifactId> |  | ||||||
|                             <contextRoot>/wildfly</contextRoot> |  | ||||||
|                         </webModule> |  | ||||||
|                     </modules> |  | ||||||
|                 </configuration> |  | ||||||
|             </plugin> |  | ||||||
|             <plugin> |  | ||||||
|                 <groupId>org.wildfly.plugins</groupId> |  | ||||||
|                 <artifactId>wildfly-maven-plugin</artifactId> |  | ||||||
|                 <version>${wildfly-maven-plugin.version}</version> |  | ||||||
|             </plugin> |  | ||||||
|         </plugins> |  | ||||||
|     </build> |  | ||||||
| 
 |  | ||||||
|     <properties> |  | ||||||
|         <maven-ear-plugin.version>2.10.1</maven-ear-plugin.version> |  | ||||||
|         <wildfly-maven-plugin.version>1.2.0.Final</wildfly-maven-plugin.version> |  | ||||||
|         <defaultLibBundleDir.version>7</defaultLibBundleDir.version> |  | ||||||
|     </properties> |  | ||||||
| 
 |  | ||||||
| </project> |  | ||||||
| @ -1,35 +0,0 @@ | |||||||
| <?xml version="1.0" encoding="UTF-8"?> |  | ||||||
| <project xmlns="http://maven.apache.org/POM/4.0.0" |  | ||||||
|     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |  | ||||||
|     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |  | ||||||
|     <modelVersion>4.0.0</modelVersion> |  | ||||||
|     <artifactId>wildfly-ejb-interfaces</artifactId> |  | ||||||
|     <name>wildfly-ejb-interfaces</name> |  | ||||||
| 
 |  | ||||||
|     <parent> |  | ||||||
|         <groupId>com.baeldung.wildfly</groupId> |  | ||||||
|         <artifactId>wildfly</artifactId> |  | ||||||
|         <version>0.0.1-SNAPSHOT</version> |  | ||||||
|     </parent> |  | ||||||
| 
 |  | ||||||
|     <dependencies> |  | ||||||
|         <!-- Dependency for EJB javax --> |  | ||||||
|         <dependency> |  | ||||||
|             <groupId>javax.ejb</groupId> |  | ||||||
|             <artifactId>javax.ejb-api</artifactId> |  | ||||||
|             <version>${javax.ejb-api.version}</version> |  | ||||||
|             <scope>provided</scope> |  | ||||||
|         </dependency> |  | ||||||
|         <!-- Dependency for JPA module --> |  | ||||||
|         <dependency> |  | ||||||
|             <groupId>com.baeldung.wildfly</groupId> |  | ||||||
|             <artifactId>wildfly-jpa</artifactId> |  | ||||||
|             <version>${wildlfy.version}</version> |  | ||||||
|         </dependency> |  | ||||||
|     </dependencies> |  | ||||||
| 
 |  | ||||||
|     <properties> |  | ||||||
|         <javax.ejb-api.version>3.2</javax.ejb-api.version> |  | ||||||
|     </properties> |  | ||||||
| 
 |  | ||||||
| </project> |  | ||||||
| @ -1,13 +0,0 @@ | |||||||
| package wildfly.beans; |  | ||||||
| 
 |  | ||||||
| import java.util.List; |  | ||||||
| 
 |  | ||||||
| import javax.ejb.Local; |  | ||||||
| 
 |  | ||||||
| import model.User; |  | ||||||
| 
 |  | ||||||
| @Local |  | ||||||
| public interface UserBeanLocal { |  | ||||||
| 
 |  | ||||||
|     List<User> getUsers(); |  | ||||||
| } |  | ||||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user