From 7852a3ec2b545cd27844c30e580cad8556ac6896 Mon Sep 17 00:00:00 2001 From: Philippe Soares Date: Sun, 25 Oct 2020 23:05:27 -0400 Subject: [PATCH 01/43] Fix for issue #10204. --- .../chat.html => resources/public/index.html} | 50 +++++++++---------- .../public}/js/sockjs-0.3.4.js | 0 .../public}/js/stomp.js | 0 .../public}/js/webSocketSendToUserApp.js | 0 4 files changed, 25 insertions(+), 25 deletions(-) rename spring-websockets/src/main/{webapp/resources/chat.html => resources/public/index.html} (88%) rename spring-websockets/src/main/{webapp/resources => resources/public}/js/sockjs-0.3.4.js (100%) rename spring-websockets/src/main/{webapp/resources => resources/public}/js/stomp.js (100%) rename spring-websockets/src/main/{webapp/resources => resources/public}/js/webSocketSendToUserApp.js (100%) diff --git a/spring-websockets/src/main/webapp/resources/chat.html b/spring-websockets/src/main/resources/public/index.html similarity index 88% rename from spring-websockets/src/main/webapp/resources/chat.html rename to spring-websockets/src/main/resources/public/index.html index 17c8494dd8..f52cca34d1 100644 --- a/spring-websockets/src/main/webapp/resources/chat.html +++ b/spring-websockets/src/main/resources/public/index.html @@ -1,73 +1,73 @@ Chat WebSocket - + - + - + - +
- - + +
@@ -85,4 +85,4 @@
- \ No newline at end of file + diff --git a/spring-websockets/src/main/webapp/resources/js/sockjs-0.3.4.js b/spring-websockets/src/main/resources/public/js/sockjs-0.3.4.js similarity index 100% rename from spring-websockets/src/main/webapp/resources/js/sockjs-0.3.4.js rename to spring-websockets/src/main/resources/public/js/sockjs-0.3.4.js diff --git a/spring-websockets/src/main/webapp/resources/js/stomp.js b/spring-websockets/src/main/resources/public/js/stomp.js similarity index 100% rename from spring-websockets/src/main/webapp/resources/js/stomp.js rename to spring-websockets/src/main/resources/public/js/stomp.js diff --git a/spring-websockets/src/main/webapp/resources/js/webSocketSendToUserApp.js b/spring-websockets/src/main/resources/public/js/webSocketSendToUserApp.js similarity index 100% rename from spring-websockets/src/main/webapp/resources/js/webSocketSendToUserApp.js rename to spring-websockets/src/main/resources/public/js/webSocketSendToUserApp.js From 6dab1d510f3965233cc54423f50a2364115acd46 Mon Sep 17 00:00:00 2001 From: Philippe Soares Date: Sun, 25 Oct 2020 23:28:41 -0400 Subject: [PATCH 02/43] Fix for issue #10204. --- .../src/main/resources/public/index.html | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/spring-websockets/src/main/resources/public/index.html b/spring-websockets/src/main/resources/public/index.html index f52cca34d1..d507e186d4 100644 --- a/spring-websockets/src/main/resources/public/index.html +++ b/spring-websockets/src/main/resources/public/index.html @@ -1,73 +1,73 @@ Chat WebSocket - + - + - + - +
- - + +
@@ -85,4 +85,4 @@
- + \ No newline at end of file From 18954efcee89355109476e9a43bd11e8ba3b8be1 Mon Sep 17 00:00:00 2001 From: Philippe Soares Date: Sun, 25 Oct 2020 23:52:08 -0400 Subject: [PATCH 03/43] Added push messages using the @Scheduled annotation. --- spring-websockets/pom.xml | 5 +++ .../main/java/com/baeldung/SpringBootApp.java | 2 ++ .../websockets/ScheduledPushMessages.java | 31 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 spring-websockets/src/main/java/com/baeldung/websockets/ScheduledPushMessages.java diff --git a/spring-websockets/pom.xml b/spring-websockets/pom.xml index ddfd512476..8f24962185 100644 --- a/spring-websockets/pom.xml +++ b/spring-websockets/pom.xml @@ -18,6 +18,11 @@ org.springframework.boot spring-boot-starter-websocket + + com.github.javafaker + javafaker + 1.0.2 + com.google.code.gson gson diff --git a/spring-websockets/src/main/java/com/baeldung/SpringBootApp.java b/spring-websockets/src/main/java/com/baeldung/SpringBootApp.java index ea2a461dfc..3a98746748 100644 --- a/spring-websockets/src/main/java/com/baeldung/SpringBootApp.java +++ b/spring-websockets/src/main/java/com/baeldung/SpringBootApp.java @@ -3,8 +3,10 @@ package com.baeldung; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication +@EnableScheduling public class SpringBootApp extends SpringBootServletInitializer { public static void main(String[] args) { SpringApplication.run(SpringBootApp.class, args); diff --git a/spring-websockets/src/main/java/com/baeldung/websockets/ScheduledPushMessages.java b/spring-websockets/src/main/java/com/baeldung/websockets/ScheduledPushMessages.java new file mode 100644 index 0000000000..3e27d840d9 --- /dev/null +++ b/spring-websockets/src/main/java/com/baeldung/websockets/ScheduledPushMessages.java @@ -0,0 +1,31 @@ +package com.baeldung.websockets; + + +import com.github.javafaker.Faker; +import org.springframework.messaging.simp.SimpMessagingTemplate; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Controller; + +import java.text.SimpleDateFormat; +import java.util.Date; + +@Controller +public class ScheduledPushMessages { + + private final SimpMessagingTemplate simpMessagingTemplate; + + private final Faker faker; + + public ScheduledPushMessages(SimpMessagingTemplate simpMessagingTemplate) { + this.simpMessagingTemplate = simpMessagingTemplate; + faker = new Faker(); + } + + @Scheduled(fixedRate = 5000) + public void sendMessage() { + final String time = new SimpleDateFormat("HH:mm").format(new Date()); + simpMessagingTemplate.convertAndSend("/topic/messages", + new OutputMessage("Chuck Norris", faker.chuckNorris().fact(), time)); + } + +} From 66fff973aeab0792e2fcf814b1bca34104d42da1 Mon Sep 17 00:00:00 2001 From: Philippe Soares Date: Mon, 26 Oct 2020 00:04:15 -0400 Subject: [PATCH 04/43] Added push messages using an interval Flux. --- spring-websockets/pom.xml | 4 +++ .../ReactiveScheduledPushMessages.java | 32 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 spring-websockets/src/main/java/com/baeldung/websockets/ReactiveScheduledPushMessages.java diff --git a/spring-websockets/pom.xml b/spring-websockets/pom.xml index 8f24962185..d2a32a8eb6 100644 --- a/spring-websockets/pom.xml +++ b/spring-websockets/pom.xml @@ -18,6 +18,10 @@ org.springframework.boot spring-boot-starter-websocket + + io.projectreactor + reactor-core + com.github.javafaker javafaker diff --git a/spring-websockets/src/main/java/com/baeldung/websockets/ReactiveScheduledPushMessages.java b/spring-websockets/src/main/java/com/baeldung/websockets/ReactiveScheduledPushMessages.java new file mode 100644 index 0000000000..cfaf981d96 --- /dev/null +++ b/spring-websockets/src/main/java/com/baeldung/websockets/ReactiveScheduledPushMessages.java @@ -0,0 +1,32 @@ +package com.baeldung.websockets; + +import com.github.javafaker.Faker; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.messaging.simp.SimpMessagingTemplate; +import org.springframework.stereotype.Service; +import reactor.core.publisher.Flux; + +import java.text.SimpleDateFormat; +import java.time.Duration; +import java.util.Date; + +@Service +public class ReactiveScheduledPushMessages implements InitializingBean { + + private final SimpMessagingTemplate simpMessagingTemplate; + + private final Faker faker; + + public ReactiveScheduledPushMessages(SimpMessagingTemplate simpMessagingTemplate) { + this.simpMessagingTemplate = simpMessagingTemplate; + this.faker = new Faker(); + } + + @Override + public void afterPropertiesSet() throws Exception { + Flux.interval(Duration.ofSeconds(4L)) + .map((n) -> new OutputMessage(faker.backToTheFuture().character(), faker.backToTheFuture().quote(), + new SimpleDateFormat("HH:mm").format(new Date()))) + .subscribe(message -> simpMessagingTemplate.convertAndSend("/topic/messages", message)); + } +} From 9b8455e82992dff01cae00a1560f0d4ed750841c Mon Sep 17 00:00:00 2001 From: Adina Rolea Date: Tue, 27 Oct 2020 15:47:40 +0200 Subject: [PATCH 05/43] BAEL-4687: added spring boot jackson configuration example --- spring-boot-modules/pom.xml | 1 + .../spring-boot-jackson/pom.xml | 21 +++++++++ .../baeldung/boot/jackson/Application.java | 12 ++++++ .../jackson/config/CoffeeConfiguration.java | 43 +++++++++++++++++++ .../jackson/controller/CoffeeController.java | 25 +++++++++++ .../baeldung/boot/jackson/model/Coffee.java | 26 +++++++++++ .../boot/jackson/model/CoffeeResponse.java | 28 ++++++++++++ .../src/main/resources/application.properties | 3 ++ .../boot/jackson/CoffeeIntegrationTest.java | 32 ++++++++++++++ 9 files changed, 191 insertions(+) create mode 100644 spring-boot-modules/spring-boot-jackson/pom.xml create mode 100644 spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/Application.java create mode 100644 spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConfiguration.java create mode 100644 spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java create mode 100644 spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/Coffee.java create mode 100644 spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/CoffeeResponse.java create mode 100644 spring-boot-modules/spring-boot-jackson/src/main/resources/application.properties create mode 100644 spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/CoffeeIntegrationTest.java diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index fa70a9f058..3d721d7147 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -68,6 +68,7 @@ spring-boot-vue spring-boot-xml spring-boot-actuator + spring-boot-jackson diff --git a/spring-boot-modules/spring-boot-jackson/pom.xml b/spring-boot-modules/spring-boot-jackson/pom.xml new file mode 100644 index 0000000000..b502bca908 --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/pom.xml @@ -0,0 +1,21 @@ + + + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + 4.0.0 + + spring-boot-jackson + + + org.springframework.boot + spring-boot-starter-web + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/Application.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/Application.java new file mode 100644 index 0000000000..c4de34879f --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/Application.java @@ -0,0 +1,12 @@ +package com.baeldung.boot.jackson; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConfiguration.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConfiguration.java new file mode 100644 index 0000000000..ac7be062c2 --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConfiguration.java @@ -0,0 +1,43 @@ +package com.baeldung.boot.jackson.config; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; +import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; + +import java.time.format.DateTimeFormatter; + +@Configuration +public class CoffeeConfiguration { + public static final String dateTimeFormat = "dd-MM-yyyy HH:mm"; + private LocalDateTimeSerializer localDateTimeSerializer = new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(dateTimeFormat)); + + @Bean + public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() { + return builder -> builder.serializationInclusion(JsonInclude.Include.NON_NULL) + .serializers(localDateTimeSerializer); + } + + @Bean + @Primary + public ObjectMapper objectMapper() { + JavaTimeModule module = new JavaTimeModule(); + module.addSerializer(localDateTimeSerializer); + return new ObjectMapper() + .setSerializationInclusion(JsonInclude.Include.NON_NULL) + .registerModule(module); + } + + @Bean + @Primary + public Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder() { + return new Jackson2ObjectMapperBuilder() + .serializers(localDateTimeSerializer) + .serializationInclusion(JsonInclude.Include.NON_NULL); + } +} diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java new file mode 100644 index 0000000000..2a0f6e1240 --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java @@ -0,0 +1,25 @@ +package com.baeldung.boot.jackson.controller; + +import com.baeldung.boot.jackson.model.Coffee; +import com.baeldung.boot.jackson.model.CoffeeResponse; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.time.LocalDateTime; + +@RestController +public class CoffeeController { + + @GetMapping("/coffee") + public CoffeeResponse createCoffee(@RequestParam(required = false) String brand, + @RequestParam(required = false) String name) { + Coffee coffee = new Coffee() + .setBrand(brand) + .setName(name); + + return new CoffeeResponse() + .setDate(LocalDateTime.now()) + .setBody(coffee); + } +} diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/Coffee.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/Coffee.java new file mode 100644 index 0000000000..12c2e200df --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/Coffee.java @@ -0,0 +1,26 @@ +package com.baeldung.boot.jackson.model; + +public class Coffee { + + private String name; + + private String brand; + + public String getName() { + return name; + } + + public Coffee setName(String name) { + this.name = name; + return this; + } + + public String getBrand() { + return brand; + } + + public Coffee setBrand(String brand) { + this.brand = brand; + return this; + } +} diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/CoffeeResponse.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/CoffeeResponse.java new file mode 100644 index 0000000000..c2667df03a --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/CoffeeResponse.java @@ -0,0 +1,28 @@ +package com.baeldung.boot.jackson.model; + +import java.time.LocalDateTime; + +public class CoffeeResponse { + + private LocalDateTime date; + + private T body; + + public LocalDateTime getDate() { + return date; + } + + public CoffeeResponse setDate(LocalDateTime date) { + this.date = date; + return this; + } + + public T getBody() { + return body; + } + + public CoffeeResponse setBody(T body) { + this.body = body; + return this; + } +} diff --git a/spring-boot-modules/spring-boot-jackson/src/main/resources/application.properties b/spring-boot-modules/spring-boot-jackson/src/main/resources/application.properties new file mode 100644 index 0000000000..2129762424 --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/main/resources/application.properties @@ -0,0 +1,3 @@ +spring.jackson.default-property-inclusion=non_null +spring.jackson.serialization.write-dates-as-timestamps=false +spring.jackson.date-format=dd-MM-yyyy HH:mm \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/CoffeeIntegrationTest.java b/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/CoffeeIntegrationTest.java new file mode 100644 index 0000000000..d508ee45d1 --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/CoffeeIntegrationTest.java @@ -0,0 +1,32 @@ +package com.baeldung.boot.jackson; + +import com.baeldung.boot.jackson.config.CoffeeConfiguration; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +import static org.assertj.core.api.Assertions.assertThat; + +@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class CoffeeIntegrationTest { + + @Autowired + TestRestTemplate restTemplate; + + @Test + public void whenQueryCoffeeWithoutParam_thenNullIsNotInserted() { + String formattedDate = DateTimeFormatter.ofPattern(CoffeeConfiguration.dateTimeFormat) + .format(LocalDateTime.now()); + String brand = "Lavazza"; + + String url = "/coffee?brand=" + brand; + String response = restTemplate.getForObject(url, String.class); + + assertThat(response).isEqualTo( + "{\"date\":\"" + formattedDate + "\",\"body\":{\"brand\":\"" + brand + "\"}}"); + } +} From 2a8ff6f23b38b356d5ab70d8dcad9cf5110c20e6 Mon Sep 17 00:00:00 2001 From: Adina Rolea Date: Tue, 27 Oct 2020 16:12:59 +0200 Subject: [PATCH 06/43] BAEL-4687: added web configuration for jackson --- .../jackson/config/CoffeeConfiguration.java | 8 +++++ .../config/CoffeeWebConfiguration.java | 32 +++++++++++++++++++ .../src/main/resources/application.properties | 3 +- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeWebConfiguration.java diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConfiguration.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConfiguration.java index ac7be062c2..a6804a12f0 100644 --- a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConfiguration.java +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConfiguration.java @@ -1,6 +1,7 @@ package com.baeldung.boot.jackson.config; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.Module; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; @@ -40,4 +41,11 @@ public class CoffeeConfiguration { .serializers(localDateTimeSerializer) .serializationInclusion(JsonInclude.Include.NON_NULL); } + + @Bean + public Module javaTimeModule() { + JavaTimeModule module = new JavaTimeModule(); + module.addSerializer(localDateTimeSerializer); + return module; + } } diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeWebConfiguration.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeWebConfiguration.java new file mode 100644 index 0000000000..a53ab3a805 --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeWebConfiguration.java @@ -0,0 +1,32 @@ +package com.baeldung.boot.jackson.config; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import java.time.format.DateTimeFormatter; +import java.util.List; + +@Configuration +public class CoffeeWebConfiguration implements WebMvcConfigurer { + public static final String dateTimeFormat = "dd-MM-yyyy HH:mm"; + private LocalDateTimeSerializer localDateTimeSerializer = new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(dateTimeFormat)); + + @Override + public void configureMessageConverters(List> converters) { + converters.add(mappingJackson2HttpMessageConverter()); + } + + @Bean + public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() { + Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder() + .serializers(localDateTimeSerializer) + .serializationInclusion(JsonInclude.Include.NON_NULL); + return new MappingJackson2HttpMessageConverter(builder.build()); + } +} diff --git a/spring-boot-modules/spring-boot-jackson/src/main/resources/application.properties b/spring-boot-modules/spring-boot-jackson/src/main/resources/application.properties index 2129762424..352add464b 100644 --- a/spring-boot-modules/spring-boot-jackson/src/main/resources/application.properties +++ b/spring-boot-modules/spring-boot-jackson/src/main/resources/application.properties @@ -1,3 +1,2 @@ spring.jackson.default-property-inclusion=non_null -spring.jackson.serialization.write-dates-as-timestamps=false -spring.jackson.date-format=dd-MM-yyyy HH:mm \ No newline at end of file +spring.jackson.serialization.write-dates-as-timestamps=false \ No newline at end of file From 0218395e89cdc42fcd1e522502a01d2278a50636 Mon Sep 17 00:00:00 2001 From: Adina Rolea Date: Tue, 27 Oct 2020 17:07:14 +0200 Subject: [PATCH 07/43] BAEL-4687: simplified configuration --- .../jackson/controller/CoffeeController.java | 12 +++----- .../baeldung/boot/jackson/model/Coffee.java | 13 +++++++++ .../boot/jackson/model/CoffeeResponse.java | 28 ------------------- .../boot/jackson/CoffeeIntegrationTest.java | 4 +-- 4 files changed, 19 insertions(+), 38 deletions(-) delete mode 100644 spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/CoffeeResponse.java diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java index 2a0f6e1240..075126de67 100644 --- a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java @@ -1,7 +1,6 @@ package com.baeldung.boot.jackson.controller; import com.baeldung.boot.jackson.model.Coffee; -import com.baeldung.boot.jackson.model.CoffeeResponse; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -12,14 +11,11 @@ import java.time.LocalDateTime; public class CoffeeController { @GetMapping("/coffee") - public CoffeeResponse createCoffee(@RequestParam(required = false) String brand, - @RequestParam(required = false) String name) { - Coffee coffee = new Coffee() + public Coffee getCoffee(@RequestParam(required = false) String brand, + @RequestParam(required = false) String name) { + return new Coffee() .setBrand(brand) - .setName(name); - - return new CoffeeResponse() .setDate(LocalDateTime.now()) - .setBody(coffee); + .setName(name); } } diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/Coffee.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/Coffee.java index 12c2e200df..4df6b4bd6d 100644 --- a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/Coffee.java +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/Coffee.java @@ -1,11 +1,15 @@ package com.baeldung.boot.jackson.model; +import java.time.LocalDateTime; + public class Coffee { private String name; private String brand; + private LocalDateTime date; + public String getName() { return name; } @@ -23,4 +27,13 @@ public class Coffee { this.brand = brand; return this; } + + public LocalDateTime getDate() { + return date; + } + + public Coffee setDate(LocalDateTime date) { + this.date = date; + return this; + } } diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/CoffeeResponse.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/CoffeeResponse.java deleted file mode 100644 index c2667df03a..0000000000 --- a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/CoffeeResponse.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.boot.jackson.model; - -import java.time.LocalDateTime; - -public class CoffeeResponse { - - private LocalDateTime date; - - private T body; - - public LocalDateTime getDate() { - return date; - } - - public CoffeeResponse setDate(LocalDateTime date) { - this.date = date; - return this; - } - - public T getBody() { - return body; - } - - public CoffeeResponse setBody(T body) { - this.body = body; - return this; - } -} diff --git a/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/CoffeeIntegrationTest.java b/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/CoffeeIntegrationTest.java index d508ee45d1..1fda173d37 100644 --- a/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/CoffeeIntegrationTest.java +++ b/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/CoffeeIntegrationTest.java @@ -18,7 +18,7 @@ public class CoffeeIntegrationTest { TestRestTemplate restTemplate; @Test - public void whenQueryCoffeeWithoutParam_thenNullIsNotInserted() { + public void whenGetCoffee_thenSerializedWithDateAndNonNull() { String formattedDate = DateTimeFormatter.ofPattern(CoffeeConfiguration.dateTimeFormat) .format(LocalDateTime.now()); String brand = "Lavazza"; @@ -27,6 +27,6 @@ public class CoffeeIntegrationTest { String response = restTemplate.getForObject(url, String.class); assertThat(response).isEqualTo( - "{\"date\":\"" + formattedDate + "\",\"body\":{\"brand\":\"" + brand + "\"}}"); + "{\"brand\":\"" + brand + "\",\"date\":\"" + formattedDate + "\"}"); } } From 6e8b8c086de2d100d5212f354dd70cc42b540b18 Mon Sep 17 00:00:00 2001 From: Adina Rolea Date: Wed, 4 Nov 2020 10:36:43 +0200 Subject: [PATCH 08/43] BAEL-4687: updated jackson configuration --- .../jackson/config/CoffeeConfiguration.java | 9 ++++++ .../config/CoffeeWebConfiguration.java | 32 ------------------- 2 files changed, 9 insertions(+), 32 deletions(-) delete mode 100644 spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeWebConfiguration.java diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConfiguration.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConfiguration.java index a6804a12f0..d13ce51e9b 100644 --- a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConfiguration.java +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConfiguration.java @@ -10,6 +10,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import java.time.format.DateTimeFormatter; @@ -18,6 +19,14 @@ public class CoffeeConfiguration { public static final String dateTimeFormat = "dd-MM-yyyy HH:mm"; private LocalDateTimeSerializer localDateTimeSerializer = new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(dateTimeFormat)); + @Bean + public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() { + Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder() + .serializers(localDateTimeSerializer) + .serializationInclusion(JsonInclude.Include.NON_NULL); + return new MappingJackson2HttpMessageConverter(builder.build()); + } + @Bean public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() { return builder -> builder.serializationInclusion(JsonInclude.Include.NON_NULL) diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeWebConfiguration.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeWebConfiguration.java deleted file mode 100644 index a53ab3a805..0000000000 --- a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeWebConfiguration.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.boot.jackson.config; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -import java.time.format.DateTimeFormatter; -import java.util.List; - -@Configuration -public class CoffeeWebConfiguration implements WebMvcConfigurer { - public static final String dateTimeFormat = "dd-MM-yyyy HH:mm"; - private LocalDateTimeSerializer localDateTimeSerializer = new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(dateTimeFormat)); - - @Override - public void configureMessageConverters(List> converters) { - converters.add(mappingJackson2HttpMessageConverter()); - } - - @Bean - public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() { - Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder() - .serializers(localDateTimeSerializer) - .serializationInclusion(JsonInclude.Include.NON_NULL); - return new MappingJackson2HttpMessageConverter(builder.build()); - } -} From 7077a5f80cf6faf74923a4bf6c2fc42aa4bc23b3 Mon Sep 17 00:00:00 2001 From: Daniel Strmecki Date: Sun, 8 Nov 2020 11:15:42 +0100 Subject: [PATCH 09/43] BAEL-4717: Create new collections module --- .../core-java-collections-4/README.md | 7 +++++ .../core-java-collections-4/pom.xml | 31 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 core-java-modules/core-java-collections-4/README.md create mode 100644 core-java-modules/core-java-collections-4/pom.xml diff --git a/core-java-modules/core-java-collections-4/README.md b/core-java-modules/core-java-collections-4/README.md new file mode 100644 index 0000000000..1c680b86ba --- /dev/null +++ b/core-java-modules/core-java-collections-4/README.md @@ -0,0 +1,7 @@ +========= + +## Core Java Collections Cookbooks and Examples + +### Relevant Articles: + +- TODO: add article links here diff --git a/core-java-modules/core-java-collections-4/pom.xml b/core-java-modules/core-java-collections-4/pom.xml new file mode 100644 index 0000000000..23baa51d0d --- /dev/null +++ b/core-java-modules/core-java-collections-4/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + core-java-collections-3 + 0.1.0-SNAPSHOT + core-java-collections-3 + jar + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + ../pom.xml + + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + 3.18.0 + + + From 6866b51d52b8edc4ebceb77bcbe51c8b7ae8d562 Mon Sep 17 00:00:00 2001 From: Philippe Soares Date: Sun, 8 Nov 2020 11:38:17 -0500 Subject: [PATCH 10/43] Put html and js resources back to their original location. Split backend code so it doesn't modify existing examples. Added a bots.html page for the server push version. --- .../baeldung/websockets/BotsController.java | 21 +++++ .../ReactiveScheduledPushMessages.java | 2 +- .../websockets/ScheduledPushMessages.java | 5 +- .../baeldung/websockets/WebSocketConfig.java | 2 + spring-websockets/src/main/webapp/bots.html | 88 +++++++++++++++++++ .../resources}/js/sockjs-0.3.4.js | 0 .../public => webapp/resources}/js/stomp.js | 0 .../resources}/js/webSocketSendToUserApp.js | 0 8 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 spring-websockets/src/main/java/com/baeldung/websockets/BotsController.java create mode 100644 spring-websockets/src/main/webapp/bots.html rename spring-websockets/src/main/{resources/public => webapp/resources}/js/sockjs-0.3.4.js (100%) rename spring-websockets/src/main/{resources/public => webapp/resources}/js/stomp.js (100%) rename spring-websockets/src/main/{resources/public => webapp/resources}/js/webSocketSendToUserApp.js (100%) diff --git a/spring-websockets/src/main/java/com/baeldung/websockets/BotsController.java b/spring-websockets/src/main/java/com/baeldung/websockets/BotsController.java new file mode 100644 index 0000000000..3f268f3794 --- /dev/null +++ b/spring-websockets/src/main/java/com/baeldung/websockets/BotsController.java @@ -0,0 +1,21 @@ +package com.baeldung.websockets; + +import org.springframework.messaging.handler.annotation.MessageMapping; +import org.springframework.messaging.handler.annotation.SendTo; +import org.springframework.stereotype.Controller; + +import java.text.SimpleDateFormat; +import java.util.Date; + +@Controller +public class BotsController { + + @MessageMapping("/chatwithbots") + @SendTo("/topic/pushmessages") + public OutputMessage send(final Message message) throws Exception { + + final String time = new SimpleDateFormat("HH:mm").format(new Date()); + return new OutputMessage(message.getFrom(), message.getText(), time); + } + +} diff --git a/spring-websockets/src/main/java/com/baeldung/websockets/ReactiveScheduledPushMessages.java b/spring-websockets/src/main/java/com/baeldung/websockets/ReactiveScheduledPushMessages.java index cfaf981d96..36b1b886fc 100644 --- a/spring-websockets/src/main/java/com/baeldung/websockets/ReactiveScheduledPushMessages.java +++ b/spring-websockets/src/main/java/com/baeldung/websockets/ReactiveScheduledPushMessages.java @@ -27,6 +27,6 @@ public class ReactiveScheduledPushMessages implements InitializingBean { Flux.interval(Duration.ofSeconds(4L)) .map((n) -> new OutputMessage(faker.backToTheFuture().character(), faker.backToTheFuture().quote(), new SimpleDateFormat("HH:mm").format(new Date()))) - .subscribe(message -> simpMessagingTemplate.convertAndSend("/topic/messages", message)); + .subscribe(message -> simpMessagingTemplate.convertAndSend("/topic/pushmessages", message)); } } diff --git a/spring-websockets/src/main/java/com/baeldung/websockets/ScheduledPushMessages.java b/spring-websockets/src/main/java/com/baeldung/websockets/ScheduledPushMessages.java index 3e27d840d9..2468b69713 100644 --- a/spring-websockets/src/main/java/com/baeldung/websockets/ScheduledPushMessages.java +++ b/spring-websockets/src/main/java/com/baeldung/websockets/ScheduledPushMessages.java @@ -5,11 +5,12 @@ import com.github.javafaker.Faker; import org.springframework.messaging.simp.SimpMessagingTemplate; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Controller; +import org.springframework.stereotype.Service; import java.text.SimpleDateFormat; import java.util.Date; -@Controller +@Service public class ScheduledPushMessages { private final SimpMessagingTemplate simpMessagingTemplate; @@ -24,7 +25,7 @@ public class ScheduledPushMessages { @Scheduled(fixedRate = 5000) public void sendMessage() { final String time = new SimpleDateFormat("HH:mm").format(new Date()); - simpMessagingTemplate.convertAndSend("/topic/messages", + simpMessagingTemplate.convertAndSend("/topic/pushmessages", new OutputMessage("Chuck Norris", faker.chuckNorris().fact(), time)); } diff --git a/spring-websockets/src/main/java/com/baeldung/websockets/WebSocketConfig.java b/spring-websockets/src/main/java/com/baeldung/websockets/WebSocketConfig.java index 7b53dbc3f3..6179ec9c0d 100644 --- a/spring-websockets/src/main/java/com/baeldung/websockets/WebSocketConfig.java +++ b/spring-websockets/src/main/java/com/baeldung/websockets/WebSocketConfig.java @@ -20,6 +20,8 @@ public class WebSocketConfig implements WebSocketMessageBrokerConfigurer { public void registerStompEndpoints(final StompEndpointRegistry registry) { registry.addEndpoint("/chat"); registry.addEndpoint("/chat").withSockJS(); + registry.addEndpoint("/chatwithbots"); + registry.addEndpoint("/chatwithbots").withSockJS(); } } \ No newline at end of file diff --git a/spring-websockets/src/main/webapp/bots.html b/spring-websockets/src/main/webapp/bots.html new file mode 100644 index 0000000000..38570d420c --- /dev/null +++ b/spring-websockets/src/main/webapp/bots.html @@ -0,0 +1,88 @@ + + + Chat WebSocket + + + + + + + + + + +
+ + +
+ +
+
+
+ + +
+
+
+ + +

+
+
+ + + \ No newline at end of file diff --git a/spring-websockets/src/main/resources/public/js/sockjs-0.3.4.js b/spring-websockets/src/main/webapp/resources/js/sockjs-0.3.4.js similarity index 100% rename from spring-websockets/src/main/resources/public/js/sockjs-0.3.4.js rename to spring-websockets/src/main/webapp/resources/js/sockjs-0.3.4.js diff --git a/spring-websockets/src/main/resources/public/js/stomp.js b/spring-websockets/src/main/webapp/resources/js/stomp.js similarity index 100% rename from spring-websockets/src/main/resources/public/js/stomp.js rename to spring-websockets/src/main/webapp/resources/js/stomp.js diff --git a/spring-websockets/src/main/resources/public/js/webSocketSendToUserApp.js b/spring-websockets/src/main/webapp/resources/js/webSocketSendToUserApp.js similarity index 100% rename from spring-websockets/src/main/resources/public/js/webSocketSendToUserApp.js rename to spring-websockets/src/main/webapp/resources/js/webSocketSendToUserApp.js From 796aefa9962896f00ede30cb94b7f4deb5a0b4cb Mon Sep 17 00:00:00 2001 From: Daniel Strmecki Date: Sun, 15 Nov 2020 11:47:08 +0100 Subject: [PATCH 11/43] BAEL-4717: Added ArrayList examples --- .../comparation/ArrayListUnitTest.java | 29 ++++++++++++++++++ .../comparation/ListVsMapUnitTest.java | 30 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ArrayListUnitTest.java create mode 100644 core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ListVsMapUnitTest.java diff --git a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ArrayListUnitTest.java b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ArrayListUnitTest.java new file mode 100644 index 0000000000..935be19e74 --- /dev/null +++ b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ArrayListUnitTest.java @@ -0,0 +1,29 @@ +package com.baeldung.collections.comparation; + +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ArrayListUnitTest { + + @Test + void givenList_whenItemAddedToSpecificIndex_thenItCanBeRetrieved() { + List list = new ArrayList<>(); + list.add("Daniel"); + list.add(1, "Marko"); + assertThat(list).hasSize(2); + assertThat(list.get(1)).isEqualTo("Marko"); + } + + @Test + void givenList_whenItemRemovedViaIndex_thenListSizeIsReduced() { + List list = new ArrayList<>(Arrays.asList("Daniel", "Marko")); + list.remove(1); + assertThat(list).hasSize(1); + } + +} diff --git a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ListVsMapUnitTest.java b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ListVsMapUnitTest.java new file mode 100644 index 0000000000..6507013fbf --- /dev/null +++ b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ListVsMapUnitTest.java @@ -0,0 +1,30 @@ +package com.baeldung.collections.comparation; + +import static org.assertj.core.api.Assertions.*; +import org.junit.jupiter.api.Test; + +import java.util.*; + +class ListVsMapUnitTest { + + @Test + void givenList_whenIteratingTroughValues_thenEachValueIsPresent() { + List list = new ArrayList<>(); + list.add("Daniel"); + list.add("Marko"); + for (String name : list) { + assertThat(name).isIn(list); + } + } + + @Test + void givenMap_whenIteratingTroughValues_thenEachValueIsPresent() { + Map map = new HashMap<>(); + map.put(1, "Daniel"); + map.put(2, "Marko"); + for (String name : map.values()) { + assertThat(name).isIn(map.values()); + } + } + +} From 644939da0755d266186dc15e0ee4934b9c2387a3 Mon Sep 17 00:00:00 2001 From: Adina Rolea Date: Mon, 16 Nov 2020 14:27:29 +0200 Subject: [PATCH 12/43] BAEL-4687: added test for each configuration --- .../boot/jackson/{ => app}/Application.java | 5 +- .../jackson/config/CoffeeConfiguration.java | 60 ------------------- .../boot/jackson/config/CoffeeConstants.java | 11 ++++ .../config/CoffeeCustomizerConfig.java | 18 ++++++ .../CoffeeHttpConverterConfiguration.java | 21 +++++++ .../config/CoffeeJacksonBuilderConfig.java | 21 +++++++ .../config/CoffeeObjectMapperConfig.java | 24 ++++++++ .../config/CoffeeRegisterModuleConfig.java | 21 +++++++ .../src/main/resources/application.properties | 2 - .../src/main/resources/coffee.properties | 1 + .../AbstractCoffeeIntegrationTest.java} | 12 ++-- .../app/CoffeeCustomizerIntegrationTest.java | 8 +++ .../CoffeeHttpConverterIntegrationTest.java | 8 +++ .../CoffeeJacksonBuilderIntegrationTest.java | 8 +++ .../CoffeeObjectMapperIntegrationTest.java | 8 +++ .../CoffeeRegisterModuleIntegrationTest.java | 8 +++ 16 files changed, 166 insertions(+), 70 deletions(-) rename spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/{ => app}/Application.java (62%) delete mode 100644 spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConfiguration.java create mode 100644 spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java create mode 100644 spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java create mode 100644 spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java create mode 100644 spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java create mode 100644 spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java create mode 100644 spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java delete mode 100644 spring-boot-modules/spring-boot-jackson/src/main/resources/application.properties create mode 100644 spring-boot-modules/spring-boot-jackson/src/main/resources/coffee.properties rename spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/{CoffeeIntegrationTest.java => app/AbstractCoffeeIntegrationTest.java} (81%) create mode 100644 spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeCustomizerIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeHttpConverterIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeJacksonBuilderIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeObjectMapperIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeRegisterModuleIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/Application.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/app/Application.java similarity index 62% rename from spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/Application.java rename to spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/app/Application.java index c4de34879f..6f57a534a8 100644 --- a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/Application.java +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/app/Application.java @@ -1,11 +1,12 @@ -package com.baeldung.boot.jackson; +package com.baeldung.boot.jackson.app; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; @SpringBootApplication +@ComponentScan(basePackages = "com.baeldung.boot.jackson.controller") public class Application { - public static void main(String[] args) { SpringApplication.run(Application.class, args); } diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConfiguration.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConfiguration.java deleted file mode 100644 index d13ce51e9b..0000000000 --- a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConfiguration.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.baeldung.boot.jackson.config; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.Module; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; - -import java.time.format.DateTimeFormatter; - -@Configuration -public class CoffeeConfiguration { - public static final String dateTimeFormat = "dd-MM-yyyy HH:mm"; - private LocalDateTimeSerializer localDateTimeSerializer = new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(dateTimeFormat)); - - @Bean - public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() { - Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder() - .serializers(localDateTimeSerializer) - .serializationInclusion(JsonInclude.Include.NON_NULL); - return new MappingJackson2HttpMessageConverter(builder.build()); - } - - @Bean - public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() { - return builder -> builder.serializationInclusion(JsonInclude.Include.NON_NULL) - .serializers(localDateTimeSerializer); - } - - @Bean - @Primary - public ObjectMapper objectMapper() { - JavaTimeModule module = new JavaTimeModule(); - module.addSerializer(localDateTimeSerializer); - return new ObjectMapper() - .setSerializationInclusion(JsonInclude.Include.NON_NULL) - .registerModule(module); - } - - @Bean - @Primary - public Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder() { - return new Jackson2ObjectMapperBuilder() - .serializers(localDateTimeSerializer) - .serializationInclusion(JsonInclude.Include.NON_NULL); - } - - @Bean - public Module javaTimeModule() { - JavaTimeModule module = new JavaTimeModule(); - module.addSerializer(localDateTimeSerializer); - return module; - } -} diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java new file mode 100644 index 0000000000..7e7d7b8bc2 --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java @@ -0,0 +1,11 @@ +package com.baeldung.boot.jackson.config; + +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; + +import java.time.format.DateTimeFormatter; + +public class CoffeeConstants { + + public static final String dateTimeFormat = "dd-MM-yyyy HH:mm"; + public static LocalDateTimeSerializer localDateTimeSerializer = new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(dateTimeFormat)); +} diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java new file mode 100644 index 0000000000..c13615e702 --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java @@ -0,0 +1,18 @@ +package com.baeldung.boot.jackson.config; + +import com.fasterxml.jackson.annotation.JsonInclude; +import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; + +@Configuration +public class CoffeeCustomizerConfig { + + @Bean + public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() { + return builder -> builder.serializationInclusion(JsonInclude.Include.NON_NULL) + .serializers(localDateTimeSerializer); + } +} diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java new file mode 100644 index 0000000000..83474a5c1f --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java @@ -0,0 +1,21 @@ +package com.baeldung.boot.jackson.config; + +import com.fasterxml.jackson.annotation.JsonInclude; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; + +import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; + +@Configuration +public class CoffeeHttpConverterConfiguration { + + @Bean + public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() { + Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder() + .serializers(localDateTimeSerializer) + .serializationInclusion(JsonInclude.Include.NON_NULL); + return new MappingJackson2HttpMessageConverter(builder.build()); + } +} diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java new file mode 100644 index 0000000000..7a7b3e48bf --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java @@ -0,0 +1,21 @@ +package com.baeldung.boot.jackson.config; + +import com.fasterxml.jackson.annotation.JsonInclude; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; + +import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; + +@Configuration +public class CoffeeJacksonBuilderConfig { + + @Bean + @Primary + public Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder() { + return new Jackson2ObjectMapperBuilder() + .serializers(localDateTimeSerializer) + .serializationInclusion(JsonInclude.Include.NON_NULL); + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java new file mode 100644 index 0000000000..5697928cc5 --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java @@ -0,0 +1,24 @@ +package com.baeldung.boot.jackson.config; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; + +import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; + +@Configuration +public class CoffeeObjectMapperConfig { + + @Bean + @Primary + public ObjectMapper objectMapper() { + JavaTimeModule module = new JavaTimeModule(); + module.addSerializer(localDateTimeSerializer); + return new ObjectMapper() + .setSerializationInclusion(JsonInclude.Include.NON_NULL) + .registerModule(module); + } +} diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java new file mode 100644 index 0000000000..855bc84966 --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java @@ -0,0 +1,21 @@ +package com.baeldung.boot.jackson.config; + +import com.fasterxml.jackson.databind.Module; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; + +@Configuration +@PropertySource("classpath:coffee.properties") +public class CoffeeRegisterModuleConfig { + + @Bean + public Module javaTimeModule() { + JavaTimeModule module = new JavaTimeModule(); + module.addSerializer(localDateTimeSerializer); + return module; + } +} diff --git a/spring-boot-modules/spring-boot-jackson/src/main/resources/application.properties b/spring-boot-modules/spring-boot-jackson/src/main/resources/application.properties deleted file mode 100644 index 352add464b..0000000000 --- a/spring-boot-modules/spring-boot-jackson/src/main/resources/application.properties +++ /dev/null @@ -1,2 +0,0 @@ -spring.jackson.default-property-inclusion=non_null -spring.jackson.serialization.write-dates-as-timestamps=false \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-jackson/src/main/resources/coffee.properties b/spring-boot-modules/spring-boot-jackson/src/main/resources/coffee.properties new file mode 100644 index 0000000000..269845cbf1 --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/main/resources/coffee.properties @@ -0,0 +1 @@ +spring.jackson.default-property-inclusion=non_null \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/CoffeeIntegrationTest.java b/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/AbstractCoffeeIntegrationTest.java similarity index 81% rename from spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/CoffeeIntegrationTest.java rename to spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/AbstractCoffeeIntegrationTest.java index 1fda173d37..13e1f05f97 100644 --- a/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/CoffeeIntegrationTest.java +++ b/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/AbstractCoffeeIntegrationTest.java @@ -1,6 +1,6 @@ -package com.baeldung.boot.jackson; +package com.baeldung.boot.jackson.app; -import com.baeldung.boot.jackson.config.CoffeeConfiguration; +import com.baeldung.boot.jackson.config.CoffeeConstants; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -12,20 +12,20 @@ import java.time.format.DateTimeFormatter; import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -public class CoffeeIntegrationTest { +public abstract class AbstractCoffeeIntegrationTest { @Autowired - TestRestTemplate restTemplate; + protected TestRestTemplate restTemplate; @Test public void whenGetCoffee_thenSerializedWithDateAndNonNull() { - String formattedDate = DateTimeFormatter.ofPattern(CoffeeConfiguration.dateTimeFormat) + String formattedDate = DateTimeFormatter.ofPattern(CoffeeConstants.dateTimeFormat) .format(LocalDateTime.now()); + String brand = "Lavazza"; String url = "/coffee?brand=" + brand; String response = restTemplate.getForObject(url, String.class); - assertThat(response).isEqualTo( "{\"brand\":\"" + brand + "\",\"date\":\"" + formattedDate + "\"}"); } diff --git a/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeCustomizerIntegrationTest.java b/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeCustomizerIntegrationTest.java new file mode 100644 index 0000000000..d690de1b9c --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeCustomizerIntegrationTest.java @@ -0,0 +1,8 @@ +package com.baeldung.boot.jackson.app; + +import com.baeldung.boot.jackson.config.CoffeeCustomizerConfig; +import org.springframework.context.annotation.Import; + +@Import(CoffeeCustomizerConfig.class) +public class CoffeeCustomizerIntegrationTest extends AbstractCoffeeIntegrationTest { +} diff --git a/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeHttpConverterIntegrationTest.java b/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeHttpConverterIntegrationTest.java new file mode 100644 index 0000000000..62b1d42152 --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeHttpConverterIntegrationTest.java @@ -0,0 +1,8 @@ +package com.baeldung.boot.jackson.app; + +import com.baeldung.boot.jackson.config.CoffeeHttpConverterConfiguration; +import org.springframework.context.annotation.Import; + +@Import(CoffeeHttpConverterConfiguration.class) +public class CoffeeHttpConverterIntegrationTest extends AbstractCoffeeIntegrationTest { +} diff --git a/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeJacksonBuilderIntegrationTest.java b/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeJacksonBuilderIntegrationTest.java new file mode 100644 index 0000000000..52a55394c0 --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeJacksonBuilderIntegrationTest.java @@ -0,0 +1,8 @@ +package com.baeldung.boot.jackson.app; + +import com.baeldung.boot.jackson.config.CoffeeJacksonBuilderConfig; +import org.springframework.context.annotation.Import; + +@Import(CoffeeJacksonBuilderConfig.class) +public class CoffeeJacksonBuilderIntegrationTest extends AbstractCoffeeIntegrationTest { +} diff --git a/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeObjectMapperIntegrationTest.java b/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeObjectMapperIntegrationTest.java new file mode 100644 index 0000000000..34743ceba5 --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeObjectMapperIntegrationTest.java @@ -0,0 +1,8 @@ +package com.baeldung.boot.jackson.app; + +import com.baeldung.boot.jackson.config.CoffeeObjectMapperConfig; +import org.springframework.context.annotation.Import; + +@Import(CoffeeObjectMapperConfig.class) +public class CoffeeObjectMapperIntegrationTest extends AbstractCoffeeIntegrationTest { +} diff --git a/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeRegisterModuleIntegrationTest.java b/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeRegisterModuleIntegrationTest.java new file mode 100644 index 0000000000..69bbd5be2a --- /dev/null +++ b/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeRegisterModuleIntegrationTest.java @@ -0,0 +1,8 @@ +package com.baeldung.boot.jackson.app; + +import com.baeldung.boot.jackson.config.CoffeeRegisterModuleConfig; +import org.springframework.context.annotation.Import; + +@Import(CoffeeRegisterModuleConfig.class) +public class CoffeeRegisterModuleIntegrationTest extends AbstractCoffeeIntegrationTest { +} From 003a5f203419f19c3a4a0f023ada288ea982d2e6 Mon Sep 17 00:00:00 2001 From: Adina Rolea Date: Mon, 16 Nov 2020 14:29:46 +0200 Subject: [PATCH 13/43] BAEL-4687: updated parent --- spring-boot-modules/spring-boot-jackson/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-boot-modules/spring-boot-jackson/pom.xml b/spring-boot-modules/spring-boot-jackson/pom.xml index b502bca908..1b2e55839a 100644 --- a/spring-boot-modules/spring-boot-jackson/pom.xml +++ b/spring-boot-modules/spring-boot-jackson/pom.xml @@ -3,10 +3,10 @@ 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"> - parent-boot-2 - com.baeldung - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ 4.0.0 From cc1a2e9b15892f181240e867481335527dee8a00 Mon Sep 17 00:00:00 2001 From: Daniel Strmecki Date: Mon, 16 Nov 2020 16:02:18 +0100 Subject: [PATCH 14/43] BAEL-4717: Added HashMap and LinkedList examples --- .../comparation/ArrayListUnitTest.java | 5 ++- .../comparation/HashMapUnitTest.java | 31 ++++++++++++++ .../comparation/LinkedListUnitTest.java | 41 +++++++++++++++++++ .../comparation/ListVsMapUnitTest.java | 2 + 4 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/HashMapUnitTest.java create mode 100644 core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/LinkedListUnitTest.java diff --git a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ArrayListUnitTest.java b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ArrayListUnitTest.java index 935be19e74..4041ff1637 100644 --- a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ArrayListUnitTest.java +++ b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ArrayListUnitTest.java @@ -11,7 +11,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class ArrayListUnitTest { @Test - void givenList_whenItemAddedToSpecificIndex_thenItCanBeRetrieved() { + void givenArrayList_whenItemAddedToSpecificIndex_thenItCanBeRetrieved() { List list = new ArrayList<>(); list.add("Daniel"); list.add(1, "Marko"); @@ -20,10 +20,11 @@ public class ArrayListUnitTest { } @Test - void givenList_whenItemRemovedViaIndex_thenListSizeIsReduced() { + void givenArrayList_whenItemRemovedViaIndex_thenListSizeIsReduced() { List list = new ArrayList<>(Arrays.asList("Daniel", "Marko")); list.remove(1); assertThat(list).hasSize(1); + assertThat(list).doesNotContain("Marko"); } } diff --git a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/HashMapUnitTest.java b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/HashMapUnitTest.java new file mode 100644 index 0000000000..3b595472e0 --- /dev/null +++ b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/HashMapUnitTest.java @@ -0,0 +1,31 @@ +package com.baeldung.collections.comparation; + +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; + +public class HashMapUnitTest { + + @Test + void givenHashMap_whenItemAddedByKey_thenItCanBeRetrieved() { + Map map = new HashMap<>(); + map.put("123456", "Daniel"); + map.put("654321", "Marko"); + assertThat(map.get("654321")).isEqualTo("Marko"); + } + + @Test + void givenHashMap_whenItemRemovedByKey_thenMapSizeIsReduced() { + Map map = new HashMap<>(); + map.put("123456", "Daniel"); + map.put("654321", "Marko"); + map.remove("654321"); + assertThat(map).hasSize(1); + } + +} diff --git a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/LinkedListUnitTest.java b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/LinkedListUnitTest.java new file mode 100644 index 0000000000..c2ab554c91 --- /dev/null +++ b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/LinkedListUnitTest.java @@ -0,0 +1,41 @@ +package com.baeldung.collections.comparation; + +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class LinkedListUnitTest { + + @Test + void givenLinkedList_whenItemIsAppended_thenItCanBeRetrieved() { + LinkedList list = new LinkedList<>(); + list.addLast("Daniel"); + list.addFirst( "Marko"); + assertThat(list).hasSize(2); + assertThat(list.getLast()).isEqualTo("Daniel"); + } + + @Test + void givenLinkedList_whenItemIsRemoved_thenListSizeIsReduced() { + LinkedList list = new LinkedList<>(Arrays.asList("Daniel", "Marko", "David")); + list.removeFirst(); + list.removeLast(); + assertThat(list).hasSize(1); + assertThat(list).containsExactly("Marko"); + } + + @Test + void givenLinkedList_whenItemInserted_thenItCanBeRetrievedAndDeleted() { + LinkedList list = new LinkedList<>(); + list.push("Daniel"); + list.push("Marko"); + assertThat(list.poll()).isEqualTo("Marko"); + assertThat(list).hasSize(1); + } + +} diff --git a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ListVsMapUnitTest.java b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ListVsMapUnitTest.java index 6507013fbf..dd6bf760fd 100644 --- a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ListVsMapUnitTest.java +++ b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ListVsMapUnitTest.java @@ -15,6 +15,7 @@ class ListVsMapUnitTest { for (String name : list) { assertThat(name).isIn(list); } + assertThat(list).containsExactly("Daniel", "Marko"); } @Test @@ -25,6 +26,7 @@ class ListVsMapUnitTest { for (String name : map.values()) { assertThat(name).isIn(map.values()); } + assertThat(map.values()).containsExactlyInAnyOrder("Daniel", "Marko"); } } From 79fc666e0709f947a2b0eaa33ffe49f95a05ffe3 Mon Sep 17 00:00:00 2001 From: Daniel Strmecki Date: Tue, 17 Nov 2020 11:00:56 +0100 Subject: [PATCH 15/43] BAEL-4717: Refactor examples --- .../baeldung/collections/comparation/ArrayListUnitTest.java | 4 ++-- .../baeldung/collections/comparation/LinkedListUnitTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ArrayListUnitTest.java b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ArrayListUnitTest.java index 4041ff1637..bc6a07d274 100644 --- a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ArrayListUnitTest.java +++ b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/ArrayListUnitTest.java @@ -14,9 +14,9 @@ public class ArrayListUnitTest { void givenArrayList_whenItemAddedToSpecificIndex_thenItCanBeRetrieved() { List list = new ArrayList<>(); list.add("Daniel"); - list.add(1, "Marko"); + list.add(0, "Marko"); assertThat(list).hasSize(2); - assertThat(list.get(1)).isEqualTo("Marko"); + assertThat(list.get(0)).isEqualTo("Marko"); } @Test diff --git a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/LinkedListUnitTest.java b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/LinkedListUnitTest.java index c2ab554c91..aa6b7fa923 100644 --- a/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/LinkedListUnitTest.java +++ b/core-java-modules/core-java-collections-4/src/test/java/com/baeldung/collections/comparation/LinkedListUnitTest.java @@ -15,7 +15,7 @@ public class LinkedListUnitTest { void givenLinkedList_whenItemIsAppended_thenItCanBeRetrieved() { LinkedList list = new LinkedList<>(); list.addLast("Daniel"); - list.addFirst( "Marko"); + list.addFirst("Marko"); assertThat(list).hasSize(2); assertThat(list.getLast()).isEqualTo("Daniel"); } From f3d390b6844ad2374d0aaa477a5e7c465578b890 Mon Sep 17 00:00:00 2001 From: Adrian Maghear Date: Sat, 28 Nov 2020 14:14:20 +0100 Subject: [PATCH 16/43] initial commit --- spring-cloud/spring-cloud-eureka/pom.xml | 1 + .../pom.xml | 86 +++++++++++++++++++ .../baeldung/spring/cloud/Application.java | 15 ++++ .../spring/cloud/client/BooksClient.java | 16 ++++ .../com/baeldung/spring/cloud/model/Book.java | 15 ++++ .../src/main/resources/application.yml | 12 +++ .../client/BooksClientIntegrationTest.java | 49 +++++++++++ .../cloud/client/EurekaContainerConfig.java | 34 ++++++++ .../client/GreetingClientIntegrationTest.java | 54 ++++++++++++ .../cloud/client/MockBookServiceConfig.java | 31 +++++++ .../spring/cloud/client/WireMockConfig.java | 29 +++++++ .../src/test/resources/application-test.yml | 21 +++++ .../resources/payload/get-books-response.json | 10 +++ 13 files changed, 373 insertions(+) create mode 100644 spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/pom.xml create mode 100644 spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/main/java/com/baeldung/spring/cloud/Application.java create mode 100644 spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/main/java/com/baeldung/spring/cloud/client/BooksClient.java create mode 100644 spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/main/java/com/baeldung/spring/cloud/model/Book.java create mode 100644 spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/main/resources/application.yml create mode 100644 spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/BooksClientIntegrationTest.java create mode 100644 spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/EurekaContainerConfig.java create mode 100644 spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/GreetingClientIntegrationTest.java create mode 100644 spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/MockBookServiceConfig.java create mode 100644 spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/WireMockConfig.java create mode 100644 spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-test.yml create mode 100644 spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/payload/get-books-response.json diff --git a/spring-cloud/spring-cloud-eureka/pom.xml b/spring-cloud/spring-cloud-eureka/pom.xml index 7af0c15352..9d7350e774 100644 --- a/spring-cloud/spring-cloud-eureka/pom.xml +++ b/spring-cloud/spring-cloud-eureka/pom.xml @@ -19,6 +19,7 @@ spring-cloud-eureka-server spring-cloud-eureka-client spring-cloud-eureka-feign-client + spring-cloud-eureka-feign-client-integration-test diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/pom.xml b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/pom.xml new file mode 100644 index 0000000000..09edb89dfe --- /dev/null +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/pom.xml @@ -0,0 +1,86 @@ + + + 4.0.0 + spring-cloud-eureka-feign-client-integration-test + 1.0.0-SNAPSHOT + spring-cloud-eureka-feign-client-integration-test + jar + Spring Cloud Eureka - Feign Client Integration Tests + + + com.baeldung.spring.cloud + spring-cloud-eureka + 1.0.0-SNAPSHOT + + + + + + org.junit + junit-bom + ${junit-jupiter.version} + pom + import + + + org.springframework.cloud + spring-cloud-starter-parent + ${spring-cloud-dependencies.version} + pom + import + + + + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + + + + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + org.springframework.boot + spring-boot-starter-web + + + + com.github.tomakehurst + wiremock + 2.27.2 + test + + + + + org.projectlombok + lombok + + + + org.testcontainers + testcontainers + 1.14.3 + test + + + + org.awaitility + awaitility + 4.0.3 + test + + + + + + diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/main/java/com/baeldung/spring/cloud/Application.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/main/java/com/baeldung/spring/cloud/Application.java new file mode 100644 index 0000000000..342e7e163b --- /dev/null +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/main/java/com/baeldung/spring/cloud/Application.java @@ -0,0 +1,15 @@ +package com.baeldung.spring.cloud; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; + +@EnableFeignClients +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/main/java/com/baeldung/spring/cloud/client/BooksClient.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/main/java/com/baeldung/spring/cloud/client/BooksClient.java new file mode 100644 index 0000000000..b3abe58e3c --- /dev/null +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/main/java/com/baeldung/spring/cloud/client/BooksClient.java @@ -0,0 +1,16 @@ +package com.baeldung.spring.cloud.client; + +import com.baeldung.spring.cloud.model.Book; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.RequestMapping; + +import java.util.List; + +//@FeignClient(value="simple-books-client", url="${book.service.url}") +@FeignClient("books-client") +public interface BooksClient { + + @RequestMapping("/books") + List getBooks(); + +} diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/main/java/com/baeldung/spring/cloud/model/Book.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/main/java/com/baeldung/spring/cloud/model/Book.java new file mode 100644 index 0000000000..64492f678d --- /dev/null +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/main/java/com/baeldung/spring/cloud/model/Book.java @@ -0,0 +1,15 @@ +package com.baeldung.spring.cloud.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Book { + + private String title; + private String author; + +} diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/main/resources/application.yml b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/main/resources/application.yml new file mode 100644 index 0000000000..dba4752ef9 --- /dev/null +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/main/resources/application.yml @@ -0,0 +1,12 @@ +#book: +# service: +# url: http://book.service.com + +books-client: + ribbon: + eureka: + enabled: false + listOfServers: http://book.service.com + ServerListRefreshInterval: 15000 + MaxAutoRetries: 3 + retryableStatusCodes: 503, 408 \ No newline at end of file diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/BooksClientIntegrationTest.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/BooksClientIntegrationTest.java new file mode 100644 index 0000000000..594b3e785a --- /dev/null +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/BooksClientIntegrationTest.java @@ -0,0 +1,49 @@ +package com.baeldung.spring.cloud.client; + +import com.baeldung.spring.cloud.Application; +import com.baeldung.spring.cloud.model.Book; +import com.netflix.discovery.EurekaClient; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Lazy; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +import java.util.List; + +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.awaitility.Awaitility.await; +import static org.junit.jupiter.api.Assertions.assertTrue; + +@ActiveProfiles("test") +@EnableConfigurationProperties +@ExtendWith(SpringExtension.class) +@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ContextConfiguration(classes = {MockBookServiceConfig.class}, initializers = {EurekaContainerConfig.Initializer.class}) +class BooksClientIntegrationTest { + + @Autowired + private BooksClient booksClient; + + @Autowired + @Lazy + private EurekaClient eurekaClient; + + @BeforeEach + void setUp() { + await().atMost(60, SECONDS).until(() -> eurekaClient.getApplications().size() > 0); + } + + @Test + public void whenGetBooks_thenListBooksSizeGreaterThanZero() throws InterruptedException { + List books = booksClient.getBooks(); + + assertTrue(books.size() == 1); + } + +} \ No newline at end of file diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/EurekaContainerConfig.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/EurekaContainerConfig.java new file mode 100644 index 0000000000..3e85a791f7 --- /dev/null +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/EurekaContainerConfig.java @@ -0,0 +1,34 @@ +package com.baeldung.spring.cloud.client; + +import org.jetbrains.annotations.NotNull; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.test.util.TestPropertyValues; +import org.springframework.context.ApplicationContextInitializer; +import org.springframework.context.ConfigurableApplicationContext; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.lifecycle.Startables; + +import java.util.stream.Stream; + +public class EurekaContainerConfig { + + public static class Initializer implements ApplicationContextInitializer { + + public static GenericContainer eurekaServer + = new GenericContainer("springcloud/eureka") + .withExposedPorts(8761); + + @Override + public void initialize(@NotNull ConfigurableApplicationContext configurableApplicationContext) { + + Startables.deepStart(Stream.of(eurekaServer)).join(); + + TestPropertyValues + .of("eureka.client.serviceUrl.defaultZone=http://localhost:" + eurekaServer.getFirstMappedPort().toString() + "/eureka") + .applyTo(configurableApplicationContext); + + } + + } + +} diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/GreetingClientIntegrationTest.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/GreetingClientIntegrationTest.java new file mode 100644 index 0000000000..c743931dae --- /dev/null +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/GreetingClientIntegrationTest.java @@ -0,0 +1,54 @@ +package com.baeldung.spring.cloud.client; + +import com.baeldung.spring.cloud.model.Book; +import com.github.tomakehurst.wiremock.WireMockServer; +import com.github.tomakehurst.wiremock.client.WireMock; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.util.StreamUtils; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.List; + +import static org.junit.Assert.assertFalse; + +@SpringBootTest +@ActiveProfiles("test") +@EnableConfigurationProperties +@ExtendWith(SpringExtension.class) +@ContextConfiguration(classes = {WireMockConfig.class}) +class GreetingClientIntegrationTest { + + @Autowired + private WireMockServer wireMockServer; + + @Autowired + private BooksClient booksClient; + + @BeforeEach + void setUp() throws IOException { + wireMockServer.stubFor(WireMock.get(WireMock.urlEqualTo("/books")) + .willReturn(WireMock.aResponse() + .withStatus(HttpStatus.OK.value()) + .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) + .withBody(StreamUtils.copyToString(getClass().getClassLoader().getResourceAsStream("payload/get-books-response.json"), Charset.defaultCharset())))); + } + + @Test + public void whenGetBooks_thenListBooksSizeGreaterThanZero() { + List books = booksClient.getBooks(); + + assertFalse(books.isEmpty()); + } + +} \ No newline at end of file diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/MockBookServiceConfig.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/MockBookServiceConfig.java new file mode 100644 index 0000000000..d33c6a311b --- /dev/null +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/MockBookServiceConfig.java @@ -0,0 +1,31 @@ +package com.baeldung.spring.cloud.client; + +import com.baeldung.spring.cloud.model.Book; +import com.github.tomakehurst.wiremock.WireMockServer; +import com.netflix.loadbalancer.Server; +import com.netflix.loadbalancer.ServerList; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.cloud.netflix.ribbon.StaticServerList; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Collections; +import java.util.List; + +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; + +@Configuration +@EnableAutoConfiguration +@RestController +public class MockBookServiceConfig { + + @RequestMapping("/books") + public List getBooks() { + return Collections.singletonList(new Book("some title", "some author")); + } + +} diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/WireMockConfig.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/WireMockConfig.java new file mode 100644 index 0000000000..136dd391ca --- /dev/null +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/WireMockConfig.java @@ -0,0 +1,29 @@ +package com.baeldung.spring.cloud.client; + +import com.github.tomakehurst.wiremock.WireMockServer; +import com.netflix.loadbalancer.Server; +import com.netflix.loadbalancer.ServerList; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.cloud.netflix.ribbon.StaticServerList; +import org.springframework.context.annotation.Bean; + +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; + +@TestConfiguration +public class WireMockConfig { + + @Autowired + private WireMockServer wireMockServer; + + @Bean(initMethod = "start", destroyMethod = "stop") + public WireMockServer booksMockService() { + return new WireMockServer(options().dynamicPort()); + } + + @Bean + public ServerList ribbonServerList() { + return new StaticServerList<>(new Server("localhost", wireMockServer.port())); + } + +} diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-test.yml b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-test.yml new file mode 100644 index 0000000000..3e04a54cbc --- /dev/null +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-test.yml @@ -0,0 +1,21 @@ +#book: +# service: +# url: http://localhost:9561 + +#books-client: +# ribbon: +# listOfServers: http://localhost:9561 + +spring: + application: + name: books-client + +server: + port: 0 + +eureka: + client: + serviceUrl: + defaultZone: ${EUREKA_URI:http://localhost:8761/eureka} + instance: + preferIpAddress: true \ No newline at end of file diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/payload/get-books-response.json b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/payload/get-books-response.json new file mode 100644 index 0000000000..373dc15926 --- /dev/null +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/payload/get-books-response.json @@ -0,0 +1,10 @@ +[ + { + "title": "Dune", + "author": "Frank Herbert" + }, + { + "title": "Foundation", + "author": "Isaac Asimov" + } +] \ No newline at end of file From e67b1f95a87a532ce8a9710add1553c43df527d5 Mon Sep 17 00:00:00 2001 From: Adrian Maghear Date: Sat, 28 Nov 2020 23:38:06 +0100 Subject: [PATCH 17/43] solve port conflict during integration tests --- .../pom.xml | 12 ++++++++++++ .../spring/cloud/client/EurekaContainerConfig.java | 4 ++++ .../LoadBalancerBooksClientIntegrationTest.java | 2 +- .../spring/cloud/client/RibbonTestConfig.java | 9 ++++++++- ... ServiceDiscoveryBooksClientIntegrationTest.java} | 2 +- .../baeldung/spring/cloud/client/WireMockConfig.java | 2 ++ .../src/test/resources/application-ribbon-test.yml | 3 +++ 7 files changed, 31 insertions(+), 3 deletions(-) rename spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/{EurekaBooksClientIntegrationTest.java => ServiceDiscoveryBooksClientIntegrationTest.java} (97%) create mode 100644 spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-ribbon-test.yml diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/pom.xml b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/pom.xml index 90aae719d6..3348dbb24f 100644 --- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/pom.xml +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/pom.xml @@ -82,4 +82,16 @@ + + + + maven-surefire-plugin + + 1 + true + + + + + diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/EurekaContainerConfig.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/EurekaContainerConfig.java index ed004e43d2..6747d14b88 100644 --- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/EurekaContainerConfig.java +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/EurekaContainerConfig.java @@ -1,14 +1,18 @@ package com.baeldung.spring.cloud.client; import org.jetbrains.annotations.NotNull; +import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.test.context.ActiveProfiles; import org.testcontainers.containers.GenericContainer; import org.testcontainers.lifecycle.Startables; import java.util.stream.Stream; +@TestConfiguration +@ActiveProfiles("eureka-test") public class EurekaContainerConfig { public static class Initializer implements ApplicationContextInitializer { diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/LoadBalancerBooksClientIntegrationTest.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/LoadBalancerBooksClientIntegrationTest.java index d3284fa197..46159d53a9 100644 --- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/LoadBalancerBooksClientIntegrationTest.java +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/LoadBalancerBooksClientIntegrationTest.java @@ -22,7 +22,7 @@ import static java.util.Arrays.asList; import static org.junit.jupiter.api.Assertions.assertTrue; @SpringBootTest -@ActiveProfiles("test") +@ActiveProfiles("ribbon-test") @EnableConfigurationProperties @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { RibbonTestConfig.class }) diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/RibbonTestConfig.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/RibbonTestConfig.java index ac3bae1a3d..273ba182b1 100644 --- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/RibbonTestConfig.java +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/RibbonTestConfig.java @@ -7,11 +7,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.cloud.netflix.ribbon.StaticServerList; import org.springframework.context.annotation.Bean; +import org.springframework.test.context.ActiveProfiles; import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options; @TestConfiguration -public class RibbonTestConfig extends WireMockConfig { +@ActiveProfiles("ribbon-test") +public class RibbonTestConfig { @Autowired private WireMockServer mockBooksService; @@ -19,6 +21,11 @@ public class RibbonTestConfig extends WireMockConfig { @Autowired private WireMockServer secondMockBooksService; + @Bean(initMethod = "start", destroyMethod = "stop") + public WireMockServer mockBooksService() { + return new WireMockServer(options().dynamicPort()); + } + @Bean(name="secondMockBooksService", initMethod = "start", destroyMethod = "stop") public WireMockServer secondBooksMockService() { return new WireMockServer(options().dynamicPort()); diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/EurekaBooksClientIntegrationTest.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/ServiceDiscoveryBooksClientIntegrationTest.java similarity index 97% rename from spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/EurekaBooksClientIntegrationTest.java rename to spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/ServiceDiscoveryBooksClientIntegrationTest.java index 89f598ba56..f2c3fde469 100644 --- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/EurekaBooksClientIntegrationTest.java +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/ServiceDiscoveryBooksClientIntegrationTest.java @@ -25,7 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; @ExtendWith(SpringExtension.class) @SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ContextConfiguration(classes = { MockBookServiceConfig.class }, initializers = { EurekaContainerConfig.Initializer.class }) -class EurekaBooksClientIntegrationTest { +class ServiceDiscoveryBooksClientIntegrationTest { @Autowired private BooksClient booksClient; diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/WireMockConfig.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/WireMockConfig.java index 30421abc78..82b7cddede 100644 --- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/WireMockConfig.java +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/WireMockConfig.java @@ -3,8 +3,10 @@ package com.baeldung.spring.cloud.client; import com.github.tomakehurst.wiremock.WireMockServer; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; +import org.springframework.test.context.ActiveProfiles; @TestConfiguration +@ActiveProfiles("test") public class WireMockConfig { @Bean(initMethod = "start", destroyMethod = "stop") diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-ribbon-test.yml b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-ribbon-test.yml new file mode 100644 index 0000000000..5fde57fd8a --- /dev/null +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-ribbon-test.yml @@ -0,0 +1,3 @@ +eureka: + client: + enabled: false \ No newline at end of file From b6ff72353300feea81dccebecdf617c118ee2079 Mon Sep 17 00:00:00 2001 From: Adrian Maghear Date: Sat, 28 Nov 2020 23:44:06 +0100 Subject: [PATCH 18/43] add newlines at end of files --- .../spring/cloud/client/BooksClientIntegrationTest.java | 2 +- .../cloud/client/LoadBalancerBooksClientIntegrationTest.java | 2 +- .../client/ServiceDiscoveryBooksClientIntegrationTest.java | 2 +- .../src/test/resources/application-eureka-test.yml | 2 +- .../src/test/resources/application-ribbon-test.yml | 2 +- .../src/test/resources/application-test.yml | 2 +- .../src/test/resources/payload/get-books-response.json | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/BooksClientIntegrationTest.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/BooksClientIntegrationTest.java index b1df99ee5e..2842eef435 100644 --- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/BooksClientIntegrationTest.java +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/BooksClientIntegrationTest.java @@ -50,4 +50,4 @@ class BooksClientIntegrationTest { new Book("Foundation", "Isaac Asimov")))); } -} \ No newline at end of file +} diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/LoadBalancerBooksClientIntegrationTest.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/LoadBalancerBooksClientIntegrationTest.java index 46159d53a9..f05df11ba3 100644 --- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/LoadBalancerBooksClientIntegrationTest.java +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/LoadBalancerBooksClientIntegrationTest.java @@ -62,4 +62,4 @@ class LoadBalancerBooksClientIntegrationTest { new Book("Dune", "Frank Herbert"), new Book("Foundation", "Isaac Asimov")))); } -} \ No newline at end of file +} diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/ServiceDiscoveryBooksClientIntegrationTest.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/ServiceDiscoveryBooksClientIntegrationTest.java index f2c3fde469..027579d20d 100644 --- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/ServiceDiscoveryBooksClientIntegrationTest.java +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/ServiceDiscoveryBooksClientIntegrationTest.java @@ -49,4 +49,4 @@ class ServiceDiscoveryBooksClientIntegrationTest { books.stream().findFirst().get()); } -} \ No newline at end of file +} diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-eureka-test.yml b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-eureka-test.yml index c34a79c838..6f6af6a080 100644 --- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-eureka-test.yml +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-eureka-test.yml @@ -1,3 +1,3 @@ spring: application: - name: books-service \ No newline at end of file + name: books-service diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-ribbon-test.yml b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-ribbon-test.yml index 5fde57fd8a..84a78d0ec7 100644 --- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-ribbon-test.yml +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-ribbon-test.yml @@ -1,3 +1,3 @@ eureka: client: - enabled: false \ No newline at end of file + enabled: false diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-test.yml b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-test.yml index b5a318c659..dce11adf69 100644 --- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-test.yml +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/application-test.yml @@ -8,4 +8,4 @@ books-service: eureka: client: - enabled: false \ No newline at end of file + enabled: false diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/payload/get-books-response.json b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/payload/get-books-response.json index 373dc15926..b4223ff8f2 100644 --- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/payload/get-books-response.json +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/resources/payload/get-books-response.json @@ -7,4 +7,4 @@ "title": "Foundation", "author": "Isaac Asimov" } -] \ No newline at end of file +] From c19b868d3b92fd2911ea9b5a89e21677550294b4 Mon Sep 17 00:00:00 2001 From: Adina Rolea Date: Fri, 4 Dec 2020 19:55:44 +0200 Subject: [PATCH 19/43] BAEL-4687: renamed project from jackson to data 2 --- spring-boot-modules/pom.xml | 2 +- .../{spring-boot-jackson => spring-boot-data-2}/pom.xml | 6 +++--- .../java/com/baeldung/boot/jackson/app/Application.java | 0 .../com/baeldung/boot/jackson/config/CoffeeConstants.java | 0 .../boot/jackson/config/CoffeeCustomizerConfig.java | 0 .../jackson/config/CoffeeHttpConverterConfiguration.java | 0 .../boot/jackson/config/CoffeeJacksonBuilderConfig.java | 0 .../boot/jackson/config/CoffeeObjectMapperConfig.java | 0 .../boot/jackson/config/CoffeeRegisterModuleConfig.java | 0 .../baeldung/boot/jackson/controller/CoffeeController.java | 0 .../main/java/com/baeldung/boot/jackson/model/Coffee.java | 0 .../src/main/resources/coffee.properties | 0 .../boot/jackson/app/AbstractCoffeeIntegrationTest.java | 0 .../boot/jackson/app/CoffeeCustomizerIntegrationTest.java | 0 .../jackson/app/CoffeeHttpConverterIntegrationTest.java | 0 .../jackson/app/CoffeeJacksonBuilderIntegrationTest.java | 0 .../boot/jackson/app/CoffeeObjectMapperIntegrationTest.java | 0 .../jackson/app/CoffeeRegisterModuleIntegrationTest.java | 0 18 files changed, 4 insertions(+), 4 deletions(-) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/pom.xml (79%) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/src/main/java/com/baeldung/boot/jackson/app/Application.java (100%) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java (100%) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java (100%) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java (100%) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java (100%) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java (100%) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java (100%) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java (100%) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/src/main/java/com/baeldung/boot/jackson/model/Coffee.java (100%) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/src/main/resources/coffee.properties (100%) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/src/test/java/com/baeldung/boot/jackson/app/AbstractCoffeeIntegrationTest.java (100%) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/src/test/java/com/baeldung/boot/jackson/app/CoffeeCustomizerIntegrationTest.java (100%) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/src/test/java/com/baeldung/boot/jackson/app/CoffeeHttpConverterIntegrationTest.java (100%) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/src/test/java/com/baeldung/boot/jackson/app/CoffeeJacksonBuilderIntegrationTest.java (100%) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/src/test/java/com/baeldung/boot/jackson/app/CoffeeObjectMapperIntegrationTest.java (100%) rename spring-boot-modules/{spring-boot-jackson => spring-boot-data-2}/src/test/java/com/baeldung/boot/jackson/app/CoffeeRegisterModuleIntegrationTest.java (100%) diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 3d721d7147..4ff825309a 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -68,7 +68,7 @@ spring-boot-vue spring-boot-xml spring-boot-actuator - spring-boot-jackson + spring-boot-data-2 diff --git a/spring-boot-modules/spring-boot-jackson/pom.xml b/spring-boot-modules/spring-boot-data-2/pom.xml similarity index 79% rename from spring-boot-modules/spring-boot-jackson/pom.xml rename to spring-boot-modules/spring-boot-data-2/pom.xml index 1b2e55839a..199a204500 100644 --- a/spring-boot-modules/spring-boot-jackson/pom.xml +++ b/spring-boot-modules/spring-boot-data-2/pom.xml @@ -1,6 +1,6 @@ - com.baeldung.spring-boot-modules @@ -10,7 +10,7 @@ 4.0.0 - spring-boot-jackson + spring-boot-data-2 org.springframework.boot diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/app/Application.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/app/Application.java similarity index 100% rename from spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/app/Application.java rename to spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/app/Application.java diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java similarity index 100% rename from spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java rename to spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java similarity index 100% rename from spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java rename to spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java similarity index 100% rename from spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java rename to spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java similarity index 100% rename from spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java rename to spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java similarity index 100% rename from spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java rename to spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java similarity index 100% rename from spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java rename to spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java similarity index 100% rename from spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java rename to spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java diff --git a/spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/Coffee.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/model/Coffee.java similarity index 100% rename from spring-boot-modules/spring-boot-jackson/src/main/java/com/baeldung/boot/jackson/model/Coffee.java rename to spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/model/Coffee.java diff --git a/spring-boot-modules/spring-boot-jackson/src/main/resources/coffee.properties b/spring-boot-modules/spring-boot-data-2/src/main/resources/coffee.properties similarity index 100% rename from spring-boot-modules/spring-boot-jackson/src/main/resources/coffee.properties rename to spring-boot-modules/spring-boot-data-2/src/main/resources/coffee.properties diff --git a/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/AbstractCoffeeIntegrationTest.java b/spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/boot/jackson/app/AbstractCoffeeIntegrationTest.java similarity index 100% rename from spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/AbstractCoffeeIntegrationTest.java rename to spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/boot/jackson/app/AbstractCoffeeIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeCustomizerIntegrationTest.java b/spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/boot/jackson/app/CoffeeCustomizerIntegrationTest.java similarity index 100% rename from spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeCustomizerIntegrationTest.java rename to spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/boot/jackson/app/CoffeeCustomizerIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeHttpConverterIntegrationTest.java b/spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/boot/jackson/app/CoffeeHttpConverterIntegrationTest.java similarity index 100% rename from spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeHttpConverterIntegrationTest.java rename to spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/boot/jackson/app/CoffeeHttpConverterIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeJacksonBuilderIntegrationTest.java b/spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/boot/jackson/app/CoffeeJacksonBuilderIntegrationTest.java similarity index 100% rename from spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeJacksonBuilderIntegrationTest.java rename to spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/boot/jackson/app/CoffeeJacksonBuilderIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeObjectMapperIntegrationTest.java b/spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/boot/jackson/app/CoffeeObjectMapperIntegrationTest.java similarity index 100% rename from spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeObjectMapperIntegrationTest.java rename to spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/boot/jackson/app/CoffeeObjectMapperIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeRegisterModuleIntegrationTest.java b/spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/boot/jackson/app/CoffeeRegisterModuleIntegrationTest.java similarity index 100% rename from spring-boot-modules/spring-boot-jackson/src/test/java/com/baeldung/boot/jackson/app/CoffeeRegisterModuleIntegrationTest.java rename to spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/boot/jackson/app/CoffeeRegisterModuleIntegrationTest.java From 65e9e80f0c0f1ccefbfe858eed02e52ca0d62682 Mon Sep 17 00:00:00 2001 From: Adina Rolea Date: Fri, 4 Dec 2020 20:01:12 +0200 Subject: [PATCH 20/43] BAEL-4687: formatted code with eclipse formatter --- .../boot/jackson/config/CoffeeConstants.java | 4 ++-- .../jackson/config/CoffeeCustomizerConfig.java | 5 +++-- .../config/CoffeeHttpConverterConfiguration.java | 5 +++-- .../config/CoffeeJacksonBuilderConfig.java | 5 +++-- .../jackson/config/CoffeeObjectMapperConfig.java | 14 +++++++------- .../config/CoffeeRegisterModuleConfig.java | 7 ++++--- .../boot/jackson/controller/CoffeeController.java | 15 +++++++-------- 7 files changed, 29 insertions(+), 26 deletions(-) diff --git a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java index 7e7d7b8bc2..90cad011ae 100644 --- a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java +++ b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java @@ -1,9 +1,9 @@ package com.baeldung.boot.jackson.config; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; - import java.time.format.DateTimeFormatter; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; + public class CoffeeConstants { public static final String dateTimeFormat = "dd-MM-yyyy HH:mm"; diff --git a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java index c13615e702..363c67fd9a 100644 --- a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java +++ b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java @@ -1,11 +1,12 @@ package com.baeldung.boot.jackson.config; -import com.fasterxml.jackson.annotation.JsonInclude; +import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; + import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; +import com.fasterxml.jackson.annotation.JsonInclude; @Configuration public class CoffeeCustomizerConfig { diff --git a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java index 83474a5c1f..b67f215816 100644 --- a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java +++ b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java @@ -1,12 +1,13 @@ package com.baeldung.boot.jackson.config; -import com.fasterxml.jackson.annotation.JsonInclude; +import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; + import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; +import com.fasterxml.jackson.annotation.JsonInclude; @Configuration public class CoffeeHttpConverterConfiguration { diff --git a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java index 7a7b3e48bf..ec4de1d353 100644 --- a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java +++ b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java @@ -1,12 +1,13 @@ package com.baeldung.boot.jackson.config; -import com.fasterxml.jackson.annotation.JsonInclude; +import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; + import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; -import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; +import com.fasterxml.jackson.annotation.JsonInclude; @Configuration public class CoffeeJacksonBuilderConfig { diff --git a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java index 5697928cc5..3754de018a 100644 --- a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java +++ b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java @@ -1,13 +1,14 @@ package com.baeldung.boot.jackson.config; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; + import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; -import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; @Configuration public class CoffeeObjectMapperConfig { @@ -17,8 +18,7 @@ public class CoffeeObjectMapperConfig { public ObjectMapper objectMapper() { JavaTimeModule module = new JavaTimeModule(); module.addSerializer(localDateTimeSerializer); - return new ObjectMapper() - .setSerializationInclusion(JsonInclude.Include.NON_NULL) - .registerModule(module); + return new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL) + .registerModule(module); } } diff --git a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java index 855bc84966..ea00e5a58e 100644 --- a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java +++ b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java @@ -1,12 +1,13 @@ package com.baeldung.boot.jackson.config; -import com.fasterxml.jackson.databind.Module; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; + import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; +import com.fasterxml.jackson.databind.Module; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; @Configuration @PropertySource("classpath:coffee.properties") diff --git a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java index 075126de67..a960dafd89 100644 --- a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java +++ b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java @@ -1,21 +1,20 @@ package com.baeldung.boot.jackson.controller; -import com.baeldung.boot.jackson.model.Coffee; +import java.time.LocalDateTime; + import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.time.LocalDateTime; +import com.baeldung.boot.jackson.model.Coffee; @RestController public class CoffeeController { @GetMapping("/coffee") - public Coffee getCoffee(@RequestParam(required = false) String brand, - @RequestParam(required = false) String name) { - return new Coffee() - .setBrand(brand) - .setDate(LocalDateTime.now()) - .setName(name); + public Coffee getCoffee(@RequestParam(required = false) String brand, @RequestParam(required = false) String name) { + return new Coffee().setBrand(brand) + .setDate(LocalDateTime.now()) + .setName(name); } } From c02a2052205d634961a4bf6d9c0d037ad46f62cf Mon Sep 17 00:00:00 2001 From: Daniel Strmecki Date: Sat, 5 Dec 2020 09:52:32 +0100 Subject: [PATCH 21/43] BAEL-4717: add new module to parent pom --- core-java-modules/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index a6aecef741..a12b3548f9 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -33,6 +33,7 @@ core-java-collections core-java-collections-2 core-java-collections-3 + core-java-collections-4 core-java-collections-array-list core-java-collections-list core-java-collections-list-2 From 18727de7c5c94b03cf713039a151a7b42f384644 Mon Sep 17 00:00:00 2001 From: AbdallahSawan Date: Sat, 12 Dec 2020 00:44:55 +0200 Subject: [PATCH 22/43] Determine if an Integer's Square Root Is an Integer in Java Article by Abdallah Sawan --- .../baeldung/perfectsquare/PerfectSquareUnitTest.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/java-numbers-4/src/test/java/com/baeldung/perfectsquare/PerfectSquareUnitTest.java b/java-numbers-4/src/test/java/com/baeldung/perfectsquare/PerfectSquareUnitTest.java index 334b95ea9d..83fce31047 100644 --- a/java-numbers-4/src/test/java/com/baeldung/perfectsquare/PerfectSquareUnitTest.java +++ b/java-numbers-4/src/test/java/com/baeldung/perfectsquare/PerfectSquareUnitTest.java @@ -6,22 +6,21 @@ import static org.junit.Assert.assertEquals; public class PerfectSquareUnitTest { @Test - public void test0xFFAssignedToInteger() { + public void testIsNumberPerfectSquare() { long n = 18676209273604L; //‬ 18676209273604 = 43621598 * 43621598 boolean expectedValue = true; assertEquals(expectedValue, PerfectSquareUtil.isPerfectSquareByUsingSqrt(n)); assertEquals(expectedValue, PerfectSquareUtil.isPerfectSquareByUsingBinarySearch(1, Integer.MAX_VALUE, n)); assertEquals(expectedValue, PerfectSquareUtil.isPerfectSquareByUsingNewtonMethod(n)); assertEquals(expectedValue, PerfectSquareUtil.isPerfectSquareWithOptimization(n)); - } - @Test - public void test0xFFAssignedToByte() { - long n = 549790047707L; // prime number - boolean expectedValue = false; + n = 549790047707L; // prime number + expectedValue = false; assertEquals(expectedValue, PerfectSquareUtil.isPerfectSquareByUsingSqrt(n)); assertEquals(expectedValue, PerfectSquareUtil.isPerfectSquareByUsingBinarySearch(1, Integer.MAX_VALUE, n)); assertEquals(expectedValue, PerfectSquareUtil.isPerfectSquareByUsingNewtonMethod(n)); assertEquals(expectedValue, PerfectSquareUtil.isPerfectSquareWithOptimization(n)); } + + } From 0d8d1d3a09978e35233ee5484306393f8d8dfb7b Mon Sep 17 00:00:00 2001 From: Daniel Strmecki Date: Sun, 13 Dec 2020 10:33:53 +0100 Subject: [PATCH 23/43] BAEL-4717: Fix artifactId --- core-java-modules/core-java-collections-4/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core-java-modules/core-java-collections-4/pom.xml b/core-java-modules/core-java-collections-4/pom.xml index 23baa51d0d..0e3cabf40e 100644 --- a/core-java-modules/core-java-collections-4/pom.xml +++ b/core-java-modules/core-java-collections-4/pom.xml @@ -4,9 +4,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - core-java-collections-3 + core-java-collections-4 0.1.0-SNAPSHOT - core-java-collections-3 + core-java-collections-4 jar com.baeldung.core-java-modules From 7afdb4cba720a08b603dd049b562ca832d923549 Mon Sep 17 00:00:00 2001 From: Kai Yuan Date: Sun, 13 Dec 2020 17:22:09 +0100 Subject: [PATCH 24/43] [BAEL-4497] jdbc url --- .../core-java-persistence-2/pom.xml | 35 +++++++- .../jdbcurlformat/JdbcUrlFormatLiveTest.java | 86 +++++++++++++++++++ 2 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 persistence-modules/core-java-persistence-2/src/test/java/com/baeldung/jdbcurlformat/JdbcUrlFormatLiveTest.java diff --git a/persistence-modules/core-java-persistence-2/pom.xml b/persistence-modules/core-java-persistence-2/pom.xml index 9845d5009d..a1088b0801 100644 --- a/persistence-modules/core-java-persistence-2/pom.xml +++ b/persistence-modules/core-java-persistence-2/pom.xml @@ -20,10 +20,43 @@ h2 ${h2.version} + + org.postgresql + postgresql + ${postgresql.version} + test + + + mysql + mysql-connector-java + ${mysql.driver.version} + + + + com.microsoft.sqlserver + mssql-jdbc + ${mssql.driver.version} + + 1.4.200 + 42.2.5.jre7 + 8.4.1.jre11 + 10.2.0.4.0 + 8.0.22 - \ No newline at end of file + diff --git a/persistence-modules/core-java-persistence-2/src/test/java/com/baeldung/jdbcurlformat/JdbcUrlFormatLiveTest.java b/persistence-modules/core-java-persistence-2/src/test/java/com/baeldung/jdbcurlformat/JdbcUrlFormatLiveTest.java new file mode 100644 index 0000000000..fc00119704 --- /dev/null +++ b/persistence-modules/core-java-persistence-2/src/test/java/com/baeldung/jdbcurlformat/JdbcUrlFormatLiveTest.java @@ -0,0 +1,86 @@ +package com.baeldung.jdbcurlformat; + +import org.junit.Test; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; + +import static org.junit.Assert.assertNotNull; + +public class JdbcUrlFormatLiveTest { + @Test + public void givenOracleSID_thenCreateConnectionObject() { + String oracleJdbcUrl = "jdbc:oracle:thin:@myoracle.db.server:1521:my_sid"; + String username = "dbUser"; + String password = "1234567"; + try (Connection conn = DriverManager.getConnection(oracleJdbcUrl, username, password)) { + assertNotNull(conn); + } catch (SQLException e) { + System.err.format("SQL State: %s\n%s", e.getSQLState(), e.getMessage()); + } + } + + @Test + public void givenOracleServiceName_thenCreateConnectionObject() { + String oracleJdbcUrl = "jdbc:oracle:thin:@//myoracle.db.server:1521/my_servicename"; + String username = "dbUser"; + String password = "1234567"; + try (Connection conn = DriverManager.getConnection(oracleJdbcUrl, username, password)) { + assertNotNull(conn); + } catch (SQLException e) { + System.err.format("SQL State: %s\n%s", e.getSQLState(), e.getMessage()); + } + } + + @Test + public void givenOracleTnsnames_thenCreateConnectionObject() { + String oracleJdbcUrl = "jdbc:oracle:thin:@" + + "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)" + + "(HOST=myoracle.db.server)(PORT=1521))" + + "(CONNECT_DATA=(SERVICE_NAME=my_servicename)))"; + String username = "dbUser"; + String password = "1234567"; + try (Connection conn = DriverManager.getConnection(oracleJdbcUrl, username, password)) { + assertNotNull(conn); + } catch (SQLException e) { + System.err.format("SQL State: %s\n%s", e.getSQLState(), e.getMessage()); + } + } + + @Test + public void givenMysqlDb_thenCreateConnectionObject() { + String jdbcUrl = "jdbc:mysql://mysql.db.server:3306/my_database?useSSL=false&serverTimezone=UTC"; + String username = "dbUser"; + String password = "1234567"; + try (Connection conn = DriverManager.getConnection(jdbcUrl, username, password)) { + assertNotNull(conn); + } catch (SQLException e) { + System.err.format("SQL State: %s\n%s", e.getSQLState(), e.getMessage()); + } + } + + @Test + public void givenMssqlDb_thenCreateConnectionObject() { + String jdbcUrl = "jdbc:sqlserver://mssql.db.server\\mssql_instance;databaseName=my_database"; + String username = "dbUser"; + String password = "1234567"; + try (Connection conn = DriverManager.getConnection(jdbcUrl, username, password)) { + assertNotNull(conn); + } catch (SQLException e) { + System.err.format("SQL State: %s\n%s", e.getSQLState(), e.getMessage()); + } + } + + @Test + public void givenPostgreSqlDb_thenCreateConnectionObject() { + String jdbcUrl = "jdbc:postgresql://postgresql.db.server:5430/my_database?ssl=true&loglevel=2"; + String username = "dbUser"; + String password = "1234567"; + try (Connection conn = DriverManager.getConnection(jdbcUrl, username, password)) { + assertNotNull(conn); + } catch (SQLException e) { + System.err.format("SQL State: %s\n%s", e.getSQLState(), e.getMessage()); + } + } +} From eb29a0a084435ee8c318978321acf027e6c0ca61 Mon Sep 17 00:00:00 2001 From: Amy DeGregorio Date: Mon, 14 Dec 2020 12:15:23 -0500 Subject: [PATCH 25/43] BAEL-4721 (#10272) * BAEL-4721 Examples * BAEL-4721 Requested edits * Fix formatting issues * Correct unit test name --- .../WriteByteArrayUnitTest.java | 77 ++++++++++++++++++ .../src/test/resources/example-image.jpg | Bin 0 -> 39665 bytes 2 files changed, 77 insertions(+) create mode 100644 core-java-modules/core-java-io-3/src/test/java/com/baeldung/writebytearray/WriteByteArrayUnitTest.java create mode 100644 core-java-modules/core-java-io-3/src/test/resources/example-image.jpg diff --git a/core-java-modules/core-java-io-3/src/test/java/com/baeldung/writebytearray/WriteByteArrayUnitTest.java b/core-java-modules/core-java-io-3/src/test/java/com/baeldung/writebytearray/WriteByteArrayUnitTest.java new file mode 100644 index 0000000000..ef8c8e2470 --- /dev/null +++ b/core-java-modules/core-java-io-3/src/test/java/com/baeldung/writebytearray/WriteByteArrayUnitTest.java @@ -0,0 +1,77 @@ +package com.baeldung.writebytearray; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; + +import org.apache.commons.io.FileUtils; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import com.google.common.io.ByteSink; +import com.google.common.io.MoreFiles; + +public class WriteByteArrayUnitTest { + private static byte[] dataForWriting; + + @Rule + public TemporaryFolder tempFolder = new TemporaryFolder(); + + @BeforeClass + public static void setup() throws IOException { + dataForWriting = Files.readAllBytes(Paths.get("src/test/resources/example-image.jpg")); + } + + @Test + public void whenUsingFileOutputStream_thenByteArrayIsWritten() throws IOException { + File outputFile = tempFolder.newFile("example-fos.jpg"); + try (FileOutputStream outputStream = new FileOutputStream(outputFile)) { + outputStream.write(dataForWriting); + assertThat(outputFile).hasBinaryContent(dataForWriting); + } + } + + @Test + public void whenUsingNioFiles_thenByteArrayIsWritten() throws IOException { + File outputFile = tempFolder.newFile("example-nio-files.jpg"); + Files.write(outputFile.toPath(), dataForWriting); + assertThat(outputFile).hasBinaryContent(dataForWriting); + } + + @Test + public void whenUsingGuavaFiles_thenByteArrayIsWritten() throws IOException { + File outputFile = tempFolder.newFile("example-guava-files.jpg"); + com.google.common.io.Files.write(dataForWriting, outputFile); + assertThat(outputFile).hasBinaryContent(dataForWriting); + } + + @Test + public void whenUsingGuavaByteSink_thenByteArrayIsWritten() throws IOException { + File outputFile = tempFolder.newFile("example-guava-bs.jpg"); + ByteSink byteSink = com.google.common.io.Files.asByteSink(outputFile); + byteSink.write(dataForWriting); + assertThat(outputFile).hasBinaryContent(dataForWriting); + } + + @Test + public void whenUsingGuavaByteSinkMoreFiles_thenByteArrayIsWritten() throws IOException { + File outputFile = tempFolder.newFile("example-guava-bs.jpg"); + ByteSink byteSink = MoreFiles.asByteSink(outputFile.toPath(), StandardOpenOption.CREATE, StandardOpenOption.WRITE); + byteSink.write(dataForWriting); + assertThat(outputFile).hasBinaryContent(dataForWriting); + } + + @Test + public void whenUsingCommonsIo_thenByteArrayIsWritten() throws IOException { + File outputFile = tempFolder.newFile("example-file-utils.jpg"); + FileUtils.writeByteArrayToFile(outputFile, dataForWriting); + assertThat(outputFile).hasBinaryContent(dataForWriting); + } +} diff --git a/core-java-modules/core-java-io-3/src/test/resources/example-image.jpg b/core-java-modules/core-java-io-3/src/test/resources/example-image.jpg new file mode 100644 index 0000000000000000000000000000000000000000..43b8962793fc7289bb9291fe2161e9b3c623f515 GIT binary patch literal 39665 zcmbTedt8%ex-Og$Axe=$Bo!E-@g+crM@|-y)SwBxqzEJ=LuE473ZBqCTY_ydPNyK_ zNFpL{AWT7;atK0Ti6fRSnATZ1E$1RAQPj3B3Wy4|l?v9Gc4qeVr1S0XpYM-v@2;N? zOG3!|JkNdK*LB_3{rv0pzb09pip1nZ7Msmx?Z*GH{`EEMfV|+~J{D`o4wjh3Vl8Ja zWBak3@f90?USa>@e}A3G7O^;ve|N$+!&&&7<%K_~_(T5NjX&gP9RGXdjf1~Ay5To_ zj|!qTL~IC;!f*P5wVmaJU(9Bczn#c`%Q)n3=Vi+{%UqmYTpWM6E0()(S8!cimcOuk zg)8|FU%9>D>PG$_@+Lq3sFO2?hl3C8j8BYLzk~0ymU%hz)`TaxtWv(g zrSiNZikSN4LEA1}<*Tkg5k~IOomk=e;%XmXzu=HiQJ6R?dh^RMv2ojF^28)MS&^aE z{4(>komtsAd-v@>a4CI14Ddp@|MqwC zTx=HS=f}d||DVt0h39f2d%z{n#ddlde>h&toY#cA@Dh~VH}Y0d5k$CLg4d$1G#S5Nl8AMF2quDdKZ4jY@t@nUUdJ(oJ=$~m@+ z&-91y@I)i@=||d%y}ZQ6^I>!0ce{l{2I@osUmPZxuR7cySLMpJ&)N@0Cd}2^jV_0( zR8I0;1vc(3^YG>@;ZI^|*Tc0{hr3LoAY=KFaBYQ%VaNM1NpEN`@8wZXOYO$kp7xy) z2JhW_ER6?xbvtS(xuPoC_bPv6bF@yb_1|X=*tE84Z&`X$w7Asueuc=K(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@q-BaQwN%W4xoPfG`F0{?;#nx!`&6pVM;p&l56L%Q&P=E8k*`wixyn(OrKU$ zn)O;U8=L;)l$Ukp1SC;+>_Tf;Z-O`_B}w^YGtg;%Cydbv z3R#E(Si{T{@-4V+h^OBt*bP!;voeg#=FQ4L@~m^t>S2lFRG8=9mv%~>-@8z{c@DzT zBPWt9PCbC@df%HWL{{*ndL9$ToazIbsFUpcxM5c_M%a;b7$E076oybFU)Af$Q4)XU zOlsVr{$Ntgc*h_wz5LGO?8T z6Tb#l19bs~egf1~-=kA5wvd zPv;wy&p6i;iOjdg(6CAxu}4?B@+G5>^Im4(>VNkee@-XE6@y6UfI+butn^*`vlX*x z{~CV&abfSWmnm(@$pB!F$>-M>PR80M-Wk?}-#$xKd|RG5Q+d`0vYGYy)kEw{;)nMZ+!M%A*1jD{tHcLI=x$GJvf#^4 zj Date: Mon, 14 Dec 2020 19:24:02 +0100 Subject: [PATCH 26/43] update indentation --- .../baeldung/spring/cloud/client/BookMocks.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/BookMocks.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/BookMocks.java index 0a64156ba8..2cce72e6cb 100644 --- a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/BookMocks.java +++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/BookMocks.java @@ -14,13 +14,14 @@ public class BookMocks { public static void setupMockBooksResponse(WireMockServer mockService) throws IOException { mockService.stubFor(WireMock.get(WireMock.urlEqualTo("/books")) - .willReturn(WireMock.aResponse() - .withStatus(HttpStatus.OK.value()) - .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) - .withBody( - copyToString( - BookMocks.class.getClassLoader().getResourceAsStream("payload/get-books-response.json"), - defaultCharset())))); + .willReturn( + WireMock.aResponse() + .withStatus(HttpStatus.OK.value()) + .withHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE) + .withBody( + copyToString( + BookMocks.class.getClassLoader().getResourceAsStream("payload/get-books-response.json"), + defaultCharset())))); } } From 5e8cf2618a8fb08513b5524b237535c5205ac6b4 Mon Sep 17 00:00:00 2001 From: Jonathan Cook Date: Mon, 14 Dec 2020 19:37:05 +0100 Subject: [PATCH 27/43] BAEL-4736 - Convert JSONArray to List of Object using camel-jackson (#10316) * BAEL-4706 - Spring Boot with Spring Batch * BAEL-3948 - Fix test(s) in spring-batch which leaves repository.sqlite changed * BAEL-4736 - Convert JSONArray to List of Object using camel-jackson Co-authored-by: Jonathan Cook --- spring-apache-camel/pom.xml | 11 ++++ .../com/baeldung/camel/jackson/Fruit.java | 24 ++++++++ .../com/baeldung/camel/jackson/FruitList.java | 17 ++++++ .../FruitArrayJacksonUnmarshalUnitTest.java | 60 +++++++++++++++++++ .../FruitListJacksonUnmarshalUnitTest.java | 59 ++++++++++++++++++ .../src/test/resources/json/fruit-array.json | 10 ++++ .../src/test/resources/json/fruit-list.json | 12 ++++ 7 files changed, 193 insertions(+) create mode 100644 spring-apache-camel/src/main/java/com/baeldung/camel/jackson/Fruit.java create mode 100644 spring-apache-camel/src/main/java/com/baeldung/camel/jackson/FruitList.java create mode 100644 spring-apache-camel/src/test/java/com/baeldung/camel/jackson/FruitArrayJacksonUnmarshalUnitTest.java create mode 100644 spring-apache-camel/src/test/java/com/baeldung/camel/jackson/FruitListJacksonUnmarshalUnitTest.java create mode 100644 spring-apache-camel/src/test/resources/json/fruit-array.json create mode 100644 spring-apache-camel/src/test/resources/json/fruit-list.json diff --git a/spring-apache-camel/pom.xml b/spring-apache-camel/pom.xml index 2d0d632546..9c7cc14381 100644 --- a/spring-apache-camel/pom.xml +++ b/spring-apache-camel/pom.xml @@ -47,6 +47,17 @@ camel-spring-javaconfig ${env.camel.version} + + org.apache.camel + camel-jackson + ${env.camel.version} + + + org.apache.camel + camel-test + ${env.camel.version} + test + diff --git a/spring-apache-camel/src/main/java/com/baeldung/camel/jackson/Fruit.java b/spring-apache-camel/src/main/java/com/baeldung/camel/jackson/Fruit.java new file mode 100644 index 0000000000..1932131ddd --- /dev/null +++ b/spring-apache-camel/src/main/java/com/baeldung/camel/jackson/Fruit.java @@ -0,0 +1,24 @@ +package com.baeldung.camel.jackson; + +public class Fruit { + + private String name; + private int id; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + +} diff --git a/spring-apache-camel/src/main/java/com/baeldung/camel/jackson/FruitList.java b/spring-apache-camel/src/main/java/com/baeldung/camel/jackson/FruitList.java new file mode 100644 index 0000000000..02f2b6feb0 --- /dev/null +++ b/spring-apache-camel/src/main/java/com/baeldung/camel/jackson/FruitList.java @@ -0,0 +1,17 @@ +package com.baeldung.camel.jackson; + +import java.util.List; + +public class FruitList { + + private List fruits; + + public List getFruits() { + return fruits; + } + + public void setFruits(List fruits) { + this.fruits = fruits; + } + +} diff --git a/spring-apache-camel/src/test/java/com/baeldung/camel/jackson/FruitArrayJacksonUnmarshalUnitTest.java b/spring-apache-camel/src/test/java/com/baeldung/camel/jackson/FruitArrayJacksonUnmarshalUnitTest.java new file mode 100644 index 0000000000..4810d7370e --- /dev/null +++ b/spring-apache-camel/src/test/java/com/baeldung/camel/jackson/FruitArrayJacksonUnmarshalUnitTest.java @@ -0,0 +1,60 @@ +package com.baeldung.camel.jackson; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.jackson.ListJacksonDataFormat; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class FruitArrayJacksonUnmarshalUnitTest extends CamelTestSupport { + + @Test + public void givenJsonFruitArray_whenUnmarshalled_thenSuccess() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:marshalledObject"); + mock.expectedMessageCount(1); + mock.message(0).body().isInstanceOf(List.class); + + String json = readJsonFromFile("/json/fruit-array.json"); + template.sendBody("direct:jsonInput", json); + assertMockEndpointsSatisfied(); + + @SuppressWarnings("unchecked") + List fruitList = mock.getReceivedExchanges().get(0).getIn().getBody(List.class); + assertNotNull("Fruit lists should not be null", fruitList); + + assertEquals("There should be two fruits", 2, fruitList.size()); + + Fruit fruit = fruitList.get(0); + assertEquals("Fruit name", "Banana", fruit.getName()); + assertEquals("Fruit id", 100, fruit.getId()); + + fruit = fruitList.get(1); + assertEquals("Fruit name", "Apple", fruit.getName()); + assertEquals("Fruit id", 101, fruit.getId()); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + + from("direct:jsonInput").unmarshal(new ListJacksonDataFormat(Fruit.class)) + .to("mock:marshalledObject"); + } + }; + } + + private String readJsonFromFile(String path) throws URISyntaxException, IOException { + URL resource = FruitArrayJacksonUnmarshalUnitTest.class.getResource(path); + return new String(Files.readAllBytes(Paths.get(resource.toURI()))); + } + +} diff --git a/spring-apache-camel/src/test/java/com/baeldung/camel/jackson/FruitListJacksonUnmarshalUnitTest.java b/spring-apache-camel/src/test/java/com/baeldung/camel/jackson/FruitListJacksonUnmarshalUnitTest.java new file mode 100644 index 0000000000..b5647f02f9 --- /dev/null +++ b/spring-apache-camel/src/test/java/com/baeldung/camel/jackson/FruitListJacksonUnmarshalUnitTest.java @@ -0,0 +1,59 @@ +package com.baeldung.camel.jackson; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.List; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.jackson.JacksonDataFormat; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.junit4.CamelTestSupport; +import org.junit.Test; + +public class FruitListJacksonUnmarshalUnitTest extends CamelTestSupport { + + @Test + public void givenJsonFruitList_whenUnmarshalled_thenSuccess() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:marshalledObject"); + mock.expectedMessageCount(1); + mock.message(0).body().isInstanceOf(FruitList.class); + + String json = readJsonFromFile("/json/fruit-list.json"); + template.sendBody("direct:jsonInput", json); + assertMockEndpointsSatisfied(); + + FruitList fruitList = mock.getReceivedExchanges().get(0).getIn().getBody(FruitList.class); + assertNotNull("Fruit lists should not be null", fruitList); + + List fruits = fruitList.getFruits(); + assertEquals("There should be two fruits", 2, fruits.size()); + + Fruit fruit = fruits.get(0); + assertEquals("Fruit name", "Banana", fruit.getName()); + assertEquals("Fruit id", 100, fruit.getId()); + + fruit = fruits.get(1); + assertEquals("Fruit name", "Apple", fruit.getName()); + assertEquals("Fruit id", 101, fruit.getId()); + } + + @Override + protected RouteBuilder createRouteBuilder() throws Exception { + return new RouteBuilder() { + @Override + public void configure() throws Exception { + from("direct:jsonInput").unmarshal(new JacksonDataFormat(FruitList.class)) + .to("mock:marshalledObject"); + } + }; + } + + private String readJsonFromFile(String path) throws URISyntaxException, IOException { + URL resource = FruitListJacksonUnmarshalUnitTest.class.getResource(path); + return new String(Files.readAllBytes(Paths.get(resource.toURI()))); + } + +} diff --git a/spring-apache-camel/src/test/resources/json/fruit-array.json b/spring-apache-camel/src/test/resources/json/fruit-array.json new file mode 100644 index 0000000000..0bd917c53f --- /dev/null +++ b/spring-apache-camel/src/test/resources/json/fruit-array.json @@ -0,0 +1,10 @@ +[ + { + "id": 100, + "name": "Banana" + }, + { + "id": 101, + "name": "Apple" + } +] \ No newline at end of file diff --git a/spring-apache-camel/src/test/resources/json/fruit-list.json b/spring-apache-camel/src/test/resources/json/fruit-list.json new file mode 100644 index 0000000000..357e08f7d5 --- /dev/null +++ b/spring-apache-camel/src/test/resources/json/fruit-list.json @@ -0,0 +1,12 @@ +{ + "fruits": [ + { + "id": 100, + "name": "Banana" + }, + { + "id": 101, + "name": "Apple" + } + ] +} \ No newline at end of file From abfc9637073d44f6f83a86000786264496ecf646 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Dec 2020 17:21:52 +0800 Subject: [PATCH 28/43] Update README.md --- core-java-modules/core-java-collections-4/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-collections-4/README.md b/core-java-modules/core-java-collections-4/README.md index 1c680b86ba..6e117c98b1 100644 --- a/core-java-modules/core-java-collections-4/README.md +++ b/core-java-modules/core-java-collections-4/README.md @@ -4,4 +4,4 @@ ### Relevant Articles: -- TODO: add article links here +- [ArrayList vs. LinkedList vs. HashMap in Java](https://www.baeldung.com/java-arraylist-vs-linkedlist-vs-hashmap) From 42604275ff2b848400545a44e394319567ee790b Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Dec 2020 17:24:51 +0800 Subject: [PATCH 29/43] Update README.md --- persistence-modules/core-java-persistence-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/core-java-persistence-2/README.md b/persistence-modules/core-java-persistence-2/README.md index 467de757ce..36c33cc6e1 100644 --- a/persistence-modules/core-java-persistence-2/README.md +++ b/persistence-modules/core-java-persistence-2/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Getting Database URL From JDBC Connection Object](https://www.baeldung.com/jdbc-get-url-from-connection) +- [JDBC URL Format For Different Databases](https://www.baeldung.com/java-jdbc-url-format) From 11cd12ffb58ce125dbd8288706538cfb49609842 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Dec 2020 17:39:28 +0800 Subject: [PATCH 30/43] Update README.md --- core-java-modules/core-java-security-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-security-2/README.md b/core-java-modules/core-java-security-2/README.md index bb5e204c98..9b99d624c9 100644 --- a/core-java-modules/core-java-security-2/README.md +++ b/core-java-modules/core-java-security-2/README.md @@ -14,4 +14,5 @@ This module contains articles about core Java Security - [Get a List of Trusted Certificates in Java](https://www.baeldung.com/java-list-trusted-certificates) - [Security Context Basics: User, Subject and Principal](https://www.baeldung.com/security-context-basics) - [Java AES Encryption and Decryption](https://www.baeldung.com/java-aes-encryption-decryption) +- [InvalidAlgorithmParameterException: Wrong IV Length](https://www.baeldung.com/java-invalidalgorithmparameter-exception) - More articles: [[<-- prev]](/core-java-modules/core-java-security) From c6dd691407d8c9a49d3853f32a118d5f8cf788d1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 16 Dec 2020 17:41:24 +0800 Subject: [PATCH 31/43] Update README.md --- core-java-modules/core-java-io-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-io-3/README.md b/core-java-modules/core-java-io-3/README.md index 36617a210e..d0ac5387a8 100644 --- a/core-java-modules/core-java-io-3/README.md +++ b/core-java-modules/core-java-io-3/README.md @@ -13,4 +13,5 @@ This module contains articles about core Java input and output (IO) - [Reading a Line at a Given Line Number From a File in Java](https://www.baeldung.com/java-read-line-at-number) - [Find the Last Modified File in a Directory with Java](https://www.baeldung.com/java-last-modified-file) - [Get a Filename Without the Extension in Java](https://www.baeldung.com/java-filename-without-extension) +- [Writing byte[] to a File in Java](https://www.baeldung.com/java-write-byte-array-file) - [[<-- Prev]](/core-java-modules/core-java-io-2) From 8a9c1a1911594488d7e0e8f8a6384f260a1e036b Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Wed, 16 Dec 2020 16:38:31 -0300 Subject: [PATCH 32/43] migrated spring.profiles properties to spring.config.activate.on-profile --- .../src/main/resources/application.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/application.yml b/spring-boot-modules/spring-boot-properties/src/main/resources/application.yml index fc9bb42a95..61d462bb5a 100644 --- a/spring-boot-modules/spring-boot-properties/src/main/resources/application.yml +++ b/spring-boot-modules/spring-boot-properties/src/main/resources/application.yml @@ -6,7 +6,9 @@ spring: --- spring: - profiles: test + config: + activate: + on-profile: test name: test-YAML environment: testing enabled: false @@ -37,7 +39,9 @@ component: --- spring: - profiles: prod + config: + activate: + on-profile: prod name: prod-YAML environment: production enabled: true @@ -48,7 +52,9 @@ servers: --- spring: - profiles: dev + config: + activate: + on-profile: dev name: ${DEV_NAME:dev-YAML} environment: development enabled: true From 7b17a09eb74b9401b7d28a85d0ea2bfd660ccdfe Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Wed, 16 Dec 2020 16:53:33 -0300 Subject: [PATCH 33/43] avoid using deprecated StringUtils#isEmpty method --- .../properties/reloading/configs/ReloadablePropertySource.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadablePropertySource.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadablePropertySource.java index 6d76a2e1e2..5d4e170226 100644 --- a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadablePropertySource.java +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/reloading/configs/ReloadablePropertySource.java @@ -15,7 +15,7 @@ public class ReloadablePropertySource extends PropertySource { } public ReloadablePropertySource(String name, String path) { - super(StringUtils.isEmpty(name) ? path : name); + super(StringUtils.hasText(name) ? path : name); try { this.propertiesConfiguration = new PropertiesConfiguration(path); FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy(); From d4b22c74e3ab06291ba92585f136342c347b83e2 Mon Sep 17 00:00:00 2001 From: Adina Rolea Date: Thu, 17 Dec 2020 14:02:59 +0200 Subject: [PATCH 34/43] BAEL-4687: updated formatting --- .../boot/jackson/controller/CoffeeController.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java index a960dafd89..ad2f6ab942 100644 --- a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java +++ b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java @@ -1,20 +1,21 @@ package com.baeldung.boot.jackson.controller; -import java.time.LocalDateTime; - +import com.baeldung.boot.jackson.model.Coffee; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.baeldung.boot.jackson.model.Coffee; +import java.time.LocalDateTime; @RestController public class CoffeeController { @GetMapping("/coffee") - public Coffee getCoffee(@RequestParam(required = false) String brand, @RequestParam(required = false) String name) { + public Coffee getCoffee( + @RequestParam(required = false) String brand, + @RequestParam(required = false) String name) { return new Coffee().setBrand(brand) - .setDate(LocalDateTime.now()) - .setName(name); + .setDate(LocalDateTime.now()) + .setName(name); } } From d8f681c38e2d3dd8981a942e90e69778a3485840 Mon Sep 17 00:00:00 2001 From: Adina Rolea Date: Thu, 17 Dec 2020 14:23:06 +0200 Subject: [PATCH 35/43] BAEL-4687: returned fixed date instead of dynamic --- .../boot/jackson/config/CoffeeConstants.java | 10 ++++++---- .../boot/jackson/config/CoffeeCustomizerConfig.java | 7 +++---- .../config/CoffeeHttpConverterConfiguration.java | 7 +++---- .../jackson/config/CoffeeJacksonBuilderConfig.java | 7 +++---- .../jackson/config/CoffeeObjectMapperConfig.java | 13 ++++++------- .../jackson/config/CoffeeRegisterModuleConfig.java | 9 ++++----- .../boot/jackson/controller/CoffeeController.java | 4 ++-- .../jackson/app/AbstractCoffeeIntegrationTest.java | 9 +++++---- 8 files changed, 32 insertions(+), 34 deletions(-) diff --git a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java index 90cad011ae..d1875d03d9 100644 --- a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java +++ b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeConstants.java @@ -1,11 +1,13 @@ package com.baeldung.boot.jackson.config; -import java.time.format.DateTimeFormatter; - import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + public class CoffeeConstants { - public static final String dateTimeFormat = "dd-MM-yyyy HH:mm"; - public static LocalDateTimeSerializer localDateTimeSerializer = new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(dateTimeFormat)); + public static final String DATETIME_FORMAT = "dd-MM-yyyy HH:mm"; + public static final LocalDateTime FIXED_DATE = LocalDateTime.now(); + public static LocalDateTimeSerializer LOCAL_DATETIME_SERIALIZER = new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DATETIME_FORMAT)); } diff --git a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java index 363c67fd9a..edb2b478fc 100644 --- a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java +++ b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeCustomizerConfig.java @@ -1,12 +1,11 @@ package com.baeldung.boot.jackson.config; -import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; - +import com.fasterxml.jackson.annotation.JsonInclude; import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import com.fasterxml.jackson.annotation.JsonInclude; +import static com.baeldung.boot.jackson.config.CoffeeConstants.LOCAL_DATETIME_SERIALIZER; @Configuration public class CoffeeCustomizerConfig { @@ -14,6 +13,6 @@ public class CoffeeCustomizerConfig { @Bean public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() { return builder -> builder.serializationInclusion(JsonInclude.Include.NON_NULL) - .serializers(localDateTimeSerializer); + .serializers(LOCAL_DATETIME_SERIALIZER); } } diff --git a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java index b67f215816..eff2b5c252 100644 --- a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java +++ b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeHttpConverterConfiguration.java @@ -1,13 +1,12 @@ package com.baeldung.boot.jackson.config; -import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; - +import com.fasterxml.jackson.annotation.JsonInclude; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import com.fasterxml.jackson.annotation.JsonInclude; +import static com.baeldung.boot.jackson.config.CoffeeConstants.LOCAL_DATETIME_SERIALIZER; @Configuration public class CoffeeHttpConverterConfiguration { @@ -15,7 +14,7 @@ public class CoffeeHttpConverterConfiguration { @Bean public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() { Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder() - .serializers(localDateTimeSerializer) + .serializers(LOCAL_DATETIME_SERIALIZER) .serializationInclusion(JsonInclude.Include.NON_NULL); return new MappingJackson2HttpMessageConverter(builder.build()); } diff --git a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java index ec4de1d353..8057fff3db 100644 --- a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java +++ b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeJacksonBuilderConfig.java @@ -1,13 +1,12 @@ package com.baeldung.boot.jackson.config; -import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; - +import com.fasterxml.jackson.annotation.JsonInclude; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; -import com.fasterxml.jackson.annotation.JsonInclude; +import static com.baeldung.boot.jackson.config.CoffeeConstants.LOCAL_DATETIME_SERIALIZER; @Configuration public class CoffeeJacksonBuilderConfig { @@ -16,7 +15,7 @@ public class CoffeeJacksonBuilderConfig { @Primary public Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder() { return new Jackson2ObjectMapperBuilder() - .serializers(localDateTimeSerializer) + .serializers(LOCAL_DATETIME_SERIALIZER) .serializationInclusion(JsonInclude.Include.NON_NULL); } } \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java index 3754de018a..f1ce6458ae 100644 --- a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java +++ b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeObjectMapperConfig.java @@ -1,14 +1,13 @@ package com.baeldung.boot.jackson.config; -import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; + +import static com.baeldung.boot.jackson.config.CoffeeConstants.LOCAL_DATETIME_SERIALIZER; @Configuration public class CoffeeObjectMapperConfig { @@ -17,7 +16,7 @@ public class CoffeeObjectMapperConfig { @Primary public ObjectMapper objectMapper() { JavaTimeModule module = new JavaTimeModule(); - module.addSerializer(localDateTimeSerializer); + module.addSerializer(LOCAL_DATETIME_SERIALIZER); return new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL) .registerModule(module); } diff --git a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java index ea00e5a58e..fc157f8156 100644 --- a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java +++ b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/config/CoffeeRegisterModuleConfig.java @@ -1,13 +1,12 @@ package com.baeldung.boot.jackson.config; -import static com.baeldung.boot.jackson.config.CoffeeConstants.localDateTimeSerializer; - +import com.fasterxml.jackson.databind.Module; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; -import com.fasterxml.jackson.databind.Module; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import static com.baeldung.boot.jackson.config.CoffeeConstants.LOCAL_DATETIME_SERIALIZER; @Configuration @PropertySource("classpath:coffee.properties") @@ -16,7 +15,7 @@ public class CoffeeRegisterModuleConfig { @Bean public Module javaTimeModule() { JavaTimeModule module = new JavaTimeModule(); - module.addSerializer(localDateTimeSerializer); + module.addSerializer(LOCAL_DATETIME_SERIALIZER); return module; } } diff --git a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java index ad2f6ab942..23749b18a2 100644 --- a/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java +++ b/spring-boot-modules/spring-boot-data-2/src/main/java/com/baeldung/boot/jackson/controller/CoffeeController.java @@ -5,7 +5,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.time.LocalDateTime; +import static com.baeldung.boot.jackson.config.CoffeeConstants.FIXED_DATE; @RestController public class CoffeeController { @@ -15,7 +15,7 @@ public class CoffeeController { @RequestParam(required = false) String brand, @RequestParam(required = false) String name) { return new Coffee().setBrand(brand) - .setDate(LocalDateTime.now()) + .setDate(FIXED_DATE) .setName(name); } } diff --git a/spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/boot/jackson/app/AbstractCoffeeIntegrationTest.java b/spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/boot/jackson/app/AbstractCoffeeIntegrationTest.java index 13e1f05f97..f1bc35a8ce 100644 --- a/spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/boot/jackson/app/AbstractCoffeeIntegrationTest.java +++ b/spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/boot/jackson/app/AbstractCoffeeIntegrationTest.java @@ -6,9 +6,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; -import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; +import static com.baeldung.boot.jackson.config.CoffeeConstants.FIXED_DATE; import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @@ -19,13 +19,14 @@ public abstract class AbstractCoffeeIntegrationTest { @Test public void whenGetCoffee_thenSerializedWithDateAndNonNull() { - String formattedDate = DateTimeFormatter.ofPattern(CoffeeConstants.dateTimeFormat) - .format(LocalDateTime.now()); + String formattedDate = DateTimeFormatter.ofPattern(CoffeeConstants.DATETIME_FORMAT) + .format(FIXED_DATE); String brand = "Lavazza"; - String url = "/coffee?brand=" + brand; + String response = restTemplate.getForObject(url, String.class); + assertThat(response).isEqualTo( "{\"brand\":\"" + brand + "\",\"date\":\"" + formattedDate + "\"}"); } From 83e87aebc081a13f061ed251ce73e4d9c05943ec Mon Sep 17 00:00:00 2001 From: mdabrowski-eu <57441874+mdabrowski-eu@users.noreply.github.com> Date: Fri, 18 Dec 2020 06:13:31 +0100 Subject: [PATCH 36/43] BAEL-4718 using bytes array as key in HashMap (#10315) --- .../com/baeldung/map/bytearrays/BytesKey.java | 28 +++++ .../map/bytearrays/ByteArrayKeyUnitTest.java | 104 ++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 java-collections-maps-3/src/main/java/com/baeldung/map/bytearrays/BytesKey.java create mode 100644 java-collections-maps-3/src/test/java/com/baeldung/map/bytearrays/ByteArrayKeyUnitTest.java diff --git a/java-collections-maps-3/src/main/java/com/baeldung/map/bytearrays/BytesKey.java b/java-collections-maps-3/src/main/java/com/baeldung/map/bytearrays/BytesKey.java new file mode 100644 index 0000000000..4bdcfe4b06 --- /dev/null +++ b/java-collections-maps-3/src/main/java/com/baeldung/map/bytearrays/BytesKey.java @@ -0,0 +1,28 @@ +package com.baeldung.map.bytearrays; + +import java.util.Arrays; + +public final class BytesKey { + private final byte[] array; + + public BytesKey(byte[] array) { + this.array = array; + } + + public byte[] getArray() { + return array.clone(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + BytesKey bytesKey = (BytesKey) o; + return Arrays.equals(array, bytesKey.array); + } + + @Override + public int hashCode() { + return Arrays.hashCode(array); + } +} diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/bytearrays/ByteArrayKeyUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/bytearrays/ByteArrayKeyUnitTest.java new file mode 100644 index 0000000000..8f5b89e11e --- /dev/null +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/bytearrays/ByteArrayKeyUnitTest.java @@ -0,0 +1,104 @@ +package com.baeldung.map.bytearrays; + +import com.google.common.collect.ImmutableList; +import org.junit.jupiter.api.Test; + +import java.util.Base64; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; + +class ByteArrayKeyUnitTest { + @Test + void givenPrimitiveByteArrayKey_whenRetrievingFromMap_shouldRetrieveDifferentObjects() { + // given + byte[] key1 = {1, 2, 3}; + byte[] key2 = {1, 2, 3}; + String value1 = "value1"; + String value2 = "value2"; + Map map = new HashMap<>(); + map.put(key1, value1); + map.put(key2, value2); + + // when + String retrievedValue1 = map.get(key1); + String retrievedValue2 = map.get(key2); + String retrievedValue3 = map.get(new byte[]{1, 2, 3}); + + // then + assertThat(retrievedValue1).isEqualTo(value1); + assertThat(retrievedValue2).isEqualTo(value2); + assertThat(retrievedValue3).isNull(); + } + + @Test + void givenEncodedStringKey_whenRetrievingFromMap_shouldRetrieveLastPutObject() { + // given + String key1 = Base64.getEncoder().encodeToString(new byte[]{1, 2, 3}); + String key2 = Base64.getEncoder().encodeToString(new byte[]{1, 2, 3}); + String value1 = "value1"; + String value2 = "value2"; + Map map = new HashMap<>(); + map.put(key1, value1); + map.put(key2, value2); + + // when + String retrievedValue1 = map.get(key1); + String retrievedValue2 = map.get(key2); + + // then + assertThat(key1).isEqualTo(key2); + assertThat(retrievedValue1).isEqualTo(value2); + assertThat(retrievedValue2).isEqualTo(value2); + assertThat(retrievedValue1).isEqualTo(retrievedValue2); + } + + @Test + void givenByteListKey_whenRetrievingFromMap_shouldRetrieveLastPutObject() { + // given + List key1 = ImmutableList.of((byte)1, (byte)2, (byte)3); + List key2 = ImmutableList.of((byte)1, (byte)2, (byte)3); + String value1 = "value1"; + String value2 = "value2"; + Map, String> map = new HashMap<>(); + map.put(key1, value1); + map.put(key2, value2); + + // when + String retrievedValue1 = map.get(key1); + String retrievedValue2 = map.get(key2); + + // then + assertThat(key1).isEqualTo(key2); + assertThat(retrievedValue1).isEqualTo(value2); + assertThat(retrievedValue2).isEqualTo(value2); + assertThat(retrievedValue1).isEqualTo(retrievedValue2); + } + + @Test + void givenCustomWrapperKey_whenRetrievingFromMap_shouldRetrieveLastPutObject() { + // given + BytesKey key1 = new BytesKey(new byte[]{1, 2, 3}); + BytesKey key2 = new BytesKey(new byte[]{1, 2, 3}); + String value1 = "value1"; + String value2 = "value2"; + Map map = new HashMap<>(); + map.put(key1, value1); + map.put(key2, value2); + + // when + String retrievedValue1 = map.get(key1); + String retrievedValue2 = map.get(key2); + String retrievedValue3 = map.get(new BytesKey(new byte[]{1, 2, 3})); + + // then + assertThat(key1).isEqualTo(key2); + assertThat(retrievedValue1).isEqualTo(value2); + assertThat(retrievedValue2).isEqualTo(value2); + assertThat(retrievedValue1).isEqualTo(retrievedValue2); + assertThat(retrievedValue3).isEqualTo(value2); + + } +} From f542a4afabed15cd2617cae535ca2cfc2a294f81 Mon Sep 17 00:00:00 2001 From: Trixi-Turny Date: Fri, 18 Dec 2020 09:11:27 +0000 Subject: [PATCH 37/43] Bael 4457 list of json objects with rest template (#10058) * Add users.json * BAEL-4457 demo app with Object array and ParameterizedTypeReference example * BAEL-4457 write unit tests * BAEL-4456 remove new directory * BAEL-4457 fix pom and testname * BAEL-4457 use default target release * BAEL-4457 add more examples of processing the objects and address comments * BAEL-4457 remove new ArrayList and put @ResponseBody before public * BAEL-4457 use static userJson object * BAEL-4456 tidy up extra spaces * BAEL-4457 removed too many brackets * BAEL-4457 remove incorrect assertion * BAEL-4457 use a service instead of another controller * BAEL-4457 use ObjectMapper to extract usernames from objects * BAEL-4457 fix UserController * BAEL-4457 delete provider service and controller * BAEL-4457 use functional interface where possible * BAEL-4457 remove unnecessary annotations and tidy indents for exchange() * BAEL-4457 use @JsonCreator and @JsonProperty and resolve comments * BAEL-4457 improve comment * BAEL-4457 remove comments and use assertj core lib for assertions * BAEL-4457 fix indents Co-authored-by: Trixi Turny --- spring-resttemplate-2/pom.xml | 14 +- .../consumer/service/UserConsumerService.java | 16 +++ .../service/UserConsumerServiceImpl.java | 90 +++++++++++++ .../resttemplate/json/model/Address.java | 29 ++++ .../resttemplate/json/model/User.java | 30 +++++ .../UserConsumerServiceImplUnitTest.java | 127 ++++++++++++++++++ 6 files changed, 299 insertions(+), 7 deletions(-) create mode 100644 spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerService.java create mode 100644 spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImpl.java create mode 100644 spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/model/Address.java create mode 100644 spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/model/User.java create mode 100644 spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImplUnitTest.java diff --git a/spring-resttemplate-2/pom.xml b/spring-resttemplate-2/pom.xml index 2aed154be6..1404a35f33 100644 --- a/spring-resttemplate-2/pom.xml +++ b/spring-resttemplate-2/pom.xml @@ -71,16 +71,16 @@ ch.qos.logback logback-classic - + - + - - org.springframework.boot - spring-boot-maven-plugin - + + org.springframework.boot + spring-boot-maven-plugin + - + \ No newline at end of file diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerService.java b/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerService.java new file mode 100644 index 0000000000..751e234e8b --- /dev/null +++ b/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerService.java @@ -0,0 +1,16 @@ +package com.baeldung.resttemplate.json.consumer.service; + +import java.util.List; + +public interface UserConsumerService { + + List processUserDataFromObjectArray(); + + List processUserDataFromUserArray(); + + List processUserDataFromUserList(); + + List processNestedUserDataFromUserArray(); + + List processNestedUserDataFromUserList(); +} diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImpl.java b/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImpl.java new file mode 100644 index 0000000000..dc1566d971 --- /dev/null +++ b/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImpl.java @@ -0,0 +1,90 @@ +package com.baeldung.resttemplate.json.consumer.service; + +import com.baeldung.resttemplate.json.model.Address; +import com.baeldung.resttemplate.json.model.User; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class UserConsumerServiceImpl implements UserConsumerService { + + private static final String BASE_URL = "http://localhost:8080/users"; + private final RestTemplate restTemplate; + private static final ObjectMapper mapper = new ObjectMapper(); + + public UserConsumerServiceImpl(RestTemplate restTemplate) { + this.restTemplate = restTemplate; + } + + @Override + public List processUserDataFromObjectArray() { + ResponseEntity responseEntity = restTemplate.getForEntity(BASE_URL, Object[].class); + Object[] objects = responseEntity.getBody(); + return Arrays.stream(objects) + .map(object -> mapper.convertValue(object, User.class)) + .map(User::getName) + .collect(Collectors.toList()); + } + + @Override + public List processUserDataFromUserArray() { + ResponseEntity responseEntity = restTemplate.getForEntity(BASE_URL, User[].class); + User[] userArray = responseEntity.getBody(); + return Arrays.stream(userArray) + .map(User::getName) + .collect(Collectors.toList()); + } + + @Override + public List processUserDataFromUserList() { + ResponseEntity> responseEntity = + restTemplate.exchange( + BASE_URL, + HttpMethod.GET, + null, + new ParameterizedTypeReference>() {} + ); + List users = responseEntity.getBody(); + return users.stream() + .map(User::getName) + .collect(Collectors.toList()); + } + + @Override + public List processNestedUserDataFromUserArray() { + ResponseEntity responseEntity = restTemplate.getForEntity(BASE_URL, User[].class); + User[] userArray = responseEntity.getBody(); + //we can get more info if we need : + MediaType contentType = responseEntity.getHeaders().getContentType(); + HttpStatus statusCode = responseEntity.getStatusCode(); + + return Arrays.stream(userArray) + .flatMap(user -> user.getAddressList().stream()) + .map(Address::getPostCode) + .collect(Collectors.toList()); + } + + @Override + public List processNestedUserDataFromUserList() { + ResponseEntity> responseEntity = + restTemplate.exchange( + BASE_URL, + HttpMethod.GET, + null, + new ParameterizedTypeReference>() {} + ); + List userList = responseEntity.getBody(); + return userList.stream() + .flatMap(user -> user.getAddressList().stream()) + .map(Address::getPostCode) + .collect(Collectors.toList()); + } +} \ No newline at end of file diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/model/Address.java b/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/model/Address.java new file mode 100644 index 0000000000..f41ff4d8ea --- /dev/null +++ b/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/model/Address.java @@ -0,0 +1,29 @@ +package com.baeldung.resttemplate.json.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class Address { + private final String addressLine1; + private final String addressLine2; + private final String town; + private final String postCode; + + @JsonCreator + public Address( + @JsonProperty("addressLine1") String addressLine1, + @JsonProperty("addressLine2") String addressLine2, + @JsonProperty("town") String town, + @JsonProperty("postCode") String postCode) { + this.addressLine1 = addressLine1; + this.addressLine2 = addressLine2; + this.town = town; + this.postCode = postCode; + } + public String getPostCode() { + return postCode; + } +} diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/model/User.java b/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/model/User.java new file mode 100644 index 0000000000..8e02ef7787 --- /dev/null +++ b/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/model/User.java @@ -0,0 +1,30 @@ +package com.baeldung.resttemplate.json.model; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +@JsonInclude(JsonInclude.Include.NON_NULL) +public class User { + private final int id; + private final String name; + private final List

addressList; + + @JsonCreator + public User( + @JsonProperty("id") int id, + @JsonProperty("name") String name, + @JsonProperty("addressList") List
addressList) { + this.id = id; + this.name = name; + this.addressList = addressList; + } + + public String getName() { + return name; + } + + public List
getAddressList() { return addressList; } +} diff --git a/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImplUnitTest.java b/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImplUnitTest.java new file mode 100644 index 0000000000..4cc58e30f5 --- /dev/null +++ b/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImplUnitTest.java @@ -0,0 +1,127 @@ +package com.baeldung.resttemplate.json.consumer.service; + +import org.junit.Before; +import org.junit.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.test.web.client.ExpectedCount; +import org.springframework.test.web.client.MockRestServiceServer; +import org.springframework.web.client.RestTemplate; + +import java.util.Arrays; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; +import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; + +@SpringBootTest +public class UserConsumerServiceImplUnitTest { + + private static String USER_JSON = "[{\"id\":1,\"name\":\"user1\",\"addressList\":[{\"addressLine1\":\"address1_addressLine1\",\"addressLine2\":\"address1_addressLine2\",\"town\":\"address1_town\",\"postCode\":\"user1_address1_postCode\"}," + + "{\"addressLine1\":\"address2_addressLine1\",\"addressLine2\":\"address2_addressLine2\",\"town\":\"address2_town\",\"postCode\":\"user1_address2_postCode\"}]}," + + "{\"id\":2,\"name\":\"user2\",\"addressList\":[{\"addressLine1\":\"address1_addressLine1\",\"addressLine2\":\"address1_addressLine2\",\"town\":\"address1_town\",\"postCode\":\"user2_address1_postCode\"}]}]"; + + private MockRestServiceServer mockServer; + private final RestTemplate restTemplate = new RestTemplate(); + private final UserConsumerService tested = new UserConsumerServiceImpl(restTemplate); + + @Before + public void init() { + mockServer = MockRestServiceServer.createServer(restTemplate); + } + + @Test + public void whenProcessUserDataAsObjects_thenOK() { + String url = "http://localhost:8080/users"; + List expected = Arrays.asList("user1", "user2"); + + mockServer.expect(ExpectedCount.once(), + requestTo(url)) + .andExpect(method(HttpMethod.GET)) + .andRespond(withStatus(HttpStatus.OK) + .contentType(MediaType.APPLICATION_JSON) + .body(USER_JSON)); + + List actual = tested.processUserDataFromObjectArray(); + + mockServer.verify(); + assertThat(actual).containsExactly(expected.get(0), expected.get(1)); + } + + @Test + public void whenProcessUserDataAsArray_thenOK() { + String url = "http://localhost:8080/users"; + List expected = Arrays.asList("user1", "user2"); + + mockServer.expect(ExpectedCount.once(), + requestTo(url)) + .andExpect(method(HttpMethod.GET)) + .andRespond(withStatus(HttpStatus.OK) + .contentType(MediaType.APPLICATION_JSON) + .body(USER_JSON)); + + List actual = tested.processUserDataFromUserArray(); + + mockServer.verify(); + assertThat(actual).containsExactly(expected.get(0), expected.get(1)); + } + + @Test + public void whenProcessUserDataAsList_thenOK() { + String url = "http://localhost:8080/users"; + List expected = Arrays.asList("user1", "user2"); + + mockServer.expect(ExpectedCount.once(), + requestTo(url)) + .andExpect(method(HttpMethod.GET)) + .andRespond(withStatus(HttpStatus.OK) + .contentType(MediaType.APPLICATION_JSON) + .body(USER_JSON)); + + List actual = tested.processUserDataFromUserList(); + + mockServer.verify(); + assertThat(actual).containsExactly(expected.get(0), expected.get(1)); + } + + + @Test + public void whenProcessNestedUserDataFromArray_thenOK() { + String url = "http://localhost:8080/users"; + List expected = Arrays.asList("user1_address1_postCode", "user1_address2_postCode", "user2_address1_postCode"); + + mockServer.expect(ExpectedCount.once(), + requestTo(url)) + .andExpect(method(HttpMethod.GET)) + .andRespond(withStatus(HttpStatus.OK) + .contentType(MediaType.APPLICATION_JSON) + .body(USER_JSON)); + + List actual = tested.processNestedUserDataFromUserArray(); + + mockServer.verify(); + assertThat(actual).containsExactly(expected.get(0), expected.get(1), expected.get(2)); + } + + @Test + public void whenProcessNestedUserDataFromList_thenOK() { + String url = "http://localhost:8080/users"; + List expected = Arrays.asList("user1_address1_postCode", "user1_address2_postCode", "user2_address1_postCode"); + + mockServer.expect(ExpectedCount.once(), + requestTo(url)) + .andExpect(method(HttpMethod.GET)) + .andRespond(withStatus(HttpStatus.OK) + .contentType(MediaType.APPLICATION_JSON) + .body(USER_JSON)); + + List actual = tested.processNestedUserDataFromUserList(); + + mockServer.verify(); + assertThat(actual).containsExactly(expected.get(0), expected.get(1), expected.get(2)); + } +} \ No newline at end of file From df7af0d0ecde427e161d72aa4b089ea4298b83d2 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 20 Dec 2020 23:02:10 +0530 Subject: [PATCH 38/43] JAVA-3508: Create spring-web-modules parent --- pom.xml | 2 ++ spring-web-modules/pom.xml | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 spring-web-modules/pom.xml diff --git a/pom.xml b/pom.xml index 17e4fe1584..b309d027fb 100644 --- a/pom.xml +++ b/pom.xml @@ -714,6 +714,7 @@ spring-vault spring-vertx + spring-web-modules spring-webflux-amqp spring-websockets @@ -1199,6 +1200,7 @@ spring-vault spring-vertx + spring-web-modules spring-webflux-amqp spring-websockets diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml new file mode 100644 index 0000000000..df8b0d6562 --- /dev/null +++ b/spring-web-modules/pom.xml @@ -0,0 +1,19 @@ + + + 4.0.0 + spring-web-modules + 0.0.1-SNAPSHOT + spring-web-modules + pom + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + + From 17d2870daa871ff283ee9b50384bdad32e6b0e8a Mon Sep 17 00:00:00 2001 From: Sampada <46674082+sampada07@users.noreply.github.com> Date: Mon, 21 Dec 2020 01:19:26 +0530 Subject: [PATCH 39/43] BAEL-4751: Java 14 New Features (#10319) * BAEL-4751: Java 14 New Features * BAEL-4751: Code formatting * BAEL-4751: Consistent excpetion message * BAEL-4751: Changed assert --- .../java14/newfeatues/MultilineUnitTest.java | 26 ++++++++++ .../java14/newfeatues/RecordUnitTest.java | 38 ++++++++++++++ .../java14/newfeatues/SwitchExprUnitTest.java | 50 +++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 core-java-modules/core-java-14/src/test/java/com/baeldung/java14/newfeatues/MultilineUnitTest.java create mode 100644 core-java-modules/core-java-14/src/test/java/com/baeldung/java14/newfeatues/RecordUnitTest.java create mode 100644 core-java-modules/core-java-14/src/test/java/com/baeldung/java14/newfeatues/SwitchExprUnitTest.java diff --git a/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/newfeatues/MultilineUnitTest.java b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/newfeatues/MultilineUnitTest.java new file mode 100644 index 0000000000..4efd1ff362 --- /dev/null +++ b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/newfeatues/MultilineUnitTest.java @@ -0,0 +1,26 @@ +package com.baeldung.java14.newfeatues; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class MultilineUnitTest { + + @SuppressWarnings("preview") + String multiline = """ + A quick brown fox jumps over a lazy dog; \ + the lazy dog howls loudly."""; + + @SuppressWarnings("preview") + String anotherMultiline = """ + A quick brown fox jumps over a lazy dog; + the lazy dog howls loudly."""; + + @Test + public void givenMultilineString_whenSlashUsed_thenNoNewLine() { + assertFalse(multiline.contains("\n")); + assertTrue(anotherMultiline.contains("\n")); + } + +} diff --git a/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/newfeatues/RecordUnitTest.java b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/newfeatues/RecordUnitTest.java new file mode 100644 index 0000000000..3d7a55d3e6 --- /dev/null +++ b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/newfeatues/RecordUnitTest.java @@ -0,0 +1,38 @@ +package com.baeldung.java14.newfeatues; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class RecordUnitTest { + + @SuppressWarnings("preview") + public record User(int id, String password) { + }; + + private User user1 = new User(0, "UserOne"); + + @Test + public void givenRecord_whenObjInitialized_thenValuesCanBeFetchedWithGetters() { + + assertEquals(0, user1.id()); + assertEquals("UserOne", user1.password()); + } + + @Test + public void whenRecord_thenEqualsImplemented() { + + User user2 = user1; + + assertEquals(user1, user2); + } + + @Test + public void whenRecord_thenToStringImplemented() { + + assertTrue(user1.toString() + .contains("UserOne")); + } + +} diff --git a/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/newfeatues/SwitchExprUnitTest.java b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/newfeatues/SwitchExprUnitTest.java new file mode 100644 index 0000000000..896b3ec7de --- /dev/null +++ b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/newfeatues/SwitchExprUnitTest.java @@ -0,0 +1,50 @@ +package com.baeldung.java14.newfeatues; + +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SwitchExprUnitTest { + + @Test + public void givenDay_whenSunday_thenWeekend() { + assertTrue(isTodayHolidayInJava8("SUNDAY")); + + assertTrue(isTodayHolidayInJava14("SUNDAY")); + + assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> isTodayHolidayInJava8("SOMEDAY")); + + assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> isTodayHolidayInJava14("SOMEDAY")); + } + + private boolean isTodayHolidayInJava8(String day) { + + boolean isTodayHoliday; + switch (day) { + case "MONDAY": + case "TUESDAY": + case "WEDNESDAY": + case "THURSDAY": + case "FRIDAY": + isTodayHoliday = false; + break; + case "SATURDAY": + case "SUNDAY": + isTodayHoliday = true; + break; + default: + throw new IllegalArgumentException("What's a " + day); + } + return isTodayHoliday; + } + + private boolean isTodayHolidayInJava14(String day) { + return switch (day) { + case "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY" -> false; + case "SATURDAY", "SUNDAY" -> true; + default -> throw new IllegalArgumentException("What's a " + day); + }; + } + +} From dcd9eaf33a47d8e73d294aa7befcb6c455200db4 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 21 Dec 2020 19:52:50 +0530 Subject: [PATCH 40/43] JAVA-3509: Moved spring-mvc-basics inside spring-web-modules --- .../spring-mvc-basics}/.gitignore | 0 .../spring-mvc-basics}/README.md | 0 .../spring-mvc-basics}/pom.xml | 2 +- .../src/main/java/com/baeldung/Application.java | 0 .../main/java/com/baeldung/config/MainWebAppInitializer.java | 0 .../com/baeldung/customvalidator/ContactNumberConstraint.java | 0 .../com/baeldung/customvalidator/ContactNumberValidator.java | 0 .../java/com/baeldung/customvalidator/FieldsValueMatch.java | 0 .../com/baeldung/customvalidator/FieldsValueMatchValidator.java | 0 .../HttpMediaTypeNotAcceptableExceptionExampleController.java | 0 .../src/main/java/com/baeldung/model/Book.java | 0 .../src/main/java/com/baeldung/model/Employee.java | 0 .../src/main/java/com/baeldung/model/NewUserForm.java | 0 .../src/main/java/com/baeldung/model/User.java | 0 .../src/main/java/com/baeldung/model/ValidatedPhone.java | 0 .../src/main/java/com/baeldung/services/UserService.java | 0 .../src/main/java/com/baeldung/spring/web/config/WebConfig.java | 0 .../java/com/baeldung/web/controller/EmployeeController.java | 0 .../java/com/baeldung/web/controller/MultipartController.java | 0 .../java/com/baeldung/web/controller/NewUserController.java | 0 .../web/controller/RequestMappingShortcutsController.java | 0 .../baeldung/web/controller/ResponseStatusRestController.java | 0 .../main/java/com/baeldung/web/controller/SampleController.java | 0 .../java/com/baeldung/web/controller/SimpleBookController.java | 0 .../com/baeldung/web/controller/SimpleBookRestController.java | 0 .../main/java/com/baeldung/web/controller/UserController.java | 0 .../java/com/baeldung/web/controller/UserRestController.java | 0 .../com/baeldung/web/controller/ValidatedPhoneController.java | 0 .../handlermapping/BeanNameHandlerMappingController.java | 0 .../controller/handlermapping/SimpleUrlMappingController.java | 0 .../web/controller/handlermapping/WelcomeController.java | 0 .../src/main/resources/application.properties | 0 .../spring-mvc-basics}/src/main/resources/mvc-configuration.xml | 0 .../src/main/resources/themes/default.properties | 0 .../src/main/resources/themes/example.properties | 0 .../spring-mvc-basics}/src/main/resources/views.properties | 0 .../spring-mvc-basics}/src/main/resources/views.xml | 0 .../src/main/webapp/WEB-INF/view/employeeHome.jsp | 0 .../src/main/webapp/WEB-INF/view/employeeView.jsp | 0 .../spring-mvc-basics}/src/main/webapp/WEB-INF/view/index.jsp | 0 .../src/main/webapp/WEB-INF/view/phoneHome.jsp | 0 .../spring-mvc-basics}/src/main/webapp/WEB-INF/view/sample.jsp | 0 .../src/main/webapp/WEB-INF/view/userHome.jsp | 0 .../src/main/webapp/WEB-INF/view2/sample2.jsp | 0 .../src/main/webapp/WEB-INF/view3/sample3.jsp | 0 .../src/test/java/com/baeldung/SpringContextTest.java | 0 .../com/baeldung/config/BeanNameUrlHandlerMappingConfig.java | 0 .../java/com/baeldung/config/HandlerMappingDefaultConfig.java | 0 .../com/baeldung/config/HandlerMappingPrioritiesConfig.java | 0 .../java/com/baeldung/config/SimpleUrlHandlerMappingConfig.java | 0 ...ediaTypeNotAcceptableExceptionControllerIntegrationTest.java | 0 .../handlermappings/BeanNameMappingConfigIntegrationTest.java | 0 .../HandlerMappingDefaultConfigIntegrationTest.java | 0 .../HandlerMappingPriorityConfigIntegrationTest.java | 0 .../handlermappings/SimpleUrlMappingConfigIntegrationTest.java | 0 .../web/controller/ClassValidationMvcIntegrationTest.java | 0 .../web/controller/CustomMVCValidatorIntegrationTest.java | 0 .../EmployeeControllerContentNegotiationIntegrationTest.java | 0 .../EmployeeControllerModelAttributeIntegrationTest.java | 0 .../web/controller/RequestMapingShortcutsIntegrationTest.java | 0 .../controller/ResponseStatusRestControllerIntegrationTest.java | 0 .../com/baeldung/web/controller/SampleControllerLiveTest.java | 0 .../web/controller/SimpleBookControllerIntegrationTest.java | 0 .../web/controller/SimpleBookRestControllerIntegrationTest.java | 0 .../src/test/resources/BeanNameUrlHandlerMappingConfig.xml | 0 .../test/resources/ControllerClassNameHandlerMappingConfig.xml | 0 .../src/test/resources/HandlerMappingConfiguringPriorities.xml | 0 .../src/test/resources/SimpleUrlHandlerMappingConfig.xml | 0 68 files changed, 1 insertion(+), 1 deletion(-) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/.gitignore (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/README.md (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/pom.xml (97%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/Application.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/config/MainWebAppInitializer.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/customvalidator/ContactNumberConstraint.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/customvalidator/ContactNumberValidator.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/customvalidator/FieldsValueMatch.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/customvalidator/FieldsValueMatchValidator.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/exception/HttpMediaTypeNotAcceptableExceptionExampleController.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/model/Book.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/model/Employee.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/model/NewUserForm.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/model/User.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/model/ValidatedPhone.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/services/UserService.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/spring/web/config/WebConfig.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/web/controller/EmployeeController.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/web/controller/MultipartController.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/web/controller/NewUserController.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/web/controller/RequestMappingShortcutsController.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/web/controller/ResponseStatusRestController.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/web/controller/SampleController.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/web/controller/SimpleBookController.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/web/controller/SimpleBookRestController.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/web/controller/UserController.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/web/controller/UserRestController.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/web/controller/ValidatedPhoneController.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/web/controller/handlermapping/BeanNameHandlerMappingController.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/web/controller/handlermapping/SimpleUrlMappingController.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/java/com/baeldung/web/controller/handlermapping/WelcomeController.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/resources/application.properties (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/resources/mvc-configuration.xml (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/resources/themes/default.properties (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/resources/themes/example.properties (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/resources/views.properties (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/resources/views.xml (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/webapp/WEB-INF/view/employeeHome.jsp (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/webapp/WEB-INF/view/employeeView.jsp (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/webapp/WEB-INF/view/index.jsp (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/webapp/WEB-INF/view/phoneHome.jsp (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/webapp/WEB-INF/view/sample.jsp (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/webapp/WEB-INF/view/userHome.jsp (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/webapp/WEB-INF/view2/sample2.jsp (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/main/webapp/WEB-INF/view3/sample3.jsp (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/SpringContextTest.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/config/BeanNameUrlHandlerMappingConfig.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/config/HandlerMappingDefaultConfig.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/config/HandlerMappingPrioritiesConfig.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/config/SimpleUrlHandlerMappingConfig.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/exception/HttpMediaTypeNotAcceptableExceptionControllerIntegrationTest.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/handlermappings/BeanNameMappingConfigIntegrationTest.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/handlermappings/HandlerMappingDefaultConfigIntegrationTest.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/handlermappings/HandlerMappingPriorityConfigIntegrationTest.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/handlermappings/SimpleUrlMappingConfigIntegrationTest.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/web/controller/ClassValidationMvcIntegrationTest.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/web/controller/CustomMVCValidatorIntegrationTest.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/web/controller/EmployeeControllerContentNegotiationIntegrationTest.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/web/controller/EmployeeControllerModelAttributeIntegrationTest.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/web/controller/RequestMapingShortcutsIntegrationTest.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/web/controller/ResponseStatusRestControllerIntegrationTest.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/web/controller/SampleControllerLiveTest.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/web/controller/SimpleBookControllerIntegrationTest.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/java/com/baeldung/web/controller/SimpleBookRestControllerIntegrationTest.java (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/resources/BeanNameUrlHandlerMappingConfig.xml (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/resources/ControllerClassNameHandlerMappingConfig.xml (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/resources/HandlerMappingConfiguringPriorities.xml (100%) rename {spring-mvc-basics => spring-web-modules/spring-mvc-basics}/src/test/resources/SimpleUrlHandlerMappingConfig.xml (100%) diff --git a/spring-mvc-basics/.gitignore b/spring-web-modules/spring-mvc-basics/.gitignore similarity index 100% rename from spring-mvc-basics/.gitignore rename to spring-web-modules/spring-mvc-basics/.gitignore diff --git a/spring-mvc-basics/README.md b/spring-web-modules/spring-mvc-basics/README.md similarity index 100% rename from spring-mvc-basics/README.md rename to spring-web-modules/spring-mvc-basics/README.md diff --git a/spring-mvc-basics/pom.xml b/spring-web-modules/spring-mvc-basics/pom.xml similarity index 97% rename from spring-mvc-basics/pom.xml rename to spring-web-modules/spring-mvc-basics/pom.xml index cd486cb1d3..ac92c7bfe5 100644 --- a/spring-mvc-basics/pom.xml +++ b/spring-web-modules/spring-mvc-basics/pom.xml @@ -12,7 +12,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-mvc-basics/src/main/java/com/baeldung/Application.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/Application.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/Application.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/Application.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/config/MainWebAppInitializer.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/config/MainWebAppInitializer.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/config/MainWebAppInitializer.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/config/MainWebAppInitializer.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/ContactNumberConstraint.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/ContactNumberConstraint.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/customvalidator/ContactNumberConstraint.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/ContactNumberConstraint.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/ContactNumberValidator.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/ContactNumberValidator.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/customvalidator/ContactNumberValidator.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/ContactNumberValidator.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/FieldsValueMatch.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/FieldsValueMatch.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/customvalidator/FieldsValueMatch.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/FieldsValueMatch.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/FieldsValueMatchValidator.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/FieldsValueMatchValidator.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/customvalidator/FieldsValueMatchValidator.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/FieldsValueMatchValidator.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/exception/HttpMediaTypeNotAcceptableExceptionExampleController.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/exception/HttpMediaTypeNotAcceptableExceptionExampleController.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/exception/HttpMediaTypeNotAcceptableExceptionExampleController.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/exception/HttpMediaTypeNotAcceptableExceptionExampleController.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/model/Book.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/model/Book.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/model/Book.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/model/Book.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/model/Employee.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/model/Employee.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/model/Employee.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/model/Employee.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/model/NewUserForm.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/model/NewUserForm.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/model/NewUserForm.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/model/NewUserForm.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/model/User.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/model/User.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/model/User.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/model/User.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/model/ValidatedPhone.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/model/ValidatedPhone.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/model/ValidatedPhone.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/model/ValidatedPhone.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/services/UserService.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/services/UserService.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/services/UserService.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/services/UserService.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/spring/web/config/WebConfig.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/spring/web/config/WebConfig.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/spring/web/config/WebConfig.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/spring/web/config/WebConfig.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/EmployeeController.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/EmployeeController.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/web/controller/EmployeeController.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/EmployeeController.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/MultipartController.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/MultipartController.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/web/controller/MultipartController.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/MultipartController.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/NewUserController.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/NewUserController.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/web/controller/NewUserController.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/NewUserController.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/RequestMappingShortcutsController.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/RequestMappingShortcutsController.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/web/controller/RequestMappingShortcutsController.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/RequestMappingShortcutsController.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/ResponseStatusRestController.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/ResponseStatusRestController.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/web/controller/ResponseStatusRestController.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/ResponseStatusRestController.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/SampleController.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/SampleController.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/web/controller/SampleController.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/SampleController.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/SimpleBookController.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/SimpleBookController.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/web/controller/SimpleBookController.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/SimpleBookController.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/SimpleBookRestController.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/SimpleBookRestController.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/web/controller/SimpleBookRestController.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/SimpleBookRestController.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/UserController.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/UserController.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/web/controller/UserController.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/UserController.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/UserRestController.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/UserRestController.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/web/controller/UserRestController.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/UserRestController.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/ValidatedPhoneController.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/ValidatedPhoneController.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/web/controller/ValidatedPhoneController.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/ValidatedPhoneController.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/BeanNameHandlerMappingController.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/BeanNameHandlerMappingController.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/BeanNameHandlerMappingController.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/BeanNameHandlerMappingController.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/SimpleUrlMappingController.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/SimpleUrlMappingController.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/SimpleUrlMappingController.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/SimpleUrlMappingController.java diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/WelcomeController.java b/spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/WelcomeController.java similarity index 100% rename from spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/WelcomeController.java rename to spring-web-modules/spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/WelcomeController.java diff --git a/spring-mvc-basics/src/main/resources/application.properties b/spring-web-modules/spring-mvc-basics/src/main/resources/application.properties similarity index 100% rename from spring-mvc-basics/src/main/resources/application.properties rename to spring-web-modules/spring-mvc-basics/src/main/resources/application.properties diff --git a/spring-mvc-basics/src/main/resources/mvc-configuration.xml b/spring-web-modules/spring-mvc-basics/src/main/resources/mvc-configuration.xml similarity index 100% rename from spring-mvc-basics/src/main/resources/mvc-configuration.xml rename to spring-web-modules/spring-mvc-basics/src/main/resources/mvc-configuration.xml diff --git a/spring-mvc-basics/src/main/resources/themes/default.properties b/spring-web-modules/spring-mvc-basics/src/main/resources/themes/default.properties similarity index 100% rename from spring-mvc-basics/src/main/resources/themes/default.properties rename to spring-web-modules/spring-mvc-basics/src/main/resources/themes/default.properties diff --git a/spring-mvc-basics/src/main/resources/themes/example.properties b/spring-web-modules/spring-mvc-basics/src/main/resources/themes/example.properties similarity index 100% rename from spring-mvc-basics/src/main/resources/themes/example.properties rename to spring-web-modules/spring-mvc-basics/src/main/resources/themes/example.properties diff --git a/spring-mvc-basics/src/main/resources/views.properties b/spring-web-modules/spring-mvc-basics/src/main/resources/views.properties similarity index 100% rename from spring-mvc-basics/src/main/resources/views.properties rename to spring-web-modules/spring-mvc-basics/src/main/resources/views.properties diff --git a/spring-mvc-basics/src/main/resources/views.xml b/spring-web-modules/spring-mvc-basics/src/main/resources/views.xml similarity index 100% rename from spring-mvc-basics/src/main/resources/views.xml rename to spring-web-modules/spring-mvc-basics/src/main/resources/views.xml diff --git a/spring-mvc-basics/src/main/webapp/WEB-INF/view/employeeHome.jsp b/spring-web-modules/spring-mvc-basics/src/main/webapp/WEB-INF/view/employeeHome.jsp similarity index 100% rename from spring-mvc-basics/src/main/webapp/WEB-INF/view/employeeHome.jsp rename to spring-web-modules/spring-mvc-basics/src/main/webapp/WEB-INF/view/employeeHome.jsp diff --git a/spring-mvc-basics/src/main/webapp/WEB-INF/view/employeeView.jsp b/spring-web-modules/spring-mvc-basics/src/main/webapp/WEB-INF/view/employeeView.jsp similarity index 100% rename from spring-mvc-basics/src/main/webapp/WEB-INF/view/employeeView.jsp rename to spring-web-modules/spring-mvc-basics/src/main/webapp/WEB-INF/view/employeeView.jsp diff --git a/spring-mvc-basics/src/main/webapp/WEB-INF/view/index.jsp b/spring-web-modules/spring-mvc-basics/src/main/webapp/WEB-INF/view/index.jsp similarity index 100% rename from spring-mvc-basics/src/main/webapp/WEB-INF/view/index.jsp rename to spring-web-modules/spring-mvc-basics/src/main/webapp/WEB-INF/view/index.jsp diff --git a/spring-mvc-basics/src/main/webapp/WEB-INF/view/phoneHome.jsp b/spring-web-modules/spring-mvc-basics/src/main/webapp/WEB-INF/view/phoneHome.jsp similarity index 100% rename from spring-mvc-basics/src/main/webapp/WEB-INF/view/phoneHome.jsp rename to spring-web-modules/spring-mvc-basics/src/main/webapp/WEB-INF/view/phoneHome.jsp diff --git a/spring-mvc-basics/src/main/webapp/WEB-INF/view/sample.jsp b/spring-web-modules/spring-mvc-basics/src/main/webapp/WEB-INF/view/sample.jsp similarity index 100% rename from spring-mvc-basics/src/main/webapp/WEB-INF/view/sample.jsp rename to spring-web-modules/spring-mvc-basics/src/main/webapp/WEB-INF/view/sample.jsp diff --git a/spring-mvc-basics/src/main/webapp/WEB-INF/view/userHome.jsp b/spring-web-modules/spring-mvc-basics/src/main/webapp/WEB-INF/view/userHome.jsp similarity index 100% rename from spring-mvc-basics/src/main/webapp/WEB-INF/view/userHome.jsp rename to spring-web-modules/spring-mvc-basics/src/main/webapp/WEB-INF/view/userHome.jsp diff --git a/spring-mvc-basics/src/main/webapp/WEB-INF/view2/sample2.jsp b/spring-web-modules/spring-mvc-basics/src/main/webapp/WEB-INF/view2/sample2.jsp similarity index 100% rename from spring-mvc-basics/src/main/webapp/WEB-INF/view2/sample2.jsp rename to spring-web-modules/spring-mvc-basics/src/main/webapp/WEB-INF/view2/sample2.jsp diff --git a/spring-mvc-basics/src/main/webapp/WEB-INF/view3/sample3.jsp b/spring-web-modules/spring-mvc-basics/src/main/webapp/WEB-INF/view3/sample3.jsp similarity index 100% rename from spring-mvc-basics/src/main/webapp/WEB-INF/view3/sample3.jsp rename to spring-web-modules/spring-mvc-basics/src/main/webapp/WEB-INF/view3/sample3.jsp diff --git a/spring-mvc-basics/src/test/java/com/baeldung/SpringContextTest.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/SpringContextTest.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/config/BeanNameUrlHandlerMappingConfig.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/config/BeanNameUrlHandlerMappingConfig.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/config/BeanNameUrlHandlerMappingConfig.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/config/BeanNameUrlHandlerMappingConfig.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/config/HandlerMappingDefaultConfig.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/config/HandlerMappingDefaultConfig.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/config/HandlerMappingDefaultConfig.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/config/HandlerMappingDefaultConfig.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/config/HandlerMappingPrioritiesConfig.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/config/HandlerMappingPrioritiesConfig.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/config/HandlerMappingPrioritiesConfig.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/config/HandlerMappingPrioritiesConfig.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/config/SimpleUrlHandlerMappingConfig.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/config/SimpleUrlHandlerMappingConfig.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/config/SimpleUrlHandlerMappingConfig.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/config/SimpleUrlHandlerMappingConfig.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/exception/HttpMediaTypeNotAcceptableExceptionControllerIntegrationTest.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/exception/HttpMediaTypeNotAcceptableExceptionControllerIntegrationTest.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/exception/HttpMediaTypeNotAcceptableExceptionControllerIntegrationTest.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/exception/HttpMediaTypeNotAcceptableExceptionControllerIntegrationTest.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/handlermappings/BeanNameMappingConfigIntegrationTest.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/handlermappings/BeanNameMappingConfigIntegrationTest.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/handlermappings/BeanNameMappingConfigIntegrationTest.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/handlermappings/BeanNameMappingConfigIntegrationTest.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/handlermappings/HandlerMappingDefaultConfigIntegrationTest.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/handlermappings/HandlerMappingDefaultConfigIntegrationTest.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/handlermappings/HandlerMappingDefaultConfigIntegrationTest.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/handlermappings/HandlerMappingDefaultConfigIntegrationTest.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/handlermappings/HandlerMappingPriorityConfigIntegrationTest.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/handlermappings/HandlerMappingPriorityConfigIntegrationTest.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/handlermappings/HandlerMappingPriorityConfigIntegrationTest.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/handlermappings/HandlerMappingPriorityConfigIntegrationTest.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/handlermappings/SimpleUrlMappingConfigIntegrationTest.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/handlermappings/SimpleUrlMappingConfigIntegrationTest.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/handlermappings/SimpleUrlMappingConfigIntegrationTest.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/handlermappings/SimpleUrlMappingConfigIntegrationTest.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/web/controller/ClassValidationMvcIntegrationTest.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/ClassValidationMvcIntegrationTest.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/web/controller/ClassValidationMvcIntegrationTest.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/ClassValidationMvcIntegrationTest.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/web/controller/CustomMVCValidatorIntegrationTest.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/CustomMVCValidatorIntegrationTest.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/web/controller/CustomMVCValidatorIntegrationTest.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/CustomMVCValidatorIntegrationTest.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/web/controller/EmployeeControllerContentNegotiationIntegrationTest.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/EmployeeControllerContentNegotiationIntegrationTest.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/web/controller/EmployeeControllerContentNegotiationIntegrationTest.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/EmployeeControllerContentNegotiationIntegrationTest.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/web/controller/EmployeeControllerModelAttributeIntegrationTest.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/EmployeeControllerModelAttributeIntegrationTest.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/web/controller/EmployeeControllerModelAttributeIntegrationTest.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/EmployeeControllerModelAttributeIntegrationTest.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/web/controller/RequestMapingShortcutsIntegrationTest.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/RequestMapingShortcutsIntegrationTest.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/web/controller/RequestMapingShortcutsIntegrationTest.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/RequestMapingShortcutsIntegrationTest.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/web/controller/ResponseStatusRestControllerIntegrationTest.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/ResponseStatusRestControllerIntegrationTest.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/web/controller/ResponseStatusRestControllerIntegrationTest.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/ResponseStatusRestControllerIntegrationTest.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SampleControllerLiveTest.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SampleControllerLiveTest.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/web/controller/SampleControllerLiveTest.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SampleControllerLiveTest.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookControllerIntegrationTest.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookControllerIntegrationTest.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookControllerIntegrationTest.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookControllerIntegrationTest.java diff --git a/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookRestControllerIntegrationTest.java b/spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookRestControllerIntegrationTest.java similarity index 100% rename from spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookRestControllerIntegrationTest.java rename to spring-web-modules/spring-mvc-basics/src/test/java/com/baeldung/web/controller/SimpleBookRestControllerIntegrationTest.java diff --git a/spring-mvc-basics/src/test/resources/BeanNameUrlHandlerMappingConfig.xml b/spring-web-modules/spring-mvc-basics/src/test/resources/BeanNameUrlHandlerMappingConfig.xml similarity index 100% rename from spring-mvc-basics/src/test/resources/BeanNameUrlHandlerMappingConfig.xml rename to spring-web-modules/spring-mvc-basics/src/test/resources/BeanNameUrlHandlerMappingConfig.xml diff --git a/spring-mvc-basics/src/test/resources/ControllerClassNameHandlerMappingConfig.xml b/spring-web-modules/spring-mvc-basics/src/test/resources/ControllerClassNameHandlerMappingConfig.xml similarity index 100% rename from spring-mvc-basics/src/test/resources/ControllerClassNameHandlerMappingConfig.xml rename to spring-web-modules/spring-mvc-basics/src/test/resources/ControllerClassNameHandlerMappingConfig.xml diff --git a/spring-mvc-basics/src/test/resources/HandlerMappingConfiguringPriorities.xml b/spring-web-modules/spring-mvc-basics/src/test/resources/HandlerMappingConfiguringPriorities.xml similarity index 100% rename from spring-mvc-basics/src/test/resources/HandlerMappingConfiguringPriorities.xml rename to spring-web-modules/spring-mvc-basics/src/test/resources/HandlerMappingConfiguringPriorities.xml diff --git a/spring-mvc-basics/src/test/resources/SimpleUrlHandlerMappingConfig.xml b/spring-web-modules/spring-mvc-basics/src/test/resources/SimpleUrlHandlerMappingConfig.xml similarity index 100% rename from spring-mvc-basics/src/test/resources/SimpleUrlHandlerMappingConfig.xml rename to spring-web-modules/spring-mvc-basics/src/test/resources/SimpleUrlHandlerMappingConfig.xml From faa64a1f7591ff43e458d721d01a2f7861c944ed Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 21 Dec 2020 19:53:49 +0530 Subject: [PATCH 41/43] JAVA-3509: Added module to new parent's pom --- spring-web-modules/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index df8b0d6562..29a90b5bd2 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -14,6 +14,7 @@ + spring-mvc-basics From c531b9851d8168a86a184959a13a5482dbd62896 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 21 Dec 2020 19:56:23 +0530 Subject: [PATCH 42/43] JAVA-3509: Updated README to change link from http to https --- spring-web-modules/spring-mvc-basics/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-web-modules/spring-mvc-basics/README.md b/spring-web-modules/spring-mvc-basics/README.md index dea18a1619..49d23aef25 100644 --- a/spring-web-modules/spring-mvc-basics/README.md +++ b/spring-web-modules/spring-mvc-basics/README.md @@ -4,7 +4,7 @@ This module contains articles about the basics of Spring MVC. Articles about mor their own module. ### The Course -The "REST With Spring" Classes: http://bit.ly/restwithspring +The "REST With Spring" Classes: https://bit.ly/restwithspring ### Relevant Articles: - [Spring MVC Tutorial](https://www.baeldung.com/spring-mvc-tutorial) From b89b16b430e77e5b811a82e484ef5740d61e6936 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 21 Dec 2020 19:57:39 +0530 Subject: [PATCH 43/43] JAVA-3509: removed module spring-mvc-basics from main pom --- pom.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index b309d027fb..f6e3ddad6c 100644 --- a/pom.xml +++ b/pom.xml @@ -662,8 +662,7 @@ spring-mobile spring-mockito - - spring-mvc-basics + spring-mvc-basics-2 spring-mvc-basics-3 spring-mvc-basics-4 @@ -1149,8 +1148,7 @@ spring-mobile spring-mockito - - spring-mvc-basics + spring-mvc-basics-2 spring-mvc-basics-3 spring-mvc-basics-4