From 949572f93b940213b616095df74729bfc740cb4f Mon Sep 17 00:00:00 2001 From: panos-kakos Date: Mon, 11 Sep 2023 12:23:34 +0300 Subject: [PATCH 01/12] [JAVA-24600] --- spring-boot-modules/spring-boot-jasypt/pom.xml | 8 -------- .../src/main/resources/application.yml | 6 +----- .../src/main/resources/application.properties | 1 - 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/spring-boot-modules/spring-boot-jasypt/pom.xml b/spring-boot-modules/spring-boot-jasypt/pom.xml index f48cd78595..d62a287e7b 100644 --- a/spring-boot-modules/spring-boot-jasypt/pom.xml +++ b/spring-boot-modules/spring-boot-jasypt/pom.xml @@ -46,14 +46,6 @@ - - - spring-milestone - Spring Milestone - https://repo.spring.io/milestone - - - 2.0.0 diff --git a/spring-cloud-modules/spring-cloud-task/springcloudtaskbatch/src/main/resources/application.yml b/spring-cloud-modules/spring-cloud-task/springcloudtaskbatch/src/main/resources/application.yml index 71275793ec..b7cd3e7726 100644 --- a/spring-cloud-modules/spring-cloud-task/springcloudtaskbatch/src/main/resources/application.yml +++ b/spring-cloud-modules/spring-cloud-task/springcloudtaskbatch/src/main/resources/application.yml @@ -19,8 +19,4 @@ spring: hibernate: dialect: org.hibernate.dialect.MySQL5Dialect batch: - initialize-schema: always -maven: - remoteRepositories: - springRepo: - url: https://repo.spring.io/libs-snapshot \ No newline at end of file + initialize-schema: always \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-task/springcloudtasksink/src/main/resources/application.properties b/spring-cloud-modules/spring-cloud-task/springcloudtasksink/src/main/resources/application.properties index 1660dc8516..e69de29bb2 100644 --- a/spring-cloud-modules/spring-cloud-task/springcloudtasksink/src/main/resources/application.properties +++ b/spring-cloud-modules/spring-cloud-task/springcloudtasksink/src/main/resources/application.properties @@ -1 +0,0 @@ -maven.remoteRepositories.springRepo.url=https://repo.spring.io/libs-snapshot \ No newline at end of file From 7b188517e3c9795a9250836472a14a50f36d522e Mon Sep 17 00:00:00 2001 From: parthiv39731 <70740707+parthiv39731@users.noreply.github.com> Date: Fri, 15 Sep 2023 09:20:34 -0700 Subject: [PATCH 02/12] BAEL-6726, Merge Two Arrays and Remove Duplicates in Java --- .../MergeArraysAndRemoveDuplicate.java | 96 +++++++++++++++++++ ...MergeArraysAndRemoveDuplicateUnitTest.java | 74 ++++++++++++++ 2 files changed, 170 insertions(+) create mode 100644 core-java-modules/core-java-arrays-guides/src/main/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicate.java create mode 100644 core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicateUnitTest.java diff --git a/core-java-modules/core-java-arrays-guides/src/main/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicate.java b/core-java-modules/core-java-arrays-guides/src/main/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicate.java new file mode 100644 index 0000000000..e0b249565f --- /dev/null +++ b/core-java-modules/core-java-arrays-guides/src/main/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicate.java @@ -0,0 +1,96 @@ +package com.baeldung.mergeandremoveduplicate; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Stream; + +public class MergeArraysAndRemoveDuplicate { + + public static int[] removeDuplicateOnSortedArray(int[] arr) { + // Initialize a new array to store unique elements + int[] uniqueArray = new int[arr.length]; + uniqueArray[0] = arr[0]; + int uniqueCount = 1; + + // Iterate through the sorted array to remove duplicates + for (int i = 1; i < arr.length; i++) { + if (arr[i] != arr[i - 1]) { + uniqueArray[uniqueCount] = arr[i]; + uniqueCount++; + } + } + int[] truncatedArray = new int[uniqueCount]; + System.arraycopy(uniqueArray, 0, truncatedArray, 0, uniqueCount); + return truncatedArray; + } + + public static int[] mergeAndRemoveDuplicatesUsingStream(int[] arr1, int[] arr2) { + Stream s1 = Arrays.stream(arr1).boxed(); + Stream s2 = Arrays.stream(arr2).boxed(); + return Stream.concat(s1, s2) + .distinct() + .mapToInt(Integer::intValue) + .toArray(); + } + + public static int[] mergeAndRemoveDuplicatesUsingSet(int[] arr1, int[] arr2) { + int[] mergedArr = mergeArrays(arr1, arr2); + Set uniqueInts = new HashSet<>(); + + for (int el : mergedArr) { + uniqueInts.add(el); + } + + return getArrayFromSet(uniqueInts); + } + + private static int[] getArrayFromSet(Set set) { + int[] mergedArrWithoutDuplicated = new int[set.size()]; + int i = 0; + for (Integer el: set) { + mergedArrWithoutDuplicated[i] = el; + i++; + } + return mergedArrWithoutDuplicated; + } + + public static int[] mergeAndRemoveDuplicates(int[] arr1, int[] arr2) { + return removeDuplicate(mergeArrays(arr1, arr2)); + } + + public static int[] mergeAndRemoveDuplicatesOnSortedArray(int[] arr1, int[] arr2) { + return removeDuplicateOnSortedArray(mergeArrays(arr1, arr2)); + } + + private static int[] mergeArrays(int[] arr1, int[] arr2) { + int[] mergedArrays = new int[arr1.length + arr2.length]; + System.arraycopy(arr1, 0, mergedArrays, 0, arr1.length); + System.arraycopy(arr2, 0, mergedArrays, arr1.length, arr2.length); + + return mergedArrays; + } + private static int[] removeDuplicate(int[] arr) { + int[] withoutDuplicates = new int[arr.length]; + int i = 0; + + for(int element : arr) { + if(!isElementPresent(withoutDuplicates, element)) { + withoutDuplicates[i] = element; + i++; + } + } + int[] truncatedArray = new int[i]; + System.arraycopy(withoutDuplicates, 0, truncatedArray, 0, i); + return truncatedArray; + } + + private static boolean isElementPresent(int[] arr, int element) { + for(int el : arr) { + if(el == element) { + return true; + } + } + return false; + } +} diff --git a/core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicateUnitTest.java b/core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicateUnitTest.java new file mode 100644 index 0000000000..ce8d69b445 --- /dev/null +++ b/core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicateUnitTest.java @@ -0,0 +1,74 @@ +package com.baeldung.mergeandremoveduplicate; + +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; + +public class MergeArraysAndRemoveDuplicateUnitTest { + + private final Logger logger = LoggerFactory.getLogger(MergeArraysAndRemoveDuplicateUnitTest.class); + + private static String getCommaDelimited(int[] arr) { + return Arrays.stream(arr) + .mapToObj(Integer::toString) + .collect(Collectors.joining(", ")); + } + + @Test + public void givenNoLibrary_whenArr1andArr2_thenMergeAndRemoveDuplicates() { + int[] arr1 = {3, 2, 1, 4, 5, 6, 8, 7, 9}; + int[] arr2 = {8, 9, 10, 11, 12, 13, 15, 14, 15, 14, 16, 17}; + int[] expectedArr = {3, 2, 1, 4, 5, 6, 8, 7, 9, 10, 11, 12, 13, 15, 14, 16, 17}; + + int[] mergedArr = MergeArraysAndRemoveDuplicate.mergeAndRemoveDuplicates(arr1, arr2); + + //merged array maintains the order of the elements in the arrays + assertArrayEquals(expectedArr, mergedArr); + + logger.info(getCommaDelimited(mergedArr)); + } + + @Test + public void givenNoLibrary_whenArr1andArr2_thenMergeSortAndRemoveDuplicates() { + int[] arr1 = {1, 2, 3, 4, 5, 5, 6, 7, 7, 8}; + int[] arr2 = {8, 9, 10, 11, 12, 13, 14, 15, 15, 16, 17}; + int[] expectedArr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + + int[] mergedArr = MergeArraysAndRemoveDuplicate.mergeAndRemoveDuplicatesOnSortedArray(arr1, arr2); + + assertArrayEquals(expectedArr, mergedArr); + + logger.info(getCommaDelimited(mergedArr)); + } + + @Test + public void givenSet_whenArr1andArr2_thenMergeAndRemoveDuplicates() { + int[] arr1 = {3, 2, 1, 4, 5, 6, 8, 7, 9}; + int[] arr2 = {8, 9, 10, 11, 12, 13, 15, 14, 15, 14, 16, 17}; + int[] expectedArr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + + int[] mergedArr = MergeArraysAndRemoveDuplicate.mergeAndRemoveDuplicatesUsingSet(arr1, arr2); + + assertArrayEquals(expectedArr, mergedArr); + + logger.info(getCommaDelimited(mergedArr)); + } + + @Test + public void givenStream_whenArr1andArr2_thenMergeAndRemoveDuplicates() { + int[] arr1 = {3, 2, 1, 4, 5, 6, 8, 7, 9}; + int[] arr2 = {8, 9, 10, 11, 12, 13, 15, 14, 15, 14, 16, 17}; + int[] expectedArr = {3, 2, 1, 4, 5, 6, 8, 7, 9, 10, 11, 12, 13, 15, 14, 16, 17}; + + int[] mergedArr = MergeArraysAndRemoveDuplicate.mergeAndRemoveDuplicatesUsingStream(arr1, arr2); + + assertArrayEquals(expectedArr, mergedArr); + + logger.info(getCommaDelimited(mergedArr)); + } +} From 2d4d7308ad2b218f2f6fc9dcaa81e6340dd34925 Mon Sep 17 00:00:00 2001 From: parthiv39731 <70740707+parthiv39731@users.noreply.github.com> Date: Fri, 15 Sep 2023 21:26:37 -0700 Subject: [PATCH 03/12] BAEL-6726, modified method names --- .../MergeArraysAndRemoveDuplicateUnitTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicateUnitTest.java b/core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicateUnitTest.java index ce8d69b445..5076ef8159 100644 --- a/core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicateUnitTest.java +++ b/core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicateUnitTest.java @@ -20,7 +20,7 @@ public class MergeArraysAndRemoveDuplicateUnitTest { } @Test - public void givenNoLibrary_whenArr1andArr2_thenMergeAndRemoveDuplicates() { + public void givenNoLibraryAndUnSortedArrays_whenArr1andArr2_thenMergeAndRemoveDuplicates() { int[] arr1 = {3, 2, 1, 4, 5, 6, 8, 7, 9}; int[] arr2 = {8, 9, 10, 11, 12, 13, 15, 14, 15, 14, 16, 17}; int[] expectedArr = {3, 2, 1, 4, 5, 6, 8, 7, 9, 10, 11, 12, 13, 15, 14, 16, 17}; @@ -34,7 +34,7 @@ public class MergeArraysAndRemoveDuplicateUnitTest { } @Test - public void givenNoLibrary_whenArr1andArr2_thenMergeSortAndRemoveDuplicates() { + public void givenNoLibraryAndSortedArrays_whenArr1andArr2_thenMergeAndRemoveDuplicates() { int[] arr1 = {1, 2, 3, 4, 5, 5, 6, 7, 7, 8}; int[] arr2 = {8, 9, 10, 11, 12, 13, 14, 15, 15, 16, 17}; int[] expectedArr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; From 808502520e57bbf87ae639da04a164f85cb9bc5c Mon Sep 17 00:00:00 2001 From: panos-kakos Date: Tue, 19 Sep 2023 12:11:51 +0300 Subject: [PATCH 04/12] [JAVA-24600] Upgraded jasypt version to 3.0.5 --- spring-boot-modules/spring-boot-jasypt/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-modules/spring-boot-jasypt/pom.xml b/spring-boot-modules/spring-boot-jasypt/pom.xml index d62a287e7b..70bbe35319 100644 --- a/spring-boot-modules/spring-boot-jasypt/pom.xml +++ b/spring-boot-modules/spring-boot-jasypt/pom.xml @@ -27,7 +27,7 @@ com.github.ulisesbocchio - jasypt-spring-boot-starter + jasypt-spring-boot-starter ${jasypt.version} @@ -47,6 +47,6 @@ - 2.0.0 + 3.0.5 \ No newline at end of file From 030f308c5b922f5f3f7ed3b6508fa03a9e6a6c20 Mon Sep 17 00:00:00 2001 From: rajatgarg Date: Wed, 20 Sep 2023 00:36:33 +0530 Subject: [PATCH 05/12] Use ContentType to fetch the extensions --- .../baeldung/extension/ExtensionFromMimeTypeUnitTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core-java-modules/core-java-io/src/test/java/com/baeldung/extension/ExtensionFromMimeTypeUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/extension/ExtensionFromMimeTypeUnitTest.java index f8f42861cc..2238cfcafa 100644 --- a/core-java-modules/core-java-io/src/test/java/com/baeldung/extension/ExtensionFromMimeTypeUnitTest.java +++ b/core-java-modules/core-java-io/src/test/java/com/baeldung/extension/ExtensionFromMimeTypeUnitTest.java @@ -14,7 +14,7 @@ import org.apache.tika.mime.MimeTypeException; import org.junit.Test; -import com.j256.simplemagic.ContentInfo; +import com.j256.simplemagic.ContentType; public class ExtensionFromMimeTypeUnitTest { private static final String IMAGE_JPEG_MIME_TYPE = "image/jpeg"; @@ -39,8 +39,7 @@ public class ExtensionFromMimeTypeUnitTest { @Test public void whenUsingMimetypesFileTypeMap_thenGetFileExtension() { List expectedExtensions = Arrays.asList("jpeg", "jpg", "jpe"); - ContentInfo contentInfo = new ContentInfo("", IMAGE_JPEG_MIME_TYPE, "", true); - String[] detectedExtensions = contentInfo.getFileExtensions(); + String[] detectedExtensions = ContentType.fromMimeType(IMAGE_JPEG_MIME_TYPE).getFileExtensions(); assertThat(detectedExtensions).containsExactlyElementsOf(expectedExtensions); } From 52d10c1c4a3c59c33e8107a4ad3b9b6fef58b342 Mon Sep 17 00:00:00 2001 From: Alexander Molochko Date: Tue, 19 Sep 2023 21:19:31 -0600 Subject: [PATCH 06/12] BAEL-6866: Securing Spring Boot 3 Applications with SSL Bundles (#14725) * BAEL-6866: Securing Spring Boot 3 Applications with SSL Bundles * [bael-6866] Fix review issues --- .../spring-boot-ssl-bundles/README.md | 1 + .../spring-boot-ssl-bundles/pom.xml | 56 ++++++++++++++++++ .../springbootsslbundles/SSLBundlesApp.java | 19 ++++++ .../SecureRestTemplateConfig.java | 38 ++++++++++++ .../SecureServiceRestApi.java | 28 +++++++++ .../src/main/resources/application.yml | 11 ++++ .../src/main/resources/cert.pem | 31 ++++++++++ .../src/main/resources/key.pem | 54 +++++++++++++++++ .../src/main/resources/keystore.p12 | Bin 0 -> 4242 bytes .../src/main/resources/static/index.html | 13 ++++ .../SSLBundleApplicationTests.java | 12 ++++ 11 files changed, 263 insertions(+) create mode 100644 spring-boot-modules/spring-boot-ssl-bundles/README.md create mode 100644 spring-boot-modules/spring-boot-ssl-bundles/pom.xml create mode 100644 spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SSLBundlesApp.java create mode 100644 spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SecureRestTemplateConfig.java create mode 100644 spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SecureServiceRestApi.java create mode 100644 spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/application.yml create mode 100644 spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/cert.pem create mode 100644 spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/key.pem create mode 100644 spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/keystore.p12 create mode 100644 spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/static/index.html create mode 100644 spring-boot-modules/spring-boot-ssl-bundles/src/test/java/com/baeldung/springbootsslbundles/SSLBundleApplicationTests.java diff --git a/spring-boot-modules/spring-boot-ssl-bundles/README.md b/spring-boot-modules/spring-boot-ssl-bundles/README.md new file mode 100644 index 0000000000..5616cce48b --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/README.md @@ -0,0 +1 @@ +## Relevant Articles diff --git a/spring-boot-modules/spring-boot-ssl-bundles/pom.xml b/spring-boot-modules/spring-boot-ssl-bundles/pom.xml new file mode 100644 index 0000000000..056d0308c2 --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.1.3 + + + springbootsslbundles + spring-boot-ssl-bundles + jar + Module for showing usage of SSL Bundles + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.security + spring-security-test + test + + + org.apache.httpcomponents.client5 + httpclient5-fluent + ${apache.client5.version} + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + 5.0.3 + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SSLBundlesApp.java b/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SSLBundlesApp.java new file mode 100644 index 0000000000..f6cfb35d1e --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SSLBundlesApp.java @@ -0,0 +1,19 @@ +package com.baeldung.springbootsslbundles; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.web.client.RestTemplate; +import org.springframework.boot.ssl.SslBundles; + +@SpringBootApplication +public class SSLBundlesApp { + public static void main(String[] args) { + SpringApplication.run(SSLBundlesApp.class, args); + } + @Bean + public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder, SslBundles sslBundles) { + return restTemplateBuilder.setSslBundle(sslBundles.getBundle("secure-service")).build(); + } +} diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SecureRestTemplateConfig.java b/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SecureRestTemplateConfig.java new file mode 100644 index 0000000000..48eda219dd --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SecureRestTemplateConfig.java @@ -0,0 +1,38 @@ +package com.baeldung.springbootsslbundles; + +import org.apache.hc.client5.http.classic.HttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.client5.http.io.HttpClientConnectionManager; +import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; +import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ssl.NoSuchSslBundleException; +import org.springframework.boot.ssl.SslBundle; +import org.springframework.boot.ssl.SslBundles; +import org.springframework.context.annotation.Bean; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +import javax.net.ssl.SSLContext; + +@Component +public class SecureRestTemplateConfig { + private final SSLContext sslContext; + + @Autowired + public SecureRestTemplateConfig(SslBundles sslBundles) throws NoSuchSslBundleException { + SslBundle sslBundle = sslBundles.getBundle("secure-service"); + this.sslContext = sslBundle.createSslContext(); + } + + @Bean + public RestTemplate secureRestTemplate() { + final SSLConnectionSocketFactory sslSocketFactory = SSLConnectionSocketFactoryBuilder.create().setSslContext(this.sslContext).build(); + final HttpClientConnectionManager cm = PoolingHttpClientConnectionManagerBuilder.create().setSSLSocketFactory(sslSocketFactory).build(); + HttpClient httpClient = HttpClients.custom().setConnectionManager(cm).evictExpiredConnections().build(); + HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient); + return new RestTemplate(factory); + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SecureServiceRestApi.java b/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SecureServiceRestApi.java new file mode 100644 index 0000000000..3ed919b957 --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SecureServiceRestApi.java @@ -0,0 +1,28 @@ +package com.baeldung.springbootsslbundles; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +@Service +public class SecureServiceRestApi { + private final RestTemplate restTemplate; + + @Autowired + public SecureServiceRestApi(RestTemplate restTemplate) { + this.restTemplate = restTemplate; + } + + public String fetchData(String dataId) { + ResponseEntity response = restTemplate.exchange( + "https://secure-service.com/api/data/{id}", + HttpMethod.GET, + null, + String.class, + dataId + ); + return response.getBody(); + } +} diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/application.yml b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/application.yml new file mode 100644 index 0000000000..1598645805 --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/application.yml @@ -0,0 +1,11 @@ +spring: + ssl: + bundle: + jks: + secure-service: + key: + alias: "secure-service" + keystore: + location: "classpath:keystore.p12" + password: "FooBar" + type: "PKCS12" \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/cert.pem b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/cert.pem new file mode 100644 index 0000000000..82ed122a80 --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/cert.pem @@ -0,0 +1,31 @@ +-----BEGIN CERTIFICATE----- +MIIFazCCA1OgAwIBAgIUCJcVMwyhLy/ln+ENMXbSWcsO0aswDQYJKoZIhvcNAQEL +BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM +GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMzA5MDUxNjAyMzdaFw0yNDA5 +MDQxNjAyMzdaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw +HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggIiMA0GCSqGSIb3DQEB +AQUAA4ICDwAwggI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I7VMLYqNnX2+tnvszO +HvWtIqm6foyReDLfC0n87cuEBV7/9304V5vgEj20TR19isd0LffJDD1ujDXvN8dS +uGOB1VLRxAPonr9Iqk358EJ1T22uEcMdKE+sMnCBjw2fYIYRfjhGN+m6U6sb4MrF +zFUI6qB7W7T/5iukiRb4pLQ0OGgKOwYxpZoxcB3Ldjo5x58uKNOTNJ5zEJ8HUofA +BNfty10D3m3DlSyYbf7m1UUM0jj2l83LBGQzhGGUZgCnCsMczLrj64Gvf2iLGmCF +gu5zrxL01dptBkvTsYJwYBA67BBS4FcgYNMGx3m1uPsVUUIguJxufXWYfbub74QV +a1SH1NjO8HR3DLDU+S92tyTKWOUzJ5qOegEsR2cutVRzDuVTsFy7kayuNv/uLRrG +3P2HnUo8PG/nmysReBk6CGycUiDTt55DoPYGoQ5l19xTlkIt7ulNg7yX5pwFMeE= +-----END CERTIFICATE----- diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/key.pem b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/key.pem new file mode 100644 index 0000000000..b4202e9a8e --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/key.pem @@ -0,0 +1,54 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIJpDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIblni8xi+83QCAggA +MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECJSRFMcxzIKiBIIJUEqyZcVQEBL1 +6jkeo5TGxVwolLnCNpEuj8UwLoK5Z2N5oVwSPzD5rMYuPg6OXXWk6zReaaKBkRR2 +vlpkckA4o+aSXfzvEXYGd+rZ3EeIK43zquIBjymlcN++FbEYOtAY1SoQm7FtyvdN +4QW7MOONUJcnN3EgRSRic2CCa0k6NSREfrBWaa+OcYB4C/JEuA2xgkCUw8bCcos6 +mksoF6mZDQearirNankMDR7gLQt9pdK7S55T4sCrFpL072s3k7lV0WtvTE/CQ8Wu +pdBKV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jk7dZ+Hmy60zPjgYkHyvOdZRUKfIhZrpCM5Al/xKUqhR6rPtr2U7lkHw9zT +gsK6rxXfvmJjIzSFBQzBah8K9rYzk/DScXMQ+3XY7fu6r2LTnfWxCKYhX/2eEoXW +/+t0HsRNoGCLB9g8sDAt2tDbjOsGRIdtfQ28Q56Pi91+IlGE5/n4iJ/bws5F1MXB +amG44iYYNPHUnkr3YsQeCiyh/1GgiLbIi3P6ZVJ5vG1a5oPGNolsABMZ5HZzd/aD +LgZDFjIMDzL5WaP2xhfnTjQsaowpulLE0/7mrc5KnfKxwdlDmLGjLIRsa5fXbL6W +rqezhAkgRrGRhnljMnCgZGpkHMtZN3S0u78/u17FvtlbyDFOev1y9cpvMmp/RAP3 +OXp7Wo3JELz/7aMkmVt6a++j9hxuX0vas6PPCoM0PGlTdWxPo2y96fFuW41j59vh +XY54kI5sBFibuvxLJOr9lXw8EuXJTNiyKuoEoXu2QKNHYSOZi1OPzrJRsKxEwNBh +8TP1G99H/gdlYEI/CPYOGbhWMq1qZyukDHjQaOMdzRIRYawx4GbQE1HeGla5bFSy +n0Gki5ApqQk8b6muUxDXBgPdQKFL6o7KYhAg+8JsGvnByh7qVZl2kmwxjx2bJIcj +o7BBRSYLSWdW3cguXojtgoN2NcFZZON4IEDSBuu/1ESgi2a2W5T9NClK/3ZagPmJ +hX2T2qTTkVjWQ+xM15SD46s4s+5nZX2kGE1DHwtYSKgdHYR9n81po7CuEqVP1n/G +7NNrMLXj3PGrZ2vzKDGSAU1LzLOUrJ4m +-----END ENCRYPTED PRIVATE KEY----- diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/keystore.p12 b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/keystore.p12 new file mode 100644 index 0000000000000000000000000000000000000000..f58b35546780aa7e7abf00d71dda9a327513076d GIT binary patch literal 4242 zcmY+GcQ_mVx5tBsJ!;d~dz9F-R%z@asI913d(>XBw^A#W8dViam9|LKrnN_{8dXA3 z#42L{`n}J+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4ozY;8x9uwTMr_uM zc5Ny~(TQtOd=ezNtijUeAwTrTC|ApQGW7mvsWdik2|^A_@7)>lmnD3$ZdaZV5nmy1 zaci1kp8K+1jg)R8X41{y13?-dbW%6 zR@Uz-yIr_Bq+~K9X$s-}-z$xbQIZMBU}L?fr!ZDHQ)f||URdY1GAEb!0V4Wu6N4lN z2N)0tZ~-_2f&l@4>z)7l1puA`JpM8lh$Ms?LIxrhr6wX|BL)B&)J+so`AEe%K{D`; Z`piIM31#vSkTfwI5tNV+;rP#K_a7xu_sswR literal 0 HcmV?d00001 diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/static/index.html b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/static/index.html new file mode 100644 index 0000000000..117910cc89 --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/static/index.html @@ -0,0 +1,13 @@ + + + + + Spring SSL Bundler Demo Application + + +

Spring SSL Bundler Demo Application

+

+ This is a sample application that can be built as native executable. +

+ + diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/test/java/com/baeldung/springbootsslbundles/SSLBundleApplicationTests.java b/spring-boot-modules/spring-boot-ssl-bundles/src/test/java/com/baeldung/springbootsslbundles/SSLBundleApplicationTests.java new file mode 100644 index 0000000000..876641c8b5 --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/src/test/java/com/baeldung/springbootsslbundles/SSLBundleApplicationTests.java @@ -0,0 +1,12 @@ +package com.baeldung.springbootsslbundles; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class SSLBundleApplicationTests { + @Test + void contextLoads() { + + } +} From 1f9bcc7ef1512e96c761ed425a9403ef71d29a39 Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Wed, 20 Sep 2023 22:28:18 +0530 Subject: [PATCH 07/12] JAVA-20438 Create new spring-data-couchbase module (#14745) --- spring-reactive-modules/pom.xml | 1 + .../spring-5-data-reactive/README.md | 3 +- .../spring-5-data-reactive/pom.xml | 92 ----------- .../R2dbcApplicationIntegrationTest.java | 7 +- .../spring-data-couchbase/README.md | 9 ++ .../spring-data-couchbase/pom.xml | 146 ++++++++++++++++++ .../ReactiveCouchbaseApplication.java | 0 .../configuration/CouchbaseProperties.java | 0 .../N1QLReactiveCouchbaseConfiguration.java | 0 .../ReactiveCouchbaseConfiguration.java | 0 .../ViewReactiveCouchbaseConfiguration.java | 0 .../com/baeldung/couchbase/domain/Person.java | 0 .../repository/n1ql/N1QLPersonRepository.java | 0 .../n1ql/N1QLSortingPersonRepository.java | 0 .../repository/view/ViewPersonRepository.java | 0 .../src/main/resources/couchbase.properties | 0 .../src/main/resources/logback.xml | 13 ++ .../CouchbaseMockConfiguration.java | 0 .../n1ql/N1QLPersonRepositoryLiveTest.java | 0 .../N1QLSortingPersonRepositoryLiveTest.java | 0 .../ViewPersonRepositoryIntegrationTest.java | 0 21 files changed, 174 insertions(+), 97 deletions(-) create mode 100644 spring-reactive-modules/spring-data-couchbase/README.md create mode 100644 spring-reactive-modules/spring-data-couchbase/pom.xml rename spring-reactive-modules/{spring-5-data-reactive => spring-data-couchbase}/src/main/java/com/baeldung/couchbase/ReactiveCouchbaseApplication.java (100%) rename spring-reactive-modules/{spring-5-data-reactive => spring-data-couchbase}/src/main/java/com/baeldung/couchbase/configuration/CouchbaseProperties.java (100%) rename spring-reactive-modules/{spring-5-data-reactive => spring-data-couchbase}/src/main/java/com/baeldung/couchbase/configuration/N1QLReactiveCouchbaseConfiguration.java (100%) rename spring-reactive-modules/{spring-5-data-reactive => spring-data-couchbase}/src/main/java/com/baeldung/couchbase/configuration/ReactiveCouchbaseConfiguration.java (100%) rename spring-reactive-modules/{spring-5-data-reactive => spring-data-couchbase}/src/main/java/com/baeldung/couchbase/configuration/ViewReactiveCouchbaseConfiguration.java (100%) rename spring-reactive-modules/{spring-5-data-reactive => spring-data-couchbase}/src/main/java/com/baeldung/couchbase/domain/Person.java (100%) rename spring-reactive-modules/{spring-5-data-reactive => spring-data-couchbase}/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepository.java (100%) rename spring-reactive-modules/{spring-5-data-reactive => spring-data-couchbase}/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepository.java (100%) rename spring-reactive-modules/{spring-5-data-reactive => spring-data-couchbase}/src/main/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepository.java (100%) rename spring-reactive-modules/{spring-5-data-reactive => spring-data-couchbase}/src/main/resources/couchbase.properties (100%) create mode 100644 spring-reactive-modules/spring-data-couchbase/src/main/resources/logback.xml rename spring-reactive-modules/{spring-5-data-reactive => spring-data-couchbase}/src/test/java/com/baeldung/couchbase/domain/repository/CouchbaseMockConfiguration.java (100%) rename spring-reactive-modules/{spring-5-data-reactive => spring-data-couchbase}/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepositoryLiveTest.java (100%) rename spring-reactive-modules/{spring-5-data-reactive => spring-data-couchbase}/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepositoryLiveTest.java (100%) rename spring-reactive-modules/{spring-5-data-reactive => spring-data-couchbase}/src/test/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepositoryIntegrationTest.java (100%) diff --git a/spring-reactive-modules/pom.xml b/spring-reactive-modules/pom.xml index e75682da78..309687f011 100644 --- a/spring-reactive-modules/pom.xml +++ b/spring-reactive-modules/pom.xml @@ -27,6 +27,7 @@ spring-5-reactive-filters spring-5-reactive-oauth spring-5-reactive-security + spring-data-couchbase spring-reactive spring-reactive-exceptions spring-reactor diff --git a/spring-reactive-modules/spring-5-data-reactive/README.md b/spring-reactive-modules/spring-5-data-reactive/README.md index ecb6d01267..3522d9681b 100644 --- a/spring-reactive-modules/spring-5-data-reactive/README.md +++ b/spring-reactive-modules/spring-5-data-reactive/README.md @@ -6,5 +6,4 @@ This module contains articles about reactive Spring 5 Data The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles -- [A Quick Look at R2DBC with Spring Data](https://www.baeldung.com/spring-data-r2dbc) -- [Spring Data Reactive Repositories with Couchbase](https://www.baeldung.com/spring-data-reactive-couchbase) +- [A Quick Look at R2DBC with Spring Data](https://www.baeldung.com/spring-data-r2dbc) \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-data-reactive/pom.xml b/spring-reactive-modules/spring-5-data-reactive/pom.xml index e4d3aeeddd..dc4a5b9bd1 100644 --- a/spring-reactive-modules/spring-5-data-reactive/pom.xml +++ b/spring-reactive-modules/spring-5-data-reactive/pom.xml @@ -26,15 +26,6 @@ - - io.projectreactor - reactor-core - ${reactor-core.version} - - - org.springframework.boot - spring-boot-starter-data-couchbase-reactive - org.springframework.boot spring-boot-starter-web @@ -42,21 +33,12 @@ org.projectlombok lombok - ${lombok.version} io.projectreactor reactor-test test - - io.reactivex.rxjava2 - rxjava - - - org.springframework - spring-test - org.springframework.boot spring-boot-starter-test @@ -66,101 +48,27 @@ org.springframework.boot spring-boot-starter-webflux - - org.springframework - spring-tx - ${spring-tx.version} - org.springframework.data spring-data-r2dbc - ${spring-data-r2dbc.version} io.r2dbc r2dbc-h2 - ${r2dbc-h2.version} - - - com.h2database - h2 - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - - - com.couchbase.mock - CouchbaseMock - ${couchbaseMock.version} - test - - org.apache.maven.plugins - maven-surefire-plugin - - - --add-opens java.base/java.util=ALL-UNNAMED - - - org.springframework.boot spring-boot-maven-plugin - - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - - - - - default-compile - none - - - - default-testCompile - none - - - java-compile - compile - - compile - - - - java-test-compile - test-compile - - testCompile - - - - - 5.2.2.RELEASE - 1.0.0.RELEASE - 0.8.1.RELEASE - 4.5.2 - 1.5.23 - 3.3.1.RELEASE - - 2.2.6.RELEASE 2.17.1 - 1.18.26 \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java b/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java index 1af570587e..b5e859ae2f 100644 --- a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java +++ b/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java @@ -1,6 +1,7 @@ package com.baeldung.r2dbc; +import com.baeldung.r2dbc.configuration.R2DBCConfiguration; import com.baeldung.r2dbc.model.Player; import com.baeldung.r2dbc.repository.PlayerRepository; import io.r2dbc.h2.H2ConnectionFactory; @@ -9,7 +10,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.r2dbc.core.DatabaseClient; +import org.springframework.r2dbc.core.DatabaseClient; import org.springframework.test.context.junit4.SpringRunner; import reactor.core.publisher.Flux; import reactor.core.publisher.Hooks; @@ -20,7 +21,7 @@ import java.util.Arrays; import java.util.List; @RunWith(SpringRunner.class) -@SpringBootTest +@SpringBootTest(classes = R2DBCConfiguration.class) public class R2dbcApplicationIntegrationTest { @@ -43,7 +44,7 @@ public class R2dbcApplicationIntegrationTest { "DROP TABLE IF EXISTS player;", "CREATE table player (id INT AUTO_INCREMENT NOT NULL, name VARCHAR2, age INT NOT NULL);"); - statements.forEach(it -> client.execute(it) // + statements.forEach(it -> client.sql(it) // .fetch() // .rowsUpdated() // .as(StepVerifier::create) // diff --git a/spring-reactive-modules/spring-data-couchbase/README.md b/spring-reactive-modules/spring-data-couchbase/README.md new file mode 100644 index 0000000000..e38ef10562 --- /dev/null +++ b/spring-reactive-modules/spring-data-couchbase/README.md @@ -0,0 +1,9 @@ +## Spring Data Reactive Project + +This module contains articles about reactive Spring Data Couchbase + +### The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring + +### Relevant Articles +- [Spring Data Reactive Repositories with Couchbase](https://www.baeldung.com/spring-data-reactive-couchbase) diff --git a/spring-reactive-modules/spring-data-couchbase/pom.xml b/spring-reactive-modules/spring-data-couchbase/pom.xml new file mode 100644 index 0000000000..68ddd1cefa --- /dev/null +++ b/spring-reactive-modules/spring-data-couchbase/pom.xml @@ -0,0 +1,146 @@ + + + 4.0.0 + spring-data-couchbase + spring-data-couchbase + jar + + + com.baeldung.spring.reactive + spring-reactive-modules + 1.0.0-SNAPSHOT + + + + + + org.apache.logging.log4j + log4j-bom + ${log4j2.version} + import + pom + + + + + + + io.projectreactor + reactor-core + ${reactor-core.version} + + + org.springframework.boot + spring-boot-starter-data-couchbase-reactive + + + org.springframework.boot + spring-boot-starter-web + + + org.projectlombok + lombok + ${lombok.version} + + + io.projectreactor + reactor-test + test + + + io.reactivex.rxjava2 + rxjava + + + org.springframework + spring-test + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework + spring-tx + ${spring-tx.version} + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + com.couchbase.mock + CouchbaseMock + ${couchbaseMock.version} + test + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + --add-opens java.base/java.util=ALL-UNNAMED + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + + + + + default-compile + none + + + + default-testCompile + none + + + java-compile + compile + + compile + + + + java-test-compile + test-compile + + testCompile + + + + + + + + + 5.2.2.RELEASE + 4.5.2 + 1.5.23 + 3.3.1.RELEASE + + 2.2.6.RELEASE + 2.17.1 + 1.18.26 + + + \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/ReactiveCouchbaseApplication.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/ReactiveCouchbaseApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/ReactiveCouchbaseApplication.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/ReactiveCouchbaseApplication.java diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/CouchbaseProperties.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/CouchbaseProperties.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/CouchbaseProperties.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/CouchbaseProperties.java diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/N1QLReactiveCouchbaseConfiguration.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/N1QLReactiveCouchbaseConfiguration.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/N1QLReactiveCouchbaseConfiguration.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/N1QLReactiveCouchbaseConfiguration.java diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/ReactiveCouchbaseConfiguration.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/ReactiveCouchbaseConfiguration.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/ReactiveCouchbaseConfiguration.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/ReactiveCouchbaseConfiguration.java diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/ViewReactiveCouchbaseConfiguration.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/ViewReactiveCouchbaseConfiguration.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/ViewReactiveCouchbaseConfiguration.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/ViewReactiveCouchbaseConfiguration.java diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/Person.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/Person.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/Person.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/Person.java diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepository.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepository.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepository.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepository.java diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepository.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepository.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepository.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepository.java diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepository.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepository.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepository.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepository.java diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/resources/couchbase.properties b/spring-reactive-modules/spring-data-couchbase/src/main/resources/couchbase.properties similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/main/resources/couchbase.properties rename to spring-reactive-modules/spring-data-couchbase/src/main/resources/couchbase.properties diff --git a/spring-reactive-modules/spring-data-couchbase/src/main/resources/logback.xml b/spring-reactive-modules/spring-data-couchbase/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/spring-reactive-modules/spring-data-couchbase/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/CouchbaseMockConfiguration.java b/spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/CouchbaseMockConfiguration.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/CouchbaseMockConfiguration.java rename to spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/CouchbaseMockConfiguration.java diff --git a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepositoryLiveTest.java b/spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepositoryLiveTest.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepositoryLiveTest.java rename to spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepositoryLiveTest.java diff --git a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepositoryLiveTest.java b/spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepositoryLiveTest.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepositoryLiveTest.java rename to spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepositoryLiveTest.java diff --git a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepositoryIntegrationTest.java b/spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepositoryIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepositoryIntegrationTest.java rename to spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepositoryIntegrationTest.java From 914d01d03dd5671218bdb8d0e4a502307b0fcf77 Mon Sep 17 00:00:00 2001 From: Kasra Madadipouya Date: Thu, 21 Sep 2023 05:58:33 +0200 Subject: [PATCH 08/12] JAVA-25341 fix Java networking flaky tests (#14798) --- .../src/test/java/com/baeldung/socket/EchoIntegrationTest.java | 2 +- .../java/com/baeldung/socket/GreetServerIntegrationTest.java | 2 +- .../com/baeldung/socket/SocketEchoMultiIntegrationTest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/EchoIntegrationTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/EchoIntegrationTest.java index 103824b6aa..1e85b9d6dd 100644 --- a/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/EchoIntegrationTest.java +++ b/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/EchoIntegrationTest.java @@ -24,7 +24,7 @@ public class EchoIntegrationTest { Executors.newSingleThreadExecutor() .submit(() -> new EchoServer().start(port)); - Thread.sleep(500); + Thread.sleep(2000); } private EchoClient client = new EchoClient(); diff --git a/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java index 2bded156c5..09f20c970d 100644 --- a/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java +++ b/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java @@ -27,7 +27,7 @@ public class GreetServerIntegrationTest { Executors.newSingleThreadExecutor() .submit(() -> new GreetServer().start(port)); - Thread.sleep(500); + Thread.sleep(2000); } @Before diff --git a/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java index 62e2dd44ae..f08542c1aa 100644 --- a/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java +++ b/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java @@ -23,7 +23,7 @@ public class SocketEchoMultiIntegrationTest { s.close(); Executors.newSingleThreadExecutor().submit(() -> new EchoMultiServer().start(port)); - Thread.sleep(500); + Thread.sleep(2000); } @Test From e842b87ec53cc8e391de030e7b043c68e5168f68 Mon Sep 17 00:00:00 2001 From: Bipin kumar Date: Thu, 21 Sep 2023 15:22:42 +0530 Subject: [PATCH 09/12] =?UTF-8?q?JAVA-23380:=20Changes=20made=20for=20upgr?= =?UTF-8?q?ading=20sprint-boot-autoconfiguration=20=E2=80=A6=20(#14769)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spring-boot-autoconfiguration/pom.xml | 14 +++++++++++--- .../autoconfiguration/MySQLAutoconfiguration.java | 7 ++++--- .../annotationprocessor/DatabaseProperties.java | 6 ++++-- .../baeldung/autoconfiguration/example/MyUser.java | 4 ++-- .../src/main/resources/META-INF/spring.factories | 1 - ...rk.boot.autoconfigure.AutoConfiguration.imports | 1 + .../src/main/resources/mysql.properties | 2 +- 7 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports diff --git a/spring-boot-modules/spring-boot-autoconfiguration/pom.xml b/spring-boot-modules/spring-boot-autoconfiguration/pom.xml index 7a3f9f01e8..7880a033f8 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/pom.xml +++ b/spring-boot-modules/spring-boot-autoconfiguration/pom.xml @@ -10,9 +10,10 @@ This is simple boot application demonstrating a custom auto-configuration - com.baeldung.spring-boot-modules - spring-boot-modules - 1.0.0-SNAPSHOT + com.baeldung + parent-boot-3 + 0.0.1-SNAPSHOT + ../../parent-boot-3 @@ -66,6 +67,13 @@ org.apache.maven.plugins maven-war-plugin + + org.springframework.boot + spring-boot-maven-plugin + + com.baeldung.autoconfiguration.example.AutoconfigurationApplication + + diff --git a/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/MySQLAutoconfiguration.java b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/MySQLAutoconfiguration.java index 295e0d74c9..c470656597 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/MySQLAutoconfiguration.java +++ b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/MySQLAutoconfiguration.java @@ -3,10 +3,10 @@ package com.baeldung.autoconfiguration; import java.util.Arrays; import java.util.Properties; -import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureOrder; import org.springframework.boot.autoconfigure.condition.ConditionMessage; import org.springframework.boot.autoconfigure.condition.ConditionMessage.Style; @@ -20,7 +20,6 @@ import org.springframework.boot.autoconfigure.condition.SpringBootCondition; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; -import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.core.Ordered; import org.springframework.core.env.Environment; @@ -31,7 +30,9 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.util.ClassUtils; -@Configuration +import jakarta.persistence.EntityManagerFactory; + +@AutoConfiguration @ConditionalOnClass(DataSource.class) @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) @PropertySource("classpath:mysql.properties") diff --git a/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/annotationprocessor/DatabaseProperties.java b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/annotationprocessor/DatabaseProperties.java index 4fb5b408a2..47f07c808f 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/annotationprocessor/DatabaseProperties.java +++ b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/annotationprocessor/DatabaseProperties.java @@ -1,11 +1,13 @@ package com.baeldung.autoconfiguration.annotationprocessor; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; + import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; + @Configuration @ConfigurationProperties(prefix = "database") public class DatabaseProperties { diff --git a/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/MyUser.java b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/MyUser.java index 31ce0fd969..26a2e04e2f 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/MyUser.java +++ b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/MyUser.java @@ -1,7 +1,7 @@ package com.baeldung.autoconfiguration.example; -import javax.persistence.Entity; -import javax.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; @Entity public class MyUser { diff --git a/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring.factories b/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring.factories index 11c775fc6c..e69de29bb2 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring.factories +++ b/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring.factories @@ -1 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.baeldung.autoconfiguration.MySQLAutoconfiguration diff --git a/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000000..ab28361814 --- /dev/null +++ b/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.baeldung.autoconfiguration.MySQLAutoconfiguration diff --git a/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/mysql.properties b/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/mysql.properties index 74f1ee1373..27092f852f 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/mysql.properties +++ b/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/mysql.properties @@ -1,5 +1,5 @@ usemysql=local -mysql-hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +mysql-hibernate.dialect=org.hibernate.dialect.MySQLDialect mysql-hibernate.show_sql=true mysql-hibernate.hbm2ddl.auto=create-drop \ No newline at end of file From 7af1c7917f06688eb47d70d42062327c9527ca8b Mon Sep 17 00:00:00 2001 From: Bhaskar Ghosh Dastidar Date: Thu, 21 Sep 2023 21:53:10 +0530 Subject: [PATCH 10/12] BAEL-6823-middle-element-array (#14774) Co-authored-by: Bhaskar --- .../pom.xml | 46 +++++++++++++++++++ .../baeldung/arraymiddle/MiddleOfArray.java | 2 +- .../arraymiddle/MiddleOfArrayUnitTest.java | 2 +- core-java-modules/pom.xml | 1 + 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 core-java-modules/core-java-arrays-operations-advanced-2/pom.xml rename core-java-modules/{core-java-arrays-operations-advanced => core-java-arrays-operations-advanced-2}/src/main/java/com/baeldung/arraymiddle/MiddleOfArray.java (99%) rename core-java-modules/{core-java-arrays-operations-advanced => core-java-arrays-operations-advanced-2}/src/test/java/com/baeldung/arraymiddle/MiddleOfArrayUnitTest.java (99%) diff --git a/core-java-modules/core-java-arrays-operations-advanced-2/pom.xml b/core-java-modules/core-java-arrays-operations-advanced-2/pom.xml new file mode 100644 index 0000000000..53cccb8a73 --- /dev/null +++ b/core-java-modules/core-java-arrays-operations-advanced-2/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + core-java-arrays-operations-advanced-2 + core-java-arrays-operations-advanced-2 + jar + + + core-java-modules + com.baeldung.core-java-modules + 0.0.1-SNAPSHOT + + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + + + + maven-assembly-plugin + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/arraymiddle/MiddleOfArray.java b/core-java-modules/core-java-arrays-operations-advanced-2/src/main/java/com/baeldung/arraymiddle/MiddleOfArray.java similarity index 99% rename from core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/arraymiddle/MiddleOfArray.java rename to core-java-modules/core-java-arrays-operations-advanced-2/src/main/java/com/baeldung/arraymiddle/MiddleOfArray.java index f389893209..bfff003512 100644 --- a/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/arraymiddle/MiddleOfArray.java +++ b/core-java-modules/core-java-arrays-operations-advanced-2/src/main/java/com/baeldung/arraymiddle/MiddleOfArray.java @@ -62,4 +62,4 @@ public class MiddleOfArray { return array[mid]; } } -} +} \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-operations-advanced/src/test/java/com/baeldung/arraymiddle/MiddleOfArrayUnitTest.java b/core-java-modules/core-java-arrays-operations-advanced-2/src/test/java/com/baeldung/arraymiddle/MiddleOfArrayUnitTest.java similarity index 99% rename from core-java-modules/core-java-arrays-operations-advanced/src/test/java/com/baeldung/arraymiddle/MiddleOfArrayUnitTest.java rename to core-java-modules/core-java-arrays-operations-advanced-2/src/test/java/com/baeldung/arraymiddle/MiddleOfArrayUnitTest.java index 706412d83e..64a9796e67 100644 --- a/core-java-modules/core-java-arrays-operations-advanced/src/test/java/com/baeldung/arraymiddle/MiddleOfArrayUnitTest.java +++ b/core-java-modules/core-java-arrays-operations-advanced-2/src/test/java/com/baeldung/arraymiddle/MiddleOfArrayUnitTest.java @@ -86,4 +86,4 @@ public class MiddleOfArrayUnitTest { MiddleOfArray middleOfArray = new MiddleOfArray(); Assert.assertEquals(expectMedian, middleOfArray.medianOfArray(array, 0, 100)); } -} +} \ No newline at end of file diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 7fbd6cf657..34e5204868 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -65,6 +65,7 @@ core-java-arrays-convert core-java-arrays-operations-basic core-java-arrays-operations-advanced + core-java-arrays-operations-advanced-2 core-java-booleans core-java-char core-java-collections From e64dbf88ac7ccc72a82b32a64f1614627c209c2c Mon Sep 17 00:00:00 2001 From: Manfred <77407079+manfred106@users.noreply.github.com> Date: Thu, 21 Sep 2023 18:24:00 +0100 Subject: [PATCH 11/12] BAEL-6522: Expand Columns with Apache POI (#14801) --- apache-poi-3/pom.xml | 33 +++++++++ .../expandcolumn/ExpandColumnUnitTest.java | 70 +++++++++++++++++++ pom.xml | 2 + 3 files changed, 105 insertions(+) create mode 100644 apache-poi-3/pom.xml create mode 100644 apache-poi-3/src/test/java/com/baeldung/poi/excel/expandcolumn/ExpandColumnUnitTest.java diff --git a/apache-poi-3/pom.xml b/apache-poi-3/pom.xml new file mode 100644 index 0000000000..5031e1c5c7 --- /dev/null +++ b/apache-poi-3/pom.xml @@ -0,0 +1,33 @@ + + + 4.0.0 + apache-poi-3 + 0.0.1-SNAPSHOT + apache-poi-3 + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + org.apache.poi + poi-ooxml + ${poi.version} + + + org.apache.poi + poi-scratchpad + ${poi.version} + + + + + 5.2.3 + + + \ No newline at end of file diff --git a/apache-poi-3/src/test/java/com/baeldung/poi/excel/expandcolumn/ExpandColumnUnitTest.java b/apache-poi-3/src/test/java/com/baeldung/poi/excel/expandcolumn/ExpandColumnUnitTest.java new file mode 100644 index 0000000000..04d0aef211 --- /dev/null +++ b/apache-poi-3/src/test/java/com/baeldung/poi/excel/expandcolumn/ExpandColumnUnitTest.java @@ -0,0 +1,70 @@ +package com.baeldung.poi.excel.expandcolumn; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.*; + +import java.io.IOException; + +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class ExpandColumnUnitTest { + + private Workbook workbook; + private Sheet sheet; + + @BeforeEach + void prepareSpreadsheet() { + workbook = new XSSFWorkbook(); + sheet = workbook.createSheet(); + + Row headerRow = sheet.createRow(0); + Cell headerCell1 = headerRow.createCell(0); + headerCell1.setCellValue("Full Name"); + Cell headerCell2 = headerRow.createCell(1); + headerCell2.setCellValue("Abbreviation"); + + Row dataRow = sheet.createRow(1); + Cell dataCell1 = dataRow.createCell(0); + dataCell1.setCellValue("Java Virtual Machine"); + Cell dataCell2 = dataRow.createCell(1); + dataCell2.setCellValue("JVM"); + + dataRow = sheet.createRow(2); + dataCell1 = dataRow.createCell(0); + dataCell1.setCellValue("Java Runtime Environment"); + dataCell2 = dataRow.createCell(1); + dataCell2.setCellValue("JRE"); + } + + @Test + void whenSetColumnWidth_thenColumnSetToTheSpecifiedWidth() { + + Row row = sheet.getRow(2); + String cellValue = row.getCell(0).getStringCellValue(); + int targetWidth = cellValue.length() * 256; + + sheet.setColumnWidth(0, targetWidth); + + assertEquals(targetWidth, sheet.getColumnWidth(0)); + } + + @Test + void whenAutoSizeColumn_thenColumnExpands() { + + int originalWidth = sheet.getColumnWidth(0); + + sheet.autoSizeColumn(0); + + assertThat(sheet.getColumnWidth(0)).isGreaterThan(originalWidth); + } + + @AfterEach + void cleanup() throws IOException { + workbook.close(); + } + +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index c65f6ce62d..060f158888 100644 --- a/pom.xml +++ b/pom.xml @@ -816,6 +816,7 @@ apache-olingo apache-poi-2 + apache-poi-3 apache-thrift apache-tika @@ -1089,6 +1090,7 @@ apache-olingo apache-poi-2 + apache-poi-3 apache-thrift apache-tika From f2b646005680f03581b8e0268e3a63a8451b38a3 Mon Sep 17 00:00:00 2001 From: Eugene Kovko <37694937+eukovko@users.noreply.github.com> Date: Thu, 21 Sep 2023 19:26:51 +0200 Subject: [PATCH 12/12] BAEL-6978: Adding the information about the bug (#14804) --- .../identity/IdentityHashMapDemonstrator.java | 2 +- .../IdentityHashMapDemonstratorUnitTest.java | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/core-java-modules/core-java-collections-maps-5/src/main/java/com/baeldung/map/identity/IdentityHashMapDemonstrator.java b/core-java-modules/core-java-collections-maps-5/src/main/java/com/baeldung/map/identity/IdentityHashMapDemonstrator.java index 3cbe09b93f..3b98423120 100644 --- a/core-java-modules/core-java-collections-maps-5/src/main/java/com/baeldung/map/identity/IdentityHashMapDemonstrator.java +++ b/core-java-modules/core-java-collections-maps-5/src/main/java/com/baeldung/map/identity/IdentityHashMapDemonstrator.java @@ -53,7 +53,7 @@ public class IdentityHashMapDemonstrator { } } - private static class Book { + static class Book { String title; int year; diff --git a/core-java-modules/core-java-collections-maps-5/src/test/java/com/baeldung/map/identity/IdentityHashMapDemonstratorUnitTest.java b/core-java-modules/core-java-collections-maps-5/src/test/java/com/baeldung/map/identity/IdentityHashMapDemonstratorUnitTest.java index cc74ce4dd6..388338c3ab 100644 --- a/core-java-modules/core-java-collections-maps-5/src/test/java/com/baeldung/map/identity/IdentityHashMapDemonstratorUnitTest.java +++ b/core-java-modules/core-java-collections-maps-5/src/test/java/com/baeldung/map/identity/IdentityHashMapDemonstratorUnitTest.java @@ -1,8 +1,11 @@ package com.baeldung.map.identity; +import com.baeldung.map.identity.IdentityHashMapDemonstrator.Book; import org.junit.jupiter.api.Test; import java.util.IdentityHashMap; +import org.junit.jupiter.api.condition.EnabledForJreRange; +import org.junit.jupiter.api.condition.JRE; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -18,4 +21,44 @@ public class IdentityHashMapDemonstratorUnitTest { assertEquals("Fantasy", identityHashMap.get("genre")); assertEquals("Drama", identityHashMap.get(newGenreKey)); } + + @Test + @EnabledForJreRange(max = JRE.JAVA_19) + public void removeEntryComparingValueByEquality() { + Book book = new Book("A Passage to India", 1924); + IdentityHashMap identityHashMap = new IdentityHashMap<>(10); + identityHashMap.put(book, "A great work of fiction"); + identityHashMap.remove(book, new String("A great work of fiction")); + assertEquals(null, identityHashMap.get(book)); + } + + @Test + @EnabledForJreRange(max = JRE.JAVA_19) + public void replaceEntryComparingValueByEquality() { + Book book = new Book("A Passage to India", 1924); + IdentityHashMap identityHashMap = new IdentityHashMap<>(10); + identityHashMap.put(book, "A great work of fiction"); + identityHashMap.replace(book, new String("A great work of fiction"), "One of the greatest books"); + assertEquals("One of the greatest books", identityHashMap.get(book)); + } + + @Test + @EnabledForJreRange(min = JRE.JAVA_20) + public void dontRemoveEntryComparingValueByEquality() { + Book book = new Book("A Passage to India", 1924); + IdentityHashMap identityHashMap = new IdentityHashMap<>(10); + identityHashMap.put(book, "A great work of fiction"); + identityHashMap.remove(book, new String("A great work of fiction")); + assertEquals("A great work of fiction", identityHashMap.get(book)); + } + + @Test + @EnabledForJreRange(min = JRE.JAVA_20) + public void dontReplaceEntryComparingValueByEquality() { + Book book = new Book("A Passage to India", 1924); + IdentityHashMap identityHashMap = new IdentityHashMap<>(10); + identityHashMap.put(book, "A great work of fiction"); + identityHashMap.replace(book, new String("A great work of fiction"), "One of the greatest books"); + assertEquals("A great work of fiction", identityHashMap.get(book)); + } }