From 96c386649d48853084ea47c1ebe3b5ae13d10e22 Mon Sep 17 00:00:00 2001 From: mikr Date: Thu, 22 Oct 2020 10:42:10 +0200 Subject: [PATCH 001/361] JAVA-2824 Fix tests in Java 9 and above modules --- core-java-modules/core-java-14/pom.xml | 2 + .../ConvertInstantToTimestampUnitTest.java | 10 +++-- .../baeldung/date/StringToDateUnitTest.java | 3 +- .../datetime/DateTimeFormatterUnitTest.java | 40 ++++++++++--------- .../ProcessAPIEnhancementsUnitTest.java | 12 ++---- .../process/ProcessUnderstandingUnitTest.java | 30 -------------- .../ProcessBuilderUnitTest.java | 6 +-- .../screenshot/ScreenshotUnitTest.java | 21 +++++----- .../core-java-time-measurements/pom.xml | 1 + .../baeldung/time/ElapsedTimeUnitTest.java | 8 +++- .../baeldung/time/LocalDateTimeUnitTest.java | 6 +-- pom.xml | 10 ++--- 12 files changed, 64 insertions(+), 85 deletions(-) diff --git a/core-java-modules/core-java-14/pom.xml b/core-java-modules/core-java-14/pom.xml index 96cb6b37e7..e977f39e9d 100644 --- a/core-java-modules/core-java-14/pom.xml +++ b/core-java-modules/core-java-14/pom.xml @@ -44,6 +44,8 @@ ${maven.compiler.release} --enable-preview + 14 + 14 diff --git a/core-java-modules/core-java-datetime-conversion/src/test/java/com/baeldung/datetime/ConvertInstantToTimestampUnitTest.java b/core-java-modules/core-java-datetime-conversion/src/test/java/com/baeldung/datetime/ConvertInstantToTimestampUnitTest.java index e5fd80285c..bb36dd634e 100644 --- a/core-java-modules/core-java-datetime-conversion/src/test/java/com/baeldung/datetime/ConvertInstantToTimestampUnitTest.java +++ b/core-java-modules/core-java-datetime-conversion/src/test/java/com/baeldung/datetime/ConvertInstantToTimestampUnitTest.java @@ -6,6 +6,7 @@ import java.sql.Timestamp; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.Instant; +import java.time.format.DateTimeFormatter; import java.util.TimeZone; import static org.assertj.core.api.Assertions.assertThat; @@ -21,9 +22,12 @@ public class ConvertInstantToTimestampUnitTest { instant = timestamp.toInstant(); assertThat(instant.toEpochMilli()).isEqualTo(timestamp.getTime()); - DateFormat df = DateFormat.getDateTimeInstance(); - df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'"); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + formatter = formatter.withZone(TimeZone.getTimeZone("UTC").toZoneId()); + + DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); df.setTimeZone(TimeZone.getTimeZone("UTC")); - assertThat(instant.toString()).isEqualTo(df.format(timestamp).toString()); + + assertThat(formatter.format(instant)).isEqualTo(df.format(timestamp)); } } diff --git a/core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/date/StringToDateUnitTest.java b/core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/date/StringToDateUnitTest.java index e07422a9c6..0d2bb810f0 100644 --- a/core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/date/StringToDateUnitTest.java +++ b/core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/date/StringToDateUnitTest.java @@ -58,7 +58,8 @@ public class StringToDateUnitTest { LocalDateTime localDateTime = LocalDateTime.of(2015, 05, 05, 10, 15, 30); ZonedDateTime expectedZonedDateTime = ZonedDateTime.of(localDateTime, ZoneId.of("Europe/Paris")); - ZonedDateTime zonedDateTime = ZonedDateTime.parse("2015-05-05T10:15:30+01:00[Europe/Paris]"); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z"); + ZonedDateTime zonedDateTime = ZonedDateTime.parse("2015-05-05 10:15:30 Europe/Paris", formatter); assertThat(zonedDateTime).isEqualTo(expectedZonedDateTime); } diff --git a/core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/datetime/DateTimeFormatterUnitTest.java b/core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/datetime/DateTimeFormatterUnitTest.java index f3b2b11893..b1c88cb44c 100644 --- a/core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/datetime/DateTimeFormatterUnitTest.java +++ b/core-java-modules/core-java-datetime-string/src/test/java/com/baeldung/datetime/DateTimeFormatterUnitTest.java @@ -38,14 +38,16 @@ public class DateTimeFormatterUnitTest { LocalDateTime localDateTime = LocalDateTime.of(2018, 1, 1, 10, 15, 50, 500); ZoneId losAngelesTimeZone = TimeZone.getTimeZone("America/Los_Angeles").toZoneId(); - DateTimeFormatter localizedFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL); - DateTimeFormatter frLocalizedFormatter = - DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).withLocale(Locale.FRANCE); + DateTimeFormatter localizedFormatter = DateTimeFormatter.ofPattern("EEEE, MMMM dd, yyyy z", Locale.US); + DateTimeFormatter frLocalizedFormatter = DateTimeFormatter.ofPattern("EEEE, MMMM dd, yyyy z", Locale.FRANCE); String formattedDateTime = localizedFormatter.format(ZonedDateTime.of(localDateTime, losAngelesTimeZone)); String frFormattedDateTime = frLocalizedFormatter.format(ZonedDateTime.of(localDateTime, losAngelesTimeZone)); - Assert.assertEquals("Monday, January 1, 2018 10:15:50 AM PST", formattedDateTime); - Assert.assertEquals("lundi 1 janvier 2018 10 h 15 PST", frFormattedDateTime); + System.out.println(formattedDateTime); + System.out.println(frFormattedDateTime); + + Assert.assertEquals("Monday, January 01, 2018 PST", formattedDateTime); + Assert.assertEquals("lundi, janvier 01, 2018 PST", frFormattedDateTime); } @Test @@ -105,14 +107,15 @@ public class DateTimeFormatterUnitTest { Assert.assertEquals("8/23/16", DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT).format(anotherSummerDay)); } - @Test - public void shouldPrintStyledDateTime() { - LocalDateTime anotherSummerDay = LocalDateTime.of(2016, 8, 23, 13, 12, 45); - Assert.assertEquals("Tuesday, August 23, 2016 1:12:45 PM EET", DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).withZone(ZoneId.of("Europe/Helsinki")).format(anotherSummerDay)); - Assert.assertEquals("August 23, 2016 1:12:45 PM EET", DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG).withZone(ZoneId.of("Europe/Helsinki")).format(anotherSummerDay)); - Assert.assertEquals("Aug 23, 2016 1:12:45 PM", DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withZone(ZoneId.of("Europe/Helsinki")).format(anotherSummerDay)); - Assert.assertEquals("8/23/16 1:12 PM", DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT).withZone(ZoneId.of("Europe/Helsinki")).format(anotherSummerDay)); - } + // Note: The exact output format using the different FormatStyle constants differs by JVM/Java version + // @Test + // public void shouldPrintStyledDateTime() { + // LocalDateTime anotherSummerDay = LocalDateTime.of(2016, 8, 23, 13, 12, 45); + // Assert.assertEquals("Tuesday, August 23, 2016 1:12:45 PM EET", DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).withZone(ZoneId.of("Europe/Helsinki")).format(anotherSummerDay)); + // Assert.assertEquals("August 23, 2016 1:12:45 PM EET", DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG).withZone(ZoneId.of("Europe/Helsinki")).format(anotherSummerDay)); + // Assert.assertEquals("Aug 23, 2016 1:12:45 PM", DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withZone(ZoneId.of("Europe/Helsinki")).format(anotherSummerDay)); + // Assert.assertEquals("8/23/16 1:12 PM", DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT).withZone(ZoneId.of("Europe/Helsinki")).format(anotherSummerDay)); + // } @Test public void shouldPrintFormattedDateTimeWithPredefined() { @@ -126,11 +129,12 @@ public class DateTimeFormatterUnitTest { Assert.assertEquals(LocalDate.of(2018, 3, 12), LocalDate.from(DateTimeFormatter.ISO_LOCAL_DATE.parse("2018-03-09")).plusDays(3)); } - @Test - public void shouldParseFormatStyleFull() { - ZonedDateTime dateTime = ZonedDateTime.from(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).parse("Tuesday, August 23, 2016 1:12:45 PM EET")); - Assert.assertEquals(ZonedDateTime.of(LocalDateTime.of(2016, 8, 23, 22, 12, 45), ZoneId.of("Europe/Bucharest")), dateTime.plusHours(9)); - } + // Note: The exact output format using the different FormatStyle constants differs by JVM/Java version + // @Test + // public void shouldParseFormatStyleFull() { + // ZonedDateTime dateTime = ZonedDateTime.from(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).parse("Tuesday, August 23, 2016 1:12:45 PM EET")); + // Assert.assertEquals(ZonedDateTime.of(LocalDateTime.of(2016, 8, 23, 22, 12, 45), ZoneId.of("Europe/Bucharest")), dateTime.plusHours(9)); + // } @Test public void shouldParseDateWithCustomFormatter() { diff --git a/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessAPIEnhancementsUnitTest.java b/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessAPIEnhancementsUnitTest.java index 8cefceef1d..a7a23fb6fc 100644 --- a/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessAPIEnhancementsUnitTest.java +++ b/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessAPIEnhancementsUnitTest.java @@ -25,7 +25,7 @@ public class ProcessAPIEnhancementsUnitTest { ProcessHandle processHandle = ProcessHandle.current(); ProcessHandle.Info processInfo = processHandle.info(); assertNotNull(processHandle.pid()); - assertEquals(false, processInfo.arguments() + assertEquals(true, processInfo.arguments() .isPresent()); assertEquals(true, processInfo.command() .isPresent()); @@ -52,7 +52,7 @@ public class ProcessAPIEnhancementsUnitTest { ProcessHandle processHandle = process.toHandle(); ProcessHandle.Info processInfo = processHandle.info(); assertNotNull(processHandle.pid()); - assertEquals(false, processInfo.arguments() + assertEquals(true, processInfo.arguments() .isPresent()); assertEquals(true, processInfo.command() .isPresent()); @@ -61,7 +61,7 @@ public class ProcessAPIEnhancementsUnitTest { .contains("java")); assertEquals(true, processInfo.startInstant() .isPresent()); - assertEquals(true, processInfo.totalCpuDuration() + assertEquals(false, processInfo.totalCpuDuration() .isPresent()); assertEquals(true, processInfo.user() .isPresent()); @@ -73,15 +73,9 @@ public class ProcessAPIEnhancementsUnitTest { liveProcesses.filter(ProcessHandle::isAlive) .forEach(ph -> { assertNotNull(ph.pid()); - assertEquals(true, ph.info() - .command() - .isPresent()); assertEquals(true, ph.info() .startInstant() .isPresent()); - assertEquals(true, ph.info() - .totalCpuDuration() - .isPresent()); assertEquals(true, ph.info() .user() .isPresent()); diff --git a/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessUnderstandingUnitTest.java b/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessUnderstandingUnitTest.java index 6ad07c5c3a..c8932efb4f 100644 --- a/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessUnderstandingUnitTest.java +++ b/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessUnderstandingUnitTest.java @@ -16,28 +16,6 @@ import org.junit.jupiter.api.Test; class ProcessUnderstandingUnitTest { - @Test - public void givenSourceProgram_whenExecutedFromAnotherProgram_thenSourceProgramOutput3() throws IOException { - Process process = Runtime.getRuntime() - .exec("javac -cp src src\\main\\java\\com\\baeldung\\java9\\process\\OutputStreamExample.java"); - process = Runtime.getRuntime() - .exec("java -cp src/main/java com.baeldung.java9.process.OutputStreamExample"); - BufferedReader output = new BufferedReader(new InputStreamReader(process.getInputStream())); - int value = Integer.parseInt(output.readLine()); - assertEquals(3, value); - } - - @Test - public void givenSourceProgram_whenReadingInputStream_thenFirstLineEquals3() throws IOException { - Process process = Runtime.getRuntime() - .exec("javac -cp src src\\main\\java\\com\\baeldung\\java9\\process\\OutputStreamExample.java"); - process = Runtime.getRuntime() - .exec("java -cp src/main/java com.baeldung.java9.process.OutputStreamExample"); - BufferedReader output = new BufferedReader(new InputStreamReader(process.getInputStream())); - int value = Integer.parseInt(output.readLine()); - assertEquals(3, value); - } - @Test public void givenSubProcess_whenEncounteringError_thenErrorStreamNotNull() throws IOException { Process process = Runtime.getRuntime() @@ -83,14 +61,6 @@ class ProcessUnderstandingUnitTest { assertFalse(process.isAlive()); } - @Test - public void givenProcessNotCreated_fromWithinJavaApplicationDestroying_thenProcessNotAlive() { - Optional optionalProcessHandle = ProcessHandle.of(5232); - ProcessHandle processHandle = optionalProcessHandle.get(); - processHandle.destroy(); - assertFalse(processHandle.isAlive()); - } - //@Test - windows specific public void givenSubProcess_whenCurrentThreadWaitsIndefinitelyuntilSubProcessEnds_thenProcessWaitForReturnsGrt0() throws IOException, InterruptedException { ProcessBuilder builder = new ProcessBuilder("notepad.exe"); diff --git a/core-java-modules/core-java-os/src/test/java/com/baeldung/processbuilder/ProcessBuilderUnitTest.java b/core-java-modules/core-java-os/src/test/java/com/baeldung/processbuilder/ProcessBuilderUnitTest.java index 8fc5f9f160..d35cf6a665 100644 --- a/core-java-modules/core-java-os/src/test/java/com/baeldung/processbuilder/ProcessBuilderUnitTest.java +++ b/core-java-modules/core-java-os/src/test/java/com/baeldung/processbuilder/ProcessBuilderUnitTest.java @@ -40,7 +40,7 @@ public class ProcessBuilderUnitTest { List results = readOutput(process.getInputStream()); assertThat("Results should not be empty", results, is(not(empty()))); - assertThat("Results should contain java version: ", results, hasItem(containsString("java version"))); + assertThat("Results should contain java version: ", results, hasItem(containsString("version"))); int exitCode = process.waitFor(); assertEquals("No errors should be detected", 0, exitCode); @@ -101,7 +101,7 @@ public class ProcessBuilderUnitTest { .collect(Collectors.toList()); assertThat("Results should not be empty", lines, is(not(empty()))); - assertThat("Results should contain java version: ", lines, hasItem(containsString("java version"))); + assertThat("Results should contain java version: ", lines, hasItem(containsString("version"))); } @Test @@ -124,7 +124,7 @@ public class ProcessBuilderUnitTest { .collect(Collectors.toList()); assertThat("Results should not be empty", lines, is(not(empty()))); - assertThat("Results should contain java version: ", lines, hasItem(containsString("java version"))); + assertThat("Results should contain java version: ", lines, hasItem(containsString("version"))); } @Test diff --git a/core-java-modules/core-java-os/src/test/java/com/baeldung/screenshot/ScreenshotUnitTest.java b/core-java-modules/core-java-os/src/test/java/com/baeldung/screenshot/ScreenshotUnitTest.java index 6bd0e7dff7..4391037eb2 100644 --- a/core-java-modules/core-java-os/src/test/java/com/baeldung/screenshot/ScreenshotUnitTest.java +++ b/core-java-modules/core-java-os/src/test/java/com/baeldung/screenshot/ScreenshotUnitTest.java @@ -1,3 +1,5 @@ +package com.baeldung.screenshot; + import javax.imageio.ImageIO; import java.awt.Component; import java.awt.GraphicsDevice; @@ -38,14 +40,15 @@ public class ScreenshotUnitTest { assertTrue(imageFile.exists()); } - @Test - public void givenComponent_whenTakeScreenshot_thenSaveToFile(Component component) throws Exception { - Rectangle componentRect = component.getBounds(); - BufferedImage bufferedImage = new BufferedImage(componentRect.width, componentRect.height, BufferedImage.TYPE_INT_ARGB); - component.paint(bufferedImage.getGraphics()); - File imageFile = File.createTempFile("component-screenshot", "bmp"); - ImageIO.write(bufferedImage, "bmp", imageFile); - assertTrue(imageFile.exists()); - } + // This methods needs a component as a parameter and can only be run from an application with a GUI + // @Test + // public void givenComponent_whenTakeScreenshot_thenSaveToFile(Component component) throws Exception { + // Rectangle componentRect = component.getBounds(); + // BufferedImage bufferedImage = new BufferedImage(componentRect.width, componentRect.height, BufferedImage.TYPE_INT_ARGB); + // component.paint(bufferedImage.getGraphics()); + // File imageFile = File.createTempFile("component-screenshot", "bmp"); + // ImageIO.write(bufferedImage, "bmp", imageFile); + // assertTrue(imageFile.exists()); + // } } \ No newline at end of file diff --git a/core-java-modules/core-java-time-measurements/pom.xml b/core-java-modules/core-java-time-measurements/pom.xml index 67b8d7179a..ae0ccb4342 100644 --- a/core-java-modules/core-java-time-measurements/pom.xml +++ b/core-java-modules/core-java-time-measurements/pom.xml @@ -92,6 +92,7 @@ 3.6.1 2.10 + 1.18.12 3.6.1 1.8.9 diff --git a/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/ElapsedTimeUnitTest.java b/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/ElapsedTimeUnitTest.java index 1d92684ef4..283e851288 100644 --- a/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/ElapsedTimeUnitTest.java +++ b/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/ElapsedTimeUnitTest.java @@ -54,13 +54,17 @@ public class ElapsedTimeUnitTest { @Test public void givenRunningTask_whenMeasuringTimeWithInstantClass_thenGetElapsedTime() throws InterruptedException { Instant start = Instant.now(); + System.out.println("start: " + start); simulateRunningTask(); Instant finish = Instant.now(); - + + System.out.println("start: " + start); + System.out.println("finish: " + finish); long timeElapsed = Duration.between(start, finish).toMillis(); - + + System.out.println("elapsed: " + timeElapsed); assertEquals(true, (2000L <= timeElapsed) && (timeElapsed <= 3000L)); } diff --git a/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java b/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java index 04c1a0b74e..1611a3002f 100644 --- a/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java +++ b/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java @@ -21,12 +21,8 @@ public class LocalDateTimeUnitTest { @Test public void givenLocalDateTimeMock_whenNow_thenGetFixedLocalDateTime() { Clock clock = Clock.fixed(Instant.parse("2014-12-22T10:15:30.00Z"), ZoneId.of("UTC")); - LocalDateTime dateTime = LocalDateTime.now(clock); - mockStatic(LocalDateTime.class); - when(LocalDateTime.now()).thenReturn(dateTime); String dateTimeExpected = "2014-12-22T10:15:30"; - - LocalDateTime now = LocalDateTime.now(); + LocalDateTime now = LocalDateTime.now(clock); assertThat(now).isEqualTo(dateTimeExpected); } diff --git a/pom.xml b/pom.xml index 065d6abbdd..2c5575548d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,5 @@ + @@ -1343,7 +1344,6 @@ org.apache.maven.plugins maven-surefire-plugin - ${maven-surefire-plugin.version} 3 true @@ -1377,11 +1377,11 @@ core-java-modules/core-java-collections-set - - - + core-java-modules/core-java-date-operations-1 + core-java-modules/core-java-datetime-conversion + core-java-modules/core-java-datetime-string core-java-modules/core-java-jpms - + core-java-modules/core-java-os core-java-modules/multimodulemavenproject From 0e54f859cca54688bee10c7702856063600aea3b Mon Sep 17 00:00:00 2001 From: mikr Date: Thu, 22 Oct 2020 22:04:22 +0200 Subject: [PATCH 002/361] JAVA-2824 Fix tests in Java 9 and above modules --- .../httpclient/test/HttpClientUnitTest.java | 2 +- .../httpclient/test/HttpRequestUnitTest.java | 9 ++++- .../java9/modules/ModuleAPIUnitTest.java | 13 ++----- .../core-java-time-measurements/pom.xml | 2 +- .../baeldung/time/ElapsedTimeUnitTest.java | 14 ++++--- .../com/baeldung/time/InstantUnitTest.java | 2 +- pom.xml | 38 +++++++++---------- 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpClientUnitTest.java b/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpClientUnitTest.java index 42f56838c4..2a2540a517 100644 --- a/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpClientUnitTest.java +++ b/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpClientUnitTest.java @@ -64,7 +64,7 @@ public class HttpClientUnitTest { .send(request, HttpResponse.BodyHandlers.ofString()); assertThat(response.statusCode(), equalTo(HttpURLConnection.HTTP_MOVED_PERM)); - assertThat(response.body(), containsString("https://stackoverflow.com/")); + assertTrue(response.headers().map().get("location").stream().anyMatch("https://stackoverflow.com/"::equals)); } @Test diff --git a/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpRequestUnitTest.java b/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpRequestUnitTest.java index b87e6b3c6e..e09dccc1f0 100644 --- a/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpRequestUnitTest.java +++ b/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpRequestUnitTest.java @@ -48,7 +48,12 @@ public class HttpRequestUnitTest { assertThat(response.version(), equalTo(HttpClient.Version.HTTP_2)); } - @Test + /* + * This test will fail as soon as the given URL returns a HTTP 2 response. + * Therefore, let's leave it commented out. + * */ + + /* @Test public void shouldFallbackToHttp1_1WhenWebsiteDoesNotUseHttp2() throws IOException, InterruptedException, URISyntaxException, NoSuchAlgorithmException { HttpRequest request = HttpRequest.newBuilder() .uri(new URI("https://postman-echo.com/get")) @@ -60,7 +65,7 @@ public class HttpRequestUnitTest { .send(request, HttpResponse.BodyHandlers.ofString()); assertThat(response.version(), equalTo(HttpClient.Version.HTTP_1_1)); - } + }*/ @Test public void shouldReturnStatusOKWhenSendGetRequestWithDummyHeaders() throws IOException, InterruptedException, URISyntaxException { diff --git a/core-java-modules/core-java-9-jigsaw/src/test/java/com/baeldung/java9/modules/ModuleAPIUnitTest.java b/core-java-modules/core-java-9-jigsaw/src/test/java/com/baeldung/java9/modules/ModuleAPIUnitTest.java index aa2fb34753..b909636b56 100644 --- a/core-java-modules/core-java-9-jigsaw/src/test/java/com/baeldung/java9/modules/ModuleAPIUnitTest.java +++ b/core-java-modules/core-java-9-jigsaw/src/test/java/com/baeldung/java9/modules/ModuleAPIUnitTest.java @@ -2,8 +2,7 @@ package com.baeldung.java9.modules; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.*; import static org.hamcrest.collection.IsEmptyCollection.empty; import static org.junit.Assert.*; @@ -74,7 +73,6 @@ public class ModuleAPIUnitTest { ModuleLayer javaBaseModuleLayer = javaBaseModule.getLayer(); assertTrue(javaBaseModuleLayer.configuration().findModule(JAVA_BASE_MODULE_NAME).isPresent()); - assertThat(javaBaseModuleLayer.configuration().modules().size(), is(78)); assertTrue(javaBaseModuleLayer.parents().get(0).configuration().parents().isEmpty()); } @@ -108,8 +106,7 @@ public class ModuleAPIUnitTest { .collect(Collectors.toSet()); assertThat(javaBaseRequires, empty()); - assertThat(javaSqlRequires.size(), is(3)); - assertThat(javaSqlRequiresNames, containsInAnyOrder("java.base", "java.xml", "java.logging")); + assertThat(javaSqlRequiresNames, hasItems("java.base", "java.xml", "java.logging")); } @Test @@ -127,16 +124,13 @@ public class ModuleAPIUnitTest { @Test public void givenModules_whenAccessingModuleDescriptorExports_thenExportsAreReturned() { - Set javaBaseExports = javaBaseModule.getDescriptor().exports(); Set javaSqlExports = javaSqlModule.getDescriptor().exports(); Set javaSqlExportsSource = javaSqlExports.stream() .map(Exports::source) .collect(Collectors.toSet()); - assertThat(javaBaseExports.size(), is(108)); - assertThat(javaSqlExports.size(), is(3)); - assertThat(javaSqlExportsSource, containsInAnyOrder("java.sql", "javax.transaction.xa", "javax.sql")); + assertThat(javaSqlExportsSource, hasItems("java.sql", "javax.sql")); } @Test @@ -144,7 +138,6 @@ public class ModuleAPIUnitTest { Set javaBaseUses = javaBaseModule.getDescriptor().uses(); Set javaSqlUses = javaSqlModule.getDescriptor().uses(); - assertThat(javaBaseUses.size(), is(34)); assertThat(javaSqlUses, contains("java.sql.Driver")); } diff --git a/core-java-modules/core-java-time-measurements/pom.xml b/core-java-modules/core-java-time-measurements/pom.xml index ae0ccb4342..3197b1ae6a 100644 --- a/core-java-modules/core-java-time-measurements/pom.xml +++ b/core-java-modules/core-java-time-measurements/pom.xml @@ -96,7 +96,7 @@ 3.6.1 1.8.9 - 2.0.0 + 2.0.7 1.44 2.22.1 diff --git a/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/ElapsedTimeUnitTest.java b/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/ElapsedTimeUnitTest.java index 283e851288..e5a9cdd603 100644 --- a/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/ElapsedTimeUnitTest.java +++ b/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/ElapsedTimeUnitTest.java @@ -50,14 +50,18 @@ public class ElapsedTimeUnitTest { assertEquals(true, (2000L <= timeElapsed) && (timeElapsed <= 3000L)); } - - @Test + + /* + The below test depends on the elapsed time, which isn't ideal in a test. + Also, it slows down test execution artificially. + */ + /*@Test public void givenRunningTask_whenMeasuringTimeWithInstantClass_thenGetElapsedTime() throws InterruptedException { Instant start = Instant.now(); System.out.println("start: " + start); - + simulateRunningTask(); - + Instant finish = Instant.now(); System.out.println("start: " + start); @@ -66,7 +70,7 @@ public class ElapsedTimeUnitTest { System.out.println("elapsed: " + timeElapsed); assertEquals(true, (2000L <= timeElapsed) && (timeElapsed <= 3000L)); - } + }*/ /** * Simulate task running for 2.5 seconds. diff --git a/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/InstantUnitTest.java b/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/InstantUnitTest.java index 8400748710..608199197a 100644 --- a/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/InstantUnitTest.java +++ b/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/InstantUnitTest.java @@ -10,8 +10,8 @@ import java.time.Instant; import java.time.ZoneId; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.when; import static org.powermock.api.mockito.PowerMockito.mockStatic; +import static org.powermock.api.mockito.PowerMockito.when; @RunWith(PowerMockRunner.class) @PrepareForTest({ Instant.class }) diff --git a/pom.xml b/pom.xml index 2c5575548d..602b92ffee 100644 --- a/pom.xml +++ b/pom.xml @@ -1368,23 +1368,22 @@ core-java-modules/core-java-9 core-java-modules/core-java-9-improvements - - + core-java-modules/core-java-9-jigsaw + core-java-modules/core-java-9-streams core-java-modules/core-java-10 - - - - + core-java-modules/core-java-11 + + + core-java-modules/core-java-collections-set core-java-modules/core-java-date-operations-1 core-java-modules/core-java-datetime-conversion core-java-modules/core-java-datetime-string core-java-modules/core-java-jpms core-java-modules/core-java-os - + core-java-modules/core-java-time-measurements core-java-modules/multimodulemavenproject - @@ -1413,23 +1412,22 @@ core-java-modules/core-java-9 core-java-modules/core-java-9-improvements - - + core-java-modules/core-java-9-jigsaw + core-java-modules/core-java-9-streams core-java-modules/core-java-10 - - - - + core-java-modules/core-java-11 + + + core-java-modules/core-java-collections-set - - - + core-java-modules/core-java-date-operations-1 + core-java-modules/core-java-datetime-conversion + core-java-modules/core-java-datetime-string core-java-modules/core-java-jpms - - + core-java-modules/core-java-os + core-java-modules/core-java-time-measurements core-java-modules/multimodulemavenproject - From 7852a3ec2b545cd27844c30e580cad8556ac6896 Mon Sep 17 00:00:00 2001 From: Philippe Soares Date: Sun, 25 Oct 2020 23:05:27 -0400 Subject: [PATCH 003/361] 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 004/361] 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 005/361] 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 006/361] 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 007/361] 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 008/361] 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 009/361] 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 4cac5aa1d8a1d0aff382595dc6167d812ecb4c4f Mon Sep 17 00:00:00 2001 From: mikr Date: Thu, 29 Oct 2020 22:01:15 +0100 Subject: [PATCH 010/361] JAVA-2824 Fix tests in Java 9 and above modules (Update after PR review) --- .../httpclient/test/HttpRequestUnitTest.java | 7 ++-- .../screenshot/ScreenshotUnitTest.java | 22 +++++++------ ...itTest.java => ElapsedTimeManualTest.java} | 6 ++-- pom.xml | 32 +++++++++---------- 4 files changed, 35 insertions(+), 32 deletions(-) rename core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/{ElapsedTimeUnitTest.java => ElapsedTimeManualTest.java} (97%) diff --git a/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpRequestUnitTest.java b/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpRequestUnitTest.java index e09dccc1f0..a3a5592cd9 100644 --- a/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpRequestUnitTest.java +++ b/core-java-modules/core-java-11/src/test/java/com/baeldung/java11/httpclient/test/HttpRequestUnitTest.java @@ -18,6 +18,7 @@ import java.security.NoSuchAlgorithmException; import java.time.Duration; import org.junit.Test; +import org.junit.jupiter.api.Disabled; public class HttpRequestUnitTest { @@ -52,8 +53,8 @@ public class HttpRequestUnitTest { * This test will fail as soon as the given URL returns a HTTP 2 response. * Therefore, let's leave it commented out. * */ - - /* @Test + @Test + @Disabled public void shouldFallbackToHttp1_1WhenWebsiteDoesNotUseHttp2() throws IOException, InterruptedException, URISyntaxException, NoSuchAlgorithmException { HttpRequest request = HttpRequest.newBuilder() .uri(new URI("https://postman-echo.com/get")) @@ -65,7 +66,7 @@ public class HttpRequestUnitTest { .send(request, HttpResponse.BodyHandlers.ofString()); assertThat(response.version(), equalTo(HttpClient.Version.HTTP_1_1)); - }*/ + } @Test public void shouldReturnStatusOKWhenSendGetRequestWithDummyHeaders() throws IOException, InterruptedException, URISyntaxException { diff --git a/core-java-modules/core-java-os/src/test/java/com/baeldung/screenshot/ScreenshotUnitTest.java b/core-java-modules/core-java-os/src/test/java/com/baeldung/screenshot/ScreenshotUnitTest.java index 4391037eb2..ac358b4e71 100644 --- a/core-java-modules/core-java-os/src/test/java/com/baeldung/screenshot/ScreenshotUnitTest.java +++ b/core-java-modules/core-java-os/src/test/java/com/baeldung/screenshot/ScreenshotUnitTest.java @@ -10,6 +10,7 @@ import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.io.File; import org.junit.Test; +import org.junit.jupiter.api.Disabled; import static org.junit.Assert.assertTrue; @@ -40,15 +41,16 @@ public class ScreenshotUnitTest { assertTrue(imageFile.exists()); } - // This methods needs a component as a parameter and can only be run from an application with a GUI - // @Test - // public void givenComponent_whenTakeScreenshot_thenSaveToFile(Component component) throws Exception { - // Rectangle componentRect = component.getBounds(); - // BufferedImage bufferedImage = new BufferedImage(componentRect.width, componentRect.height, BufferedImage.TYPE_INT_ARGB); - // component.paint(bufferedImage.getGraphics()); - // File imageFile = File.createTempFile("component-screenshot", "bmp"); - // ImageIO.write(bufferedImage, "bmp", imageFile); - // assertTrue(imageFile.exists()); - // } + // This methods needs a component as a parameter and can only be run from an application with a GUI + @Test + @Disabled + public void givenComponent_whenTakeScreenshot_thenSaveToFile(Component component) throws Exception { + Rectangle componentRect = component.getBounds(); + BufferedImage bufferedImage = new BufferedImage(componentRect.width, componentRect.height, BufferedImage.TYPE_INT_ARGB); + component.paint(bufferedImage.getGraphics()); + File imageFile = File.createTempFile("component-screenshot", "bmp"); + ImageIO.write(bufferedImage, "bmp", imageFile); + assertTrue(imageFile.exists()); + } } \ No newline at end of file diff --git a/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/ElapsedTimeUnitTest.java b/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/ElapsedTimeManualTest.java similarity index 97% rename from core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/ElapsedTimeUnitTest.java rename to core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/ElapsedTimeManualTest.java index e5a9cdd603..211222c665 100644 --- a/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/ElapsedTimeUnitTest.java +++ b/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/ElapsedTimeManualTest.java @@ -9,7 +9,7 @@ import java.util.concurrent.TimeUnit; import org.apache.commons.lang3.time.StopWatch; import org.junit.Test; -public class ElapsedTimeUnitTest { +public class ElapsedTimeManualTest { @Test public void givenRunningTask_whenMeasuringTimeWithCurrentTimeMillis_thenGetElapsedTime() throws InterruptedException { @@ -55,7 +55,7 @@ public class ElapsedTimeUnitTest { The below test depends on the elapsed time, which isn't ideal in a test. Also, it slows down test execution artificially. */ - /*@Test + @Test public void givenRunningTask_whenMeasuringTimeWithInstantClass_thenGetElapsedTime() throws InterruptedException { Instant start = Instant.now(); System.out.println("start: " + start); @@ -70,7 +70,7 @@ public class ElapsedTimeUnitTest { System.out.println("elapsed: " + timeElapsed); assertEquals(true, (2000L <= timeElapsed) && (timeElapsed <= 3000L)); - }*/ + } /** * Simulate task running for 2.5 seconds. diff --git a/pom.xml b/pom.xml index 602b92ffee..63f2a12640 100644 --- a/pom.xml +++ b/pom.xml @@ -1368,21 +1368,21 @@ core-java-modules/core-java-9 core-java-modules/core-java-9-improvements - core-java-modules/core-java-9-jigsaw - + core-java-modules/core-java-9-jigsaw + core-java-modules/core-java-9-streams core-java-modules/core-java-10 - core-java-modules/core-java-11 + core-java-modules/core-java-11 core-java-modules/core-java-collections-set - core-java-modules/core-java-date-operations-1 - core-java-modules/core-java-datetime-conversion - core-java-modules/core-java-datetime-string + core-java-modules/core-java-date-operations-1 + core-java-modules/core-java-datetime-conversion + core-java-modules/core-java-datetime-string core-java-modules/core-java-jpms - core-java-modules/core-java-os - core-java-modules/core-java-time-measurements + core-java-modules/core-java-os + core-java-modules/core-java-time-measurements core-java-modules/multimodulemavenproject @@ -1412,21 +1412,21 @@ core-java-modules/core-java-9 core-java-modules/core-java-9-improvements - core-java-modules/core-java-9-jigsaw - + core-java-modules/core-java-9-jigsaw + core-java-modules/core-java-9-streams core-java-modules/core-java-10 - core-java-modules/core-java-11 + core-java-modules/core-java-11 core-java-modules/core-java-collections-set - core-java-modules/core-java-date-operations-1 - core-java-modules/core-java-datetime-conversion - core-java-modules/core-java-datetime-string + core-java-modules/core-java-date-operations-1 + core-java-modules/core-java-datetime-conversion + core-java-modules/core-java-datetime-string core-java-modules/core-java-jpms - core-java-modules/core-java-os - core-java-modules/core-java-time-measurements + core-java-modules/core-java-os + core-java-modules/core-java-time-measurements core-java-modules/multimodulemavenproject From 6e8b8c086de2d100d5212f354dd70cc42b540b18 Mon Sep 17 00:00:00 2001 From: Adina Rolea Date: Wed, 4 Nov 2020 10:36:43 +0200 Subject: [PATCH 011/361] 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 012/361] 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 013/361] 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 014/361] 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 015/361] 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 016/361] 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 017/361] 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 018/361] 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 a34be087d9e2c7ec2789624d6910e2dcea3f8eeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Horacio=20L=C3=B3pez?= Date: Tue, 17 Nov 2020 20:06:51 -0300 Subject: [PATCH 019/361] Update UserController.java --- .../baeldung/crud/controllers/UserController.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java index 8a7ef96f1e..4fac1ba0ca 100644 --- a/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java +++ b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java @@ -23,6 +23,12 @@ public class UserController { this.userRepository = userRepository; } + @GetMapping("/index") + public String userList(User user) { + model.addAttribute("users", userRepository.findAll()); + return "index"; + } + @GetMapping("/signup") public String showSignUpForm(User user) { return "add-user"; @@ -35,7 +41,6 @@ public class UserController { } userRepository.save(user); - model.addAttribute("users", userRepository.findAll()); return "redirect:/index"; } @@ -43,6 +48,7 @@ public class UserController { public String showUpdateForm(@PathVariable("id") long id, Model model) { User user = userRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("Invalid user Id:" + id)); model.addAttribute("user", user); + return "update-user"; } @@ -54,7 +60,7 @@ public class UserController { } userRepository.save(user); - model.addAttribute("users", userRepository.findAll()); + return "redirect:/index"; } @@ -62,7 +68,7 @@ public class UserController { public String deleteUser(@PathVariable("id") long id, Model model) { User user = userRepository.findById(id).orElseThrow(() -> new IllegalArgumentException("Invalid user Id:" + id)); userRepository.delete(user); - model.addAttribute("users", userRepository.findAll()); - return "index"; + + return "redirect:/index"; } } From 34243ccef424815e1d28f346cc00f8695d9e557e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Horacio=20L=C3=B3pez?= Date: Tue, 17 Nov 2020 20:16:10 -0300 Subject: [PATCH 020/361] Removed user param on userList method --- .../main/java/com/baeldung/crud/controllers/UserController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java index 4fac1ba0ca..9c27c1764c 100644 --- a/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java +++ b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java @@ -24,7 +24,7 @@ public class UserController { } @GetMapping("/index") - public String userList(User user) { + public String userList() { model.addAttribute("users", userRepository.findAll()); return "index"; } From 01ecd328687ff1465e5e3688422011b24273086f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Horacio=20L=C3=B3pez?= Date: Tue, 17 Nov 2020 21:50:02 -0300 Subject: [PATCH 021/361] Fixed test --- .../src/test/java/com/baeldung/crud/UserControllerUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java b/spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java index f1455f7a73..651f17b57a 100644 --- a/spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java +++ b/spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java @@ -78,6 +78,6 @@ public class UserControllerUnitTest { @Test(expected = IllegalArgumentException.class) public void whenCalleddeleteUser_thenIllegalArgumentException() { - assertThat(userController.deleteUser(1l, mockedModel)).isEqualTo("index"); + assertThat(userController.deleteUser(1l, mockedModel)).isEqualTo("redirect:/index"); } } From d2f2bb6ab0b009c8e3e1939ffa3d215c9e98416b Mon Sep 17 00:00:00 2001 From: Horacio Lopez Date: Tue, 17 Nov 2020 21:57:15 -0300 Subject: [PATCH 022/361] Added test and some fixes --- .../java/com/baeldung/crud/controllers/UserController.java | 2 +- .../test/java/com/baeldung/crud/UserControllerUnitTest.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java index 9c27c1764c..fb86683d6b 100644 --- a/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java +++ b/spring-boot-modules/spring-boot-crud/src/main/java/com/baeldung/crud/controllers/UserController.java @@ -24,7 +24,7 @@ public class UserController { } @GetMapping("/index") - public String userList() { + public String showUserList(Model model) { model.addAttribute("users", userRepository.findAll()); return "index"; } diff --git a/spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java b/spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java index 651f17b57a..77d83698de 100644 --- a/spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java +++ b/spring-boot-modules/spring-boot-crud/src/test/java/com/baeldung/crud/UserControllerUnitTest.java @@ -28,6 +28,11 @@ public class UserControllerUnitTest { userController = new UserController(mockedUserRepository); } + @Test + public void whenCalledIndex_thenCorrect() { + assertThat(userController.showUserList(mockedModel)).isEqualTo("index"); + } + @Test public void whenCalledshowSignUpForm_thenCorrect() { User user = new User("John", "john@domain.com"); From 6743c4de492c5937f4b2807b6630fe4a1f4ab1cb Mon Sep 17 00:00:00 2001 From: Maciej Glowka Date: Fri, 20 Nov 2020 00:42:56 +0100 Subject: [PATCH 023/361] BAEL-4725: examples of double comparison in Java --- core-java-modules/core-java-lang-3/pom.xml | 12 ++++ .../comparedouble/CompareDoubleUnitTest.java | 71 +++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 core-java-modules/core-java-lang-3/src/test/java/com/baeldung/comparedouble/CompareDoubleUnitTest.java diff --git a/core-java-modules/core-java-lang-3/pom.xml b/core-java-modules/core-java-lang-3/pom.xml index de290717b1..f98074ad1b 100644 --- a/core-java-modules/core-java-lang-3/pom.xml +++ b/core-java-modules/core-java-lang-3/pom.xml @@ -23,6 +23,18 @@ ${assertj.version} test
+ + com.google.guava + guava + ${guava.version} + test + + + org.apache.commons + commons-math3 + 3.6.1 + test + diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/comparedouble/CompareDoubleUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/comparedouble/CompareDoubleUnitTest.java new file mode 100644 index 0000000000..c70dabd014 --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/comparedouble/CompareDoubleUnitTest.java @@ -0,0 +1,71 @@ +package com.baeldung.comparedouble; + +import com.google.common.math.DoubleMath; +import org.apache.commons.math3.util.Precision; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; + +public class CompareDoubleUnitTest { + + @Test + public void givenDoubleValuesThatShouldHaveSameValue_whenUsingSimpleComparison_thenFails() { + double d1 = getFirstDouble(0); + + double d2 = .1 * 8; + + assertThat(d1 == d2).isFalse(); + } + + @Test + public void givenDoubleValuesThatShouldHaveSameValue_whenUsingThresholdComparison_thenSuccess() { + double d1 = getFirstDouble(0); + + double d2 = .1 * 8; + + double epsilon = 0.000001d; + + assertThat(Math.abs(d1 - d2) < epsilon).isTrue(); + } + + @Test + public void givenDoubleValuesThatShouldHaveSameValue_whenUsingGuavaFuzzyComparison_thenSuccess() { + double d1 = getFirstDouble(0); + double d2 = .1 * 8; + + double epsilon = 0.000001d; + + + assertThat(DoubleMath.fuzzyEquals(d1, d2, epsilon)).isTrue(); + } + + @Test + public void givenDoubleValuesThatShouldHaveSameValue_whenUsingCommonsMathComparison_thenSuccess() { + double d1 = getFirstDouble(0); + double d2 = .1 * 8; + + double epsilon = 0.000001d; + + + assertThat(Precision.equals(d1, d2, epsilon)).isTrue(); + assertThat(Precision.equals(d1, d2)).isTrue(); + } + + @Test + public void givenDoubleValuesThatShouldHaveSameValue_whenUsingJunitComparison_thenSuccess() { + double d1 = getFirstDouble(0); + double d2 = .1 * 8; + + double epsilon = 0.000001d; + + assertEquals(d1, d2, epsilon); + } + + private double getFirstDouble(double d1) { + for (int i = 1; i <= 8; i++) { + d1 += .1; + } + return d1; + } +} \ No newline at end of file From 94aa14c43a5b41935bf1f1c025f9b917388c4c9c Mon Sep 17 00:00:00 2001 From: Tomas Skalicky Date: Sat, 21 Nov 2020 09:51:59 +0100 Subject: [PATCH 024/361] GraphQL schema file added, fix of PostResolver - graphqls was missing - author in Post is mandatory --- .../com/baeldung/graphql/PostResolver.java | 6 ++--- .../src/main/resources/graphql/post.graphqls | 24 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 spring-boot-modules/spring-boot-libraries/src/main/resources/graphql/post.graphqls diff --git a/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/graphql/PostResolver.java b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/graphql/PostResolver.java index dbfde330ea..329d1f469a 100644 --- a/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/graphql/PostResolver.java +++ b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/graphql/PostResolver.java @@ -1,7 +1,5 @@ package com.baeldung.graphql; -import java.util.Optional; - import com.coxautodev.graphql.tools.GraphQLResolver; public class PostResolver implements GraphQLResolver { @@ -11,7 +9,7 @@ public class PostResolver implements GraphQLResolver { this.authorDao = authorDao; } - public Optional getAuthor(Post post) { - return authorDao.getAuthor(post.getAuthorId()); + public Author getAuthor(Post post) { + return authorDao.getAuthor(post.getAuthorId()).orElseThrow(RuntimeException::new); } } diff --git a/spring-boot-modules/spring-boot-libraries/src/main/resources/graphql/post.graphqls b/spring-boot-modules/spring-boot-libraries/src/main/resources/graphql/post.graphqls new file mode 100644 index 0000000000..0e42f7255c --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries/src/main/resources/graphql/post.graphqls @@ -0,0 +1,24 @@ +type Post { + id: ID! + title: String! + text: String! + category: String + author: Author! +} + +type Author { + id: ID! + name: String! + thumbnail: String + posts: [Post]! +} + +# The Root Query for the application +type Query { + recentPosts(count: Int, offset: Int): [Post]! +} + +# The Root Mutation for the application +type Mutation { + writePost(title: String!, text: String!, category: String, author: String!) : Post! +} From 83d16d3ade028b9c3d16d90af74b9bb145d2ce21 Mon Sep 17 00:00:00 2001 From: Tomas Skalicky Date: Sat, 21 Nov 2020 09:52:46 +0100 Subject: [PATCH 025/361] security disabled for easier experimenting --- .../src/main/java/com/baeldung/demo/DemoApplication.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/demo/DemoApplication.java b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/demo/DemoApplication.java index eb091b4695..e30ee6104d 100644 --- a/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/demo/DemoApplication.java +++ b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/demo/DemoApplication.java @@ -2,12 +2,14 @@ package com.baeldung.demo; import com.baeldung.graphql.GraphqlConfiguration; import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; - +import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; import org.springframework.context.annotation.Import; @SpringBootApplication @Import(GraphqlConfiguration.class) +@EnableAutoConfiguration(exclude = {SecurityAutoConfiguration.class}) public class DemoApplication { public static void main(String[] args) { From 1332044479a7ea83984368a2741ebb2190073339 Mon Sep 17 00:00:00 2001 From: Tomas Skalicky Date: Sat, 21 Nov 2020 09:53:18 +0100 Subject: [PATCH 026/361] server port changed to 8081 for avoiding conflicts --- .../spring-boot-libraries/src/main/resources/demo.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 spring-boot-modules/spring-boot-libraries/src/main/resources/demo.yml diff --git a/spring-boot-modules/spring-boot-libraries/src/main/resources/demo.yml b/spring-boot-modules/spring-boot-libraries/src/main/resources/demo.yml new file mode 100644 index 0000000000..11e54c5449 --- /dev/null +++ b/spring-boot-modules/spring-boot-libraries/src/main/resources/demo.yml @@ -0,0 +1,2 @@ +server: + port: 8081 From e3c28ba8a5545d71d1f98313c49356cb50d43f62 Mon Sep 17 00:00:00 2001 From: Tomas Skalicky Date: Sat, 21 Nov 2020 09:53:42 +0100 Subject: [PATCH 027/361] sample queries, both Query and Mutation, added --- .../spring-boot-libraries/README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spring-boot-modules/spring-boot-libraries/README.md b/spring-boot-modules/spring-boot-libraries/README.md index 10c56ca576..6976435866 100644 --- a/spring-boot-modules/spring-boot-libraries/README.md +++ b/spring-boot-modules/spring-boot-libraries/README.md @@ -15,3 +15,21 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Spring Boot and Togglz Aspect](https://www.baeldung.com/spring-togglz) - [Getting Started with GraphQL and Spring Boot](https://www.baeldung.com/spring-graphql) - [An Introduction to Kong](https://www.baeldung.com/kong) + +### GraphQL sample queries + +Query +```shell script +curl \ +--request POST 'localhost:8081/graphql' \ +--header 'Content-Type: application/json' \ +--data-raw '{"query":"query {\n recentPosts(count: 2, offset: 0) {\n id\n title\n author {\n id\n posts {\n id\n }\n }\n }\n}"}' +``` + +Mutation +```shell script +curl \ +--request POST 'localhost:8081/graphql' \ +--header 'Content-Type: application/json' \ +--data-raw '{"query":"mutation {\n writePost(title: \"New Title\", author: \"Author2\", text: \"New Text\") {\n id\n category\n author {\n id\n name\n }\n }\n}"}' +``` From aaac4e6a95e5e274c60418034e74ca1a2679a6ea Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Mon, 23 Nov 2020 09:56:16 +0530 Subject: [PATCH 028/361] Added changes to fix the details --- ...oncurrentHashMapVsSynchronizedMapTest.java | 159 ++++++++++++++++++ .../ConcurrentModificationErrorTest.java | 41 +++++ .../cuncurrenthashmap/PerformanceTest.java | 54 ++++++ .../map/cuncurrenthashmap/UserId.java | 17 ++ 4 files changed, 271 insertions(+) create mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/ConcurrentHashMapVsSynchronizedMapTest.java create mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/ConcurrentModificationErrorTest.java create mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/PerformanceTest.java create mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/UserId.java diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/ConcurrentHashMapVsSynchronizedMapTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/ConcurrentHashMapVsSynchronizedMapTest.java new file mode 100644 index 0000000000..6a7716d38a --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/ConcurrentHashMapVsSynchronizedMapTest.java @@ -0,0 +1,159 @@ +package com.baeldung.map.cuncurrenthashmap; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + +import org.junit.Assert; +import org.junit.Test; + +public class ConcurrentHashMapVsSynchronizedMapTest { + + public final static int THREAD_POOL_SIZE = 5; + public final static int TEST_ITERATIONS = 5; + public final static int TEST_NO_ITEMS = 500000; + + @Test + public void randomReadAndWritePerformaceTest_cuncurrentHashMap_faster() + throws InterruptedException { + // For synchronizedMap + Long totalTimeForSynchronizedMap = 0l; + Map slowerMap = Collections + .synchronizedMap(new HashMap()); + for (int i = 0; i < TEST_ITERATIONS; i++) { + totalTimeForSynchronizedMap += performReadAndWriteTest(slowerMap); + } + Long avgTimeForSynchronizedMap = totalTimeForSynchronizedMap / TEST_ITERATIONS; + + // For ConcurrentHashMap Object + Long totalTimeForCuncurrentHashMap = 0l; + Map fasterMap = new ConcurrentHashMap<>(); + for (int i = 0; i < TEST_ITERATIONS; i++) { + totalTimeForCuncurrentHashMap += performReadAndWriteTest(fasterMap); + } + Long avgTimeForCuncurrentHashMap = totalTimeForCuncurrentHashMap / TEST_ITERATIONS; + + Assert.assertTrue(avgTimeForSynchronizedMap > avgTimeForCuncurrentHashMap); + } + + @Test + public void randomWritePerformaceTest_cuncurrentHashMap_faster() throws InterruptedException { + // For synchronizedMap + Long totalTimeForSynchronizedMap = 0l; + Map slowerMap = Collections + .synchronizedMap(new HashMap()); + for (int i = 0; i < TEST_ITERATIONS; i++) { + totalTimeForSynchronizedMap += performWriteTest(slowerMap); + } + Long avgTimeForSynchronizedMap = totalTimeForSynchronizedMap / TEST_ITERATIONS; + + // For ConcurrentHashMap Object + Long totalTimeForCuncurrentHashMap = 0l; + Map fasterMap = new ConcurrentHashMap<>(); + for (int i = 0; i < TEST_ITERATIONS; i++) { + totalTimeForCuncurrentHashMap += performWriteTest(fasterMap); + } + Long avgTimeForCuncurrentHashMap = totalTimeForCuncurrentHashMap / TEST_ITERATIONS; + + Assert.assertTrue(avgTimeForSynchronizedMap > avgTimeForCuncurrentHashMap); + } + + @Test + public void randomReadPerformaceTest_cuncurrentHashMap_faster() throws InterruptedException { + + Map slowerMap = Collections + .synchronizedMap(addItems(new HashMap())); + // For synchronizedMap + Long totalTimeForSynchronizedMap = 0l; + for (int i = 0; i < TEST_ITERATIONS; i++) { + totalTimeForSynchronizedMap += performReadTest(slowerMap); + } + Long avgTimeForSynchronizedMap = totalTimeForSynchronizedMap / TEST_ITERATIONS; + + Map fasterMap = Collections + .synchronizedMap(addItems(new ConcurrentHashMap())); + // For ConcurrentHashMap Object + Long totalTimeForCuncurrentHashMap = 0l; + new ConcurrentHashMap<>(); + for (int i = 0; i < TEST_ITERATIONS; i++) { + totalTimeForCuncurrentHashMap += performReadTest(fasterMap); + } + Long avgTimeForCuncurrentHashMap = totalTimeForCuncurrentHashMap / TEST_ITERATIONS; + + Assert.assertTrue(avgTimeForSynchronizedMap > avgTimeForCuncurrentHashMap); + } + + private Map addItems(Map map) { + for (int i = 0; i < TEST_NO_ITEMS; i++) { + Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); + map.put(String.valueOf(randNumber), randNumber); + } + return map; + } + + private long performWriteTest(final Map map) throws InterruptedException { + long startTime = System.nanoTime(); + ExecutorService exectures = Executors.newFixedThreadPool(THREAD_POOL_SIZE); + for (int j = 0; j < THREAD_POOL_SIZE; j++) { + exectures.execute(new Runnable() { + @Override + public void run() { + for (int i = 0; i < TEST_NO_ITEMS; i++) { + Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); + map.put(String.valueOf(randNumber), randNumber); + } + } + }); + } + exectures.shutdown(); + exectures.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); + long entTime = System.nanoTime(); + return (entTime - startTime) / 1000000L; + } + + private long performReadAndWriteTest(final Map map) + throws InterruptedException { + long startTime = System.nanoTime(); + ExecutorService exectures = Executors.newFixedThreadPool(THREAD_POOL_SIZE); + for (int j = 0; j < THREAD_POOL_SIZE; j++) { + exectures.execute(new Runnable() { + @Override + public void run() { + for (int i = 0; i < TEST_NO_ITEMS; i++) { + Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); + Integer value = map.get(String.valueOf(randNumber)); + map.put(String.valueOf(randNumber), randNumber); + } + } + }); + } + exectures.shutdown(); + exectures.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); + long entTime = System.nanoTime(); + return (entTime - startTime) / 1000000L; + } + + private long performReadTest(final Map map) throws InterruptedException { + long startTime = System.nanoTime(); + ExecutorService exectures = Executors.newFixedThreadPool(THREAD_POOL_SIZE); + for (int j = 0; j < THREAD_POOL_SIZE; j++) { + exectures.execute(new Runnable() { + @Override + public void run() { + for (int i = 0; i < TEST_NO_ITEMS; i++) { + Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); + Integer value = map.get(String.valueOf(randNumber)); + } + } + }); + } + exectures.shutdown(); + exectures.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); + long entTime = System.nanoTime(); + return (entTime - startTime) / 1000000L; + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/ConcurrentModificationErrorTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/ConcurrentModificationErrorTest.java new file mode 100644 index 0000000000..993354d6d0 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/ConcurrentModificationErrorTest.java @@ -0,0 +1,41 @@ +package com.baeldung.map.cuncurrenthashmap; + +import java.util.Collections; +import java.util.ConcurrentModificationException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; + +import org.junit.Assert; +import org.junit.Test; + +public class ConcurrentModificationErrorTest { + + @Test(expected = ConcurrentModificationException.class) + public void whenRemoveAndAddOnHashMap_thenCuncurrentModificationError() { + Map map = new HashMap<>(); + map.put(1, "baeldung"); + map.put(2, "HashMap"); + Map synchronizedMap = Collections.synchronizedMap(map); + Iterator> iterator = synchronizedMap.entrySet().iterator(); + while (iterator.hasNext()) { + synchronizedMap.put(4, "Modification"); + iterator.next(); + } + } + + public void whenRemoveAndAddOnCuncurrentHashMap_thenNoError() { + Map map = new ConcurrentHashMap<>(); + map.put(1, "baeldung"); + map.put(2, "HashMap"); + Iterator> iterator = map.entrySet().iterator(); + while (iterator.hasNext()) { + map.put(4, "Modification"); + iterator.next(); + } + + Assert.assertEquals(4, map.size()); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/PerformanceTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/PerformanceTest.java new file mode 100644 index 0000000000..9751decf53 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/PerformanceTest.java @@ -0,0 +1,54 @@ +package com.baeldung.map.cuncurrenthashmap; + +import java.util.Collections; +import java.util.ConcurrentModificationException; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.junit.Test; + +public class PerformanceTest { + + @Test(expected = ConcurrentModificationException.class) + public void whenRemoveAndAddOnHashMap_thenCuncurrentModificationError() { + Map map = new HashMap<>(); + Map synchronizedMap = Collections.synchronizedMap(map); + long startTime = System.currentTimeMillis(); + for(int i=0; i<100000; i++) { + UserId userId = new UserId(1); + synchronizedMap.put(userId, userId.toString()); + } + long endTime = System.currentTimeMillis(); + long addTimeForSynchronized = endTime-startTime; + + startTime = System.currentTimeMillis(); + for(int i=0; i<100000; i++) { + UserId userId = new UserId(1); + synchronizedMap.get(userId); + } + endTime = System.currentTimeMillis(); + long fetchTimeForSynchronized = endTime-startTime; + + Map map1 = new ConcurrentHashMap<>(); + startTime = System.currentTimeMillis(); + for(int i=0; i<100000; i++) { + UserId userId = new UserId(1); + map1.put(userId, userId.toString()); + } + endTime = System.currentTimeMillis(); + long addTimeForConcurrent = endTime-startTime; + + startTime = System.currentTimeMillis(); + for(int i=0; i<100000; i++) { + UserId userId = new UserId(1); + map1.get(userId); + } + endTime = System.currentTimeMillis(); + long fetchTimeForConcurrent = endTime-startTime; + + System.out.println("ABC"); + + } + +} diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/UserId.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/UserId.java new file mode 100644 index 0000000000..a69976180d --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/UserId.java @@ -0,0 +1,17 @@ +package com.baeldung.map.cuncurrenthashmap; + +public class UserId { + + private int id; + + public UserId(int id) { + super(); + this.id = id; + } + + @Override + public int hashCode() { + return this.id%10; + } + +} From 61f4eb62a77c2a70679a96a81d5370388424832c Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Mon, 23 Nov 2020 14:54:44 +0530 Subject: [PATCH 029/361] BAEL-4686: Performance test --- ...hMapVsSynchronizedMapPerformanceTest.java} | 41 +++++++------- .../ConcurrentModificationErrorTest.java | 6 +-- .../cuncurrenthashmap/PerformanceTest.java | 54 ------------------- .../map/cuncurrenthashmap/UserId.java | 17 ------ 4 files changed, 23 insertions(+), 95 deletions(-) rename core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/{cuncurrenthashmap/ConcurrentHashMapVsSynchronizedMapTest.java => concurrenthashmap/ConcurrentHashMapVsSynchronizedMapPerformanceTest.java} (82%) rename core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/{cuncurrenthashmap => concurrenthashmap}/ConcurrentModificationErrorTest.java (87%) delete mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/PerformanceTest.java delete mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/UserId.java diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/ConcurrentHashMapVsSynchronizedMapTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentHashMapVsSynchronizedMapPerformanceTest.java similarity index 82% rename from core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/ConcurrentHashMapVsSynchronizedMapTest.java rename to core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentHashMapVsSynchronizedMapPerformanceTest.java index 6a7716d38a..eb0c58a8b0 100644 --- a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/ConcurrentHashMapVsSynchronizedMapTest.java +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentHashMapVsSynchronizedMapPerformanceTest.java @@ -1,4 +1,4 @@ -package com.baeldung.map.cuncurrenthashmap; +package com.baeldung.map.concurrenthashmap; import java.util.Collections; import java.util.HashMap; @@ -11,14 +11,14 @@ import java.util.concurrent.TimeUnit; import org.junit.Assert; import org.junit.Test; -public class ConcurrentHashMapVsSynchronizedMapTest { +public class ConcurrentHashMapVsSynchronizedMapPerformanceTest { public final static int THREAD_POOL_SIZE = 5; public final static int TEST_ITERATIONS = 5; public final static int TEST_NO_ITEMS = 500000; @Test - public void randomReadAndWritePerformaceTest_cuncurrentHashMap_faster() + public void randomReadAndWritePerformaceTest_ConcurrentHashMap_faster() throws InterruptedException { // For synchronizedMap Long totalTimeForSynchronizedMap = 0l; @@ -30,18 +30,18 @@ public class ConcurrentHashMapVsSynchronizedMapTest { Long avgTimeForSynchronizedMap = totalTimeForSynchronizedMap / TEST_ITERATIONS; // For ConcurrentHashMap Object - Long totalTimeForCuncurrentHashMap = 0l; + Long totalTimeForConcurrentHashMap = 0l; Map fasterMap = new ConcurrentHashMap<>(); for (int i = 0; i < TEST_ITERATIONS; i++) { - totalTimeForCuncurrentHashMap += performReadAndWriteTest(fasterMap); + totalTimeForConcurrentHashMap += performReadAndWriteTest(fasterMap); } - Long avgTimeForCuncurrentHashMap = totalTimeForCuncurrentHashMap / TEST_ITERATIONS; + Long avgTimeForConcurrentHashMap = totalTimeForConcurrentHashMap / TEST_ITERATIONS; - Assert.assertTrue(avgTimeForSynchronizedMap > avgTimeForCuncurrentHashMap); + Assert.assertTrue(avgTimeForSynchronizedMap > avgTimeForConcurrentHashMap); } @Test - public void randomWritePerformaceTest_cuncurrentHashMap_faster() throws InterruptedException { + public void randomWritePerformaceTest_ConcurrentHashMap_faster() throws InterruptedException { // For synchronizedMap Long totalTimeForSynchronizedMap = 0l; Map slowerMap = Collections @@ -52,18 +52,18 @@ public class ConcurrentHashMapVsSynchronizedMapTest { Long avgTimeForSynchronizedMap = totalTimeForSynchronizedMap / TEST_ITERATIONS; // For ConcurrentHashMap Object - Long totalTimeForCuncurrentHashMap = 0l; + Long totalTimeForConcurrentHashMap = 0l; Map fasterMap = new ConcurrentHashMap<>(); for (int i = 0; i < TEST_ITERATIONS; i++) { - totalTimeForCuncurrentHashMap += performWriteTest(fasterMap); + totalTimeForConcurrentHashMap += performWriteTest(fasterMap); } - Long avgTimeForCuncurrentHashMap = totalTimeForCuncurrentHashMap / TEST_ITERATIONS; + Long avgTimeForConcurrentHashMap = totalTimeForConcurrentHashMap / TEST_ITERATIONS; - Assert.assertTrue(avgTimeForSynchronizedMap > avgTimeForCuncurrentHashMap); + Assert.assertTrue(avgTimeForSynchronizedMap > avgTimeForConcurrentHashMap); } @Test - public void randomReadPerformaceTest_cuncurrentHashMap_faster() throws InterruptedException { + public void randomReadPerformaceTest_ConcurrentHashMap_faster() throws InterruptedException { Map slowerMap = Collections .synchronizedMap(addItems(new HashMap())); @@ -74,17 +74,16 @@ public class ConcurrentHashMapVsSynchronizedMapTest { } Long avgTimeForSynchronizedMap = totalTimeForSynchronizedMap / TEST_ITERATIONS; - Map fasterMap = Collections - .synchronizedMap(addItems(new ConcurrentHashMap())); + Map fasterMap = addItems(new ConcurrentHashMap()); // For ConcurrentHashMap Object - Long totalTimeForCuncurrentHashMap = 0l; + Long totalTimeForConcurrentHashMap = 0l; new ConcurrentHashMap<>(); for (int i = 0; i < TEST_ITERATIONS; i++) { - totalTimeForCuncurrentHashMap += performReadTest(fasterMap); + totalTimeForConcurrentHashMap += performReadTest(fasterMap); } - Long avgTimeForCuncurrentHashMap = totalTimeForCuncurrentHashMap / TEST_ITERATIONS; + Long avgTimeForConcurrentHashMap = totalTimeForConcurrentHashMap / TEST_ITERATIONS; - Assert.assertTrue(avgTimeForSynchronizedMap > avgTimeForCuncurrentHashMap); + Assert.assertTrue(avgTimeForSynchronizedMap > avgTimeForConcurrentHashMap); } private Map addItems(Map map) { @@ -125,7 +124,7 @@ public class ConcurrentHashMapVsSynchronizedMapTest { public void run() { for (int i = 0; i < TEST_NO_ITEMS; i++) { Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); - Integer value = map.get(String.valueOf(randNumber)); + map.get(String.valueOf(randNumber)); map.put(String.valueOf(randNumber), randNumber); } } @@ -146,7 +145,7 @@ public class ConcurrentHashMapVsSynchronizedMapTest { public void run() { for (int i = 0; i < TEST_NO_ITEMS; i++) { Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); - Integer value = map.get(String.valueOf(randNumber)); + map.get(String.valueOf(randNumber)); } } }); diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/ConcurrentModificationErrorTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentModificationErrorTest.java similarity index 87% rename from core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/ConcurrentModificationErrorTest.java rename to core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentModificationErrorTest.java index 993354d6d0..998496720e 100644 --- a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/ConcurrentModificationErrorTest.java +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentModificationErrorTest.java @@ -1,4 +1,4 @@ -package com.baeldung.map.cuncurrenthashmap; +package com.baeldung.map.concurrenthashmap; import java.util.Collections; import java.util.ConcurrentModificationException; @@ -14,7 +14,7 @@ import org.junit.Test; public class ConcurrentModificationErrorTest { @Test(expected = ConcurrentModificationException.class) - public void whenRemoveAndAddOnHashMap_thenCuncurrentModificationError() { + public void whenRemoveAndAddOnHashMap_thenConcurrentModificationError() { Map map = new HashMap<>(); map.put(1, "baeldung"); map.put(2, "HashMap"); @@ -26,7 +26,7 @@ public class ConcurrentModificationErrorTest { } } - public void whenRemoveAndAddOnCuncurrentHashMap_thenNoError() { + public void whenRemoveAndAddOnConcurrentHashMap_thenNoError() { Map map = new ConcurrentHashMap<>(); map.put(1, "baeldung"); map.put(2, "HashMap"); diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/PerformanceTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/PerformanceTest.java deleted file mode 100644 index 9751decf53..0000000000 --- a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/PerformanceTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.baeldung.map.cuncurrenthashmap; - -import java.util.Collections; -import java.util.ConcurrentModificationException; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.junit.Test; - -public class PerformanceTest { - - @Test(expected = ConcurrentModificationException.class) - public void whenRemoveAndAddOnHashMap_thenCuncurrentModificationError() { - Map map = new HashMap<>(); - Map synchronizedMap = Collections.synchronizedMap(map); - long startTime = System.currentTimeMillis(); - for(int i=0; i<100000; i++) { - UserId userId = new UserId(1); - synchronizedMap.put(userId, userId.toString()); - } - long endTime = System.currentTimeMillis(); - long addTimeForSynchronized = endTime-startTime; - - startTime = System.currentTimeMillis(); - for(int i=0; i<100000; i++) { - UserId userId = new UserId(1); - synchronizedMap.get(userId); - } - endTime = System.currentTimeMillis(); - long fetchTimeForSynchronized = endTime-startTime; - - Map map1 = new ConcurrentHashMap<>(); - startTime = System.currentTimeMillis(); - for(int i=0; i<100000; i++) { - UserId userId = new UserId(1); - map1.put(userId, userId.toString()); - } - endTime = System.currentTimeMillis(); - long addTimeForConcurrent = endTime-startTime; - - startTime = System.currentTimeMillis(); - for(int i=0; i<100000; i++) { - UserId userId = new UserId(1); - map1.get(userId); - } - endTime = System.currentTimeMillis(); - long fetchTimeForConcurrent = endTime-startTime; - - System.out.println("ABC"); - - } - -} diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/UserId.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/UserId.java deleted file mode 100644 index a69976180d..0000000000 --- a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/cuncurrenthashmap/UserId.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.map.cuncurrenthashmap; - -public class UserId { - - private int id; - - public UserId(int id) { - super(); - this.id = id; - } - - @Override - public int hashCode() { - return this.id%10; - } - -} From bd6bc03c93a926c357ee22006a75082d606c4731 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Mon, 23 Nov 2020 17:32:18 +0530 Subject: [PATCH 030/361] BAEL-4686: Corrected the test --- ...shMapVsSynchronizedMapPerformanceTest.java | 86 +++++++++---------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentHashMapVsSynchronizedMapPerformanceTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentHashMapVsSynchronizedMapPerformanceTest.java index eb0c58a8b0..573087d5a5 100644 --- a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentHashMapVsSynchronizedMapPerformanceTest.java +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentHashMapVsSynchronizedMapPerformanceTest.java @@ -15,7 +15,7 @@ public class ConcurrentHashMapVsSynchronizedMapPerformanceTest { public final static int THREAD_POOL_SIZE = 5; public final static int TEST_ITERATIONS = 5; - public final static int TEST_NO_ITEMS = 500000; + public final static int TEST_NO_ITEMS = 10000; @Test public void randomReadAndWritePerformaceTest_ConcurrentHashMap_faster() @@ -40,6 +40,28 @@ public class ConcurrentHashMapVsSynchronizedMapPerformanceTest { Assert.assertTrue(avgTimeForSynchronizedMap > avgTimeForConcurrentHashMap); } + private long performReadAndWriteTest(final Map map) + throws InterruptedException { + long startTime = System.nanoTime(); + ExecutorService exectures = Executors.newFixedThreadPool(THREAD_POOL_SIZE); + for (int j = 0; j < THREAD_POOL_SIZE; j++) { + exectures.execute(new Runnable() { + @Override + public void run() { + for (int i = 0; i < TEST_NO_ITEMS; i++) { + Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); + map.get(String.valueOf(randNumber)); + map.put(String.valueOf(randNumber), randNumber); + } + } + }); + } + exectures.shutdown(); + exectures.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); + long entTime = System.nanoTime(); + return (entTime - startTime) / 1000000L; + } + @Test public void randomWritePerformaceTest_ConcurrentHashMap_faster() throws InterruptedException { // For synchronizedMap @@ -62,6 +84,26 @@ public class ConcurrentHashMapVsSynchronizedMapPerformanceTest { Assert.assertTrue(avgTimeForSynchronizedMap > avgTimeForConcurrentHashMap); } + private long performWriteTest(final Map map) throws InterruptedException { + long startTime = System.nanoTime(); + ExecutorService exectures = Executors.newFixedThreadPool(THREAD_POOL_SIZE); + for (int j = 0; j < THREAD_POOL_SIZE; j++) { + exectures.execute(new Runnable() { + @Override + public void run() { + for (int i = 0; i < TEST_NO_ITEMS; i++) { + Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); + map.put(String.valueOf(randNumber), randNumber); + } + } + }); + } + exectures.shutdown(); + exectures.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); + long entTime = System.nanoTime(); + return (entTime - startTime) / 1000000L; + } + @Test public void randomReadPerformaceTest_ConcurrentHashMap_faster() throws InterruptedException { @@ -94,48 +136,6 @@ public class ConcurrentHashMapVsSynchronizedMapPerformanceTest { return map; } - private long performWriteTest(final Map map) throws InterruptedException { - long startTime = System.nanoTime(); - ExecutorService exectures = Executors.newFixedThreadPool(THREAD_POOL_SIZE); - for (int j = 0; j < THREAD_POOL_SIZE; j++) { - exectures.execute(new Runnable() { - @Override - public void run() { - for (int i = 0; i < TEST_NO_ITEMS; i++) { - Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); - map.put(String.valueOf(randNumber), randNumber); - } - } - }); - } - exectures.shutdown(); - exectures.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); - long entTime = System.nanoTime(); - return (entTime - startTime) / 1000000L; - } - - private long performReadAndWriteTest(final Map map) - throws InterruptedException { - long startTime = System.nanoTime(); - ExecutorService exectures = Executors.newFixedThreadPool(THREAD_POOL_SIZE); - for (int j = 0; j < THREAD_POOL_SIZE; j++) { - exectures.execute(new Runnable() { - @Override - public void run() { - for (int i = 0; i < TEST_NO_ITEMS; i++) { - Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); - map.get(String.valueOf(randNumber)); - map.put(String.valueOf(randNumber), randNumber); - } - } - }); - } - exectures.shutdown(); - exectures.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); - long entTime = System.nanoTime(); - return (entTime - startTime) / 1000000L; - } - private long performReadTest(final Map map) throws InterruptedException { long startTime = System.nanoTime(); ExecutorService exectures = Executors.newFixedThreadPool(THREAD_POOL_SIZE); From 2a1baae5991ffa9d240acd4257be5f8604384e4e Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Mon, 23 Nov 2020 20:10:17 +0530 Subject: [PATCH 031/361] BAEL-4686:Allow Null test --- .../concurrenthashmap/NullAllowInMapTest.java | 27 +++++++++++++++++++ ...formanceTest.java => PerformanceTest.java} | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapTest.java rename core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/{ConcurrentHashMapVsSynchronizedMapPerformanceTest.java => PerformanceTest.java} (99%) diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapTest.java new file mode 100644 index 0000000000..23c76e59e8 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapTest.java @@ -0,0 +1,27 @@ +package com.baeldung.map.concurrenthashmap; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.junit.Assert; +import org.junit.Test; + +public class NullAllowInMapTest { + + @Test + public void allowOnlyNull_In_SynchronizedMap() { + Map map = Collections + .synchronizedMap(new HashMap()); + map.put(null, 1); + Assert.assertTrue(map.get(null).equals(1)); + } + + @Test(expected = NullPointerException.class) + public void allowOnlyNull_In_ConcurrentHasMap() { + Map map = new ConcurrentHashMap<>(); + map.put(null, 1); + } + +} diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentHashMapVsSynchronizedMapPerformanceTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/PerformanceTest.java similarity index 99% rename from core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentHashMapVsSynchronizedMapPerformanceTest.java rename to core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/PerformanceTest.java index 573087d5a5..5321d33b36 100644 --- a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentHashMapVsSynchronizedMapPerformanceTest.java +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/PerformanceTest.java @@ -11,7 +11,7 @@ import java.util.concurrent.TimeUnit; import org.junit.Assert; import org.junit.Test; -public class ConcurrentHashMapVsSynchronizedMapPerformanceTest { +public class PerformanceTest { public final static int THREAD_POOL_SIZE = 5; public final static int TEST_ITERATIONS = 5; From f3d390b6844ad2374d0aaa477a5e7c465578b890 Mon Sep 17 00:00:00 2001 From: Adrian Maghear Date: Sat, 28 Nov 2020 14:14:20 +0100 Subject: [PATCH 032/361] 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 033/361] 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 034/361] 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 074d016b64ee598e6ad00a1dd856d803cbeef591 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Mon, 30 Nov 2020 07:12:58 +0530 Subject: [PATCH 035/361] BAEL-4686: Review comments implemented --- .../core-java-collections-maps-3/pom.xml | 6 +- .../MapPerformanceComparison.java | 96 +++++++++++ .../ConcurrentModificationErrorTest.java | 41 ----- .../concurrenthashmap/NullAllowInMapTest.java | 27 --- .../concurrenthashmap/PerformanceTest.java | 158 ------------------ 5 files changed, 101 insertions(+), 227 deletions(-) create mode 100644 core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/concurrenthashmap/MapPerformanceComparison.java delete mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentModificationErrorTest.java delete mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapTest.java delete mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/PerformanceTest.java diff --git a/core-java-modules/core-java-collections-maps-3/pom.xml b/core-java-modules/core-java-collections-maps-3/pom.xml index f547968b22..577ad58255 100644 --- a/core-java-modules/core-java-collections-maps-3/pom.xml +++ b/core-java-modules/core-java-collections-maps-3/pom.xml @@ -15,7 +15,11 @@ - + + org.openjdk.jmh + jmh-core + ${jmh-core.version} + diff --git a/core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/concurrenthashmap/MapPerformanceComparison.java b/core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/concurrenthashmap/MapPerformanceComparison.java new file mode 100644 index 0000000000..c788dbc27d --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/concurrenthashmap/MapPerformanceComparison.java @@ -0,0 +1,96 @@ +package com.baeldung.map.concurrenthashmap; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; + +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Threads; +import org.openjdk.jmh.annotations.Warmup; + +@Fork(5) +@Threads(10) +@Warmup(iterations = 5) +@State(Scope.Benchmark) +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +public class MapPerformanceComparison { + + private int TEST_NO_ITEMS; + + public static void main(String[] args) throws Exception { + org.openjdk.jmh.Main.main(args); + } + + @Setup + public void setup() { + TEST_NO_ITEMS = 1000; + } + + @Benchmark + public void randomReadAndWriteSynchronizedMap() { + Map map = Collections.synchronizedMap(new HashMap()); + performReadAndWriteTest(map); + } + + @Benchmark + public void randomReadAndWriteConcurrentHashMap() { + Map map = new ConcurrentHashMap<>(); + performReadAndWriteTest(map); + } + + private void performReadAndWriteTest(final Map map) { + for (int i = 0; i < TEST_NO_ITEMS; i++) { + Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); + map.get(String.valueOf(randNumber)); + map.put(String.valueOf(randNumber), randNumber); + } + } + + @Benchmark + public void randomWriteSynchronizedMap() { + Map map = Collections.synchronizedMap(new HashMap()); + performWriteTest(map); + } + + @Benchmark + public void randomWriteConcurrentHashMap() { + Map map = new ConcurrentHashMap<>(); + performWriteTest(map); + } + + private void performWriteTest(final Map map) { + for (int i = 0; i < TEST_NO_ITEMS; i++) { + Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); + map.put(String.valueOf(randNumber), randNumber); + } + } + + @Benchmark + public void randomReadSynchronizedMap() { + Map map = Collections.synchronizedMap(new HashMap()); + performReadTest(map); + } + + @Benchmark + public void randomReadConcurrentHashMap() { + Map map = new ConcurrentHashMap<>(); + performReadTest(map); + } + + private void performReadTest(final Map map) { + for (int i = 0; i < TEST_NO_ITEMS; i++) { + Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); + map.get(String.valueOf(randNumber)); + } + } +} diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentModificationErrorTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentModificationErrorTest.java deleted file mode 100644 index 998496720e..0000000000 --- a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentModificationErrorTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.baeldung.map.concurrenthashmap; - -import java.util.Collections; -import java.util.ConcurrentModificationException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.ConcurrentHashMap; - -import org.junit.Assert; -import org.junit.Test; - -public class ConcurrentModificationErrorTest { - - @Test(expected = ConcurrentModificationException.class) - public void whenRemoveAndAddOnHashMap_thenConcurrentModificationError() { - Map map = new HashMap<>(); - map.put(1, "baeldung"); - map.put(2, "HashMap"); - Map synchronizedMap = Collections.synchronizedMap(map); - Iterator> iterator = synchronizedMap.entrySet().iterator(); - while (iterator.hasNext()) { - synchronizedMap.put(4, "Modification"); - iterator.next(); - } - } - - public void whenRemoveAndAddOnConcurrentHashMap_thenNoError() { - Map map = new ConcurrentHashMap<>(); - map.put(1, "baeldung"); - map.put(2, "HashMap"); - Iterator> iterator = map.entrySet().iterator(); - while (iterator.hasNext()) { - map.put(4, "Modification"); - iterator.next(); - } - - Assert.assertEquals(4, map.size()); - } -} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapTest.java deleted file mode 100644 index 23c76e59e8..0000000000 --- a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.baeldung.map.concurrenthashmap; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.junit.Assert; -import org.junit.Test; - -public class NullAllowInMapTest { - - @Test - public void allowOnlyNull_In_SynchronizedMap() { - Map map = Collections - .synchronizedMap(new HashMap()); - map.put(null, 1); - Assert.assertTrue(map.get(null).equals(1)); - } - - @Test(expected = NullPointerException.class) - public void allowOnlyNull_In_ConcurrentHasMap() { - Map map = new ConcurrentHashMap<>(); - map.put(null, 1); - } - -} diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/PerformanceTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/PerformanceTest.java deleted file mode 100644 index 5321d33b36..0000000000 --- a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/PerformanceTest.java +++ /dev/null @@ -1,158 +0,0 @@ -package com.baeldung.map.concurrenthashmap; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import org.junit.Assert; -import org.junit.Test; - -public class PerformanceTest { - - public final static int THREAD_POOL_SIZE = 5; - public final static int TEST_ITERATIONS = 5; - public final static int TEST_NO_ITEMS = 10000; - - @Test - public void randomReadAndWritePerformaceTest_ConcurrentHashMap_faster() - throws InterruptedException { - // For synchronizedMap - Long totalTimeForSynchronizedMap = 0l; - Map slowerMap = Collections - .synchronizedMap(new HashMap()); - for (int i = 0; i < TEST_ITERATIONS; i++) { - totalTimeForSynchronizedMap += performReadAndWriteTest(slowerMap); - } - Long avgTimeForSynchronizedMap = totalTimeForSynchronizedMap / TEST_ITERATIONS; - - // For ConcurrentHashMap Object - Long totalTimeForConcurrentHashMap = 0l; - Map fasterMap = new ConcurrentHashMap<>(); - for (int i = 0; i < TEST_ITERATIONS; i++) { - totalTimeForConcurrentHashMap += performReadAndWriteTest(fasterMap); - } - Long avgTimeForConcurrentHashMap = totalTimeForConcurrentHashMap / TEST_ITERATIONS; - - Assert.assertTrue(avgTimeForSynchronizedMap > avgTimeForConcurrentHashMap); - } - - private long performReadAndWriteTest(final Map map) - throws InterruptedException { - long startTime = System.nanoTime(); - ExecutorService exectures = Executors.newFixedThreadPool(THREAD_POOL_SIZE); - for (int j = 0; j < THREAD_POOL_SIZE; j++) { - exectures.execute(new Runnable() { - @Override - public void run() { - for (int i = 0; i < TEST_NO_ITEMS; i++) { - Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); - map.get(String.valueOf(randNumber)); - map.put(String.valueOf(randNumber), randNumber); - } - } - }); - } - exectures.shutdown(); - exectures.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); - long entTime = System.nanoTime(); - return (entTime - startTime) / 1000000L; - } - - @Test - public void randomWritePerformaceTest_ConcurrentHashMap_faster() throws InterruptedException { - // For synchronizedMap - Long totalTimeForSynchronizedMap = 0l; - Map slowerMap = Collections - .synchronizedMap(new HashMap()); - for (int i = 0; i < TEST_ITERATIONS; i++) { - totalTimeForSynchronizedMap += performWriteTest(slowerMap); - } - Long avgTimeForSynchronizedMap = totalTimeForSynchronizedMap / TEST_ITERATIONS; - - // For ConcurrentHashMap Object - Long totalTimeForConcurrentHashMap = 0l; - Map fasterMap = new ConcurrentHashMap<>(); - for (int i = 0; i < TEST_ITERATIONS; i++) { - totalTimeForConcurrentHashMap += performWriteTest(fasterMap); - } - Long avgTimeForConcurrentHashMap = totalTimeForConcurrentHashMap / TEST_ITERATIONS; - - Assert.assertTrue(avgTimeForSynchronizedMap > avgTimeForConcurrentHashMap); - } - - private long performWriteTest(final Map map) throws InterruptedException { - long startTime = System.nanoTime(); - ExecutorService exectures = Executors.newFixedThreadPool(THREAD_POOL_SIZE); - for (int j = 0; j < THREAD_POOL_SIZE; j++) { - exectures.execute(new Runnable() { - @Override - public void run() { - for (int i = 0; i < TEST_NO_ITEMS; i++) { - Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); - map.put(String.valueOf(randNumber), randNumber); - } - } - }); - } - exectures.shutdown(); - exectures.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); - long entTime = System.nanoTime(); - return (entTime - startTime) / 1000000L; - } - - @Test - public void randomReadPerformaceTest_ConcurrentHashMap_faster() throws InterruptedException { - - Map slowerMap = Collections - .synchronizedMap(addItems(new HashMap())); - // For synchronizedMap - Long totalTimeForSynchronizedMap = 0l; - for (int i = 0; i < TEST_ITERATIONS; i++) { - totalTimeForSynchronizedMap += performReadTest(slowerMap); - } - Long avgTimeForSynchronizedMap = totalTimeForSynchronizedMap / TEST_ITERATIONS; - - Map fasterMap = addItems(new ConcurrentHashMap()); - // For ConcurrentHashMap Object - Long totalTimeForConcurrentHashMap = 0l; - new ConcurrentHashMap<>(); - for (int i = 0; i < TEST_ITERATIONS; i++) { - totalTimeForConcurrentHashMap += performReadTest(fasterMap); - } - Long avgTimeForConcurrentHashMap = totalTimeForConcurrentHashMap / TEST_ITERATIONS; - - Assert.assertTrue(avgTimeForSynchronizedMap > avgTimeForConcurrentHashMap); - } - - private Map addItems(Map map) { - for (int i = 0; i < TEST_NO_ITEMS; i++) { - Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); - map.put(String.valueOf(randNumber), randNumber); - } - return map; - } - - private long performReadTest(final Map map) throws InterruptedException { - long startTime = System.nanoTime(); - ExecutorService exectures = Executors.newFixedThreadPool(THREAD_POOL_SIZE); - for (int j = 0; j < THREAD_POOL_SIZE; j++) { - exectures.execute(new Runnable() { - @Override - public void run() { - for (int i = 0; i < TEST_NO_ITEMS; i++) { - Integer randNumber = (int) Math.ceil(Math.random() * TEST_NO_ITEMS); - map.get(String.valueOf(randNumber)); - } - } - }); - } - exectures.shutdown(); - exectures.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); - long entTime = System.nanoTime(); - return (entTime - startTime) / 1000000L; - } -} \ No newline at end of file From 993f2baeea0bbe3348eaac6406c5106460e7ea7a Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Mon, 30 Nov 2020 07:25:51 +0530 Subject: [PATCH 036/361] Added changes based on review comments --- .../ConcurrentModificationErrorUnitTest.java | 41 +++++++++++++++++++ .../NullAllowInMapUnitTest.java | 40 ++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentModificationErrorUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapUnitTest.java diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentModificationErrorUnitTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentModificationErrorUnitTest.java new file mode 100644 index 0000000000..899c902fb0 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentModificationErrorUnitTest.java @@ -0,0 +1,41 @@ +package com.baeldung.map.concurrenthashmap; + +import java.util.Collections; +import java.util.ConcurrentModificationException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; + +import org.junit.Assert; +import org.junit.Test; + +public class ConcurrentModificationErrorUnitTest { + + @Test(expected = ConcurrentModificationException.class) + public void whenRemoveAndAddOnHashMap_thenConcurrentModificationError() { + Map map = new HashMap<>(); + map.put(1, "baeldung"); + map.put(2, "HashMap"); + Map synchronizedMap = Collections.synchronizedMap(map); + Iterator> iterator = synchronizedMap.entrySet().iterator(); + while (iterator.hasNext()) { + synchronizedMap.put(3, "Modification"); + iterator.next(); + } + } + + public void whenRemoveAndAddOnConcurrentHashMap_thenNoError() { + Map map = new ConcurrentHashMap<>(); + map.put(1, "baeldung"); + map.put(2, "HashMap"); + Iterator> iterator = map.entrySet().iterator(); + while (iterator.hasNext()) { + map.put(3, "Modification"); + iterator.next(); + } + + Assert.assertEquals(3, map.size()); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapUnitTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapUnitTest.java new file mode 100644 index 0000000000..60e293f4b3 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapUnitTest.java @@ -0,0 +1,40 @@ +package com.baeldung.map.concurrenthashmap; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.junit.Assert; +import org.junit.Test; + +public class NullAllowInMapUnitTest { + + @Test + public void allowNullKey_In_SynchronizedMap() { + Map map = Collections + .synchronizedMap(new HashMap()); + map.put(null, 1); + Assert.assertTrue(map.get(null).equals(1)); + } + + @Test(expected = NullPointerException.class) + public void allowNullKey_In_ConcurrentHasMap() { + Map map = new ConcurrentHashMap<>(); + map.put(null, 1); + } + + @Test + public void allowNullValue_In_SynchronizedMap() { + Map map = Collections.synchronizedMap(new HashMap()); + map.put("1", null); + Assert.assertNull(map.get("1")); + } + + @Test(expected = NullPointerException.class) + public void allowNullValue_In_ConcurrentHasMap() { + Map map = new ConcurrentHashMap<>(); + map.put("1", null); + } + +} \ No newline at end of file From 941b7bd3c89f2fc58d7349003149e6b9b60740a9 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 2 Dec 2020 19:11:06 +0800 Subject: [PATCH 037/361] Update README.md --- core-java-modules/core-java-lang-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-lang-3/README.md b/core-java-modules/core-java-lang-3/README.md index 78491e5bfa..757806c8f6 100644 --- a/core-java-modules/core-java-lang-3/README.md +++ b/core-java-modules/core-java-lang-3/README.md @@ -9,4 +9,5 @@ This module contains articles about core features in the Java language - [The Difference Between a.getClass() and A.class in Java](https://www.baeldung.com/java-getclass-vs-class) - [Constants in Java: Patterns and Anti-Patterns](https://www.baeldung.com/java-constants-good-practices) - [The transient Keyword in Java](https://www.baeldung.com/java-transient-keyword) +- [How to Access an Iteration Counter in a For Each Loop](https://www.baeldung.com/java-foreach-counter) - [[<-- Prev]](/core-java-modules/core-java-lang-2) From 623a13b0a9eeffea8d575ff74cc9122fe44d240e Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 2 Dec 2020 19:14:12 +0800 Subject: [PATCH 038/361] Update README.md --- testing-modules/testing-libraries-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/testing-modules/testing-libraries-2/README.md b/testing-modules/testing-libraries-2/README.md index 3325600b5e..f8361904b8 100644 --- a/testing-modules/testing-libraries-2/README.md +++ b/testing-modules/testing-libraries-2/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Guide to the System Rules Library](https://www.baeldung.com/java-system-rules-junit) +- [Guide to the System Stubs Library](https://www.baeldung.com/java-system-stubs) From 61f0a1b720ddfb5dc52d867affd00c1d81324fd4 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 2 Dec 2020 19:17:18 +0800 Subject: [PATCH 039/361] 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 03a5a94acc..b982a753cf 100644 --- a/core-java-modules/core-java-security-2/README.md +++ b/core-java-modules/core-java-security-2/README.md @@ -12,4 +12,5 @@ This module contains articles about core Java Security - [How to Read PEM File to Get Public and Private Keys](https://www.baeldung.com/java-read-pem-file-keys) - [Listing the Available Cipher Algorithms](https://www.baeldung.com/java-list-cipher-algorithms) - [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) - More articles: [[<-- prev]](/core-java-modules/core-java-security) From 9d94f7f0955414ac5834a69ba1cb15c397bcc8b1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 2 Dec 2020 19:19:21 +0800 Subject: [PATCH 040/361] Update README.md --- spring-thymeleaf-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-thymeleaf-3/README.md b/spring-thymeleaf-3/README.md index 8bb8861daf..048b48d39f 100644 --- a/spring-thymeleaf-3/README.md +++ b/spring-thymeleaf-3/README.md @@ -9,3 +9,4 @@ This module contains articles about Spring with Thymeleaf - [Working with Select and Option in Thymeleaf](https://www.baeldung.com/thymeleaf-select-option) - [Conditional CSS Classes in Thymeleaf](https://www.baeldung.com/spring-mvc-thymeleaf-conditional-css-classes) - [Using Hidden Inputs with Spring and Thymeleaf](https://www.baeldung.com/spring-thymeleaf-hidden-inputs) +- [Thymeleaf Variables](https://www.baeldung.com/thymeleaf-variables) From 5cd294b635393cc7b7a340c8c69faaced9f1676a Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 2 Dec 2020 19:21:09 +0800 Subject: [PATCH 041/361] Update README.md --- core-java-modules/core-java-exceptions-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-exceptions-3/README.md b/core-java-modules/core-java-exceptions-3/README.md index 8a59d6a229..e1372381a8 100644 --- a/core-java-modules/core-java-exceptions-3/README.md +++ b/core-java-modules/core-java-exceptions-3/README.md @@ -7,3 +7,4 @@ - [Java IndexOutOfBoundsException “Source Does Not Fit in Dest”](https://www.baeldung.com/java-indexoutofboundsexception) - [Localizing Exception Messages in Java](https://www.baeldung.com/java-localize-exception-messages) - [Explanation of ClassCastException in Java](https://www.baeldung.com/java-classcastexception) +- [NoSuchFieldError in Java](https://www.baeldung.com/java-nosuchfielderror) From 6d0a360bb45dc3a67debd893e2568aa209aa0532 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 2 Dec 2020 19:27:13 +0800 Subject: [PATCH 042/361] 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 b982a753cf..bb5e204c98 100644 --- a/core-java-modules/core-java-security-2/README.md +++ b/core-java-modules/core-java-security-2/README.md @@ -13,4 +13,5 @@ This module contains articles about core Java Security - [Listing the Available Cipher Algorithms](https://www.baeldung.com/java-list-cipher-algorithms) - [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) - More articles: [[<-- prev]](/core-java-modules/core-java-security) From e3946da6746fe5010ced37028897a27ee6a0bb84 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 2 Dec 2020 19:28:40 +0800 Subject: [PATCH 043/361] Update README.md --- spring-mvc-xml/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-mvc-xml/README.md b/spring-mvc-xml/README.md index 0adf127aaa..3fbea3626b 100644 --- a/spring-mvc-xml/README.md +++ b/spring-mvc-xml/README.md @@ -17,6 +17,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [A Java Web Application Without a web.xml](https://www.baeldung.com/java-web-app-without-web-xml) - [Validating RequestParams and PathVariables in Spring](https://www.baeldung.com/spring-validate-requestparam-pathvariable) - [Debugging the Spring MVC 404 “No mapping found for HTTP request” Error](https://www.baeldung.com/spring-mvc-404-error) +- [Introduction to Servlets and Servlet Containers](https://www.baeldung.com/java-servlets-containers-intro) ## Spring MVC with XML Configuration Example Project From f4390801ca49ef5b6f4f3b1fd323b071fe06a8ba Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Thu, 3 Dec 2020 12:51:02 +0200 Subject: [PATCH 044/361] fix illegal monitor test --- .../IllegalMonitorStateExceptionUnitTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java b/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java index a729facdbd..82c00bc72f 100644 --- a/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java +++ b/core-java-modules/core-java-exceptions-3/src/test/java/com/baeldung/exceptions/illegalmonitorstate/IllegalMonitorStateExceptionUnitTest.java @@ -20,6 +20,8 @@ public class IllegalMonitorStateExceptionUnitTest { senderThread.join(1000); receiverThread.join(1000); + + Thread.sleep(2000); assertEquals("test", receiver.getMessage()); assertFalse(sender.hasIllegalMonitorStateExceptionOccurred()); From e62e7133938d09ab2b21b114a830637fb26eecf5 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Thu, 3 Dec 2020 14:18:15 +0200 Subject: [PATCH 045/361] fix string comparison --- .../com/baeldung/jvmbitversion/JVMBitVersionUnitTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/java-native/src/test/java/com/baeldung/jvmbitversion/JVMBitVersionUnitTest.java b/java-native/src/test/java/com/baeldung/jvmbitversion/JVMBitVersionUnitTest.java index 152008e5e2..35357dec77 100644 --- a/java-native/src/test/java/com/baeldung/jvmbitversion/JVMBitVersionUnitTest.java +++ b/java-native/src/test/java/com/baeldung/jvmbitversion/JVMBitVersionUnitTest.java @@ -5,7 +5,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.Before; import org.junit.Test; -import com.baeldung.jvmbitversion.JVMBitVersion; import com.sun.jna.Platform; public class JVMBitVersionUnitTest { @@ -19,9 +18,9 @@ public class JVMBitVersionUnitTest { @Test public void whenUsingSystemClass_thenOutputIsAsExpected() { - if (System.getProperty("sun.arch.data.model") == "64") { + if ("64".equals(System.getProperty("sun.arch.data.model"))) { assertEquals("64-bit", jvmVersion.getUsingSystemClass()); - } else if (System.getProperty("sun.arch.data.model") == "32") { + } else if ("32".equals(System.getProperty("sun.arch.data.model"))) { assertEquals("32-bit", jvmVersion.getUsingSystemClass()); } } From c19b868d3b92fd2911ea9b5a89e21677550294b4 Mon Sep 17 00:00:00 2001 From: Adina Rolea Date: Fri, 4 Dec 2020 19:55:44 +0200 Subject: [PATCH 046/361] 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 (77%) 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 77% 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 047/361] 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 2700958ec07cb5afcd58f83e4acc56b7ed1109c0 Mon Sep 17 00:00:00 2001 From: majajoksovic Date: Sat, 5 Dec 2020 03:38:42 +0100 Subject: [PATCH 048/361] BAEL-4445 (#10291) * initial commit * changed test method names to follow convention --- .../httpclient/HttpClientParamsLiveTest.java | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientParamsLiveTest.java diff --git a/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientParamsLiveTest.java b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientParamsLiveTest.java new file mode 100644 index 0000000000..f3ea9be089 --- /dev/null +++ b/httpclient-simple/src/test/java/com/baeldung/httpclient/HttpClientParamsLiveTest.java @@ -0,0 +1,111 @@ +package com.baeldung.httpclient; + +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; + +import org.apache.http.NameValuePair; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpRequestBase; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.message.BasicNameValuePair; +import org.junit.Before; +import org.junit.Test; + +public class HttpClientParamsLiveTest { + + private CloseableHttpClient client; + + private CloseableHttpResponse response; + + private List nameValuePairs; + + @Before + public void setUp() { + client = HttpClientBuilder.create() + .build(); + nameValuePairs = new ArrayList(); + NameValuePair param1NameValuePair = new BasicNameValuePair("param1", "value1"); + NameValuePair param2NameValuePair = new BasicNameValuePair("param2", "value2"); + nameValuePairs.add(param1NameValuePair); + nameValuePairs.add(param2NameValuePair); + } + + @Test + public void givenStringNameValuePairParams_whenGetRequest_thenResponseOk() throws URISyntaxException, ClientProtocolException, IOException { + HttpGet httpGet = new HttpGet("https://postman-echo.com/get"); + URI uri = new URIBuilder(httpGet.getURI()).addParameter("param1", "value1") + .addParameter("param2", "value2") + .build(); + ((HttpRequestBase) httpGet).setURI(uri); + response = client.execute(httpGet); + + assertThat(response.getStatusLine() + .getStatusCode(), equalTo(200)); + client.close(); + } + + @Test + public void givenStringNameValuePairParams_whenPostRequest_thenResponseOk() throws URISyntaxException, ClientProtocolException, IOException { + HttpPost httpPost = new HttpPost("https://postman-echo.com/post"); + URI uri = new URIBuilder(httpPost.getURI()).addParameter("param1", "value1") + .addParameter("param2", "value2") + .build(); + ((HttpRequestBase) httpPost).setURI(uri); + response = client.execute(httpPost); + + assertThat(response.getStatusLine() + .getStatusCode(), equalTo(200)); + client.close(); + } + + @Test + public void givenNameValuePairParams_whenGetRequest_thenResponseOk() throws URISyntaxException, ClientProtocolException, IOException { + HttpGet httpGet = new HttpGet("https://postman-echo.com/get"); + URI uri = new URIBuilder(httpGet.getURI()).addParameters(nameValuePairs) + .build(); + ((HttpRequestBase) httpGet).setURI(uri); + response = client.execute(httpGet); + + assertThat(response.getStatusLine() + .getStatusCode(), equalTo(200)); + client.close(); + } + + @Test + public void givenNameValuePairsParams_whenPostRequest_thenResponseOk() throws URISyntaxException, ClientProtocolException, IOException { + HttpPost httpPost = new HttpPost("https://postman-echo.com/post"); + URI uri = new URIBuilder(httpPost.getURI()).addParameters(nameValuePairs) + .build(); + ((HttpRequestBase) httpPost).setURI(uri); + response = client.execute(httpPost); + + assertThat(response.getStatusLine() + .getStatusCode(), equalTo(200)); + client.close(); + } + + @Test + public void givenUrlEncodedEntityParams_whenPostRequest_thenResponseOk() throws URISyntaxException, ClientProtocolException, IOException { + HttpPost httpPost = new HttpPost("https://postman-echo.com/post"); + httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs, StandardCharsets.UTF_8)); + response = client.execute(httpPost); + + assertThat(response.getStatusLine() + .getStatusCode(), equalTo(200)); + client.close(); + } + +} From bc281bde2ffdd91adfdad9eff0929d5d1bcea0d8 Mon Sep 17 00:00:00 2001 From: Emmanuel Yasa <70507913+emyasa@users.noreply.github.com> Date: Sat, 5 Dec 2020 10:44:40 +0800 Subject: [PATCH 049/361] [BAEL-4056] Guide to MultipleBagFetchException (#10304) * Removes DummyEntity * Uses Artist Entity instead of DummyEntity --- .../DummyEntity.java | 43 ------------------- .../main/resources/META-INF/persistence.xml | 1 - ...tipleBagFetchExceptionIntegrationTest.java | 6 +-- 3 files changed, 3 insertions(+), 47 deletions(-) delete mode 100644 persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/multiplebagfetchexception/DummyEntity.java diff --git a/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/multiplebagfetchexception/DummyEntity.java b/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/multiplebagfetchexception/DummyEntity.java deleted file mode 100644 index 8eb9c95724..0000000000 --- a/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/multiplebagfetchexception/DummyEntity.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.baeldung.jpa.multiplebagfetchexception; - -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import java.util.List; -import java.util.Objects; - -@Entity -class DummyEntity { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - @ElementCollection - private List collection1; - - @ElementCollection - private List collection2; - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - DummyEntity that = (DummyEntity) o; - - return Objects.equals(id, that.id); - } - - @Override - public int hashCode() { - return id != null ? id.hashCode() : 0; - } - - protected DummyEntity() { - } -} diff --git a/persistence-modules/java-jpa-3/src/main/resources/META-INF/persistence.xml b/persistence-modules/java-jpa-3/src/main/resources/META-INF/persistence.xml index 46090c51d7..f428fea07b 100644 --- a/persistence-modules/java-jpa-3/src/main/resources/META-INF/persistence.xml +++ b/persistence-modules/java-jpa-3/src/main/resources/META-INF/persistence.xml @@ -57,7 +57,6 @@ org.hibernate.jpa.HibernatePersistenceProvider - com.baeldung.jpa.multiplebagfetchexception.DummyEntity com.baeldung.jpa.multiplebagfetchexception.Album com.baeldung.jpa.multiplebagfetchexception.Song com.baeldung.jpa.multiplebagfetchexception.User diff --git a/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/multiplebagfetchexception/MultipleBagFetchExceptionIntegrationTest.java b/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/multiplebagfetchexception/MultipleBagFetchExceptionIntegrationTest.java index f607bbeae4..648650ad8a 100644 --- a/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/multiplebagfetchexception/MultipleBagFetchExceptionIntegrationTest.java +++ b/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/multiplebagfetchexception/MultipleBagFetchExceptionIntegrationTest.java @@ -29,9 +29,9 @@ public class MultipleBagFetchExceptionIntegrationTest { public void whenFetchingMoreThanOneBag_thenThrowAnException() { IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> { - String jpql = "SELECT dummy FROM DummyEntity dummy " - + "JOIN FETCH dummy.collection1 " - + "JOIN FETCH dummy.collection2 "; + String jpql = "SELECT artist FROM Artist artist " + + "JOIN FETCH artist.songs " + + "JOIN FETCH artist.offers "; entityManager.createQuery(jpql); }); From c02a2052205d634961a4bf6d9c0d037ad46f62cf Mon Sep 17 00:00:00 2001 From: Daniel Strmecki Date: Sat, 5 Dec 2020 09:52:32 +0100 Subject: [PATCH 050/361] 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 32dba7dd0699f7581b3f871cd21ff74e1d0d526f Mon Sep 17 00:00:00 2001 From: Kai Yuan Date: Wed, 25 Nov 2020 00:03:34 +0100 Subject: [PATCH 051/361] remove file extensions --- .../MyFilenameUtil.java | 14 ++++ .../FileNameDelExtensionUnitTest.java | 72 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 core-java-modules/core-java-io-3/src/main/java/com/baeldung/filenamewithoutextension/MyFilenameUtil.java create mode 100644 core-java-modules/core-java-io-3/src/test/java/com/baeldung/filenamewithoutextension/FileNameDelExtensionUnitTest.java diff --git a/core-java-modules/core-java-io-3/src/main/java/com/baeldung/filenamewithoutextension/MyFilenameUtil.java b/core-java-modules/core-java-io-3/src/main/java/com/baeldung/filenamewithoutextension/MyFilenameUtil.java new file mode 100644 index 0000000000..102c454c49 --- /dev/null +++ b/core-java-modules/core-java-io-3/src/main/java/com/baeldung/filenamewithoutextension/MyFilenameUtil.java @@ -0,0 +1,14 @@ +package com.baeldung.filenamewithoutextension; + +public class MyFilenameUtil { + private MyFilenameUtil() {} + + public static String removeFileExtension(String filename, boolean removeAllExtensions) { + if (filename == null || filename.isEmpty()) { + return filename; + } + + String extPattern = "(? Date: Mon, 7 Dec 2020 07:41:10 +0000 Subject: [PATCH 052/361] BAEL-4652: Running Spring Boot with PostgreSQL in Docker Compose (#10297) --- docker/docker-spring-boot-postgres/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/docker-spring-boot-postgres/pom.xml b/docker/docker-spring-boot-postgres/pom.xml index f409ca7d92..0b359138f6 100644 --- a/docker/docker-spring-boot-postgres/pom.xml +++ b/docker/docker-spring-boot-postgres/pom.xml @@ -9,9 +9,9 @@ com.baeldung.docker - spring-boot-postgres-docker + docker-spring-boot-postgres 0.0.1-SNAPSHOT - spring-boot-postgres-docker + docker-spring-boot-postgres Demo project showing Spring Boot, PostgreSQL, and Docker @@ -45,4 +45,4 @@ - + \ No newline at end of file From 77ca7cffa58553a29419da6e9ad0af062adcbabe Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 9 Dec 2020 18:13:04 +0800 Subject: [PATCH 053/361] Update README.md --- docker/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/README.md b/docker/README.md index fcace3978f..ce7fe261c2 100644 --- a/docker/README.md +++ b/docker/README.md @@ -2,3 +2,4 @@ - [Introduction to Docker Compose](https://www.baeldung.com/docker-compose) - [Reusing Docker Layers with Spring Boot](https://www.baeldung.com/docker-layers-spring-boot) +- [Running Spring Boot with PostgreSQL in Docker Compose](https://www.baeldung.com/spring-boot-postgresql-docker) From 3d0bd4a844f34389d78ff27eb8f977afe16dc591 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 9 Dec 2020 18:15:40 +0800 Subject: [PATCH 054/361] Create README.md --- spring-batch-2/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 spring-batch-2/README.md diff --git a/spring-batch-2/README.md b/spring-batch-2/README.md new file mode 100644 index 0000000000..08bf1933db --- /dev/null +++ b/spring-batch-2/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Spring Boot With Spring Batch](https://www.baeldung.com/spring-boot-spring-batch) From 3b04af5f0503a83bf7988fcd84a4b996c105b318 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 9 Dec 2020 18:17:32 +0800 Subject: [PATCH 055/361] Update README.md --- persistence-modules/java-jpa-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/java-jpa-3/README.md b/persistence-modules/java-jpa-3/README.md index 50ea75d995..1949207364 100644 --- a/persistence-modules/java-jpa-3/README.md +++ b/persistence-modules/java-jpa-3/README.md @@ -8,3 +8,4 @@ This module contains articles about the Java Persistence API (JPA) in Java. - [Ignoring Fields With the JPA @Transient Annotation](https://www.baeldung.com/jpa-transient-ignore-field) - [Defining Indexes in JPA](https://www.baeldung.com/jpa-indexes) - [JPA CascadeType.REMOVE vs orphanRemoval](https://www.baeldung.com/jpa-cascade-remove-vs-orphanremoval) +- [A Guide to MultipleBagFetchException in Hibernate](https://www.baeldung.com/java-hibernate-multiplebagfetchexception) From 59b090e4a832225e0d1cc7cda7db40aa96f84f91 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 9 Dec 2020 18:20:01 +0800 Subject: [PATCH 056/361] 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 18caabc784..36617a210e 100644 --- a/core-java-modules/core-java-io-3/README.md +++ b/core-java-modules/core-java-io-3/README.md @@ -12,4 +12,5 @@ This module contains articles about core Java input and output (IO) - [Creating Temporary Directories in Java](https://www.baeldung.com/java-temp-directories) - [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) - [[<-- Prev]](/core-java-modules/core-java-io-2) From dbf7a4cdc8a349834aabc5a4992fbc7feeca6b6b Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 9 Dec 2020 18:21:31 +0800 Subject: [PATCH 057/361] Update README.md --- core-java-modules/core-java-lang-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-lang-3/README.md b/core-java-modules/core-java-lang-3/README.md index 757806c8f6..5279cc23b0 100644 --- a/core-java-modules/core-java-lang-3/README.md +++ b/core-java-modules/core-java-lang-3/README.md @@ -10,4 +10,5 @@ This module contains articles about core features in the Java language - [Constants in Java: Patterns and Anti-Patterns](https://www.baeldung.com/java-constants-good-practices) - [The transient Keyword in Java](https://www.baeldung.com/java-transient-keyword) - [How to Access an Iteration Counter in a For Each Loop](https://www.baeldung.com/java-foreach-counter) +- [Comparing Doubles in Java](https://www.baeldung.com/java-comparing-doubles) - [[<-- Prev]](/core-java-modules/core-java-lang-2) From df1ee124a6470a09b4714a3390c71dfb2d1802aa Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 9 Dec 2020 18:23:53 +0800 Subject: [PATCH 058/361] Update README.md --- httpclient-simple/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/httpclient-simple/README.md b/httpclient-simple/README.md index 098d5f278e..93fb22ac1e 100644 --- a/httpclient-simple/README.md +++ b/httpclient-simple/README.md @@ -11,6 +11,7 @@ This module contains articles about HTTPClient that are part of the HTTPClient E - [Custom HTTP Header with the HttpClient](https://www.baeldung.com/httpclient-custom-http-header) - [HttpClient Basic Authentication](https://www.baeldung.com/httpclient-4-basic-authentication) - [Posting with HttpClient](https://www.baeldung.com/httpclient-post-http-request) +- [Adding Parameters to HttpClient Requests](https://www.baeldung.com/java-httpclient-parameters) ### Running the Tests From 2f42035fb5d2477f0b47f65d819922d8b5fb86f5 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Wed, 9 Dec 2020 17:45:25 +0530 Subject: [PATCH 059/361] BAEL-4686: Added some more test cases for TreeMap and LinkedHashMap --- .../ConcurrentModificationErrorUnitTest.java | 29 +++++++++++++++ .../NullAllowInMapUnitTest.java | 37 ++++++++++++++++++- 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentModificationErrorUnitTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentModificationErrorUnitTest.java index 899c902fb0..4264e613f2 100644 --- a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentModificationErrorUnitTest.java +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/ConcurrentModificationErrorUnitTest.java @@ -4,8 +4,10 @@ import java.util.Collections; import java.util.ConcurrentModificationException; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; +import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import org.junit.Assert; @@ -25,7 +27,34 @@ public class ConcurrentModificationErrorUnitTest { iterator.next(); } } + + @Test(expected = ConcurrentModificationException.class) + public void whenRemoveAndAddOnTreeMap_thenConcurrentModificationError() { + Map map = new TreeMap<>(); + map.put(1, "baeldung"); + map.put(2, "HashMap"); + Map synchronizedMap = Collections.synchronizedMap(map); + Iterator> iterator = synchronizedMap.entrySet().iterator(); + while (iterator.hasNext()) { + synchronizedMap.put(3, "Modification"); + iterator.next(); + } + } + + @Test(expected = ConcurrentModificationException.class) + public void whenRemoveAndAddOnLinkedHashMap_thenConcurrentModificationError() { + Map map = new LinkedHashMap<>(); + map.put(1, "baeldung"); + map.put(2, "HashMap"); + Map synchronizedMap = Collections.synchronizedMap(map); + Iterator> iterator = synchronizedMap.entrySet().iterator(); + while (iterator.hasNext()) { + synchronizedMap.put(3, "Modification"); + iterator.next(); + } + } + @Test public void whenRemoveAndAddOnConcurrentHashMap_thenNoError() { Map map = new ConcurrentHashMap<>(); map.put(1, "baeldung"); diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapUnitTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapUnitTest.java index 60e293f4b3..c5fc57d8ce 100644 --- a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapUnitTest.java +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapUnitTest.java @@ -2,7 +2,9 @@ package com.baeldung.map.concurrenthashmap; import java.util.Collections; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; +import java.util.TreeMap; import java.util.concurrent.ConcurrentHashMap; import org.junit.Assert; @@ -11,13 +13,29 @@ import org.junit.Test; public class NullAllowInMapUnitTest { @Test - public void allowNullKey_In_SynchronizedMap() { + public void allowNullKey_In_HashMapBackedSynchronizedMap() { Map map = Collections .synchronizedMap(new HashMap()); map.put(null, 1); Assert.assertTrue(map.get(null).equals(1)); } + + @Test(expected = NullPointerException.class) + public void allowNullKey_In_TreeMapBackedSynchronizedMap() { + Map map = Collections.synchronizedMap(new TreeMap()); + map.put(null, 1); + Assert.assertTrue(map.get(null).equals(1)); + } + + @Test + public void allowNullKey_In_LinkedHashMapBackedSynchronizedMap() { + Map map = Collections + .synchronizedMap(new LinkedHashMap()); + map.put(null, 1); + Assert.assertTrue(map.get(null).equals(1)); + } + @Test(expected = NullPointerException.class) public void allowNullKey_In_ConcurrentHasMap() { Map map = new ConcurrentHashMap<>(); @@ -25,12 +43,27 @@ public class NullAllowInMapUnitTest { } @Test - public void allowNullValue_In_SynchronizedMap() { + public void allowNullValue_In_HashMapBackedSynchronizedMap() { Map map = Collections.synchronizedMap(new HashMap()); map.put("1", null); Assert.assertNull(map.get("1")); } + @Test + public void allowNullValue_In_TreeMapBackedSynchronizedMap() { + Map map = Collections.synchronizedMap(new TreeMap()); + map.put("1", null); + Assert.assertNull(map.get("1")); + } + + @Test + public void allowNullValue_In_LinkedHashSynchronizedMap() { + Map map = Collections + .synchronizedMap(new LinkedHashMap()); + map.put("1", null); + Assert.assertNull(map.get("1")); + } + @Test(expected = NullPointerException.class) public void allowNullValue_In_ConcurrentHasMap() { Map map = new ConcurrentHashMap<>(); From 2d09274e409b51251a39b7ed96e4171c3af265c3 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Fri, 11 Dec 2020 11:45:02 +0100 Subject: [PATCH 060/361] JAVA-3570: Upgrade parent-boot-2 to Spring Boot 2.4.0 --- parent-boot-2/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent-boot-2/pom.xml b/parent-boot-2/pom.xml index dab9f015b3..2ee4f1483b 100644 --- a/parent-boot-2/pom.xml +++ b/parent-boot-2/pom.xml @@ -82,7 +82,7 @@ 3.3.0 1.0.22.RELEASE - 2.3.3.RELEASE + 2.4.0 1.9.1 From 212f1ed72dc752ea368c651a4dfa35b3720baa53 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Fri, 11 Dec 2020 12:06:43 +0100 Subject: [PATCH 061/361] JAVA-3570: Keep spring-data-rest on Spring Boot 2.3.3 --- spring-data-rest/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-data-rest/pom.xml b/spring-data-rest/pom.xml index 63a42857f4..dd96182264 100644 --- a/spring-data-rest/pom.xml +++ b/spring-data-rest/pom.xml @@ -99,6 +99,7 @@ com.baeldung.books.SpringDataRestApplication 1.0 + 2.3.3.RELEASE \ No newline at end of file From 50c668c300345ce9ab548c750ccb37f297a53d8d Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Fri, 11 Dec 2020 12:16:24 +0100 Subject: [PATCH 062/361] JAVA-3570: Fix spring-security-oauth2 version in libraries-security --- libraries-security/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries-security/pom.xml b/libraries-security/pom.xml index 202b3b8763..3b812f0d2c 100644 --- a/libraries-security/pom.xml +++ b/libraries-security/pom.xml @@ -21,7 +21,7 @@ org.springframework.security.oauth spring-security-oauth2 - ${spring-boot.version} + ${spring-security-oauth2.version} org.springframework @@ -88,6 +88,7 @@ 1.58 0.1.55 2.5.1 + 2.4.0.RELEASE From 8f5f322273fb2ca0eb258b94906135506be45dc8 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Fri, 11 Dec 2020 13:05:54 +0100 Subject: [PATCH 063/361] JAVA-3570: Keep spring-5-reactive-client on Spring Boot 2.3.3 --- spring-5-reactive-client/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-5-reactive-client/pom.xml b/spring-5-reactive-client/pom.xml index 7ae7ba6edd..5b773cc63f 100644 --- a/spring-5-reactive-client/pom.xml +++ b/spring-5-reactive-client/pom.xml @@ -176,6 +176,7 @@ 4.1 1.0.3 4.0.1 + 2.3.3.RELEASE From 8a264a9981db9413b51f7a571e0a303c909dd1d8 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Fri, 11 Dec 2020 13:16:09 +0100 Subject: [PATCH 064/361] JAVA-3570: Fix unit tests in persistence-modules/redis --- .../configuration/controller/BooksControllerUnitTest.java | 4 ++-- .../configuration/repository/BooksRepositoryUnitTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/controller/BooksControllerUnitTest.java b/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/controller/BooksControllerUnitTest.java index a5c3340065..757b32385b 100644 --- a/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/controller/BooksControllerUnitTest.java +++ b/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/controller/BooksControllerUnitTest.java @@ -10,15 +10,15 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.baeldung.spring.redis.configuration.entity.Book; import com.baeldung.spring.redis.configuration.repository.BooksRepository; -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(MockitoJUnitRunner.class) public class BooksControllerUnitTest { - @Spy @InjectMocks private BooksController booksController; diff --git a/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/repository/BooksRepositoryUnitTest.java b/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/repository/BooksRepositoryUnitTest.java index 1edf9c7e89..f32800e165 100644 --- a/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/repository/BooksRepositoryUnitTest.java +++ b/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/repository/BooksRepositoryUnitTest.java @@ -11,16 +11,16 @@ import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ValueOperations; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.baeldung.spring.redis.configuration.entity.Book; -@RunWith(SpringJUnit4ClassRunner.class) +@RunWith(MockitoJUnitRunner.class) public class BooksRepositoryUnitTest { - @Spy @InjectMocks private BooksRepository booksRepository; From ee0d98b8a56d6fef4a774b0f3156640a7bbafe9e Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Fri, 11 Dec 2020 13:38:50 +0100 Subject: [PATCH 065/361] JAVA-3570: Keep spring-5-webflux on Spring Boot 2.3.3 --- spring-5-webflux/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spring-5-webflux/pom.xml b/spring-5-webflux/pom.xml index 292e4d7ad9..48b5b823fb 100644 --- a/spring-5-webflux/pom.xml +++ b/spring-5-webflux/pom.xml @@ -64,4 +64,8 @@ + + 2.3.3.RELEASE + + From e6a310c4fb94132dd9d910b6d9a90412561d44cf Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Fri, 11 Dec 2020 14:14:59 +0100 Subject: [PATCH 066/361] JAVA-3570: Keep spring-boot-admin on Spring Boot 2.3.3 --- .../spring-boot-admin/spring-boot-admin-server/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml index 4c1dcdef6b..558aed8b26 100644 --- a/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml +++ b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml @@ -86,5 +86,6 @@ 2.2.2 1.5.7 2.0.4.RELEASE + 2.3.3.RELEASE From c008e43ea817b79547f9039fa4c9db05f80e44b0 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Fri, 11 Dec 2020 21:56:46 +0100 Subject: [PATCH 067/361] JAVA-3570: Update Kotlin version in spring-boot-springdoc --- spring-boot-modules/spring-boot-springdoc/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-boot-modules/spring-boot-springdoc/pom.xml b/spring-boot-modules/spring-boot-springdoc/pom.xml index ed272200da..d4622e0595 100644 --- a/spring-boot-modules/spring-boot-springdoc/pom.xml +++ b/spring-boot-modules/spring-boot-springdoc/pom.xml @@ -81,7 +81,7 @@ org.jetbrains.kotlin - kotlin-stdlib-jre8 + kotlin-stdlib-jdk8 ${kotlin.version} @@ -173,7 +173,7 @@ 5.2.10.Final 1.2.32 1.5.6 - 1.2.71 + 1.4.0 ${project.build.directory}/generated-snippets @@ -185,7 +185,7 @@ org.springframework.boot spring-boot-maven-plugin - 2.2.2.RELEASE + ${spring-boot.version} pre-integration-test From 19ab1ccf2b3cda5a0fdfdaf3b4d74a2d38c0af6d Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Fri, 11 Dec 2020 22:17:40 +0100 Subject: [PATCH 068/361] JAVA-3570: Use Spring Boot starters in spring-security-web-mvc --- .../spring-security-web-mvc/pom.xml | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/spring-security-modules/spring-security-web-mvc/pom.xml b/spring-security-modules/spring-security-web-mvc/pom.xml index 2651b3a0f2..b1e94b2db3 100644 --- a/spring-security-modules/spring-security-web-mvc/pom.xml +++ b/spring-security-modules/spring-security-web-mvc/pom.xml @@ -61,27 +61,6 @@ spring-boot-starter-test test - - org.springframework.security - spring-security-test - ${spring.mvc.version} - test - - - org.springframework.security - spring-security-web - ${spring.mvc.version} - - - org.springframework.security - spring-security-config - ${spring.mvc.version} - - - org.springframework - spring-webmvc - ${spring.mvc.version} - javax.servlet javax.servlet-api @@ -104,7 +83,6 @@ - 5.2.2.RELEASE 4.0.1 From 18727de7c5c94b03cf713039a151a7b42f384644 Mon Sep 17 00:00:00 2001 From: AbdallahSawan Date: Sat, 12 Dec 2020 00:44:55 +0200 Subject: [PATCH 069/361] 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 070/361] 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 071/361] [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 1f8efc0c144814a054ff6833803996e9680897b5 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 14 Dec 2020 10:18:38 +0100 Subject: [PATCH 072/361] JAVA-3570: Keep spring-boot-environment on Spring Boot 2.3.3 [cloud] --- spring-boot-modules/spring-boot-environment/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-environment/pom.xml b/spring-boot-modules/spring-boot-environment/pom.xml index 694e17fd72..d34bbd18c0 100644 --- a/spring-boot-modules/spring-boot-environment/pom.xml +++ b/spring-boot-modules/spring-boot-environment/pom.xml @@ -144,6 +144,7 @@ 3.1.7 2.0.2.RELEASE 4.5.8 + 2.3.3.RELEASE From 1a3ec076dca9c7c577c8ad4b0bd0fee12f5e0c5e Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 14 Dec 2020 10:21:03 +0100 Subject: [PATCH 073/361] JAVA-3570: Keep spring-boot-deployment on Spring Boot 2.3.3 [cloud] --- spring-boot-modules/spring-boot-deployment/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-deployment/pom.xml b/spring-boot-modules/spring-boot-deployment/pom.xml index 6b5e75bd62..94a4018103 100644 --- a/spring-boot-modules/spring-boot-deployment/pom.xml +++ b/spring-boot-modules/spring-boot-deployment/pom.xml @@ -197,6 +197,7 @@ 3.1.7 2.0.2.RELEASE 4.5.8 + 2.3.3.RELEASE From adbd9ecfb97ca9facc72c596ef26bf18bb3b4864 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 14 Dec 2020 10:23:23 +0100 Subject: [PATCH 074/361] JAVA-3570: Keep spring-cloud on Spring Boot 2.3.3 [cloud] --- spring-cloud/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud/pom.xml b/spring-cloud/pom.xml index c0e452afaf..c7f6dc56a0 100644 --- a/spring-cloud/pom.xml +++ b/spring-cloud/pom.xml @@ -84,7 +84,7 @@ 1.4.7.RELEASE 1.4.7.RELEASE 3.0.6.RELEASE - + 2.3.3.RELEASE From 9e957f2fd03be867521d5d20107a34f87011e552 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 14 Dec 2020 10:41:20 +0100 Subject: [PATCH 075/361] JAVA-3570: themeResolver bean can no longer be configured without enabling bean overriding --- spring-mvc-basics/src/main/resources/application.properties | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-mvc-basics/src/main/resources/application.properties b/spring-mvc-basics/src/main/resources/application.properties index b8a9be0b40..cf26fbfb60 100644 --- a/spring-mvc-basics/src/main/resources/application.properties +++ b/spring-mvc-basics/src/main/resources/application.properties @@ -5,3 +5,6 @@ spring.mvc.pathmatch.use-suffix-pattern=true #spring.mvc.contentnegotiation.favor-path-extension=true #spring.mvc.contentnegotiation.favor-parameter=true #spring.mvc.contentnegotiation.parameter-name=mediaType + +# https://github.com/spring-projects/spring-boot/issues/24207 +spring.main.allow-bean-definition-overriding=true From 07276b1aaa00824f55f3d88d4eacc37cbb52586d Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 14 Dec 2020 10:59:45 +0100 Subject: [PATCH 076/361] JAVA-3570: Upgrade Spring framework to version compatible with Spring Boot 2.4 in spring-testing --- testing-modules/spring-testing/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing-modules/spring-testing/pom.xml b/testing-modules/spring-testing/pom.xml index f26b0f27ec..9fe0fd8895 100644 --- a/testing-modules/spring-testing/pom.xml +++ b/testing-modules/spring-testing/pom.xml @@ -114,7 +114,7 @@ 3.1.6 5.7.0 1.7.0 - 5.2.8.RELEASE + 5.3.0 4.0.1 2.1.1 From 127a377b81f7fee82bc2b8ad32b08e1866035c38 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 14 Dec 2020 11:00:28 +0100 Subject: [PATCH 077/361] Revert "JAVA-3570: Keep spring-cloud on Spring Boot 2.3.3 [cloud]" This reverts commit adbd9ecfb97ca9facc72c596ef26bf18bb3b4864. --- spring-cloud/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud/pom.xml b/spring-cloud/pom.xml index c7f6dc56a0..c0e452afaf 100644 --- a/spring-cloud/pom.xml +++ b/spring-cloud/pom.xml @@ -84,7 +84,7 @@ 1.4.7.RELEASE 1.4.7.RELEASE 3.0.6.RELEASE - 2.3.3.RELEASE + From b4ccf851d315acdb38056b69961435ce28929861 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 14 Dec 2020 11:02:50 +0100 Subject: [PATCH 078/361] JAVA-3570: Keep spring-cloud-zuul on Spring Boot 2.3.3 [cloud] --- spring-cloud/spring-cloud-zuul/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud/spring-cloud-zuul/pom.xml b/spring-cloud/spring-cloud-zuul/pom.xml index b8db1f2fc7..6035ba7e59 100644 --- a/spring-cloud/spring-cloud-zuul/pom.xml +++ b/spring-cloud/spring-cloud-zuul/pom.xml @@ -80,7 +80,7 @@ Hoxton.SR4 - + 2.3.3.RELEASE From a0ec0f3d5ca376ffa6d16eee91ce6361dda67e5b Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 14 Dec 2020 12:03:21 +0100 Subject: [PATCH 079/361] JAVA-3570: Keep spring-cloud-config on Spring Boot 2.3.3 [cloud] --- spring-cloud/spring-cloud-config/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-cloud/spring-cloud-config/pom.xml b/spring-cloud/spring-cloud-config/pom.xml index 7fb0c1fd68..5db18a7245 100644 --- a/spring-cloud/spring-cloud-config/pom.xml +++ b/spring-cloud/spring-cloud-config/pom.xml @@ -34,7 +34,7 @@ Hoxton.SR4 - + 2.3.3.RELEASE From d3770851b0fc8fb4133eb73de66a26659b75304e Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 14 Dec 2020 12:05:56 +0100 Subject: [PATCH 080/361] JAVA-3570: Keep spring-cloud-zookeeper on Spring Boot 2.3.3 [cloud] --- spring-cloud/spring-cloud-zookeeper/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-cloud/spring-cloud-zookeeper/pom.xml b/spring-cloud/spring-cloud-zookeeper/pom.xml index 244ccbd957..e3241da02c 100644 --- a/spring-cloud/spring-cloud-zookeeper/pom.xml +++ b/spring-cloud/spring-cloud-zookeeper/pom.xml @@ -20,6 +20,7 @@ 5.2.7.RELEASE 1.0.3.RELEASE + 2.3.3.RELEASE \ No newline at end of file From eb29a0a084435ee8c318978321acf027e6c0ca61 Mon Sep 17 00:00:00 2001 From: Amy DeGregorio Date: Mon, 14 Dec 2020 12:15:23 -0500 Subject: [PATCH 081/361] 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(%kme29TP4oA!BQsCS;Fnq?Wi(nj)>*Ikn4uz9troXnx*KGkeyV^yh<<~ z-A^&%6E0zM&FzP3QX1sS(i$eSOs-3=Gmfd%y@grmZ|QLo#GQ$4$k38 z>uJ5aUTuuX({}pGTAO2Sp8IR=pR+f}{rBVZ{LsF$QceKhwHyi zlZs_NlC?GR25EORwIQZGxr3qF3;5K<-D_(OcStvF64U*A@Y43*7ry0WRoq*^UR`P;BjotA(-Mkqbmt7oN?5)&_3q4d)v}V9Np)dfv9=@3 zL-U1-sy&MJY@mxv?S}H$_N>zShcP2`aW{WBa{I!P=YwLEsNd(}4;_bp+WeWZ`7LL< zk>k{z8^H)zZ#AEPYhvAuYWvvRHl6w6=wRNEn{+;H4pa^;e?V_%8BJxx)r z&s^7M@Y0E;FJL*m4J^SPtES(nd*AT(9?9H+K6htwn$nZ8$}4rBHzYh#i62yGO(K(3 zeRV`PV&=&QABttKCuncJAS=FM^>@QU=M=u>y{N(lMi??B;VNfN`P!kh~jRGs8k@oZVKNx$e#`E7KBRQ|^X0GXBaVVNR@JkuR}% z*A711f~Ap_G{;6$_^=%Yuj4fptOf055yR?tvZ_Y~6YEC2Hu>kLCX^kjN@+2PLTmJA z`i=L`h4Ieo*VEn>#MIGC6z7(uQL;lfQb}`TsHScCMF=OJVDM3zvTLe)KQ%>njYci0 z3b6WT`|Z0Hm#*oY-@Q_?)je4G-+YQwI^o|ZLBJIFPP)#Xiwfq{dZ`+UwH0BMoa>+Q z#|yeaGmoCQWb@+YKBzSQsv>dIk+7be31PLYkljnyz4!>fZIyTdadTzf)VSWAQ^T+y zl}@Z160#~(>zVv(__REcb{Y}zhSs#M{P?(?J(d|&O`Ey?c4M8+SvSxj zW%;}6+gIua&+zIbVwu##sXJ#_*dJ@-rmn4eXK1^9PZNhf9BMmI?zZ{sRC#|0BEmpz zaL?WCwAh~PEn(XQ-x>(PSS0+Glj;jffLPqsy#0A$2&n!7U{-#H4=T4BrZ=SLLz^W z?(R#rW&h$-7CC96{#+dgyC`ejB$h8D36GL5b3ZtbZT}5PHUrH*8Q13M*#tz!Nkpsd_Arib(=DLv;tm!7&z>FZP$d&`*w=k zk400ZICOWELTSD!Yz`UzvPfUnqi(^2sf3!Z(l~gXk}7>>Tg_m_s_P>*>cV+?r%q?#(|U>yC&7e=TQjP zmFFxqw?0Nb`wvBNsVlR(lVr$@Qdj-{^J~iv*FRi7pFut24@V5LI8Bn(|9v5U#~B{G zxF}6NK*C{_c-mO*c9cJe!n-Llt#m)59pB3n?|!PP>zToVqh4-#g#VTr=!A792$JtA`+6fd3BR4}O z+S2VP5%1@#HYEAr%j?gd8O5@Ifr~%1AO0zZiQCVo>gG@ZtdfL~Ciy6eUzSjbG?*TK zf~35;NLAe+KFnU8AoiMA<{R67@WoRtgR@P_+s6Bq#*#(OjV9LPNu1{GV{X&li~fj7 zv)!zI)8@@X0=qPs^Sxu8FRx>`x$lJq;r&&C#nF@vU!*T(l&UXX%*OfJ@EIz!v0&yY zIlXR2oN;Dd?^ibn6TaY6rL|;P9RGTH6h$6~Kgm5N8o$*Lj7t@ClZ4y0Jk+ePZFn0A7x)?wL zQQe3g%fu?*q0R3coP7HQN2&kYF}~Q%-8@V^ZduwD%ctC)AvXW=dt`I6j_p||c_LIl zjSp5SjE8eB)9T22A_VB-TI>U!0tZ;lipiQe=dD?Bimb8}6kqARM$F45vj*T8nw~`e8 z?$_GOVqvS*ULt8T$x)KW?Ysj1=w>Cg;oU!26N-D_xoYg=qCd#^qBXRGVQM`tqZ`#W{X zMPku>nlzkz(0VFIU9u_Cc%PA#uxISX?s$AjGhF1G!X*bf;pdN#RUvTGWe43>wnH~q z!xKM1dgz|X1l|djFYzglTzvnC|I>_(p-nn_7%%CTHMJVmph4yvKVF%ST=5ZdV90sR zXh`?I5iVY(@CF3g9CKE_^(gW|`_6B*$>qm03WW>gfUxxYni58IJ1QlKsp9lcjsTt3 z&v~S%3v=*n5mR)_iV@nI!7Cf&%N7u(#+eHLWUpg=xe2$rLxzPKzM%bBhk->|(>)aT ztCd2Ila<5a4~BW4YUz2TYR&Hf3b{^+`lG29iF5vrO4{4Ka&a4~P?e(iPg(i}fbYsz z!tYt7dXzD3az+#VKC%OlXK_!jB$G?hGcP!$@da(?3;sBhZF9i&EhcK=1`wNRZIzr- z`|A!qj3LP>XyLJonB?VuK1=@K)P+HBz0nlzAQ9r-Gj_uwk{(0-0V_B~fEGV3TP2>% z$CJqzu3leiIaIaR6zb1bH6Q@jG08zbwpGQ(>2o5zTdmz@`7434OxfbnvS;l(&0cej zO^U{l?!Dcz);gmpx(86KiY^X~X>Of)z#k6dgGAVED2NgLYNJam9;ksnZ81l%?;&7> zntoHWb(4DF(|#;sFta^uj`c{JFRF?jXcm`|(9`4% z^2MAn;2@HX!sZCS@zD5O6Kk|@qJ$chX^JD-+RP|paB0p_nVM|m zuQeK|Fz%blezn*oRj{&5E@3S?wrToXdkK3UiH`w3N#sTkqcU{kbVuGo0T-T)owX(a zj@QeKE}M{B+(?#}F;WR4)7PatWJs7=(0uV;`@tGsUF?V?^G!mCyz`A__B9;DJpZ_- zDiIPm66D1Y>+2~K>xN%?4$?JWbNEC0^v4$zT;1BLMxTdvzjF4CuGy@uFQw-^P4%z& z7wfq2cm52;CLr%5G5}Bfj4yr=4;&lVXuLPLCzLdTfZm%JA<&U}Rga=^S=B2Fd528Cuc zK_z}#q&4j|xn&D7?AbN5V4tf4kaeE7C;L&FWp3be;ecFzLJr4!iB$^j1PW3H0^>sg z_J7H^I7`%ivn@lx%Ax_=>X_MXLR@xdjQQ^)+1415tMNe;?Dddi#S#gOR;=c_SfwnW zzZyW0XsYm+-8t#cdlki@LOiiB;Y(xr%6^orOh#~(vTD8~Dacp{2D-YtJ^AuB8TSIp zXSY>lpf+~Wt!a)b7m>=gu?UQ!&53EC-CO|*i_BO(Q*(qXS!Zgl( z6{7KGoQP3*f?R;F-Kq;HNE+weYn8)Vzd z#Ig)5-Diw?8l)B=EK?<0_RMw!ILaz{u?gv9n5z18?6|t*FP%uYhHbzy1S#&VAMnsK zF2B=~Pd2oYuABZ1K26tIWl@cOV?GW|(83~4`asOcyH`54x*Mo>KUURkeP1_#vs2b7 zV1dH8>D`{H5`7TTRf;wvcsy29;%$-B)uYH}$vn!^xry^9KymV}H!N-UaAal1Mn1&? z@2@1UVj>Z|IVJA-DuD!$0h}kOQ<8+#4mj8_U8`n_ETlMpY!ZZCL2}QUZApK!!nZf2 zI39enp4xxIDj!9D;CuC~QuUEU!HC@t4gtO)%eeu`aN=EOs%6&~?pX}~*@;stIVKTH zBT?Uw!GM_mjn%#p%YNCfxDPle?Jrh|pXJVAhp$`)#;!nx{fxO7ApW`Psf3(A**rbt zGNUXfWx9*8y^0gvAtOQE;*Gh4i2`;l_i3&Z>_PAbb2v@O1c-|x%9jEjp-A$fEhJ}W zs9J&CJADrnEXz|hOyZ?OfyE!?N*m9UvoPnOe=i%c(s4=Ot}0$uE1gOZ3?15TR<*S!FIs_~t*oCfLL zOKDzLrg5NA?BzM5=F7P?_bb302WD$s3VL-Tf8@#iC)ESZj%B3WU(UFG3?fF=GhxOE z-Ga?&TzJHdiKZ^rIaGysv&(UHOXncfK)3bfrKTq(0M}6RUAZ~wE_vFUzT3yQ*d}wP zx`j&0%^&p;Ob3PCKhJ1(IR*gJQpTz%6iWfzJN%Q=^V9qn@Jts5J-vD*>0rNLN-liCv(-Z;ptz7|P<&AD@`lA2Q=7z~x=wl(u$6!OV-FvB1;@a6Jc?_~L zp2rvX;tJleH&Z`!H{eW|D1pW9X;*Q=92oy(nYhK6LB|zPi{%+(nZhETt9}DPN>RabN!UZH-|RV2rJJkn=m;qw zg`7HDkk+5%KILt7;qKi?5XwN?h@uVAz#RDLxE!*eD1e9x`@jCoc;zH=IzFT7Hlt^! zDjm{A1y$5b#}LZVK*$UCx1hPfnqI|e9szKIDiXh^DV3|3t=?{TJ8JVHJn%)jHO_9lf@}=|l9!*Bo=j+a1MR)k zt00(f2Uhy7#l?|^gVjN%Tp1S!+M908uPGRP1LwtbUMwTau?8&D*X9kTpQBCMSZ`Av z!&@?9H_O5KT5=eH?3*Mke?P2JhPs`Py@%R$yRV!}3Wtmk{DkTGD(a;ya<(})to^{g5rbaG z)l7R#^l(TN!6YShK$=yjnzs&F<%g&7uMyI^d{q&!)$K8z8x9(K7E%u*4x3jse80Bp zf2zv=(G8{LL`?JumYj`xnE|X3f|LI7!MPYP?hffEyX}T?EHy*9LukZGfJ;dr?UAx* zpg0rIX#nR$&_IRnD(<)Jq(l$pz+}Rz7p4>ngq(S$gDL+J7v~(fsukcFCPzeM;j+YbWPU?lb! zj(W<6DJ|h?$_l{1O1iEhO?eyVMVK(a7ir5-DWKBLr}@T{R4J5aU$yZe8(#z8*|ljU zSjbuuaS%7H%DX`9E2N>FlKek+=lq?|lkdt?Q56It6Un1+RWD=-8I$R+W?Hz>qYzA}^<8<2D(LPz%HRB@+bV6vhM>wElvMY8?YLNI zFdp$mBr630g*LBaz#w$PYgb(?E-_AIWzM|QDu;3d^}%K3R#fYK1|HiYMb3jB0A_sg z4OFLIf|?4aE7CN=r>N(=mVq8y(5U`?g;-d)zfdgqK_-dyro-=AH8{+xc`{X;+E`~X zquiRj|9H$iKPY15r7h1VFhQm*%XJVZBrEQ3)yD1z(L@sRU$muzf`jY}=FQL% zODCd+0vkh`@MdKx2pa4aJ09^t>&tT0z9g%kE;9oZpr*gJ#Cd*(ZUmZ?wR*hS+%k%9 zuMRj>n5JN){(JEG3~0oNflaWL4KnTb2YYx96ea%P;|%cw1l=8UfNBb~ZpN8&>pe>K zHD+#1`@u>>P=bnWA&f?rddKD+Xdc8~l-;(iwSYj_GK&CIp}<7i$0vN|u_K=qq(gB& zj?DYxiwbP41)>sgJ>6JVx%A6xglvGa#yT~fIr6()a07jN9As;KW)u#+Bv-A?6rL7p zf^5wVGc$hoEz^K0a|ajNk3pUot4?@$a1Oy8^4g+S-Gv7&(%PHj;hWs9PF`q9bbj-H{|qh zR|&oaeaRln`96#Yqj@znU!@p7(K5;(M1yNrq>(vB7NbGYR%Fz3P_^@f z2}NlMeRLlJ-xmBZS)ICf~RfcAhV!=v3wr-VoaJQs0N%K1hZCcL?Bfw z193Es0HakWLG1EX;t#&Xfyya~9JKKZrn>iO9B90?YzaWe3o4ZqOI&N5quVUuDuHlf zoiSLN1YnIL+cCC;mY6q*I8|_|+ak1YV6v)H(`73q-bEh(2|<2<2w%IOWD;tlFI8JC zX{$OsX8xr$!P3w*+f%+l?^iJ0nLi|NkpHb!mJVb;NJN2Bb!!ATq5Ld*i>i&O=E2Q7 zsWVVdj>Pf@H%G`*{xgd(m^*I;%Lkf^(Ed&7GO@Vi00RJ2(#Bj3v_2is0U9>bbwszL zjdI25Yb*1U%{+843w#LN*gob7!L-GpZHPmoo^(HQbY788h@O@M49Gslr_OW^Z$>)) zP9-kQLAZ&2dPmdGQlCEi^~E1PO8F`Nt*ekm(Qnv$jCb;JnudISNgTS3daPs?79I4| zH+pdM)(F{;os^9mJwgp;d^>(UZ?HWU3YEJqS4N<_Nf2T^>x0ao5-Q8k=vczyG8F3* zb;%ZFm0y{}mJgSFWAHw&J+VHsDaj&sq<1}r01Fgi_ImU~t9%*K!ceeOKYlYAO7EJ< zx3ZYk{?MakEfKk|_3#IS66VfD@#SLZp#?oZ}Zyi9n+hz6BQO&^$1SW!p(#MAllk z*evQLofhp=G|-W(537^a?7NoMI3l#H!SiX9x4QSv?i6O@qX&M~R)rj=MOOw#en@T- z1fd2#zl@j4n8egvFhfX}VLYmIpEb1`0XOLRc5@x{{!+6VtzOT#iKx?MpOxgJXEk^g ztns?I*?)Y@i}d?sE$)%%R_~AQk1+YOB|soV>Xa2F&srj(tWwv-XTJ0+-yaX^V|f0& zP&5+bw&-A(vAocsJYzNJ;z-1w&uT{X`Wa*hD7C69Xhuw-nLVh??-Q%RXifEb{w@Vh zR_Sq9(!;9r?S&o-c?4*0EaQ6KEi~c88)9tf?7KkC{Y4H4e;FN576Q0)I3x>N65uaT z7M~|eEwFjfgiN~R5)@(ry+%8D3l<$MF`!iR5>P8#%`Qn!-8m5&e|2$DZ~m(TV|s{& zl0)F0Dey!{GWjDU*+k^Ze2{jaK>1a>xU6W;Exi$Brei?=wiqEylx%@xfrzxIh~LX; z7PK=2>#7S-%JRXrltTC*5{T$ovh>o+=(p`6B?NVG${JWmAhI+ZasUb29AlS_zXgdq z>~O5Q#{43FMAm8zl+%sT!_=v|e)K%iU%~HzuzKkPItZJyP*^Q(B;{6p6nsWbw^aa< zAbtw<dZ+?NjanipidP3;NMk6PP((a} z6$O%N4Fc8uh;vFYH1We$r2bh8VJWb!_@IIQkL$#{U|wxkw^~WplfX*K*5{lL=B+%2 zb6db4Tw_9~fJq|M3(aQxV(QJo5N)#eel!oCkQ4BcQ1ck!`O(^%Mo8@ea@v>&)MNx2 z9nEEuu&Q@t#rLf32SI_b3SmKfyb;X~5~xeMAjqh;lWwp(Qo8%^z(;AyRjx;>WSzu>F-`3WCe`rAM;9r9f>YGe37dosGY(8ON$n`LD6 zo3LyyF5qF%SRkqr!$*VqrHyzW7+_T2{7xc5(>(FN`~K_Roy$+AfK5c<2kbl4?kvXeiZ% zeUa?wa5l_5P4htqG}J~ETSb8nR3>P@5H$<zKwU@u$ zNwJ{mx)ZHTFgT* zm%r*a2`L0EbLn5LjuJgYQuJO`B9Q|0&Gmr1eMq$Z4Hfs$BP0nV{mMXdU3=^wy@2$f zx1lEmAB+0*RmUo}Rtz+^AV4bV?x45CG8RGJ2Mp;>dFaJl`V2ay-Pr5{3Nh&Il&2EU zke-r(U(jRYzvE0;I@`(Nz_~-J8^oeAl3nD1r-2d6AqNF5JmNLUzghY26%+GZFVut< z=1PC=mU`(qDnY*+!mZ0hff3k3k;*$5!6Q{-R@Kbu+TC`edpJl4 zPgeImdKp*p>|$Z<(dL$(_JdW1AQliQ5+R_%3Fub(nd$=!YhHzFINPF(coLrW`p2XY z&o$am^oTJ`*0S7x{O0iq!dr>*ZA{7~iY&O8Z!dP8C-}~&FND;0dobM-WULW_?4_O; zZRMOkJdsR)@&$Cki%7+$3kG~~Fd%m)*Lb{sMb(^jzxLD{ICFw;NKrV|`pmYCfn=#o zP7nNW2`C&yt1lTO33z-+)^epco)?!XoKaH6<3H0>Q=iqXB9#+8h&E&$5);m>6}%nA z9=l>43Qiae`JfcF49#Gi<9-&g=9C|WywyWK+M2m8o0PR1>iGdvwCk~G>Zd+PqkjjD zbcUjb9aa=F|5p4@3HqbO0>n;8R&e?jwegb$?PWiqQ!P|bC|>!t_v(g*Jcv1=yrddP3;s538cF|L9@T7M14(Ao(zOB{lR*~bSR-go`5-H_2xcLySj)%?ua$K7NIq>Ycrga*Oy466@@D6A^XdxV!mbM|!agyl;6{Wq$> zRy}-`N3d4tk!Gar>Lf(p7YL~BF(Qdl!;-fV?+x3RvLX%q8lt8MLJRTzZPq5CIg1nm z`J>L}od-~jRv$A0xek(NJ^j;h4c45Mmhk#_hetoXPIMJd_=7_F4C);F=^|37CF~H= z10p}j{!T?9XmSd(iwI}TI%yIk6#z+ql=Bl&Fk)bm;ITilD*NE{*}L|v{6S46e0)(u z{>7XoMXfu^NR>gI*JE?S)`biSK@;_1j~ok-$rt$qtgT78G&tTw7w$LCv?#@4E*AJs zaKhg^5|>e)2bCIUz+<~ggnXMNluM8RD{gh?!X6dp$G8+AyN|2@K4BtAqE{!iKDeT& z2F!tW$$<;)2cqm4yaUNjpk8C6z)n&1*HzaoA(l#?LDjP=PT#Y%e)a?(#7eu6wj*E* z63enD&U7(puQjN(OU>*GgkY9%SB%qncp`UH#%9K=OSmZ@BnGNX2Vz5fHojtaJv|#e~gOt>Kk*PEU4IhEPRqdZ_iCANeiT>WwOd}L?O%EwSsgx zN~6V@=H{Y_tN(+)pE)xC3{+O0?VnK&u^%sNEVZ}R9dx(AJkcUrNas%dWsNxbr*@58+Io zApAL@?87DHt*#lRxP42;*h`Ap7IbMM?NA^f9-3$18~NF&1Xwcb;P(J~kO9&%ibn_x z_s)SYi)#X&Gi`_~LZbnl^z2~GAbRou+EEYB{+--5h zW}s`=t51LIKM{53I1hbFs-+J#vXn{MgQ5kUk92dKp=-OM1{u+Vk*u}APYc*w$J)>D zhjldo9T#R5NXelJTK25D z1vmi$Z~MD`3>%dqN1dF$`)G5WBThUyusNbyL7{HvDhhyDZi5Kgy!VmhiY#rzOL0!h z7XurtuK5nenCJoV2^5a{hOUE|I#c-Gpa!-|!4E{WxkMFNDwmca=j8=!o;k!4aHZ8J zN9gx~Yt{@!q?jpoUG}QrJ4RC@dk~K_^Y&?K4VK-z~^{$J`jixeBi_EK|YYd zwW~J9kp*pa2MHuaeS6QBd8&c~iwjrT?MAS~ zJHKAxwPhcUKf3%pxAB`tNVd!i1ZQgkNF3-gwN4(jaqF5mh3L+Jnb!_Zu0qU5s2{ThKVr`o!D4-?T2JNPI2SY%lu}b z;1^HaXiBl%gvzz*yNvm&#NQVeK@54ggVYc<9Nb(akw3|bYfRDj(epdSZc9-MP>fHb ztM0wn2X9vkD*uY9Ciy=I0-3VPzd?~}DU;^r_&fp&9`O?ROw|JUdfjGX zFcGD088@XfSbgnV4#y5ZktfVB$Ao{CBv1mee40`1wk8C=I zQwW30vK*L;NjXPj14nyQNzMq`3XIyzgeQQq+!?RSBUvutTCN7)g)rgbf&%cM2BOMu z;+^zr$6oE_g}_<19($z}7s~14BWReNS&{7n+UaN^1pU#nM2Q?;!;>(3pkgIgeiWRZ z2Y)F}qa9Al5|_LT!60cYCA+gKAaoGV{}i%6vd#j5?+K4pRA49Qzfkjyn6^(hp_2wx z2LwNq4=qOE<6{f*opvw<4yQ;J@>=G)6G0O%eVTUW7@j*~uyR!|X|coIIk(&=YH`;r zSk84Z`)-po^8(V7t|gQr`sw|18_-S4u(N?5x=hX-CQS+u4DZ$wU%XZih;{e^x9)-C zrRawS`1C3o(cK;{SqvDVKfXdJlq}iFlj zvQF_)tcOzI^EeHvF&rklU}Yz71-r-O(Pj#80S8lQK?8K!3WhYuOZ+ag!$bQ)Yw(M}&4JT4Ma;_SWS9XBac-2ULXX_cuxb8a8q+kzF1lWeOi4 zcA%Jqf2MQK%SfuldmR93tbneD2=_iEeqc09Q820uUN~4CjD%#Gz zbCBnf-k6I(kt3*<5uZ0_I2u|AM4nz7|6p_Jp{?X1P zUN`ECh#aC67a>n$k5d{zzTSC-v`5R*KP zumr`djEzLtokcY3yZdCtg7VFB{|9rYKI(JLTv5pn>=WOWH?8M-kM z=%u=Yd7?|TYli~!K18BQu%N$zE@g^U5@~^&dvgQ!aFilG)7P8gF#vJ@J!Arl zS;U%%s{Y;Y4Yz991W|>Iqco*83`d|;YnNjRY`~hrh9JmA4(wCJWfN(z6MB$_^_I;W zU}S_FngW-NgO#)<4B9-8Bamc6q`^S)FF1H$zN+vF#xFi3hVEDvKDp(jN%YMxt)*

{|wNqGFUU2mnMZ}vT@;YW;e94rGGA6OZs}o7> zdNtq#YDokD_8?@VF(xyVU=(e~ZV(&7HQSSGcwwRCV$HV1J+hK1f(IFPEcLzM7%hW#7z`03G!2jU_2 z4KXa<2-$b;>fsr=OdR}}nc>($uVf|MEGAq#4%*N)YiZp9%f(^E2l^%`HAL)Ljd8?g zWErdkn(Ra_Z;(Oox8T?evZhbk%;;wV@Op6G=8N5-XS_GIQc6Y-;DwyGQNgeSuu{k}-#}18W**ua*aMVrpl2QV;Cq?s7$QFel@xPCXg&TF z3WX4Q*kP{hw7u z!}3uF@ByqFHh^;hZymg>4g)KO+1|1oe7M3N;#cE3vorvS$juMd@L(3ZHRD?-c>LGLoELggp@T=Vg{;yZ7P4EJv&?$!St>{OTN|)!(&pqc8F{J`E=?P3eH&Ne=adxNKtj;J+rY z8m0dV-OX7BW$S<;J4+Ag3tQ{GJ7XFkSY%FgCdQf@;-GPW<^&8w7z%r)KJXcUvs6X zKiUlw5a;m9cspiODH7f(850#oKpK4+VBB|Fv+wqa@6acJ528BTo&&qt6p~!9CLrt~ z5^dOv2H*r6%AI3!Ae0}qdmo(3OTV0xV{4J@lmfu2P)IM{@%g=U7rJ$Rl(YZ}A1t5< zeer`PqNJEo>H+0?6?JB0)rJIg5WLBN6NA113KehwY&ZcYVRC|G>N1StWuh z;Ifi*{quTXErUoNF*Y-wvB3iv1O@y5kqN6#H7wLHk=S(7a)o{;>L(%4AS2_W#MoXh zwRwBuywuNiLuP$|nyI96{QbagU`@gfO5SNJlRIqLdMv`BJxIM43}g&a)0fs|V;+Z4 zY1&M^NgB;Gqeffi*Ixn8q1QCn4D$z0)9}Ef)Y9F+7~vISy}iT*AJA{j*U67nCpj&| z!YsmqjN;?>7jkiS<2mTN(LcQ-Pv1N~{rdLTzss5VU7%t0MZTC#9%B2={9BgRJYv_9 zF-f^(0E|>VaL-*gM?wzJt;zGq`c1ll1E%n@aLj>%Ox?aN@WqhnFZ2*w5Ap<$L4UqM z?(L9nfun)YWt>=ufT+|t7!}NA5^)yx4VQg7wtHU_fzk|J&cSCSp!~J_(5LGJ$hi)1 zwrSGAwr8-I8ZsL>{3{;H;}8q|o>IMgxKWQe$ejZpCi`HFRe*)>SjR-F#K;#)JJAOD zV7QnCTJCEL!Wn@Jq?2-r?alkVfu4wm^b*oNb3oA=hn5#;$TLhRkfL3Ii8TtNV9l)# ziyv}~isg}jEzMQ5og8RB`HFc2O@=dxk*e02eVDL6U*s}J%#-T;z?d(|K<|k_I zSKT+Yo`}O_RTF`0+}!HbKu6D_wj;CjETX%*5;_yA1bK*G5Aqf5FtU^abCb3JVjZ(f z=ZHhlIT@e*@TG^F#Ohr)2?v>krD6|(R$NXK=>x;?XLR3$Qi_x~99UO0B4H5&omKId zZdfgVJuOKFM*-hi?)nrD10#Yq3A&l#rVB2m#bjZ#T7(nmTPOr z?fX!!4C&|;t_py7)8JU@zoU;XyJW)ztYgg7n~ac^yOT5Y8M8WCeD)k5obvgzLUs)X zETaGUjK<(3D-JEDq7Q@7X4?f$_k?QN;3asWAbkSE|e^B zJLBJkm=?calbe&ZG-nTK8^Gjl zBD(tOA{D!+S4SUU()TyfZ5V>YaV4#rI`^CZc4)`I$qgZjzr3hyTx|!4Ljm61(9Z1|*V>Q!PQostw_U{3xz~pF%5ISMJ`EVJ7lHwrp@5 zA|oJK6`AErlf#XB5G*JRZXM5Wv0IR^AR>5$NVXo2tjusn!50_uX*hVZ76F10Tre^h^BOU0Hk^f zlL+pR>EJ+<Ps*jLxO_3TI*-__M5R${VljT!WIBfTB>gs zlcor!qFVjcEwLl{JIr1^01{|84Q{0%k5Af-K=ovl1}$6`Syb3qQ)96=Pmq>mCM&64 zfDh@?N2(SU03uS=7bC)dXeZMD+gm@>=moM-y9ec{G0hDR(2yJo z(F{HLH(m5+lc`c5VsX&*28B$R)fD|_j)LymhwT=kqDUqF$WasFSHY2&pU; zD9a_25g;8nbD~Pvn8grOO)qT&S0{XC7LyoGI~?awqhT-x~w~wA2*=U>-1drC~I-6Me8D*p@J@jFSo5 z`b$$d?F|z3#VmM+kpXDN1vP<$&3X^{w>xNz*5x9@=j5qyJHgH>i4^AFz&7mOQFK7E zOq=uwL~#5m3-lkPXAB)|RWKP2QQNoz{XgU(3`+|FQ1YQkpIci`VX_Z!e1tS>;n~|Y z39KeFc0{kjB0t0yqZYz-y00nDwD28zM7b1c`glPn`IrH$tt>-~R)e?zQB}{*-*rAs} zJh*4|g*@U6vabFm{N{?Rg^-mt(#8bc1Zs_Q#@P!Y9hJZ`49!uGk* zMJ~1oQHn7gin}$|q1j~?A^Ufr(LGCmdX6fPdsuyXf^5wc&5d_8XGRZFr&^z4D8L0- z^dWs3a#2Z_1h`pL4ztX^So<7eSn4;JcdTkZIDnzfFQOgSE!@d5zJE!Tc;$@l^NW-; zwudj!x?_Pnq`4XuIwK&CqMoZTbOSK1=D{JE_5!vfr==OjU}QYhrj>Lfkv!L*suS!( zF945<0Ujh6eJN7^-p};!IHt^jT-Id=9GrAp&~{`CQ)`VF+{H~&@ZHT?>NpNIhsl7F zrZdE0#4iA?ny#6~85T45KJa-=@=^mcqA(_)sFp9nOV(5dQxA-FYB&_Hq4f-%ARJ3y z3tKXT@1U}n*l-9uUpp15I$Tsi@_j_`M{h=|884ftT>gFj#pH`}SHbT?|? zUJp)m1j&v$uYEmeTV3n=0BMT!eTYp2uo@@n<`H85R|ZQx_|!(9Y^`n`qvpWphk8Fe z#$<$8NoNOuE*7`N^x&(qASCmClmTRl9m!Y*_w;S{f%hJ3I|EO8$O+GLu%tk<@VC%5 zE-7!L`Nd>7EKU7zeN#|VDTAkHtS!?A2({xM+&Tb+JRs!t20k5Y!%b88G{SVW-rvJ- zLDD4>(?7*14kk>}lv0ZNRcpGKh{3M@2MMPrvRB(gT}CSHms zKjqA_55?fO;Pgo`J+=qm4)6)Bh5BBA=FW~mWm*%>B9r7iXQ)18tgCThDbXctsEf#k zkxy=8HVCO4pE(Ql*=A!0oFs;n%p+4)Y39$^AgI({gt4=o-m&a!fZBu`8H6CNtju-a zW(A(ceI26R1jaeCeF==|#0?UUHZzA%`AlwzH60w-9%fAsW8X`EF)n4eTfg$ee=gE~HS#d?na0Hr$e6cMWHba9Q5z6{z21Mn-y#usw#w#g333nRHWJMkB|Dw=q=aopeML%x))_ zY??gK#~~wJHi&!-y`MIq*_En6dd0|c%%hBuaFk2UDUl>!6{@&jejU<<14&?nV$laz z)RY~nN>iN*c^jfDifBE$Mi*!o_vJ+BXoD|u7YxC#su&7WrKAA{bg&|N6ZcyN>JQ3G z4lGMSsJI5tJcsWC*+x8TmBQOs5hZKwp0%|7xjUE7ll^#8?7l=enC;rZo*YOJ)Sr2* zGzFu>MOGmW85wZ-62=-1{}gXl!-lrzTSo@18;yF>?Wk^=m=OiMIhZGvbK*15UCmEv zkT#QnyKTrk_0WR|OZUH{^p`l(hCWma+{m_|V(Ho1n=gxn#pt&e|L z!$Q^~ph_N5Y7%acTNuzElNmQZIk-@S`7M-GG!f8)IJd6Ssi1iSf!TleCft!JBbluu zeG4&_HR(Rj6UuwBc>sa9QN?8i99Yo3qWr;7aP@)1kF@Hxy0x*L)Nv@kAXY>dqh!n6 zb2S5#$hLH)TSf(WIFq;nqcCLjt3kfKwuVW=SU#=>X~&IlzDVE=^!wNPW=$I z#KLetZrqFaE5J2oStnn^((RDw0Ua<`0Ai3C6arz#F$w(&$|7p~V^wPf+S8bo=+AwV zlvXZDM#wfW-n&g%*r9OaALPk=Vw}*%1s#ITpwZU6aRf)G4?>73oS0gmJn8pXVPAu( zfCzFyMM#U7Hb`8lC>`A*f>*ZM2>(C?2>0hR;^&^ zoMYn<_*jHovr9}gv|f5OQlJYlMr}Xw1B6eVTsOMMV9vW+TUgdf9@Oh?=nkd+c!8`Q z-K->_f}McOQ`Yq3(9Qlp7YAX3%4h_gjBY$KgD%-sV`C`+M0F0V(sS)M#w(NfyyK+F*~w)#H~+n=BYx-1P|Ob^upRwjOOf>5%4Q$N6})o z7Tz%Vv`}qy#R6x`jLjFwzYl`LrSBl~7$Ia(_H7{TV%)58dH>f|V=Sa^!9Fs*95fHK ze5^frldPoy16_w|_7$Ik8&brXMfGX`=W$MP%zF^i15|zp+!gDpUO|)Y$D94(xKaUE z7?Mi_sj{15;uC>j__U^A*#vwE#g<&@3i!d++RNQ<3eeMo0bP9*2^W=i42m>*p@hX5 zz~V%YYlvJcMk$;`a)_X>av4?9Q?$e1S>d^R8unr$tkVV4WaJdr^VJ{FU(8FB#eyUkXE}nR5Rt5Vk@5hqfsKEh25G+<}zHRfG$d_ehQ-vADluX zG0>Tg#4U470$Sj{{+aQ{V7PST0VnfDDq|D56dHF>7(Yy@b9W3tg^;1vH`0LmP!wM? zXTV**2{pc>{2_oZ!ha}4ji26i6U+gD;(dSdr8C5n;hCd0009FwV8jeF7SPBwnBm&b z5Z=$`)aXxO5q=)%Es4a4x13T!MX_{}=p`@o)MrL-gX!NfIL+i3CSsZ|hAztt-gaFK zCpg7|*$=<)^<0Jw)l?eb9JZ$DGadACX54)2k#>CJ=eYW2C2fNSK%HvA6oK9BxV{&suaB8Qx2ps%__xc4WH^c^?IP7dPoMd=vE#U)5A{*?N5hKEg5@!Jw);F1 z0t|k*F|`-+(*CcnhmZ?jqH%4{?@LxH8V`^yCDXiG=R2abS*e~=0Ji}4vD&kWF$ajU2>Ic2 zB%#qPbKta;sOGdmazSCWdW|t%U6XQg1^vqqY0axzWC#Z zi~h);5R*||(jhEjMgxki3Z65o_PB{M#{+qy5;3qmMS_Sv)jov`xWx}L6ei2Z$PH$; zP}F#Ja>fPRG=>R)UfxF7uBmJ?XF=<~hhYhM;|^vS^YP=*P^hsb?w@QyuS3t z>~IM?_z#*tR>Ads- z{mGkXJM_H;>#)plLQibIMCc)g5eyv=0Q(I6DVUjMS4S-7pj4Kc!pfLBKU7=RtzKKbD%O=2gVp|A2IJuwP z>vXDhQhmLM*qz;9=;wo zcnW9}{4&{_{$DkndtB6Y+Wrv~%q38mNpulu7&(kbQ2IeaLe9WI$YC7TbjeK66x)_V zmSP8xEoDSxKwLp&0S94l(=^#fwsf&gVK6*mYHL0uh=yBvVzblk^S;0C@4sFqIP?8} zKKJ3euj{(&U$d*9eIzvwj@F4KlD=T3I#>`+(9S(B5zPw8ZaZZ)Wk%i_F4hV^${2AT z&GYE%-3%>N3|BHqk_94=fs~Iug1R#>?ctAG{z1^f)A_H6r1Nq@O)UXbt=&^je*4D4 z3v+o(o}&wTOJsEU0Pv%Et{w^N8L2qI!GPP#DpLhYH*a>*ni2qP8 zl@Trm!si@Gn8yIA^8DWP&L!Z0c1`JpjxQAxTioERrG6p^u>UEsoI%X$Lqhbc2=6TD zuQpb5g*Gk_l1;|<&7Xd}3`jM&I*xh!9{4zjV@u(AqY?P9TxsR&AEB2mh|w^umjY2gVF2<)18>8QNq&74hS~{Tq`NpSgrEty`gZbv&9P4%si*7 zVd!Y9xVcwO_tI2^QOilf*E1?MTaFg;xExM!E*8z%c}}~gCt+ePRm2YCtcYePx>Q;E zYNo}i%wpR1=?PAqs$qhHkdR#}VS6FegGSP~Y~jV+(;V%y1x34$*sW6;(!L#CSOAJR z^_PF{x`kBQ?8|h#{&(`LrHifIcUU-xjGF&p3Kqlml~p(vLgBiAfp{Zusn; z{O;c%re8WN-k_0Tn8K{S^)Yx^8nS^H``C%nC(|-i#YbRHuaAz)Hun)dcyX<816)(Y z*4G1d%|hKuu7VcyHf1D)#mLYK|7W%j-&Vd#`UVoX7?Vu*%%I6}ImkP#(5B-;0vafX zy5&LhHku*yVe}^<(LAG;ZBEP!eQ-JFbp&_V-7+wmzgo2j3xr250q*@I`1>+>Xw`)wf3b64K@brqPABj>t)|DpUI+Qcu$U2~GNI&OMg~0;a|E{+ z0`;jXHW#wvjuP+YM5|jXr#a0R1HNu3*$Z$4IHofm zKS|dbGI`r7rpdEUPnGzvTAM|IATFOPi!Z&OxJO!K80^&W@Q!3Zfn6-j9#v{6PZRf@ zX@A>pp)F?F6UYorWHyXS8L%2U;Cl(sPT=kQ=RyggMVw5}jmyhq2b}b_Lc3mZH<3lff`!MgVDcG?;(IW;@ew7!DL-kZGK=Mmogtl6u^~p?Urj4 z4UR?B_0%@o832e!5%;Mv%j6b;Oq!pW?p0J|$)h~qHBn5J{iVlYG=o7^G@hu7yAJ7H z4%)rTTK{>)5bMenF>wVyRZ)yz=hyKtF$NNgnYO&>In}2F^Jhdt^ zZUI2r8f+AVc3KQUf$Zh;?{Ba|SddTD(15pC4=5a_kKHYK!63?c%p~THsfwlZG)*}^ zZ)QKjDq1Yl=&}hoy3`H#%+@E#$T(Z!I@~oO635e5ouJlby`vK(viQ7h(s~~CIseXu z&;jYraqBCv&ihjEVz&rqTe|opZGl_=;#X?^5x?R9OtYEhWBcIp7pS)~Yy@Ha$EDwa zgpyH18_|r|oS0q&E~aQ}*8E7R7U<%psoS&aBn2_dv6H!`K%u}*DV?0S{jI4r8~)g< zxLR_c10i|RO54v+1S5>ax(iYlb`JWkNc%#_K_Q;0ix`->l3p<74?@62qp?8jKQYE8 z)eSs9j2_O62|m-9&2CL3dMmXk7SEv%QBn?E`svD3BnzdAA*$}0Y1b5);%xbXJ&gDk z!UDvTXv;0gX;ucpm9$fe1-uxPZJ95TWYRl?)d?DR8Y7u}P~TnX^`o#1G@zNGlBrnH zfQCac1MU$Mt!sN@PZOSk3l5CD(7TL7oqE=4Hn-FxAoLWS(kP^gA2Mc*ZjF&{1Xge# zX4}fyj-{JScW}D@i6_oo?qIg$laQeBV4;)%`NfU+#x&xx^eg4=^jYL?hxed;JnK`m zqW#WgD+MfItl0dn?~Q?;RyhP5!nO>+YK1D2?vLwdz_TlSd>2-j(SRrXTbkho+q?}&NEg;vgqDA1%(JgKPpwu+a3zy8G ze#?L@1y6cv%dqL9&WXm9BQNVxylH(8VMK%cN5Ke_ke6Ns1fK4p*6hnv5TmXzm}nP{L48> zTrYHPM923kh2*q6&+KZmbeRztiZi2^uyQB{^EpGnMh>P|a3?i)k*MXE1ixnYt_vkm zH!fq~)4`VsZA2@Z$<~)i7{&deHB1IVKJan#6er3^n(+*neu!bjexDFX$4U7nBLHSL z0f0yZkIo3Y%9+cg7zm3SIbB1EI{*s(muoQCpR3-B6ynmiLl17NhSgX01hi+jC0 zV%V-WMpy$)O3y>{Ot)776!P%^>ziOyL-wWMkEF&(Q^3FX^N_p@ zFZxw-Qf34ogK3_p7Oyx&GfFAm89w7|+-!PkO-y}$3Wk6m(v-Pn$S*C+^xG2GJ3{Zazwe|Ot{u&fZ9+f z_XL{b<2IoN{e6Mr3>axZ3^jV zY8Kp|4p87l$|sZXT$m~Kgl49~ENR148Om#VQYqhuqPFXV!T?S>QW-bet`<`lO4*T& zmOLH`63BdDNx{r)@*6Wmg>-`Qw*|A{X0jCsh8cl-YX#hxlbc#^TGq`k8h-Jn%0?$=W$rIhNQ=j zLzUwQt-_H@5ll-D1UFa~UNAYa%nAiH=o&z^VPaKF2Uy}okX23b*@YK3NDH8Bx;nTq zj(9P_{{a(J)H|QGlr1<3C?UTAQCUr8b1ZKK)GEd7Prjqoa0}OMZG*3L>v&KET^|1z zmSLAYl_>yVklnX;^T%X0riHPU-MDUDn*MCbSaS*WAaMRYot`hTC*;+{dKgwNU<+7D zQ5fs&bX%`rRv#1|c!6XZrZ?&IPQw&pfXa2qJ|OfEGu`j49>VGlM1MypTmXFF!b(yz zYw`$#NqBtTHq|?nZYt&I`C5Dq#0MNV3lR_WY)>j2ZVr|pX;r=|as1g5v)4KiFW_)a zOtg>7g}b*=o0?mQ%77zVBjl)&G$sy}_i?*ZKf&~ggp~Bo0(P>L=*s9j_W`Z4?FF^8 zEj0#-SuTE2CLO3HY;77M*?-^&ndqhIZLz@_z-E#_mMOKfC)4)Eico|nm}|KB*5o8dnw%8P5ziCxsz;PaI0tg0ZDU_%rqicI@GRa#zjS&u5k^L1m^9OTZ|vH z@@`uK!Zj^XR$fYluB=g%@I8R)U?a04TnIuf6>+v1Us!P)Mb)VFKx@HH0}2s$rNF}b%WVKgqfjjh>KJWOpsv4Xf_)MKJpq47xz<^Cezj*N`E#| z;qPeCyZtxOo;K*$F(p!OpgA>7Npb-z_T+7Z={uq<>p-bNxzkEa>=m^z>gpm8zr zTEUuxgE%IcWo7K&AR?53_A;9P@GV@bPOlykzRe2F^T#{!JAFWtLiq(uY9n_(g~K1S zh2_dg6;U*cRl016dzcK1@xoD7TXJ!8@7!ByM7nHrNkRn=<{eQoZDB1-g0}%^e)AsPF14%U32{;ND#e;AiqYB z9aqlrIAnhDtDdM}8jdTOXUBbEOF~rHsY-&exmz+!O!P%M2iUx6uC!6e`-ATfn99QJCS?rLz3j?K5Z?z8@BH;8>B~AX) zo+c{u83E7+jnUj}i9MmFdPv&6$ZmGSj|c8V4WUJ(&gj9qs&dU6synjjh&F>8z27KS zb@(x#w26p)LDfN4OF%cv7Tq-aI+!^MZG+WCMkx26HR@9%!~H=Lg`P9}WJuT16M0>n zh*0Z74>!*1na=Ixm@xOdFMhWo?rmRKr`K&6D-|YjQ*`_!dCdBSz2^F5a?7sfVJYPg z*}7*aEo|m14Bz>JP{L93iGVs=wdo`ajb;hu3WmkbPUfCK8jez{8#K8$_^}#qUD35# zH&)15jbP2$R=2y7dRtMKT2g-hi8MIYU;az6*2csuMdIRU@ZC4;>J(Xrfk0w{t57e= z(k@XeZL!Sb7|lUOHi+*K{gFo=&svUPBVLk1zm$wydJi7s){9iPWvK}RX2&Iok37R4 z;IVuzvd3@RSZN3u#FkVXZJ4+E5x4n+<*9HK%7PvpLBolhoFcT__L^PwW}A$FN3NYSAi5V| z-(v)B3Fi9?u+kO<==PG-Tt_oFEa}e1r3$3v`uxZsk8!0f>84Qhw8`3#Eb0d+kl5RfT zwaL7HJ$L#PQWG~?DRHB;rDJsq7+jkJ5b!0(=pb{Kqx<+k2^0J7iyrdP6-rKBLM#(q zEtB!Q&kn^feXGCuKH$lpqvII}6fBzdUI~^!y@lTL$_zdb(23|^gN!e&F=rBQ)ZOsZ z->j(`4?<6|v9HD&FIdScx~PTca(JkgDTYp#u8<~#c0Q9OO$e^MG=0ox;A&x12z5{q zb`4O#hAce7J^Yazw&`+2AG zJ}yxw(y?bZ$Ahz*sm=hFJQd-||Ey04lDbj|+BOXep3J zvwD7KkUC5!=^025Fno6y2<5?{u+>9z#{jN+)9=`wskbb?AA>H9XB3vynED3}ILu_B z6xLoS?8)t7<=`YR@gOT7;?ta)qy*l!!4oB&*`-0y_txT$Id^67jJMI4|8KR7_Ay3= zG~4MYgQ%c89+4Ruh92X5i!TBc{xLv)boE|PwP(agWukfCxH*Lid4_iLy!VuA5LV*G z&^Z=55FHjPW((OBNgtbcprC5}5lMJDuFlb%1(F+2VT@>%A;4Ly>PNHXBY+;C;f%a& z!|fCKX71=DI9CtCJ0aX4=NZ7ATtJYyy;c%jgRanZ_3cZ=8TT@^=`1J=FhRCqr36+2 z0vH66kJiHn;0VDyylUS3(N^i%#)6`P@P4-c50>WrARaw53ENm#z{*moM@wKo>SR{O zcA-#9UI?#ldtz&fD6a2GNuItCs|5-5V%JoTZlMCJ-i)%gX=^%ZbI1AOVJ|iY4cJaN z*%vYVqF0&FXSOy2W7{lR!@nn1gwv2d0axDD<}-;OC)G@9#h`U+Mbcr0kNEcT?%8MX zL{s{8X`~EYEcs!u#A+G16L4F)OM)jrASQQ2jz6Z$61fK|z1aj7Drx{{A0)*T?}w9Q zjn6qq0=nqVU?k;qEKGR(oPg`Vls z@kU*@F{6{Esk0p_(Q$C%>S=|Trtr$+B0$DkI;6qbg!&_mBY~@WzN7i%tQ<0)EpdE6 zQ>04pZ9tL^d-*sAUD@+}k5S{|(4xJPizL;;xRMgj!*8cO!0FDK9rK5Hwl#3r$U;D8 zwFrr(u{@@CMTOHSW4+W6q5dZwKs2Nh01>1*QZCG;ne z>ON)itqy?xOEo8E2R`cH)AGxS!gobOqg};NtV%N@2lT@B+{FB1!WN)Ga9#`O8!pT} z8Z@$NAw~#bEqYssm;^2sje6ItQ|!OeH1)h%H^?%CI8OW?XM$B@v?~vHf8x9NPMU(h zHLzk=o~(AQ^gVd*Xo9a;Fn7OfofV&m@=M_^%zab`t|V>j!zP{P2iic!u&Zs%mk6n$ zn?T5vVnDU26`P`sq&}sG%6w}q)?Z%p?vuoq;c0_DZIhNc+K z2x@F~P0?^!!p}UFUNY7z-}G)L-k=!x4_U{{eP))$mK{dEHfbEC#lU5|0K>n~+FlDU zu@XX?JJgYTBIh*!$QEUR*q;2lwih-r_jLZbSU!gp((Z@gTBz73D5c4kf9le)Si%ml z-qBq2MSClxdC*)-N&$9TRS2>b<$8G^YO6&uDTV<1ujZmkOTYYccTL*2hfhU1v##j$ z+zaPo84c4Dj-;TbG^{Xy6qJr*W&?x+a(^=9)+`RF#u`l2x~^y@SV-gqCvw1?pu+V6 zqji}G6Hy<`#~{J6Bf)1l9AAA-I%*;(yDN=mx8cby&n4TP_(f7dc~oi8)QjI^#{J~| z>nBd$HuSeon2^ny`peL+d5?>&VuBCr)GDWYyL2XseHVGML>)UIwKX08wltPSxiSdY zHor$$IZE7n1OqbaW%-XO_&D1J7)`~~B^v<}e{aVF0H`fy(i+gr5rA@%KWU8JNGeXRXE^pX2RO zEr->~X{{`gV4aU5SMbK0WBV3us+&6KtBk5&=`GRrTeXO050#|jVPr0g*}wW&zupq^ zl_X6^suN|oTA3%%Z3FRH^rvbwxzohT?#t!*9nFnaLZ!ywGsMn!py9)b`z!^{;5)1$ zz^;)hhA~sFRT=CY+SH8BVkvD2Rqsd-1KKA-8%fR7a%&At8Cf$rONw$AYi>`J3yupY zPSQP~Zn_l=RO$kHy@c#=f^Tiy0=8i7;)B62O6ZY2x|K&TIQ@Zud?o_Cp zJ)cRze;zZ>KW)Q>4#(Foey6|kFmDQLXEiek#y($dq)tSB~zwA}A>*)}i96B}3 z;)qni>#zVC7nehUph?f@eU#lS1uJdoylYs1aeN&#&0sKAEV-HNGXbv9^tT!J@Yz!t z@{ckWgGvNjz0p)s*bv#+rsu*oLX5v#I_E)-rp(0}r=!_Fpp5}!XQz<_ST-XDHTM7l2s#x|+ z^SWAy)23QHlVU6=ff;}>8gqJ?z3<6=xARt-XhK0S10RvAO zTSrsNWpTh)<*?Svy_ir3%gu%p-i$>!G3YI`Q_|`l2f$8b0tBU6YI)isO`$8tRik&0 z%Z?Syy#CCRx1{H(x1xu1g1Jfn+w*}Pj%tOWBCZ-=yCaJE&3z30_=oZ9a7Ax0D-s1q zi8_bTm)Zd{OFWAT39Qxg`;%&s4&GEN^z>P?6doWFq=AuZ?Phn7=lK@`YIf$I<}=8$ zn&gxwB8&NJix>-|o_b4EV=8HtBw}l&{#O z1$Q-C^E@~mvJPCorRp~P3ZE~@OrB#P*qA*ehQKkoUf23-`~HMK+BHrvZG)raELUM3 zWvtByU6{5mgXRu27ItFQ)4iLYd6m=J&_VMtmT{G+P6~PtZhO1xR9N|q2@!TzH+3iJ z92oH48cbRHaDc2Qp6@U^@tR`5f4AIXG>^Rr?ZvAU3tpm)8LYdZ$nIQx!X1&>i_&oQ zT~qr(W8u6f&p*R*y0WRi^jROSN32-xPC0n!?8D=*_s4ZHP&Zm*gVaHZ(7h=(EN`w+ zrW)xP%FbO5W3)LlJWR-k*Q1|aX4#(4e6M@{_OaRKC1^UP#6T^wyP=7%e%;T)%Yb{> zsQ;R2PT5ADXh|^Mi2e|9(;meKj8+?rRjRt)VMhe_X|X~T%b@$gj+mQ8FO_AwTp{GU z(?$s&g=_6&{n{kam90ne4Szhi0>vfYyX%}+u>S**k_(lkb&w5DGEeY4{?oBG&EEJW zG7Q4}&Yqr=F9)2=iE}Is*RkS`AWL;bBsD|lf%8o<8{nV+Q~c008)*r*=^k!wa*$H;mo*{ zV~^Qs6kB!S8#(_a8~uhOY*Qcx4fXw!z!FOsU%Dmo1j@5KR(J7$0MdP+Wuwil8rOwN z2lTAlul4B~tM?!rE?bi8IZNI)$_Tc+;mOLzD#HK4ThXn0Dp-6^hNfyZTAY3^c{Gds z<*N1J<_8Obo@2>tJUkZS`Mw;^I-mseG9I|>as|T(l(i^yh%k*J=L`!~#86Qm9b>1e zU}qxwT4WpnD z`!cl!&J#&Q(hexEwE7!Va9eZ+S$jb1UD!tZ2h67Mcd(7)3-xG>5tBlOPz?|n&Snba zGiyx+>H99{L6#amd8_$+lgw<$gK6g#6UCMIj}H!jF~d@#=uL1 z_RyvObX59@Ti81>XFwGLY4wr&`1asQt8dABgyjxRne7=A`GLplw%-Y(Izb9?l&;Q| zGGrHvJZv718!e%gLZ26B&K9>M+yu307wB#QsD;{~v0)vuxXbq3Wa-zD-MkxEw?*D% z)uL!@I|YL(ne~>kzwi9C;1-{>n90`M=2vpSQUL_F11cv-fi9wsL8uk^m!@)8m6jD{ELM!kg zZ*FFclyD2ecuJ!6?WJU}RgVO75ezK5F(EqNWDq0*t23s0LV0ERXx~l9S3uK<7YwIC zYnE|j*giNaS{Bz-;8JS57Y_+K*!r}&A&y4EGXEUpN-|*-^v^i_iVBAnEVdZHLVEgB z+S07vU9$+16}ocKcgY;_5%R=tBaM6Qg^q7IYw-)Qx0?tZqB>d7{n!T7ocxilLN+XH{rH6_h8|9sGKGULg z`MgO_jTN?OTcS1IS1<*3P!04J0x#^ER#C_5W-*daQ68Y+BaV&M}ZP*_PVa_kC3igo1S?*95E{E zZ2pdBm=grEU|hnWBE<&{WQ)n>-TNv`!LYSxq1I6$L%d_IcX^TTl`QH?q;OJ6>k3C1 znOgwurj?`J#cKsR5_aUE{;Ov{YZy5uZ-&SZ(*n2Bxrl`gBUUQ$ABB(MAjFkF2znyox&6V-7<5d~^P4aO{XP6VVhdN6@D&v$q6RT$XfnZ1%aI#gi_wmG?Ck@2%PYYP? zEFOC&|3{nN8E8wBLj7Pjp7#Dg0AkR4dV#T;$0Qpy@7J3OAq)tuf zBdX2spra@pA)Cg$g5?Ox$zfK1?}2?hW&l#zd$65GD!3+F1v3apuIsZwtOqj{zYHB=O`@%)!U8>;YY?{dZ?vW`z2c_W)5 z?#RF@W1|gzfj~~lvQn07M!R^EcK>KzB7y_=+Huq|RLMkLu^6s|p0SE`(6;0%%mH=x zdvGS1y2FH_<(cdP53WR5V^VdGQDv0`mRE|b=qgb%*ov;Uid`x@3?4wm)^*e;t4gZ! z)~kjG2)D>^f!0RUISHJiLYtT#^uDzI<@w^Bzg$T-Z_tB%it4t(|0V@4TxGQMrSD+G zTUp4#WdPS^93cR*=<{PcWyggU6;K}!3M4S4DSA9d5c#H1KA3Ky`_PKH72-C9{o=pU zwsk`#XJyTD18xoVKxhPnu!s|EbGpxOW$PVqK5Whpg&hjC076MV>(rVzH+&=kA-0DR zUz&KNw1#pW6(J{Q#r`ibBXu~cU-jdlwLZ->;?ZkwMCJm4boWzl z2O6u9qm`F* zV{dal1zDyttBP|S%~j}Z8Ei_Ot5{XnS0Y^oA$znXJDq|L%rll>`OMObr!?hvfYn-W z;;vrfX_%l`LSDcP2*Yz~f~OQlhS)et8+EKrE*wsD9rm^9#=e05$RQA6AV?>I$Yti%V;ki+Ax>nq zxmB2*I@NPOzE?dd?FX{>}38&KV9s9DIcrS@t zzDXAG!mc?}%n=Nrc`tx3^_A>;$&@T9XH~Iv-Fa@>8igsEF#gDoRu$7j+hUFTo$Oeg zHkto#IfJA`uH85E+AL3`3vkP}sv&v^pm@-v`;n6!0!bDUF18!HR3AHLg>Gb+P6cKu z(KJVyi(cQ)wBX>-&M02gJ7Zv{yrGS~%yQ6`FPaQrpGcUPFZ1%K8J?~RS&_zNG&lGj zc%Z?n@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 082/361] 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 083/361] 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 084/361] 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 085/361] 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 086/361] 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 087/361] 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 088/361] 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 089/361] 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 fbf57804b87ab53a5096c3f54f2498189e100b2e Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Wed, 16 Dec 2020 20:54:29 +0100 Subject: [PATCH 090/361] JAVA-3570: Keep spring-cloud-bus on Spring Boot 2.3.3 [cloud] --- spring-cloud-bus/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-cloud-bus/pom.xml b/spring-cloud-bus/pom.xml index ec56e23ac7..15eed8dcf0 100644 --- a/spring-cloud-bus/pom.xml +++ b/spring-cloud-bus/pom.xml @@ -35,6 +35,7 @@ Hoxton.SR4 + 2.3.3.RELEASE From 7b0de8a7031b00df90c47983ac34abae2b04cf9a Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Wed, 16 Dec 2020 21:00:33 +0100 Subject: [PATCH 091/361] JAVA-3570: Keep spring-cloud-ribbon-client on Spring Boot 2.3.3 [cloud] --- spring-cloud/spring-cloud-ribbon-client/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-cloud/spring-cloud-ribbon-client/pom.xml b/spring-cloud/spring-cloud-ribbon-client/pom.xml index fa9cee29a2..7bc7b51d51 100644 --- a/spring-cloud/spring-cloud-ribbon-client/pom.xml +++ b/spring-cloud/spring-cloud-ribbon-client/pom.xml @@ -46,6 +46,7 @@ Hoxton.SR4 + 2.3.3.RELEASE \ No newline at end of file From 080dd971f8c0c878620bd68304005e7582c890db Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Wed, 16 Dec 2020 21:03:50 +0100 Subject: [PATCH 092/361] JAVA-3570: Keep spring-cloud-security on Spring Boot 2.3.3 [cloud] --- spring-cloud/spring-cloud-security/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-cloud/spring-cloud-security/pom.xml b/spring-cloud/spring-cloud-security/pom.xml index 3a007c8df1..f861b892c0 100644 --- a/spring-cloud/spring-cloud-security/pom.xml +++ b/spring-cloud/spring-cloud-security/pom.xml @@ -21,5 +21,6 @@ + 2.3.3.RELEASE From 26eff5ca447a8f9e3c4f4005b0d8bd1b8d16778c Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Wed, 16 Dec 2020 21:14:09 +0100 Subject: [PATCH 093/361] JAVA-3570: Upgrade Spring framework to version compatible with Spring Boot 2.4 in spring-core-2 --- spring-core-2/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-core-2/pom.xml b/spring-core-2/pom.xml index edbb351bd0..3f8e84e13d 100644 --- a/spring-core-2/pom.xml +++ b/spring-core-2/pom.xml @@ -198,7 +198,7 @@ com.baeldung.sample.App - 5.2.2.RELEASE + 5.3.0 1.3.2 5.2.5.Final From 3d17425795b3c5f0c3ee4dd2a3459aa16c75bb53 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Wed, 16 Dec 2020 21:22:30 +0100 Subject: [PATCH 094/361] JAVA-3570: Register DefaultServlet in spring-social-login --- spring-social-login/src/main/resources/application.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-social-login/src/main/resources/application.properties b/spring-social-login/src/main/resources/application.properties index 2bd99d8239..22e6acf9e2 100644 --- a/spring-social-login/src/main/resources/application.properties +++ b/spring-social-login/src/main/resources/application.properties @@ -1,3 +1,4 @@ spring.social.facebook.appId=1715784745414888 spring.social.facebook.appSecret=abefd6497e9cc01ad03be28509617bf0 -spring.thymeleaf.cache=false \ No newline at end of file +spring.thymeleaf.cache=false +server.servlet.register-default-servlet=true \ No newline at end of file From d7cb1a586fe508b44ff021ecf1da04d71de17de2 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Wed, 16 Dec 2020 21:28:39 +0100 Subject: [PATCH 095/361] JAVA-3570: Keep spring-cloud-kubernetes on Spring Boot 2.3.3 [cloud] --- spring-cloud/spring-cloud-kubernetes/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-cloud/spring-cloud-kubernetes/pom.xml b/spring-cloud/spring-cloud-kubernetes/pom.xml index a3669d2d55..44c429d8f5 100644 --- a/spring-cloud/spring-cloud-kubernetes/pom.xml +++ b/spring-cloud/spring-cloud-kubernetes/pom.xml @@ -25,5 +25,6 @@ + 2.3.3.RELEASE \ No newline at end of file From d4b22c74e3ab06291ba92585f136342c347b83e2 Mon Sep 17 00:00:00 2001 From: Adina Rolea Date: Thu, 17 Dec 2020 14:02:59 +0200 Subject: [PATCH 096/361] 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 097/361] 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 450c0fe6dbc87f7955b87c5a7666d990cb88e34b Mon Sep 17 00:00:00 2001 From: bnasslah Date: Thu, 17 Dec 2020 13:49:42 +0100 Subject: [PATCH 098/361] upgrade to springdoc-openapi v1.5.2 --- .../spring-boot-springdoc/pom.xml | 2 +- .../springdoc/controller/BookController.java | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/spring-boot-modules/spring-boot-springdoc/pom.xml b/spring-boot-modules/spring-boot-springdoc/pom.xml index ed272200da..46c9a6a1b4 100644 --- a/spring-boot-modules/spring-boot-springdoc/pom.xml +++ b/spring-boot-modules/spring-boot-springdoc/pom.xml @@ -171,7 +171,7 @@ 1.8 5.2.10.Final - 1.2.32 + 1.5.2 1.5.6 1.2.71 ${project.build.directory}/generated-snippets diff --git a/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/controller/BookController.java b/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/controller/BookController.java index 326a97149b..f2355a2ec3 100644 --- a/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/controller/BookController.java +++ b/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/controller/BookController.java @@ -5,6 +5,17 @@ import java.util.Collection; import javax.validation.Valid; import javax.validation.constraints.NotNull; +import com.baeldung.springdoc.exception.BookNotFoundException; +import com.baeldung.springdoc.model.Book; +import com.baeldung.springdoc.repository.BookRepository; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import org.springdoc.api.annotations.ParameterObject; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -21,17 +32,6 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import com.baeldung.springdoc.exception.BookNotFoundException; -import com.baeldung.springdoc.model.Book; -import com.baeldung.springdoc.repository.BookRepository; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; - @RestController @RequestMapping("/api/book") public class BookController { @@ -58,7 +58,7 @@ public class BookController { } @GetMapping("/filter") - public Page filterBooks(Pageable pageable) { + public Page filterBooks(@ParameterObject Pageable pageable) { return repository.getBooks(pageable); } 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 099/361] 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 100/361] 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 9a7a3fdac34d633480a40eb84f7cf7511dfbf24c Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Fri, 18 Dec 2020 10:14:23 +0100 Subject: [PATCH 101/361] JAVA-3570: Fix spring-security-oauth2 version in spring-security-oauth2-sso --- spring-security-modules/spring-security-oauth2-sso/pom.xml | 4 ++-- .../src/main/resources/application.yml | 1 + .../spring-security-sso-ui/src/main/resources/application.yml | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-security-modules/spring-security-oauth2-sso/pom.xml b/spring-security-modules/spring-security-oauth2-sso/pom.xml index ed4b1d64ba..a272ba5b50 100644 --- a/spring-security-modules/spring-security-oauth2-sso/pom.xml +++ b/spring-security-modules/spring-security-oauth2-sso/pom.xml @@ -24,8 +24,8 @@ 3.1.0 - 2.3.3.RELEASE - 2.1.1.RELEASE + 2.4.0.RELEASE + 2.4.0 1.0.1.RELEASE 2.0.0-M2 diff --git a/spring-security-modules/spring-security-oauth2-sso/spring-security-sso-ui-2/src/main/resources/application.yml b/spring-security-modules/spring-security-oauth2-sso/spring-security-sso-ui-2/src/main/resources/application.yml index 97c8de7839..8cee9f24d5 100644 --- a/spring-security-modules/spring-security-oauth2-sso/spring-security-sso-ui-2/src/main/resources/application.yml +++ b/spring-security-modules/spring-security-oauth2-sso/spring-security-sso-ui-2/src/main/resources/application.yml @@ -2,6 +2,7 @@ server: port: 8083 servlet: context-path: /ui2 + register-default-servlet: true session: cookie: name: UI2SESSION diff --git a/spring-security-modules/spring-security-oauth2-sso/spring-security-sso-ui/src/main/resources/application.yml b/spring-security-modules/spring-security-oauth2-sso/spring-security-sso-ui/src/main/resources/application.yml index d1d9ea6ebc..f98dee9429 100644 --- a/spring-security-modules/spring-security-oauth2-sso/spring-security-sso-ui/src/main/resources/application.yml +++ b/spring-security-modules/spring-security-oauth2-sso/spring-security-sso-ui/src/main/resources/application.yml @@ -2,6 +2,7 @@ server: port: 8082 servlet: context-path: /ui + register-default-servlet: true session: cookie: name: UISESSION From 35b8de3a5fef91ca64758b3dcb23d0e3ef836e83 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Sat, 19 Dec 2020 23:07:14 +0100 Subject: [PATCH 102/361] JAVA-3570: Update Mockito version in the parent-boot-2 to match Spring Boot 2.4 --- parent-boot-2/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/parent-boot-2/pom.xml b/parent-boot-2/pom.xml index 2ee4f1483b..ace3e538c9 100644 --- a/parent-boot-2/pom.xml +++ b/parent-boot-2/pom.xml @@ -84,6 +84,8 @@ 1.0.22.RELEASE 2.4.0 1.9.1 + + 3.4.0 From 0ee156ff9235d2f696b1ba3dd50e505c2bb1ddc3 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Sat, 19 Dec 2020 23:15:22 +0100 Subject: [PATCH 103/361] JAVA-3570: Remove unused spring-cloud-context dependency from spring-mvc-basics-3 --- spring-mvc-basics-3/pom.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/spring-mvc-basics-3/pom.xml b/spring-mvc-basics-3/pom.xml index a929337b25..fac6f54a16 100644 --- a/spring-mvc-basics-3/pom.xml +++ b/spring-mvc-basics-3/pom.xml @@ -78,12 +78,6 @@ test - - org.springframework.cloud - spring-cloud-context - ${springcloud.version} - - org.apache.httpcomponents httpclient @@ -149,7 +143,6 @@ 2.2 18.0 3.1.7 - 2.0.2.RELEASE 4.5.8 From 00e15a4911ae4b34efcb0c15def916352228ea91 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Sat, 19 Dec 2020 23:21:02 +0100 Subject: [PATCH 104/361] JAVA-3570: Remove unused spring-cloud-context dependency from spring-boot-artifacts --- spring-boot-modules/spring-boot-artifacts/pom.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/spring-boot-modules/spring-boot-artifacts/pom.xml b/spring-boot-modules/spring-boot-artifacts/pom.xml index 2704b71bd6..467f931559 100644 --- a/spring-boot-modules/spring-boot-artifacts/pom.xml +++ b/spring-boot-modules/spring-boot-artifacts/pom.xml @@ -86,12 +86,6 @@ ${jquery.version} - - org.springframework.cloud - spring-cloud-context - ${springcloud.version} - - org.apache.httpcomponents httpclient @@ -216,7 +210,6 @@ 2.2.4 18.0 3.1.7 - 2.0.2.RELEASE 4.5.8 From e2026cf43e7c537d5c5be35a7d051e50200b98d5 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Sat, 19 Dec 2020 23:27:59 +0100 Subject: [PATCH 105/361] JAVA-3570: Update JaVers version in spring-boot-data --- spring-boot-modules/spring-boot-data/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-data/pom.xml b/spring-boot-modules/spring-boot-data/pom.xml index fe64b07379..06f09c70fe 100644 --- a/spring-boot-modules/spring-boot-data/pom.xml +++ b/spring-boot-modules/spring-boot-data/pom.xml @@ -168,7 +168,7 @@ - 5.6.3 + 5.14.0 2.2.4 1.8 1.8 From 84a14bcaeb9a2dad95794b418a80c91375d7399d Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Sun, 20 Dec 2020 18:25:50 +0100 Subject: [PATCH 106/361] JAVA-3570: Update to Spring Batch 4.3 and update config accordingly in spring-batch --- spring-batch/pom.xml | 4 +-- spring-batch/repository.sqlite | Bin 73728 -> 73728 bytes .../batchscheduler/SpringBatchScheduler.java | 32 ++++++++++++------ .../taskletsvschunks/config/ChunksConfig.java | 18 ++++++++-- .../config/TaskletsConfig.java | 18 ++++++++-- 5 files changed, 54 insertions(+), 18 deletions(-) diff --git a/spring-batch/pom.xml b/spring-batch/pom.xml index 9edf8ad3be..75ec0d4877 100644 --- a/spring-batch/pom.xml +++ b/spring-batch/pom.xml @@ -95,8 +95,8 @@ - 5.2.0.RELEASE - 4.2.0.RELEASE + 5.3.0 + 4.3.0 3.15.1 4.1 2.3.1 diff --git a/spring-batch/repository.sqlite b/spring-batch/repository.sqlite index 2b549352ec8073708bd085fd414ed93d189c7511..a2b87ffa00f315b4084437ce2f5f639d47469027 100644 GIT binary patch delta 4429 zcmb`JO>7&-6~}kQ-Q}(*ab;Ms<0dMpb?eG7&2UNX2h}f;6cb4yB|)Mhsj(^zxl57K zlB<%G4Z>#Es&nYcsKXTXB}ft2$e}KfL0{H$VO7@m;)0T)avA;tBlrl_#V4?Kjr0u}2tZ1Y_T4f61O< zN1UHIZ#l0y%g)H|p@9*n;bTaQKAtFp(x#@COH+EvCn=(j&xF)eS{6k`$fN|HmJ1PKoWxiNdT&3WOy;9!euoe@nD2%no0pl6a+CS2Gx+H_=6cKm67imMe<@}5D278)aW3M{nkdGhoA&w{T1JGf-ge!sX8xB1}98Tc(XM@nR*w~wv z-Ox~bGw4Q!+&%qNe1Kver)&aV`@lX(Ii4hK-#4eViv&SAjuN&2Ui+8rFvUD!vwas$ zj~-)=^w@Yj5>7@ZR;OkntCQ37$?$YE#=JR33_zl{F!t~4TkMN$o}Gq7`n7)aq-?F3K{X?loBat9yBfv`!#fC%io6_~HMrk&iF$ z=2w3;@C^s~D(3uC|CPQUIga=Km^n{hwcoZMqt1}8!dtvRp4gEbB=)nPVCT89v<6Bg zZj{>qXMuOSoYTA$pp;F3EzVQ>^G_cOr1iWv1yoJhF06Z-QaW3zYs6ac#&ZR=v{=lQ z)go7OUWlLA8SRBfoZH6{;z5p>E$V5tRMMNLNU#EY{TG>2fnr@G0!zjvd-sbh)CMk0 zo!VK072{I0i#eCl_08Jp>d_tnVQ#v@3i42{Cw3yRr0h4zI8N-YToCcyGZ(Jg92kb- z>|Kn#%ii7XyZA9XO!r_tOb^x%HyFAPV?Sf>u>WQM$^L=8%9hz#x({mT-*)420-}F; z$h_#~Fq)IyF0CPvaHG$+i7i|#f=WDBDs!Ia+tm1AN#u1!H8fLmoQErbyb1-J0IGXJ zSJvSP9!}9y+~|3(qJknf%7-Mshs*1Qau(XnM3Xa-*c>tfm6=SUzU*&WJO{LG7>@UO zIJF3@WXrj{>P=^hdO`P2mh@QB05C!{#;r8sEUM}zj6T0GJsw_e246PM_lHCer>S78 z{Vc$; z=ELods*}_+pjdIw>Sgp+??EL5TBx3mMdlX5bJlg*Ss9310~TcWKvw%lg-&mg$^fnO zRj7>puo5Mc)x)ETsO56Sy_hShoumvtB+6Y;@lwO&(MW}p3v(T^GLRD5VLhU(1pmQM z8EU7j7D1(;y65zJS-}U`&+a!%E>PF?Y#kkFFVd~7xuOWdbiNyc7cq3*=?56myY z>euBN8V4v@e&Jx+x<^{^?Q~AlRQGHae&n`Lg*Q4%e5hH#p~4ca3f#~a4;9reFo^ge zDpqo0VXi4J1O0f^3pyWw;aa#J@ge%<>dH!$qX}&CLBFTQ7FXr$U5t7GV&@#alpY>*~sjQpH@ zoy?IO@i*cnB0K(=Cz#vLmTK~dJ+-1{VEZ>G~0ibUx|U{6`HBdayi z9H%T-8$noebL-g{_0?ev7>7b;OVj4qx>jeLrQc4F-EM|*Iq4?QIDEv)qT^yGhmXEw zBL?fBUn3~IcYq>3!YGP-pL~&ABELy|1f}r-VaQA$hQogb>4F4dqlyyTu$f~NjhmlX zM_3bc{Zkn>vu⪻Dcx{`y3i`q~%~u%yqkLw>%AWsL6QsU9`FSKQykLu{^AaxxOM( zmMikCQ#F%bdJ0)Ay=^&I6Lb9?ncU-PQglh*f}1B@H_$lzJkKxzYtY{#?KUqWm4p3B=f&U!8 zE`I|544|ki|7Kl%9|1NN2{vX^#>p4hMc7zmSeb3X%*hQbENm>|EX>A?lOHk*v$04s zGh2h0;*u<4Ow5LiPL3hY9`RoOPVt_8!6A-*&aNz*99RT^mgF+<-{IfRKZ!qgv*3bQ z{>{1Z(}BX=$_#ubcqj5iaVu|D6cFZSZZcun99v_?xH+a~DKj_!9|lJL9}N6I_%a=;`v r9bj=_V`Tls!1@d5k`Jugf3Y%haj`M7u`#f*0Y(0>Zf6r?{KW|X$tzkF diff --git a/spring-batch/src/main/java/com/baeldung/batchscheduler/SpringBatchScheduler.java b/spring-batch/src/main/java/com/baeldung/batchscheduler/SpringBatchScheduler.java index 4de3e0a4b6..cff4e96c89 100644 --- a/spring-batch/src/main/java/com/baeldung/batchscheduler/SpringBatchScheduler.java +++ b/spring-batch/src/main/java/com/baeldung/batchscheduler/SpringBatchScheduler.java @@ -1,12 +1,5 @@ package com.baeldung.batchscheduler; -import java.util.Date; -import java.util.IdentityHashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; import com.baeldung.batchscheduler.model.Book; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,7 +13,7 @@ import org.springframework.batch.core.configuration.annotation.StepBuilderFactor import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.launch.support.SimpleJobLauncher; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; +import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean; import org.springframework.batch.item.ItemWriter; import org.springframework.batch.item.file.FlatFileItemReader; import org.springframework.batch.item.file.builder.FlatFileItemReaderBuilder; @@ -30,12 +23,22 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.io.ClassPathResource; +import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.scheduling.TaskScheduler; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.scheduling.support.ScheduledMethodRunnable; +import javax.sql.DataSource; +import java.util.Date; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + @Configuration @EnableBatchProcessing @EnableScheduling @@ -122,9 +125,18 @@ public class SpringBatchScheduler { @Bean public JobRepository jobRepository() throws Exception { - MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); + JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean(); + factory.setDataSource(dataSource()); factory.setTransactionManager(new ResourcelessTransactionManager()); - return (JobRepository) factory.getObject(); + return factory.getObject(); + } + + @Bean + public DataSource dataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("org.sqlite.JDBC"); + dataSource.setUrl("jdbc:sqlite:repository.sqlite"); + return dataSource; } @Bean diff --git a/spring-batch/src/main/java/com/baeldung/taskletsvschunks/config/ChunksConfig.java b/spring-batch/src/main/java/com/baeldung/taskletsvschunks/config/ChunksConfig.java index 57288fb312..c8b05848f9 100644 --- a/spring-batch/src/main/java/com/baeldung/taskletsvschunks/config/ChunksConfig.java +++ b/spring-batch/src/main/java/com/baeldung/taskletsvschunks/config/ChunksConfig.java @@ -12,7 +12,7 @@ import org.springframework.batch.core.configuration.annotation.StepBuilderFactor import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.launch.support.SimpleJobLauncher; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; +import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean; import org.springframework.batch.item.ItemProcessor; import org.springframework.batch.item.ItemReader; import org.springframework.batch.item.ItemWriter; @@ -21,8 +21,11 @@ import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.transaction.PlatformTransactionManager; +import javax.sql.DataSource; + @Configuration @EnableBatchProcessing public class ChunksConfig { @@ -38,9 +41,18 @@ public class ChunksConfig { @Bean public JobRepository jobRepository() throws Exception { - MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); + JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean(); + factory.setDataSource(dataSource()); factory.setTransactionManager(transactionManager()); - return (JobRepository) factory.getObject(); + return factory.getObject(); + } + + @Bean + public DataSource dataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("org.sqlite.JDBC"); + dataSource.setUrl("jdbc:sqlite:repository.sqlite"); + return dataSource; } @Bean diff --git a/spring-batch/src/main/java/com/baeldung/taskletsvschunks/config/TaskletsConfig.java b/spring-batch/src/main/java/com/baeldung/taskletsvschunks/config/TaskletsConfig.java index e7157ac520..5f2f49928c 100644 --- a/spring-batch/src/main/java/com/baeldung/taskletsvschunks/config/TaskletsConfig.java +++ b/spring-batch/src/main/java/com/baeldung/taskletsvschunks/config/TaskletsConfig.java @@ -11,14 +11,17 @@ import org.springframework.batch.core.configuration.annotation.StepBuilderFactor import org.springframework.batch.core.launch.JobLauncher; import org.springframework.batch.core.launch.support.SimpleJobLauncher; import org.springframework.batch.core.repository.JobRepository; -import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean; +import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean; import org.springframework.batch.support.transaction.ResourcelessTransactionManager; import org.springframework.batch.test.JobLauncherTestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.transaction.PlatformTransactionManager; +import javax.sql.DataSource; + @Configuration @EnableBatchProcessing public class TaskletsConfig { @@ -34,9 +37,18 @@ public class TaskletsConfig { @Bean public JobRepository jobRepository() throws Exception { - MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); + JobRepositoryFactoryBean factory = new JobRepositoryFactoryBean(); + factory.setDataSource(dataSource()); factory.setTransactionManager(transactionManager()); - return (JobRepository) factory.getObject(); + return factory.getObject(); + } + + @Bean + public DataSource dataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("org.sqlite.JDBC"); + dataSource.setUrl("jdbc:sqlite:repository.sqlite"); + return dataSource; } @Bean From df7af0d0ecde427e161d72aa4b089ea4298b83d2 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 20 Dec 2020 23:02:10 +0530 Subject: [PATCH 107/361] 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 108/361] 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 a07e23dddd90d529a0719f24c6f6217694834c15 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Mon, 21 Dec 2020 02:06:26 +0530 Subject: [PATCH 109/361] BAEL-4686: fixed review comments --- .../NullAllowInMapUnitTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapUnitTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapUnitTest.java index c5fc57d8ce..594e8ec3b4 100644 --- a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapUnitTest.java +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/concurrenthashmap/NullAllowInMapUnitTest.java @@ -13,7 +13,7 @@ import org.junit.Test; public class NullAllowInMapUnitTest { @Test - public void allowNullKey_In_HashMapBackedSynchronizedMap() { + public void givenHashMapBackedSynchronizedMap_whenNullAsKey_thenNoError() { Map map = Collections .synchronizedMap(new HashMap()); map.put(null, 1); @@ -22,14 +22,14 @@ public class NullAllowInMapUnitTest { @Test(expected = NullPointerException.class) - public void allowNullKey_In_TreeMapBackedSynchronizedMap() { + public void givenTreeMapBackedSynchronizedMap_whenNullAsKey_thenException() { Map map = Collections.synchronizedMap(new TreeMap()); map.put(null, 1); Assert.assertTrue(map.get(null).equals(1)); } @Test - public void allowNullKey_In_LinkedHashMapBackedSynchronizedMap() { + public void givenLinkedHashMapBackedSynchronizedMap_whenNullAsKey_thenNoError() { Map map = Collections .synchronizedMap(new LinkedHashMap()); map.put(null, 1); @@ -37,27 +37,27 @@ public class NullAllowInMapUnitTest { } @Test(expected = NullPointerException.class) - public void allowNullKey_In_ConcurrentHasMap() { + public void givenConcurrentHasMap_whenNullAsKey_thenException() { Map map = new ConcurrentHashMap<>(); map.put(null, 1); } @Test - public void allowNullValue_In_HashMapBackedSynchronizedMap() { + public void givenHashMapBackedSynchronizedMap_whenNullAsValue_thenNoError() { Map map = Collections.synchronizedMap(new HashMap()); map.put("1", null); Assert.assertNull(map.get("1")); } @Test - public void allowNullValue_In_TreeMapBackedSynchronizedMap() { + public void givenTreeMapBackedSynchronizedMap_whenNullAsValue_thenNoError() { Map map = Collections.synchronizedMap(new TreeMap()); map.put("1", null); Assert.assertNull(map.get("1")); } @Test - public void allowNullValue_In_LinkedHashSynchronizedMap() { + public void givenLinkedHashMapBackedSynchronizedMap_whenNullAsValue_thenNoError() { Map map = Collections .synchronizedMap(new LinkedHashMap()); map.put("1", null); @@ -65,7 +65,7 @@ public class NullAllowInMapUnitTest { } @Test(expected = NullPointerException.class) - public void allowNullValue_In_ConcurrentHasMap() { + public void givenConcurrentHasMap_whenNullAsValue_thenException() { Map map = new ConcurrentHashMap<>(); map.put("1", null); } From 3ef0ac42572f64ce9f99c112a43bcc350803ab97 Mon Sep 17 00:00:00 2001 From: Gilvan Ornelas Fernandes Filho Date: Sun, 20 Dec 2020 21:29:30 -0300 Subject: [PATCH 110/361] Clean architecture initial commit --- patterns/clean-architecture/pom.xml | 87 +++++++++++++++++++ .../CleanArchitectureApplication.java | 40 +++++++++ .../usercreation/CommonUser.java | 30 +++++++ .../usercreation/CommonUserFactory.java | 8 ++ .../usercreation/JpaUser.java | 21 +++++ .../usercreation/JpaUserRepository.java | 8 ++ .../cleanarchitecture/usercreation/User.java | 9 ++ .../usercreation/UserDataMapper.java | 53 +++++++++++ .../usercreation/UserDsRequestModel.java | 41 +++++++++ .../usercreation/UserFactory.java | 5 ++ .../usercreation/UserInputBoundary.java | 5 ++ .../usercreation/UserPresenter.java | 7 ++ .../usercreation/UserRegisterController.java | 20 +++++ .../usercreation/UserRegisterDsGateway.java | 7 ++ .../usercreation/UserRegisterInteractor.java | 35 ++++++++ .../usercreation/UserRequestModel.java | 33 +++++++ .../usercreation/UserResponseFormatter.java | 22 +++++ .../usercreation/UserResponseModel.java | 29 +++++++ .../src/main/resources/application.properties | 2 + .../UserResponseFormatterTests.java | 29 +++++++ .../usercreation/UserUnitTest.java | 15 ++++ 21 files changed, 506 insertions(+) create mode 100644 patterns/clean-architecture/pom.xml create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/CleanArchitectureApplication.java create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/CommonUser.java create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/CommonUserFactory.java create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/JpaUser.java create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/JpaUserRepository.java create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/User.java create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserDataMapper.java create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserDsRequestModel.java create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserFactory.java create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserInputBoundary.java create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserPresenter.java create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserRegisterController.java create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserRegisterDsGateway.java create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserRegisterInteractor.java create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserRequestModel.java create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseFormatter.java create mode 100644 patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseModel.java create mode 100644 patterns/clean-architecture/src/main/resources/application.properties create mode 100644 patterns/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseFormatterTests.java create mode 100644 patterns/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserUnitTest.java diff --git a/patterns/clean-architecture/pom.xml b/patterns/clean-architecture/pom.xml new file mode 100644 index 0000000000..6e7de78751 --- /dev/null +++ b/patterns/clean-architecture/pom.xml @@ -0,0 +1,87 @@ + + + 4.0.0 + clean-architecture + 1.0 + clean-architecture + Project for clean architecture in java + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + + 1.8 + + + + + com.h2database + h2 + runtime + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + org.mockito + mockito-core + test + + + org.junit.platform + junit-platform-engine + + + org.junit.jupiter + junit-jupiter-engine + + + org.junit.jupiter + junit-jupiter-api + + + org.junit.platform + junit-platform-runner + test + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/CleanArchitectureApplication.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/CleanArchitectureApplication.java new file mode 100644 index 0000000000..ebac2bacf3 --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/CleanArchitectureApplication.java @@ -0,0 +1,40 @@ +package com.baeldung.pattern.cleanarchitecture; + +import org.springframework.beans.factory.config.BeanFactoryPostProcessor; +import org.springframework.beans.factory.support.BeanDefinitionRegistry; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ClassPathBeanDefinitionScanner; +import org.springframework.core.type.classreading.MetadataReader; +import org.springframework.core.type.classreading.MetadataReaderFactory; +import org.springframework.core.type.filter.TypeFilter; + +@SpringBootApplication +public class CleanArchitectureApplication { + + public static void main(String[] args) { + SpringApplication.run(CleanArchitectureApplication.class); + } + + @Bean + BeanFactoryPostProcessor beanFactoryPostProcessor(ApplicationContext beanRegistry) { + return beanFactory -> { + genericApplicationContext((BeanDefinitionRegistry) ((AnnotationConfigServletWebServerApplicationContext) beanRegistry).getBeanFactory()); + }; + } + + void genericApplicationContext(BeanDefinitionRegistry beanRegistry) { + ClassPathBeanDefinitionScanner beanDefinitionScanner = new ClassPathBeanDefinitionScanner(beanRegistry); + beanDefinitionScanner.addIncludeFilter(removeModelAndEntitiesFilter()); + beanDefinitionScanner.scan("com.baeldung.pattern.cleanarchitecture"); + } + + static TypeFilter removeModelAndEntitiesFilter() { + return (MetadataReader mr, MetadataReaderFactory mrf) -> !mr.getClassMetadata() + .getClassName() + .endsWith("Model"); + } +} diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/CommonUser.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/CommonUser.java new file mode 100644 index 0000000000..f7ba9dacc0 --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/CommonUser.java @@ -0,0 +1,30 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +class CommonUser implements User { + + String name; + String password; + + CommonUser(String name, String password) { + this.name = name; + this.password = password; + } + + CommonUser() { + } + + @Override + public boolean passwordIsValid() { + return password == null || password.length() > 5; + } + + @Override + public String getName() { + return name; + } + + @Override + public String getPassword() { + return password; + } +} diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/CommonUserFactory.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/CommonUserFactory.java new file mode 100644 index 0000000000..a2b851da94 --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/CommonUserFactory.java @@ -0,0 +1,8 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +class CommonUserFactory implements UserFactory { + @Override + public User create(String name, String password) { + return new CommonUser(name, password); + } +} diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/JpaUser.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/JpaUser.java new file mode 100644 index 0000000000..20751f282a --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/JpaUser.java @@ -0,0 +1,21 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +class JpaUser implements UserRegisterDsGateway { + + final JpaUserRepository repository; + + JpaUser(JpaUserRepository repository) { + this.repository = repository; + } + + @Override + public boolean existsByName(String name) { + return repository.existsById(name); + } + + @Override + public void save(UserDsRequestModel requestModel) { + UserDataMapper accountDataMapper = new UserDataMapper(requestModel.getName(), requestModel.getPassword(), requestModel.getCreationTime()); + repository.save(accountDataMapper); + } +} diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/JpaUserRepository.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/JpaUserRepository.java new file mode 100644 index 0000000000..8565ed7965 --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/JpaUserRepository.java @@ -0,0 +1,8 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +interface JpaUserRepository extends JpaRepository { +} diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/User.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/User.java new file mode 100644 index 0000000000..aab652f2a1 --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/User.java @@ -0,0 +1,9 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +interface User { + boolean passwordIsValid(); + + String getName(); + + String getPassword(); +} diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserDataMapper.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserDataMapper.java new file mode 100644 index 0000000000..44112de8a9 --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserDataMapper.java @@ -0,0 +1,53 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +import java.time.LocalDateTime; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "user") +class UserDataMapper { + + @Id + String name; + + String password; + + LocalDateTime creationTime; + + public UserDataMapper() { + } + + public UserDataMapper(String name, String password, LocalDateTime creationTime) { + super(); + this.name = name; + this.password = password; + this.creationTime = creationTime; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public LocalDateTime getCreationTime() { + return creationTime; + } + + public void setCreationTime(LocalDateTime creationTime) { + this.creationTime = creationTime; + } +} diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserDsRequestModel.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserDsRequestModel.java new file mode 100644 index 0000000000..aa0f0b56d1 --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserDsRequestModel.java @@ -0,0 +1,41 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +import java.time.LocalDateTime; + +class UserDsRequestModel { + + String name; + String password; + LocalDateTime creationTime; + + public UserDsRequestModel(String name, String password, LocalDateTime creationTime) { + this.name = name; + this.password = password; + this.creationTime = creationTime; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public LocalDateTime getCreationTime() { + return creationTime; + } + + public void setCreationTime(LocalDateTime creationTime) { + this.creationTime = creationTime; + } + +} diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserFactory.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserFactory.java new file mode 100644 index 0000000000..1ff29709be --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserFactory.java @@ -0,0 +1,5 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +interface UserFactory { + User create(String name, String password); +} diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserInputBoundary.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserInputBoundary.java new file mode 100644 index 0000000000..e72c30f13c --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserInputBoundary.java @@ -0,0 +1,5 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +public interface UserInputBoundary { + UserResponseModel create(UserRequestModel requestModel); +} diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserPresenter.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserPresenter.java new file mode 100644 index 0000000000..45d202643e --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserPresenter.java @@ -0,0 +1,7 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +interface UserPresenter { + UserResponseModel prepareSuccessView(UserResponseModel user); + + UserResponseModel prepareFailView(String error); +} diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserRegisterController.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserRegisterController.java new file mode 100644 index 0000000000..039dc12910 --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserRegisterController.java @@ -0,0 +1,20 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +class UserRegisterController { + + final UserInputBoundary userInput; + + UserRegisterController(UserInputBoundary accountGateway) { + this.userInput = accountGateway; + } + + @PostMapping("/user") + UserResponseModel create(@RequestBody UserRequestModel requestModel) { + return userInput.create(requestModel); + } +} diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserRegisterDsGateway.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserRegisterDsGateway.java new file mode 100644 index 0000000000..89c1b7e774 --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserRegisterDsGateway.java @@ -0,0 +1,7 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +interface UserRegisterDsGateway { + boolean existsByName(String identifier); + + void save(UserDsRequestModel requestModel); +} diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserRegisterInteractor.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserRegisterInteractor.java new file mode 100644 index 0000000000..5137593dc3 --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserRegisterInteractor.java @@ -0,0 +1,35 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +import java.time.LocalDateTime; + +class UserRegisterInteractor implements UserInputBoundary { + + final UserRegisterDsGateway userDsGateway; + final UserPresenter userPresenter; + final UserFactory userFactory; + + UserRegisterInteractor(UserRegisterDsGateway userRegisterDfGateway, UserPresenter userPresenter, + UserFactory userFactory) { + this.userDsGateway = userRegisterDfGateway; + this.userPresenter = userPresenter; + this.userFactory = userFactory; + } + + @Override + public UserResponseModel create(UserRequestModel requestModel) { + if (userDsGateway.existsByName(requestModel.getName())) { + return userPresenter.prepareFailView("User already exists."); + } + User user = userFactory.create(requestModel.getName(), requestModel.getPassword()); + if (!user.passwordIsValid()) { + return userPresenter.prepareFailView("User password must have more than 5 characters."); + } + LocalDateTime now = LocalDateTime.now(); + UserDsRequestModel userDsModel = new UserDsRequestModel(user.getName(), user.getPassword(), now); + + userDsGateway.save(userDsModel); + + UserResponseModel accountResponseModel = new UserResponseModel(user.getName(), now.toString()); + return userPresenter.prepareSuccessView(accountResponseModel); + } +} \ No newline at end of file diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserRequestModel.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserRequestModel.java new file mode 100644 index 0000000000..8317665c31 --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserRequestModel.java @@ -0,0 +1,33 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +class UserRequestModel { + + String name; + String password; + + public UserRequestModel() { + super(); + } + + UserRequestModel(String name, String password) { + super(); + this.name = name; + this.password = password; + } + + String getName() { + return name; + } + + void setName(String name) { + this.name = name; + } + + String getPassword() { + return password; + } + + void setPassword(String password) { + this.password = password; + } +} diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseFormatter.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseFormatter.java new file mode 100644 index 0000000000..4842d44e22 --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseFormatter.java @@ -0,0 +1,22 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +import org.springframework.http.HttpStatus; +import org.springframework.web.server.ResponseStatusException; + +class UserResponseFormatter implements UserPresenter { + + @Override + public UserResponseModel prepareSuccessView(UserResponseModel response) { + LocalDateTime responseTime = LocalDateTime.parse(response.getCreationTime()); + response.setCreationTime(responseTime.format(DateTimeFormatter.ofPattern("hh:mm:ss"))); + return response; + } + + @Override + public UserResponseModel prepareFailView(String error) { + throw new ResponseStatusException(HttpStatus.CONFLICT, error); + } +} diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseModel.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseModel.java new file mode 100644 index 0000000000..73a3d8fb10 --- /dev/null +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseModel.java @@ -0,0 +1,29 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +public class UserResponseModel { + + String login; + String creationTime; + + public UserResponseModel(String login, String creationTime) { + this.login = login; + this.creationTime = creationTime; + } + + public String getLogin() { + return login; + } + + public void setLogin(String login) { + this.login = login; + } + + public String getCreationTime() { + return creationTime; + } + + public void setCreationTime(String creationTime) { + this.creationTime = creationTime; + } + +} diff --git a/patterns/clean-architecture/src/main/resources/application.properties b/patterns/clean-architecture/src/main/resources/application.properties new file mode 100644 index 0000000000..a5a02bb49d --- /dev/null +++ b/patterns/clean-architecture/src/main/resources/application.properties @@ -0,0 +1,2 @@ +server.port=8080 +server.error.include-message=always \ No newline at end of file diff --git a/patterns/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseFormatterTests.java b/patterns/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseFormatterTests.java new file mode 100644 index 0000000000..f8ebde5f10 --- /dev/null +++ b/patterns/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseFormatterTests.java @@ -0,0 +1,29 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import org.junit.jupiter.api.Test; +import org.springframework.web.server.ResponseStatusException; + +import com.baeldung.pattern.cleanarchitecture.usercreation.UserResponseFormatter; +import com.baeldung.pattern.cleanarchitecture.usercreation.UserResponseModel; + +class UserResponseFormatterTests { + + UserResponseFormatter userResponseFormatter = new UserResponseFormatter(); + + @Test + void givenDateAnd3HourTime_whenPrepareSuccessView_thenReturnOnly3HourTime() { + UserResponseModel modelResponse = new UserResponseModel("baeldung", "2020-12-20T03:00:00.000"); + UserResponseModel formattedResponse = userResponseFormatter.prepareSuccessView(modelResponse); + + assertThat(formattedResponse.getCreationTime()).isEqualTo("03:00:00"); + } + + @Test + void whenPrepareFailView_thenThrowHttpConflictException() { + assertThatThrownBy(() -> userResponseFormatter.prepareFailView("Invalid password")) + .isInstanceOf(ResponseStatusException.class); + } +} diff --git a/patterns/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserUnitTest.java b/patterns/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserUnitTest.java new file mode 100644 index 0000000000..505ea47e3f --- /dev/null +++ b/patterns/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserUnitTest.java @@ -0,0 +1,15 @@ +package com.baeldung.pattern.cleanarchitecture.usercreation; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; + +class UserUnitTest { + + @Test + void given123Password_whenPasswordIsNotValid_thenIsFalse() { + User user = new CommonUser("Baeldung", "123"); + + assertThat(user.passwordIsValid()).isFalse(); + } +} From b18f0e7980d02fdfea4af9be2f5f36221ce38917 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Mon, 21 Dec 2020 10:49:28 +0200 Subject: [PATCH 111/361] Update README.md --- spring-5/README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/spring-5/README.md b/spring-5/README.md index d50f9c7544..cef0fedb4f 100644 --- a/spring-5/README.md +++ b/spring-5/README.md @@ -2,9 +2,6 @@ This module contains articles about Spring 5 -### The Course -The "REST With Spring" Classes: http://bit.ly/restwithspring - ### Relevant Articles - [Concurrent Test Execution in Spring 5](https://www.baeldung.com/spring-5-concurrent-tests) From 9264d091b09eda29f77825ea34aa62ddbf7f78c8 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 21 Dec 2020 13:41:50 +0100 Subject: [PATCH 112/361] JAVA-3570: Ignore one of the FunctionalWebApplicationIntegrationTest --- .../functional/FunctionalWebApplicationIntegrationTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-5-reactive/src/test/java/com/baeldung/functional/FunctionalWebApplicationIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/functional/FunctionalWebApplicationIntegrationTest.java index 1256d5f129..38496d3500 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/functional/FunctionalWebApplicationIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/functional/FunctionalWebApplicationIntegrationTest.java @@ -5,6 +5,7 @@ import static org.springframework.web.reactive.function.BodyInserters.fromResour import org.junit.AfterClass; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; import org.springframework.boot.web.server.WebServer; import org.springframework.core.io.ClassPathResource; @@ -102,6 +103,7 @@ public class FunctionalWebApplicationIntegrationTest { .isEqualTo(String.valueOf(resource.contentLength())); } + @Ignore("We get 404 after Spring Boot 2.4 upgrade. We need to solve it in a new task.") @Test public void givenActors_whenAddActor_thenAdded() throws Exception { client.get() From dcd9eaf33a47d8e73d294aa7befcb6c455200db4 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 21 Dec 2020 19:52:50 +0530 Subject: [PATCH 113/361] 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 114/361] 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 115/361] 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 116/361] 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 From 8bf0f8a0a3fc37861914ce4f0a616b55b9b0045a Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 22 Dec 2020 16:24:43 +0530 Subject: [PATCH 117/361] JAVA-3519: Moved spring-mvc-basics-2 inside spring-web-modules --- .../spring-mvc-basics-2}/README.md | 0 .../spring-mvc-basics-2}/pom.xml | 2 +- .../configuration/ApplicationConfiguration.java | 0 .../spring/configuration/EmailConfiguration.java | 0 .../configuration/FreemarkerConfiguration.java | 0 .../spring/configuration/GroovyConfiguration.java | 0 .../configuration/JadeTemplateConfiguration.java | 0 .../spring/configuration/PushConfiguration.java | 0 .../configuration/ThymeleafConfiguration.java | 0 .../spring/configuration/WebInitializer.java | 0 .../AnnotationMethodHandlerAdapterExample.java | 0 .../spring/controller/CustomerController.java | 0 .../spring/controller/EmployeeController.java | 0 .../spring/controller/FileUploadController.java | 0 .../baeldung/spring/controller/MailController.java | 0 .../RequestMappingHandlerAdapterExample.java | 0 .../spring/controller/RequestMethodController.java | 0 .../SimpleControllerHandlerAdapterExample.java | 0 .../baeldung/spring/controller/UserController.java | 0 .../com/baeldung/spring/controller/rss/Article.java | 0 .../spring/controller/rss/ArticleFeedView.java | 0 .../spring/controller/rss/ArticleRssController.java | 0 .../controller/rss/ArticleRssFeedViewResolver.java | 0 .../rss/JsonChannelHttpMessageConverter.java | 0 .../spring/controller/scribe/GithubController.java | 0 .../spring/controller/scribe/TwitterController.java | 0 .../java/com/baeldung/spring/domain/Customer.java | 0 .../java/com/baeldung/spring/domain/Employee.java | 0 .../java/com/baeldung/spring/domain/MailObject.java | 0 .../main/java/com/baeldung/spring/domain/User.java | 0 .../spring/exception/InvalidRequestException.java | 0 .../interceptor/FileUploadExceptionAdvice.java | 0 .../java/com/baeldung/spring/mail/EmailService.java | 0 .../com/baeldung/spring/mail/EmailServiceImpl.java | 0 .../spring/push/controller/PushController.java | 0 .../spring/requestparam/RequestParamController.java | 0 .../baeldung/spring/service/EmployeeService.java | 0 .../spring/service/EmployeeServiceImpl.java | 0 .../baeldung/spring/servlets/ForwardedServlet.java | 0 .../com/baeldung/spring/servlets/HelloServlet.java | 0 .../baeldung/spring/servlets/RedirectedServlet.java | 0 .../baeldung/spring/servlets/WelcomeServlet.java | 0 .../spring/validator/CustomerValidator.java | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/logback.xml | 0 .../src/main/resources/mail-logo.png | Bin .../mail-templates/template-freemarker.ftl | 0 .../mail-templates/template-thymeleaf.html | 0 .../src/main/resources/mailMessages.properties | 0 .../main/resources/mailMessages_fr_FR.properties | 0 .../src/main/webapp/WEB-INF/Greeting.jsp | 0 .../src/main/webapp/WEB-INF/views/Greeting.jsp | 0 .../src/main/webapp/WEB-INF/views/customerHome.jsp | 0 .../src/main/webapp/WEB-INF/views/customerView.jsp | 0 .../src/main/webapp/WEB-INF/views/demo.jsp | 0 .../src/main/webapp/WEB-INF/views/emails.jsp | 0 .../src/main/webapp/WEB-INF/views/employeeHome.jsp | 0 .../src/main/webapp/WEB-INF/views/employeeView.jsp | 0 .../src/main/webapp/WEB-INF/views/error.jsp | 0 .../src/main/webapp/WEB-INF/views/file.jsp | 0 .../src/main/webapp/WEB-INF/views/mail/send.jsp | 0 .../src/main/webapp/WEB-INF/views/mail/sendHtml.jsp | 0 .../src/main/webapp/WEB-INF/views/pages/home.jsp | 0 .../main/webapp/WEB-INF/views/pages/springmvc.jsp | 0 .../WEB-INF/views/registration-freemarker.ftl | 0 .../webapp/WEB-INF/views/registration-groovy.tpl | 0 .../webapp/WEB-INF/views/registration-jade.jade | 0 .../WEB-INF/views/registration-thymeleaf.html | 0 .../src/main/webapp/WEB-INF/views/registration.jsp | 0 .../src/main/webapp/resources/logo.png | Bin .../src/main/webapp/static/css/app.css | 0 .../test/java/com/baeldung/SpringContextTest.java | 0 .../push/PushControllerIntegrationTest.java | 0 .../controller/rss/ArticleRssIntegrationTest.java | 0 .../servlets/HelloServletIntegrationTest.java | 0 .../servlets/WelcomeServletIntegrationTest.java | 0 76 files changed, 1 insertion(+), 1 deletion(-) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/README.md (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/pom.xml (99%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/configuration/ApplicationConfiguration.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/configuration/EmailConfiguration.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/configuration/FreemarkerConfiguration.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/configuration/GroovyConfiguration.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/configuration/JadeTemplateConfiguration.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/configuration/PushConfiguration.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/configuration/ThymeleafConfiguration.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/configuration/WebInitializer.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/controller/AnnotationMethodHandlerAdapterExample.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/controller/CustomerController.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/controller/EmployeeController.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/controller/FileUploadController.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/controller/MailController.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/controller/RequestMappingHandlerAdapterExample.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/controller/RequestMethodController.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/controller/SimpleControllerHandlerAdapterExample.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/controller/UserController.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/controller/rss/Article.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/controller/rss/ArticleFeedView.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/controller/rss/ArticleRssController.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/controller/rss/ArticleRssFeedViewResolver.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/controller/rss/JsonChannelHttpMessageConverter.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/controller/scribe/GithubController.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/controller/scribe/TwitterController.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/domain/Customer.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/domain/Employee.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/domain/MailObject.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/domain/User.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/exception/InvalidRequestException.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/interceptor/FileUploadExceptionAdvice.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/mail/EmailService.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/push/controller/PushController.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/requestparam/RequestParamController.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/service/EmployeeService.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/service/EmployeeServiceImpl.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/servlets/ForwardedServlet.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/servlets/HelloServlet.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/servlets/RedirectedServlet.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/servlets/WelcomeServlet.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/java/com/baeldung/spring/validator/CustomerValidator.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/resources/application.properties (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/resources/logback.xml (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/resources/mail-logo.png (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/resources/mail-templates/template-freemarker.ftl (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/resources/mail-templates/template-thymeleaf.html (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/resources/mailMessages.properties (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/resources/mailMessages_fr_FR.properties (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/Greeting.jsp (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/Greeting.jsp (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/customerHome.jsp (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/customerView.jsp (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/demo.jsp (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/emails.jsp (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/employeeHome.jsp (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/employeeView.jsp (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/error.jsp (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/file.jsp (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/mail/send.jsp (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/mail/sendHtml.jsp (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/pages/home.jsp (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/pages/springmvc.jsp (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/registration-freemarker.ftl (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/registration-groovy.tpl (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/registration-jade.jade (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/registration-thymeleaf.html (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/WEB-INF/views/registration.jsp (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/resources/logo.png (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/main/webapp/static/css/app.css (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/test/java/com/baeldung/SpringContextTest.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/test/java/com/baeldung/controller/push/PushControllerIntegrationTest.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/test/java/com/baeldung/controller/rss/ArticleRssIntegrationTest.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/test/java/com/baeldung/spring/servlets/HelloServletIntegrationTest.java (100%) rename {spring-mvc-basics-2 => spring-web-modules/spring-mvc-basics-2}/src/test/java/com/baeldung/spring/servlets/WelcomeServletIntegrationTest.java (100%) diff --git a/spring-mvc-basics-2/README.md b/spring-web-modules/spring-mvc-basics-2/README.md similarity index 100% rename from spring-mvc-basics-2/README.md rename to spring-web-modules/spring-mvc-basics-2/README.md diff --git a/spring-mvc-basics-2/pom.xml b/spring-web-modules/spring-mvc-basics-2/pom.xml similarity index 99% rename from spring-mvc-basics-2/pom.xml rename to spring-web-modules/spring-mvc-basics-2/pom.xml index c4688ffad6..e16b54b2c8 100644 --- a/spring-mvc-basics-2/pom.xml +++ b/spring-web-modules/spring-mvc-basics-2/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-spring-5 0.0.1-SNAPSHOT - ../parent-spring-5 + ../../parent-spring-5 diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ApplicationConfiguration.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ApplicationConfiguration.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ApplicationConfiguration.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ApplicationConfiguration.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/EmailConfiguration.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/EmailConfiguration.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/EmailConfiguration.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/EmailConfiguration.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/FreemarkerConfiguration.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/FreemarkerConfiguration.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/FreemarkerConfiguration.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/FreemarkerConfiguration.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/GroovyConfiguration.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/GroovyConfiguration.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/GroovyConfiguration.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/GroovyConfiguration.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/JadeTemplateConfiguration.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/JadeTemplateConfiguration.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/JadeTemplateConfiguration.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/JadeTemplateConfiguration.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/PushConfiguration.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/PushConfiguration.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/PushConfiguration.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/PushConfiguration.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ThymeleafConfiguration.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ThymeleafConfiguration.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ThymeleafConfiguration.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ThymeleafConfiguration.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/WebInitializer.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/WebInitializer.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/WebInitializer.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/WebInitializer.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/AnnotationMethodHandlerAdapterExample.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/AnnotationMethodHandlerAdapterExample.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/AnnotationMethodHandlerAdapterExample.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/AnnotationMethodHandlerAdapterExample.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/CustomerController.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/CustomerController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/CustomerController.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/CustomerController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/EmployeeController.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/EmployeeController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/EmployeeController.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/EmployeeController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/FileUploadController.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/FileUploadController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/FileUploadController.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/FileUploadController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/MailController.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/MailController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/MailController.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/MailController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/RequestMappingHandlerAdapterExample.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/RequestMappingHandlerAdapterExample.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/RequestMappingHandlerAdapterExample.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/RequestMappingHandlerAdapterExample.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/RequestMethodController.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/RequestMethodController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/RequestMethodController.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/RequestMethodController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/SimpleControllerHandlerAdapterExample.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/SimpleControllerHandlerAdapterExample.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/SimpleControllerHandlerAdapterExample.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/SimpleControllerHandlerAdapterExample.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/UserController.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/UserController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/UserController.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/UserController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/Article.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/Article.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/Article.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/Article.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleFeedView.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleFeedView.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleFeedView.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleFeedView.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleRssController.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleRssController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleRssController.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleRssController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleRssFeedViewResolver.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleRssFeedViewResolver.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleRssFeedViewResolver.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/ArticleRssFeedViewResolver.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/JsonChannelHttpMessageConverter.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/JsonChannelHttpMessageConverter.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/JsonChannelHttpMessageConverter.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/rss/JsonChannelHttpMessageConverter.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/scribe/GithubController.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/scribe/GithubController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/scribe/GithubController.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/scribe/GithubController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/scribe/TwitterController.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/scribe/TwitterController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/scribe/TwitterController.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/scribe/TwitterController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/Customer.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/Customer.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/Customer.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/Customer.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/Employee.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/Employee.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/Employee.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/Employee.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/MailObject.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/MailObject.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/MailObject.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/MailObject.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/User.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/User.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/User.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/User.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/exception/InvalidRequestException.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/exception/InvalidRequestException.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/exception/InvalidRequestException.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/exception/InvalidRequestException.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/interceptor/FileUploadExceptionAdvice.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/interceptor/FileUploadExceptionAdvice.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/interceptor/FileUploadExceptionAdvice.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/interceptor/FileUploadExceptionAdvice.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailService.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailService.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailService.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailService.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/push/controller/PushController.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/push/controller/PushController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/push/controller/PushController.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/push/controller/PushController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/requestparam/RequestParamController.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/requestparam/RequestParamController.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/requestparam/RequestParamController.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/requestparam/RequestParamController.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/service/EmployeeService.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/service/EmployeeService.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/service/EmployeeService.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/service/EmployeeService.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/service/EmployeeServiceImpl.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/service/EmployeeServiceImpl.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/service/EmployeeServiceImpl.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/service/EmployeeServiceImpl.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/ForwardedServlet.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/ForwardedServlet.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/ForwardedServlet.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/ForwardedServlet.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/HelloServlet.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/HelloServlet.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/HelloServlet.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/HelloServlet.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/RedirectedServlet.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/RedirectedServlet.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/RedirectedServlet.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/RedirectedServlet.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/WelcomeServlet.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/WelcomeServlet.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/WelcomeServlet.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/servlets/WelcomeServlet.java diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/validator/CustomerValidator.java b/spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/validator/CustomerValidator.java similarity index 100% rename from spring-mvc-basics-2/src/main/java/com/baeldung/spring/validator/CustomerValidator.java rename to spring-web-modules/spring-mvc-basics-2/src/main/java/com/baeldung/spring/validator/CustomerValidator.java diff --git a/spring-mvc-basics-2/src/main/resources/application.properties b/spring-web-modules/spring-mvc-basics-2/src/main/resources/application.properties similarity index 100% rename from spring-mvc-basics-2/src/main/resources/application.properties rename to spring-web-modules/spring-mvc-basics-2/src/main/resources/application.properties diff --git a/spring-mvc-basics-2/src/main/resources/logback.xml b/spring-web-modules/spring-mvc-basics-2/src/main/resources/logback.xml similarity index 100% rename from spring-mvc-basics-2/src/main/resources/logback.xml rename to spring-web-modules/spring-mvc-basics-2/src/main/resources/logback.xml diff --git a/spring-mvc-basics-2/src/main/resources/mail-logo.png b/spring-web-modules/spring-mvc-basics-2/src/main/resources/mail-logo.png similarity index 100% rename from spring-mvc-basics-2/src/main/resources/mail-logo.png rename to spring-web-modules/spring-mvc-basics-2/src/main/resources/mail-logo.png diff --git a/spring-mvc-basics-2/src/main/resources/mail-templates/template-freemarker.ftl b/spring-web-modules/spring-mvc-basics-2/src/main/resources/mail-templates/template-freemarker.ftl similarity index 100% rename from spring-mvc-basics-2/src/main/resources/mail-templates/template-freemarker.ftl rename to spring-web-modules/spring-mvc-basics-2/src/main/resources/mail-templates/template-freemarker.ftl diff --git a/spring-mvc-basics-2/src/main/resources/mail-templates/template-thymeleaf.html b/spring-web-modules/spring-mvc-basics-2/src/main/resources/mail-templates/template-thymeleaf.html similarity index 100% rename from spring-mvc-basics-2/src/main/resources/mail-templates/template-thymeleaf.html rename to spring-web-modules/spring-mvc-basics-2/src/main/resources/mail-templates/template-thymeleaf.html diff --git a/spring-mvc-basics-2/src/main/resources/mailMessages.properties b/spring-web-modules/spring-mvc-basics-2/src/main/resources/mailMessages.properties similarity index 100% rename from spring-mvc-basics-2/src/main/resources/mailMessages.properties rename to spring-web-modules/spring-mvc-basics-2/src/main/resources/mailMessages.properties diff --git a/spring-mvc-basics-2/src/main/resources/mailMessages_fr_FR.properties b/spring-web-modules/spring-mvc-basics-2/src/main/resources/mailMessages_fr_FR.properties similarity index 100% rename from spring-mvc-basics-2/src/main/resources/mailMessages_fr_FR.properties rename to spring-web-modules/spring-mvc-basics-2/src/main/resources/mailMessages_fr_FR.properties diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/Greeting.jsp b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/Greeting.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/Greeting.jsp rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/Greeting.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/Greeting.jsp b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/Greeting.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/Greeting.jsp rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/Greeting.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/customerHome.jsp b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/customerHome.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/customerHome.jsp rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/customerHome.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/customerView.jsp b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/customerView.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/customerView.jsp rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/customerView.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/demo.jsp b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/demo.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/demo.jsp rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/demo.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/emails.jsp b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/emails.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/emails.jsp rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/emails.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/employeeHome.jsp b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/employeeHome.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/employeeHome.jsp rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/employeeHome.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/employeeView.jsp b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/employeeView.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/employeeView.jsp rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/employeeView.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/error.jsp b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/error.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/error.jsp rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/error.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/file.jsp b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/file.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/file.jsp rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/file.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/send.jsp b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/send.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/send.jsp rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/send.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/sendHtml.jsp b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/sendHtml.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/sendHtml.jsp rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/sendHtml.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/pages/home.jsp b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/pages/home.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/pages/home.jsp rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/pages/home.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/pages/springmvc.jsp b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/pages/springmvc.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/pages/springmvc.jsp rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/pages/springmvc.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-freemarker.ftl b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-freemarker.ftl similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-freemarker.ftl rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-freemarker.ftl diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-groovy.tpl b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-groovy.tpl similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-groovy.tpl rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-groovy.tpl diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-jade.jade b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-jade.jade similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-jade.jade rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-jade.jade diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-thymeleaf.html b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-thymeleaf.html similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-thymeleaf.html rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration-thymeleaf.html diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration.jsp b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration.jsp similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration.jsp rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/registration.jsp diff --git a/spring-mvc-basics-2/src/main/webapp/resources/logo.png b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/resources/logo.png similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/resources/logo.png rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/resources/logo.png diff --git a/spring-mvc-basics-2/src/main/webapp/static/css/app.css b/spring-web-modules/spring-mvc-basics-2/src/main/webapp/static/css/app.css similarity index 100% rename from spring-mvc-basics-2/src/main/webapp/static/css/app.css rename to spring-web-modules/spring-mvc-basics-2/src/main/webapp/static/css/app.css diff --git a/spring-mvc-basics-2/src/test/java/com/baeldung/SpringContextTest.java b/spring-web-modules/spring-mvc-basics-2/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-mvc-basics-2/src/test/java/com/baeldung/SpringContextTest.java rename to spring-web-modules/spring-mvc-basics-2/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-mvc-basics-2/src/test/java/com/baeldung/controller/push/PushControllerIntegrationTest.java b/spring-web-modules/spring-mvc-basics-2/src/test/java/com/baeldung/controller/push/PushControllerIntegrationTest.java similarity index 100% rename from spring-mvc-basics-2/src/test/java/com/baeldung/controller/push/PushControllerIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-2/src/test/java/com/baeldung/controller/push/PushControllerIntegrationTest.java diff --git a/spring-mvc-basics-2/src/test/java/com/baeldung/controller/rss/ArticleRssIntegrationTest.java b/spring-web-modules/spring-mvc-basics-2/src/test/java/com/baeldung/controller/rss/ArticleRssIntegrationTest.java similarity index 100% rename from spring-mvc-basics-2/src/test/java/com/baeldung/controller/rss/ArticleRssIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-2/src/test/java/com/baeldung/controller/rss/ArticleRssIntegrationTest.java diff --git a/spring-mvc-basics-2/src/test/java/com/baeldung/spring/servlets/HelloServletIntegrationTest.java b/spring-web-modules/spring-mvc-basics-2/src/test/java/com/baeldung/spring/servlets/HelloServletIntegrationTest.java similarity index 100% rename from spring-mvc-basics-2/src/test/java/com/baeldung/spring/servlets/HelloServletIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-2/src/test/java/com/baeldung/spring/servlets/HelloServletIntegrationTest.java diff --git a/spring-mvc-basics-2/src/test/java/com/baeldung/spring/servlets/WelcomeServletIntegrationTest.java b/spring-web-modules/spring-mvc-basics-2/src/test/java/com/baeldung/spring/servlets/WelcomeServletIntegrationTest.java similarity index 100% rename from spring-mvc-basics-2/src/test/java/com/baeldung/spring/servlets/WelcomeServletIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-2/src/test/java/com/baeldung/spring/servlets/WelcomeServletIntegrationTest.java From f54863d501f991f8f4fc7cb67cdb313652c3c147 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 22 Dec 2020 16:25:19 +0530 Subject: [PATCH 118/361] JAVA-3519: 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 29a90b5bd2..9134906364 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -15,6 +15,7 @@ spring-mvc-basics + spring-mvc-basics-2 From 97a4f763daeea858652909ab178e654e8a693e47 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 22 Dec 2020 16:26:16 +0530 Subject: [PATCH 119/361] JAVA-3519: removed module spring-mvc-basics-2 from main pom --- pom.xml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index f6e3ddad6c..00bc39d49f 100644 --- a/pom.xml +++ b/pom.xml @@ -662,8 +662,7 @@ spring-mobile spring-mockito - - spring-mvc-basics-2 + spring-mvc-basics-3 spring-mvc-basics-4 @@ -1148,8 +1147,7 @@ spring-mobile spring-mockito - - spring-mvc-basics-2 + spring-mvc-basics-3 spring-mvc-basics-4 From e5bb56740559f4a05c365145d36d8f658ee284cc Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Tue, 22 Dec 2020 21:27:18 +0100 Subject: [PATCH 120/361] Rename finalize methods --- .../migration/junit4/BeforeAndAfterAnnotationsUnitTest.java | 4 ++-- .../junit5/BeforeEachAndAfterEachAnnotationsUnitTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/BeforeAndAfterAnnotationsUnitTest.java b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/BeforeAndAfterAnnotationsUnitTest.java index fac07a20ef..6022de123f 100644 --- a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/BeforeAndAfterAnnotationsUnitTest.java +++ b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit4/BeforeAndAfterAnnotationsUnitTest.java @@ -28,8 +28,8 @@ public class BeforeAndAfterAnnotationsUnitTest { } @After - public void finalize() { - LOG.info("finalize"); + public void teardown() { + LOG.info("teardown"); list.clear(); } diff --git a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/BeforeEachAndAfterEachAnnotationsUnitTest.java b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/BeforeEachAndAfterEachAnnotationsUnitTest.java index be916d66ea..f0093b3bf6 100644 --- a/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/BeforeEachAndAfterEachAnnotationsUnitTest.java +++ b/testing-modules/junit-5-basics/src/test/java/com/baeldung/migration/junit5/BeforeEachAndAfterEachAnnotationsUnitTest.java @@ -28,8 +28,8 @@ public class BeforeEachAndAfterEachAnnotationsUnitTest { } @AfterEach - public void finalize() { - LOG.info("finalize"); + public void teardown() { + LOG.info("teardown"); list.clear(); } From 76778779dd6eec6f66ac94520a808b977cfdedcc Mon Sep 17 00:00:00 2001 From: Kai Yuan Date: Wed, 23 Dec 2020 00:04:10 +0100 Subject: [PATCH 121/361] mvn package vs springboot:repackage --- spring-boot-modules/pom.xml | 1 + .../spring-boot-artifacts-2/README.md | 7 +++ .../spring-boot-artifacts-2/pom.xml | 48 +++++++++++++++++++ .../com/baeldung/demo/DemoApplication.java | 11 +++++ .../com/baeldung/demo/DemoRestController.java | 15 ++++++ .../src/main/resources/application.yml | 3 ++ 6 files changed, 85 insertions(+) create mode 100644 spring-boot-modules/spring-boot-artifacts-2/README.md create mode 100644 spring-boot-modules/spring-boot-artifacts-2/pom.xml create mode 100644 spring-boot-modules/spring-boot-artifacts-2/src/main/java/com/baeldung/demo/DemoApplication.java create mode 100644 spring-boot-modules/spring-boot-artifacts-2/src/main/java/com/baeldung/demo/DemoRestController.java create mode 100644 spring-boot-modules/spring-boot-artifacts-2/src/main/resources/application.yml diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 825af8fb9e..c562d522e2 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -24,6 +24,7 @@ spring-boot-angular spring-boot-annotations spring-boot-artifacts + spring-boot-artifacts-2 spring-boot-autoconfiguration spring-boot-basic-customization spring-boot-basic-customization-2 diff --git a/spring-boot-modules/spring-boot-artifacts-2/README.md b/spring-boot-modules/spring-boot-artifacts-2/README.md new file mode 100644 index 0000000000..80e3d95d14 --- /dev/null +++ b/spring-boot-modules/spring-boot-artifacts-2/README.md @@ -0,0 +1,7 @@ +## Spring Boot Artifacts 2 + +This module contains articles about configuring the Spring Boot build process 2. + +### Relevant Articles: + +TBD \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-artifacts-2/pom.xml b/spring-boot-modules/spring-boot-artifacts-2/pom.xml new file mode 100644 index 0000000000..abea13151e --- /dev/null +++ b/spring-boot-modules/spring-boot-artifacts-2/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + + + spring-boot-artifacts-2 + jar + + spring-boot-artifacts-2 + Demo project for Spring Boot + + + + org.springframework.boot + spring-boot-starter-web + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + + + + com.baeldung.demo.DemoApplication + + + diff --git a/spring-boot-modules/spring-boot-artifacts-2/src/main/java/com/baeldung/demo/DemoApplication.java b/spring-boot-modules/spring-boot-artifacts-2/src/main/java/com/baeldung/demo/DemoApplication.java new file mode 100644 index 0000000000..177d3c834e --- /dev/null +++ b/spring-boot-modules/spring-boot-artifacts-2/src/main/java/com/baeldung/demo/DemoApplication.java @@ -0,0 +1,11 @@ +package com.baeldung.demo; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class DemoApplication { + public static void main(String[] args) { + SpringApplication.run(DemoApplication.class, args); + } +} diff --git a/spring-boot-modules/spring-boot-artifacts-2/src/main/java/com/baeldung/demo/DemoRestController.java b/spring-boot-modules/spring-boot-artifacts-2/src/main/java/com/baeldung/demo/DemoRestController.java new file mode 100644 index 0000000000..0869927926 --- /dev/null +++ b/spring-boot-modules/spring-boot-artifacts-2/src/main/java/com/baeldung/demo/DemoRestController.java @@ -0,0 +1,15 @@ +package com.baeldung.demo; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class DemoRestController { + + @GetMapping(value = "/welcome") + public ResponseEntity welcomeEndpoint() { + return ResponseEntity.ok("Welcome to Baeldung Spring Boot Demo!"); + } + +} diff --git a/spring-boot-modules/spring-boot-artifacts-2/src/main/resources/application.yml b/spring-boot-modules/spring-boot-artifacts-2/src/main/resources/application.yml new file mode 100644 index 0000000000..3cd1d2e797 --- /dev/null +++ b/spring-boot-modules/spring-boot-artifacts-2/src/main/resources/application.yml @@ -0,0 +1,3 @@ +spring: + application: + name: Baeldung_SpringBoot_Demo \ No newline at end of file From 981ca0b5068b3b4fdb73af3304fa7c792ad2990e Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Wed, 23 Dec 2020 11:05:24 +0100 Subject: [PATCH 122/361] JAVA-3496: Add integration tests for UserRepository --- .../data/jpa/query/UserApplication.java | 13 ++ .../src/main/resources/insert_users.sql | 8 + .../query/UserRepositoryIntegrationTest.java | 162 ++++++++++++++++++ 3 files changed, 183 insertions(+) create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserApplication.java create mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_users.sql create mode 100644 persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/UserRepositoryIntegrationTest.java diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserApplication.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserApplication.java new file mode 100644 index 0000000000..0f7b19ec47 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.spring.data.jpa.query; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class UserApplication { + + public static void main(String[] args) { + SpringApplication.run(UserApplication.class, args); + } + +} diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_users.sql b/persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_users.sql new file mode 100644 index 0000000000..330b2e36b0 --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/main/resources/insert_users.sql @@ -0,0 +1,8 @@ +insert into Users(id, name, creation_date, last_login_date, active, age, email, status) +values(1, 'John', TO_DATE('01/01/2018', 'DD/MM/YYYY'), TO_DATE('01/01/2020', 'DD/MM/YYYY'), 1, 23, 'john@email.com', 1); + +insert into Users(id, name, creation_date, last_login_date, active, age, email, status) +values(2, 'Bob', TO_DATE('02/02/2019', 'DD/MM/YYYY'), TO_DATE('02/02/2020', 'DD/MM/YYYY'), 1, 56, 'bob@email.com', 1); + +insert into Users(id, name, creation_date, last_login_date, active, age, email, status) +values(3, 'Cindy', TO_DATE('02/02/2019', 'DD/MM/YYYY'), TO_DATE('02/02/2020', 'DD/MM/YYYY'), 1, 18, 'cindy@email.com', 0); \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/UserRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/UserRepositoryIntegrationTest.java new file mode 100644 index 0000000000..0ede418acd --- /dev/null +++ b/persistence-modules/spring-data-jpa-query-2/src/test/java/com/baeldung/spring/data/jpa/query/UserRepositoryIntegrationTest.java @@ -0,0 +1,162 @@ +package com.baeldung.spring.data.jpa.query; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; +import org.springframework.data.jpa.domain.JpaSort; +import org.springframework.data.mapping.PropertyReferenceException; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +@RunWith(SpringRunner.class) +@DataJpaTest(properties = "spring.datasource.data=classpath:insert_users.sql") +public class UserRepositoryIntegrationTest { + + @Autowired + private UserRepository userRepository; + + @Test + public void whenFindAllActiveUsersThenAllActiveFound() { + Collection allActiveUsers = userRepository.findAllActiveUsers(); + assertThat(allActiveUsers).hasSize(2); + } + + @Test + public void whenFindAllActiveUsersNativeThenAllActiveFound() { + Collection allActiveUsers = userRepository.findAllActiveUsersNative(); + assertThat(allActiveUsers).hasSize(2); + } + + @Test + public void whenFindAllSortedByNameThenAllSorted() { + List allUsersSortedByName = userRepository.findAll(Sort.by(Sort.Direction.ASC, "name")); + assertThat(allUsersSortedByName) + .extracting("name") + .containsSequence("Bob", "Cindy", "John"); + } + + @Test + public void whenFindAllSortedByNameLengthThenException() { + assertThatThrownBy(() -> userRepository.findAll(Sort.by("LENGTH(name)"))) + .isInstanceOf(PropertyReferenceException.class); + } + + @Test + public void whenFindAllUsersSortedByNameThenAllSorted() { + List allUsersSortedByName = userRepository.findAllUsers(Sort.by(Sort.Direction.ASC, "name")); + assertThat(allUsersSortedByName) + .extracting("name") + .containsSequence("Bob", "Cindy", "John"); + } + + @Test + public void whenFindAllUsersSortedByNameLengthThenAllSorted() { + List allUsersSortedByName = userRepository.findAllUsers(JpaSort.unsafe("LENGTH(name)")); + assertThat(allUsersSortedByName) + .extracting("name") + .containsSequence("Bob", "John", "Cindy"); + } + + @Test + public void whenFindAllUsersWithPaginationThenPaginated() { + Page page = userRepository.findAllUsersWithPagination(PageRequest.of(0, 1)); + assertThat(page.stream().map(User::getId)) + .hasSize(1) + .containsOnly(1); + } + + @Test + public void whenFindAllUsersWithPaginationNativeThenPaginated() { + Page page = userRepository.findAllUsersWithPaginationNative(PageRequest.of(1, 1)); + assertThat(page.stream().map(User::getId)) + .hasSize(1) + .containsOnly(2); + } + + @Test + public void whenFindUserByStatusThenFound() { + User user = userRepository.findUserByStatus(0); + assertThat(user.getStatus()).isZero(); + } + + @Test + public void whenFindUserByStatusAndNameThenFound() { + User user = userRepository.findUserByStatusAndName(1, "John"); + assertThat(user.getStatus()).isOne(); + assertThat(user.getName()).isEqualTo("John"); + } + + @Test + public void whenFindUserByStatusNativeThenFound() { + User user = userRepository.findUserByStatusNative(0); + assertThat(user.getStatus()).isZero(); + } + + @Test + public void whenFindUserByStatusAndNameNamedParamsThenFound() { + User user = userRepository.findUserByStatusAndNameNamedParams(1, "John"); + assertThat(user.getStatus()).isOne(); + assertThat(user.getName()).isEqualTo("John"); + } + + @Test + public void whenFindUserByUserStatusAndUserNameThenFound() { + User user = userRepository.findUserByUserStatusAndUserName(1, "John"); + assertThat(user.getStatus()).isOne(); + assertThat(user.getName()).isEqualTo("John"); + } + + @Test + public void whenFindUserByStatusAndNameNamedParamsNativeThenFound() { + User user = userRepository.findUserByStatusAndNameNamedParamsNative(1, "Bob"); + assertThat(user.getStatus()).isOne(); + assertThat(user.getName()).isEqualTo("Bob"); + } + + @Test + public void whenFindUserByNameListThenAllFound() { + List users = userRepository.findUserByNameList(Arrays.asList("Bob", "Cindy")); + assertThat(users) + .extracting("name") + .containsOnly("Bob", "Cindy"); + } + + @Test + public void whenUpdateUserSetStatusForNameThenUpdated() { + int updated = userRepository.updateUserSetStatusForName(0, "John"); + assertThat(updated).isOne(); + + User john = userRepository.findUserByStatusAndName(0, "John"); + assertThat(john).isNotNull(); + } + + @Test + public void whenUpdateUserSetStatusForNameNativeThenUpdated() { + int updated = userRepository.updateUserSetStatusForNameNative(0, "John"); + assertThat(updated).isOne(); + + User john = userRepository.findUserByStatusAndName(0, "John"); + assertThat(john).isNotNull(); + } + + @Test + public void whenInsertUserThenInserted() { + User beforeInsert = userRepository.findUserByStatusAndName(0, "Mandy"); + assertThat(beforeInsert).isNull(); + + userRepository.insertUser("Mandy", 20, "mandy@email.com", 0, true); + + User afterInsert = userRepository.findUserByStatusAndName(0, "Mandy"); + assertThat(afterInsert).isNotNull(); + } +} From c6e380d798ed362a754754a73f82a7553f66dd0d Mon Sep 17 00:00:00 2001 From: krzysztof Date: Wed, 23 Dec 2020 12:46:18 +0100 Subject: [PATCH 123/361] BAEL-4750 Java 12 New Features --- .../newfeatures/CompactNumbersUnitTest.java | 21 ++++++++++++ .../newfeatures/FileMismatchUnitTest.java | 32 +++++++++++++++++++ .../baeldung/newfeatures/StringUnitTest.java | 15 +++++++++ .../newfeatures/TeeingCollectorUnitTest.java | 18 +++++++++++ 4 files changed, 86 insertions(+) create mode 100644 core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/CompactNumbersUnitTest.java create mode 100644 core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/FileMismatchUnitTest.java create mode 100644 core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/StringUnitTest.java create mode 100644 core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/TeeingCollectorUnitTest.java diff --git a/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/CompactNumbersUnitTest.java b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/CompactNumbersUnitTest.java new file mode 100644 index 0000000000..08a6d58d72 --- /dev/null +++ b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/CompactNumbersUnitTest.java @@ -0,0 +1,21 @@ +package java.com.baeldung.newfeatures; + +import org.junit.Test; + +import java.text.NumberFormat; +import java.util.Locale; + +import static org.junit.Assert.assertEquals; + +public class CompactNumbersUnitTest { + + @Test + public void givenNumber_thenCompactValues() { + NumberFormat likesShort = NumberFormat.getCompactNumberInstance(new Locale("en", "US"), NumberFormat.Style.SHORT); + likesShort.setMaximumFractionDigits(2); + assertEquals("2.59K", likesShort.format(2592)); + NumberFormat likesLong = NumberFormat.getCompactNumberInstance(new Locale("en", "US"), NumberFormat.Style.LONG); + likesLong.setMaximumFractionDigits(2); + assertEquals("2.59 thousand", likesShort.format(2592)); + } +} diff --git a/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/FileMismatchUnitTest.java b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/FileMismatchUnitTest.java new file mode 100644 index 0000000000..7f081fe399 --- /dev/null +++ b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/FileMismatchUnitTest.java @@ -0,0 +1,32 @@ +package java.com.baeldung.newfeatures; + +import org.junit.Test; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import static org.junit.Assert.assertEquals; + +public class FileMismatchUnitTest { + + @Test + public void givenIdenticalFiles_thenShouldNotFindMismatch() throws IOException { + Path filePath1 = Files.createTempFile("file1", ".txt"); + Path filePath2 = Files.createTempFile("file2", ".txt"); + Files.writeString(filePath1, "Java 12 Article"); + Files.writeString(filePath2, "Java 12 Article"); + long mismatch = Files.mismatch(filePath1, filePath2); + assertEquals(-1, mismatch); + } + + @Test + public void givenDifferentFiles_thenShouldFindMismatch() throws IOException { + Path filePath3 = Files.createTempFile("file3", ".txt"); + Path filePath4 = Files.createTempFile("file4", ".txt"); + Files.writeString(filePath3, "Java 12 Article"); + Files.writeString(filePath4, "Java 12 Tutorial"); + long mismatch = Files.mismatch(filePath3, filePath4); + assertEquals(8, mismatch); + } +} diff --git a/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/StringUnitTest.java b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/StringUnitTest.java new file mode 100644 index 0000000000..5ae51bd960 --- /dev/null +++ b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/StringUnitTest.java @@ -0,0 +1,15 @@ +package java.com.baeldung.newfeatures; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class StringUnitTest { + + @Test + public void givenString_thenRevertValue() { + String text = "Baeldung"; + String transformed = text.transform(value -> new StringBuilder(value).reverse().toString()); + assertEquals("gnudleaB", transformed); + } +} diff --git a/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/TeeingCollectorUnitTest.java b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/TeeingCollectorUnitTest.java new file mode 100644 index 0000000000..90fc4eda5e --- /dev/null +++ b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/TeeingCollectorUnitTest.java @@ -0,0 +1,18 @@ +package java.com.baeldung.newfeatures; + +import org.junit.Test; + +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.junit.Assert.assertEquals; + +public class TeeingCollectorUnitTest { + + @Test + public void givenSetOfNumbers_thenCalculateAverage() { + double mean = Stream.of(1, 2, 3, 4, 5) + .collect(Collectors.teeing(Collectors.summingDouble(i -> i), Collectors.counting(), (sum, count) -> sum / count)); + assertEquals(3.0, mean); + } +} From c79e7d8cbdf130e36412289d1f6c24070617a142 Mon Sep 17 00:00:00 2001 From: krzysztof Date: Wed, 23 Dec 2020 12:48:07 +0100 Subject: [PATCH 124/361] BAEL-4750 Java 12 New Features --- .../java/com/baeldung/newfeatures/TeeingCollectorUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/TeeingCollectorUnitTest.java b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/TeeingCollectorUnitTest.java index 90fc4eda5e..30a5cb40a7 100644 --- a/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/TeeingCollectorUnitTest.java +++ b/core-java-modules/core-java-12/src/test/java/com/baeldung/newfeatures/TeeingCollectorUnitTest.java @@ -12,7 +12,7 @@ public class TeeingCollectorUnitTest { @Test public void givenSetOfNumbers_thenCalculateAverage() { double mean = Stream.of(1, 2, 3, 4, 5) - .collect(Collectors.teeing(Collectors.summingDouble(i -> i), Collectors.counting(), (sum, count) -> sum / count)); + .collect(Collectors.teeing(Collectors.summingDouble(i -> i), Collectors.counting(), (sum, count) -> sum / count)); assertEquals(3.0, mean); } } From 500b2f63f8086d75dac536f66e32ba6e6d28aa31 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Wed, 23 Dec 2020 18:51:25 +0530 Subject: [PATCH 125/361] JAVA-3520: Moved spring-mvc-basics-3 inside spring-web-modules --- .../spring-mvc-basics-3}/README.md | 0 .../spring-mvc-basics-3}/pom.xml | 2 +- .../src/main/java/com/baeldung/boot/Application.java | 0 .../src/main/java/com/baeldung/boot/config/WebConfig.java | 0 .../com/baeldung/boot/controller/GenericEntityController.java | 0 .../com/baeldung/boot/converter/GenericBigDecimalConverter.java | 0 .../boot/converter/StringToAbstractEntityConverterFactory.java | 0 .../com/baeldung/boot/converter/StringToEmployeeConverter.java | 0 .../java/com/baeldung/boot/converter/StringToEnumConverter.java | 0 .../baeldung/boot/converter/StringToLocalDateTimeConverter.java | 0 .../boot/converter/controller/AbstractEntityController.java | 0 .../controller/StringToEmployeeConverterController.java | 0 .../src/main/java/com/baeldung/boot/domain/AbstractEntity.java | 0 .../src/main/java/com/baeldung/boot/domain/Bar.java | 0 .../src/main/java/com/baeldung/boot/domain/Employee.java | 0 .../src/main/java/com/baeldung/boot/domain/Foo.java | 0 .../src/main/java/com/baeldung/boot/domain/GenericEntity.java | 0 .../src/main/java/com/baeldung/boot/domain/Modes.java | 0 .../com/baeldung/boot/repository/GenericEntityRepository.java | 0 .../boot/web/resolver/HeaderVersionArgumentResolver.java | 0 .../src/main/java/com/baeldung/boot/web/resolver/Version.java | 0 .../baeldung/cachedrequest/CachedBodyHttpServletRequest.java | 0 .../baeldung/cachedrequest/CachedBodyServletInputStream.java | 0 .../java/com/baeldung/cachedrequest/ContentCachingFilter.java | 0 .../java/com/baeldung/cachedrequest/HttpRequestDemoConfig.java | 0 .../src/main/java/com/baeldung/cachedrequest/Person.java | 0 .../main/java/com/baeldung/cachedrequest/PersonController.java | 0 .../com/baeldung/cachedrequest/PrintRequestContentFilter.java | 0 .../main/java/com/baeldung/exclude_urls_filter/Application.java | 0 .../baeldung/exclude_urls_filter/controller/FAQController.java | 0 .../java/com/baeldung/exclude_urls_filter/controller/Ping.java | 0 .../exclude_urls_filter/filter/FilterRegistrationConfig.java | 0 .../exclude_urls_filter/filter/HeaderValidatorFilter.java | 0 .../java/com/baeldung/exclude_urls_filter/filter/LogFilter.java | 0 .../com/baeldung/exclude_urls_filter/service/FAQService.java | 0 .../baeldung/exclude_urls_filter/service/FAQServiceImpl.java | 0 .../main/java/com/baeldung/flash_attributes/Application.java | 0 .../baeldung/flash_attributes/controllers/PoemSubmission.java | 0 .../src/main/java/com/baeldung/flash_attributes/model/Poem.java | 0 .../src/main/java/com/baeldung/form_submission/Application.java | 0 .../com/baeldung/form_submission/controllers/FeedbackForm.java | 0 .../main/java/com/baeldung/form_submission/model/Feedback.java | 0 .../java/com/baeldung/interpolation/MyMessageInterpolator.java | 0 .../main/java/com/baeldung/interpolation/NotNullRequest.java | 0 .../java/com/baeldung/interpolation/ValidationController.java | 0 .../java/com/baeldung/interpolation/ValidationExamples.java | 0 .../src/main/java/com/baeldung/spring/Application.java | 0 .../src/main/java/com/baeldung/spring/config/MvcConfig.java | 0 .../baeldung/spring/config/converter/StringToEnumConverter.java | 0 .../src/main/java/com/baeldung/spring/enums/EnumController.java | 0 .../spring/exceptions/GlobalControllerExceptionHandler.java | 0 .../spring/headers/controller/ReadHeaderRestController.java | 0 .../src/main/java/com/baeldung/spring/model/Modes.java | 0 .../src/main/java/com/baeldung/spring/slash/Application.java | 0 .../java/com/baeldung/spring/slash/SlashParsingController.java | 0 .../listvalidation/SpringListValidationApplication.java | 0 .../validation/listvalidation/constraint/MaxSizeConstraint.java | 0 .../listvalidation/constraint/MaxSizeConstraintValidator.java | 0 .../validation/listvalidation/controller/MovieController.java | 0 .../exception/ConstraintViolationExceptionHandler.java | 0 .../com/baeldung/validation/listvalidation/model/Movie.java | 0 .../validation/listvalidation/service/MovieService.java | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/templates/feedback.html | 0 .../src/main/resources/templates/submit.html | 0 .../src/main/resources/templates/success.html | 0 .../src/test/java/com/baeldung/AppContextIntegrationTest.java | 0 .../java/com/baeldung/SpringBootApplicationIntegrationTest.java | 0 .../test/java/com/baeldung/SpringBootJPAIntegrationTest.java | 0 .../test/java/com/baeldung/SpringBootMailIntegrationTest.java | 0 .../cachedrequest/CachedBodyHttpServletRequestUnitTest.java | 0 .../cachedrequest/CachedBodyServletInputStreamUnitTest.java | 0 .../baeldung/cachedrequest/ContentCachingFilterUnitTest.java | 0 .../baeldung/cachedrequest/PersonControllerIntegrationTest.java | 0 .../cachedrequest/PrintRequestContentFilterUnitTest.java | 0 .../controller/ReadHeaderRestControllerIntegrationTest.java | 0 .../baeldung/spring/slash/SlashParsingControllerIntTest.java | 0 .../listvalidation/MovieControllerIntegrationTest.java | 0 78 files changed, 1 insertion(+), 1 deletion(-) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/README.md (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/pom.xml (98%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/Application.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/config/WebConfig.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/controller/GenericEntityController.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/converter/GenericBigDecimalConverter.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/converter/StringToAbstractEntityConverterFactory.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/converter/StringToEmployeeConverter.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/converter/StringToEnumConverter.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/converter/StringToLocalDateTimeConverter.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/converter/controller/AbstractEntityController.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/converter/controller/StringToEmployeeConverterController.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/domain/AbstractEntity.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/domain/Bar.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/domain/Employee.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/domain/Foo.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/domain/GenericEntity.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/domain/Modes.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/repository/GenericEntityRepository.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/web/resolver/HeaderVersionArgumentResolver.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/boot/web/resolver/Version.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/cachedrequest/CachedBodyHttpServletRequest.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/cachedrequest/CachedBodyServletInputStream.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/cachedrequest/ContentCachingFilter.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/cachedrequest/HttpRequestDemoConfig.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/cachedrequest/Person.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/cachedrequest/PersonController.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/cachedrequest/PrintRequestContentFilter.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/exclude_urls_filter/Application.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/flash_attributes/Application.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/flash_attributes/controllers/PoemSubmission.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/flash_attributes/model/Poem.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/form_submission/Application.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/form_submission/controllers/FeedbackForm.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/form_submission/model/Feedback.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/interpolation/MyMessageInterpolator.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/interpolation/NotNullRequest.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/interpolation/ValidationController.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/interpolation/ValidationExamples.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/spring/Application.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/spring/config/MvcConfig.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/spring/config/converter/StringToEnumConverter.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/spring/enums/EnumController.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/spring/exceptions/GlobalControllerExceptionHandler.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/spring/headers/controller/ReadHeaderRestController.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/spring/model/Modes.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/spring/slash/Application.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/spring/slash/SlashParsingController.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/validation/listvalidation/SpringListValidationApplication.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraint.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraintValidator.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/validation/listvalidation/controller/MovieController.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/validation/listvalidation/exception/ConstraintViolationExceptionHandler.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/validation/listvalidation/model/Movie.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/java/com/baeldung/validation/listvalidation/service/MovieService.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/resources/application.properties (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/resources/templates/feedback.html (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/resources/templates/submit.html (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/main/resources/templates/success.html (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/test/java/com/baeldung/AppContextIntegrationTest.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/test/java/com/baeldung/SpringBootApplicationIntegrationTest.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/test/java/com/baeldung/SpringBootJPAIntegrationTest.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/test/java/com/baeldung/SpringBootMailIntegrationTest.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/test/java/com/baeldung/cachedrequest/CachedBodyHttpServletRequestUnitTest.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/test/java/com/baeldung/cachedrequest/CachedBodyServletInputStreamUnitTest.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/test/java/com/baeldung/cachedrequest/ContentCachingFilterUnitTest.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/test/java/com/baeldung/cachedrequest/PersonControllerIntegrationTest.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/test/java/com/baeldung/cachedrequest/PrintRequestContentFilterUnitTest.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/test/java/com/baeldung/headers/controller/ReadHeaderRestControllerIntegrationTest.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/test/java/com/baeldung/spring/slash/SlashParsingControllerIntTest.java (100%) rename {spring-mvc-basics-3 => spring-web-modules/spring-mvc-basics-3}/src/test/java/com/baeldung/validation/listvalidation/MovieControllerIntegrationTest.java (100%) diff --git a/spring-mvc-basics-3/README.md b/spring-web-modules/spring-mvc-basics-3/README.md similarity index 100% rename from spring-mvc-basics-3/README.md rename to spring-web-modules/spring-mvc-basics-3/README.md diff --git a/spring-mvc-basics-3/pom.xml b/spring-web-modules/spring-mvc-basics-3/pom.xml similarity index 98% rename from spring-mvc-basics-3/pom.xml rename to spring-web-modules/spring-mvc-basics-3/pom.xml index a929337b25..c6b7763d64 100644 --- a/spring-mvc-basics-3/pom.xml +++ b/spring-web-modules/spring-mvc-basics-3/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/Application.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/Application.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/Application.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/Application.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/config/WebConfig.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/config/WebConfig.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/config/WebConfig.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/config/WebConfig.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/controller/GenericEntityController.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/controller/GenericEntityController.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/controller/GenericEntityController.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/controller/GenericEntityController.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/GenericBigDecimalConverter.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/GenericBigDecimalConverter.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/GenericBigDecimalConverter.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/GenericBigDecimalConverter.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToAbstractEntityConverterFactory.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToAbstractEntityConverterFactory.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToAbstractEntityConverterFactory.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToAbstractEntityConverterFactory.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToEmployeeConverter.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToEmployeeConverter.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToEmployeeConverter.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToEmployeeConverter.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToEnumConverter.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToEnumConverter.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToEnumConverter.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToEnumConverter.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToLocalDateTimeConverter.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToLocalDateTimeConverter.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToLocalDateTimeConverter.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/StringToLocalDateTimeConverter.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/controller/AbstractEntityController.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/controller/AbstractEntityController.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/controller/AbstractEntityController.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/controller/AbstractEntityController.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/controller/StringToEmployeeConverterController.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/controller/StringToEmployeeConverterController.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/controller/StringToEmployeeConverterController.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/converter/controller/StringToEmployeeConverterController.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/AbstractEntity.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/AbstractEntity.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/AbstractEntity.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/AbstractEntity.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Bar.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Bar.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Bar.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Bar.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Employee.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Employee.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Employee.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Employee.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Foo.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Foo.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Foo.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Foo.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/GenericEntity.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/GenericEntity.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/GenericEntity.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/GenericEntity.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Modes.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Modes.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Modes.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/domain/Modes.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/repository/GenericEntityRepository.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/repository/GenericEntityRepository.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/repository/GenericEntityRepository.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/repository/GenericEntityRepository.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/web/resolver/HeaderVersionArgumentResolver.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/web/resolver/HeaderVersionArgumentResolver.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/web/resolver/HeaderVersionArgumentResolver.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/web/resolver/HeaderVersionArgumentResolver.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/boot/web/resolver/Version.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/web/resolver/Version.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/boot/web/resolver/Version.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/boot/web/resolver/Version.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/CachedBodyHttpServletRequest.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/CachedBodyHttpServletRequest.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/CachedBodyHttpServletRequest.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/CachedBodyHttpServletRequest.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/CachedBodyServletInputStream.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/CachedBodyServletInputStream.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/CachedBodyServletInputStream.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/CachedBodyServletInputStream.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/ContentCachingFilter.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/ContentCachingFilter.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/ContentCachingFilter.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/ContentCachingFilter.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/HttpRequestDemoConfig.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/HttpRequestDemoConfig.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/HttpRequestDemoConfig.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/HttpRequestDemoConfig.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/Person.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/Person.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/Person.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/Person.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/PersonController.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/PersonController.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/PersonController.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/PersonController.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/PrintRequestContentFilter.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/PrintRequestContentFilter.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/PrintRequestContentFilter.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/cachedrequest/PrintRequestContentFilter.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/Application.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/Application.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/Application.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/Application.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/controller/FAQController.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/controller/Ping.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/FilterRegistrationConfig.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/LogFilter.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/service/FAQService.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/service/FAQServiceImpl.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/Application.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/Application.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/Application.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/Application.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/controllers/PoemSubmission.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/controllers/PoemSubmission.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/controllers/PoemSubmission.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/controllers/PoemSubmission.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/model/Poem.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/model/Poem.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/model/Poem.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/flash_attributes/model/Poem.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/Application.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/Application.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/Application.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/Application.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/controllers/FeedbackForm.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/controllers/FeedbackForm.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/controllers/FeedbackForm.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/controllers/FeedbackForm.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/model/Feedback.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/model/Feedback.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/model/Feedback.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/form_submission/model/Feedback.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/MyMessageInterpolator.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/MyMessageInterpolator.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/MyMessageInterpolator.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/MyMessageInterpolator.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/NotNullRequest.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/NotNullRequest.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/NotNullRequest.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/NotNullRequest.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/ValidationController.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/ValidationController.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/ValidationController.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/ValidationController.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/ValidationExamples.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/ValidationExamples.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/ValidationExamples.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/interpolation/ValidationExamples.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/spring/Application.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/Application.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/spring/Application.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/Application.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/spring/config/MvcConfig.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/config/MvcConfig.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/spring/config/MvcConfig.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/config/MvcConfig.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/spring/config/converter/StringToEnumConverter.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/config/converter/StringToEnumConverter.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/spring/config/converter/StringToEnumConverter.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/config/converter/StringToEnumConverter.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/spring/enums/EnumController.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/enums/EnumController.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/spring/enums/EnumController.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/enums/EnumController.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/spring/exceptions/GlobalControllerExceptionHandler.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/exceptions/GlobalControllerExceptionHandler.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/spring/exceptions/GlobalControllerExceptionHandler.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/exceptions/GlobalControllerExceptionHandler.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/spring/headers/controller/ReadHeaderRestController.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/headers/controller/ReadHeaderRestController.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/spring/headers/controller/ReadHeaderRestController.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/headers/controller/ReadHeaderRestController.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/spring/model/Modes.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/model/Modes.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/spring/model/Modes.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/model/Modes.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/spring/slash/Application.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/slash/Application.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/spring/slash/Application.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/slash/Application.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/spring/slash/SlashParsingController.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/slash/SlashParsingController.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/spring/slash/SlashParsingController.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/spring/slash/SlashParsingController.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/SpringListValidationApplication.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/SpringListValidationApplication.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/SpringListValidationApplication.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/SpringListValidationApplication.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraint.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraint.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraint.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraint.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraintValidator.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraintValidator.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraintValidator.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/constraint/MaxSizeConstraintValidator.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/controller/MovieController.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/controller/MovieController.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/controller/MovieController.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/controller/MovieController.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/exception/ConstraintViolationExceptionHandler.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/exception/ConstraintViolationExceptionHandler.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/exception/ConstraintViolationExceptionHandler.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/exception/ConstraintViolationExceptionHandler.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/model/Movie.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/model/Movie.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/model/Movie.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/model/Movie.java diff --git a/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/service/MovieService.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/service/MovieService.java similarity index 100% rename from spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/service/MovieService.java rename to spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/validation/listvalidation/service/MovieService.java diff --git a/spring-mvc-basics-3/src/main/resources/application.properties b/spring-web-modules/spring-mvc-basics-3/src/main/resources/application.properties similarity index 100% rename from spring-mvc-basics-3/src/main/resources/application.properties rename to spring-web-modules/spring-mvc-basics-3/src/main/resources/application.properties diff --git a/spring-mvc-basics-3/src/main/resources/templates/feedback.html b/spring-web-modules/spring-mvc-basics-3/src/main/resources/templates/feedback.html similarity index 100% rename from spring-mvc-basics-3/src/main/resources/templates/feedback.html rename to spring-web-modules/spring-mvc-basics-3/src/main/resources/templates/feedback.html diff --git a/spring-mvc-basics-3/src/main/resources/templates/submit.html b/spring-web-modules/spring-mvc-basics-3/src/main/resources/templates/submit.html similarity index 100% rename from spring-mvc-basics-3/src/main/resources/templates/submit.html rename to spring-web-modules/spring-mvc-basics-3/src/main/resources/templates/submit.html diff --git a/spring-mvc-basics-3/src/main/resources/templates/success.html b/spring-web-modules/spring-mvc-basics-3/src/main/resources/templates/success.html similarity index 100% rename from spring-mvc-basics-3/src/main/resources/templates/success.html rename to spring-web-modules/spring-mvc-basics-3/src/main/resources/templates/success.html diff --git a/spring-mvc-basics-3/src/test/java/com/baeldung/AppContextIntegrationTest.java b/spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/AppContextIntegrationTest.java similarity index 100% rename from spring-mvc-basics-3/src/test/java/com/baeldung/AppContextIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/AppContextIntegrationTest.java diff --git a/spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootApplicationIntegrationTest.java b/spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootApplicationIntegrationTest.java similarity index 100% rename from spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootApplicationIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootApplicationIntegrationTest.java diff --git a/spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootJPAIntegrationTest.java b/spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootJPAIntegrationTest.java similarity index 100% rename from spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootJPAIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootJPAIntegrationTest.java diff --git a/spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootMailIntegrationTest.java b/spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootMailIntegrationTest.java similarity index 100% rename from spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootMailIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/SpringBootMailIntegrationTest.java diff --git a/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/CachedBodyHttpServletRequestUnitTest.java b/spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/CachedBodyHttpServletRequestUnitTest.java similarity index 100% rename from spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/CachedBodyHttpServletRequestUnitTest.java rename to spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/CachedBodyHttpServletRequestUnitTest.java diff --git a/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/CachedBodyServletInputStreamUnitTest.java b/spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/CachedBodyServletInputStreamUnitTest.java similarity index 100% rename from spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/CachedBodyServletInputStreamUnitTest.java rename to spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/CachedBodyServletInputStreamUnitTest.java diff --git a/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/ContentCachingFilterUnitTest.java b/spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/ContentCachingFilterUnitTest.java similarity index 100% rename from spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/ContentCachingFilterUnitTest.java rename to spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/ContentCachingFilterUnitTest.java diff --git a/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/PersonControllerIntegrationTest.java b/spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/PersonControllerIntegrationTest.java similarity index 100% rename from spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/PersonControllerIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/PersonControllerIntegrationTest.java diff --git a/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/PrintRequestContentFilterUnitTest.java b/spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/PrintRequestContentFilterUnitTest.java similarity index 100% rename from spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/PrintRequestContentFilterUnitTest.java rename to spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/cachedrequest/PrintRequestContentFilterUnitTest.java diff --git a/spring-mvc-basics-3/src/test/java/com/baeldung/headers/controller/ReadHeaderRestControllerIntegrationTest.java b/spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/headers/controller/ReadHeaderRestControllerIntegrationTest.java similarity index 100% rename from spring-mvc-basics-3/src/test/java/com/baeldung/headers/controller/ReadHeaderRestControllerIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/headers/controller/ReadHeaderRestControllerIntegrationTest.java diff --git a/spring-mvc-basics-3/src/test/java/com/baeldung/spring/slash/SlashParsingControllerIntTest.java b/spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/spring/slash/SlashParsingControllerIntTest.java similarity index 100% rename from spring-mvc-basics-3/src/test/java/com/baeldung/spring/slash/SlashParsingControllerIntTest.java rename to spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/spring/slash/SlashParsingControllerIntTest.java diff --git a/spring-mvc-basics-3/src/test/java/com/baeldung/validation/listvalidation/MovieControllerIntegrationTest.java b/spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/validation/listvalidation/MovieControllerIntegrationTest.java similarity index 100% rename from spring-mvc-basics-3/src/test/java/com/baeldung/validation/listvalidation/MovieControllerIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-3/src/test/java/com/baeldung/validation/listvalidation/MovieControllerIntegrationTest.java From e0db0ca9f8da49bbd1e979058d540b6968f390c8 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Wed, 23 Dec 2020 18:51:57 +0530 Subject: [PATCH 126/361] JAVA-3520: 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 9134906364..6900e20994 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -16,6 +16,7 @@ spring-mvc-basics spring-mvc-basics-2 + spring-mvc-basics-3 From 2d9750ec8a1b55c62b0d81c1b48f12bc409f8d92 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Wed, 23 Dec 2020 18:52:49 +0530 Subject: [PATCH 127/361] JAVA-3520: Removed module spring-mvc-basics-3 from main pom --- pom.xml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 00bc39d49f..ec5586a4ad 100644 --- a/pom.xml +++ b/pom.xml @@ -662,8 +662,7 @@ spring-mobile spring-mockito - - spring-mvc-basics-3 + spring-mvc-basics-4 spring-mvc-forms-jsp @@ -1148,7 +1147,6 @@ spring-mobile spring-mockito - spring-mvc-basics-3 spring-mvc-basics-4 spring-mvc-forms-jsp From dd3513dd532b1e29fa4547a3283cfeb7195fed83 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 23 Dec 2020 22:27:26 +0800 Subject: [PATCH 128/361] Update README.md --- spring-websockets/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-websockets/README.md b/spring-websockets/README.md index 26e1c6db7c..9cc84f0fda 100644 --- a/spring-websockets/README.md +++ b/spring-websockets/README.md @@ -5,3 +5,4 @@ This module contains articles about Spring WebSockets. ### Relevant articles - [Intro to WebSockets with Spring](https://www.baeldung.com/websockets-spring) - [A Quick Example of Spring Websockets’ @SendToUser Annotation](https://www.baeldung.com/spring-websockets-sendtouser) +- [Scheduled WebSocket Push with Spring Boot](https://www.baeldung.com/spring-boot-scheduled-websocket) From ea4d34438aac13922e72f206690f3036ef52c202 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 23 Dec 2020 22:30:16 +0800 Subject: [PATCH 129/361] Update README.md --- spring-resttemplate-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-resttemplate-2/README.md b/spring-resttemplate-2/README.md index aab6a188b6..a903757bb4 100644 --- a/spring-resttemplate-2/README.md +++ b/spring-resttemplate-2/README.md @@ -9,3 +9,4 @@ This module contains articles about Spring RestTemplate - [A Custom Media Type for a Spring REST API](https://www.baeldung.com/spring-rest-custom-media-type) - [RestTemplate Post Request with JSON](https://www.baeldung.com/spring-resttemplate-post-json) - [How to Compress Requests Using the Spring RestTemplate](https://www.baeldung.com/spring-resttemplate-compressing-requests) +- [Get list of JSON objects with Spring RestTemplate](https://www.baeldung.com/spring-resttemplate-json-list) From 73358da094936652f8727cf5eaaacca2e916c6f0 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 23 Dec 2020 22:32:01 +0800 Subject: [PATCH 130/361] Update README.md --- spring-apache-camel/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-apache-camel/README.md b/spring-apache-camel/README.md index e89eb4fe6c..6a16e1da05 100644 --- a/spring-apache-camel/README.md +++ b/spring-apache-camel/README.md @@ -9,6 +9,7 @@ This module contains articles about Spring with Apache Camel - [Introduction To Apache Camel](http://www.baeldung.com/apache-camel-intro) - [Integration Patterns With Apache Camel](http://www.baeldung.com/camel-integration-patterns) - [Using Apache Camel with Spring](http://www.baeldung.com/spring-apache-camel-tutorial) +- [Unmarshalling a JSON Array Using camel-jackson](https://www.baeldung.com/java-camel-jackson-json-array) ### Framework Versions: @@ -23,4 +24,4 @@ To build this application execute: To run this application you can either run our main class App from your IDE or you can execute following maven command: -`mvn exec:java -Dexec.mainClass="com.baeldung.camel.main.App"` \ No newline at end of file +`mvn exec:java -Dexec.mainClass="com.baeldung.camel.main.App"` From d1bb00ed39ffb41168387aec04c60d10d0bee158 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 23 Dec 2020 22:34:11 +0800 Subject: [PATCH 131/361] Update README.md --- core-java-modules/core-java-14/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-14/README.md b/core-java-modules/core-java-14/README.md index d382c4814a..004b3587c4 100644 --- a/core-java-modules/core-java-14/README.md +++ b/core-java-modules/core-java-14/README.md @@ -10,3 +10,4 @@ This module contains articles about Java 14. - [Helpful NullPointerExceptions in Java 14](https://www.baeldung.com/java-14-nullpointerexception) - [Foreign Memory Access API in Java 14](https://www.baeldung.com/java-foreign-memory-access) - [Java 14 Record Keyword](https://www.baeldung.com/java-record-keyword) +- [Java 14 – New Features](https://www.baeldung.com/java-14-new-features) From af36328752111b0255cf5094ee5501eb2fff4310 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 23 Dec 2020 22:36:11 +0800 Subject: [PATCH 132/361] Create README.md --- spring-boot-modules/spring-boot-data-2/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 spring-boot-modules/spring-boot-data-2/README.md diff --git a/spring-boot-modules/spring-boot-data-2/README.md b/spring-boot-modules/spring-boot-data-2/README.md new file mode 100644 index 0000000000..d5020ce354 --- /dev/null +++ b/spring-boot-modules/spring-boot-data-2/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Spring Boot: Customize the Jackson ObjectMapper](https://www.baeldung.com/spring-boot-customize-jackson-objectmapper) From b682fddd885a971fd51ee5384d7c6a24b77b59e9 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 23 Dec 2020 22:38:23 +0800 Subject: [PATCH 133/361] Update README.md --- core-java-modules/core-java-collections-maps-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-collections-maps-3/README.md b/core-java-modules/core-java-collections-maps-3/README.md index 7386f7e9b7..918c81fe4b 100644 --- a/core-java-modules/core-java-collections-maps-3/README.md +++ b/core-java-modules/core-java-collections-maps-3/README.md @@ -6,4 +6,5 @@ This module contains articles about Map data structures in Java. - [Java TreeMap vs HashMap](https://www.baeldung.com/java-treemap-vs-hashmap) - [Comparing Two HashMaps in Java](https://www.baeldung.com/java-compare-hashmaps) - [The Map.computeIfAbsent() Method](https://www.baeldung.com/java-map-computeifabsent) +- [Collections.synchronizedMap vs. ConcurrentHashMap](https://www.baeldung.com/java-synchronizedmap-vs-concurrenthashmap) - More articles: [[<-- prev]](/core-java-modules/core-java-collections-maps-2) From a07556adaf2381d70955c122188fb61bc479869b Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Thu, 24 Dec 2020 12:41:29 +0100 Subject: [PATCH 134/361] JAVA-3710: Use hibernate-core in spring-jpa --- persistence-modules/spring-jpa/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/spring-jpa/pom.xml b/persistence-modules/spring-jpa/pom.xml index 410ed592b0..e389886d8d 100644 --- a/persistence-modules/spring-jpa/pom.xml +++ b/persistence-modules/spring-jpa/pom.xml @@ -41,7 +41,7 @@ org.hibernate - hibernate-entitymanager + hibernate-core ${hibernate.version} From 95f98baeb33516967e98096a79a330ad13598c42 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Thu, 24 Dec 2020 12:45:51 +0100 Subject: [PATCH 135/361] JAVA-3710: Use hibernate-core in spring-jpa-2 --- persistence-modules/spring-jpa-2/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/spring-jpa-2/pom.xml b/persistence-modules/spring-jpa-2/pom.xml index 8d8dfe3a7b..7770c0e045 100644 --- a/persistence-modules/spring-jpa-2/pom.xml +++ b/persistence-modules/spring-jpa-2/pom.xml @@ -46,7 +46,7 @@ org.hibernate - hibernate-entitymanager + hibernate-core ${hibernate.version} From 6af6f685fd22cbbd63ef6711b725c463638c61f0 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Thu, 24 Dec 2020 13:07:07 +0100 Subject: [PATCH 136/361] JAVA-3710: Replace hibernate-entitymanager dependency with hibernate-core --- atomikos/pom.xml | 2 +- persistence-modules/querydsl/pom.xml | 2 +- spring-jinq/pom.xml | 5 ----- spring-rest-query-language/pom.xml | 2 +- spring-rest-testing/pom.xml | 2 +- 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/atomikos/pom.xml b/atomikos/pom.xml index d680a3ca77..8918de7b77 100644 --- a/atomikos/pom.xml +++ b/atomikos/pom.xml @@ -51,7 +51,7 @@ org.hibernate - hibernate-entitymanager + hibernate-core ${hibernate.version} provided diff --git a/persistence-modules/querydsl/pom.xml b/persistence-modules/querydsl/pom.xml index 9f6802ff77..a611c309b6 100644 --- a/persistence-modules/querydsl/pom.xml +++ b/persistence-modules/querydsl/pom.xml @@ -31,7 +31,7 @@ org.hibernate - hibernate-entitymanager + hibernate-core ${hibernate.version} compile diff --git a/spring-jinq/pom.xml b/spring-jinq/pom.xml index 647c0907a7..1f5d8cd915 100644 --- a/spring-jinq/pom.xml +++ b/spring-jinq/pom.xml @@ -27,11 +27,6 @@ h2 - - org.hibernate - hibernate-entitymanager - - org.springframework.boot spring-boot-starter-data-jpa diff --git a/spring-rest-query-language/pom.xml b/spring-rest-query-language/pom.xml index 2423528743..4458aa0580 100644 --- a/spring-rest-query-language/pom.xml +++ b/spring-rest-query-language/pom.xml @@ -140,7 +140,7 @@ org.hibernate - hibernate-entitymanager + hibernate-core xml-apis diff --git a/spring-rest-testing/pom.xml b/spring-rest-testing/pom.xml index 9bfe9d83a4..0e947260f4 100644 --- a/spring-rest-testing/pom.xml +++ b/spring-rest-testing/pom.xml @@ -120,7 +120,7 @@ org.hibernate - hibernate-entitymanager + hibernate-core xml-apis From 405bb17b46b4a8371abc19a9c9d946fc5e9f5ed9 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Thu, 24 Dec 2020 19:58:59 +0530 Subject: [PATCH 137/361] JAVA-3521: Moved spring-mvc-basics-4 inside spring-web-modules --- .../spring-mvc-basics-4}/.gitignore | 0 .../spring-mvc-basics-4}/README.md | 2 +- .../spring-mvc-basics-4}/pom.xml | 2 +- .../src/main/java/com/baeldung/contexts/Greeting.java | 0 .../AnnotationsBasedApplicationAndServletInitializer.java | 0 .../contexts/config/AnnotationsBasedApplicationInitializer.java | 0 .../com/baeldung/contexts/config/ApplicationInitializer.java | 0 .../java/com/baeldung/contexts/config/NormalWebAppConfig.java | 0 .../com/baeldung/contexts/config/RootApplicationConfig.java | 0 .../SecureAnnotationsBasedApplicationAndServletInitializer.java | 0 .../java/com/baeldung/contexts/config/SecureWebAppConfig.java | 0 .../java/com/baeldung/contexts/normal/HelloWorldController.java | 0 .../baeldung/contexts/secure/HelloWorldSecureController.java | 0 .../contexts/services/ApplicationContextUtilService.java | 0 .../java/com/baeldung/contexts/services/GreeterService.java | 0 .../com/baeldung/controller/config/StudentControllerConfig.java | 0 .../src/main/java/com/baeldung/controller/config/WebConfig.java | 0 .../controller/controller/PassParametersController.java | 0 .../baeldung/controller/controller/RestAnnotatedController.java | 0 .../java/com/baeldung/controller/controller/RestController.java | 0 .../java/com/baeldung/controller/controller/TestController.java | 0 .../src/main/java/com/baeldung/controller/student/Student.java | 0 .../java/com/baeldung/jsonparams/config/JsonParamsConfig.java | 0 .../java/com/baeldung/jsonparams/config/JsonParamsInit.java | 0 .../com/baeldung/jsonparams/controller/ProductController.java | 0 .../src/main/java/com/baeldung/jsonparams/model/Product.java | 0 .../com/baeldung/jsonparams/propertyeditor/ProductEditor.java | 0 .../src/main/java/com/baeldung/optionalpathvars/Article.java | 0 .../com/baeldung/optionalpathvars/ArticleViewerController.java | 0 .../optionalpathvars/ArticleViewerWithMapParamController.java | 0 .../ArticleViewerWithOptionalParamController.java | 0 .../ArticleViewerWithRequiredAttributeController.java | 0 .../ArticleViewerWithTwoSeparateMethodsController.java | 0 .../src/main/resources/application.properties | 0 .../spring-mvc-basics-4}/src/main/resources/logback.xml | 0 .../spring-mvc-basics-4}/src/main/resources/test-mvc.xml | 0 .../spring-mvc-basics-4}/src/main/webapp/WEB-INF/greeting.xml | 0 .../spring-mvc-basics-4}/src/main/webapp/WEB-INF/index.jsp | 0 .../src/main/webapp/WEB-INF/normal-webapp-servlet.xml | 0 .../src/main/webapp/WEB-INF/rootApplicationContext.xml | 0 .../src/main/webapp/WEB-INF/secure-webapp-servlet.xml | 0 .../src/main/webapp/WEB-INF/secure/view/welcome.jsp | 0 .../src/main/webapp/WEB-INF/view/sample.jsp | 0 .../src/main/webapp/WEB-INF/view/scopesExample.jsp | 0 .../src/main/webapp/WEB-INF/view/viewPage.html | 0 .../src/main/webapp/WEB-INF/view/welcome.jsp | 0 .../spring-mvc-basics-4}/src/main/webapp/WEB-INF/web-old.xml | 0 .../spring-mvc-basics-4}/src/main/webapp/WEB-INF/welcome.jsp | 0 .../spring-mvc-basics-4}/src/main/webapp/index.jsp | 0 .../controller/ControllerAnnotationIntegrationTest.java | 0 .../java/com/baeldung/controller/ControllerIntegrationTest.java | 0 .../controller/PassParametersControllerIntegrationTest.java | 0 .../java/com/baeldung/jsonparams/JsonParamsIntegrationTest.java | 0 .../ArticleViewerControllerIntegrationTest.java | 0 ...ArticleViewerControllerWithOptionalParamIntegrationTest.java | 0 ...cleViewerControllerWithRequiredAttributeIntegrationTest.java | 0 .../ArticleViewerWithMapParamIntegrationTest.java | 0 .../ArticleViewerWithTwoSeparateMethodsIntegrationTest.java | 0 .../spring-mvc-basics-4}/src/test/resources/test-mvc.xml | 0 59 files changed, 2 insertions(+), 2 deletions(-) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/.gitignore (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/README.md (90%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/pom.xml (94%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/contexts/Greeting.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationAndServletInitializer.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationInitializer.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/contexts/config/ApplicationInitializer.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/contexts/config/NormalWebAppConfig.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/contexts/config/RootApplicationConfig.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/contexts/config/SecureAnnotationsBasedApplicationAndServletInitializer.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/contexts/config/SecureWebAppConfig.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/contexts/normal/HelloWorldController.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/contexts/secure/HelloWorldSecureController.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/contexts/services/ApplicationContextUtilService.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/contexts/services/GreeterService.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/controller/config/StudentControllerConfig.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/controller/config/WebConfig.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/controller/controller/PassParametersController.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/controller/controller/RestAnnotatedController.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/controller/controller/RestController.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/controller/controller/TestController.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/controller/student/Student.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/jsonparams/config/JsonParamsConfig.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/jsonparams/config/JsonParamsInit.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/jsonparams/controller/ProductController.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/jsonparams/model/Product.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/jsonparams/propertyeditor/ProductEditor.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/optionalpathvars/Article.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/optionalpathvars/ArticleViewerController.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamController.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithOptionalParamController.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithRequiredAttributeController.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/resources/application.properties (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/resources/logback.xml (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/resources/test-mvc.xml (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/webapp/WEB-INF/greeting.xml (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/webapp/WEB-INF/index.jsp (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/webapp/WEB-INF/normal-webapp-servlet.xml (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/webapp/WEB-INF/rootApplicationContext.xml (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/webapp/WEB-INF/secure-webapp-servlet.xml (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/webapp/WEB-INF/secure/view/welcome.jsp (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/webapp/WEB-INF/view/sample.jsp (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/webapp/WEB-INF/view/scopesExample.jsp (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/webapp/WEB-INF/view/viewPage.html (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/webapp/WEB-INF/view/welcome.jsp (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/webapp/WEB-INF/web-old.xml (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/webapp/WEB-INF/welcome.jsp (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/main/webapp/index.jsp (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/test/java/com/baeldung/controller/ControllerAnnotationIntegrationTest.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/test/java/com/baeldung/controller/ControllerIntegrationTest.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/test/java/com/baeldung/controller/PassParametersControllerIntegrationTest.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/test/java/com/baeldung/jsonparams/JsonParamsIntegrationTest.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerIntegrationTest.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java (100%) rename {spring-mvc-basics-4 => spring-web-modules/spring-mvc-basics-4}/src/test/resources/test-mvc.xml (100%) diff --git a/spring-mvc-basics-4/.gitignore b/spring-web-modules/spring-mvc-basics-4/.gitignore similarity index 100% rename from spring-mvc-basics-4/.gitignore rename to spring-web-modules/spring-mvc-basics-4/.gitignore diff --git a/spring-mvc-basics-4/README.md b/spring-web-modules/spring-mvc-basics-4/README.md similarity index 90% rename from spring-mvc-basics-4/README.md rename to spring-web-modules/spring-mvc-basics-4/README.md index 0da83540ad..d0bca4a303 100644 --- a/spring-mvc-basics-4/README.md +++ b/spring-web-modules/spring-mvc-basics-4/README.md @@ -1,7 +1,7 @@ ## Spring MVC Basics with Java Configuration Example Project ### The Course -The "REST With Spring" Classes: http://bit.ly/restwithspring +The "REST With Spring" Classes: https://bit.ly/restwithspring ### Relevant Articles: - [Quick Guide to Spring Controllers](https://www.baeldung.com/spring-controllers) diff --git a/spring-mvc-basics-4/pom.xml b/spring-web-modules/spring-mvc-basics-4/pom.xml similarity index 94% rename from spring-mvc-basics-4/pom.xml rename to spring-web-modules/spring-mvc-basics-4/pom.xml index 8382cd03b8..07dddcde0c 100644 --- a/spring-mvc-basics-4/pom.xml +++ b/spring-web-modules/spring-mvc-basics-4/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/Greeting.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/Greeting.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/contexts/Greeting.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/Greeting.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationAndServletInitializer.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationAndServletInitializer.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationAndServletInitializer.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationAndServletInitializer.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationInitializer.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationInitializer.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationInitializer.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/AnnotationsBasedApplicationInitializer.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/ApplicationInitializer.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/ApplicationInitializer.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/ApplicationInitializer.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/ApplicationInitializer.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/NormalWebAppConfig.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/NormalWebAppConfig.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/NormalWebAppConfig.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/NormalWebAppConfig.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/RootApplicationConfig.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/RootApplicationConfig.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/RootApplicationConfig.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/RootApplicationConfig.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/SecureAnnotationsBasedApplicationAndServletInitializer.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/SecureAnnotationsBasedApplicationAndServletInitializer.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/SecureAnnotationsBasedApplicationAndServletInitializer.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/SecureAnnotationsBasedApplicationAndServletInitializer.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/SecureWebAppConfig.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/SecureWebAppConfig.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/SecureWebAppConfig.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/config/SecureWebAppConfig.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/normal/HelloWorldController.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/normal/HelloWorldController.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/contexts/normal/HelloWorldController.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/normal/HelloWorldController.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/secure/HelloWorldSecureController.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/secure/HelloWorldSecureController.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/contexts/secure/HelloWorldSecureController.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/secure/HelloWorldSecureController.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/services/ApplicationContextUtilService.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/services/ApplicationContextUtilService.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/contexts/services/ApplicationContextUtilService.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/services/ApplicationContextUtilService.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/services/GreeterService.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/services/GreeterService.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/contexts/services/GreeterService.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/contexts/services/GreeterService.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/controller/config/StudentControllerConfig.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/controller/config/StudentControllerConfig.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/controller/config/StudentControllerConfig.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/controller/config/StudentControllerConfig.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/controller/config/WebConfig.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/controller/config/WebConfig.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/controller/config/WebConfig.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/controller/config/WebConfig.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/PassParametersController.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/PassParametersController.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/PassParametersController.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/PassParametersController.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/RestAnnotatedController.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/RestAnnotatedController.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/RestAnnotatedController.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/RestAnnotatedController.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/RestController.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/RestController.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/RestController.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/RestController.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/TestController.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/TestController.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/TestController.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/controller/controller/TestController.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/controller/student/Student.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/controller/student/Student.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/controller/student/Student.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/controller/student/Student.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/config/JsonParamsConfig.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/config/JsonParamsConfig.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/config/JsonParamsConfig.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/config/JsonParamsConfig.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/config/JsonParamsInit.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/config/JsonParamsInit.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/config/JsonParamsInit.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/config/JsonParamsInit.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/controller/ProductController.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/controller/ProductController.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/controller/ProductController.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/controller/ProductController.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/model/Product.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/model/Product.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/model/Product.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/model/Product.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/propertyeditor/ProductEditor.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/propertyeditor/ProductEditor.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/propertyeditor/ProductEditor.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/jsonparams/propertyeditor/ProductEditor.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/Article.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/Article.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/Article.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/Article.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerController.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerController.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerController.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerController.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamController.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamController.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamController.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamController.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithOptionalParamController.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithOptionalParamController.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithOptionalParamController.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithOptionalParamController.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithRequiredAttributeController.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithRequiredAttributeController.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithRequiredAttributeController.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithRequiredAttributeController.java diff --git a/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java b/spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java similarity index 100% rename from spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java rename to spring-web-modules/spring-mvc-basics-4/src/main/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java diff --git a/spring-mvc-basics-4/src/main/resources/application.properties b/spring-web-modules/spring-mvc-basics-4/src/main/resources/application.properties similarity index 100% rename from spring-mvc-basics-4/src/main/resources/application.properties rename to spring-web-modules/spring-mvc-basics-4/src/main/resources/application.properties diff --git a/spring-mvc-basics-4/src/main/resources/logback.xml b/spring-web-modules/spring-mvc-basics-4/src/main/resources/logback.xml similarity index 100% rename from spring-mvc-basics-4/src/main/resources/logback.xml rename to spring-web-modules/spring-mvc-basics-4/src/main/resources/logback.xml diff --git a/spring-mvc-basics-4/src/main/resources/test-mvc.xml b/spring-web-modules/spring-mvc-basics-4/src/main/resources/test-mvc.xml similarity index 100% rename from spring-mvc-basics-4/src/main/resources/test-mvc.xml rename to spring-web-modules/spring-mvc-basics-4/src/main/resources/test-mvc.xml diff --git a/spring-mvc-basics-4/src/main/webapp/WEB-INF/greeting.xml b/spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/greeting.xml similarity index 100% rename from spring-mvc-basics-4/src/main/webapp/WEB-INF/greeting.xml rename to spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/greeting.xml diff --git a/spring-mvc-basics-4/src/main/webapp/WEB-INF/index.jsp b/spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/index.jsp similarity index 100% rename from spring-mvc-basics-4/src/main/webapp/WEB-INF/index.jsp rename to spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/index.jsp diff --git a/spring-mvc-basics-4/src/main/webapp/WEB-INF/normal-webapp-servlet.xml b/spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/normal-webapp-servlet.xml similarity index 100% rename from spring-mvc-basics-4/src/main/webapp/WEB-INF/normal-webapp-servlet.xml rename to spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/normal-webapp-servlet.xml diff --git a/spring-mvc-basics-4/src/main/webapp/WEB-INF/rootApplicationContext.xml b/spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/rootApplicationContext.xml similarity index 100% rename from spring-mvc-basics-4/src/main/webapp/WEB-INF/rootApplicationContext.xml rename to spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/rootApplicationContext.xml diff --git a/spring-mvc-basics-4/src/main/webapp/WEB-INF/secure-webapp-servlet.xml b/spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/secure-webapp-servlet.xml similarity index 100% rename from spring-mvc-basics-4/src/main/webapp/WEB-INF/secure-webapp-servlet.xml rename to spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/secure-webapp-servlet.xml diff --git a/spring-mvc-basics-4/src/main/webapp/WEB-INF/secure/view/welcome.jsp b/spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/secure/view/welcome.jsp similarity index 100% rename from spring-mvc-basics-4/src/main/webapp/WEB-INF/secure/view/welcome.jsp rename to spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/secure/view/welcome.jsp diff --git a/spring-mvc-basics-4/src/main/webapp/WEB-INF/view/sample.jsp b/spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/view/sample.jsp similarity index 100% rename from spring-mvc-basics-4/src/main/webapp/WEB-INF/view/sample.jsp rename to spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/view/sample.jsp diff --git a/spring-mvc-basics-4/src/main/webapp/WEB-INF/view/scopesExample.jsp b/spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/view/scopesExample.jsp similarity index 100% rename from spring-mvc-basics-4/src/main/webapp/WEB-INF/view/scopesExample.jsp rename to spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/view/scopesExample.jsp diff --git a/spring-mvc-basics-4/src/main/webapp/WEB-INF/view/viewPage.html b/spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/view/viewPage.html similarity index 100% rename from spring-mvc-basics-4/src/main/webapp/WEB-INF/view/viewPage.html rename to spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/view/viewPage.html diff --git a/spring-mvc-basics-4/src/main/webapp/WEB-INF/view/welcome.jsp b/spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/view/welcome.jsp similarity index 100% rename from spring-mvc-basics-4/src/main/webapp/WEB-INF/view/welcome.jsp rename to spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/view/welcome.jsp diff --git a/spring-mvc-basics-4/src/main/webapp/WEB-INF/web-old.xml b/spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/web-old.xml similarity index 100% rename from spring-mvc-basics-4/src/main/webapp/WEB-INF/web-old.xml rename to spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/web-old.xml diff --git a/spring-mvc-basics-4/src/main/webapp/WEB-INF/welcome.jsp b/spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/welcome.jsp similarity index 100% rename from spring-mvc-basics-4/src/main/webapp/WEB-INF/welcome.jsp rename to spring-web-modules/spring-mvc-basics-4/src/main/webapp/WEB-INF/welcome.jsp diff --git a/spring-mvc-basics-4/src/main/webapp/index.jsp b/spring-web-modules/spring-mvc-basics-4/src/main/webapp/index.jsp similarity index 100% rename from spring-mvc-basics-4/src/main/webapp/index.jsp rename to spring-web-modules/spring-mvc-basics-4/src/main/webapp/index.jsp diff --git a/spring-mvc-basics-4/src/test/java/com/baeldung/controller/ControllerAnnotationIntegrationTest.java b/spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/controller/ControllerAnnotationIntegrationTest.java similarity index 100% rename from spring-mvc-basics-4/src/test/java/com/baeldung/controller/ControllerAnnotationIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/controller/ControllerAnnotationIntegrationTest.java diff --git a/spring-mvc-basics-4/src/test/java/com/baeldung/controller/ControllerIntegrationTest.java b/spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/controller/ControllerIntegrationTest.java similarity index 100% rename from spring-mvc-basics-4/src/test/java/com/baeldung/controller/ControllerIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/controller/ControllerIntegrationTest.java diff --git a/spring-mvc-basics-4/src/test/java/com/baeldung/controller/PassParametersControllerIntegrationTest.java b/spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/controller/PassParametersControllerIntegrationTest.java similarity index 100% rename from spring-mvc-basics-4/src/test/java/com/baeldung/controller/PassParametersControllerIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/controller/PassParametersControllerIntegrationTest.java diff --git a/spring-mvc-basics-4/src/test/java/com/baeldung/jsonparams/JsonParamsIntegrationTest.java b/spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/jsonparams/JsonParamsIntegrationTest.java similarity index 100% rename from spring-mvc-basics-4/src/test/java/com/baeldung/jsonparams/JsonParamsIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/jsonparams/JsonParamsIntegrationTest.java diff --git a/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerIntegrationTest.java b/spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerIntegrationTest.java similarity index 100% rename from spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerIntegrationTest.java diff --git a/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java b/spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java similarity index 100% rename from spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java diff --git a/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java b/spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java similarity index 100% rename from spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java diff --git a/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java b/spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java similarity index 100% rename from spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java diff --git a/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java b/spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java similarity index 100% rename from spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java rename to spring-web-modules/spring-mvc-basics-4/src/test/java/com/baeldung/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java diff --git a/spring-mvc-basics-4/src/test/resources/test-mvc.xml b/spring-web-modules/spring-mvc-basics-4/src/test/resources/test-mvc.xml similarity index 100% rename from spring-mvc-basics-4/src/test/resources/test-mvc.xml rename to spring-web-modules/spring-mvc-basics-4/src/test/resources/test-mvc.xml From 6af74b63f18e933322c678669181ac826b40a03a Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Thu, 24 Dec 2020 19:59:41 +0530 Subject: [PATCH 138/361] JAVA-3521: 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 6900e20994..bf6fda09f4 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -17,6 +17,7 @@ spring-mvc-basics spring-mvc-basics-2 spring-mvc-basics-3 + spring-mvc-basics-4 From ba9e0b9c38d307102addb361153b6ef43f0bc42a Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Thu, 24 Dec 2020 20:00:29 +0530 Subject: [PATCH 139/361] JAVA-3521: removed spring-mvc-basics-4 from main pom --- pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pom.xml b/pom.xml index ec5586a4ad..e0ad1ad35a 100644 --- a/pom.xml +++ b/pom.xml @@ -662,8 +662,6 @@ spring-mobile spring-mockito - - spring-mvc-basics-4 spring-mvc-forms-jsp spring-mvc-forms-thymeleaf @@ -1146,8 +1144,6 @@ spring-mobile spring-mockito - - spring-mvc-basics-4 spring-mvc-forms-jsp spring-mvc-forms-thymeleaf From 2d2a64acbe74fdb9da86e582362e6df28590db8c Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Fri, 25 Dec 2020 09:06:51 +0530 Subject: [PATCH 140/361] Added changes to show transaction roll back --- .../baeldung/spring/transaction/Course.java | 35 +++++++++++++++++ .../spring/transaction/CourseDao.java | 24 ++++++++++++ .../spring/transaction/CourseService.java | 38 +++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/Course.java create mode 100644 persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseDao.java create mode 100644 persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseService.java diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/Course.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/Course.java new file mode 100644 index 0000000000..5add1e4a99 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/Course.java @@ -0,0 +1,35 @@ +package com.baeldung.spring.transaction; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "course") +public class Course implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "id") + private Long id; + + public Course() { + } + + public Course(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + +} diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseDao.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseDao.java new file mode 100644 index 0000000000..489784bb40 --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseDao.java @@ -0,0 +1,24 @@ +package com.baeldung.spring.transaction; + +import java.sql.SQLException; + +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.stereotype.Repository; + +import com.baeldung.spring.hibernate.AbstractHibernateDao; + +@Repository +public class CourseDao extends AbstractHibernateDao { + public CourseDao() { + super(); + setClazz(Course.class); + } + + public Course createWithRuntimeException(final Course entity) { + throw new DataIntegrityViolationException("Throwing exception for demoing Rollback!!!"); + } + + public Course createWithCheckedException(final Course entity) throws SQLException { + throw new SQLException("Throwing exception for demoing Rollback!!!"); + } +} diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseService.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseService.java new file mode 100644 index 0000000000..1478c5bd1d --- /dev/null +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseService.java @@ -0,0 +1,38 @@ +package com.baeldung.spring.transaction; + +import java.sql.SQLException; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; + +@Service +public class CourseService { + + @Autowired + private CourseDao courseDao; + + @Transactional + public void createCourseDeclarativeWithRuntimeException(Course course) { + courseDao.createWithRuntimeException(course); + } + + @Transactional(rollbackFor = { SQLException.class }) + public void createCourseDeclarativeWithCheckedException(Course course) throws SQLException { + courseDao.createWithCheckedException(course); + } + + public void createCourseDefaultRatingProgramatic(Course course) { + try { + courseDao.createWithRuntimeException(course); + } catch (Exception e) { + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + } + } + + public Course findById(Long id) { + return courseDao.findOne(id); + } + +} From 4fb5e52080dba3d85df14737ba053c0d3ce21772 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 25 Dec 2020 22:41:37 +0530 Subject: [PATCH 141/361] JAVA-3506: removed moved modules from main pom --- pom.xml | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index ec5586a4ad..4dca7e76c7 100644 --- a/pom.xml +++ b/pom.xml @@ -606,9 +606,6 @@ spring-5-reactive-client spring-5-reactive-oauth spring-5-reactive-security - spring-5-security - spring-5-security-cognito - spring-5-security-oauth spring-5-webflux spring-activiti @@ -658,8 +655,6 @@ spring-kafka spring-katharsis - spring-ldap - spring-mobile spring-mockito @@ -693,11 +688,9 @@ spring-scheduling spring-security-modules - spring-session spring-shell spring-sleuth - spring-soap - spring-social-login + spring-soap spring-spel spring-state-machine spring-static-resources @@ -1092,9 +1085,6 @@ spring-5-reactive-client spring-5-reactive-oauth spring-5-reactive-security - spring-5-security - spring-5-security-cognito - spring-5-security-oauth spring-5-webflux spring-activiti @@ -1142,8 +1132,6 @@ spring-kafka spring-katharsis - spring-ldap - spring-mobile spring-mockito @@ -1177,11 +1165,9 @@ spring-scheduling spring-security-modules - spring-session spring-shell spring-sleuth spring-soap - spring-social-login spring-spel spring-state-machine spring-static-resources From 69e579debe498e3d9eea901fb5ba61f1c8400e13 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 25 Dec 2020 22:42:29 +0530 Subject: [PATCH 142/361] JAVA-3506: moved spring-5-security inside spring-security-modules --- .../spring-5-security}/README.md | 0 .../spring-5-security}/pom.xml | 2 +- .../java/com/baeldung/authresolver/AuthResolverApplication.java | 0 .../java/com/baeldung/authresolver/AuthResolverController.java | 0 .../com/baeldung/authresolver/CustomWebSecurityConfigurer.java | 0 .../java/com/baeldung/dsl/ClientErrorLoggingConfigurer.java | 0 .../main/java/com/baeldung/dsl/ClientErrorLoggingFilter.java | 0 .../main/java/com/baeldung/dsl/CustomConfigurerApplication.java | 0 .../src/main/java/com/baeldung/dsl/MyController.java | 0 .../src/main/java/com/baeldung/dsl/SecurityConfig.java | 0 .../java/com/baeldung/inmemory/InMemoryAuthApplication.java | 0 .../main/java/com/baeldung/inmemory/InMemoryAuthController.java | 0 .../baeldung/inmemory/InMemoryAuthWebSecurityConfigurer.java | 0 .../inmemory/InMemoryNoOpAuthWebSecurityConfigurer.java | 0 .../loginextrafieldscustom/CustomAuthenticationFilter.java | 0 .../loginextrafieldscustom/CustomAuthenticationToken.java | 0 .../CustomUserDetailsAuthenticationProvider.java | 0 .../loginextrafieldscustom/CustomUserDetailsService.java | 0 .../loginextrafieldscustom/CustomUserDetailsServiceImpl.java | 0 .../baeldung/loginextrafieldscustom/CustomUserRepository.java | 0 .../loginextrafieldscustom/ExtraLoginFieldsApplication.java | 0 .../loginextrafieldscustom/PasswordEncoderConfiguration.java | 0 .../com/baeldung/loginextrafieldscustom/SecurityConfig.java | 0 .../src/main/java/com/baeldung/loginextrafieldscustom/User.java | 0 .../com/baeldung/loginextrafieldscustom/UserRepository.java | 0 .../java/com/baeldung/loginextrafieldscustom/WebController.java | 0 .../loginextrafieldssimple/ExtraLoginFieldsApplication.java | 0 .../loginextrafieldssimple/PasswordEncoderConfiguration.java | 0 .../com/baeldung/loginextrafieldssimple/SecurityConfig.java | 0 .../loginextrafieldssimple/SimpleAuthenticationFilter.java | 0 .../loginextrafieldssimple/SimpleUserDetailsService.java | 0 .../baeldung/loginextrafieldssimple/SimpleUserRepository.java | 0 .../src/main/java/com/baeldung/loginextrafieldssimple/User.java | 0 .../com/baeldung/loginextrafieldssimple/UserRepository.java | 0 .../java/com/baeldung/loginextrafieldssimple/WebController.java | 0 .../java/com/baeldung/logoutredirects/LogoutApplication.java | 0 .../logoutredirects/securityconfig/SpringSecurityConfig.java | 0 .../java/com/baeldung/manuallogout/ManualLogoutApplication.java | 0 .../com/baeldung/manuallogout/SimpleSecurityConfiguration.java | 0 .../baeldung/passwordstorage/BaeldungPasswordEncoderSetup.java | 0 .../baeldung/passwordstorage/PasswordStorageApplication.java | 0 .../passwordstorage/PasswordStorageWebSecurityConfigurer.java | 0 .../src/main/java/com/baeldung/securityprofile/Application.java | 0 .../com/baeldung/securityprofile/ApplicationNoSecurity.java | 0 .../java/com/baeldung/securityprofile/ApplicationSecurity.java | 0 .../java/com/baeldung/securityprofile/EmployeeController.java | 0 .../src/main/resources/application-extrafields.properties | 0 .../src/main/resources/application.properties | 0 .../spring-5-security}/src/main/resources/logback.xml | 0 .../spring-5-security}/src/main/resources/static/css/main.css | 0 .../spring-5-security}/src/main/resources/templates/index.html | 0 .../src/main/resources/templatesextrafields/index.html | 0 .../src/main/resources/templatesextrafields/login.html | 0 .../src/main/resources/templatesextrafields/user/index.html | 0 .../src/test/java/com/baeldung/SpringContextTest.java | 0 .../com/baeldung/authresolver/AuthResolverIntegrationTest.java | 0 .../inmemory/InMemoryAuthControllerIntegrationTest.java | 0 .../AbstractExtraLoginFieldsIntegrationTest.java | 0 .../loginextrafields/LoginFieldsFullIntegrationTest.java | 0 .../loginextrafields/LoginFieldsSimpleIntegrationTest.java | 0 .../com/baeldung/logoutredirects/LogoutApplicationUnitTest.java | 0 .../com/baeldung/manuallogout/ManualLogoutIntegrationTest.java | 0 .../securityprofile/EmployeeControllerNoSecurityUnitTest.java | 0 .../baeldung/securityprofile/EmployeeControllerUnitTest.java | 0 64 files changed, 1 insertion(+), 1 deletion(-) rename {spring-5-security => spring-security-modules/spring-5-security}/README.md (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/pom.xml (97%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/authresolver/AuthResolverApplication.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/authresolver/AuthResolverController.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/authresolver/CustomWebSecurityConfigurer.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/dsl/ClientErrorLoggingConfigurer.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/dsl/ClientErrorLoggingFilter.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/dsl/CustomConfigurerApplication.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/dsl/MyController.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/dsl/SecurityConfig.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/inmemory/InMemoryAuthApplication.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/inmemory/InMemoryAuthController.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/inmemory/InMemoryAuthWebSecurityConfigurer.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/inmemory/InMemoryNoOpAuthWebSecurityConfigurer.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldscustom/CustomAuthenticationFilter.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldscustom/CustomAuthenticationToken.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserDetailsAuthenticationProvider.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserDetailsService.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserDetailsServiceImpl.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserRepository.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldscustom/ExtraLoginFieldsApplication.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldscustom/PasswordEncoderConfiguration.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldscustom/SecurityConfig.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldscustom/User.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldscustom/UserRepository.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldscustom/WebController.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldssimple/ExtraLoginFieldsApplication.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldssimple/PasswordEncoderConfiguration.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldssimple/SecurityConfig.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldssimple/SimpleAuthenticationFilter.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldssimple/SimpleUserDetailsService.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldssimple/SimpleUserRepository.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldssimple/User.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldssimple/UserRepository.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/loginextrafieldssimple/WebController.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/logoutredirects/LogoutApplication.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/logoutredirects/securityconfig/SpringSecurityConfig.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/manuallogout/ManualLogoutApplication.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/passwordstorage/BaeldungPasswordEncoderSetup.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/passwordstorage/PasswordStorageApplication.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/passwordstorage/PasswordStorageWebSecurityConfigurer.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/securityprofile/Application.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/securityprofile/ApplicationNoSecurity.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/securityprofile/ApplicationSecurity.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/java/com/baeldung/securityprofile/EmployeeController.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/resources/application-extrafields.properties (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/resources/application.properties (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/resources/logback.xml (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/resources/static/css/main.css (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/resources/templates/index.html (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/resources/templatesextrafields/index.html (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/resources/templatesextrafields/login.html (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/main/resources/templatesextrafields/user/index.html (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/test/java/com/baeldung/SpringContextTest.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/test/java/com/baeldung/authresolver/AuthResolverIntegrationTest.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/test/java/com/baeldung/inmemory/InMemoryAuthControllerIntegrationTest.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/test/java/com/baeldung/loginextrafields/AbstractExtraLoginFieldsIntegrationTest.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/test/java/com/baeldung/loginextrafields/LoginFieldsFullIntegrationTest.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/test/java/com/baeldung/loginextrafields/LoginFieldsSimpleIntegrationTest.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/test/java/com/baeldung/logoutredirects/LogoutApplicationUnitTest.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/test/java/com/baeldung/securityprofile/EmployeeControllerNoSecurityUnitTest.java (100%) rename {spring-5-security => spring-security-modules/spring-5-security}/src/test/java/com/baeldung/securityprofile/EmployeeControllerUnitTest.java (100%) diff --git a/spring-5-security/README.md b/spring-security-modules/spring-5-security/README.md similarity index 100% rename from spring-5-security/README.md rename to spring-security-modules/spring-5-security/README.md diff --git a/spring-5-security/pom.xml b/spring-security-modules/spring-5-security/pom.xml similarity index 97% rename from spring-5-security/pom.xml rename to spring-security-modules/spring-5-security/pom.xml index c486d5346b..09de91491c 100644 --- a/spring-5-security/pom.xml +++ b/spring-security-modules/spring-5-security/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-5-security/src/main/java/com/baeldung/authresolver/AuthResolverApplication.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/authresolver/AuthResolverApplication.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/authresolver/AuthResolverApplication.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/authresolver/AuthResolverApplication.java diff --git a/spring-5-security/src/main/java/com/baeldung/authresolver/AuthResolverController.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/authresolver/AuthResolverController.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/authresolver/AuthResolverController.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/authresolver/AuthResolverController.java diff --git a/spring-5-security/src/main/java/com/baeldung/authresolver/CustomWebSecurityConfigurer.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/authresolver/CustomWebSecurityConfigurer.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/authresolver/CustomWebSecurityConfigurer.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/authresolver/CustomWebSecurityConfigurer.java diff --git a/spring-5-security/src/main/java/com/baeldung/dsl/ClientErrorLoggingConfigurer.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/dsl/ClientErrorLoggingConfigurer.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/dsl/ClientErrorLoggingConfigurer.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/dsl/ClientErrorLoggingConfigurer.java diff --git a/spring-5-security/src/main/java/com/baeldung/dsl/ClientErrorLoggingFilter.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/dsl/ClientErrorLoggingFilter.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/dsl/ClientErrorLoggingFilter.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/dsl/ClientErrorLoggingFilter.java diff --git a/spring-5-security/src/main/java/com/baeldung/dsl/CustomConfigurerApplication.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/dsl/CustomConfigurerApplication.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/dsl/CustomConfigurerApplication.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/dsl/CustomConfigurerApplication.java diff --git a/spring-5-security/src/main/java/com/baeldung/dsl/MyController.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/dsl/MyController.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/dsl/MyController.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/dsl/MyController.java diff --git a/spring-5-security/src/main/java/com/baeldung/dsl/SecurityConfig.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/dsl/SecurityConfig.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/dsl/SecurityConfig.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/dsl/SecurityConfig.java diff --git a/spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryAuthApplication.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryAuthApplication.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryAuthApplication.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryAuthApplication.java diff --git a/spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryAuthController.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryAuthController.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryAuthController.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryAuthController.java diff --git a/spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryAuthWebSecurityConfigurer.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryAuthWebSecurityConfigurer.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryAuthWebSecurityConfigurer.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryAuthWebSecurityConfigurer.java diff --git a/spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryNoOpAuthWebSecurityConfigurer.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryNoOpAuthWebSecurityConfigurer.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryNoOpAuthWebSecurityConfigurer.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/inmemory/InMemoryNoOpAuthWebSecurityConfigurer.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomAuthenticationFilter.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomAuthenticationFilter.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomAuthenticationFilter.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomAuthenticationFilter.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomAuthenticationToken.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomAuthenticationToken.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomAuthenticationToken.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomAuthenticationToken.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserDetailsAuthenticationProvider.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserDetailsAuthenticationProvider.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserDetailsAuthenticationProvider.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserDetailsAuthenticationProvider.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserDetailsService.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserDetailsService.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserDetailsService.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserDetailsService.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserDetailsServiceImpl.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserDetailsServiceImpl.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserDetailsServiceImpl.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserDetailsServiceImpl.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserRepository.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserRepository.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserRepository.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/CustomUserRepository.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/ExtraLoginFieldsApplication.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/ExtraLoginFieldsApplication.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/ExtraLoginFieldsApplication.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/ExtraLoginFieldsApplication.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/PasswordEncoderConfiguration.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/PasswordEncoderConfiguration.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/PasswordEncoderConfiguration.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/PasswordEncoderConfiguration.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/SecurityConfig.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/SecurityConfig.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/SecurityConfig.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/SecurityConfig.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/User.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/User.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/User.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/User.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/UserRepository.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/UserRepository.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/UserRepository.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/UserRepository.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/WebController.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/WebController.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/WebController.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldscustom/WebController.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/ExtraLoginFieldsApplication.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/ExtraLoginFieldsApplication.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/ExtraLoginFieldsApplication.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/ExtraLoginFieldsApplication.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/PasswordEncoderConfiguration.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/PasswordEncoderConfiguration.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/PasswordEncoderConfiguration.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/PasswordEncoderConfiguration.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/SecurityConfig.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/SecurityConfig.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/SecurityConfig.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/SecurityConfig.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/SimpleAuthenticationFilter.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/SimpleAuthenticationFilter.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/SimpleAuthenticationFilter.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/SimpleAuthenticationFilter.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/SimpleUserDetailsService.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/SimpleUserDetailsService.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/SimpleUserDetailsService.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/SimpleUserDetailsService.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/SimpleUserRepository.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/SimpleUserRepository.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/SimpleUserRepository.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/SimpleUserRepository.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/User.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/User.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/User.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/User.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/UserRepository.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/UserRepository.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/UserRepository.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/UserRepository.java diff --git a/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/WebController.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/WebController.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/WebController.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/loginextrafieldssimple/WebController.java diff --git a/spring-5-security/src/main/java/com/baeldung/logoutredirects/LogoutApplication.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/logoutredirects/LogoutApplication.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/logoutredirects/LogoutApplication.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/logoutredirects/LogoutApplication.java diff --git a/spring-5-security/src/main/java/com/baeldung/logoutredirects/securityconfig/SpringSecurityConfig.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/logoutredirects/securityconfig/SpringSecurityConfig.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/logoutredirects/securityconfig/SpringSecurityConfig.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/logoutredirects/securityconfig/SpringSecurityConfig.java diff --git a/spring-5-security/src/main/java/com/baeldung/manuallogout/ManualLogoutApplication.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/manuallogout/ManualLogoutApplication.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/manuallogout/ManualLogoutApplication.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/manuallogout/ManualLogoutApplication.java diff --git a/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java diff --git a/spring-5-security/src/main/java/com/baeldung/passwordstorage/BaeldungPasswordEncoderSetup.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/passwordstorage/BaeldungPasswordEncoderSetup.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/passwordstorage/BaeldungPasswordEncoderSetup.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/passwordstorage/BaeldungPasswordEncoderSetup.java diff --git a/spring-5-security/src/main/java/com/baeldung/passwordstorage/PasswordStorageApplication.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/passwordstorage/PasswordStorageApplication.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/passwordstorage/PasswordStorageApplication.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/passwordstorage/PasswordStorageApplication.java diff --git a/spring-5-security/src/main/java/com/baeldung/passwordstorage/PasswordStorageWebSecurityConfigurer.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/passwordstorage/PasswordStorageWebSecurityConfigurer.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/passwordstorage/PasswordStorageWebSecurityConfigurer.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/passwordstorage/PasswordStorageWebSecurityConfigurer.java diff --git a/spring-5-security/src/main/java/com/baeldung/securityprofile/Application.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/securityprofile/Application.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/securityprofile/Application.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/securityprofile/Application.java diff --git a/spring-5-security/src/main/java/com/baeldung/securityprofile/ApplicationNoSecurity.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/securityprofile/ApplicationNoSecurity.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/securityprofile/ApplicationNoSecurity.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/securityprofile/ApplicationNoSecurity.java diff --git a/spring-5-security/src/main/java/com/baeldung/securityprofile/ApplicationSecurity.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/securityprofile/ApplicationSecurity.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/securityprofile/ApplicationSecurity.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/securityprofile/ApplicationSecurity.java diff --git a/spring-5-security/src/main/java/com/baeldung/securityprofile/EmployeeController.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/securityprofile/EmployeeController.java similarity index 100% rename from spring-5-security/src/main/java/com/baeldung/securityprofile/EmployeeController.java rename to spring-security-modules/spring-5-security/src/main/java/com/baeldung/securityprofile/EmployeeController.java diff --git a/spring-5-security/src/main/resources/application-extrafields.properties b/spring-security-modules/spring-5-security/src/main/resources/application-extrafields.properties similarity index 100% rename from spring-5-security/src/main/resources/application-extrafields.properties rename to spring-security-modules/spring-5-security/src/main/resources/application-extrafields.properties diff --git a/spring-5-security/src/main/resources/application.properties b/spring-security-modules/spring-5-security/src/main/resources/application.properties similarity index 100% rename from spring-5-security/src/main/resources/application.properties rename to spring-security-modules/spring-5-security/src/main/resources/application.properties diff --git a/spring-5-security/src/main/resources/logback.xml b/spring-security-modules/spring-5-security/src/main/resources/logback.xml similarity index 100% rename from spring-5-security/src/main/resources/logback.xml rename to spring-security-modules/spring-5-security/src/main/resources/logback.xml diff --git a/spring-5-security/src/main/resources/static/css/main.css b/spring-security-modules/spring-5-security/src/main/resources/static/css/main.css similarity index 100% rename from spring-5-security/src/main/resources/static/css/main.css rename to spring-security-modules/spring-5-security/src/main/resources/static/css/main.css diff --git a/spring-5-security/src/main/resources/templates/index.html b/spring-security-modules/spring-5-security/src/main/resources/templates/index.html similarity index 100% rename from spring-5-security/src/main/resources/templates/index.html rename to spring-security-modules/spring-5-security/src/main/resources/templates/index.html diff --git a/spring-5-security/src/main/resources/templatesextrafields/index.html b/spring-security-modules/spring-5-security/src/main/resources/templatesextrafields/index.html similarity index 100% rename from spring-5-security/src/main/resources/templatesextrafields/index.html rename to spring-security-modules/spring-5-security/src/main/resources/templatesextrafields/index.html diff --git a/spring-5-security/src/main/resources/templatesextrafields/login.html b/spring-security-modules/spring-5-security/src/main/resources/templatesextrafields/login.html similarity index 100% rename from spring-5-security/src/main/resources/templatesextrafields/login.html rename to spring-security-modules/spring-5-security/src/main/resources/templatesextrafields/login.html diff --git a/spring-5-security/src/main/resources/templatesextrafields/user/index.html b/spring-security-modules/spring-5-security/src/main/resources/templatesextrafields/user/index.html similarity index 100% rename from spring-5-security/src/main/resources/templatesextrafields/user/index.html rename to spring-security-modules/spring-5-security/src/main/resources/templatesextrafields/user/index.html diff --git a/spring-5-security/src/test/java/com/baeldung/SpringContextTest.java b/spring-security-modules/spring-5-security/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-5-security/src/test/java/com/baeldung/SpringContextTest.java rename to spring-security-modules/spring-5-security/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-5-security/src/test/java/com/baeldung/authresolver/AuthResolverIntegrationTest.java b/spring-security-modules/spring-5-security/src/test/java/com/baeldung/authresolver/AuthResolverIntegrationTest.java similarity index 100% rename from spring-5-security/src/test/java/com/baeldung/authresolver/AuthResolverIntegrationTest.java rename to spring-security-modules/spring-5-security/src/test/java/com/baeldung/authresolver/AuthResolverIntegrationTest.java diff --git a/spring-5-security/src/test/java/com/baeldung/inmemory/InMemoryAuthControllerIntegrationTest.java b/spring-security-modules/spring-5-security/src/test/java/com/baeldung/inmemory/InMemoryAuthControllerIntegrationTest.java similarity index 100% rename from spring-5-security/src/test/java/com/baeldung/inmemory/InMemoryAuthControllerIntegrationTest.java rename to spring-security-modules/spring-5-security/src/test/java/com/baeldung/inmemory/InMemoryAuthControllerIntegrationTest.java diff --git a/spring-5-security/src/test/java/com/baeldung/loginextrafields/AbstractExtraLoginFieldsIntegrationTest.java b/spring-security-modules/spring-5-security/src/test/java/com/baeldung/loginextrafields/AbstractExtraLoginFieldsIntegrationTest.java similarity index 100% rename from spring-5-security/src/test/java/com/baeldung/loginextrafields/AbstractExtraLoginFieldsIntegrationTest.java rename to spring-security-modules/spring-5-security/src/test/java/com/baeldung/loginextrafields/AbstractExtraLoginFieldsIntegrationTest.java diff --git a/spring-5-security/src/test/java/com/baeldung/loginextrafields/LoginFieldsFullIntegrationTest.java b/spring-security-modules/spring-5-security/src/test/java/com/baeldung/loginextrafields/LoginFieldsFullIntegrationTest.java similarity index 100% rename from spring-5-security/src/test/java/com/baeldung/loginextrafields/LoginFieldsFullIntegrationTest.java rename to spring-security-modules/spring-5-security/src/test/java/com/baeldung/loginextrafields/LoginFieldsFullIntegrationTest.java diff --git a/spring-5-security/src/test/java/com/baeldung/loginextrafields/LoginFieldsSimpleIntegrationTest.java b/spring-security-modules/spring-5-security/src/test/java/com/baeldung/loginextrafields/LoginFieldsSimpleIntegrationTest.java similarity index 100% rename from spring-5-security/src/test/java/com/baeldung/loginextrafields/LoginFieldsSimpleIntegrationTest.java rename to spring-security-modules/spring-5-security/src/test/java/com/baeldung/loginextrafields/LoginFieldsSimpleIntegrationTest.java diff --git a/spring-5-security/src/test/java/com/baeldung/logoutredirects/LogoutApplicationUnitTest.java b/spring-security-modules/spring-5-security/src/test/java/com/baeldung/logoutredirects/LogoutApplicationUnitTest.java similarity index 100% rename from spring-5-security/src/test/java/com/baeldung/logoutredirects/LogoutApplicationUnitTest.java rename to spring-security-modules/spring-5-security/src/test/java/com/baeldung/logoutredirects/LogoutApplicationUnitTest.java diff --git a/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java b/spring-security-modules/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java similarity index 100% rename from spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java rename to spring-security-modules/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java diff --git a/spring-5-security/src/test/java/com/baeldung/securityprofile/EmployeeControllerNoSecurityUnitTest.java b/spring-security-modules/spring-5-security/src/test/java/com/baeldung/securityprofile/EmployeeControllerNoSecurityUnitTest.java similarity index 100% rename from spring-5-security/src/test/java/com/baeldung/securityprofile/EmployeeControllerNoSecurityUnitTest.java rename to spring-security-modules/spring-5-security/src/test/java/com/baeldung/securityprofile/EmployeeControllerNoSecurityUnitTest.java diff --git a/spring-5-security/src/test/java/com/baeldung/securityprofile/EmployeeControllerUnitTest.java b/spring-security-modules/spring-5-security/src/test/java/com/baeldung/securityprofile/EmployeeControllerUnitTest.java similarity index 100% rename from spring-5-security/src/test/java/com/baeldung/securityprofile/EmployeeControllerUnitTest.java rename to spring-security-modules/spring-5-security/src/test/java/com/baeldung/securityprofile/EmployeeControllerUnitTest.java From 3880907db1e077345246556b503283177441e6cc Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 25 Dec 2020 22:42:51 +0530 Subject: [PATCH 143/361] JAVA-3506: moved spring-5-security-cognito inside spring-security-modules --- .../spring-5-security-cognito}/README.md | 0 .../spring-5-security-cognito}/pom.xml | 2 +- .../main/java/com/baeldung/cognito/CognitoWebConfiguration.java | 0 .../main/java/com/baeldung/cognito/SecurityConfiguration.java | 0 .../java/com/baeldung/cognito/SpringCognitoApplication.java | 0 .../src/main/resources/application.yml | 0 .../spring-5-security-cognito}/src/main/resources/logback.xml | 0 .../src/main/resources/templates/home.html | 0 8 files changed, 1 insertion(+), 1 deletion(-) rename {spring-5-security-cognito => spring-security-modules/spring-5-security-cognito}/README.md (100%) rename {spring-5-security-cognito => spring-security-modules/spring-5-security-cognito}/pom.xml (97%) rename {spring-5-security-cognito => spring-security-modules/spring-5-security-cognito}/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java (100%) rename {spring-5-security-cognito => spring-security-modules/spring-5-security-cognito}/src/main/java/com/baeldung/cognito/SecurityConfiguration.java (100%) rename {spring-5-security-cognito => spring-security-modules/spring-5-security-cognito}/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java (100%) rename {spring-5-security-cognito => spring-security-modules/spring-5-security-cognito}/src/main/resources/application.yml (100%) rename {spring-5-security-cognito => spring-security-modules/spring-5-security-cognito}/src/main/resources/logback.xml (100%) rename {spring-5-security-cognito => spring-security-modules/spring-5-security-cognito}/src/main/resources/templates/home.html (100%) diff --git a/spring-5-security-cognito/README.md b/spring-security-modules/spring-5-security-cognito/README.md similarity index 100% rename from spring-5-security-cognito/README.md rename to spring-security-modules/spring-5-security-cognito/README.md diff --git a/spring-5-security-cognito/pom.xml b/spring-security-modules/spring-5-security-cognito/pom.xml similarity index 97% rename from spring-5-security-cognito/pom.xml rename to spring-security-modules/spring-5-security-cognito/pom.xml index 5f8f328086..877dbd52fa 100644 --- a/spring-5-security-cognito/pom.xml +++ b/spring-security-modules/spring-5-security-cognito/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-5-security-cognito/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java b/spring-security-modules/spring-5-security-cognito/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java similarity index 100% rename from spring-5-security-cognito/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java rename to spring-security-modules/spring-5-security-cognito/src/main/java/com/baeldung/cognito/CognitoWebConfiguration.java diff --git a/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SecurityConfiguration.java b/spring-security-modules/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SecurityConfiguration.java similarity index 100% rename from spring-5-security-cognito/src/main/java/com/baeldung/cognito/SecurityConfiguration.java rename to spring-security-modules/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SecurityConfiguration.java diff --git a/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java b/spring-security-modules/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java similarity index 100% rename from spring-5-security-cognito/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java rename to spring-security-modules/spring-5-security-cognito/src/main/java/com/baeldung/cognito/SpringCognitoApplication.java diff --git a/spring-5-security-cognito/src/main/resources/application.yml b/spring-security-modules/spring-5-security-cognito/src/main/resources/application.yml similarity index 100% rename from spring-5-security-cognito/src/main/resources/application.yml rename to spring-security-modules/spring-5-security-cognito/src/main/resources/application.yml diff --git a/spring-5-security-cognito/src/main/resources/logback.xml b/spring-security-modules/spring-5-security-cognito/src/main/resources/logback.xml similarity index 100% rename from spring-5-security-cognito/src/main/resources/logback.xml rename to spring-security-modules/spring-5-security-cognito/src/main/resources/logback.xml diff --git a/spring-5-security-cognito/src/main/resources/templates/home.html b/spring-security-modules/spring-5-security-cognito/src/main/resources/templates/home.html similarity index 100% rename from spring-5-security-cognito/src/main/resources/templates/home.html rename to spring-security-modules/spring-5-security-cognito/src/main/resources/templates/home.html From d7afc4a11b2ee728fa52ddf2c10e5b884d16544b Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 25 Dec 2020 22:43:12 +0530 Subject: [PATCH 144/361] JAVA-3506: moved spring-5-security-oauth inside spring-security-modules --- .../spring-5-security-oauth}/README.md | 0 .../spring-5-security-oauth}/pom.xml | 2 +- .../src/main/java/com/baeldung/jersey/JerseyApplication.java | 0 .../src/main/java/com/baeldung/jersey/JerseyResource.java | 0 .../src/main/java/com/baeldung/jersey/RestConfig.java | 0 .../src/main/java/com/baeldung/jersey/SecurityConfig.java | 0 .../java/com/baeldung/oauth2/CustomRequestSecurityConfig.java | 0 .../src/main/java/com/baeldung/oauth2/LoginController.java | 0 .../src/main/java/com/baeldung/oauth2/MvcConfig.java | 0 .../src/main/java/com/baeldung/oauth2/SecurityConfig.java | 0 .../main/java/com/baeldung/oauth2/SpringOAuthApplication.java | 0 .../com/baeldung/oauth2extractors/ExtractorsApplication.java | 0 .../baeldung/oauth2extractors/configuration/SecurityConfig.java | 0 .../extractor/custom/BaeldungAuthoritiesExtractor.java | 0 .../extractor/custom/BaeldungPrincipalExtractor.java | 0 .../extractor/github/GithubAuthoritiesExtractor.java | 0 .../extractor/github/GithubPrincipalExtractor.java | 0 .../oauth2request/CustomAuthorizationRequestResolver.java | 0 .../baeldung/oauth2request/CustomRequestEntityConverter.java | 0 .../baeldung/oauth2request/CustomTokenResponseConverter.java | 0 .../baeldung/oauth2request/LinkedinTokenResponseConverter.java | 0 .../resources/application-oauth2-extractors-baeldung.properties | 0 .../resources/application-oauth2-extractors-github.properties | 0 .../src/main/resources/application-oauth2.properties | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/default-application.properties | 0 .../src/main/resources/jersey-application.properties | 0 .../spring-5-security-oauth}/src/main/resources/logback.xml | 0 .../src/main/resources/static/css/main.css | 0 .../src/main/resources/templates/index.html | 0 .../src/main/resources/templates/loginFailure.html | 0 .../src/main/resources/templates/loginSuccess.html | 0 .../src/main/resources/templates/oauth2_extractors.html | 0 .../src/main/resources/templates/oauth_login.html | 0 .../src/main/resources/templates/securedPage.html | 0 .../test/java/com/baeldung/jersey/JerseyResourceUnitTest.java | 0 .../java/com/baeldung/oauth2extractors/ExtractorsUnitTest.java | 0 37 files changed, 1 insertion(+), 1 deletion(-) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/README.md (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/pom.xml (98%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/jersey/JerseyApplication.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/jersey/JerseyResource.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/jersey/RestConfig.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/jersey/SecurityConfig.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/oauth2/CustomRequestSecurityConfig.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/oauth2/LoginController.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/oauth2/MvcConfig.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/oauth2/SecurityConfig.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/oauth2/SpringOAuthApplication.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/oauth2extractors/ExtractorsApplication.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/oauth2extractors/configuration/SecurityConfig.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungAuthoritiesExtractor.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungPrincipalExtractor.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubAuthoritiesExtractor.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubPrincipalExtractor.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/oauth2request/CustomAuthorizationRequestResolver.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/oauth2request/CustomRequestEntityConverter.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/oauth2request/CustomTokenResponseConverter.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/java/com/baeldung/oauth2request/LinkedinTokenResponseConverter.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/resources/application-oauth2-extractors-baeldung.properties (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/resources/application-oauth2-extractors-github.properties (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/resources/application-oauth2.properties (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/resources/application.properties (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/resources/default-application.properties (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/resources/jersey-application.properties (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/resources/logback.xml (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/resources/static/css/main.css (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/resources/templates/index.html (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/resources/templates/loginFailure.html (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/resources/templates/loginSuccess.html (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/resources/templates/oauth2_extractors.html (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/resources/templates/oauth_login.html (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/main/resources/templates/securedPage.html (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/test/java/com/baeldung/jersey/JerseyResourceUnitTest.java (100%) rename {spring-5-security-oauth => spring-security-modules/spring-5-security-oauth}/src/test/java/com/baeldung/oauth2extractors/ExtractorsUnitTest.java (100%) diff --git a/spring-5-security-oauth/README.md b/spring-security-modules/spring-5-security-oauth/README.md similarity index 100% rename from spring-5-security-oauth/README.md rename to spring-security-modules/spring-5-security-oauth/README.md diff --git a/spring-5-security-oauth/pom.xml b/spring-security-modules/spring-5-security-oauth/pom.xml similarity index 98% rename from spring-5-security-oauth/pom.xml rename to spring-security-modules/spring-5-security-oauth/pom.xml index 19aaa576c8..d31cf293a3 100644 --- a/spring-5-security-oauth/pom.xml +++ b/spring-security-modules/spring-5-security-oauth/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-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyApplication.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyApplication.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyApplication.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyApplication.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyResource.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyResource.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyResource.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/jersey/JerseyResource.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/jersey/RestConfig.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/jersey/RestConfig.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/jersey/RestConfig.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/jersey/RestConfig.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/jersey/SecurityConfig.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/jersey/SecurityConfig.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/jersey/SecurityConfig.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/jersey/SecurityConfig.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/CustomRequestSecurityConfig.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/CustomRequestSecurityConfig.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/oauth2/CustomRequestSecurityConfig.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/CustomRequestSecurityConfig.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/LoginController.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/LoginController.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/oauth2/LoginController.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/LoginController.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/MvcConfig.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/MvcConfig.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/oauth2/MvcConfig.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/MvcConfig.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/SecurityConfig.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/SecurityConfig.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/oauth2/SecurityConfig.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/SecurityConfig.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/SpringOAuthApplication.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/SpringOAuthApplication.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/oauth2/SpringOAuthApplication.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2/SpringOAuthApplication.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/ExtractorsApplication.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/ExtractorsApplication.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/ExtractorsApplication.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/ExtractorsApplication.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/configuration/SecurityConfig.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/configuration/SecurityConfig.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/configuration/SecurityConfig.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/configuration/SecurityConfig.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungAuthoritiesExtractor.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungAuthoritiesExtractor.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungAuthoritiesExtractor.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungAuthoritiesExtractor.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungPrincipalExtractor.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungPrincipalExtractor.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungPrincipalExtractor.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/custom/BaeldungPrincipalExtractor.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubAuthoritiesExtractor.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubAuthoritiesExtractor.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubAuthoritiesExtractor.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubAuthoritiesExtractor.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubPrincipalExtractor.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubPrincipalExtractor.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubPrincipalExtractor.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2extractors/extractor/github/GithubPrincipalExtractor.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomAuthorizationRequestResolver.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomAuthorizationRequestResolver.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomAuthorizationRequestResolver.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomAuthorizationRequestResolver.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomRequestEntityConverter.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomRequestEntityConverter.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomRequestEntityConverter.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomRequestEntityConverter.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomTokenResponseConverter.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomTokenResponseConverter.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomTokenResponseConverter.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/CustomTokenResponseConverter.java diff --git a/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/LinkedinTokenResponseConverter.java b/spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/LinkedinTokenResponseConverter.java similarity index 100% rename from spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/LinkedinTokenResponseConverter.java rename to spring-security-modules/spring-5-security-oauth/src/main/java/com/baeldung/oauth2request/LinkedinTokenResponseConverter.java diff --git a/spring-5-security-oauth/src/main/resources/application-oauth2-extractors-baeldung.properties b/spring-security-modules/spring-5-security-oauth/src/main/resources/application-oauth2-extractors-baeldung.properties similarity index 100% rename from spring-5-security-oauth/src/main/resources/application-oauth2-extractors-baeldung.properties rename to spring-security-modules/spring-5-security-oauth/src/main/resources/application-oauth2-extractors-baeldung.properties diff --git a/spring-5-security-oauth/src/main/resources/application-oauth2-extractors-github.properties b/spring-security-modules/spring-5-security-oauth/src/main/resources/application-oauth2-extractors-github.properties similarity index 100% rename from spring-5-security-oauth/src/main/resources/application-oauth2-extractors-github.properties rename to spring-security-modules/spring-5-security-oauth/src/main/resources/application-oauth2-extractors-github.properties diff --git a/spring-5-security-oauth/src/main/resources/application-oauth2.properties b/spring-security-modules/spring-5-security-oauth/src/main/resources/application-oauth2.properties similarity index 100% rename from spring-5-security-oauth/src/main/resources/application-oauth2.properties rename to spring-security-modules/spring-5-security-oauth/src/main/resources/application-oauth2.properties diff --git a/spring-5-security-oauth/src/main/resources/application.properties b/spring-security-modules/spring-5-security-oauth/src/main/resources/application.properties similarity index 100% rename from spring-5-security-oauth/src/main/resources/application.properties rename to spring-security-modules/spring-5-security-oauth/src/main/resources/application.properties diff --git a/spring-5-security-oauth/src/main/resources/default-application.properties b/spring-security-modules/spring-5-security-oauth/src/main/resources/default-application.properties similarity index 100% rename from spring-5-security-oauth/src/main/resources/default-application.properties rename to spring-security-modules/spring-5-security-oauth/src/main/resources/default-application.properties diff --git a/spring-5-security-oauth/src/main/resources/jersey-application.properties b/spring-security-modules/spring-5-security-oauth/src/main/resources/jersey-application.properties similarity index 100% rename from spring-5-security-oauth/src/main/resources/jersey-application.properties rename to spring-security-modules/spring-5-security-oauth/src/main/resources/jersey-application.properties diff --git a/spring-5-security-oauth/src/main/resources/logback.xml b/spring-security-modules/spring-5-security-oauth/src/main/resources/logback.xml similarity index 100% rename from spring-5-security-oauth/src/main/resources/logback.xml rename to spring-security-modules/spring-5-security-oauth/src/main/resources/logback.xml diff --git a/spring-5-security-oauth/src/main/resources/static/css/main.css b/spring-security-modules/spring-5-security-oauth/src/main/resources/static/css/main.css similarity index 100% rename from spring-5-security-oauth/src/main/resources/static/css/main.css rename to spring-security-modules/spring-5-security-oauth/src/main/resources/static/css/main.css diff --git a/spring-5-security-oauth/src/main/resources/templates/index.html b/spring-security-modules/spring-5-security-oauth/src/main/resources/templates/index.html similarity index 100% rename from spring-5-security-oauth/src/main/resources/templates/index.html rename to spring-security-modules/spring-5-security-oauth/src/main/resources/templates/index.html diff --git a/spring-5-security-oauth/src/main/resources/templates/loginFailure.html b/spring-security-modules/spring-5-security-oauth/src/main/resources/templates/loginFailure.html similarity index 100% rename from spring-5-security-oauth/src/main/resources/templates/loginFailure.html rename to spring-security-modules/spring-5-security-oauth/src/main/resources/templates/loginFailure.html diff --git a/spring-5-security-oauth/src/main/resources/templates/loginSuccess.html b/spring-security-modules/spring-5-security-oauth/src/main/resources/templates/loginSuccess.html similarity index 100% rename from spring-5-security-oauth/src/main/resources/templates/loginSuccess.html rename to spring-security-modules/spring-5-security-oauth/src/main/resources/templates/loginSuccess.html diff --git a/spring-5-security-oauth/src/main/resources/templates/oauth2_extractors.html b/spring-security-modules/spring-5-security-oauth/src/main/resources/templates/oauth2_extractors.html similarity index 100% rename from spring-5-security-oauth/src/main/resources/templates/oauth2_extractors.html rename to spring-security-modules/spring-5-security-oauth/src/main/resources/templates/oauth2_extractors.html diff --git a/spring-5-security-oauth/src/main/resources/templates/oauth_login.html b/spring-security-modules/spring-5-security-oauth/src/main/resources/templates/oauth_login.html similarity index 100% rename from spring-5-security-oauth/src/main/resources/templates/oauth_login.html rename to spring-security-modules/spring-5-security-oauth/src/main/resources/templates/oauth_login.html diff --git a/spring-5-security-oauth/src/main/resources/templates/securedPage.html b/spring-security-modules/spring-5-security-oauth/src/main/resources/templates/securedPage.html similarity index 100% rename from spring-5-security-oauth/src/main/resources/templates/securedPage.html rename to spring-security-modules/spring-5-security-oauth/src/main/resources/templates/securedPage.html diff --git a/spring-5-security-oauth/src/test/java/com/baeldung/jersey/JerseyResourceUnitTest.java b/spring-security-modules/spring-5-security-oauth/src/test/java/com/baeldung/jersey/JerseyResourceUnitTest.java similarity index 100% rename from spring-5-security-oauth/src/test/java/com/baeldung/jersey/JerseyResourceUnitTest.java rename to spring-security-modules/spring-5-security-oauth/src/test/java/com/baeldung/jersey/JerseyResourceUnitTest.java diff --git a/spring-5-security-oauth/src/test/java/com/baeldung/oauth2extractors/ExtractorsUnitTest.java b/spring-security-modules/spring-5-security-oauth/src/test/java/com/baeldung/oauth2extractors/ExtractorsUnitTest.java similarity index 100% rename from spring-5-security-oauth/src/test/java/com/baeldung/oauth2extractors/ExtractorsUnitTest.java rename to spring-security-modules/spring-5-security-oauth/src/test/java/com/baeldung/oauth2extractors/ExtractorsUnitTest.java From cca9e25a42f05ebf6f57a53aacc297623acd8c89 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 25 Dec 2020 22:43:37 +0530 Subject: [PATCH 145/361] JAVA-3506: moved spring-ldap inside spring-security-modules --- .../spring-ldap}/.gitignore | 0 .../spring-ldap}/README.md | 0 {spring-ldap => spring-security-modules/spring-ldap}/pom.xml | 4 ++-- .../src/main/java/com/baeldung/ldap/client/LdapClient.java | 0 .../src/main/java/com/baeldung/ldap/data/repository/User.java | 0 .../com/baeldung/ldap/data/repository/UserRepository.java | 0 .../main/java/com/baeldung/ldap/data/service/LdapClient.java | 0 .../main/java/com/baeldung/ldap/data/service/UserService.java | 0 .../src/main/java/com/baeldung/ldap/javaconfig/AppConfig.java | 0 .../spring-ldap}/src/main/resources/application.properties | 0 .../spring-ldap}/src/main/resources/logback.xml | 0 .../java/com/baeldung/ldap/client/LdapClientLiveTest.java | 0 .../ldap/client/LdapDataRepositoryIntegrationTest.java | 0 .../test/java/com/baeldung/ldap/javaconfig/TestConfig.java | 0 .../src/test/java/org/baeldung/SpringContextTest.java | 0 .../spring-ldap}/src/test/resources/test.ldif | 0 .../src/test/resources/test_application.properties | 0 17 files changed, 2 insertions(+), 2 deletions(-) rename {spring-ldap => spring-security-modules/spring-ldap}/.gitignore (100%) rename {spring-ldap => spring-security-modules/spring-ldap}/README.md (100%) rename {spring-ldap => spring-security-modules/spring-ldap}/pom.xml (98%) rename {spring-ldap => spring-security-modules/spring-ldap}/src/main/java/com/baeldung/ldap/client/LdapClient.java (100%) rename {spring-ldap => spring-security-modules/spring-ldap}/src/main/java/com/baeldung/ldap/data/repository/User.java (100%) rename {spring-ldap => spring-security-modules/spring-ldap}/src/main/java/com/baeldung/ldap/data/repository/UserRepository.java (100%) rename {spring-ldap => spring-security-modules/spring-ldap}/src/main/java/com/baeldung/ldap/data/service/LdapClient.java (100%) rename {spring-ldap => spring-security-modules/spring-ldap}/src/main/java/com/baeldung/ldap/data/service/UserService.java (100%) rename {spring-ldap => spring-security-modules/spring-ldap}/src/main/java/com/baeldung/ldap/javaconfig/AppConfig.java (100%) rename {spring-ldap => spring-security-modules/spring-ldap}/src/main/resources/application.properties (100%) rename {spring-ldap => spring-security-modules/spring-ldap}/src/main/resources/logback.xml (100%) rename {spring-ldap => spring-security-modules/spring-ldap}/src/test/java/com/baeldung/ldap/client/LdapClientLiveTest.java (100%) rename {spring-ldap => spring-security-modules/spring-ldap}/src/test/java/com/baeldung/ldap/client/LdapDataRepositoryIntegrationTest.java (100%) rename {spring-ldap => spring-security-modules/spring-ldap}/src/test/java/com/baeldung/ldap/javaconfig/TestConfig.java (100%) rename {spring-ldap => spring-security-modules/spring-ldap}/src/test/java/org/baeldung/SpringContextTest.java (100%) rename {spring-ldap => spring-security-modules/spring-ldap}/src/test/resources/test.ldif (100%) rename {spring-ldap => spring-security-modules/spring-ldap}/src/test/resources/test_application.properties (100%) diff --git a/spring-ldap/.gitignore b/spring-security-modules/spring-ldap/.gitignore similarity index 100% rename from spring-ldap/.gitignore rename to spring-security-modules/spring-ldap/.gitignore diff --git a/spring-ldap/README.md b/spring-security-modules/spring-ldap/README.md similarity index 100% rename from spring-ldap/README.md rename to spring-security-modules/spring-ldap/README.md diff --git a/spring-ldap/pom.xml b/spring-security-modules/spring-ldap/pom.xml similarity index 98% rename from spring-ldap/pom.xml rename to spring-security-modules/spring-ldap/pom.xml index a9882ccb52..60da7d4c0d 100644 --- a/spring-ldap/pom.xml +++ b/spring-security-modules/spring-ldap/pom.xml @@ -9,8 +9,8 @@ com.baeldung - parent-modules - 1.0.0-SNAPSHOT + spring-security-modules + 0.0.1-SNAPSHOT diff --git a/spring-ldap/src/main/java/com/baeldung/ldap/client/LdapClient.java b/spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/client/LdapClient.java similarity index 100% rename from spring-ldap/src/main/java/com/baeldung/ldap/client/LdapClient.java rename to spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/client/LdapClient.java diff --git a/spring-ldap/src/main/java/com/baeldung/ldap/data/repository/User.java b/spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/data/repository/User.java similarity index 100% rename from spring-ldap/src/main/java/com/baeldung/ldap/data/repository/User.java rename to spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/data/repository/User.java diff --git a/spring-ldap/src/main/java/com/baeldung/ldap/data/repository/UserRepository.java b/spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/data/repository/UserRepository.java similarity index 100% rename from spring-ldap/src/main/java/com/baeldung/ldap/data/repository/UserRepository.java rename to spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/data/repository/UserRepository.java diff --git a/spring-ldap/src/main/java/com/baeldung/ldap/data/service/LdapClient.java b/spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/data/service/LdapClient.java similarity index 100% rename from spring-ldap/src/main/java/com/baeldung/ldap/data/service/LdapClient.java rename to spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/data/service/LdapClient.java diff --git a/spring-ldap/src/main/java/com/baeldung/ldap/data/service/UserService.java b/spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/data/service/UserService.java similarity index 100% rename from spring-ldap/src/main/java/com/baeldung/ldap/data/service/UserService.java rename to spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/data/service/UserService.java diff --git a/spring-ldap/src/main/java/com/baeldung/ldap/javaconfig/AppConfig.java b/spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/javaconfig/AppConfig.java similarity index 100% rename from spring-ldap/src/main/java/com/baeldung/ldap/javaconfig/AppConfig.java rename to spring-security-modules/spring-ldap/src/main/java/com/baeldung/ldap/javaconfig/AppConfig.java diff --git a/spring-ldap/src/main/resources/application.properties b/spring-security-modules/spring-ldap/src/main/resources/application.properties similarity index 100% rename from spring-ldap/src/main/resources/application.properties rename to spring-security-modules/spring-ldap/src/main/resources/application.properties diff --git a/spring-ldap/src/main/resources/logback.xml b/spring-security-modules/spring-ldap/src/main/resources/logback.xml similarity index 100% rename from spring-ldap/src/main/resources/logback.xml rename to spring-security-modules/spring-ldap/src/main/resources/logback.xml diff --git a/spring-ldap/src/test/java/com/baeldung/ldap/client/LdapClientLiveTest.java b/spring-security-modules/spring-ldap/src/test/java/com/baeldung/ldap/client/LdapClientLiveTest.java similarity index 100% rename from spring-ldap/src/test/java/com/baeldung/ldap/client/LdapClientLiveTest.java rename to spring-security-modules/spring-ldap/src/test/java/com/baeldung/ldap/client/LdapClientLiveTest.java diff --git a/spring-ldap/src/test/java/com/baeldung/ldap/client/LdapDataRepositoryIntegrationTest.java b/spring-security-modules/spring-ldap/src/test/java/com/baeldung/ldap/client/LdapDataRepositoryIntegrationTest.java similarity index 100% rename from spring-ldap/src/test/java/com/baeldung/ldap/client/LdapDataRepositoryIntegrationTest.java rename to spring-security-modules/spring-ldap/src/test/java/com/baeldung/ldap/client/LdapDataRepositoryIntegrationTest.java diff --git a/spring-ldap/src/test/java/com/baeldung/ldap/javaconfig/TestConfig.java b/spring-security-modules/spring-ldap/src/test/java/com/baeldung/ldap/javaconfig/TestConfig.java similarity index 100% rename from spring-ldap/src/test/java/com/baeldung/ldap/javaconfig/TestConfig.java rename to spring-security-modules/spring-ldap/src/test/java/com/baeldung/ldap/javaconfig/TestConfig.java diff --git a/spring-ldap/src/test/java/org/baeldung/SpringContextTest.java b/spring-security-modules/spring-ldap/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-ldap/src/test/java/org/baeldung/SpringContextTest.java rename to spring-security-modules/spring-ldap/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-ldap/src/test/resources/test.ldif b/spring-security-modules/spring-ldap/src/test/resources/test.ldif similarity index 100% rename from spring-ldap/src/test/resources/test.ldif rename to spring-security-modules/spring-ldap/src/test/resources/test.ldif diff --git a/spring-ldap/src/test/resources/test_application.properties b/spring-security-modules/spring-ldap/src/test/resources/test_application.properties similarity index 100% rename from spring-ldap/src/test/resources/test_application.properties rename to spring-security-modules/spring-ldap/src/test/resources/test_application.properties From c6f3d465d5d27038911918f0bbfb9a0e0b3ad474 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 25 Dec 2020 22:44:02 +0530 Subject: [PATCH 146/361] JAVA-3506: moved spring-session inside spring-security-modules --- .../spring-session}/README.md | 0 .../spring-session}/pom.xml | 2 +- .../spring-session}/spring-session-jdbc/README.md | 0 .../spring-session}/spring-session-jdbc/pom.xml | 2 +- .../springsessionjdbc/SpringSessionJdbcApplication.java | 0 .../controller/SpringSessionJdbcController.java | 0 .../src/main/resources/application.properties | 0 .../spring-session-jdbc/src/main/resources/logback.xml | 0 .../src/test/java/com/baeldung/SpringContextTest.java | 0 .../springsessionjdbc/SpringSessionJdbcIntegrationTest.java | 0 .../spring-session}/spring-session-mongodb/README.md | 0 .../spring-session}/spring-session-mongodb/pom.xml | 2 +- .../springsessionmongodb/SpringSessionMongoDBApplication.java | 0 .../controller/SpringSessionMongoDBController.java | 0 .../src/main/resources/application.properties | 0 .../spring-session-mongodb/src/main/resources/logback.xml | 0 .../src/test/java/com/baeldung/SpringContextTest.java | 0 .../SpringSessionMongoDBIntegrationTest.java | 0 .../src/test/resources/application.properties | 0 .../spring-session}/spring-session-redis/README.md | 0 .../spring-session}/spring-session-redis/pom.xml | 2 +- .../main/java/com/baeldung/spring/session/SecurityConfig.java | 0 .../java/com/baeldung/spring/session/SessionController.java | 0 .../java/com/baeldung/spring/session/SessionWebApplication.java | 0 .../src/main/resources/application.properties | 0 .../spring-session-redis/src/main/resources/logback.xml | 0 .../src/test/java/com/baeldung/SpringContextLiveTest.java | 0 .../spring/session/SessionControllerIntegrationTest.java | 0 28 files changed, 4 insertions(+), 4 deletions(-) rename {spring-session => spring-security-modules/spring-session}/README.md (100%) rename {spring-session => spring-security-modules/spring-session}/pom.xml (93%) rename {spring-session => spring-security-modules/spring-session}/spring-session-jdbc/README.md (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-jdbc/pom.xml (95%) rename {spring-session => spring-security-modules/spring-session}/spring-session-jdbc/src/main/java/com/baeldung/springsessionjdbc/SpringSessionJdbcApplication.java (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-jdbc/src/main/java/com/baeldung/springsessionjdbc/controller/SpringSessionJdbcController.java (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-jdbc/src/main/resources/application.properties (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-jdbc/src/main/resources/logback.xml (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-jdbc/src/test/java/com/baeldung/SpringContextTest.java (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-jdbc/src/test/java/com/baeldung/springsessionjdbc/SpringSessionJdbcIntegrationTest.java (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-mongodb/README.md (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-mongodb/pom.xml (96%) rename {spring-session => spring-security-modules/spring-session}/spring-session-mongodb/src/main/java/com/baeldung/springsessionmongodb/SpringSessionMongoDBApplication.java (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-mongodb/src/main/java/com/baeldung/springsessionmongodb/controller/SpringSessionMongoDBController.java (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-mongodb/src/main/resources/application.properties (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-mongodb/src/main/resources/logback.xml (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-mongodb/src/test/java/com/baeldung/SpringContextTest.java (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-mongodb/src/test/java/com/baeldung/springsessionmongodb/SpringSessionMongoDBIntegrationTest.java (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-mongodb/src/test/resources/application.properties (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-redis/README.md (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-redis/pom.xml (96%) rename {spring-session => spring-security-modules/spring-session}/spring-session-redis/src/main/java/com/baeldung/spring/session/SecurityConfig.java (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-redis/src/main/java/com/baeldung/spring/session/SessionController.java (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-redis/src/main/java/com/baeldung/spring/session/SessionWebApplication.java (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-redis/src/main/resources/application.properties (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-redis/src/main/resources/logback.xml (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-redis/src/test/java/com/baeldung/SpringContextLiveTest.java (100%) rename {spring-session => spring-security-modules/spring-session}/spring-session-redis/src/test/java/com/baeldung/spring/session/SessionControllerIntegrationTest.java (100%) diff --git a/spring-session/README.md b/spring-security-modules/spring-session/README.md similarity index 100% rename from spring-session/README.md rename to spring-security-modules/spring-session/README.md diff --git a/spring-session/pom.xml b/spring-security-modules/spring-session/pom.xml similarity index 93% rename from spring-session/pom.xml rename to spring-security-modules/spring-session/pom.xml index 6616a0d1f3..ac10700240 100644 --- a/spring-session/pom.xml +++ b/spring-security-modules/spring-session/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-session/spring-session-jdbc/README.md b/spring-security-modules/spring-session/spring-session-jdbc/README.md similarity index 100% rename from spring-session/spring-session-jdbc/README.md rename to spring-security-modules/spring-session/spring-session-jdbc/README.md diff --git a/spring-session/spring-session-jdbc/pom.xml b/spring-security-modules/spring-session/spring-session-jdbc/pom.xml similarity index 95% rename from spring-session/spring-session-jdbc/pom.xml rename to spring-security-modules/spring-session/spring-session-jdbc/pom.xml index 64cdb4dd09..95c366fc2e 100644 --- a/spring-session/spring-session-jdbc/pom.xml +++ b/spring-security-modules/spring-session/spring-session-jdbc/pom.xml @@ -13,7 +13,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../../parent-boot-2 + ../../../parent-boot-2 diff --git a/spring-session/spring-session-jdbc/src/main/java/com/baeldung/springsessionjdbc/SpringSessionJdbcApplication.java b/spring-security-modules/spring-session/spring-session-jdbc/src/main/java/com/baeldung/springsessionjdbc/SpringSessionJdbcApplication.java similarity index 100% rename from spring-session/spring-session-jdbc/src/main/java/com/baeldung/springsessionjdbc/SpringSessionJdbcApplication.java rename to spring-security-modules/spring-session/spring-session-jdbc/src/main/java/com/baeldung/springsessionjdbc/SpringSessionJdbcApplication.java diff --git a/spring-session/spring-session-jdbc/src/main/java/com/baeldung/springsessionjdbc/controller/SpringSessionJdbcController.java b/spring-security-modules/spring-session/spring-session-jdbc/src/main/java/com/baeldung/springsessionjdbc/controller/SpringSessionJdbcController.java similarity index 100% rename from spring-session/spring-session-jdbc/src/main/java/com/baeldung/springsessionjdbc/controller/SpringSessionJdbcController.java rename to spring-security-modules/spring-session/spring-session-jdbc/src/main/java/com/baeldung/springsessionjdbc/controller/SpringSessionJdbcController.java diff --git a/spring-session/spring-session-jdbc/src/main/resources/application.properties b/spring-security-modules/spring-session/spring-session-jdbc/src/main/resources/application.properties similarity index 100% rename from spring-session/spring-session-jdbc/src/main/resources/application.properties rename to spring-security-modules/spring-session/spring-session-jdbc/src/main/resources/application.properties diff --git a/spring-session/spring-session-jdbc/src/main/resources/logback.xml b/spring-security-modules/spring-session/spring-session-jdbc/src/main/resources/logback.xml similarity index 100% rename from spring-session/spring-session-jdbc/src/main/resources/logback.xml rename to spring-security-modules/spring-session/spring-session-jdbc/src/main/resources/logback.xml diff --git a/spring-session/spring-session-jdbc/src/test/java/com/baeldung/SpringContextTest.java b/spring-security-modules/spring-session/spring-session-jdbc/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-session/spring-session-jdbc/src/test/java/com/baeldung/SpringContextTest.java rename to spring-security-modules/spring-session/spring-session-jdbc/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-session/spring-session-jdbc/src/test/java/com/baeldung/springsessionjdbc/SpringSessionJdbcIntegrationTest.java b/spring-security-modules/spring-session/spring-session-jdbc/src/test/java/com/baeldung/springsessionjdbc/SpringSessionJdbcIntegrationTest.java similarity index 100% rename from spring-session/spring-session-jdbc/src/test/java/com/baeldung/springsessionjdbc/SpringSessionJdbcIntegrationTest.java rename to spring-security-modules/spring-session/spring-session-jdbc/src/test/java/com/baeldung/springsessionjdbc/SpringSessionJdbcIntegrationTest.java diff --git a/spring-session/spring-session-mongodb/README.md b/spring-security-modules/spring-session/spring-session-mongodb/README.md similarity index 100% rename from spring-session/spring-session-mongodb/README.md rename to spring-security-modules/spring-session/spring-session-mongodb/README.md diff --git a/spring-session/spring-session-mongodb/pom.xml b/spring-security-modules/spring-session/spring-session-mongodb/pom.xml similarity index 96% rename from spring-session/spring-session-mongodb/pom.xml rename to spring-security-modules/spring-session/spring-session-mongodb/pom.xml index 10d4eb595e..82c8520356 100644 --- a/spring-session/spring-session-mongodb/pom.xml +++ b/spring-security-modules/spring-session/spring-session-mongodb/pom.xml @@ -13,7 +13,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../../parent-boot-2 + ../../../parent-boot-2 diff --git a/spring-session/spring-session-mongodb/src/main/java/com/baeldung/springsessionmongodb/SpringSessionMongoDBApplication.java b/spring-security-modules/spring-session/spring-session-mongodb/src/main/java/com/baeldung/springsessionmongodb/SpringSessionMongoDBApplication.java similarity index 100% rename from spring-session/spring-session-mongodb/src/main/java/com/baeldung/springsessionmongodb/SpringSessionMongoDBApplication.java rename to spring-security-modules/spring-session/spring-session-mongodb/src/main/java/com/baeldung/springsessionmongodb/SpringSessionMongoDBApplication.java diff --git a/spring-session/spring-session-mongodb/src/main/java/com/baeldung/springsessionmongodb/controller/SpringSessionMongoDBController.java b/spring-security-modules/spring-session/spring-session-mongodb/src/main/java/com/baeldung/springsessionmongodb/controller/SpringSessionMongoDBController.java similarity index 100% rename from spring-session/spring-session-mongodb/src/main/java/com/baeldung/springsessionmongodb/controller/SpringSessionMongoDBController.java rename to spring-security-modules/spring-session/spring-session-mongodb/src/main/java/com/baeldung/springsessionmongodb/controller/SpringSessionMongoDBController.java diff --git a/spring-session/spring-session-mongodb/src/main/resources/application.properties b/spring-security-modules/spring-session/spring-session-mongodb/src/main/resources/application.properties similarity index 100% rename from spring-session/spring-session-mongodb/src/main/resources/application.properties rename to spring-security-modules/spring-session/spring-session-mongodb/src/main/resources/application.properties diff --git a/spring-session/spring-session-mongodb/src/main/resources/logback.xml b/spring-security-modules/spring-session/spring-session-mongodb/src/main/resources/logback.xml similarity index 100% rename from spring-session/spring-session-mongodb/src/main/resources/logback.xml rename to spring-security-modules/spring-session/spring-session-mongodb/src/main/resources/logback.xml diff --git a/spring-session/spring-session-mongodb/src/test/java/com/baeldung/SpringContextTest.java b/spring-security-modules/spring-session/spring-session-mongodb/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-session/spring-session-mongodb/src/test/java/com/baeldung/SpringContextTest.java rename to spring-security-modules/spring-session/spring-session-mongodb/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-session/spring-session-mongodb/src/test/java/com/baeldung/springsessionmongodb/SpringSessionMongoDBIntegrationTest.java b/spring-security-modules/spring-session/spring-session-mongodb/src/test/java/com/baeldung/springsessionmongodb/SpringSessionMongoDBIntegrationTest.java similarity index 100% rename from spring-session/spring-session-mongodb/src/test/java/com/baeldung/springsessionmongodb/SpringSessionMongoDBIntegrationTest.java rename to spring-security-modules/spring-session/spring-session-mongodb/src/test/java/com/baeldung/springsessionmongodb/SpringSessionMongoDBIntegrationTest.java diff --git a/spring-session/spring-session-mongodb/src/test/resources/application.properties b/spring-security-modules/spring-session/spring-session-mongodb/src/test/resources/application.properties similarity index 100% rename from spring-session/spring-session-mongodb/src/test/resources/application.properties rename to spring-security-modules/spring-session/spring-session-mongodb/src/test/resources/application.properties diff --git a/spring-session/spring-session-redis/README.md b/spring-security-modules/spring-session/spring-session-redis/README.md similarity index 100% rename from spring-session/spring-session-redis/README.md rename to spring-security-modules/spring-session/spring-session-redis/README.md diff --git a/spring-session/spring-session-redis/pom.xml b/spring-security-modules/spring-session/spring-session-redis/pom.xml similarity index 96% rename from spring-session/spring-session-redis/pom.xml rename to spring-security-modules/spring-session/spring-session-redis/pom.xml index 8d225e06ed..36eb632e1c 100644 --- a/spring-session/spring-session-redis/pom.xml +++ b/spring-security-modules/spring-session/spring-session-redis/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../../parent-boot-2 + ../../../parent-boot-2 diff --git a/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SecurityConfig.java b/spring-security-modules/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SecurityConfig.java similarity index 100% rename from spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SecurityConfig.java rename to spring-security-modules/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SecurityConfig.java diff --git a/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SessionController.java b/spring-security-modules/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SessionController.java similarity index 100% rename from spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SessionController.java rename to spring-security-modules/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SessionController.java diff --git a/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SessionWebApplication.java b/spring-security-modules/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SessionWebApplication.java similarity index 100% rename from spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SessionWebApplication.java rename to spring-security-modules/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SessionWebApplication.java diff --git a/spring-session/spring-session-redis/src/main/resources/application.properties b/spring-security-modules/spring-session/spring-session-redis/src/main/resources/application.properties similarity index 100% rename from spring-session/spring-session-redis/src/main/resources/application.properties rename to spring-security-modules/spring-session/spring-session-redis/src/main/resources/application.properties diff --git a/spring-session/spring-session-redis/src/main/resources/logback.xml b/spring-security-modules/spring-session/spring-session-redis/src/main/resources/logback.xml similarity index 100% rename from spring-session/spring-session-redis/src/main/resources/logback.xml rename to spring-security-modules/spring-session/spring-session-redis/src/main/resources/logback.xml diff --git a/spring-session/spring-session-redis/src/test/java/com/baeldung/SpringContextLiveTest.java b/spring-security-modules/spring-session/spring-session-redis/src/test/java/com/baeldung/SpringContextLiveTest.java similarity index 100% rename from spring-session/spring-session-redis/src/test/java/com/baeldung/SpringContextLiveTest.java rename to spring-security-modules/spring-session/spring-session-redis/src/test/java/com/baeldung/SpringContextLiveTest.java diff --git a/spring-session/spring-session-redis/src/test/java/com/baeldung/spring/session/SessionControllerIntegrationTest.java b/spring-security-modules/spring-session/spring-session-redis/src/test/java/com/baeldung/spring/session/SessionControllerIntegrationTest.java similarity index 100% rename from spring-session/spring-session-redis/src/test/java/com/baeldung/spring/session/SessionControllerIntegrationTest.java rename to spring-security-modules/spring-session/spring-session-redis/src/test/java/com/baeldung/spring/session/SessionControllerIntegrationTest.java From 49ae245cc2a8d93a23bcf2bc9a5b7132b50fbc00 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 25 Dec 2020 22:44:25 +0530 Subject: [PATCH 147/361] JAVA-3506: moved spring-social-login inside spring-security-modules --- .../spring-social-login}/README.md | 0 .../spring-social-login}/pom.xml | 2 +- .../src/main/java/com/baeldung/config/Application.java | 0 .../src/main/java/com/baeldung/config/SecurityConfig.java | 0 .../src/main/java/com/baeldung/config/WebConfig.java | 0 .../main/java/com/baeldung/persistence/dao/UserRepository.java | 0 .../src/main/java/com/baeldung/persistence/model/User.java | 0 .../java/com/baeldung/security/FacebookConnectionSignup.java | 0 .../main/java/com/baeldung/security/FacebookSignInAdapter.java | 0 .../main/java/com/baeldung/security/MyUserDetailsService.java | 0 .../src/main/resources/application.properties | 0 .../spring-social-login}/src/main/resources/data.sql | 0 .../spring-social-login}/src/main/resources/logback.xml | 0 .../src/main/resources/templates/index.html | 0 .../src/main/resources/templates/login.html | 0 .../src/test/java/com/baeldung/SpringContextTest.java | 0 16 files changed, 1 insertion(+), 1 deletion(-) rename {spring-social-login => spring-security-modules/spring-social-login}/README.md (100%) rename {spring-social-login => spring-security-modules/spring-social-login}/pom.xml (97%) rename {spring-social-login => spring-security-modules/spring-social-login}/src/main/java/com/baeldung/config/Application.java (100%) rename {spring-social-login => spring-security-modules/spring-social-login}/src/main/java/com/baeldung/config/SecurityConfig.java (100%) rename {spring-social-login => spring-security-modules/spring-social-login}/src/main/java/com/baeldung/config/WebConfig.java (100%) rename {spring-social-login => spring-security-modules/spring-social-login}/src/main/java/com/baeldung/persistence/dao/UserRepository.java (100%) rename {spring-social-login => spring-security-modules/spring-social-login}/src/main/java/com/baeldung/persistence/model/User.java (100%) rename {spring-social-login => spring-security-modules/spring-social-login}/src/main/java/com/baeldung/security/FacebookConnectionSignup.java (100%) rename {spring-social-login => spring-security-modules/spring-social-login}/src/main/java/com/baeldung/security/FacebookSignInAdapter.java (100%) rename {spring-social-login => spring-security-modules/spring-social-login}/src/main/java/com/baeldung/security/MyUserDetailsService.java (100%) rename {spring-social-login => spring-security-modules/spring-social-login}/src/main/resources/application.properties (100%) rename {spring-social-login => spring-security-modules/spring-social-login}/src/main/resources/data.sql (100%) rename {spring-social-login => spring-security-modules/spring-social-login}/src/main/resources/logback.xml (100%) rename {spring-social-login => spring-security-modules/spring-social-login}/src/main/resources/templates/index.html (100%) rename {spring-social-login => spring-security-modules/spring-social-login}/src/main/resources/templates/login.html (100%) rename {spring-social-login => spring-security-modules/spring-social-login}/src/test/java/com/baeldung/SpringContextTest.java (100%) diff --git a/spring-social-login/README.md b/spring-security-modules/spring-social-login/README.md similarity index 100% rename from spring-social-login/README.md rename to spring-security-modules/spring-social-login/README.md diff --git a/spring-social-login/pom.xml b/spring-security-modules/spring-social-login/pom.xml similarity index 97% rename from spring-social-login/pom.xml rename to spring-security-modules/spring-social-login/pom.xml index 0de20cd087..209a546a5a 100644 --- a/spring-social-login/pom.xml +++ b/spring-security-modules/spring-social-login/pom.xml @@ -10,7 +10,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-social-login/src/main/java/com/baeldung/config/Application.java b/spring-security-modules/spring-social-login/src/main/java/com/baeldung/config/Application.java similarity index 100% rename from spring-social-login/src/main/java/com/baeldung/config/Application.java rename to spring-security-modules/spring-social-login/src/main/java/com/baeldung/config/Application.java diff --git a/spring-social-login/src/main/java/com/baeldung/config/SecurityConfig.java b/spring-security-modules/spring-social-login/src/main/java/com/baeldung/config/SecurityConfig.java similarity index 100% rename from spring-social-login/src/main/java/com/baeldung/config/SecurityConfig.java rename to spring-security-modules/spring-social-login/src/main/java/com/baeldung/config/SecurityConfig.java diff --git a/spring-social-login/src/main/java/com/baeldung/config/WebConfig.java b/spring-security-modules/spring-social-login/src/main/java/com/baeldung/config/WebConfig.java similarity index 100% rename from spring-social-login/src/main/java/com/baeldung/config/WebConfig.java rename to spring-security-modules/spring-social-login/src/main/java/com/baeldung/config/WebConfig.java diff --git a/spring-social-login/src/main/java/com/baeldung/persistence/dao/UserRepository.java b/spring-security-modules/spring-social-login/src/main/java/com/baeldung/persistence/dao/UserRepository.java similarity index 100% rename from spring-social-login/src/main/java/com/baeldung/persistence/dao/UserRepository.java rename to spring-security-modules/spring-social-login/src/main/java/com/baeldung/persistence/dao/UserRepository.java diff --git a/spring-social-login/src/main/java/com/baeldung/persistence/model/User.java b/spring-security-modules/spring-social-login/src/main/java/com/baeldung/persistence/model/User.java similarity index 100% rename from spring-social-login/src/main/java/com/baeldung/persistence/model/User.java rename to spring-security-modules/spring-social-login/src/main/java/com/baeldung/persistence/model/User.java diff --git a/spring-social-login/src/main/java/com/baeldung/security/FacebookConnectionSignup.java b/spring-security-modules/spring-social-login/src/main/java/com/baeldung/security/FacebookConnectionSignup.java similarity index 100% rename from spring-social-login/src/main/java/com/baeldung/security/FacebookConnectionSignup.java rename to spring-security-modules/spring-social-login/src/main/java/com/baeldung/security/FacebookConnectionSignup.java diff --git a/spring-social-login/src/main/java/com/baeldung/security/FacebookSignInAdapter.java b/spring-security-modules/spring-social-login/src/main/java/com/baeldung/security/FacebookSignInAdapter.java similarity index 100% rename from spring-social-login/src/main/java/com/baeldung/security/FacebookSignInAdapter.java rename to spring-security-modules/spring-social-login/src/main/java/com/baeldung/security/FacebookSignInAdapter.java diff --git a/spring-social-login/src/main/java/com/baeldung/security/MyUserDetailsService.java b/spring-security-modules/spring-social-login/src/main/java/com/baeldung/security/MyUserDetailsService.java similarity index 100% rename from spring-social-login/src/main/java/com/baeldung/security/MyUserDetailsService.java rename to spring-security-modules/spring-social-login/src/main/java/com/baeldung/security/MyUserDetailsService.java diff --git a/spring-social-login/src/main/resources/application.properties b/spring-security-modules/spring-social-login/src/main/resources/application.properties similarity index 100% rename from spring-social-login/src/main/resources/application.properties rename to spring-security-modules/spring-social-login/src/main/resources/application.properties diff --git a/spring-social-login/src/main/resources/data.sql b/spring-security-modules/spring-social-login/src/main/resources/data.sql similarity index 100% rename from spring-social-login/src/main/resources/data.sql rename to spring-security-modules/spring-social-login/src/main/resources/data.sql diff --git a/spring-social-login/src/main/resources/logback.xml b/spring-security-modules/spring-social-login/src/main/resources/logback.xml similarity index 100% rename from spring-social-login/src/main/resources/logback.xml rename to spring-security-modules/spring-social-login/src/main/resources/logback.xml diff --git a/spring-social-login/src/main/resources/templates/index.html b/spring-security-modules/spring-social-login/src/main/resources/templates/index.html similarity index 100% rename from spring-social-login/src/main/resources/templates/index.html rename to spring-security-modules/spring-social-login/src/main/resources/templates/index.html diff --git a/spring-social-login/src/main/resources/templates/login.html b/spring-security-modules/spring-social-login/src/main/resources/templates/login.html similarity index 100% rename from spring-social-login/src/main/resources/templates/login.html rename to spring-security-modules/spring-social-login/src/main/resources/templates/login.html diff --git a/spring-social-login/src/test/java/com/baeldung/SpringContextTest.java b/spring-security-modules/spring-social-login/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-social-login/src/test/java/com/baeldung/SpringContextTest.java rename to spring-security-modules/spring-social-login/src/test/java/com/baeldung/SpringContextTest.java From 0513c0b64d052e1a7dc57f5f30e85b0ecb32c5bc Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 25 Dec 2020 22:45:16 +0530 Subject: [PATCH 148/361] JAVA-3506: added modules to new parent's pom --- spring-security-modules/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spring-security-modules/pom.xml b/spring-security-modules/pom.xml index e32fadd671..99dea4bc67 100644 --- a/spring-security-modules/pom.xml +++ b/spring-security-modules/pom.xml @@ -14,6 +14,10 @@ + spring-ldap + spring-5-security + spring-5-security-cognito + spring-5-security-oauth spring-security-acl spring-security-auth0 spring-security-web-angular/server @@ -38,6 +42,8 @@ spring-security-oauth2-sso spring-security-web-thymeleaf spring-security-web-x509 + spring-session + spring-social-login From d44dacaa2b69659b1d257229650c2c7598c09761 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Sat, 26 Dec 2020 06:14:52 +0530 Subject: [PATCH 149/361] Removed unwanted method --- .../java/com/baeldung/spring/transaction/CourseService.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseService.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseService.java index 1478c5bd1d..21f947a925 100644 --- a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseService.java +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseService.java @@ -31,8 +31,4 @@ public class CourseService { } } - public Course findById(Long id) { - return courseDao.findOne(id); - } - } From 698185a55b56a516bb21ce12567bdf427c974a35 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sat, 26 Dec 2020 10:22:35 +0200 Subject: [PATCH 150/361] remove files left after move --- .../spring-boot-libraries/pom.xml | 1 - .../src/main/resources/graphql/blog.graphqls | 24 --- ...GraphQL collection.postman_collection.json | 169 ------------------ 3 files changed, 194 deletions(-) delete mode 100644 spring-boot-modules/spring-boot/src/main/resources/graphql/blog.graphqls delete mode 100644 spring-boot-modules/spring-boot/src/test/resources/GraphQL collection.postman_collection.json diff --git a/spring-boot-modules/spring-boot-libraries/pom.xml b/spring-boot-modules/spring-boot-libraries/pom.xml index 3913babaa8..cec035cf93 100644 --- a/spring-boot-modules/spring-boot-libraries/pom.xml +++ b/spring-boot-modules/spring-boot-libraries/pom.xml @@ -6,7 +6,6 @@ spring-boot-libraries spring-boot-libraries war - This is simple boot application for Spring boot actuator test com.baeldung.spring-boot-modules diff --git a/spring-boot-modules/spring-boot/src/main/resources/graphql/blog.graphqls b/spring-boot-modules/spring-boot/src/main/resources/graphql/blog.graphqls deleted file mode 100644 index aa0c8757e9..0000000000 --- a/spring-boot-modules/spring-boot/src/main/resources/graphql/blog.graphqls +++ /dev/null @@ -1,24 +0,0 @@ -type Post { - id: ID! - title: String! - text: String! - category: String - author: Author -} - -type Author { - id: ID! - name: String! - thumbnail: String - posts: [Post]! -} - -# The Root Query for the application -type Query { - recentPosts(count: Int, offset: Int): [Post]! -} - -# The Root Mutation for the application -type Mutation { - writePost(title: String!, text: String!, category: String, author: String!) : Post! -} diff --git a/spring-boot-modules/spring-boot/src/test/resources/GraphQL collection.postman_collection.json b/spring-boot-modules/spring-boot/src/test/resources/GraphQL collection.postman_collection.json deleted file mode 100644 index f19bc1febb..0000000000 --- a/spring-boot-modules/spring-boot/src/test/resources/GraphQL collection.postman_collection.json +++ /dev/null @@ -1,169 +0,0 @@ -{ - "info": { - "_postman_id": "910d9690-f629-4491-bbbd-adb30982a386", - "name": "GraphQL collection", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, - "item": [ - { - "name": "mutations", - "item": [ - { - "name": "writePost", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "graphql", - "graphql": { - "query": "mutation writePost ($title: String!, $text: String!, $category: String) {\n writePost (title: $title, text: $text, category: $category) {\n id\n title\n text\n category\n }\n}", - "variables": "{\n \"title\": \"\",\n \"text\": \"\",\n \"category\": \"\"\n}" - }, - "options": { - "graphql": {} - } - }, - "url": { - "raw": "http://localhost:9090/springbootapp/graphql", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "9090", - "path": [ - "springbootapp", - "graphql" - ] - } - }, - "response": [] - } - ], - "protocolProfileBehavior": {} - }, - { - "name": "queries", - "item": [ - { - "name": "get recent posts", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "graphql", - "graphql": { - "query": "{\r\n recentPosts(count: 10, offset: 0) {\r\n id\r\n title\r\n category\r\n text\r\n author {\r\n id\r\n name\r\n thumbnail\r\n }\r\n }\r\n}", - "variables": "" - } - }, - "url": { - "raw": "http://localhost:9090/springbootapp/graphql", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "9090", - "path": [ - "springbootapp", - "graphql" - ] - } - }, - "response": [] - }, - { - "name": "recentPosts - variables", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "graphql", - "graphql": { - "query": "query recentPosts ($count: Int, $offset: Int) {\n recentPosts (count: $count, offset: $offset) {\n id\n title\n text\n category\n }\n}", - "variables": "{\n \"count\": 1,\n \"offset\": 0\n}" - }, - "options": { - "graphql": {} - } - }, - "url": { - "raw": "http://localhost:9090/springbootapp/graphql", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "9090", - "path": [ - "springbootapp", - "graphql" - ] - } - }, - "response": [] - }, - { - "name": "get recent posts - raw", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/graphql", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "query {\r\n recentPosts(count: 10, offset: 0) {\r\n id\r\n title\r\n category\r\n author {\r\n id\r\n name\r\n thumbnail\r\n }\r\n }\r\n}" - }, - "url": { - "raw": "http://localhost:9090/springbootapp/graphql", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "9090", - "path": [ - "springbootapp", - "graphql" - ] - } - }, - "response": [] - } - ], - "protocolProfileBehavior": {} - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "id": "b54f267b-c450-4f2d-8105-2f23bab4c922", - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "id": "00b575be-03d4-4b29-b137-733ead139638", - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ], - "variable": [ - { - "id": "20a274e5-6d51-40d6-81cb-af9eb115b21b", - "key": "url", - "value": "", - "type": "string" - } - ], - "protocolProfileBehavior": {} -} \ No newline at end of file From fa02e7b10403b51902036dff9ed119fc75d2818c Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 27 Dec 2020 12:16:48 +0530 Subject: [PATCH 151/361] JAVA-3522: Moved spring-mvc-crash inside spring-web-modules --- .../spring-mvc-crash}/.gitignore | 0 .../spring-mvc-crash}/README.md | 0 .../spring-mvc-crash}/pom.xml | 4 ++-- .../src/main/java/com/baeldung/spring/ClientWebConfig.java | 0 .../main/java/com/baeldung/spring/ClientWebConfigJava.java | 0 .../com/baeldung/spring/controller/WelcomeController.java | 0 .../src/main/resources/contentManagementWebMvcConfig.xml | 0 .../spring-mvc-crash}/src/main/resources/logback.xml | 0 .../spring-mvc-crash}/src/main/resources/messages.properties | 0 .../spring-mvc-crash}/src/main/resources/webMvcConfig.xml | 0 .../src/main/webapp/WEB-INF/crash/commands/message.groovy | 0 .../src/main/webapp/WEB-INF/crash/commands/message2.java | 0 .../src/main/webapp/WEB-INF/crash/crash.properties | 0 .../src/main/webapp/WEB-INF/crash/telnet.properties | 0 .../spring-mvc-crash}/src/main/webapp/WEB-INF/mvc-servlet.xml | 0 .../spring-mvc-crash}/src/main/webapp/WEB-INF/view/error.jsp | 0 .../src/main/webapp/WEB-INF/view/errorPage.jsp | 0 .../src/main/webapp/WEB-INF/view/welcome.jsp | 0 .../spring-mvc-crash}/src/main/webapp/WEB-INF/web.xml | 0 .../spring-mvc-crash}/src/main/webapp/index.jsp | 0 .../spring-mvc-crash}/src/main/webapp/jsp/ExampleThree.jsp | 0 .../spring-mvc-crash}/src/main/webapp/jsp/ExampleTwo.jsp | 0 .../spring-mvc-crash}/src/main/webapp/jsp/index.jsp | 0 .../src/test/java/com/baeldung/SpringContextTest.java | 0 24 files changed, 2 insertions(+), 2 deletions(-) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/.gitignore (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/README.md (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/pom.xml (98%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/java/com/baeldung/spring/ClientWebConfig.java (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/java/com/baeldung/spring/ClientWebConfigJava.java (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/java/com/baeldung/spring/controller/WelcomeController.java (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/resources/contentManagementWebMvcConfig.xml (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/resources/logback.xml (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/resources/messages.properties (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/resources/webMvcConfig.xml (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/webapp/WEB-INF/crash/commands/message.groovy (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/webapp/WEB-INF/crash/commands/message2.java (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/webapp/WEB-INF/crash/crash.properties (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/webapp/WEB-INF/crash/telnet.properties (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/webapp/WEB-INF/mvc-servlet.xml (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/webapp/WEB-INF/view/error.jsp (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/webapp/WEB-INF/view/errorPage.jsp (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/webapp/WEB-INF/view/welcome.jsp (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/webapp/WEB-INF/web.xml (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/webapp/index.jsp (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/webapp/jsp/ExampleThree.jsp (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/webapp/jsp/ExampleTwo.jsp (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/main/webapp/jsp/index.jsp (100%) rename {spring-mvc-crash => spring-web-modules/spring-mvc-crash}/src/test/java/com/baeldung/SpringContextTest.java (100%) diff --git a/spring-mvc-crash/.gitignore b/spring-web-modules/spring-mvc-crash/.gitignore similarity index 100% rename from spring-mvc-crash/.gitignore rename to spring-web-modules/spring-mvc-crash/.gitignore diff --git a/spring-mvc-crash/README.md b/spring-web-modules/spring-mvc-crash/README.md similarity index 100% rename from spring-mvc-crash/README.md rename to spring-web-modules/spring-mvc-crash/README.md diff --git a/spring-mvc-crash/pom.xml b/spring-web-modules/spring-mvc-crash/pom.xml similarity index 98% rename from spring-mvc-crash/pom.xml rename to spring-web-modules/spring-mvc-crash/pom.xml index 8a902d4937..9a0d97bae9 100644 --- a/spring-mvc-crash/pom.xml +++ b/spring-web-modules/spring-mvc-crash/pom.xml @@ -10,8 +10,8 @@ com.baeldung - parent-modules - 1.0.0-SNAPSHOT + spring-web-modules + 0.0.1-SNAPSHOT diff --git a/spring-mvc-crash/src/main/java/com/baeldung/spring/ClientWebConfig.java b/spring-web-modules/spring-mvc-crash/src/main/java/com/baeldung/spring/ClientWebConfig.java similarity index 100% rename from spring-mvc-crash/src/main/java/com/baeldung/spring/ClientWebConfig.java rename to spring-web-modules/spring-mvc-crash/src/main/java/com/baeldung/spring/ClientWebConfig.java diff --git a/spring-mvc-crash/src/main/java/com/baeldung/spring/ClientWebConfigJava.java b/spring-web-modules/spring-mvc-crash/src/main/java/com/baeldung/spring/ClientWebConfigJava.java similarity index 100% rename from spring-mvc-crash/src/main/java/com/baeldung/spring/ClientWebConfigJava.java rename to spring-web-modules/spring-mvc-crash/src/main/java/com/baeldung/spring/ClientWebConfigJava.java diff --git a/spring-mvc-crash/src/main/java/com/baeldung/spring/controller/WelcomeController.java b/spring-web-modules/spring-mvc-crash/src/main/java/com/baeldung/spring/controller/WelcomeController.java similarity index 100% rename from spring-mvc-crash/src/main/java/com/baeldung/spring/controller/WelcomeController.java rename to spring-web-modules/spring-mvc-crash/src/main/java/com/baeldung/spring/controller/WelcomeController.java diff --git a/spring-mvc-crash/src/main/resources/contentManagementWebMvcConfig.xml b/spring-web-modules/spring-mvc-crash/src/main/resources/contentManagementWebMvcConfig.xml similarity index 100% rename from spring-mvc-crash/src/main/resources/contentManagementWebMvcConfig.xml rename to spring-web-modules/spring-mvc-crash/src/main/resources/contentManagementWebMvcConfig.xml diff --git a/spring-mvc-crash/src/main/resources/logback.xml b/spring-web-modules/spring-mvc-crash/src/main/resources/logback.xml similarity index 100% rename from spring-mvc-crash/src/main/resources/logback.xml rename to spring-web-modules/spring-mvc-crash/src/main/resources/logback.xml diff --git a/spring-mvc-crash/src/main/resources/messages.properties b/spring-web-modules/spring-mvc-crash/src/main/resources/messages.properties similarity index 100% rename from spring-mvc-crash/src/main/resources/messages.properties rename to spring-web-modules/spring-mvc-crash/src/main/resources/messages.properties diff --git a/spring-mvc-crash/src/main/resources/webMvcConfig.xml b/spring-web-modules/spring-mvc-crash/src/main/resources/webMvcConfig.xml similarity index 100% rename from spring-mvc-crash/src/main/resources/webMvcConfig.xml rename to spring-web-modules/spring-mvc-crash/src/main/resources/webMvcConfig.xml diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/crash/commands/message.groovy b/spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/crash/commands/message.groovy similarity index 100% rename from spring-mvc-crash/src/main/webapp/WEB-INF/crash/commands/message.groovy rename to spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/crash/commands/message.groovy diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/crash/commands/message2.java b/spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/crash/commands/message2.java similarity index 100% rename from spring-mvc-crash/src/main/webapp/WEB-INF/crash/commands/message2.java rename to spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/crash/commands/message2.java diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/crash/crash.properties b/spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/crash/crash.properties similarity index 100% rename from spring-mvc-crash/src/main/webapp/WEB-INF/crash/crash.properties rename to spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/crash/crash.properties diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/crash/telnet.properties b/spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/crash/telnet.properties similarity index 100% rename from spring-mvc-crash/src/main/webapp/WEB-INF/crash/telnet.properties rename to spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/crash/telnet.properties diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-mvc-crash/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/view/error.jsp b/spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/view/error.jsp similarity index 100% rename from spring-mvc-crash/src/main/webapp/WEB-INF/view/error.jsp rename to spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/view/error.jsp diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/view/errorPage.jsp b/spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/view/errorPage.jsp similarity index 100% rename from spring-mvc-crash/src/main/webapp/WEB-INF/view/errorPage.jsp rename to spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/view/errorPage.jsp diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/view/welcome.jsp b/spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/view/welcome.jsp similarity index 100% rename from spring-mvc-crash/src/main/webapp/WEB-INF/view/welcome.jsp rename to spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/view/welcome.jsp diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/web.xml b/spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-mvc-crash/src/main/webapp/WEB-INF/web.xml rename to spring-web-modules/spring-mvc-crash/src/main/webapp/WEB-INF/web.xml diff --git a/spring-mvc-crash/src/main/webapp/index.jsp b/spring-web-modules/spring-mvc-crash/src/main/webapp/index.jsp similarity index 100% rename from spring-mvc-crash/src/main/webapp/index.jsp rename to spring-web-modules/spring-mvc-crash/src/main/webapp/index.jsp diff --git a/spring-mvc-crash/src/main/webapp/jsp/ExampleThree.jsp b/spring-web-modules/spring-mvc-crash/src/main/webapp/jsp/ExampleThree.jsp similarity index 100% rename from spring-mvc-crash/src/main/webapp/jsp/ExampleThree.jsp rename to spring-web-modules/spring-mvc-crash/src/main/webapp/jsp/ExampleThree.jsp diff --git a/spring-mvc-crash/src/main/webapp/jsp/ExampleTwo.jsp b/spring-web-modules/spring-mvc-crash/src/main/webapp/jsp/ExampleTwo.jsp similarity index 100% rename from spring-mvc-crash/src/main/webapp/jsp/ExampleTwo.jsp rename to spring-web-modules/spring-mvc-crash/src/main/webapp/jsp/ExampleTwo.jsp diff --git a/spring-mvc-crash/src/main/webapp/jsp/index.jsp b/spring-web-modules/spring-mvc-crash/src/main/webapp/jsp/index.jsp similarity index 100% rename from spring-mvc-crash/src/main/webapp/jsp/index.jsp rename to spring-web-modules/spring-mvc-crash/src/main/webapp/jsp/index.jsp diff --git a/spring-mvc-crash/src/test/java/com/baeldung/SpringContextTest.java b/spring-web-modules/spring-mvc-crash/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-mvc-crash/src/test/java/com/baeldung/SpringContextTest.java rename to spring-web-modules/spring-mvc-crash/src/test/java/com/baeldung/SpringContextTest.java From 50b03440ea5c09e4707870caa67c8bd029870387 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 27 Dec 2020 12:17:36 +0530 Subject: [PATCH 152/361] JAVA-3522: Moved spring-mvc-forms-jsp to spring-web-modules --- .../spring-mvc-forms-jsp}/README.md | 0 .../spring-mvc-forms-jsp}/pom.xml | 2 +- .../main/java/com/baeldung/jstl/bundles/CustomMessage_en.java | 0 .../java/com/baeldung/jstl/bundles/CustomMessage_fr_FR.java | 0 .../main/java/com/baeldung/jstl/controllers/JSTLController.java | 0 .../src/main/java/com/baeldung/jstl/dbaccess/SQLConnection.java | 0 .../springmvcforms/configuration/ApplicationConfiguration.java | 0 .../baeldung/springmvcforms/configuration/WebInitializer.java | 0 .../baeldung/springmvcforms/controller/CustomerController.java | 0 .../baeldung/springmvcforms/controller/EmployeeController.java | 0 .../springmvcforms/controller/FileUploadController.java | 0 .../com/baeldung/springmvcforms/controller/UserController.java | 0 .../main/java/com/baeldung/springmvcforms/domain/Customer.java | 0 .../main/java/com/baeldung/springmvcforms/domain/Employee.java | 0 .../src/main/java/com/baeldung/springmvcforms/domain/User.java | 0 .../springmvcforms/interceptor/FileUploadExceptionAdvice.java | 0 .../baeldung/springmvcforms/validator/CustomerValidator.java | 0 .../spring-mvc-forms-jsp}/src/main/resources/logback.xml | 0 .../src/main/webapp/WEB-INF/html/user.html | 0 .../spring-mvc-forms-jsp}/src/main/webapp/WEB-INF/items.xsl | 0 .../src/main/webapp/WEB-INF/views/core_tags.jsp | 0 .../src/main/webapp/WEB-INF/views/core_tags_redirect.jsp | 0 .../src/main/webapp/WEB-INF/views/customerHome.jsp | 0 .../src/main/webapp/WEB-INF/views/customerView.jsp | 0 .../src/main/webapp/WEB-INF/views/employeeHome.jsp | 0 .../src/main/webapp/WEB-INF/views/employeeView.jsp | 0 .../src/main/webapp/WEB-INF/views/error.jsp | 0 .../src/main/webapp/WEB-INF/views/file.jsp | 0 .../src/main/webapp/WEB-INF/views/formatting_tags.jsp | 0 .../src/main/webapp/WEB-INF/views/function_tags.jsp | 0 .../src/main/webapp/WEB-INF/views/sql_tags.jsp | 0 .../src/main/webapp/WEB-INF/views/xml_tags.jsp | 0 .../spring-mvc-forms-jsp}/src/main/webapp/css/user.css | 0 .../spring-mvc-forms-jsp}/src/main/webapp/js/app.js | 0 .../src/test/java/com}/baeldung/SpringContextTest.java | 0 35 files changed, 1 insertion(+), 1 deletion(-) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/README.md (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/pom.xml (98%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/java/com/baeldung/jstl/bundles/CustomMessage_en.java (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/java/com/baeldung/jstl/bundles/CustomMessage_fr_FR.java (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/java/com/baeldung/jstl/controllers/JSTLController.java (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/java/com/baeldung/jstl/dbaccess/SQLConnection.java (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/java/com/baeldung/springmvcforms/configuration/ApplicationConfiguration.java (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/java/com/baeldung/springmvcforms/configuration/WebInitializer.java (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/java/com/baeldung/springmvcforms/controller/CustomerController.java (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/java/com/baeldung/springmvcforms/controller/EmployeeController.java (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/java/com/baeldung/springmvcforms/controller/FileUploadController.java (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/java/com/baeldung/springmvcforms/controller/UserController.java (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/java/com/baeldung/springmvcforms/domain/Customer.java (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/java/com/baeldung/springmvcforms/domain/Employee.java (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/java/com/baeldung/springmvcforms/domain/User.java (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/java/com/baeldung/springmvcforms/interceptor/FileUploadExceptionAdvice.java (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/java/com/baeldung/springmvcforms/validator/CustomerValidator.java (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/resources/logback.xml (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/webapp/WEB-INF/html/user.html (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/webapp/WEB-INF/items.xsl (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/webapp/WEB-INF/views/core_tags.jsp (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/webapp/WEB-INF/views/core_tags_redirect.jsp (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/webapp/WEB-INF/views/customerHome.jsp (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/webapp/WEB-INF/views/customerView.jsp (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/webapp/WEB-INF/views/employeeHome.jsp (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/webapp/WEB-INF/views/employeeView.jsp (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/webapp/WEB-INF/views/error.jsp (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/webapp/WEB-INF/views/file.jsp (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/webapp/WEB-INF/views/formatting_tags.jsp (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/webapp/WEB-INF/views/function_tags.jsp (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/webapp/WEB-INF/views/sql_tags.jsp (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/webapp/WEB-INF/views/xml_tags.jsp (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/webapp/css/user.css (100%) rename {spring-mvc-forms-jsp => spring-web-modules/spring-mvc-forms-jsp}/src/main/webapp/js/app.js (100%) rename {spring-mvc-forms-jsp/src/test/java/org => spring-web-modules/spring-mvc-forms-jsp/src/test/java/com}/baeldung/SpringContextTest.java (100%) diff --git a/spring-mvc-forms-jsp/README.md b/spring-web-modules/spring-mvc-forms-jsp/README.md similarity index 100% rename from spring-mvc-forms-jsp/README.md rename to spring-web-modules/spring-mvc-forms-jsp/README.md diff --git a/spring-mvc-forms-jsp/pom.xml b/spring-web-modules/spring-mvc-forms-jsp/pom.xml similarity index 98% rename from spring-mvc-forms-jsp/pom.xml rename to spring-web-modules/spring-mvc-forms-jsp/pom.xml index 4e1c2516f6..aba16236da 100644 --- a/spring-mvc-forms-jsp/pom.xml +++ b/spring-web-modules/spring-mvc-forms-jsp/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-spring-5 0.0.1-SNAPSHOT - ../parent-spring-5 + ../../parent-spring-5 diff --git a/spring-mvc-forms-jsp/src/main/java/com/baeldung/jstl/bundles/CustomMessage_en.java b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/jstl/bundles/CustomMessage_en.java similarity index 100% rename from spring-mvc-forms-jsp/src/main/java/com/baeldung/jstl/bundles/CustomMessage_en.java rename to spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/jstl/bundles/CustomMessage_en.java diff --git a/spring-mvc-forms-jsp/src/main/java/com/baeldung/jstl/bundles/CustomMessage_fr_FR.java b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/jstl/bundles/CustomMessage_fr_FR.java similarity index 100% rename from spring-mvc-forms-jsp/src/main/java/com/baeldung/jstl/bundles/CustomMessage_fr_FR.java rename to spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/jstl/bundles/CustomMessage_fr_FR.java diff --git a/spring-mvc-forms-jsp/src/main/java/com/baeldung/jstl/controllers/JSTLController.java b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/jstl/controllers/JSTLController.java similarity index 100% rename from spring-mvc-forms-jsp/src/main/java/com/baeldung/jstl/controllers/JSTLController.java rename to spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/jstl/controllers/JSTLController.java diff --git a/spring-mvc-forms-jsp/src/main/java/com/baeldung/jstl/dbaccess/SQLConnection.java b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/jstl/dbaccess/SQLConnection.java similarity index 100% rename from spring-mvc-forms-jsp/src/main/java/com/baeldung/jstl/dbaccess/SQLConnection.java rename to spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/jstl/dbaccess/SQLConnection.java diff --git a/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/configuration/ApplicationConfiguration.java b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/configuration/ApplicationConfiguration.java similarity index 100% rename from spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/configuration/ApplicationConfiguration.java rename to spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/configuration/ApplicationConfiguration.java diff --git a/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/configuration/WebInitializer.java b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/configuration/WebInitializer.java similarity index 100% rename from spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/configuration/WebInitializer.java rename to spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/configuration/WebInitializer.java diff --git a/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/CustomerController.java b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/CustomerController.java similarity index 100% rename from spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/CustomerController.java rename to spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/CustomerController.java diff --git a/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/EmployeeController.java b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/EmployeeController.java similarity index 100% rename from spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/EmployeeController.java rename to spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/EmployeeController.java diff --git a/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/FileUploadController.java b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/FileUploadController.java similarity index 100% rename from spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/FileUploadController.java rename to spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/FileUploadController.java diff --git a/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/UserController.java b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/UserController.java similarity index 100% rename from spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/UserController.java rename to spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/UserController.java diff --git a/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/domain/Customer.java b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/domain/Customer.java similarity index 100% rename from spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/domain/Customer.java rename to spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/domain/Customer.java diff --git a/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/domain/Employee.java b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/domain/Employee.java similarity index 100% rename from spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/domain/Employee.java rename to spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/domain/Employee.java diff --git a/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/domain/User.java b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/domain/User.java similarity index 100% rename from spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/domain/User.java rename to spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/domain/User.java diff --git a/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/interceptor/FileUploadExceptionAdvice.java b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/interceptor/FileUploadExceptionAdvice.java similarity index 100% rename from spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/interceptor/FileUploadExceptionAdvice.java rename to spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/interceptor/FileUploadExceptionAdvice.java diff --git a/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/validator/CustomerValidator.java b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/validator/CustomerValidator.java similarity index 100% rename from spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/validator/CustomerValidator.java rename to spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/validator/CustomerValidator.java diff --git a/spring-mvc-forms-jsp/src/main/resources/logback.xml b/spring-web-modules/spring-mvc-forms-jsp/src/main/resources/logback.xml similarity index 100% rename from spring-mvc-forms-jsp/src/main/resources/logback.xml rename to spring-web-modules/spring-mvc-forms-jsp/src/main/resources/logback.xml diff --git a/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/html/user.html b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/html/user.html similarity index 100% rename from spring-mvc-forms-jsp/src/main/webapp/WEB-INF/html/user.html rename to spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/html/user.html diff --git a/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/items.xsl b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/items.xsl similarity index 100% rename from spring-mvc-forms-jsp/src/main/webapp/WEB-INF/items.xsl rename to spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/items.xsl diff --git a/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/core_tags.jsp b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/core_tags.jsp similarity index 100% rename from spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/core_tags.jsp rename to spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/core_tags.jsp diff --git a/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/core_tags_redirect.jsp b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/core_tags_redirect.jsp similarity index 100% rename from spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/core_tags_redirect.jsp rename to spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/core_tags_redirect.jsp diff --git a/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/customerHome.jsp b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/customerHome.jsp similarity index 100% rename from spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/customerHome.jsp rename to spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/customerHome.jsp diff --git a/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/customerView.jsp b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/customerView.jsp similarity index 100% rename from spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/customerView.jsp rename to spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/customerView.jsp diff --git a/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/employeeHome.jsp b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/employeeHome.jsp similarity index 100% rename from spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/employeeHome.jsp rename to spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/employeeHome.jsp diff --git a/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/employeeView.jsp b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/employeeView.jsp similarity index 100% rename from spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/employeeView.jsp rename to spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/employeeView.jsp diff --git a/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/error.jsp b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/error.jsp similarity index 100% rename from spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/error.jsp rename to spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/error.jsp diff --git a/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/file.jsp b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/file.jsp similarity index 100% rename from spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/file.jsp rename to spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/file.jsp diff --git a/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/formatting_tags.jsp b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/formatting_tags.jsp similarity index 100% rename from spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/formatting_tags.jsp rename to spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/formatting_tags.jsp diff --git a/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/function_tags.jsp b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/function_tags.jsp similarity index 100% rename from spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/function_tags.jsp rename to spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/function_tags.jsp diff --git a/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/sql_tags.jsp b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/sql_tags.jsp similarity index 100% rename from spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/sql_tags.jsp rename to spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/sql_tags.jsp diff --git a/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/xml_tags.jsp b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/xml_tags.jsp similarity index 100% rename from spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/xml_tags.jsp rename to spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/xml_tags.jsp diff --git a/spring-mvc-forms-jsp/src/main/webapp/css/user.css b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/css/user.css similarity index 100% rename from spring-mvc-forms-jsp/src/main/webapp/css/user.css rename to spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/css/user.css diff --git a/spring-mvc-forms-jsp/src/main/webapp/js/app.js b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/js/app.js similarity index 100% rename from spring-mvc-forms-jsp/src/main/webapp/js/app.js rename to spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/js/app.js diff --git a/spring-mvc-forms-jsp/src/test/java/org/baeldung/SpringContextTest.java b/spring-web-modules/spring-mvc-forms-jsp/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-mvc-forms-jsp/src/test/java/org/baeldung/SpringContextTest.java rename to spring-web-modules/spring-mvc-forms-jsp/src/test/java/com/baeldung/SpringContextTest.java From 950ec2f8df4dae6919ded9462c7ef42d6385d196 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 27 Dec 2020 12:18:06 +0530 Subject: [PATCH 153/361] JAVA-3522: Added modules to new parent's pom --- spring-web-modules/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index bf6fda09f4..b957b46afa 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -18,6 +18,8 @@ spring-mvc-basics-2 spring-mvc-basics-3 spring-mvc-basics-4 + spring-mvc-crash + spring-mvc-forms-jsp From 8ab0faa372a941186da10782d3b95f87f2d42aec Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 27 Dec 2020 12:19:07 +0530 Subject: [PATCH 154/361] JAVA-3522: removed modules from main pom --- pom.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pom.xml b/pom.xml index a28089e05a..c37992df44 100644 --- a/pom.xml +++ b/pom.xml @@ -658,7 +658,6 @@ spring-mobile spring-mockito - spring-mvc-forms-jsp spring-mvc-forms-thymeleaf spring-mvc-java spring-mvc-java-2 @@ -1133,7 +1132,6 @@ spring-mobile spring-mockito - spring-mvc-forms-jsp spring-mvc-forms-thymeleaf spring-mvc-java spring-mvc-java-2 @@ -1142,7 +1140,6 @@ spring-mvc-views spring-mvc-webflow spring-mvc-xml - spring-mvc-crash spring-protobuf spring-quartz From 8fc0ea77cccbef74a06abbe003c5b2c3851a42f8 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Sun, 27 Dec 2020 12:59:42 +0100 Subject: [PATCH 155/361] JAVA-3543: Move spring-thymeleaf into spring-web-modules --- pom.xml | 2 -- spring-web-modules/pom.xml | 1 + .../spring-thymeleaf}/README.md | 0 .../spring-thymeleaf}/pom.xml | 2 +- .../main/java/com/baeldung/thymeleaf/config/InitSecurity.java | 0 .../src/main/java/com/baeldung/thymeleaf/config/WebApp.java | 0 .../main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java | 0 .../main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java | 0 .../java/com/baeldung/thymeleaf/controller/BookController.java | 0 .../java/com/baeldung/thymeleaf/controller/DatesController.java | 0 .../controller/ExpressionUtilityObjectsController.java | 0 .../com/baeldung/thymeleaf/controller/FragmentsController.java | 0 .../java/com/baeldung/thymeleaf/controller/HomeController.java | 0 .../com/baeldung/thymeleaf/controller/InliningController.java | 0 .../baeldung/thymeleaf/controller/LayoutDialectController.java | 0 .../com/baeldung/thymeleaf/controller/StudentController.java | 0 .../com/baeldung/thymeleaf/controller/TeacherController.java | 0 .../java/com/baeldung/thymeleaf/formatter/NameFormatter.java | 0 .../src/main/java/com/baeldung/thymeleaf/model/Book.java | 0 .../src/main/java/com/baeldung/thymeleaf/model/Student.java | 0 .../src/main/java/com/baeldung/thymeleaf/model/Teacher.java | 0 .../main/java/com/baeldung/thymeleaf/service/BookService.java | 0 .../src/main/java/com/baeldung/thymeleaf/utils/ArrayUtil.java | 0 .../src/main/java/com/baeldung/thymeleaf/utils/BookUtils.java | 0 .../main/java/com/baeldung/thymeleaf/utils/StudentUtils.java | 0 .../main/java/com/baeldung/thymeleaf/utils/TeacherUtils.java | 0 .../spring-thymeleaf}/src/main/resources/logback.xml | 0 .../spring-thymeleaf}/src/main/resources/messages_en.properties | 0 .../spring-thymeleaf}/src/main/webapp/WEB-INF/css/styles.css | 0 .../src/main/webapp/WEB-INF/js/studentCheck.js | 0 .../src/main/webapp/WEB-INF/txt/studentsList.txt | 0 .../src/main/webapp/WEB-INF/views/addStudent.html | 0 .../src/main/webapp/WEB-INF/views/content.html | 0 .../src/main/webapp/WEB-INF/views/csrfAttack.html | 0 .../spring-thymeleaf}/src/main/webapp/WEB-INF/views/dates.html | 0 .../src/main/webapp/WEB-INF/views/fragments.html | 0 .../src/main/webapp/WEB-INF/views/fragments/forms.html | 0 .../src/main/webapp/WEB-INF/views/fragments/general.html | 0 .../src/main/webapp/WEB-INF/views/fragments/menus.html | 0 .../src/main/webapp/WEB-INF/views/fragments/subtitle.html | 0 .../src/main/webapp/WEB-INF/views/fragments/tables.html | 0 .../spring-thymeleaf}/src/main/webapp/WEB-INF/views/home.html | 0 .../src/main/webapp/WEB-INF/views/inliningExample.html | 0 .../src/main/webapp/WEB-INF/views/listBooks.html | 0 .../src/main/webapp/WEB-INF/views/listStudents.html | 0 .../src/main/webapp/WEB-INF/views/listTeachers.html | 0 .../spring-thymeleaf}/src/main/webapp/WEB-INF/views/markup.html | 0 .../src/main/webapp/WEB-INF/views/objects.html | 0 .../spring-thymeleaf}/src/main/webapp/WEB-INF/views/other.html | 0 .../spring-thymeleaf}/src/main/webapp/WEB-INF/views/params.html | 0 .../src/main/webapp/WEB-INF/views/template.html | 0 .../src/test/java/com/baeldung/thymeleaf/SpringContextTest.java | 0 .../ExpressionUtilityObjectsControllerIntegrationTest.java | 0 .../baeldung/thymeleaf/controller/FragmentsIntegrationTest.java | 0 .../controller/LayoutDialectControllerIntegrationTest.java | 0 .../thymeleaf/security/csrf/CsrfEnabledIntegrationTest.java | 0 56 files changed, 2 insertions(+), 3 deletions(-) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/README.md (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/pom.xml (99%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/config/InitSecurity.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/config/WebApp.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/controller/BookController.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/controller/DatesController.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/controller/ExpressionUtilityObjectsController.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/controller/FragmentsController.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/controller/HomeController.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/controller/InliningController.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/controller/LayoutDialectController.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/controller/StudentController.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/controller/TeacherController.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/formatter/NameFormatter.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/model/Book.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/model/Student.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/model/Teacher.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/service/BookService.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/utils/ArrayUtil.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/utils/BookUtils.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/utils/StudentUtils.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/java/com/baeldung/thymeleaf/utils/TeacherUtils.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/resources/logback.xml (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/resources/messages_en.properties (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/css/styles.css (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/js/studentCheck.js (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/txt/studentsList.txt (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/addStudent.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/content.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/csrfAttack.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/dates.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/fragments.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/fragments/forms.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/fragments/general.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/fragments/menus.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/fragments/subtitle.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/fragments/tables.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/home.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/inliningExample.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/listBooks.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/listStudents.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/listTeachers.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/markup.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/objects.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/other.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/params.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/main/webapp/WEB-INF/views/template.html (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/test/java/com/baeldung/thymeleaf/SpringContextTest.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/test/java/com/baeldung/thymeleaf/controller/ExpressionUtilityObjectsControllerIntegrationTest.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/test/java/com/baeldung/thymeleaf/controller/FragmentsIntegrationTest.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/test/java/com/baeldung/thymeleaf/controller/LayoutDialectControllerIntegrationTest.java (100%) rename {spring-thymeleaf => spring-web-modules/spring-thymeleaf}/src/test/java/com/baeldung/thymeleaf/security/csrf/CsrfEnabledIntegrationTest.java (100%) diff --git a/pom.xml b/pom.xml index a28089e05a..86de8a389c 100644 --- a/pom.xml +++ b/pom.xml @@ -695,7 +695,6 @@ spring-swagger-codegen spring-threads - spring-thymeleaf spring-thymeleaf-2 spring-thymeleaf-3 @@ -1169,7 +1168,6 @@ spring-static-resources spring-swagger-codegen - spring-thymeleaf spring-thymeleaf-2 spring-thymeleaf-3 diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index bf6fda09f4..bda3edda6a 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -18,6 +18,7 @@ spring-mvc-basics-2 spring-mvc-basics-3 spring-mvc-basics-4 + spring-thymeleaf diff --git a/spring-thymeleaf/README.md b/spring-web-modules/spring-thymeleaf/README.md similarity index 100% rename from spring-thymeleaf/README.md rename to spring-web-modules/spring-thymeleaf/README.md diff --git a/spring-thymeleaf/pom.xml b/spring-web-modules/spring-thymeleaf/pom.xml similarity index 99% rename from spring-thymeleaf/pom.xml rename to spring-web-modules/spring-thymeleaf/pom.xml index 30f77dd73e..7b0cd2c510 100644 --- a/spring-thymeleaf/pom.xml +++ b/spring-web-modules/spring-thymeleaf/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-spring-5 0.0.1-SNAPSHOT - ../parent-spring-5 + ../../parent-spring-5 diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/InitSecurity.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/InitSecurity.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/InitSecurity.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/InitSecurity.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebApp.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebApp.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebApp.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebApp.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCConfig.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/config/WebMVCSecurity.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/BookController.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/BookController.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/BookController.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/BookController.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/DatesController.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/DatesController.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/DatesController.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/DatesController.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/ExpressionUtilityObjectsController.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/ExpressionUtilityObjectsController.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/ExpressionUtilityObjectsController.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/ExpressionUtilityObjectsController.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/FragmentsController.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/FragmentsController.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/FragmentsController.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/FragmentsController.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/HomeController.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/HomeController.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/HomeController.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/HomeController.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/InliningController.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/InliningController.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/InliningController.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/InliningController.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/LayoutDialectController.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/LayoutDialectController.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/LayoutDialectController.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/LayoutDialectController.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/StudentController.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/StudentController.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/StudentController.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/StudentController.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/TeacherController.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/TeacherController.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/TeacherController.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/controller/TeacherController.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/formatter/NameFormatter.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/formatter/NameFormatter.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/formatter/NameFormatter.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/formatter/NameFormatter.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Book.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Book.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Book.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Book.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Student.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Student.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Student.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Student.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Teacher.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Teacher.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Teacher.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/model/Teacher.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/service/BookService.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/service/BookService.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/service/BookService.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/service/BookService.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/utils/ArrayUtil.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/utils/ArrayUtil.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/utils/ArrayUtil.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/utils/ArrayUtil.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/utils/BookUtils.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/utils/BookUtils.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/utils/BookUtils.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/utils/BookUtils.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/utils/StudentUtils.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/utils/StudentUtils.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/utils/StudentUtils.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/utils/StudentUtils.java diff --git a/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/utils/TeacherUtils.java b/spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/utils/TeacherUtils.java similarity index 100% rename from spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/utils/TeacherUtils.java rename to spring-web-modules/spring-thymeleaf/src/main/java/com/baeldung/thymeleaf/utils/TeacherUtils.java diff --git a/spring-thymeleaf/src/main/resources/logback.xml b/spring-web-modules/spring-thymeleaf/src/main/resources/logback.xml similarity index 100% rename from spring-thymeleaf/src/main/resources/logback.xml rename to spring-web-modules/spring-thymeleaf/src/main/resources/logback.xml diff --git a/spring-thymeleaf/src/main/resources/messages_en.properties b/spring-web-modules/spring-thymeleaf/src/main/resources/messages_en.properties similarity index 100% rename from spring-thymeleaf/src/main/resources/messages_en.properties rename to spring-web-modules/spring-thymeleaf/src/main/resources/messages_en.properties diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/css/styles.css b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/css/styles.css similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/css/styles.css rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/css/styles.css diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/js/studentCheck.js b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/js/studentCheck.js similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/js/studentCheck.js rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/js/studentCheck.js diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/txt/studentsList.txt b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/txt/studentsList.txt similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/txt/studentsList.txt rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/txt/studentsList.txt diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/addStudent.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/addStudent.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/addStudent.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/addStudent.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/content.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/content.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/content.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/content.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/csrfAttack.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/csrfAttack.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/csrfAttack.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/csrfAttack.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/dates.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/dates.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/dates.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/dates.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/forms.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/forms.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/forms.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/forms.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/general.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/general.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/general.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/general.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/menus.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/menus.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/menus.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/menus.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/subtitle.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/subtitle.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/subtitle.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/subtitle.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/tables.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/tables.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/tables.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/fragments/tables.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/home.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/home.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/home.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/home.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/inliningExample.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/inliningExample.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/inliningExample.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/inliningExample.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/listBooks.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/listBooks.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/listBooks.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/listBooks.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/listStudents.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/listStudents.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/listStudents.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/listStudents.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/listTeachers.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/listTeachers.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/listTeachers.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/listTeachers.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/markup.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/markup.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/markup.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/markup.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/objects.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/objects.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/objects.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/objects.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/other.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/other.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/other.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/other.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/params.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/params.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/params.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/params.html diff --git a/spring-thymeleaf/src/main/webapp/WEB-INF/views/template.html b/spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/template.html similarity index 100% rename from spring-thymeleaf/src/main/webapp/WEB-INF/views/template.html rename to spring-web-modules/spring-thymeleaf/src/main/webapp/WEB-INF/views/template.html diff --git a/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/SpringContextTest.java b/spring-web-modules/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/SpringContextTest.java similarity index 100% rename from spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/SpringContextTest.java rename to spring-web-modules/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/SpringContextTest.java diff --git a/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/ExpressionUtilityObjectsControllerIntegrationTest.java b/spring-web-modules/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/ExpressionUtilityObjectsControllerIntegrationTest.java similarity index 100% rename from spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/ExpressionUtilityObjectsControllerIntegrationTest.java rename to spring-web-modules/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/ExpressionUtilityObjectsControllerIntegrationTest.java diff --git a/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/FragmentsIntegrationTest.java b/spring-web-modules/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/FragmentsIntegrationTest.java similarity index 100% rename from spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/FragmentsIntegrationTest.java rename to spring-web-modules/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/FragmentsIntegrationTest.java diff --git a/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/LayoutDialectControllerIntegrationTest.java b/spring-web-modules/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/LayoutDialectControllerIntegrationTest.java similarity index 100% rename from spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/LayoutDialectControllerIntegrationTest.java rename to spring-web-modules/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/controller/LayoutDialectControllerIntegrationTest.java diff --git a/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/security/csrf/CsrfEnabledIntegrationTest.java b/spring-web-modules/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/security/csrf/CsrfEnabledIntegrationTest.java similarity index 100% rename from spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/security/csrf/CsrfEnabledIntegrationTest.java rename to spring-web-modules/spring-thymeleaf/src/test/java/com/baeldung/thymeleaf/security/csrf/CsrfEnabledIntegrationTest.java From eb8724a0d71eecef9530ff157ba264674a8d6ec5 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 28 Dec 2020 12:10:31 +0100 Subject: [PATCH 156/361] JAVA-3544: Move spring-thymeleaf-2 into spring-web-modules --- pom.xml | 2 -- spring-web-modules/pom.xml | 1 + .../spring-thymeleaf-2}/README.md | 0 .../spring-thymeleaf-2}/pom.xml | 2 +- .../src/main/java/com/baeldung/thymeleaf/Application.java | 0 .../src/main/java/com/baeldung/thymeleaf/ThymeleafConfig.java | 0 .../com/baeldung/thymeleaf/arrays/ThymeleafArrayController.java | 0 .../booleanexpressions/BooleanExpressionsController.java | 0 .../src/main/java/com/baeldung/thymeleaf/customhtml/Course.java | 0 .../thymeleaf/customhtml/CourseRegistrationController.java | 0 .../src/main/java/com/baeldung/thymeleaf/enums/Color.java | 0 .../src/main/java/com/baeldung/thymeleaf/enums/Widget.java | 0 .../java/com/baeldung/thymeleaf/enums/WidgetController.java | 0 .../main/java/com/baeldung/thymeleaf/lists/ListsController.java | 0 .../main/java/com/baeldung/thymeleaf/mvcdata/BeanConfig.java | 0 .../java/com/baeldung/thymeleaf/mvcdata/EmailController.java | 0 .../com/baeldung/thymeleaf/mvcdata/repository/EmailData.java | 0 .../main/java/com/baeldung/thymeleaf/pathvariables/Detail.java | 0 .../main/java/com/baeldung/thymeleaf/pathvariables/Item.java | 0 .../thymeleaf/pathvariables/PathVariablesController.java | 0 .../thymeleaf/requestparameters/ParticipantController.java | 0 .../com/baeldung/thymeleaf/templatedir/HelloController.java | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/templates-2/hello.html | 0 .../src/main/resources/templates-2/participants.html | 0 .../src/main/resources/templates/booleans.html | 0 .../src/main/resources/templates/continents.html | 0 .../src/main/resources/templates/courseRegistration.html | 0 .../src/main/resources/templates/enums/new.html | 0 .../src/main/resources/templates/enums/view.html | 0 .../src/main/resources/templates/lists/contains.html | 0 .../src/main/resources/templates/lists/isEmpty.html | 0 .../src/main/resources/templates/lists/size.html | 0 .../src/main/resources/templates/lists/sort.html | 0 .../src/main/resources/templates/lists/toList.html | 0 .../src/main/resources/templates/mvcdata/email-bean-data.html | 0 .../resources/templates/mvcdata/email-model-attributes.html | 0 .../resources/templates/mvcdata/email-request-parameters.html | 0 .../main/resources/templates/mvcdata/email-servlet-context.html | 0 .../resources/templates/mvcdata/email-session-attributes.html | 0 .../src/main/resources/templates/pathvariables/index.html | 0 .../src/main/resources/templates/pathvariables/view.html | 0 .../thymeleaf/lists/ListsControllerIntegrationTest.java | 0 .../com/baeldung/thymeleaf/mvcdata/EmailControllerUnitTest.java | 0 44 files changed, 2 insertions(+), 3 deletions(-) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/README.md (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/pom.xml (97%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/Application.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/ThymeleafConfig.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/arrays/ThymeleafArrayController.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/booleanexpressions/BooleanExpressionsController.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/customhtml/Course.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/customhtml/CourseRegistrationController.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/enums/Color.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/enums/Widget.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/enums/WidgetController.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/lists/ListsController.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/mvcdata/BeanConfig.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/mvcdata/EmailController.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/mvcdata/repository/EmailData.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/pathvariables/Detail.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/pathvariables/Item.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/pathvariables/PathVariablesController.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/requestparameters/ParticipantController.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/java/com/baeldung/thymeleaf/templatedir/HelloController.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/application.properties (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates-2/hello.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates-2/participants.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/booleans.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/continents.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/courseRegistration.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/enums/new.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/enums/view.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/lists/contains.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/lists/isEmpty.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/lists/size.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/lists/sort.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/lists/toList.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/mvcdata/email-bean-data.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/mvcdata/email-model-attributes.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/mvcdata/email-request-parameters.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/mvcdata/email-servlet-context.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/mvcdata/email-session-attributes.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/pathvariables/index.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/main/resources/templates/pathvariables/view.html (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/test/java/com/baeldung/thymeleaf/lists/ListsControllerIntegrationTest.java (100%) rename {spring-thymeleaf-2 => spring-web-modules/spring-thymeleaf-2}/src/test/java/com/baeldung/thymeleaf/mvcdata/EmailControllerUnitTest.java (100%) diff --git a/pom.xml b/pom.xml index 204b873c58..f66433c612 100644 --- a/pom.xml +++ b/pom.xml @@ -694,7 +694,6 @@ spring-swagger-codegen spring-threads - spring-thymeleaf-2 spring-thymeleaf-3 spring-vault @@ -1165,7 +1164,6 @@ spring-static-resources spring-swagger-codegen - spring-thymeleaf-2 spring-thymeleaf-3 spring-vault diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index c1a85188d2..910af6a1bc 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -21,6 +21,7 @@ spring-mvc-crash spring-mvc-forms-jsp spring-thymeleaf + spring-thymeleaf-2 diff --git a/spring-thymeleaf-2/README.md b/spring-web-modules/spring-thymeleaf-2/README.md similarity index 100% rename from spring-thymeleaf-2/README.md rename to spring-web-modules/spring-thymeleaf-2/README.md diff --git a/spring-thymeleaf-2/pom.xml b/spring-web-modules/spring-thymeleaf-2/pom.xml similarity index 97% rename from spring-thymeleaf-2/pom.xml rename to spring-web-modules/spring-thymeleaf-2/pom.xml index 43f36d9887..ddcd1e1005 100644 --- a/spring-thymeleaf-2/pom.xml +++ b/spring-web-modules/spring-thymeleaf-2/pom.xml @@ -10,7 +10,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/Application.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/Application.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/Application.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/Application.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/ThymeleafConfig.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/ThymeleafConfig.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/ThymeleafConfig.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/ThymeleafConfig.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/arrays/ThymeleafArrayController.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/arrays/ThymeleafArrayController.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/arrays/ThymeleafArrayController.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/arrays/ThymeleafArrayController.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/booleanexpressions/BooleanExpressionsController.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/booleanexpressions/BooleanExpressionsController.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/booleanexpressions/BooleanExpressionsController.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/booleanexpressions/BooleanExpressionsController.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/customhtml/Course.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/customhtml/Course.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/customhtml/Course.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/customhtml/Course.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/customhtml/CourseRegistrationController.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/customhtml/CourseRegistrationController.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/customhtml/CourseRegistrationController.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/customhtml/CourseRegistrationController.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/enums/Color.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/enums/Color.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/enums/Color.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/enums/Color.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/enums/Widget.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/enums/Widget.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/enums/Widget.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/enums/Widget.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/enums/WidgetController.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/enums/WidgetController.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/enums/WidgetController.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/enums/WidgetController.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/lists/ListsController.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/lists/ListsController.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/lists/ListsController.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/lists/ListsController.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/BeanConfig.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/BeanConfig.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/BeanConfig.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/BeanConfig.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/EmailController.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/EmailController.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/EmailController.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/EmailController.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/repository/EmailData.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/repository/EmailData.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/repository/EmailData.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/repository/EmailData.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/pathvariables/Detail.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/pathvariables/Detail.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/pathvariables/Detail.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/pathvariables/Detail.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/pathvariables/Item.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/pathvariables/Item.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/pathvariables/Item.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/pathvariables/Item.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/pathvariables/PathVariablesController.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/pathvariables/PathVariablesController.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/pathvariables/PathVariablesController.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/pathvariables/PathVariablesController.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/requestparameters/ParticipantController.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/requestparameters/ParticipantController.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/requestparameters/ParticipantController.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/requestparameters/ParticipantController.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/templatedir/HelloController.java b/spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/templatedir/HelloController.java similarity index 100% rename from spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/templatedir/HelloController.java rename to spring-web-modules/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/templatedir/HelloController.java diff --git a/spring-thymeleaf-2/src/main/resources/application.properties b/spring-web-modules/spring-thymeleaf-2/src/main/resources/application.properties similarity index 100% rename from spring-thymeleaf-2/src/main/resources/application.properties rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/application.properties diff --git a/spring-thymeleaf-2/src/main/resources/templates-2/hello.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates-2/hello.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates-2/hello.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates-2/hello.html diff --git a/spring-thymeleaf-2/src/main/resources/templates-2/participants.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates-2/participants.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates-2/participants.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates-2/participants.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/booleans.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/booleans.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/booleans.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/booleans.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/continents.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/continents.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/continents.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/continents.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/courseRegistration.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/courseRegistration.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/courseRegistration.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/courseRegistration.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/enums/new.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/enums/new.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/enums/new.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/enums/new.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/enums/view.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/enums/view.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/enums/view.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/enums/view.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/lists/contains.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/lists/contains.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/lists/contains.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/lists/contains.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/lists/isEmpty.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/lists/isEmpty.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/lists/isEmpty.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/lists/isEmpty.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/lists/size.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/lists/size.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/lists/size.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/lists/size.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/lists/sort.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/lists/sort.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/lists/sort.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/lists/sort.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/lists/toList.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/lists/toList.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/lists/toList.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/lists/toList.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-bean-data.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-bean-data.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-bean-data.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-bean-data.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-model-attributes.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-model-attributes.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-model-attributes.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-model-attributes.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-request-parameters.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-request-parameters.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-request-parameters.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-request-parameters.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-servlet-context.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-servlet-context.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-servlet-context.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-servlet-context.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-session-attributes.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-session-attributes.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-session-attributes.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-session-attributes.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/pathvariables/index.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/pathvariables/index.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/pathvariables/index.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/pathvariables/index.html diff --git a/spring-thymeleaf-2/src/main/resources/templates/pathvariables/view.html b/spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/pathvariables/view.html similarity index 100% rename from spring-thymeleaf-2/src/main/resources/templates/pathvariables/view.html rename to spring-web-modules/spring-thymeleaf-2/src/main/resources/templates/pathvariables/view.html diff --git a/spring-thymeleaf-2/src/test/java/com/baeldung/thymeleaf/lists/ListsControllerIntegrationTest.java b/spring-web-modules/spring-thymeleaf-2/src/test/java/com/baeldung/thymeleaf/lists/ListsControllerIntegrationTest.java similarity index 100% rename from spring-thymeleaf-2/src/test/java/com/baeldung/thymeleaf/lists/ListsControllerIntegrationTest.java rename to spring-web-modules/spring-thymeleaf-2/src/test/java/com/baeldung/thymeleaf/lists/ListsControllerIntegrationTest.java diff --git a/spring-thymeleaf-2/src/test/java/com/baeldung/thymeleaf/mvcdata/EmailControllerUnitTest.java b/spring-web-modules/spring-thymeleaf-2/src/test/java/com/baeldung/thymeleaf/mvcdata/EmailControllerUnitTest.java similarity index 100% rename from spring-thymeleaf-2/src/test/java/com/baeldung/thymeleaf/mvcdata/EmailControllerUnitTest.java rename to spring-web-modules/spring-thymeleaf-2/src/test/java/com/baeldung/thymeleaf/mvcdata/EmailControllerUnitTest.java From d1af00c8c95be12b016fc0996600178e12c058d2 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 28 Dec 2020 14:51:36 +0100 Subject: [PATCH 157/361] JAVA-3545: Move spring-thymeleaf-3 into spring-web-modules --- pom.xml | 3 --- spring-web-modules/pom.xml | 1 + .../spring-thymeleaf-3}/README.md | 0 .../spring-thymeleaf-3}/pom.xml | 2 +- .../src/main/java/com/baeldung/thymeleaf/Application.java | 0 .../src/main/java/com/baeldung/thymeleaf/articles/Article.java | 0 .../com/baeldung/thymeleaf/articles/ArticlesController.java | 0 .../main/java/com/baeldung/thymeleaf/blog/BlogController.java | 0 .../src/main/java/com/baeldung/thymeleaf/blog/BlogDTO.java | 0 .../conditionalclasses/ConditionalClassesController.java | 0 .../com/baeldung/thymeleaf/cssandjs/CssAndJsApplication.java | 0 .../com/baeldung/thymeleaf/cssandjs/CssAndJsController.java | 0 .../baeldung/thymeleaf/currencies/CurrenciesController.java | 0 .../src/main/java/com/baeldung/thymeleaf/option/Student.java | 0 .../java/com/baeldung/thymeleaf/option/StudentController.java | 0 .../src/main/resources/static/js/cssandjs/actions.js | 0 .../src/main/resources/static/styles/cssandjs/main.css | 0 .../src/main/resources/templates/articles/articles-list.html | 0 .../src/main/resources/templates/blog/blog-new.html | 0 .../templates/conditionalclasses/conditionalclasses.html | 0 .../src/main/resources/templates/cssandjs/styledPage.html | 0 .../src/main/resources/templates/currencies/currencies.html | 0 .../src/main/resources/templates/option/studentForm.html | 0 .../com/baeldung/thymeleaf/ApplicationIntegrationTest.java | 0 .../thymeleaf/cssandjs/CssAndJsControllerIntegrationTest.java | 0 .../currencies/CurrenciesControllerIntegrationTest.java | 0 26 files changed, 2 insertions(+), 4 deletions(-) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/README.md (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/pom.xml (98%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/Application.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/articles/Article.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/articles/ArticlesController.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/blog/BlogDTO.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/conditionalclasses/ConditionalClassesController.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsApplication.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsController.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/currencies/CurrenciesController.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/option/Student.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/option/StudentController.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/resources/static/js/cssandjs/actions.js (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/resources/static/styles/cssandjs/main.css (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/resources/templates/articles/articles-list.html (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/resources/templates/blog/blog-new.html (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/resources/templates/conditionalclasses/conditionalclasses.html (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/resources/templates/cssandjs/styledPage.html (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/resources/templates/currencies/currencies.html (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/resources/templates/option/studentForm.html (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/test/java/com/baeldung/thymeleaf/ApplicationIntegrationTest.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/test/java/com/baeldung/thymeleaf/cssandjs/CssAndJsControllerIntegrationTest.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/test/java/com/baeldung/thymeleaf/currencies/CurrenciesControllerIntegrationTest.java (100%) diff --git a/pom.xml b/pom.xml index f66433c612..14565fe87d 100644 --- a/pom.xml +++ b/pom.xml @@ -694,7 +694,6 @@ spring-swagger-codegen spring-threads - spring-thymeleaf-3 spring-vault spring-vertx @@ -1164,8 +1163,6 @@ spring-static-resources spring-swagger-codegen - spring-thymeleaf-3 - spring-vault spring-vertx diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index 910af6a1bc..c5d9b33dd1 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -22,6 +22,7 @@ spring-mvc-forms-jsp spring-thymeleaf spring-thymeleaf-2 + spring-thymeleaf-3 diff --git a/spring-thymeleaf-3/README.md b/spring-web-modules/spring-thymeleaf-3/README.md similarity index 100% rename from spring-thymeleaf-3/README.md rename to spring-web-modules/spring-thymeleaf-3/README.md diff --git a/spring-thymeleaf-3/pom.xml b/spring-web-modules/spring-thymeleaf-3/pom.xml similarity index 98% rename from spring-thymeleaf-3/pom.xml rename to spring-web-modules/spring-thymeleaf-3/pom.xml index 7c58115d11..6dd1267e8a 100644 --- a/spring-thymeleaf-3/pom.xml +++ b/spring-web-modules/spring-thymeleaf-3/pom.xml @@ -10,7 +10,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/Application.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/Application.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/Application.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/Application.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/articles/Article.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/articles/Article.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/articles/Article.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/articles/Article.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/articles/ArticlesController.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/articles/ArticlesController.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/articles/ArticlesController.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/articles/ArticlesController.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogDTO.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogDTO.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogDTO.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogDTO.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/conditionalclasses/ConditionalClassesController.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/conditionalclasses/ConditionalClassesController.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/conditionalclasses/ConditionalClassesController.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/conditionalclasses/ConditionalClassesController.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsApplication.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsApplication.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsApplication.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsApplication.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsController.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsController.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsController.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsController.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/currencies/CurrenciesController.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/currencies/CurrenciesController.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/currencies/CurrenciesController.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/currencies/CurrenciesController.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/option/Student.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/option/Student.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/option/Student.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/option/Student.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/option/StudentController.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/option/StudentController.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/option/StudentController.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/option/StudentController.java diff --git a/spring-thymeleaf-3/src/main/resources/static/js/cssandjs/actions.js b/spring-web-modules/spring-thymeleaf-3/src/main/resources/static/js/cssandjs/actions.js similarity index 100% rename from spring-thymeleaf-3/src/main/resources/static/js/cssandjs/actions.js rename to spring-web-modules/spring-thymeleaf-3/src/main/resources/static/js/cssandjs/actions.js diff --git a/spring-thymeleaf-3/src/main/resources/static/styles/cssandjs/main.css b/spring-web-modules/spring-thymeleaf-3/src/main/resources/static/styles/cssandjs/main.css similarity index 100% rename from spring-thymeleaf-3/src/main/resources/static/styles/cssandjs/main.css rename to spring-web-modules/spring-thymeleaf-3/src/main/resources/static/styles/cssandjs/main.css diff --git a/spring-thymeleaf-3/src/main/resources/templates/articles/articles-list.html b/spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/articles/articles-list.html similarity index 100% rename from spring-thymeleaf-3/src/main/resources/templates/articles/articles-list.html rename to spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/articles/articles-list.html diff --git a/spring-thymeleaf-3/src/main/resources/templates/blog/blog-new.html b/spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/blog/blog-new.html similarity index 100% rename from spring-thymeleaf-3/src/main/resources/templates/blog/blog-new.html rename to spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/blog/blog-new.html diff --git a/spring-thymeleaf-3/src/main/resources/templates/conditionalclasses/conditionalclasses.html b/spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/conditionalclasses/conditionalclasses.html similarity index 100% rename from spring-thymeleaf-3/src/main/resources/templates/conditionalclasses/conditionalclasses.html rename to spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/conditionalclasses/conditionalclasses.html diff --git a/spring-thymeleaf-3/src/main/resources/templates/cssandjs/styledPage.html b/spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/cssandjs/styledPage.html similarity index 100% rename from spring-thymeleaf-3/src/main/resources/templates/cssandjs/styledPage.html rename to spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/cssandjs/styledPage.html diff --git a/spring-thymeleaf-3/src/main/resources/templates/currencies/currencies.html b/spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/currencies/currencies.html similarity index 100% rename from spring-thymeleaf-3/src/main/resources/templates/currencies/currencies.html rename to spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/currencies/currencies.html diff --git a/spring-thymeleaf-3/src/main/resources/templates/option/studentForm.html b/spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/option/studentForm.html similarity index 100% rename from spring-thymeleaf-3/src/main/resources/templates/option/studentForm.html rename to spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/option/studentForm.html diff --git a/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/ApplicationIntegrationTest.java b/spring-web-modules/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/ApplicationIntegrationTest.java similarity index 100% rename from spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/ApplicationIntegrationTest.java rename to spring-web-modules/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/ApplicationIntegrationTest.java diff --git a/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/cssandjs/CssAndJsControllerIntegrationTest.java b/spring-web-modules/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/cssandjs/CssAndJsControllerIntegrationTest.java similarity index 100% rename from spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/cssandjs/CssAndJsControllerIntegrationTest.java rename to spring-web-modules/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/cssandjs/CssAndJsControllerIntegrationTest.java diff --git a/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/currencies/CurrenciesControllerIntegrationTest.java b/spring-web-modules/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/currencies/CurrenciesControllerIntegrationTest.java similarity index 100% rename from spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/currencies/CurrenciesControllerIntegrationTest.java rename to spring-web-modules/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/currencies/CurrenciesControllerIntegrationTest.java From 559fb4eb7f650bf9158bd1825b8c590e7567291e Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Mon, 28 Dec 2020 22:42:11 +0100 Subject: [PATCH 158/361] JAVA-3545: Move spring-thymeleaf-3 into spring-web-modules --- pom.xml | 3 --- spring-web-modules/pom.xml | 1 + .../spring-thymeleaf-3}/README.md | 0 .../spring-thymeleaf-3}/pom.xml | 2 +- .../src/main/java/com/baeldung/thymeleaf/Application.java | 0 .../src/main/java/com/baeldung/thymeleaf/articles/Article.java | 0 .../com/baeldung/thymeleaf/articles/ArticlesController.java | 0 .../main/java/com/baeldung/thymeleaf/blog/BlogController.java | 0 .../src/main/java/com/baeldung/thymeleaf/blog/BlogDTO.java | 0 .../conditionalclasses/ConditionalClassesController.java | 0 .../com/baeldung/thymeleaf/cssandjs/CssAndJsApplication.java | 0 .../com/baeldung/thymeleaf/cssandjs/CssAndJsController.java | 0 .../baeldung/thymeleaf/currencies/CurrenciesController.java | 0 .../src/main/java/com/baeldung/thymeleaf/option/Student.java | 0 .../java/com/baeldung/thymeleaf/option/StudentController.java | 0 .../src/main/resources/static/js/cssandjs/actions.js | 0 .../src/main/resources/static/styles/cssandjs/main.css | 0 .../src/main/resources/templates/articles/articles-list.html | 0 .../src/main/resources/templates/blog/blog-new.html | 0 .../templates/conditionalclasses/conditionalclasses.html | 0 .../src/main/resources/templates/cssandjs/styledPage.html | 0 .../src/main/resources/templates/currencies/currencies.html | 0 .../src/main/resources/templates/option/studentForm.html | 0 .../com/baeldung/thymeleaf/ApplicationIntegrationTest.java | 0 .../thymeleaf/cssandjs/CssAndJsControllerIntegrationTest.java | 0 .../currencies/CurrenciesControllerIntegrationTest.java | 0 26 files changed, 2 insertions(+), 4 deletions(-) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/README.md (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/pom.xml (98%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/Application.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/articles/Article.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/articles/ArticlesController.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/blog/BlogDTO.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/conditionalclasses/ConditionalClassesController.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsApplication.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsController.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/currencies/CurrenciesController.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/option/Student.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/java/com/baeldung/thymeleaf/option/StudentController.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/resources/static/js/cssandjs/actions.js (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/resources/static/styles/cssandjs/main.css (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/resources/templates/articles/articles-list.html (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/resources/templates/blog/blog-new.html (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/resources/templates/conditionalclasses/conditionalclasses.html (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/resources/templates/cssandjs/styledPage.html (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/resources/templates/currencies/currencies.html (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/main/resources/templates/option/studentForm.html (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/test/java/com/baeldung/thymeleaf/ApplicationIntegrationTest.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/test/java/com/baeldung/thymeleaf/cssandjs/CssAndJsControllerIntegrationTest.java (100%) rename {spring-thymeleaf-3 => spring-web-modules/spring-thymeleaf-3}/src/test/java/com/baeldung/thymeleaf/currencies/CurrenciesControllerIntegrationTest.java (100%) diff --git a/pom.xml b/pom.xml index f66433c612..14565fe87d 100644 --- a/pom.xml +++ b/pom.xml @@ -694,7 +694,6 @@ spring-swagger-codegen spring-threads - spring-thymeleaf-3 spring-vault spring-vertx @@ -1164,8 +1163,6 @@ spring-static-resources spring-swagger-codegen - spring-thymeleaf-3 - spring-vault spring-vertx diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index 910af6a1bc..c5d9b33dd1 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -22,6 +22,7 @@ spring-mvc-forms-jsp spring-thymeleaf spring-thymeleaf-2 + spring-thymeleaf-3 diff --git a/spring-thymeleaf-3/README.md b/spring-web-modules/spring-thymeleaf-3/README.md similarity index 100% rename from spring-thymeleaf-3/README.md rename to spring-web-modules/spring-thymeleaf-3/README.md diff --git a/spring-thymeleaf-3/pom.xml b/spring-web-modules/spring-thymeleaf-3/pom.xml similarity index 98% rename from spring-thymeleaf-3/pom.xml rename to spring-web-modules/spring-thymeleaf-3/pom.xml index 7c58115d11..6dd1267e8a 100644 --- a/spring-thymeleaf-3/pom.xml +++ b/spring-web-modules/spring-thymeleaf-3/pom.xml @@ -10,7 +10,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/Application.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/Application.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/Application.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/Application.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/articles/Article.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/articles/Article.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/articles/Article.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/articles/Article.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/articles/ArticlesController.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/articles/ArticlesController.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/articles/ArticlesController.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/articles/ArticlesController.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogController.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogDTO.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogDTO.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogDTO.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/blog/BlogDTO.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/conditionalclasses/ConditionalClassesController.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/conditionalclasses/ConditionalClassesController.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/conditionalclasses/ConditionalClassesController.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/conditionalclasses/ConditionalClassesController.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsApplication.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsApplication.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsApplication.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsApplication.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsController.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsController.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsController.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/cssandjs/CssAndJsController.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/currencies/CurrenciesController.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/currencies/CurrenciesController.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/currencies/CurrenciesController.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/currencies/CurrenciesController.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/option/Student.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/option/Student.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/option/Student.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/option/Student.java diff --git a/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/option/StudentController.java b/spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/option/StudentController.java similarity index 100% rename from spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/option/StudentController.java rename to spring-web-modules/spring-thymeleaf-3/src/main/java/com/baeldung/thymeleaf/option/StudentController.java diff --git a/spring-thymeleaf-3/src/main/resources/static/js/cssandjs/actions.js b/spring-web-modules/spring-thymeleaf-3/src/main/resources/static/js/cssandjs/actions.js similarity index 100% rename from spring-thymeleaf-3/src/main/resources/static/js/cssandjs/actions.js rename to spring-web-modules/spring-thymeleaf-3/src/main/resources/static/js/cssandjs/actions.js diff --git a/spring-thymeleaf-3/src/main/resources/static/styles/cssandjs/main.css b/spring-web-modules/spring-thymeleaf-3/src/main/resources/static/styles/cssandjs/main.css similarity index 100% rename from spring-thymeleaf-3/src/main/resources/static/styles/cssandjs/main.css rename to spring-web-modules/spring-thymeleaf-3/src/main/resources/static/styles/cssandjs/main.css diff --git a/spring-thymeleaf-3/src/main/resources/templates/articles/articles-list.html b/spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/articles/articles-list.html similarity index 100% rename from spring-thymeleaf-3/src/main/resources/templates/articles/articles-list.html rename to spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/articles/articles-list.html diff --git a/spring-thymeleaf-3/src/main/resources/templates/blog/blog-new.html b/spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/blog/blog-new.html similarity index 100% rename from spring-thymeleaf-3/src/main/resources/templates/blog/blog-new.html rename to spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/blog/blog-new.html diff --git a/spring-thymeleaf-3/src/main/resources/templates/conditionalclasses/conditionalclasses.html b/spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/conditionalclasses/conditionalclasses.html similarity index 100% rename from spring-thymeleaf-3/src/main/resources/templates/conditionalclasses/conditionalclasses.html rename to spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/conditionalclasses/conditionalclasses.html diff --git a/spring-thymeleaf-3/src/main/resources/templates/cssandjs/styledPage.html b/spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/cssandjs/styledPage.html similarity index 100% rename from spring-thymeleaf-3/src/main/resources/templates/cssandjs/styledPage.html rename to spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/cssandjs/styledPage.html diff --git a/spring-thymeleaf-3/src/main/resources/templates/currencies/currencies.html b/spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/currencies/currencies.html similarity index 100% rename from spring-thymeleaf-3/src/main/resources/templates/currencies/currencies.html rename to spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/currencies/currencies.html diff --git a/spring-thymeleaf-3/src/main/resources/templates/option/studentForm.html b/spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/option/studentForm.html similarity index 100% rename from spring-thymeleaf-3/src/main/resources/templates/option/studentForm.html rename to spring-web-modules/spring-thymeleaf-3/src/main/resources/templates/option/studentForm.html diff --git a/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/ApplicationIntegrationTest.java b/spring-web-modules/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/ApplicationIntegrationTest.java similarity index 100% rename from spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/ApplicationIntegrationTest.java rename to spring-web-modules/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/ApplicationIntegrationTest.java diff --git a/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/cssandjs/CssAndJsControllerIntegrationTest.java b/spring-web-modules/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/cssandjs/CssAndJsControllerIntegrationTest.java similarity index 100% rename from spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/cssandjs/CssAndJsControllerIntegrationTest.java rename to spring-web-modules/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/cssandjs/CssAndJsControllerIntegrationTest.java diff --git a/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/currencies/CurrenciesControllerIntegrationTest.java b/spring-web-modules/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/currencies/CurrenciesControllerIntegrationTest.java similarity index 100% rename from spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/currencies/CurrenciesControllerIntegrationTest.java rename to spring-web-modules/spring-thymeleaf-3/src/test/java/com/baeldung/thymeleaf/currencies/CurrenciesControllerIntegrationTest.java From 061cf1a1ed4d1e654c46dca6c02562e38ef3e5c8 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Tue, 29 Dec 2020 00:22:02 +0100 Subject: [PATCH 159/361] JAVA-3496: Use a single common QueryApplication --- .../{UserApplication.java => QueryApplication.java} | 4 ++-- .../spring/data/jpa/query/datetime/Application.java | 13 ------------- 2 files changed, 2 insertions(+), 15 deletions(-) rename persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/{UserApplication.java => QueryApplication.java} (72%) delete mode 100644 persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Application.java diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserApplication.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/QueryApplication.java similarity index 72% rename from persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserApplication.java rename to persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/QueryApplication.java index 0f7b19ec47..48c29eda23 100644 --- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/UserApplication.java +++ b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/QueryApplication.java @@ -4,10 +4,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class UserApplication { +public class QueryApplication { public static void main(String[] args) { - SpringApplication.run(UserApplication.class, args); + SpringApplication.run(QueryApplication.class, args); } } diff --git a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Application.java b/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Application.java deleted file mode 100644 index 81e5a2f790..0000000000 --- a/persistence-modules/spring-data-jpa-query-2/src/main/java/com/baeldung/spring/data/jpa/query/datetime/Application.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.baeldung.spring.data.jpa.query.datetime; - -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); - } - -} From 05c7fa926932fae40dc04c6d049775694ea5e033 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 29 Dec 2020 11:36:14 +0530 Subject: [PATCH 160/361] JAVA-3524: Moved spring-mvc-forms-thymeleaf inside spring-web-modules --- .../spring-mvc-forms-thymeleaf}/README.md | 0 .../spring-mvc-forms-thymeleaf}/pom.xml | 2 +- .../src/main/java/com/baeldung/listbindingexample/Book.java | 0 .../main/java/com/baeldung/listbindingexample/BookService.java | 0 .../java/com/baeldung/listbindingexample/BooksCreationDto.java | 0 .../src/main/java/com/baeldung/listbindingexample/Config.java | 0 .../com/baeldung/listbindingexample/InMemoryBookService.java | 0 .../com/baeldung/listbindingexample/ListBindingApplication.java | 0 .../baeldung/listbindingexample/MultipleBooksController.java | 0 .../src/main/java/com/baeldung/sessionattrs/Config.java | 0 .../java/com/baeldung/sessionattrs/SessionAttrsApplication.java | 0 .../baeldung/sessionattrs/TodoControllerWithScopedProxy.java | 0 .../sessionattrs/TodoControllerWithSessionAttributes.java | 0 .../src/main/java/com/baeldung/sessionattrs/TodoItem.java | 0 .../src/main/java/com/baeldung/sessionattrs/TodoList.java | 0 .../src/main/resources/application.properties | 0 .../spring-mvc-forms-thymeleaf}/src/main/resources/logback.xml | 0 .../src/main/resources/templates/books/allBooks.html | 0 .../src/main/resources/templates/books/createBooksForm.html | 0 .../src/main/resources/templates/books/editBooksForm.html | 0 .../src/main/resources/templates/books/index.html | 0 .../src/main/resources/templates/sessionattrs/index.html | 0 .../main/resources/templates/sessionattrs/scopedproxyform.html | 0 .../main/resources/templates/sessionattrs/scopedproxytodos.html | 0 .../resources/templates/sessionattrs/sessionattributesform.html | 0 .../templates/sessionattrs/sessionattributestodos.html | 0 .../com}/baeldung/listbindingexample/SpringContextTest.java | 0 .../sessionattrs/SessionAttrsApplicationIntegrationTest.java | 0 .../test/java/com}/baeldung/sessionattrs/SpringContextTest.java | 0 .../src/test/java/com/baeldung/sessionattrs/TestConfig.java | 0 .../TodoControllerWithScopedProxyIntegrationTest.java | 0 .../TodoControllerWithSessionAttributesIntegrationTest.java | 0 32 files changed, 1 insertion(+), 1 deletion(-) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/README.md (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/pom.xml (96%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/java/com/baeldung/listbindingexample/Book.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/java/com/baeldung/listbindingexample/BookService.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/java/com/baeldung/listbindingexample/BooksCreationDto.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/java/com/baeldung/listbindingexample/Config.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/java/com/baeldung/listbindingexample/InMemoryBookService.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/java/com/baeldung/listbindingexample/ListBindingApplication.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/java/com/baeldung/listbindingexample/MultipleBooksController.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/java/com/baeldung/sessionattrs/Config.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/java/com/baeldung/sessionattrs/SessionAttrsApplication.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/java/com/baeldung/sessionattrs/TodoControllerWithScopedProxy.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/java/com/baeldung/sessionattrs/TodoControllerWithSessionAttributes.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/java/com/baeldung/sessionattrs/TodoItem.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/java/com/baeldung/sessionattrs/TodoList.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/resources/application.properties (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/resources/logback.xml (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/resources/templates/books/allBooks.html (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/resources/templates/books/createBooksForm.html (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/resources/templates/books/editBooksForm.html (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/resources/templates/books/index.html (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/resources/templates/sessionattrs/index.html (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/resources/templates/sessionattrs/scopedproxyform.html (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/resources/templates/sessionattrs/scopedproxytodos.html (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/resources/templates/sessionattrs/sessionattributesform.html (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/main/resources/templates/sessionattrs/sessionattributestodos.html (100%) rename {spring-mvc-forms-thymeleaf/src/test/java/org => spring-web-modules/spring-mvc-forms-thymeleaf/src/test/java/com}/baeldung/listbindingexample/SpringContextTest.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/test/java/com/baeldung/sessionattrs/SessionAttrsApplicationIntegrationTest.java (100%) rename {spring-mvc-forms-thymeleaf/src/test/java/org => spring-web-modules/spring-mvc-forms-thymeleaf/src/test/java/com}/baeldung/sessionattrs/SpringContextTest.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/test/java/com/baeldung/sessionattrs/TestConfig.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/test/java/com/baeldung/sessionattrs/TodoControllerWithScopedProxyIntegrationTest.java (100%) rename {spring-mvc-forms-thymeleaf => spring-web-modules/spring-mvc-forms-thymeleaf}/src/test/java/com/baeldung/sessionattrs/TodoControllerWithSessionAttributesIntegrationTest.java (100%) diff --git a/spring-mvc-forms-thymeleaf/README.md b/spring-web-modules/spring-mvc-forms-thymeleaf/README.md similarity index 100% rename from spring-mvc-forms-thymeleaf/README.md rename to spring-web-modules/spring-mvc-forms-thymeleaf/README.md diff --git a/spring-mvc-forms-thymeleaf/pom.xml b/spring-web-modules/spring-mvc-forms-thymeleaf/pom.xml similarity index 96% rename from spring-mvc-forms-thymeleaf/pom.xml rename to spring-web-modules/spring-mvc-forms-thymeleaf/pom.xml index 2aed7f70ad..641f64b93c 100644 --- a/spring-mvc-forms-thymeleaf/pom.xml +++ b/spring-web-modules/spring-mvc-forms-thymeleaf/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/Book.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/Book.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/Book.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/Book.java diff --git a/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/BookService.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/BookService.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/BookService.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/BookService.java diff --git a/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/BooksCreationDto.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/BooksCreationDto.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/BooksCreationDto.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/BooksCreationDto.java diff --git a/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/Config.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/Config.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/Config.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/Config.java diff --git a/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/InMemoryBookService.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/InMemoryBookService.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/InMemoryBookService.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/InMemoryBookService.java diff --git a/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/ListBindingApplication.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/ListBindingApplication.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/ListBindingApplication.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/ListBindingApplication.java diff --git a/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/MultipleBooksController.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/MultipleBooksController.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/MultipleBooksController.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/listbindingexample/MultipleBooksController.java diff --git a/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/Config.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/Config.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/Config.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/Config.java diff --git a/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/SessionAttrsApplication.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/SessionAttrsApplication.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/SessionAttrsApplication.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/SessionAttrsApplication.java diff --git a/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/TodoControllerWithScopedProxy.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/TodoControllerWithScopedProxy.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/TodoControllerWithScopedProxy.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/TodoControllerWithScopedProxy.java diff --git a/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/TodoControllerWithSessionAttributes.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/TodoControllerWithSessionAttributes.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/TodoControllerWithSessionAttributes.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/TodoControllerWithSessionAttributes.java diff --git a/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/TodoItem.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/TodoItem.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/TodoItem.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/TodoItem.java diff --git a/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/TodoList.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/TodoList.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/TodoList.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/java/com/baeldung/sessionattrs/TodoList.java diff --git a/spring-mvc-forms-thymeleaf/src/main/resources/application.properties b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/application.properties similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/resources/application.properties rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/application.properties diff --git a/spring-mvc-forms-thymeleaf/src/main/resources/logback.xml b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/logback.xml similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/resources/logback.xml rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/logback.xml diff --git a/spring-mvc-forms-thymeleaf/src/main/resources/templates/books/allBooks.html b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/books/allBooks.html similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/resources/templates/books/allBooks.html rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/books/allBooks.html diff --git a/spring-mvc-forms-thymeleaf/src/main/resources/templates/books/createBooksForm.html b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/books/createBooksForm.html similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/resources/templates/books/createBooksForm.html rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/books/createBooksForm.html diff --git a/spring-mvc-forms-thymeleaf/src/main/resources/templates/books/editBooksForm.html b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/books/editBooksForm.html similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/resources/templates/books/editBooksForm.html rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/books/editBooksForm.html diff --git a/spring-mvc-forms-thymeleaf/src/main/resources/templates/books/index.html b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/books/index.html similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/resources/templates/books/index.html rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/books/index.html diff --git a/spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/index.html b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/index.html similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/index.html rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/index.html diff --git a/spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/scopedproxyform.html b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/scopedproxyform.html similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/scopedproxyform.html rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/scopedproxyform.html diff --git a/spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/scopedproxytodos.html b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/scopedproxytodos.html similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/scopedproxytodos.html rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/scopedproxytodos.html diff --git a/spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/sessionattributesform.html b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/sessionattributesform.html similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/sessionattributesform.html rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/sessionattributesform.html diff --git a/spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/sessionattributestodos.html b/spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/sessionattributestodos.html similarity index 100% rename from spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/sessionattributestodos.html rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/main/resources/templates/sessionattrs/sessionattributestodos.html diff --git a/spring-mvc-forms-thymeleaf/src/test/java/org/baeldung/listbindingexample/SpringContextTest.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/listbindingexample/SpringContextTest.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/test/java/org/baeldung/listbindingexample/SpringContextTest.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/listbindingexample/SpringContextTest.java diff --git a/spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/SessionAttrsApplicationIntegrationTest.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/SessionAttrsApplicationIntegrationTest.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/SessionAttrsApplicationIntegrationTest.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/SessionAttrsApplicationIntegrationTest.java diff --git a/spring-mvc-forms-thymeleaf/src/test/java/org/baeldung/sessionattrs/SpringContextTest.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/SpringContextTest.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/test/java/org/baeldung/sessionattrs/SpringContextTest.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/SpringContextTest.java diff --git a/spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/TestConfig.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/TestConfig.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/TestConfig.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/TestConfig.java diff --git a/spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/TodoControllerWithScopedProxyIntegrationTest.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/TodoControllerWithScopedProxyIntegrationTest.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/TodoControllerWithScopedProxyIntegrationTest.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/TodoControllerWithScopedProxyIntegrationTest.java diff --git a/spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/TodoControllerWithSessionAttributesIntegrationTest.java b/spring-web-modules/spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/TodoControllerWithSessionAttributesIntegrationTest.java similarity index 100% rename from spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/TodoControllerWithSessionAttributesIntegrationTest.java rename to spring-web-modules/spring-mvc-forms-thymeleaf/src/test/java/com/baeldung/sessionattrs/TodoControllerWithSessionAttributesIntegrationTest.java From bcfbe6102ca657416983f90559194089eddc1412 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 29 Dec 2020 11:37:05 +0530 Subject: [PATCH 161/361] JAVA-3524: 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 910af6a1bc..730647d9e2 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -20,6 +20,7 @@ spring-mvc-basics-4 spring-mvc-crash spring-mvc-forms-jsp + spring-mvc-forms-thymeleaf spring-thymeleaf spring-thymeleaf-2 From 1e89df8bcfddb6107f68f76949395c1b22750bec Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 29 Dec 2020 11:38:10 +0530 Subject: [PATCH 162/361] JAVA-3524: removed module spring-mvc-forms-thymeleaf from main pom --- pom.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pom.xml b/pom.xml index f66433c612..7db1c5bc54 100644 --- a/pom.xml +++ b/pom.xml @@ -658,7 +658,6 @@ spring-mobile spring-mockito - spring-mvc-forms-thymeleaf spring-mvc-java spring-mvc-java-2 @@ -1130,7 +1129,6 @@ spring-mobile spring-mockito - spring-mvc-forms-thymeleaf spring-mvc-java spring-mvc-java-2 From 9b1abb07fbafaadcb5151dedb1f7b435eff9841e Mon Sep 17 00:00:00 2001 From: Anshul BANSAL Date: Tue, 29 Dec 2020 11:02:52 +0200 Subject: [PATCH 163/361] BAEL-4472- Binary Semaphore vs a ReentrantLock - Unit test added --- ...inarySemaphoreVsReentrantLockUnitTest.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/binarysemaphorereentrantlock/BinarySemaphoreVsReentrantLockUnitTest.java diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/binarysemaphorereentrantlock/BinarySemaphoreVsReentrantLockUnitTest.java b/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/binarysemaphorereentrantlock/BinarySemaphoreVsReentrantLockUnitTest.java new file mode 100644 index 0000000000..f456e82f39 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/binarysemaphorereentrantlock/BinarySemaphoreVsReentrantLockUnitTest.java @@ -0,0 +1,58 @@ +package com.baeldung.binarysemaphorereentrantlock; + +import static org.junit.Assert.assertEquals; +import java.util.concurrent.Semaphore; +import java.util.concurrent.locks.ReentrantLock; + +import org.junit.Test; + +public class BinarySemaphoreVsReentrantLockUnitTest { + + @Test + public void givenBinarySemaphore_whenAcquireAndRelease_thenCheckAvailablePermits() throws InterruptedException { + Semaphore binarySemaphore = new Semaphore(1); + try { + binarySemaphore.acquire(); + assertEquals(0, binarySemaphore.availablePermits()); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + binarySemaphore.release(); + assertEquals(1, binarySemaphore.availablePermits()); + } + } + + @Test + public void givenReentrantLock_whenLockAndUnlock_thenCheckHoldCountAndIsLocked() throws InterruptedException { + ReentrantLock reentrantLock = new ReentrantLock(); + try { + reentrantLock.lock(); + assertEquals(1, reentrantLock.getHoldCount()); + assertEquals(true, reentrantLock.isLocked()); + } finally { + reentrantLock.unlock(); + assertEquals(0, reentrantLock.getHoldCount()); + assertEquals(false, reentrantLock.isLocked()); + } + } + + @Test + public void givenReentrantLock_whenLockMultipleTimes_thenUnlockMultipleTimesToRelease() throws InterruptedException { + ReentrantLock reentrantLock = new ReentrantLock(); + try { + reentrantLock.lock(); + reentrantLock.lock(); + assertEquals(2, reentrantLock.getHoldCount()); + assertEquals(true, reentrantLock.isLocked()); + } finally { + reentrantLock.unlock(); + assertEquals(1, reentrantLock.getHoldCount()); + assertEquals(true, reentrantLock.isLocked()); + + reentrantLock.unlock(); + assertEquals(0, reentrantLock.getHoldCount()); + assertEquals(false, reentrantLock.isLocked()); + } + } + +} From 80c8a10520b30fdff29e8454c501909e628a017f Mon Sep 17 00:00:00 2001 From: Krzysztof Majewski Date: Tue, 29 Dec 2020 10:38:58 +0100 Subject: [PATCH 164/361] BAEL-4745 Update "How to Configure Spring Boot Tomcat" article --- .../src/main/resources/application-tomcat.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-runtime/src/main/resources/application-tomcat.properties b/spring-boot-modules/spring-boot-runtime/src/main/resources/application-tomcat.properties index 42d03a066e..ba91c5f3b2 100644 --- a/spring-boot-modules/spring-boot-runtime/src/main/resources/application-tomcat.properties +++ b/spring-boot-modules/spring-boot-runtime/src/main/resources/application-tomcat.properties @@ -9,7 +9,7 @@ server.error.include-exception=true server.error.include-stacktrace=always ## Server connections configuration -server.tomcat.max-threads=200 +server.tomcat.threads.max=200 server.connection-timeout=5s server.max-http-header-size=8KB server.tomcat.max-swallow-size=2MB From 7a308db8023bc41e4ac8145abf567822f5a1b14c Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Tue, 29 Dec 2020 12:12:50 +0200 Subject: [PATCH 165/361] Update README.md --- spring-boot-modules/spring-boot-deployment/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-deployment/README.md b/spring-boot-modules/spring-boot-deployment/README.md index b6aa468098..85f288d33b 100644 --- a/spring-boot-modules/spring-boot-deployment/README.md +++ b/spring-boot-modules/spring-boot-deployment/README.md @@ -5,6 +5,5 @@ This module contains articles about deployment of a Spring Boot Application ### Relevant Articles: - [Deploy a Spring Boot WAR into a Tomcat Server](https://www.baeldung.com/spring-boot-war-tomcat-deploy) - [Spring Boot Console Application](https://www.baeldung.com/spring-boot-console-app) - - [How to Configure Spring Boot Tomcat](https://www.baeldung.com/spring-boot-configure-tomcat) - [Comparing Embedded Servlet Containers in Spring Boot](https://www.baeldung.com/spring-boot-servlet-containers) - [Graceful Shutdown of a Spring Boot Application](https://www.baeldung.com/spring-boot-graceful-shutdown) From 3329202a44be7b2b530ff0a2e55283016556fb29 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Tue, 29 Dec 2020 12:13:03 +0200 Subject: [PATCH 166/361] Update README.md --- spring-boot-modules/spring-boot-runtime/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-runtime/README.md b/spring-boot-modules/spring-boot-runtime/README.md index 62727ecc76..271093421c 100644 --- a/spring-boot-modules/spring-boot-runtime/README.md +++ b/spring-boot-modules/spring-boot-runtime/README.md @@ -10,4 +10,5 @@ This module contains articles about administering a Spring Boot runtime - [Spring Boot Embedded Tomcat Logs](https://www.baeldung.com/spring-boot-embedded-tomcat-logs) - [Project Configuration with Spring](https://www.baeldung.com/project-configuration-with-spring) - [CORS with Spring](https://www.baeldung.com/spring-cors) - - [Spring – Log Incoming Requests](https://www.baeldung.com/spring-http-logging) \ No newline at end of file + - [Spring – Log Incoming Requests](https://www.baeldung.com/spring-http-logging) + - [How to Configure Spring Boot Tomcat](https://www.baeldung.com/spring-boot-configure-tomcat) From ee174737ab038b0f0a76421a78ec8840d4ddb9b7 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Tue, 29 Dec 2020 12:15:04 +0100 Subject: [PATCH 167/361] JAVA-3534: Move spring-rest-http into spring-web-modules --- pom.xml | 2 -- spring-web-modules/pom.xml | 1 + .../spring-rest-http}/README.md | 0 .../spring-rest-http}/pom.xml | 2 +- .../java/com/baeldung/CustomerSpringBootRestApplication.java | 0 .../src/main/java/com/baeldung/config/MvcConfig.java | 0 .../java/com/baeldung/controllers/DeferredResultController.java | 0 .../src/main/java/com/baeldung/model/Customer.java | 0 .../baeldung/requestmapping/BarMappingExamplesController.java | 0 .../requestmapping/BazzNewMappingsExampleController.java | 0 .../baeldung/requestmapping/FooMappingExamplesController.java | 0 .../src/main/java/com/baeldung/service/CustomerIdGenerator.java | 0 .../src/main/java/com/baeldung/service/CustomerService.java | 0 .../java/com/baeldung/service/impl/CustomerIdGeneratorImpl.java | 0 .../java/com/baeldung/service/impl/CustomerServiceImpl.java | 0 .../web/controller/customer/CustomerRestController.java | 0 .../com/baeldung/web/controller/status/ExampleController.java | 0 .../com/baeldung/web/controller/status/ForbiddenException.java | 0 .../src/main/java/com/baeldung/web/dto/Bazz.java | 0 .../src/main/java/com/baeldung/web/dto/Foo.java | 0 .../com/baeldung/web/exception/CustomerNotFoundException.java | 0 .../openapi-dates-definitions/openapi-3-date-format.yaml | 0 .../openapi-dates-definitions/openapi-3-date-pattern.yaml | 0 .../openapi-dates-definitions/openapi-3-datetime-format.yaml | 0 .../resources/openapi-queryparam-definitions/openapi-2.yaml | 0 .../resources/openapi-queryparam-definitions/openapi-3.yaml | 0 .../requestmapping/BazzNewMappingsExampleIntegrationTest.java | 0 .../requestmapping/FooMappingExamplesControllerUnitTest.java | 0 .../com/baeldung/responseheaders/ResponseHeaderLiveTest.java | 0 .../baeldung/service/impl/CustomerIdGeneratorImplUnitTest.java | 0 .../com/baeldung/service/impl/CustomerServiceImplUnitTest.java | 0 .../baeldung/uribuilder/SpringUriBuilderIntegrationTest.java | 0 .../customer/CustomerRestControllerIntegrationTest.java | 0 .../web/controller/customer/CustomerRestControllerUnitTest.java | 0 .../web/controller/status/ExampleControllerIntegrationTest.java | 0 35 files changed, 2 insertions(+), 3 deletions(-) rename {spring-rest-http => spring-web-modules/spring-rest-http}/README.md (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/pom.xml (97%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/CustomerSpringBootRestApplication.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/config/MvcConfig.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/controllers/DeferredResultController.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/model/Customer.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/requestmapping/BarMappingExamplesController.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/requestmapping/BazzNewMappingsExampleController.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/requestmapping/FooMappingExamplesController.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/service/CustomerIdGenerator.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/service/CustomerService.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/service/impl/CustomerIdGeneratorImpl.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/service/impl/CustomerServiceImpl.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/web/controller/customer/CustomerRestController.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/web/controller/status/ExampleController.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/web/controller/status/ForbiddenException.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/web/dto/Bazz.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/web/dto/Foo.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/java/com/baeldung/web/exception/CustomerNotFoundException.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/resources/openapi-dates-definitions/openapi-3-date-format.yaml (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/resources/openapi-dates-definitions/openapi-3-date-pattern.yaml (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/resources/openapi-dates-definitions/openapi-3-datetime-format.yaml (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/resources/openapi-queryparam-definitions/openapi-2.yaml (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/main/resources/openapi-queryparam-definitions/openapi-3.yaml (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/test/java/com/baeldung/requestmapping/BazzNewMappingsExampleIntegrationTest.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/test/java/com/baeldung/requestmapping/FooMappingExamplesControllerUnitTest.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/test/java/com/baeldung/responseheaders/ResponseHeaderLiveTest.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/test/java/com/baeldung/service/impl/CustomerIdGeneratorImplUnitTest.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/test/java/com/baeldung/service/impl/CustomerServiceImplUnitTest.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/test/java/com/baeldung/uribuilder/SpringUriBuilderIntegrationTest.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/test/java/com/baeldung/web/controller/customer/CustomerRestControllerIntegrationTest.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/test/java/com/baeldung/web/controller/customer/CustomerRestControllerUnitTest.java (100%) rename {spring-rest-http => spring-web-modules/spring-rest-http}/src/test/java/com/baeldung/web/controller/status/ExampleControllerIntegrationTest.java (100%) diff --git a/pom.xml b/pom.xml index 14565fe87d..f8e84c09e1 100644 --- a/pom.xml +++ b/pom.xml @@ -673,7 +673,6 @@ spring-reactor spring-remoting spring-rest-angular - spring-rest-http spring-rest-http-2 spring-rest-query-language spring-rest-shell @@ -1144,7 +1143,6 @@ spring-reactor spring-remoting spring-rest-angular - spring-rest-http spring-rest-query-language spring-rest-shell spring-rest-simple diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index c5d9b33dd1..3dea8fc36e 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -20,6 +20,7 @@ spring-mvc-basics-4 spring-mvc-crash spring-mvc-forms-jsp + spring-rest-http spring-thymeleaf spring-thymeleaf-2 spring-thymeleaf-3 diff --git a/spring-rest-http/README.md b/spring-web-modules/spring-rest-http/README.md similarity index 100% rename from spring-rest-http/README.md rename to spring-web-modules/spring-rest-http/README.md diff --git a/spring-rest-http/pom.xml b/spring-web-modules/spring-rest-http/pom.xml similarity index 97% rename from spring-rest-http/pom.xml rename to spring-web-modules/spring-rest-http/pom.xml index 18b7e0af05..422bcd32f7 100644 --- a/spring-rest-http/pom.xml +++ b/spring-web-modules/spring-rest-http/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-rest-http/src/main/java/com/baeldung/CustomerSpringBootRestApplication.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/CustomerSpringBootRestApplication.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/CustomerSpringBootRestApplication.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/CustomerSpringBootRestApplication.java diff --git a/spring-rest-http/src/main/java/com/baeldung/config/MvcConfig.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/config/MvcConfig.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/config/MvcConfig.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/config/MvcConfig.java diff --git a/spring-rest-http/src/main/java/com/baeldung/controllers/DeferredResultController.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/controllers/DeferredResultController.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/controllers/DeferredResultController.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/controllers/DeferredResultController.java diff --git a/spring-rest-http/src/main/java/com/baeldung/model/Customer.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/model/Customer.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/model/Customer.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/model/Customer.java diff --git a/spring-rest-http/src/main/java/com/baeldung/requestmapping/BarMappingExamplesController.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/requestmapping/BarMappingExamplesController.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/requestmapping/BarMappingExamplesController.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/requestmapping/BarMappingExamplesController.java diff --git a/spring-rest-http/src/main/java/com/baeldung/requestmapping/BazzNewMappingsExampleController.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/requestmapping/BazzNewMappingsExampleController.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/requestmapping/BazzNewMappingsExampleController.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/requestmapping/BazzNewMappingsExampleController.java diff --git a/spring-rest-http/src/main/java/com/baeldung/requestmapping/FooMappingExamplesController.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/requestmapping/FooMappingExamplesController.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/requestmapping/FooMappingExamplesController.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/requestmapping/FooMappingExamplesController.java diff --git a/spring-rest-http/src/main/java/com/baeldung/service/CustomerIdGenerator.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/service/CustomerIdGenerator.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/service/CustomerIdGenerator.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/service/CustomerIdGenerator.java diff --git a/spring-rest-http/src/main/java/com/baeldung/service/CustomerService.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/service/CustomerService.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/service/CustomerService.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/service/CustomerService.java diff --git a/spring-rest-http/src/main/java/com/baeldung/service/impl/CustomerIdGeneratorImpl.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/service/impl/CustomerIdGeneratorImpl.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/service/impl/CustomerIdGeneratorImpl.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/service/impl/CustomerIdGeneratorImpl.java diff --git a/spring-rest-http/src/main/java/com/baeldung/service/impl/CustomerServiceImpl.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/service/impl/CustomerServiceImpl.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/service/impl/CustomerServiceImpl.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/service/impl/CustomerServiceImpl.java diff --git a/spring-rest-http/src/main/java/com/baeldung/web/controller/customer/CustomerRestController.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/web/controller/customer/CustomerRestController.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/web/controller/customer/CustomerRestController.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/web/controller/customer/CustomerRestController.java diff --git a/spring-rest-http/src/main/java/com/baeldung/web/controller/status/ExampleController.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/web/controller/status/ExampleController.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/web/controller/status/ExampleController.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/web/controller/status/ExampleController.java diff --git a/spring-rest-http/src/main/java/com/baeldung/web/controller/status/ForbiddenException.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/web/controller/status/ForbiddenException.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/web/controller/status/ForbiddenException.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/web/controller/status/ForbiddenException.java diff --git a/spring-rest-http/src/main/java/com/baeldung/web/dto/Bazz.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/web/dto/Bazz.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/web/dto/Bazz.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/web/dto/Bazz.java diff --git a/spring-rest-http/src/main/java/com/baeldung/web/dto/Foo.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/web/dto/Foo.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/web/dto/Foo.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/web/dto/Foo.java diff --git a/spring-rest-http/src/main/java/com/baeldung/web/exception/CustomerNotFoundException.java b/spring-web-modules/spring-rest-http/src/main/java/com/baeldung/web/exception/CustomerNotFoundException.java similarity index 100% rename from spring-rest-http/src/main/java/com/baeldung/web/exception/CustomerNotFoundException.java rename to spring-web-modules/spring-rest-http/src/main/java/com/baeldung/web/exception/CustomerNotFoundException.java diff --git a/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-date-format.yaml b/spring-web-modules/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-date-format.yaml similarity index 100% rename from spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-date-format.yaml rename to spring-web-modules/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-date-format.yaml diff --git a/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-date-pattern.yaml b/spring-web-modules/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-date-pattern.yaml similarity index 100% rename from spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-date-pattern.yaml rename to spring-web-modules/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-date-pattern.yaml diff --git a/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-datetime-format.yaml b/spring-web-modules/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-datetime-format.yaml similarity index 100% rename from spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-datetime-format.yaml rename to spring-web-modules/spring-rest-http/src/main/resources/openapi-dates-definitions/openapi-3-datetime-format.yaml diff --git a/spring-rest-http/src/main/resources/openapi-queryparam-definitions/openapi-2.yaml b/spring-web-modules/spring-rest-http/src/main/resources/openapi-queryparam-definitions/openapi-2.yaml similarity index 100% rename from spring-rest-http/src/main/resources/openapi-queryparam-definitions/openapi-2.yaml rename to spring-web-modules/spring-rest-http/src/main/resources/openapi-queryparam-definitions/openapi-2.yaml diff --git a/spring-rest-http/src/main/resources/openapi-queryparam-definitions/openapi-3.yaml b/spring-web-modules/spring-rest-http/src/main/resources/openapi-queryparam-definitions/openapi-3.yaml similarity index 100% rename from spring-rest-http/src/main/resources/openapi-queryparam-definitions/openapi-3.yaml rename to spring-web-modules/spring-rest-http/src/main/resources/openapi-queryparam-definitions/openapi-3.yaml diff --git a/spring-rest-http/src/test/java/com/baeldung/requestmapping/BazzNewMappingsExampleIntegrationTest.java b/spring-web-modules/spring-rest-http/src/test/java/com/baeldung/requestmapping/BazzNewMappingsExampleIntegrationTest.java similarity index 100% rename from spring-rest-http/src/test/java/com/baeldung/requestmapping/BazzNewMappingsExampleIntegrationTest.java rename to spring-web-modules/spring-rest-http/src/test/java/com/baeldung/requestmapping/BazzNewMappingsExampleIntegrationTest.java diff --git a/spring-rest-http/src/test/java/com/baeldung/requestmapping/FooMappingExamplesControllerUnitTest.java b/spring-web-modules/spring-rest-http/src/test/java/com/baeldung/requestmapping/FooMappingExamplesControllerUnitTest.java similarity index 100% rename from spring-rest-http/src/test/java/com/baeldung/requestmapping/FooMappingExamplesControllerUnitTest.java rename to spring-web-modules/spring-rest-http/src/test/java/com/baeldung/requestmapping/FooMappingExamplesControllerUnitTest.java diff --git a/spring-rest-http/src/test/java/com/baeldung/responseheaders/ResponseHeaderLiveTest.java b/spring-web-modules/spring-rest-http/src/test/java/com/baeldung/responseheaders/ResponseHeaderLiveTest.java similarity index 100% rename from spring-rest-http/src/test/java/com/baeldung/responseheaders/ResponseHeaderLiveTest.java rename to spring-web-modules/spring-rest-http/src/test/java/com/baeldung/responseheaders/ResponseHeaderLiveTest.java diff --git a/spring-rest-http/src/test/java/com/baeldung/service/impl/CustomerIdGeneratorImplUnitTest.java b/spring-web-modules/spring-rest-http/src/test/java/com/baeldung/service/impl/CustomerIdGeneratorImplUnitTest.java similarity index 100% rename from spring-rest-http/src/test/java/com/baeldung/service/impl/CustomerIdGeneratorImplUnitTest.java rename to spring-web-modules/spring-rest-http/src/test/java/com/baeldung/service/impl/CustomerIdGeneratorImplUnitTest.java diff --git a/spring-rest-http/src/test/java/com/baeldung/service/impl/CustomerServiceImplUnitTest.java b/spring-web-modules/spring-rest-http/src/test/java/com/baeldung/service/impl/CustomerServiceImplUnitTest.java similarity index 100% rename from spring-rest-http/src/test/java/com/baeldung/service/impl/CustomerServiceImplUnitTest.java rename to spring-web-modules/spring-rest-http/src/test/java/com/baeldung/service/impl/CustomerServiceImplUnitTest.java diff --git a/spring-rest-http/src/test/java/com/baeldung/uribuilder/SpringUriBuilderIntegrationTest.java b/spring-web-modules/spring-rest-http/src/test/java/com/baeldung/uribuilder/SpringUriBuilderIntegrationTest.java similarity index 100% rename from spring-rest-http/src/test/java/com/baeldung/uribuilder/SpringUriBuilderIntegrationTest.java rename to spring-web-modules/spring-rest-http/src/test/java/com/baeldung/uribuilder/SpringUriBuilderIntegrationTest.java diff --git a/spring-rest-http/src/test/java/com/baeldung/web/controller/customer/CustomerRestControllerIntegrationTest.java b/spring-web-modules/spring-rest-http/src/test/java/com/baeldung/web/controller/customer/CustomerRestControllerIntegrationTest.java similarity index 100% rename from spring-rest-http/src/test/java/com/baeldung/web/controller/customer/CustomerRestControllerIntegrationTest.java rename to spring-web-modules/spring-rest-http/src/test/java/com/baeldung/web/controller/customer/CustomerRestControllerIntegrationTest.java diff --git a/spring-rest-http/src/test/java/com/baeldung/web/controller/customer/CustomerRestControllerUnitTest.java b/spring-web-modules/spring-rest-http/src/test/java/com/baeldung/web/controller/customer/CustomerRestControllerUnitTest.java similarity index 100% rename from spring-rest-http/src/test/java/com/baeldung/web/controller/customer/CustomerRestControllerUnitTest.java rename to spring-web-modules/spring-rest-http/src/test/java/com/baeldung/web/controller/customer/CustomerRestControllerUnitTest.java diff --git a/spring-rest-http/src/test/java/com/baeldung/web/controller/status/ExampleControllerIntegrationTest.java b/spring-web-modules/spring-rest-http/src/test/java/com/baeldung/web/controller/status/ExampleControllerIntegrationTest.java similarity index 100% rename from spring-rest-http/src/test/java/com/baeldung/web/controller/status/ExampleControllerIntegrationTest.java rename to spring-web-modules/spring-rest-http/src/test/java/com/baeldung/web/controller/status/ExampleControllerIntegrationTest.java From d84de4ccdfc9c65bd0de800ea956ff86dbb25ed6 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Tue, 29 Dec 2020 14:43:19 +0100 Subject: [PATCH 168/361] JAVA-3533: Move spring-rest-http-2 into spring-web-modules --- pom.xml | 1 - spring-web-modules/pom.xml | 1 + .../spring-rest-http-2}/README.md | 0 .../spring-rest-http-2}/pom.xml | 2 +- .../src/main/java/com/baeldung/SpringBootRest2Application.java | 0 .../com/baeldung/swaggerui/disable/config/SwaggerConfig.java | 0 .../swaggerui/disable/controllers/VersionController.java | 0 7 files changed, 2 insertions(+), 2 deletions(-) rename {spring-rest-http-2 => spring-web-modules/spring-rest-http-2}/README.md (100%) rename {spring-rest-http-2 => spring-web-modules/spring-rest-http-2}/pom.xml (95%) rename {spring-rest-http-2 => spring-web-modules/spring-rest-http-2}/src/main/java/com/baeldung/SpringBootRest2Application.java (100%) rename {spring-rest-http-2 => spring-web-modules/spring-rest-http-2}/src/main/java/com/baeldung/swaggerui/disable/config/SwaggerConfig.java (100%) rename {spring-rest-http-2 => spring-web-modules/spring-rest-http-2}/src/main/java/com/baeldung/swaggerui/disable/controllers/VersionController.java (100%) diff --git a/pom.xml b/pom.xml index f8e84c09e1..520343431b 100644 --- a/pom.xml +++ b/pom.xml @@ -673,7 +673,6 @@ spring-reactor spring-remoting spring-rest-angular - spring-rest-http-2 spring-rest-query-language spring-rest-shell spring-rest-simple diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index 3dea8fc36e..2b1dfc367a 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -21,6 +21,7 @@ spring-mvc-crash spring-mvc-forms-jsp spring-rest-http + spring-rest-http-2 spring-thymeleaf spring-thymeleaf-2 spring-thymeleaf-3 diff --git a/spring-rest-http-2/README.md b/spring-web-modules/spring-rest-http-2/README.md similarity index 100% rename from spring-rest-http-2/README.md rename to spring-web-modules/spring-rest-http-2/README.md diff --git a/spring-rest-http-2/pom.xml b/spring-web-modules/spring-rest-http-2/pom.xml similarity index 95% rename from spring-rest-http-2/pom.xml rename to spring-web-modules/spring-rest-http-2/pom.xml index 8678d7243d..6aa8be365c 100644 --- a/spring-rest-http-2/pom.xml +++ b/spring-web-modules/spring-rest-http-2/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-rest-http-2/src/main/java/com/baeldung/SpringBootRest2Application.java b/spring-web-modules/spring-rest-http-2/src/main/java/com/baeldung/SpringBootRest2Application.java similarity index 100% rename from spring-rest-http-2/src/main/java/com/baeldung/SpringBootRest2Application.java rename to spring-web-modules/spring-rest-http-2/src/main/java/com/baeldung/SpringBootRest2Application.java diff --git a/spring-rest-http-2/src/main/java/com/baeldung/swaggerui/disable/config/SwaggerConfig.java b/spring-web-modules/spring-rest-http-2/src/main/java/com/baeldung/swaggerui/disable/config/SwaggerConfig.java similarity index 100% rename from spring-rest-http-2/src/main/java/com/baeldung/swaggerui/disable/config/SwaggerConfig.java rename to spring-web-modules/spring-rest-http-2/src/main/java/com/baeldung/swaggerui/disable/config/SwaggerConfig.java diff --git a/spring-rest-http-2/src/main/java/com/baeldung/swaggerui/disable/controllers/VersionController.java b/spring-web-modules/spring-rest-http-2/src/main/java/com/baeldung/swaggerui/disable/controllers/VersionController.java similarity index 100% rename from spring-rest-http-2/src/main/java/com/baeldung/swaggerui/disable/controllers/VersionController.java rename to spring-web-modules/spring-rest-http-2/src/main/java/com/baeldung/swaggerui/disable/controllers/VersionController.java From 1a63c83f55f5141b3247f005352b8e3e8433f5b3 Mon Sep 17 00:00:00 2001 From: Adrian Maghear Date: Tue, 29 Dec 2020 16:42:52 +0100 Subject: [PATCH 169/361] [BAEL-4015] fix integration tests --- .../spring-cloud-eureka-feign-client-integration-test/pom.xml | 2 +- ...rationTest.java => ServiceDiscoveryBooksClientLiveTest.java} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/{ServiceDiscoveryBooksClientIntegrationTest.java => ServiceDiscoveryBooksClientLiveTest.java} (97%) 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 3348dbb24f..95b1275e2c 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 @@ -88,7 +88,7 @@ maven-surefire-plugin 1 - true + false 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/ServiceDiscoveryBooksClientLiveTest.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/ServiceDiscoveryBooksClientIntegrationTest.java rename to spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client-integration-test/src/test/java/com/baeldung/spring/cloud/client/ServiceDiscoveryBooksClientLiveTest.java index 027579d20d..3ac067b8f8 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/ServiceDiscoveryBooksClientLiveTest.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 ServiceDiscoveryBooksClientIntegrationTest { +class ServiceDiscoveryBooksClientLiveTest { @Autowired private BooksClient booksClient; From 469e5c5c861fdefbbaf83afd9bb601a553d259f6 Mon Sep 17 00:00:00 2001 From: mikr Date: Tue, 29 Dec 2020 18:52:31 +0100 Subject: [PATCH 170/361] JAVA-3539 Move spring-resttemplate-2 module --- pom.xml | 2 -- spring-web-modules/pom.xml | 1 + .../spring-resttemplate-2}/README.md | 0 .../spring-resttemplate-2}/pom.xml | 2 +- .../compress/CompressingClientHttpRequestInterceptor.java | 0 .../src/main/java/com/baeldung/compress/GzipUtils.java | 0 .../java/com/baeldung/compress/JettyWebServerConfiguration.java | 0 .../src/main/java/com/baeldung/compress/Message.java | 0 .../src/main/java/com/baeldung/compress/MessageController.java | 0 .../java/com/baeldung/compress/RestTemplateConfiguration.java | 0 .../com/baeldung/compress/SpringCompressRequestApplication.java | 0 .../resttemplate/RestTemplateConfigurationApplication.java | 0 .../resttemplate/json/consumer/service/UserConsumerService.java | 0 .../json/consumer/service/UserConsumerServiceImpl.java | 0 .../main/java/com/baeldung/resttemplate/json/model/Address.java | 0 .../main/java/com/baeldung/resttemplate/json/model/User.java | 0 .../resttemplate/logging/web/controller/PersonController.java | 0 .../com/baeldung/resttemplate/web/controller/PersonAPI.java | 0 .../src/main/java/com/baeldung/resttemplate/web/dto/Person.java | 0 .../com/baeldung/resttemplate/web/service/PersonService.java | 0 .../baeldung/resttemplate/web/service/PersonServiceImpl.java | 0 .../src/main/java/com/baeldung/sampleapp/config/WebConfig.java | 0 .../web/controller/mediatypes/CustomMediaTypeController.java | 0 .../main/java/com/baeldung/sampleapp/web/dto/BaeldungItem.java | 0 .../java/com/baeldung/sampleapp/web/dto/BaeldungItemV2.java | 0 .../src/main/resources/application.properties | 0 .../src/test/java/com/baeldung/compress/GzipUtilsUnitTest.java | 0 .../java/com/baeldung/compress/MessageControllerUnitTest.java | 0 .../json/consumer/service/UserConsumerServiceImplUnitTest.java | 0 .../com/baeldung/resttemplate/logging/LoggingInterceptor.java | 0 .../resttemplate/logging/RestTemplateLoggingLiveTest.java | 0 .../com/baeldung/resttemplate/postjson/PersonAPILiveTest.java | 0 .../com/baeldung/resttemplate/proxy/RequestFactoryLiveTest.java | 0 .../resttemplate/proxy/RestTemplateCustomizerLiveTest.java | 0 .../mediatypes/CustomMediaTypeControllerIntegrationTest.java | 0 .../mediatypes/CustomMediaTypeControllerLiveTest.java | 0 .../java/com/baeldung/web/controller/mediatypes/TestConfig.java | 0 .../src/test/resources/application.properties | 0 38 files changed, 2 insertions(+), 3 deletions(-) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/README.md (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/pom.xml (97%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/compress/CompressingClientHttpRequestInterceptor.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/compress/GzipUtils.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/compress/JettyWebServerConfiguration.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/compress/Message.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/compress/MessageController.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/compress/RestTemplateConfiguration.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/compress/SpringCompressRequestApplication.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/resttemplate/RestTemplateConfigurationApplication.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerService.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImpl.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/resttemplate/json/model/Address.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/resttemplate/json/model/User.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/resttemplate/logging/web/controller/PersonController.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/resttemplate/web/controller/PersonAPI.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/resttemplate/web/dto/Person.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/resttemplate/web/service/PersonService.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/resttemplate/web/service/PersonServiceImpl.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/sampleapp/config/WebConfig.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/sampleapp/web/controller/mediatypes/CustomMediaTypeController.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItem.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItemV2.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/main/resources/application.properties (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/test/java/com/baeldung/compress/GzipUtilsUnitTest.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/test/java/com/baeldung/compress/MessageControllerUnitTest.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/test/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImplUnitTest.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/test/java/com/baeldung/resttemplate/logging/LoggingInterceptor.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/test/java/com/baeldung/resttemplate/logging/RestTemplateLoggingLiveTest.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/test/java/com/baeldung/resttemplate/postjson/PersonAPILiveTest.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/test/java/com/baeldung/resttemplate/proxy/RequestFactoryLiveTest.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/test/java/com/baeldung/resttemplate/proxy/RestTemplateCustomizerLiveTest.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerIntegrationTest.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerLiveTest.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java (100%) rename {spring-resttemplate-2 => spring-web-modules/spring-resttemplate-2}/src/test/resources/application.properties (100%) diff --git a/pom.xml b/pom.xml index f8e84c09e1..14de77891b 100644 --- a/pom.xml +++ b/pom.xml @@ -678,7 +678,6 @@ spring-rest-shell spring-rest-simple spring-resttemplate - spring-resttemplate-2 spring-rest-testing spring-roo @@ -1147,7 +1146,6 @@ spring-rest-shell spring-rest-simple spring-resttemplate - spring-resttemplate-2 spring-rest-testing spring-roo diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index 3dea8fc36e..67580e9b91 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -21,6 +21,7 @@ spring-mvc-crash spring-mvc-forms-jsp spring-rest-http + spring-resttemplate-2 spring-thymeleaf spring-thymeleaf-2 spring-thymeleaf-3 diff --git a/spring-resttemplate-2/README.md b/spring-web-modules/spring-resttemplate-2/README.md similarity index 100% rename from spring-resttemplate-2/README.md rename to spring-web-modules/spring-resttemplate-2/README.md diff --git a/spring-resttemplate-2/pom.xml b/spring-web-modules/spring-resttemplate-2/pom.xml similarity index 97% rename from spring-resttemplate-2/pom.xml rename to spring-web-modules/spring-resttemplate-2/pom.xml index 1404a35f33..04be058638 100644 --- a/spring-resttemplate-2/pom.xml +++ b/spring-web-modules/spring-resttemplate-2/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + parent-boot-2/pom.xml diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/compress/CompressingClientHttpRequestInterceptor.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/compress/CompressingClientHttpRequestInterceptor.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/compress/CompressingClientHttpRequestInterceptor.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/compress/CompressingClientHttpRequestInterceptor.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/compress/GzipUtils.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/compress/GzipUtils.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/compress/GzipUtils.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/compress/GzipUtils.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/compress/JettyWebServerConfiguration.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/compress/JettyWebServerConfiguration.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/compress/JettyWebServerConfiguration.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/compress/JettyWebServerConfiguration.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/compress/Message.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/compress/Message.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/compress/Message.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/compress/Message.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/compress/MessageController.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/compress/MessageController.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/compress/MessageController.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/compress/MessageController.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/compress/RestTemplateConfiguration.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/compress/RestTemplateConfiguration.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/compress/RestTemplateConfiguration.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/compress/RestTemplateConfiguration.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/compress/SpringCompressRequestApplication.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/compress/SpringCompressRequestApplication.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/compress/SpringCompressRequestApplication.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/compress/SpringCompressRequestApplication.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/RestTemplateConfigurationApplication.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/RestTemplateConfigurationApplication.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/RestTemplateConfigurationApplication.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/RestTemplateConfigurationApplication.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerService.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerService.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerService.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerService.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImpl.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImpl.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImpl.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImpl.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/model/Address.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/model/Address.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/model/Address.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/model/Address.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/model/User.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/model/User.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/model/User.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/json/model/User.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/logging/web/controller/PersonController.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/logging/web/controller/PersonController.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/logging/web/controller/PersonController.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/logging/web/controller/PersonController.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/controller/PersonAPI.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/controller/PersonAPI.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/controller/PersonAPI.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/controller/PersonAPI.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/dto/Person.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/dto/Person.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/dto/Person.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/dto/Person.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/service/PersonService.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/service/PersonService.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/service/PersonService.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/service/PersonService.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/service/PersonServiceImpl.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/service/PersonServiceImpl.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/service/PersonServiceImpl.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplate/web/service/PersonServiceImpl.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/config/WebConfig.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/config/WebConfig.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/config/WebConfig.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/config/WebConfig.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/controller/mediatypes/CustomMediaTypeController.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/controller/mediatypes/CustomMediaTypeController.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/controller/mediatypes/CustomMediaTypeController.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/controller/mediatypes/CustomMediaTypeController.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItem.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItem.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItem.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItem.java diff --git a/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItemV2.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItemV2.java similarity index 100% rename from spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItemV2.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/dto/BaeldungItemV2.java diff --git a/spring-resttemplate-2/src/main/resources/application.properties b/spring-web-modules/spring-resttemplate-2/src/main/resources/application.properties similarity index 100% rename from spring-resttemplate-2/src/main/resources/application.properties rename to spring-web-modules/spring-resttemplate-2/src/main/resources/application.properties diff --git a/spring-resttemplate-2/src/test/java/com/baeldung/compress/GzipUtilsUnitTest.java b/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/compress/GzipUtilsUnitTest.java similarity index 100% rename from spring-resttemplate-2/src/test/java/com/baeldung/compress/GzipUtilsUnitTest.java rename to spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/compress/GzipUtilsUnitTest.java diff --git a/spring-resttemplate-2/src/test/java/com/baeldung/compress/MessageControllerUnitTest.java b/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/compress/MessageControllerUnitTest.java similarity index 100% rename from spring-resttemplate-2/src/test/java/com/baeldung/compress/MessageControllerUnitTest.java rename to spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/compress/MessageControllerUnitTest.java diff --git a/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImplUnitTest.java b/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImplUnitTest.java similarity index 100% rename from spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImplUnitTest.java rename to spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/json/consumer/service/UserConsumerServiceImplUnitTest.java diff --git a/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/logging/LoggingInterceptor.java b/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/logging/LoggingInterceptor.java similarity index 100% rename from spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/logging/LoggingInterceptor.java rename to spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/logging/LoggingInterceptor.java diff --git a/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/logging/RestTemplateLoggingLiveTest.java b/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/logging/RestTemplateLoggingLiveTest.java similarity index 100% rename from spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/logging/RestTemplateLoggingLiveTest.java rename to spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/logging/RestTemplateLoggingLiveTest.java diff --git a/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/postjson/PersonAPILiveTest.java b/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/postjson/PersonAPILiveTest.java similarity index 100% rename from spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/postjson/PersonAPILiveTest.java rename to spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/postjson/PersonAPILiveTest.java diff --git a/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/proxy/RequestFactoryLiveTest.java b/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/proxy/RequestFactoryLiveTest.java similarity index 100% rename from spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/proxy/RequestFactoryLiveTest.java rename to spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/proxy/RequestFactoryLiveTest.java diff --git a/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/proxy/RestTemplateCustomizerLiveTest.java b/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/proxy/RestTemplateCustomizerLiveTest.java similarity index 100% rename from spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/proxy/RestTemplateCustomizerLiveTest.java rename to spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplate/proxy/RestTemplateCustomizerLiveTest.java diff --git a/spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerIntegrationTest.java b/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerIntegrationTest.java similarity index 100% rename from spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerIntegrationTest.java rename to spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerIntegrationTest.java diff --git a/spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerLiveTest.java b/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerLiveTest.java similarity index 100% rename from spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerLiveTest.java rename to spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/CustomMediaTypeControllerLiveTest.java diff --git a/spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java b/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java similarity index 100% rename from spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java rename to spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java diff --git a/spring-resttemplate-2/src/test/resources/application.properties b/spring-web-modules/spring-resttemplate-2/src/test/resources/application.properties similarity index 100% rename from spring-resttemplate-2/src/test/resources/application.properties rename to spring-web-modules/spring-resttemplate-2/src/test/resources/application.properties From 11dae9ea5a1a1d941a969f843b03a2e817d7e522 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 29 Dec 2020 23:44:00 +0530 Subject: [PATCH 171/361] JAVA-3526: Moved spring-mvc-java inside spring-web-modules --- .../spring-mvc-java}/.gitignore | 0 .../spring-mvc-java}/README.md | 2 +- .../spring-mvc-java}/persons.xls | Bin .../spring-mvc-java}/persons.xlsx | Bin .../spring-mvc-java}/pom.xml | 2 +- .../java/com/baeldung/SpringMVCApplication.java | 0 .../main/java/com/baeldung/accessparamsjs/App.java | 0 .../com/baeldung/accessparamsjs/Controller.java | 0 .../main/java/com/baeldung/cache/BookService.java | 0 .../java/com/baeldung/cache/CustomKeyGenerator.java | 0 .../java/com/baeldung/excel/ExcelPOIHelper.java | 0 .../src/main/java/com/baeldung/excel/MyCell.java | 0 .../java/com/baeldung/filters/EmptyParamFilter.java | 0 .../java/com/baeldung/listeners/AppListener.java | 0 .../com/baeldung/listeners/RequestListener.java | 0 .../src/main/java/com/baeldung/model/Article.java | 0 .../src/main/java/com/baeldung/model/Book.java | 0 .../java/com/baeldung/model/FormDataWithFile.java | 0 .../src/main/java/com/baeldung/model/Greeting.java | 0 .../src/main/java/com/baeldung/model/User.java | 0 .../java/com/baeldung/servlets/CounterServlet.java | 0 .../com/baeldung/servlets/UppercaseServlet.java | 0 .../spring/web/config/ApplicationCacheConfig.java | 0 .../spring/web/config/MainWebAppInitializer.java | 0 .../com/baeldung/spring/web/config/WebConfig.java | 0 .../src/main/java/com/baeldung/web/BeanA.java | 0 .../src/main/java/com/baeldung/web/BeanB.java | 0 .../baeldung/web/controller/ExcelController.java | 0 .../web/controller/FileUploadController.java | 0 .../baeldung/web/controller/GreetController.java | 0 .../baeldung/web/controller/ImageController.java | 0 .../MultipartFileUploadStubController.java | 0 .../baeldung/web/controller/SampleController.java | 0 .../com/baeldung/web/controller/UserController.java | 0 .../web/controller/message/MessageController.java | 0 .../optionalpathvars/ArticleViewerController.java | 0 .../ArticleViewerWithMapParamController.java | 0 .../ArticleViewerWithOptionalParamController.java | 0 ...rticleViewerWithRequiredAttributeController.java | 0 ...ticleViewerWithTwoSeparateMethodsController.java | 0 .../src/main/resources/annotations.properties | 0 .../src/main/resources/annotations.xml | 0 .../src/main/resources/application.properties | 0 .../spring-mvc-java}/src/main/resources/logback.xml | 0 .../src/main/resources/messages_en.properties | 0 .../src/main/resources/mvc-configuration.xml | 0 .../main/resources/templates/thymeleaf/index.html | 0 .../main/webapp/WEB-INF/images/image-example.jpg | Bin .../src/main/webapp/WEB-INF/jsp/index.jsp | 0 .../src/main/webapp/WEB-INF/mvc-servlet.xml | 0 .../src/main/webapp/WEB-INF/templates/footer.html | 0 .../src/main/webapp/WEB-INF/templates/hello.html | 0 .../src/main/webapp/WEB-INF/templates/index.html | 0 .../src/main/webapp/WEB-INF/templates/message.html | 0 .../src/main/webapp/WEB-INF/view/excel.jsp | 0 .../src/main/webapp/WEB-INF/view/fileUploadForm.jsp | 0 .../src/main/webapp/WEB-INF/view/fileUploadView.jsp | 0 .../src/main/webapp/WEB-INF/view/index.jsp | 0 .../src/main/webapp/WEB-INF/view/sample.jsp | 0 .../src/main/webapp/WEB-INF/web_old.xml | 0 .../spring-mvc-java}/src/main/webapp/js/jquery.js | 0 .../src/main/webapp/js/script-async-jquery.js | 0 .../src/main/webapp/js/script-async.js | 0 .../spring-mvc-java}/src/main/webapp/js/script.js | 0 .../baeldung/accessparamsjs/ControllerUnitTest.java | 0 .../baeldung/htmlunit/HtmlUnitAndJUnitLiveTest.java | 0 .../htmlunit/HtmlUnitAndSpringLiveTest.java | 0 .../htmlunit/HtmlUnitWebScrapingLiveTest.java | 0 .../test/java/com/baeldung/htmlunit/TestConfig.java | 0 .../controller/GreetControllerIntegrationTest.java | 0 .../GreetControllerRealIntegrationTest.java | 0 .../web/controller/GreetControllerUnitTest.java | 0 .../test/java/com/baeldung/web/controller/README.md | 0 .../ArticleViewerControllerIntegrationTest.java | 0 ...rControllerWithOptionalParamIntegrationTest.java | 0 ...trollerWithRequiredAttributeIntegrationTest.java | 0 .../ArticleViewerWithMapParamIntegrationTest.java | 0 ...ViewerWithTwoSeparateMethodsIntegrationTest.java | 0 .../spring-mvc-java}/src/test/resources/.gitignore | 0 .../src/test/resources/logback-test.xml | 0 80 files changed, 2 insertions(+), 2 deletions(-) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/.gitignore (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/README.md (92%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/persons.xls (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/persons.xlsx (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/pom.xml (99%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/SpringMVCApplication.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/accessparamsjs/App.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/accessparamsjs/Controller.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/cache/BookService.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/cache/CustomKeyGenerator.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/excel/ExcelPOIHelper.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/excel/MyCell.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/filters/EmptyParamFilter.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/listeners/AppListener.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/listeners/RequestListener.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/model/Article.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/model/Book.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/model/FormDataWithFile.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/model/Greeting.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/model/User.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/servlets/CounterServlet.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/servlets/UppercaseServlet.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/spring/web/config/ApplicationCacheConfig.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/spring/web/config/MainWebAppInitializer.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/spring/web/config/WebConfig.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/web/BeanA.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/web/BeanB.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/web/controller/ExcelController.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/web/controller/FileUploadController.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/web/controller/GreetController.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/web/controller/ImageController.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/web/controller/MultipartFileUploadStubController.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/web/controller/SampleController.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/web/controller/UserController.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/web/controller/message/MessageController.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerController.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithMapParamController.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithOptionalParamController.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithRequiredAttributeController.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/resources/annotations.properties (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/resources/annotations.xml (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/resources/application.properties (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/resources/logback.xml (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/resources/messages_en.properties (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/resources/mvc-configuration.xml (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/resources/templates/thymeleaf/index.html (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/WEB-INF/images/image-example.jpg (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/WEB-INF/jsp/index.jsp (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/WEB-INF/mvc-servlet.xml (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/WEB-INF/templates/footer.html (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/WEB-INF/templates/hello.html (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/WEB-INF/templates/index.html (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/WEB-INF/templates/message.html (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/WEB-INF/view/excel.jsp (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/WEB-INF/view/fileUploadForm.jsp (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/WEB-INF/view/fileUploadView.jsp (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/WEB-INF/view/index.jsp (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/WEB-INF/view/sample.jsp (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/WEB-INF/web_old.xml (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/js/jquery.js (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/js/script-async-jquery.js (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/js/script-async.js (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/main/webapp/js/script.js (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/test/java/com/baeldung/accessparamsjs/ControllerUnitTest.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/test/java/com/baeldung/htmlunit/HtmlUnitAndJUnitLiveTest.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringLiveTest.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/test/java/com/baeldung/htmlunit/HtmlUnitWebScrapingLiveTest.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/test/java/com/baeldung/htmlunit/TestConfig.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/test/java/com/baeldung/web/controller/GreetControllerRealIntegrationTest.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/test/java/com/baeldung/web/controller/GreetControllerUnitTest.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/test/java/com/baeldung/web/controller/README.md (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerControllerIntegrationTest.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/test/resources/.gitignore (100%) rename {spring-mvc-java => spring-web-modules/spring-mvc-java}/src/test/resources/logback-test.xml (100%) diff --git a/spring-mvc-java/.gitignore b/spring-web-modules/spring-mvc-java/.gitignore similarity index 100% rename from spring-mvc-java/.gitignore rename to spring-web-modules/spring-mvc-java/.gitignore diff --git a/spring-mvc-java/README.md b/spring-web-modules/spring-mvc-java/README.md similarity index 92% rename from spring-mvc-java/README.md rename to spring-web-modules/spring-mvc-java/README.md index 877d92901a..afd1aea3bf 100644 --- a/spring-mvc-java/README.md +++ b/spring-web-modules/spring-mvc-java/README.md @@ -4,7 +4,7 @@ This module contains articles about Spring MVC with Java configuration ### The Course -The "REST With Spring" Classes: http://bit.ly/restwithspring +The "REST With Spring" Classes: https://bit.ly/restwithspring ### Relevant Articles: - [Integration Testing in Spring](https://www.baeldung.com/integration-testing-in-spring) diff --git a/spring-mvc-java/persons.xls b/spring-web-modules/spring-mvc-java/persons.xls similarity index 100% rename from spring-mvc-java/persons.xls rename to spring-web-modules/spring-mvc-java/persons.xls diff --git a/spring-mvc-java/persons.xlsx b/spring-web-modules/spring-mvc-java/persons.xlsx similarity index 100% rename from spring-mvc-java/persons.xlsx rename to spring-web-modules/spring-mvc-java/persons.xlsx diff --git a/spring-mvc-java/pom.xml b/spring-web-modules/spring-mvc-java/pom.xml similarity index 99% rename from spring-mvc-java/pom.xml rename to spring-web-modules/spring-mvc-java/pom.xml index a45e9c8521..179ac0fb54 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-web-modules/spring-mvc-java/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-mvc-java/src/main/java/com/baeldung/SpringMVCApplication.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/SpringMVCApplication.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/SpringMVCApplication.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/SpringMVCApplication.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/accessparamsjs/App.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/accessparamsjs/App.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/accessparamsjs/App.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/accessparamsjs/App.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/accessparamsjs/Controller.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/accessparamsjs/Controller.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/accessparamsjs/Controller.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/accessparamsjs/Controller.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/cache/BookService.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/cache/BookService.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/cache/BookService.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/cache/BookService.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/cache/CustomKeyGenerator.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/cache/CustomKeyGenerator.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/cache/CustomKeyGenerator.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/cache/CustomKeyGenerator.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/excel/ExcelPOIHelper.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/excel/ExcelPOIHelper.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/excel/ExcelPOIHelper.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/excel/ExcelPOIHelper.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/excel/MyCell.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/excel/MyCell.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/excel/MyCell.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/excel/MyCell.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/filters/EmptyParamFilter.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/filters/EmptyParamFilter.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/filters/EmptyParamFilter.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/filters/EmptyParamFilter.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/listeners/AppListener.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/listeners/AppListener.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/listeners/AppListener.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/listeners/AppListener.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/listeners/RequestListener.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/listeners/RequestListener.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/listeners/RequestListener.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/listeners/RequestListener.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/model/Article.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/model/Article.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/model/Article.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/model/Article.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/model/Book.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/model/Book.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/model/Book.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/model/Book.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/model/FormDataWithFile.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/model/FormDataWithFile.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/model/FormDataWithFile.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/model/FormDataWithFile.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/model/Greeting.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/model/Greeting.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/model/Greeting.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/model/Greeting.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/model/User.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/model/User.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/model/User.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/model/User.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/servlets/CounterServlet.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/servlets/CounterServlet.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/servlets/CounterServlet.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/servlets/CounterServlet.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/servlets/UppercaseServlet.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/servlets/UppercaseServlet.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/servlets/UppercaseServlet.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/servlets/UppercaseServlet.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/ApplicationCacheConfig.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/ApplicationCacheConfig.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/spring/web/config/ApplicationCacheConfig.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/ApplicationCacheConfig.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/MainWebAppInitializer.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/MainWebAppInitializer.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/spring/web/config/MainWebAppInitializer.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/MainWebAppInitializer.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebConfig.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebConfig.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebConfig.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebConfig.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/BeanA.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/BeanA.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/web/BeanA.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/BeanA.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/BeanB.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/BeanB.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/web/BeanB.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/BeanB.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/ExcelController.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/ExcelController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/ExcelController.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/ExcelController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/FileUploadController.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/FileUploadController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/FileUploadController.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/FileUploadController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/GreetController.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/GreetController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/GreetController.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/GreetController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/ImageController.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/ImageController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/ImageController.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/ImageController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/MultipartFileUploadStubController.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/MultipartFileUploadStubController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/MultipartFileUploadStubController.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/MultipartFileUploadStubController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/SampleController.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/SampleController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/SampleController.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/SampleController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/UserController.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/UserController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/UserController.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/UserController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/message/MessageController.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/message/MessageController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/message/MessageController.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/message/MessageController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerController.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerController.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithMapParamController.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithMapParamController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithMapParamController.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithMapParamController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithOptionalParamController.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithOptionalParamController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithOptionalParamController.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithOptionalParamController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithRequiredAttributeController.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithRequiredAttributeController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithRequiredAttributeController.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithRequiredAttributeController.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java b/spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java rename to spring-web-modules/spring-mvc-java/src/main/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithTwoSeparateMethodsController.java diff --git a/spring-mvc-java/src/main/resources/annotations.properties b/spring-web-modules/spring-mvc-java/src/main/resources/annotations.properties similarity index 100% rename from spring-mvc-java/src/main/resources/annotations.properties rename to spring-web-modules/spring-mvc-java/src/main/resources/annotations.properties diff --git a/spring-mvc-java/src/main/resources/annotations.xml b/spring-web-modules/spring-mvc-java/src/main/resources/annotations.xml similarity index 100% rename from spring-mvc-java/src/main/resources/annotations.xml rename to spring-web-modules/spring-mvc-java/src/main/resources/annotations.xml diff --git a/spring-mvc-java/src/main/resources/application.properties b/spring-web-modules/spring-mvc-java/src/main/resources/application.properties similarity index 100% rename from spring-mvc-java/src/main/resources/application.properties rename to spring-web-modules/spring-mvc-java/src/main/resources/application.properties diff --git a/spring-mvc-java/src/main/resources/logback.xml b/spring-web-modules/spring-mvc-java/src/main/resources/logback.xml similarity index 100% rename from spring-mvc-java/src/main/resources/logback.xml rename to spring-web-modules/spring-mvc-java/src/main/resources/logback.xml diff --git a/spring-mvc-java/src/main/resources/messages_en.properties b/spring-web-modules/spring-mvc-java/src/main/resources/messages_en.properties similarity index 100% rename from spring-mvc-java/src/main/resources/messages_en.properties rename to spring-web-modules/spring-mvc-java/src/main/resources/messages_en.properties diff --git a/spring-mvc-java/src/main/resources/mvc-configuration.xml b/spring-web-modules/spring-mvc-java/src/main/resources/mvc-configuration.xml similarity index 100% rename from spring-mvc-java/src/main/resources/mvc-configuration.xml rename to spring-web-modules/spring-mvc-java/src/main/resources/mvc-configuration.xml diff --git a/spring-mvc-java/src/main/resources/templates/thymeleaf/index.html b/spring-web-modules/spring-mvc-java/src/main/resources/templates/thymeleaf/index.html similarity index 100% rename from spring-mvc-java/src/main/resources/templates/thymeleaf/index.html rename to spring-web-modules/spring-mvc-java/src/main/resources/templates/thymeleaf/index.html diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/images/image-example.jpg b/spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/images/image-example.jpg similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/images/image-example.jpg rename to spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/images/image-example.jpg diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/jsp/index.jsp b/spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/jsp/index.jsp similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/jsp/index.jsp rename to spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/jsp/index.jsp diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/templates/footer.html b/spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/templates/footer.html similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/templates/footer.html rename to spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/templates/footer.html diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/templates/hello.html b/spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/templates/hello.html similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/templates/hello.html rename to spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/templates/hello.html diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/templates/index.html b/spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/templates/index.html similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/templates/index.html rename to spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/templates/index.html diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/templates/message.html b/spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/templates/message.html similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/templates/message.html rename to spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/templates/message.html diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/view/excel.jsp b/spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/view/excel.jsp similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/view/excel.jsp rename to spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/view/excel.jsp diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/view/fileUploadForm.jsp b/spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/view/fileUploadForm.jsp similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/view/fileUploadForm.jsp rename to spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/view/fileUploadForm.jsp diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/view/fileUploadView.jsp b/spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/view/fileUploadView.jsp similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/view/fileUploadView.jsp rename to spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/view/fileUploadView.jsp diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/view/index.jsp b/spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/view/index.jsp similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/view/index.jsp rename to spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/view/index.jsp diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/view/sample.jsp b/spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/view/sample.jsp similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/view/sample.jsp rename to spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/view/sample.jsp diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/web_old.xml b/spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/web_old.xml similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/web_old.xml rename to spring-web-modules/spring-mvc-java/src/main/webapp/WEB-INF/web_old.xml diff --git a/spring-mvc-java/src/main/webapp/js/jquery.js b/spring-web-modules/spring-mvc-java/src/main/webapp/js/jquery.js similarity index 100% rename from spring-mvc-java/src/main/webapp/js/jquery.js rename to spring-web-modules/spring-mvc-java/src/main/webapp/js/jquery.js diff --git a/spring-mvc-java/src/main/webapp/js/script-async-jquery.js b/spring-web-modules/spring-mvc-java/src/main/webapp/js/script-async-jquery.js similarity index 100% rename from spring-mvc-java/src/main/webapp/js/script-async-jquery.js rename to spring-web-modules/spring-mvc-java/src/main/webapp/js/script-async-jquery.js diff --git a/spring-mvc-java/src/main/webapp/js/script-async.js b/spring-web-modules/spring-mvc-java/src/main/webapp/js/script-async.js similarity index 100% rename from spring-mvc-java/src/main/webapp/js/script-async.js rename to spring-web-modules/spring-mvc-java/src/main/webapp/js/script-async.js diff --git a/spring-mvc-java/src/main/webapp/js/script.js b/spring-web-modules/spring-mvc-java/src/main/webapp/js/script.js similarity index 100% rename from spring-mvc-java/src/main/webapp/js/script.js rename to spring-web-modules/spring-mvc-java/src/main/webapp/js/script.js diff --git a/spring-mvc-java/src/test/java/com/baeldung/accessparamsjs/ControllerUnitTest.java b/spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/accessparamsjs/ControllerUnitTest.java similarity index 100% rename from spring-mvc-java/src/test/java/com/baeldung/accessparamsjs/ControllerUnitTest.java rename to spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/accessparamsjs/ControllerUnitTest.java diff --git a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndJUnitLiveTest.java b/spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndJUnitLiveTest.java similarity index 100% rename from spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndJUnitLiveTest.java rename to spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndJUnitLiveTest.java diff --git a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringLiveTest.java b/spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringLiveTest.java similarity index 100% rename from spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringLiveTest.java rename to spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitAndSpringLiveTest.java diff --git a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitWebScrapingLiveTest.java b/spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitWebScrapingLiveTest.java similarity index 100% rename from spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitWebScrapingLiveTest.java rename to spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/htmlunit/HtmlUnitWebScrapingLiveTest.java diff --git a/spring-mvc-java/src/test/java/com/baeldung/htmlunit/TestConfig.java b/spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/htmlunit/TestConfig.java similarity index 100% rename from spring-mvc-java/src/test/java/com/baeldung/htmlunit/TestConfig.java rename to spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/htmlunit/TestConfig.java diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java b/spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java similarity index 100% rename from spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java rename to spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerIntegrationTest.java diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerRealIntegrationTest.java b/spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerRealIntegrationTest.java similarity index 100% rename from spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerRealIntegrationTest.java rename to spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerRealIntegrationTest.java diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerUnitTest.java b/spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerUnitTest.java similarity index 100% rename from spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerUnitTest.java rename to spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerUnitTest.java diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/README.md b/spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/README.md similarity index 100% rename from spring-mvc-java/src/test/java/com/baeldung/web/controller/README.md rename to spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/README.md diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerControllerIntegrationTest.java b/spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerControllerIntegrationTest.java similarity index 100% rename from spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerControllerIntegrationTest.java rename to spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerControllerIntegrationTest.java diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java b/spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java similarity index 100% rename from spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java rename to spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerControllerWithOptionalParamIntegrationTest.java diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java b/spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java similarity index 100% rename from spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java rename to spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerControllerWithRequiredAttributeIntegrationTest.java diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java b/spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java similarity index 100% rename from spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java rename to spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithMapParamIntegrationTest.java diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java b/spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java similarity index 100% rename from spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java rename to spring-web-modules/spring-mvc-java/src/test/java/com/baeldung/web/controller/optionalpathvars/ArticleViewerWithTwoSeparateMethodsIntegrationTest.java diff --git a/spring-mvc-java/src/test/resources/.gitignore b/spring-web-modules/spring-mvc-java/src/test/resources/.gitignore similarity index 100% rename from spring-mvc-java/src/test/resources/.gitignore rename to spring-web-modules/spring-mvc-java/src/test/resources/.gitignore diff --git a/spring-mvc-java/src/test/resources/logback-test.xml b/spring-web-modules/spring-mvc-java/src/test/resources/logback-test.xml similarity index 100% rename from spring-mvc-java/src/test/resources/logback-test.xml rename to spring-web-modules/spring-mvc-java/src/test/resources/logback-test.xml From 81b21f361c772f7cddf2460b80409a405ea25aac Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 29 Dec 2020 23:44:51 +0530 Subject: [PATCH 172/361] JAVA-3525: Moved spring-mvc-java-2 inside spring-web-modules --- .../spring-mvc-java-2}/.gitignore | 0 .../spring-mvc-java-2}/README.md | 0 .../spring-mvc-java-2}/pom.xml | 2 +- .../main/java/com/baeldung/cache/CacheControlController.java | 0 .../src/main/java/com/baeldung/cache/CacheWebConfig.java | 0 .../src/main/java/com/baeldung/datetime/DateTimeConfig.java | 0 .../src/main/java/com/baeldung/datetime/DateTimeController.java | 0 .../main/java/com/baeldung/matrix/config/MatrixWebConfig.java | 0 .../java/com/baeldung/matrix/controller/CompanyController.java | 0 .../java/com/baeldung/matrix/controller/EmployeeController.java | 0 .../src/main/java/com/baeldung/matrix/model/Company.java | 0 .../src/main/java/com/baeldung/matrix/model/Employee.java | 0 .../multiparttesting/MultipartPostRequestController.java | 0 .../CustomWebMvcConfigurationSupport.java | 0 .../com/baeldung/pathvariable.dottruncated/SiteController.java | 0 .../baeldung/pathvariable/PathVariableAnnotationController.java | 0 .../spring-mvc-java-2}/src/main/resources/targetFile.tmp | 0 .../spring-mvc-java-2}/src/main/webapp/WEB-INF/mvc-servlet.xml | 0 .../src/main/webapp/WEB-INF/view/companyHome.jsp | 0 .../src/main/webapp/WEB-INF/view/companyView.jsp | 0 .../src/main/webapp/WEB-INF/view/employeeHome.jsp | 0 .../src/main/webapp/WEB-INF/view/employeeView.jsp | 0 .../spring-mvc-java-2}/src/main/webapp/WEB-INF/web.xml | 0 .../spring-mvc-java-2}/src/main/webapp/resources/hello.css | 0 .../baeldung/cache/CacheControlControllerIntegrationTest.java | 0 .../java/com/baeldung/matrix/EmployeeMvcIntegrationTest.java | 0 .../java/com/baeldung/matrix/EmployeeNoMvcIntegrationTest.java | 0 .../baeldung/multipart/file/ConvertMultipartFileUnitTest.java | 0 .../MultipartPostRequestControllerUnitTest.java | 0 29 files changed, 1 insertion(+), 1 deletion(-) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/.gitignore (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/README.md (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/pom.xml (97%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/java/com/baeldung/cache/CacheControlController.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/java/com/baeldung/cache/CacheWebConfig.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/java/com/baeldung/datetime/DateTimeConfig.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/java/com/baeldung/datetime/DateTimeController.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/java/com/baeldung/matrix/config/MatrixWebConfig.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/java/com/baeldung/matrix/controller/CompanyController.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/java/com/baeldung/matrix/controller/EmployeeController.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/java/com/baeldung/matrix/model/Company.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/java/com/baeldung/matrix/model/Employee.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/java/com/baeldung/multiparttesting/MultipartPostRequestController.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/java/com/baeldung/pathvariable.dottruncated/CustomWebMvcConfigurationSupport.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/java/com/baeldung/pathvariable.dottruncated/SiteController.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/java/com/baeldung/pathvariable/PathVariableAnnotationController.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/resources/targetFile.tmp (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/webapp/WEB-INF/mvc-servlet.xml (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/webapp/WEB-INF/view/companyHome.jsp (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/webapp/WEB-INF/view/companyView.jsp (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/webapp/WEB-INF/view/employeeHome.jsp (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/webapp/WEB-INF/view/employeeView.jsp (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/webapp/WEB-INF/web.xml (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/main/webapp/resources/hello.css (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/test/java/com/baeldung/cache/CacheControlControllerIntegrationTest.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/test/java/com/baeldung/matrix/EmployeeMvcIntegrationTest.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/test/java/com/baeldung/matrix/EmployeeNoMvcIntegrationTest.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/test/java/com/baeldung/multipart/file/ConvertMultipartFileUnitTest.java (100%) rename {spring-mvc-java-2 => spring-web-modules/spring-mvc-java-2}/src/test/java/com/baeldung/multiparttesting/MultipartPostRequestControllerUnitTest.java (100%) diff --git a/spring-mvc-java-2/.gitignore b/spring-web-modules/spring-mvc-java-2/.gitignore similarity index 100% rename from spring-mvc-java-2/.gitignore rename to spring-web-modules/spring-mvc-java-2/.gitignore diff --git a/spring-mvc-java-2/README.md b/spring-web-modules/spring-mvc-java-2/README.md similarity index 100% rename from spring-mvc-java-2/README.md rename to spring-web-modules/spring-mvc-java-2/README.md diff --git a/spring-mvc-java-2/pom.xml b/spring-web-modules/spring-mvc-java-2/pom.xml similarity index 97% rename from spring-mvc-java-2/pom.xml rename to spring-web-modules/spring-mvc-java-2/pom.xml index 533a24771a..8a025defac 100644 --- a/spring-mvc-java-2/pom.xml +++ b/spring-web-modules/spring-mvc-java-2/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-java-2/src/main/java/com/baeldung/cache/CacheControlController.java b/spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/cache/CacheControlController.java similarity index 100% rename from spring-mvc-java-2/src/main/java/com/baeldung/cache/CacheControlController.java rename to spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/cache/CacheControlController.java diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/cache/CacheWebConfig.java b/spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/cache/CacheWebConfig.java similarity index 100% rename from spring-mvc-java-2/src/main/java/com/baeldung/cache/CacheWebConfig.java rename to spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/cache/CacheWebConfig.java diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeConfig.java b/spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeConfig.java similarity index 100% rename from spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeConfig.java rename to spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeConfig.java diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeController.java b/spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeController.java similarity index 100% rename from spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeController.java rename to spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeController.java diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/matrix/config/MatrixWebConfig.java b/spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/matrix/config/MatrixWebConfig.java similarity index 100% rename from spring-mvc-java-2/src/main/java/com/baeldung/matrix/config/MatrixWebConfig.java rename to spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/matrix/config/MatrixWebConfig.java diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/CompanyController.java b/spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/CompanyController.java similarity index 100% rename from spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/CompanyController.java rename to spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/CompanyController.java diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/EmployeeController.java b/spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/EmployeeController.java similarity index 100% rename from spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/EmployeeController.java rename to spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/EmployeeController.java diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Company.java b/spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Company.java similarity index 100% rename from spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Company.java rename to spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Company.java diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Employee.java b/spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Employee.java similarity index 100% rename from spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Employee.java rename to spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Employee.java diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/multiparttesting/MultipartPostRequestController.java b/spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/multiparttesting/MultipartPostRequestController.java similarity index 100% rename from spring-mvc-java-2/src/main/java/com/baeldung/multiparttesting/MultipartPostRequestController.java rename to spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/multiparttesting/MultipartPostRequestController.java diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable.dottruncated/CustomWebMvcConfigurationSupport.java b/spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable.dottruncated/CustomWebMvcConfigurationSupport.java similarity index 100% rename from spring-mvc-java-2/src/main/java/com/baeldung/pathvariable.dottruncated/CustomWebMvcConfigurationSupport.java rename to spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable.dottruncated/CustomWebMvcConfigurationSupport.java diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable.dottruncated/SiteController.java b/spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable.dottruncated/SiteController.java similarity index 100% rename from spring-mvc-java-2/src/main/java/com/baeldung/pathvariable.dottruncated/SiteController.java rename to spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable.dottruncated/SiteController.java diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/PathVariableAnnotationController.java b/spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/PathVariableAnnotationController.java similarity index 100% rename from spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/PathVariableAnnotationController.java rename to spring-web-modules/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/PathVariableAnnotationController.java diff --git a/spring-mvc-java-2/src/main/resources/targetFile.tmp b/spring-web-modules/spring-mvc-java-2/src/main/resources/targetFile.tmp similarity index 100% rename from spring-mvc-java-2/src/main/resources/targetFile.tmp rename to spring-web-modules/spring-mvc-java-2/src/main/resources/targetFile.tmp diff --git a/spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-web-modules/spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-web-modules/spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-mvc-java-2/src/main/webapp/WEB-INF/view/companyHome.jsp b/spring-web-modules/spring-mvc-java-2/src/main/webapp/WEB-INF/view/companyHome.jsp similarity index 100% rename from spring-mvc-java-2/src/main/webapp/WEB-INF/view/companyHome.jsp rename to spring-web-modules/spring-mvc-java-2/src/main/webapp/WEB-INF/view/companyHome.jsp diff --git a/spring-mvc-java-2/src/main/webapp/WEB-INF/view/companyView.jsp b/spring-web-modules/spring-mvc-java-2/src/main/webapp/WEB-INF/view/companyView.jsp similarity index 100% rename from spring-mvc-java-2/src/main/webapp/WEB-INF/view/companyView.jsp rename to spring-web-modules/spring-mvc-java-2/src/main/webapp/WEB-INF/view/companyView.jsp diff --git a/spring-mvc-java-2/src/main/webapp/WEB-INF/view/employeeHome.jsp b/spring-web-modules/spring-mvc-java-2/src/main/webapp/WEB-INF/view/employeeHome.jsp similarity index 100% rename from spring-mvc-java-2/src/main/webapp/WEB-INF/view/employeeHome.jsp rename to spring-web-modules/spring-mvc-java-2/src/main/webapp/WEB-INF/view/employeeHome.jsp diff --git a/spring-mvc-java-2/src/main/webapp/WEB-INF/view/employeeView.jsp b/spring-web-modules/spring-mvc-java-2/src/main/webapp/WEB-INF/view/employeeView.jsp similarity index 100% rename from spring-mvc-java-2/src/main/webapp/WEB-INF/view/employeeView.jsp rename to spring-web-modules/spring-mvc-java-2/src/main/webapp/WEB-INF/view/employeeView.jsp diff --git a/spring-mvc-java-2/src/main/webapp/WEB-INF/web.xml b/spring-web-modules/spring-mvc-java-2/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-mvc-java-2/src/main/webapp/WEB-INF/web.xml rename to spring-web-modules/spring-mvc-java-2/src/main/webapp/WEB-INF/web.xml diff --git a/spring-mvc-java-2/src/main/webapp/resources/hello.css b/spring-web-modules/spring-mvc-java-2/src/main/webapp/resources/hello.css similarity index 100% rename from spring-mvc-java-2/src/main/webapp/resources/hello.css rename to spring-web-modules/spring-mvc-java-2/src/main/webapp/resources/hello.css diff --git a/spring-mvc-java-2/src/test/java/com/baeldung/cache/CacheControlControllerIntegrationTest.java b/spring-web-modules/spring-mvc-java-2/src/test/java/com/baeldung/cache/CacheControlControllerIntegrationTest.java similarity index 100% rename from spring-mvc-java-2/src/test/java/com/baeldung/cache/CacheControlControllerIntegrationTest.java rename to spring-web-modules/spring-mvc-java-2/src/test/java/com/baeldung/cache/CacheControlControllerIntegrationTest.java diff --git a/spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeMvcIntegrationTest.java b/spring-web-modules/spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeMvcIntegrationTest.java similarity index 100% rename from spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeMvcIntegrationTest.java rename to spring-web-modules/spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeMvcIntegrationTest.java diff --git a/spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeNoMvcIntegrationTest.java b/spring-web-modules/spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeNoMvcIntegrationTest.java similarity index 100% rename from spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeNoMvcIntegrationTest.java rename to spring-web-modules/spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeNoMvcIntegrationTest.java diff --git a/spring-mvc-java-2/src/test/java/com/baeldung/multipart/file/ConvertMultipartFileUnitTest.java b/spring-web-modules/spring-mvc-java-2/src/test/java/com/baeldung/multipart/file/ConvertMultipartFileUnitTest.java similarity index 100% rename from spring-mvc-java-2/src/test/java/com/baeldung/multipart/file/ConvertMultipartFileUnitTest.java rename to spring-web-modules/spring-mvc-java-2/src/test/java/com/baeldung/multipart/file/ConvertMultipartFileUnitTest.java diff --git a/spring-mvc-java-2/src/test/java/com/baeldung/multiparttesting/MultipartPostRequestControllerUnitTest.java b/spring-web-modules/spring-mvc-java-2/src/test/java/com/baeldung/multiparttesting/MultipartPostRequestControllerUnitTest.java similarity index 100% rename from spring-mvc-java-2/src/test/java/com/baeldung/multiparttesting/MultipartPostRequestControllerUnitTest.java rename to spring-web-modules/spring-mvc-java-2/src/test/java/com/baeldung/multiparttesting/MultipartPostRequestControllerUnitTest.java From 824fd5496f94c2bae686ec94c183a043cb64481e Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 29 Dec 2020 23:46:11 +0530 Subject: [PATCH 173/361] Added module to new parent's pom --- spring-web-modules/pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index 730647d9e2..b41033bc30 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -21,6 +21,8 @@ spring-mvc-crash spring-mvc-forms-jsp spring-mvc-forms-thymeleaf + spring-mvc-java + spring-mvc-java-2 spring-thymeleaf spring-thymeleaf-2 From 4eec2e35a290fe470351cc733d4718ccdd2b0590 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 29 Dec 2020 23:46:47 +0530 Subject: [PATCH 174/361] Removed modules from main pom --- pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pom.xml b/pom.xml index 7db1c5bc54..e6cb9fd686 100644 --- a/pom.xml +++ b/pom.xml @@ -658,9 +658,6 @@ spring-mobile spring-mockito - spring-mvc-java - spring-mvc-java-2 - spring-mvc-velocity spring-mvc-views spring-mvc-webflow @@ -1129,9 +1126,6 @@ spring-mobile spring-mockito - spring-mvc-java - spring-mvc-java-2 - spring-mvc-velocity spring-mvc-views spring-mvc-webflow From 1c07f40727bac7e91007cd4e46b62459ad24f1b1 Mon Sep 17 00:00:00 2001 From: mikr Date: Tue, 29 Dec 2020 20:31:13 +0100 Subject: [PATCH 175/361] JAVA-3523 Move spring-rest-angular module --- pom.xml | 2 -- spring-web-modules/pom.xml | 1 + .../spring-rest-angular}/README.md | 0 .../spring-rest-angular}/pom.xml | 2 +- .../src/main/java/com/baeldung/web/dao/StudentRepository.java | 0 .../src/main/java/com/baeldung/web/entity/Student.java | 0 .../com/baeldung/web/exception/MyResourceNotFoundException.java | 0 .../src/main/java/com/baeldung/web/main/Application.java | 0 .../src/main/java/com/baeldung/web/main/PersistenceConfig.java | 0 .../com/baeldung/web/rest/StudentDirectoryRestController.java | 0 .../src/main/java/com/baeldung/web/service/IOperations.java | 0 .../src/main/java/com/baeldung/web/service/StudentService.java | 0 .../main/java/com/baeldung/web/service/StudentServiceImpl.java | 0 .../src/main/resources/application.properties | 0 .../spring-rest-angular}/src/main/resources/data.sql | 0 .../spring-rest-angular}/src/main/resources/logback.xml | 0 .../spring-rest-angular}/src/main/webapp/WEB-INF/web.xml | 0 .../spring-rest-angular}/src/main/webapp/index.html | 0 .../spring-rest-angular}/src/main/webapp/view/app.js | 0 .../src/test/java/com/baeldung/SpringContextTest.java | 0 .../com/baeldung/web/service/StudentServiceIntegrationTest.java | 0 21 files changed, 2 insertions(+), 3 deletions(-) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/README.md (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/pom.xml (97%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/main/java/com/baeldung/web/dao/StudentRepository.java (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/main/java/com/baeldung/web/entity/Student.java (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/main/java/com/baeldung/web/main/Application.java (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/main/java/com/baeldung/web/main/PersistenceConfig.java (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/main/java/com/baeldung/web/rest/StudentDirectoryRestController.java (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/main/java/com/baeldung/web/service/IOperations.java (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/main/java/com/baeldung/web/service/StudentService.java (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/main/java/com/baeldung/web/service/StudentServiceImpl.java (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/main/resources/application.properties (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/main/resources/data.sql (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/main/resources/logback.xml (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/main/webapp/WEB-INF/web.xml (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/main/webapp/index.html (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/main/webapp/view/app.js (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/test/java/com/baeldung/SpringContextTest.java (100%) rename {spring-rest-angular => spring-web-modules/spring-rest-angular}/src/test/java/com/baeldung/web/service/StudentServiceIntegrationTest.java (100%) diff --git a/pom.xml b/pom.xml index f8e84c09e1..dbada3d4dd 100644 --- a/pom.xml +++ b/pom.xml @@ -672,7 +672,6 @@ spring-reactor spring-remoting - spring-rest-angular spring-rest-http-2 spring-rest-query-language spring-rest-shell @@ -1142,7 +1141,6 @@ spring-reactor spring-remoting - spring-rest-angular spring-rest-query-language spring-rest-shell spring-rest-simple diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index 3dea8fc36e..3fc89f7717 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -20,6 +20,7 @@ spring-mvc-basics-4 spring-mvc-crash spring-mvc-forms-jsp + spring-rest-angular spring-rest-http spring-thymeleaf spring-thymeleaf-2 diff --git a/spring-rest-angular/README.md b/spring-web-modules/spring-rest-angular/README.md similarity index 100% rename from spring-rest-angular/README.md rename to spring-web-modules/spring-rest-angular/README.md diff --git a/spring-rest-angular/pom.xml b/spring-web-modules/spring-rest-angular/pom.xml similarity index 97% rename from spring-rest-angular/pom.xml rename to spring-web-modules/spring-rest-angular/pom.xml index 1d50b4c76c..eb1ec8696c 100644 --- a/spring-rest-angular/pom.xml +++ b/spring-web-modules/spring-rest-angular/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-rest-angular/src/main/java/com/baeldung/web/dao/StudentRepository.java b/spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/dao/StudentRepository.java similarity index 100% rename from spring-rest-angular/src/main/java/com/baeldung/web/dao/StudentRepository.java rename to spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/dao/StudentRepository.java diff --git a/spring-rest-angular/src/main/java/com/baeldung/web/entity/Student.java b/spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/entity/Student.java similarity index 100% rename from spring-rest-angular/src/main/java/com/baeldung/web/entity/Student.java rename to spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/entity/Student.java diff --git a/spring-rest-angular/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java b/spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java similarity index 100% rename from spring-rest-angular/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java rename to spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java diff --git a/spring-rest-angular/src/main/java/com/baeldung/web/main/Application.java b/spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/main/Application.java similarity index 100% rename from spring-rest-angular/src/main/java/com/baeldung/web/main/Application.java rename to spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/main/Application.java diff --git a/spring-rest-angular/src/main/java/com/baeldung/web/main/PersistenceConfig.java b/spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/main/PersistenceConfig.java similarity index 100% rename from spring-rest-angular/src/main/java/com/baeldung/web/main/PersistenceConfig.java rename to spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/main/PersistenceConfig.java diff --git a/spring-rest-angular/src/main/java/com/baeldung/web/rest/StudentDirectoryRestController.java b/spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/rest/StudentDirectoryRestController.java similarity index 100% rename from spring-rest-angular/src/main/java/com/baeldung/web/rest/StudentDirectoryRestController.java rename to spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/rest/StudentDirectoryRestController.java diff --git a/spring-rest-angular/src/main/java/com/baeldung/web/service/IOperations.java b/spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/service/IOperations.java similarity index 100% rename from spring-rest-angular/src/main/java/com/baeldung/web/service/IOperations.java rename to spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/service/IOperations.java diff --git a/spring-rest-angular/src/main/java/com/baeldung/web/service/StudentService.java b/spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/service/StudentService.java similarity index 100% rename from spring-rest-angular/src/main/java/com/baeldung/web/service/StudentService.java rename to spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/service/StudentService.java diff --git a/spring-rest-angular/src/main/java/com/baeldung/web/service/StudentServiceImpl.java b/spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/service/StudentServiceImpl.java similarity index 100% rename from spring-rest-angular/src/main/java/com/baeldung/web/service/StudentServiceImpl.java rename to spring-web-modules/spring-rest-angular/src/main/java/com/baeldung/web/service/StudentServiceImpl.java diff --git a/spring-rest-angular/src/main/resources/application.properties b/spring-web-modules/spring-rest-angular/src/main/resources/application.properties similarity index 100% rename from spring-rest-angular/src/main/resources/application.properties rename to spring-web-modules/spring-rest-angular/src/main/resources/application.properties diff --git a/spring-rest-angular/src/main/resources/data.sql b/spring-web-modules/spring-rest-angular/src/main/resources/data.sql similarity index 100% rename from spring-rest-angular/src/main/resources/data.sql rename to spring-web-modules/spring-rest-angular/src/main/resources/data.sql diff --git a/spring-rest-angular/src/main/resources/logback.xml b/spring-web-modules/spring-rest-angular/src/main/resources/logback.xml similarity index 100% rename from spring-rest-angular/src/main/resources/logback.xml rename to spring-web-modules/spring-rest-angular/src/main/resources/logback.xml diff --git a/spring-rest-angular/src/main/webapp/WEB-INF/web.xml b/spring-web-modules/spring-rest-angular/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-rest-angular/src/main/webapp/WEB-INF/web.xml rename to spring-web-modules/spring-rest-angular/src/main/webapp/WEB-INF/web.xml diff --git a/spring-rest-angular/src/main/webapp/index.html b/spring-web-modules/spring-rest-angular/src/main/webapp/index.html similarity index 100% rename from spring-rest-angular/src/main/webapp/index.html rename to spring-web-modules/spring-rest-angular/src/main/webapp/index.html diff --git a/spring-rest-angular/src/main/webapp/view/app.js b/spring-web-modules/spring-rest-angular/src/main/webapp/view/app.js similarity index 100% rename from spring-rest-angular/src/main/webapp/view/app.js rename to spring-web-modules/spring-rest-angular/src/main/webapp/view/app.js diff --git a/spring-rest-angular/src/test/java/com/baeldung/SpringContextTest.java b/spring-web-modules/spring-rest-angular/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-rest-angular/src/test/java/com/baeldung/SpringContextTest.java rename to spring-web-modules/spring-rest-angular/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-rest-angular/src/test/java/com/baeldung/web/service/StudentServiceIntegrationTest.java b/spring-web-modules/spring-rest-angular/src/test/java/com/baeldung/web/service/StudentServiceIntegrationTest.java similarity index 100% rename from spring-rest-angular/src/test/java/com/baeldung/web/service/StudentServiceIntegrationTest.java rename to spring-web-modules/spring-rest-angular/src/test/java/com/baeldung/web/service/StudentServiceIntegrationTest.java From e0ad1261c04fdadcf4490db438324184f4519d89 Mon Sep 17 00:00:00 2001 From: mikr Date: Tue, 29 Dec 2020 22:31:40 +0100 Subject: [PATCH 176/361] JAVA-3529 Move spring-mvc-views module --- pom.xml | 2 -- spring-web-modules/pom.xml | 1 + .../spring-mvc-views}/README.md | 0 .../spring-mvc-views}/pom.xml | 2 +- .../main/java/com/baeldung/themes/config/DataSourceConfig.java | 0 .../src/main/java/com/baeldung/themes/config/InitSecurity.java | 0 .../main/java/com/baeldung/themes/config/SecurityConfig.java | 0 .../main/java/com/baeldung/themes/config/ThemeMVCConfig.java | 0 .../baeldung/themes/config/TilesApplicationConfiguration.java | 0 .../main/java/com/baeldung/themes/config/WebInitializer.java | 0 .../java/com/baeldung/themes/controllers/AppController.java | 0 .../java/com/baeldung/themes/controllers/TilesController.java | 0 .../main/java/com/baeldung/themes/domain/UserPreference.java | 0 .../baeldung/themes/repository/UserPreferenceRepository.java | 0 .../baeldung/themes/resolver/UserPreferenceThemeResolver.java | 0 .../spring-mvc-views}/src/main/resources/dark.properties | 0 .../spring-mvc-views}/src/main/resources/dark_en_US.properties | 0 .../spring-mvc-views}/src/main/resources/db/sql/create-db.sql | 0 .../spring-mvc-views}/src/main/resources/db/sql/insert-data.sql | 0 .../spring-mvc-views}/src/main/resources/light.properties | 0 .../spring-mvc-views}/src/main/resources/light_en_US.properties | 0 .../spring-mvc-views}/src/main/resources/themes/black.css | 0 .../spring-mvc-views}/src/main/resources/themes/white.css | 0 .../spring-mvc-views}/src/main/webapp/WEB-INF/index.jsp | 0 .../src/main/webapp/WEB-INF/views/pages/apachetiles.jsp | 0 .../src/main/webapp/WEB-INF/views/pages/home.jsp | 0 .../src/main/webapp/WEB-INF/views/pages/springmvc.jsp | 0 .../main/webapp/WEB-INF/views/tiles/layouts/defaultLayout.jsp | 0 .../main/webapp/WEB-INF/views/tiles/templates/defaultFooter.jsp | 0 .../main/webapp/WEB-INF/views/tiles/templates/defaultHeader.jsp | 0 .../main/webapp/WEB-INF/views/tiles/templates/defaultMenu.jsp | 0 .../src/main/webapp/WEB-INF/views/tiles/tiles.xml | 0 .../spring-mvc-views}/src/main/webapp/static/css/app.css | 0 33 files changed, 2 insertions(+), 3 deletions(-) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/README.md (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/pom.xml (98%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/java/com/baeldung/themes/config/DataSourceConfig.java (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/java/com/baeldung/themes/config/InitSecurity.java (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/java/com/baeldung/themes/config/SecurityConfig.java (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/java/com/baeldung/themes/config/ThemeMVCConfig.java (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/java/com/baeldung/themes/config/TilesApplicationConfiguration.java (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/java/com/baeldung/themes/config/WebInitializer.java (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/java/com/baeldung/themes/controllers/AppController.java (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/java/com/baeldung/themes/controllers/TilesController.java (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/java/com/baeldung/themes/domain/UserPreference.java (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/java/com/baeldung/themes/repository/UserPreferenceRepository.java (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/java/com/baeldung/themes/resolver/UserPreferenceThemeResolver.java (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/resources/dark.properties (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/resources/dark_en_US.properties (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/resources/db/sql/create-db.sql (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/resources/db/sql/insert-data.sql (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/resources/light.properties (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/resources/light_en_US.properties (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/resources/themes/black.css (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/resources/themes/white.css (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/webapp/WEB-INF/index.jsp (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/webapp/WEB-INF/views/pages/apachetiles.jsp (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/webapp/WEB-INF/views/pages/home.jsp (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/webapp/WEB-INF/views/pages/springmvc.jsp (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/webapp/WEB-INF/views/tiles/layouts/defaultLayout.jsp (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/webapp/WEB-INF/views/tiles/templates/defaultFooter.jsp (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/webapp/WEB-INF/views/tiles/templates/defaultHeader.jsp (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/webapp/WEB-INF/views/tiles/templates/defaultMenu.jsp (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/webapp/WEB-INF/views/tiles/tiles.xml (100%) rename {spring-mvc-views => spring-web-modules/spring-mvc-views}/src/main/webapp/static/css/app.css (100%) diff --git a/pom.xml b/pom.xml index f8e84c09e1..3e360b58cc 100644 --- a/pom.xml +++ b/pom.xml @@ -663,7 +663,6 @@ spring-mvc-java-2 spring-mvc-velocity - spring-mvc-views spring-mvc-webflow spring-mvc-xml @@ -1133,7 +1132,6 @@ spring-mvc-java-2 spring-mvc-velocity - spring-mvc-views spring-mvc-webflow spring-mvc-xml diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index 3dea8fc36e..1da3612493 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -20,6 +20,7 @@ spring-mvc-basics-4 spring-mvc-crash spring-mvc-forms-jsp + spring-mvc-views spring-rest-http spring-thymeleaf spring-thymeleaf-2 diff --git a/spring-mvc-views/README.md b/spring-web-modules/spring-mvc-views/README.md similarity index 100% rename from spring-mvc-views/README.md rename to spring-web-modules/spring-mvc-views/README.md diff --git a/spring-mvc-views/pom.xml b/spring-web-modules/spring-mvc-views/pom.xml similarity index 98% rename from spring-mvc-views/pom.xml rename to spring-web-modules/spring-mvc-views/pom.xml index 452805bd53..2c3be5a33e 100644 --- a/spring-mvc-views/pom.xml +++ b/spring-web-modules/spring-mvc-views/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-spring-5 0.0.1-SNAPSHOT - ../parent-spring-5 + parent-spring-5/pom.xml diff --git a/spring-mvc-views/src/main/java/com/baeldung/themes/config/DataSourceConfig.java b/spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/config/DataSourceConfig.java similarity index 100% rename from spring-mvc-views/src/main/java/com/baeldung/themes/config/DataSourceConfig.java rename to spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/config/DataSourceConfig.java diff --git a/spring-mvc-views/src/main/java/com/baeldung/themes/config/InitSecurity.java b/spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/config/InitSecurity.java similarity index 100% rename from spring-mvc-views/src/main/java/com/baeldung/themes/config/InitSecurity.java rename to spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/config/InitSecurity.java diff --git a/spring-mvc-views/src/main/java/com/baeldung/themes/config/SecurityConfig.java b/spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/config/SecurityConfig.java similarity index 100% rename from spring-mvc-views/src/main/java/com/baeldung/themes/config/SecurityConfig.java rename to spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/config/SecurityConfig.java diff --git a/spring-mvc-views/src/main/java/com/baeldung/themes/config/ThemeMVCConfig.java b/spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/config/ThemeMVCConfig.java similarity index 100% rename from spring-mvc-views/src/main/java/com/baeldung/themes/config/ThemeMVCConfig.java rename to spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/config/ThemeMVCConfig.java diff --git a/spring-mvc-views/src/main/java/com/baeldung/themes/config/TilesApplicationConfiguration.java b/spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/config/TilesApplicationConfiguration.java similarity index 100% rename from spring-mvc-views/src/main/java/com/baeldung/themes/config/TilesApplicationConfiguration.java rename to spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/config/TilesApplicationConfiguration.java diff --git a/spring-mvc-views/src/main/java/com/baeldung/themes/config/WebInitializer.java b/spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/config/WebInitializer.java similarity index 100% rename from spring-mvc-views/src/main/java/com/baeldung/themes/config/WebInitializer.java rename to spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/config/WebInitializer.java diff --git a/spring-mvc-views/src/main/java/com/baeldung/themes/controllers/AppController.java b/spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/controllers/AppController.java similarity index 100% rename from spring-mvc-views/src/main/java/com/baeldung/themes/controllers/AppController.java rename to spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/controllers/AppController.java diff --git a/spring-mvc-views/src/main/java/com/baeldung/themes/controllers/TilesController.java b/spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/controllers/TilesController.java similarity index 100% rename from spring-mvc-views/src/main/java/com/baeldung/themes/controllers/TilesController.java rename to spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/controllers/TilesController.java diff --git a/spring-mvc-views/src/main/java/com/baeldung/themes/domain/UserPreference.java b/spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/domain/UserPreference.java similarity index 100% rename from spring-mvc-views/src/main/java/com/baeldung/themes/domain/UserPreference.java rename to spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/domain/UserPreference.java diff --git a/spring-mvc-views/src/main/java/com/baeldung/themes/repository/UserPreferenceRepository.java b/spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/repository/UserPreferenceRepository.java similarity index 100% rename from spring-mvc-views/src/main/java/com/baeldung/themes/repository/UserPreferenceRepository.java rename to spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/repository/UserPreferenceRepository.java diff --git a/spring-mvc-views/src/main/java/com/baeldung/themes/resolver/UserPreferenceThemeResolver.java b/spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/resolver/UserPreferenceThemeResolver.java similarity index 100% rename from spring-mvc-views/src/main/java/com/baeldung/themes/resolver/UserPreferenceThemeResolver.java rename to spring-web-modules/spring-mvc-views/src/main/java/com/baeldung/themes/resolver/UserPreferenceThemeResolver.java diff --git a/spring-mvc-views/src/main/resources/dark.properties b/spring-web-modules/spring-mvc-views/src/main/resources/dark.properties similarity index 100% rename from spring-mvc-views/src/main/resources/dark.properties rename to spring-web-modules/spring-mvc-views/src/main/resources/dark.properties diff --git a/spring-mvc-views/src/main/resources/dark_en_US.properties b/spring-web-modules/spring-mvc-views/src/main/resources/dark_en_US.properties similarity index 100% rename from spring-mvc-views/src/main/resources/dark_en_US.properties rename to spring-web-modules/spring-mvc-views/src/main/resources/dark_en_US.properties diff --git a/spring-mvc-views/src/main/resources/db/sql/create-db.sql b/spring-web-modules/spring-mvc-views/src/main/resources/db/sql/create-db.sql similarity index 100% rename from spring-mvc-views/src/main/resources/db/sql/create-db.sql rename to spring-web-modules/spring-mvc-views/src/main/resources/db/sql/create-db.sql diff --git a/spring-mvc-views/src/main/resources/db/sql/insert-data.sql b/spring-web-modules/spring-mvc-views/src/main/resources/db/sql/insert-data.sql similarity index 100% rename from spring-mvc-views/src/main/resources/db/sql/insert-data.sql rename to spring-web-modules/spring-mvc-views/src/main/resources/db/sql/insert-data.sql diff --git a/spring-mvc-views/src/main/resources/light.properties b/spring-web-modules/spring-mvc-views/src/main/resources/light.properties similarity index 100% rename from spring-mvc-views/src/main/resources/light.properties rename to spring-web-modules/spring-mvc-views/src/main/resources/light.properties diff --git a/spring-mvc-views/src/main/resources/light_en_US.properties b/spring-web-modules/spring-mvc-views/src/main/resources/light_en_US.properties similarity index 100% rename from spring-mvc-views/src/main/resources/light_en_US.properties rename to spring-web-modules/spring-mvc-views/src/main/resources/light_en_US.properties diff --git a/spring-mvc-views/src/main/resources/themes/black.css b/spring-web-modules/spring-mvc-views/src/main/resources/themes/black.css similarity index 100% rename from spring-mvc-views/src/main/resources/themes/black.css rename to spring-web-modules/spring-mvc-views/src/main/resources/themes/black.css diff --git a/spring-mvc-views/src/main/resources/themes/white.css b/spring-web-modules/spring-mvc-views/src/main/resources/themes/white.css similarity index 100% rename from spring-mvc-views/src/main/resources/themes/white.css rename to spring-web-modules/spring-mvc-views/src/main/resources/themes/white.css diff --git a/spring-mvc-views/src/main/webapp/WEB-INF/index.jsp b/spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/index.jsp similarity index 100% rename from spring-mvc-views/src/main/webapp/WEB-INF/index.jsp rename to spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/index.jsp diff --git a/spring-mvc-views/src/main/webapp/WEB-INF/views/pages/apachetiles.jsp b/spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/views/pages/apachetiles.jsp similarity index 100% rename from spring-mvc-views/src/main/webapp/WEB-INF/views/pages/apachetiles.jsp rename to spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/views/pages/apachetiles.jsp diff --git a/spring-mvc-views/src/main/webapp/WEB-INF/views/pages/home.jsp b/spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/views/pages/home.jsp similarity index 100% rename from spring-mvc-views/src/main/webapp/WEB-INF/views/pages/home.jsp rename to spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/views/pages/home.jsp diff --git a/spring-mvc-views/src/main/webapp/WEB-INF/views/pages/springmvc.jsp b/spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/views/pages/springmvc.jsp similarity index 100% rename from spring-mvc-views/src/main/webapp/WEB-INF/views/pages/springmvc.jsp rename to spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/views/pages/springmvc.jsp diff --git a/spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/layouts/defaultLayout.jsp b/spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/layouts/defaultLayout.jsp similarity index 100% rename from spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/layouts/defaultLayout.jsp rename to spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/layouts/defaultLayout.jsp diff --git a/spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/templates/defaultFooter.jsp b/spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/templates/defaultFooter.jsp similarity index 100% rename from spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/templates/defaultFooter.jsp rename to spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/templates/defaultFooter.jsp diff --git a/spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/templates/defaultHeader.jsp b/spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/templates/defaultHeader.jsp similarity index 100% rename from spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/templates/defaultHeader.jsp rename to spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/templates/defaultHeader.jsp diff --git a/spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/templates/defaultMenu.jsp b/spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/templates/defaultMenu.jsp similarity index 100% rename from spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/templates/defaultMenu.jsp rename to spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/templates/defaultMenu.jsp diff --git a/spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/tiles.xml b/spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/tiles.xml similarity index 100% rename from spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/tiles.xml rename to spring-web-modules/spring-mvc-views/src/main/webapp/WEB-INF/views/tiles/tiles.xml diff --git a/spring-mvc-views/src/main/webapp/static/css/app.css b/spring-web-modules/spring-mvc-views/src/main/webapp/static/css/app.css similarity index 100% rename from spring-mvc-views/src/main/webapp/static/css/app.css rename to spring-web-modules/spring-mvc-views/src/main/webapp/static/css/app.css From 55d36768129a31ff428fc77b230d0b011659dc7b Mon Sep 17 00:00:00 2001 From: mikr Date: Tue, 29 Dec 2020 22:56:18 +0100 Subject: [PATCH 177/361] JAVA-3530 Move spring-mvc-webflow module --- pom.xml | 2 -- spring-web-modules/pom.xml | 1 + .../spring-mvc-webflow}/README.md | 0 .../spring-mvc-webflow}/pom.xml | 0 .../src/main/java/org/baeldung/servlet/WebInitializer.java | 0 .../src/main/java/org/baeldung/spring/WebFlowConfig.java | 0 .../src/main/java/org/baeldung/spring/WebMvcConfig.java | 0 .../spring-mvc-webflow}/src/main/resources/flow-definition.xml | 0 .../spring-mvc-webflow}/src/main/resources/logback.xml | 0 .../src/main/webapp/WEB-INF/flows/activation-flow.xml | 0 .../src/main/webapp/WEB-INF/view/activation.jsp | 0 .../src/main/webapp/WEB-INF/view/failure.jsp | 0 .../spring-mvc-webflow}/src/main/webapp/WEB-INF/view/sample.jsp | 0 .../src/main/webapp/WEB-INF/view/success.jsp | 0 .../src/test/java/org/baeldung/SpringContextTest.java | 0 15 files changed, 1 insertion(+), 2 deletions(-) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/README.md (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/pom.xml (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/java/org/baeldung/servlet/WebInitializer.java (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/java/org/baeldung/spring/WebFlowConfig.java (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/java/org/baeldung/spring/WebMvcConfig.java (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/resources/flow-definition.xml (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/resources/logback.xml (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/webapp/WEB-INF/flows/activation-flow.xml (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/webapp/WEB-INF/view/activation.jsp (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/webapp/WEB-INF/view/failure.jsp (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/webapp/WEB-INF/view/sample.jsp (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/webapp/WEB-INF/view/success.jsp (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/test/java/org/baeldung/SpringContextTest.java (100%) diff --git a/pom.xml b/pom.xml index f8e84c09e1..a0c412de9c 100644 --- a/pom.xml +++ b/pom.xml @@ -664,7 +664,6 @@ spring-mvc-velocity spring-mvc-views - spring-mvc-webflow spring-mvc-xml spring-protobuf @@ -1134,7 +1133,6 @@ spring-mvc-velocity spring-mvc-views - spring-mvc-webflow spring-mvc-xml spring-protobuf diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index 3dea8fc36e..8c426fe9c0 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -20,6 +20,7 @@ spring-mvc-basics-4 spring-mvc-crash spring-mvc-forms-jsp + spring-mvc-webflow spring-rest-http spring-thymeleaf spring-thymeleaf-2 diff --git a/spring-mvc-webflow/README.md b/spring-web-modules/spring-mvc-webflow/README.md similarity index 100% rename from spring-mvc-webflow/README.md rename to spring-web-modules/spring-mvc-webflow/README.md diff --git a/spring-mvc-webflow/pom.xml b/spring-web-modules/spring-mvc-webflow/pom.xml similarity index 100% rename from spring-mvc-webflow/pom.xml rename to spring-web-modules/spring-mvc-webflow/pom.xml diff --git a/spring-mvc-webflow/src/main/java/org/baeldung/servlet/WebInitializer.java b/spring-web-modules/spring-mvc-webflow/src/main/java/org/baeldung/servlet/WebInitializer.java similarity index 100% rename from spring-mvc-webflow/src/main/java/org/baeldung/servlet/WebInitializer.java rename to spring-web-modules/spring-mvc-webflow/src/main/java/org/baeldung/servlet/WebInitializer.java diff --git a/spring-mvc-webflow/src/main/java/org/baeldung/spring/WebFlowConfig.java b/spring-web-modules/spring-mvc-webflow/src/main/java/org/baeldung/spring/WebFlowConfig.java similarity index 100% rename from spring-mvc-webflow/src/main/java/org/baeldung/spring/WebFlowConfig.java rename to spring-web-modules/spring-mvc-webflow/src/main/java/org/baeldung/spring/WebFlowConfig.java diff --git a/spring-mvc-webflow/src/main/java/org/baeldung/spring/WebMvcConfig.java b/spring-web-modules/spring-mvc-webflow/src/main/java/org/baeldung/spring/WebMvcConfig.java similarity index 100% rename from spring-mvc-webflow/src/main/java/org/baeldung/spring/WebMvcConfig.java rename to spring-web-modules/spring-mvc-webflow/src/main/java/org/baeldung/spring/WebMvcConfig.java diff --git a/spring-mvc-webflow/src/main/resources/flow-definition.xml b/spring-web-modules/spring-mvc-webflow/src/main/resources/flow-definition.xml similarity index 100% rename from spring-mvc-webflow/src/main/resources/flow-definition.xml rename to spring-web-modules/spring-mvc-webflow/src/main/resources/flow-definition.xml diff --git a/spring-mvc-webflow/src/main/resources/logback.xml b/spring-web-modules/spring-mvc-webflow/src/main/resources/logback.xml similarity index 100% rename from spring-mvc-webflow/src/main/resources/logback.xml rename to spring-web-modules/spring-mvc-webflow/src/main/resources/logback.xml diff --git a/spring-mvc-webflow/src/main/webapp/WEB-INF/flows/activation-flow.xml b/spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/flows/activation-flow.xml similarity index 100% rename from spring-mvc-webflow/src/main/webapp/WEB-INF/flows/activation-flow.xml rename to spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/flows/activation-flow.xml diff --git a/spring-mvc-webflow/src/main/webapp/WEB-INF/view/activation.jsp b/spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/view/activation.jsp similarity index 100% rename from spring-mvc-webflow/src/main/webapp/WEB-INF/view/activation.jsp rename to spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/view/activation.jsp diff --git a/spring-mvc-webflow/src/main/webapp/WEB-INF/view/failure.jsp b/spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/view/failure.jsp similarity index 100% rename from spring-mvc-webflow/src/main/webapp/WEB-INF/view/failure.jsp rename to spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/view/failure.jsp diff --git a/spring-mvc-webflow/src/main/webapp/WEB-INF/view/sample.jsp b/spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/view/sample.jsp similarity index 100% rename from spring-mvc-webflow/src/main/webapp/WEB-INF/view/sample.jsp rename to spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/view/sample.jsp diff --git a/spring-mvc-webflow/src/main/webapp/WEB-INF/view/success.jsp b/spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/view/success.jsp similarity index 100% rename from spring-mvc-webflow/src/main/webapp/WEB-INF/view/success.jsp rename to spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/view/success.jsp diff --git a/spring-mvc-webflow/src/test/java/org/baeldung/SpringContextTest.java b/spring-web-modules/spring-mvc-webflow/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-mvc-webflow/src/test/java/org/baeldung/SpringContextTest.java rename to spring-web-modules/spring-mvc-webflow/src/test/java/org/baeldung/SpringContextTest.java From 1cc511ae5e2d554ee3fcd5e250dccf68e88ea61d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 30 Dec 2020 13:32:07 +0530 Subject: [PATCH 178/361] BAEL-4301 - Updated assertTrue to assertEqual - Added examples --- .../CharacterGeneralCategoryTypeUnitTest.java | 13 ++++++------ .../character/IsLetterOrAlphabetUnitTest.java | 21 +++++++++++++++++++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/core-java-modules/core-java-char/src/test/java/com/baeldung/character/CharacterGeneralCategoryTypeUnitTest.java b/core-java-modules/core-java-char/src/test/java/com/baeldung/character/CharacterGeneralCategoryTypeUnitTest.java index 4bb41211a9..9fab13df45 100644 --- a/core-java-modules/core-java-char/src/test/java/com/baeldung/character/CharacterGeneralCategoryTypeUnitTest.java +++ b/core-java-modules/core-java-char/src/test/java/com/baeldung/character/CharacterGeneralCategoryTypeUnitTest.java @@ -3,35 +3,36 @@ package com.baeldung.character; import org.junit.Test; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; public class CharacterGeneralCategoryTypeUnitTest { @Test public void givenACharacter_whenUpperCaseLetter_thenAssertTrue() { - assertTrue(Character.getType('U') == Character.UPPERCASE_LETTER); + assertEquals(Character.UPPERCASE_LETTER, Character.getType('U')); } @Test public void givenACharacter_whenLowerCaseLetter_thenAssertTrue() { - assertTrue(Character.getType('u') == Character.LOWERCASE_LETTER); + assertEquals(Character.LOWERCASE_LETTER, Character.getType('u')); } @Test public void givenACharacter_whenTitleCaseLetter_thenAssertTrue() { - assertTrue(Character.getType('\u01f2') == Character.TITLECASE_LETTER); + assertEquals(Character.TITLECASE_LETTER, Character.getType('\u01f2')); } @Test public void givenACharacter_whenModifierLetter_thenAssertTrue() { - assertTrue(Character.getType('\u02b0') == Character.MODIFIER_LETTER); + assertEquals(Character.MODIFIER_LETTER, Character.getType('\u02b0')); } @Test public void givenACharacter_whenOtherLetter_thenAssertTrue() { - assertTrue(Character.getType('\u05d0') == Character.OTHER_LETTER); + assertEquals(Character.OTHER_LETTER, Character.getType('\u05d0')); } @Test public void givenACharacter_whenLetterNumber_thenAssertTrue() { - assertTrue(Character.getType('\u2164') == Character.LETTER_NUMBER); + assertEquals(Character.LETTER_NUMBER, Character.getType('\u2164')); } } diff --git a/core-java-modules/core-java-char/src/test/java/com/baeldung/character/IsLetterOrAlphabetUnitTest.java b/core-java-modules/core-java-char/src/test/java/com/baeldung/character/IsLetterOrAlphabetUnitTest.java index 734762ec7b..3de3a16e6a 100644 --- a/core-java-modules/core-java-char/src/test/java/com/baeldung/character/IsLetterOrAlphabetUnitTest.java +++ b/core-java-modules/core-java-char/src/test/java/com/baeldung/character/IsLetterOrAlphabetUnitTest.java @@ -6,6 +6,27 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; public class IsLetterOrAlphabetUnitTest { + + @Test + public void givenACharacter_whenUpperCaseLetter_thenAssertIsAlphabeticTrue() { + assertTrue(Character.isAlphabetic('A')); + } + + @Test + public void givenACharacter_whenTitleCaseLetter_thenAssertIsAlphabeticTrue() { + assertTrue(Character.isAlphabetic('\u01f2')); + } + + @Test + public void givenACharacter_whenLowerCaseLetter_thenAssertIsLetterTrue() { + assertTrue(Character.isAlphabetic('a')); + } + + @Test + public void givenACharacter_whenModifierLetter_thenAssertIsLetterTrue() { + assertTrue(Character.isAlphabetic('\u02b0')); + } + @Test public void givenACharacter_whenLetter_thenAssertIsLetterTrue() { assertTrue(Character.isLetter('a')); From 9b808b2fde14d6be5e7fd95254936ff09e824181 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 30 Dec 2020 16:34:08 +0800 Subject: [PATCH 179/361] Update README.md --- spring-cloud/spring-cloud-eureka/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-cloud/spring-cloud-eureka/README.md b/spring-cloud/spring-cloud-eureka/README.md index badf4c8d50..5fc96256f4 100644 --- a/spring-cloud/spring-cloud-eureka/README.md +++ b/spring-cloud/spring-cloud-eureka/README.md @@ -1,2 +1,3 @@ ### Relevant Articles: - [Introduction to Spring Cloud Netflix – Eureka](http://www.baeldung.com/spring-cloud-netflix-eureka) +- [Integration Tests With Spring Cloud Netflix and Feign](https://www.baeldung.com/spring-cloud-feign-integration-tests) From c99f74a6a1b316a15bc68bfb4477afdf829ba4bd Mon Sep 17 00:00:00 2001 From: mikr Date: Wed, 30 Dec 2020 12:14:14 +0100 Subject: [PATCH 180/361] JAVA-3535 Move spring rest query language module --- pom.xml | 2 - spring-web-modules/pom.xml | 1 + .../spring-rest-query-language}/.gitignore | 0 .../spring-rest-query-language}/README.md | 0 .../spring-rest-query-language}/pom.xml | 2 +- .../dao/GenericSpecificationsBuilder.java | 200 +++++----- .../baeldung/persistence/dao/IUserDAO.java | 0 .../persistence/dao/MyUserPredicate.java | 0 .../dao/MyUserPredicatesBuilder.java | 0 .../persistence/dao/MyUserRepository.java | 0 .../com/baeldung/persistence/dao/UserDAO.java | 0 .../persistence/dao/UserRepository.java | 0 .../dao/UserSearchQueryCriteriaConsumer.java | 0 .../persistence/dao/UserSpecification.java | 0 .../dao/UserSpecificationsBuilder.java | 140 +++---- .../dao/rsql/CustomRsqlVisitor.java | 0 .../dao/rsql/GenericRsqlSpecBuilder.java | 0 .../dao/rsql/GenericRsqlSpecification.java | 0 .../dao/rsql/RsqlSearchOperation.java | 0 .../baeldung/persistence/model/MyUser.java | 0 .../com/baeldung/persistence/model/User.java | 0 .../com/baeldung/persistence/model/User_.java | 0 .../java/com/baeldung/spring/Application.java | 0 .../baeldung/spring/PersistenceConfig.java | 0 .../java/com/baeldung/spring/WebConfig.java | 0 .../web/controller/HomeController.java | 0 .../web/controller/UserController.java | 342 ++++++++--------- .../RestResponseEntityExceptionHandler.java | 0 .../MyResourceNotFoundException.java | 0 .../com/baeldung/web/util/CriteriaParser.java | 0 .../com/baeldung/web/util/SearchCriteria.java | 0 .../baeldung/web/util/SearchOperation.java | 72 ++-- .../baeldung/web/util/SpecSearchCriteria.java | 164 ++++---- .../src/main/resources/application.properties | 0 .../src/main/resources/data.sql | 0 .../src/main/resources/logback.xml | 0 .../main/resources/persistence-h2.properties | 0 .../resources/persistence-mysql.properties | 0 .../resources/springDataPersistenceConfig.xml | 0 .../src/main/webapp/WEB-INF/api-servlet.xml | 0 .../src/main/webapp/WEB-INF/view/homepage.jsp | 0 .../src/main/webapp/WEB-INF/web.xml | 0 .../java/com/baeldung/SpringContextTest.java | 0 .../JPACriteriaQueryIntegrationTest.java | 0 .../query/JPAQuerydslIntegrationTest.java | 0 .../JPASpecificationIntegrationTest.java | 360 +++++++++--------- .../query/JPASpecificationLiveTest.java | 294 +++++++------- .../query/RsqlIntegrationTest.java | 0 .../java/com/baeldung/web/MyUserLiveTest.java | 0 .../src/test/resources/.gitignore | 0 50 files changed, 788 insertions(+), 789 deletions(-) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/.gitignore (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/README.md (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/pom.xml (99%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/dao/GenericSpecificationsBuilder.java (97%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/dao/IUserDAO.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/dao/MyUserPredicate.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/dao/MyUserPredicatesBuilder.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/dao/MyUserRepository.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/dao/UserDAO.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/dao/UserRepository.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/dao/UserSearchQueryCriteriaConsumer.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/dao/UserSpecification.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/dao/UserSpecificationsBuilder.java (97%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/dao/rsql/CustomRsqlVisitor.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/dao/rsql/GenericRsqlSpecBuilder.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/dao/rsql/GenericRsqlSpecification.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/dao/rsql/RsqlSearchOperation.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/model/MyUser.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/model/User.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/persistence/model/User_.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/spring/Application.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/spring/PersistenceConfig.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/spring/WebConfig.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/web/controller/HomeController.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/web/controller/UserController.java (97%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/web/error/RestResponseEntityExceptionHandler.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/web/util/CriteriaParser.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/web/util/SearchCriteria.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/web/util/SearchOperation.java (96%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/java/com/baeldung/web/util/SpecSearchCriteria.java (96%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/resources/application.properties (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/resources/data.sql (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/resources/logback.xml (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/resources/persistence-h2.properties (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/resources/persistence-mysql.properties (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/resources/springDataPersistenceConfig.xml (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/webapp/WEB-INF/api-servlet.xml (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/webapp/WEB-INF/view/homepage.jsp (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/main/webapp/WEB-INF/web.xml (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/test/java/com/baeldung/SpringContextTest.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/test/java/com/baeldung/persistence/query/JPACriteriaQueryIntegrationTest.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/test/java/com/baeldung/persistence/query/JPAQuerydslIntegrationTest.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/test/java/com/baeldung/persistence/query/JPASpecificationIntegrationTest.java (97%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/test/java/com/baeldung/persistence/query/JPASpecificationLiveTest.java (97%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/test/java/com/baeldung/persistence/query/RsqlIntegrationTest.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/test/java/com/baeldung/web/MyUserLiveTest.java (100%) rename {spring-rest-query-language => spring-web-modules/spring-rest-query-language}/src/test/resources/.gitignore (100%) diff --git a/pom.xml b/pom.xml index 79bf7d72b7..88b0a4e23d 100644 --- a/pom.xml +++ b/pom.xml @@ -674,7 +674,6 @@ spring-reactor spring-remoting spring-rest-http-2 - spring-rest-query-language spring-rest-shell spring-rest-simple spring-resttemplate @@ -1141,7 +1140,6 @@ spring-reactor spring-remoting - spring-rest-query-language spring-rest-shell spring-rest-simple spring-resttemplate diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index ce0524f957..19ec1c2a74 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -22,6 +22,7 @@ spring-mvc-forms-jsp spring-rest-angular spring-rest-http + spring-rest-query-language spring-resttemplate-2 spring-thymeleaf spring-thymeleaf-2 diff --git a/spring-rest-query-language/.gitignore b/spring-web-modules/spring-rest-query-language/.gitignore similarity index 100% rename from spring-rest-query-language/.gitignore rename to spring-web-modules/spring-rest-query-language/.gitignore diff --git a/spring-rest-query-language/README.md b/spring-web-modules/spring-rest-query-language/README.md similarity index 100% rename from spring-rest-query-language/README.md rename to spring-web-modules/spring-rest-query-language/README.md diff --git a/spring-rest-query-language/pom.xml b/spring-web-modules/spring-rest-query-language/pom.xml similarity index 99% rename from spring-rest-query-language/pom.xml rename to spring-web-modules/spring-rest-query-language/pom.xml index 4458aa0580..5e7ca023dd 100644 --- a/spring-rest-query-language/pom.xml +++ b/spring-web-modules/spring-rest-query-language/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/GenericSpecificationsBuilder.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/GenericSpecificationsBuilder.java similarity index 97% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/GenericSpecificationsBuilder.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/GenericSpecificationsBuilder.java index 75fb4456c4..b6623e8885 100644 --- a/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/GenericSpecificationsBuilder.java +++ b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/GenericSpecificationsBuilder.java @@ -1,100 +1,100 @@ -package com.baeldung.persistence.dao; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Deque; -import java.util.LinkedList; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; - -import org.springframework.data.jpa.domain.Specification; - -import com.baeldung.web.util.SearchOperation; -import com.baeldung.web.util.SpecSearchCriteria; - -public class GenericSpecificationsBuilder { - - private final List params; - - public GenericSpecificationsBuilder() { - this.params = new ArrayList<>(); - } - - public final GenericSpecificationsBuilder with(final String key, final String operation, final Object value, final String prefix, final String suffix) { - return with(null, key, operation, value, prefix, suffix); - } - - public final GenericSpecificationsBuilder with(final String precedenceIndicator, final String key, final String operation, final Object value, final String prefix, final String suffix) { - SearchOperation op = SearchOperation.getSimpleOperation(operation.charAt(0)); - if (op != null) { - if (op == SearchOperation.EQUALITY) // the operation may be complex operation - { - final boolean startWithAsterisk = prefix != null && prefix.contains(SearchOperation.ZERO_OR_MORE_REGEX); - final boolean endWithAsterisk = suffix != null && suffix.contains(SearchOperation.ZERO_OR_MORE_REGEX); - - if (startWithAsterisk && endWithAsterisk) { - op = SearchOperation.CONTAINS; - } else if (startWithAsterisk) { - op = SearchOperation.ENDS_WITH; - } else if (endWithAsterisk) { - op = SearchOperation.STARTS_WITH; - } - } - params.add(new SpecSearchCriteria(precedenceIndicator, key, op, value)); - } - return this; - } - - public Specification build(Function> converter) { - - if (params.size() == 0) { - return null; - } - - final List> specs = params.stream() - .map(converter) - .collect(Collectors.toCollection(ArrayList::new)); - - Specification result = specs.get(0); - - for (int idx = 1; idx < specs.size(); idx++) { - result = params.get(idx) - .isOrPredicate() - ? Specification.where(result) - .or(specs.get(idx)) - : Specification.where(result) - .and(specs.get(idx)); - } - - return result; - } - - public Specification build(Deque postFixedExprStack, Function> converter) { - - Deque> specStack = new LinkedList<>(); - - Collections.reverse((List) postFixedExprStack); - - while (!postFixedExprStack.isEmpty()) { - Object mayBeOperand = postFixedExprStack.pop(); - - if (!(mayBeOperand instanceof String)) { - specStack.push(converter.apply((SpecSearchCriteria) mayBeOperand)); - } else { - Specification operand1 = specStack.pop(); - Specification operand2 = specStack.pop(); - if (mayBeOperand.equals(SearchOperation.AND_OPERATOR)) - specStack.push(Specification.where(operand1) - .and(operand2)); - else if (mayBeOperand.equals(SearchOperation.OR_OPERATOR)) - specStack.push(Specification.where(operand1) - .or(operand2)); - } - - } - return specStack.pop(); - - } - -} +package com.baeldung.persistence.dao; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Deque; +import java.util.LinkedList; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.springframework.data.jpa.domain.Specification; + +import com.baeldung.web.util.SearchOperation; +import com.baeldung.web.util.SpecSearchCriteria; + +public class GenericSpecificationsBuilder { + + private final List params; + + public GenericSpecificationsBuilder() { + this.params = new ArrayList<>(); + } + + public final GenericSpecificationsBuilder with(final String key, final String operation, final Object value, final String prefix, final String suffix) { + return with(null, key, operation, value, prefix, suffix); + } + + public final GenericSpecificationsBuilder with(final String precedenceIndicator, final String key, final String operation, final Object value, final String prefix, final String suffix) { + SearchOperation op = SearchOperation.getSimpleOperation(operation.charAt(0)); + if (op != null) { + if (op == SearchOperation.EQUALITY) // the operation may be complex operation + { + final boolean startWithAsterisk = prefix != null && prefix.contains(SearchOperation.ZERO_OR_MORE_REGEX); + final boolean endWithAsterisk = suffix != null && suffix.contains(SearchOperation.ZERO_OR_MORE_REGEX); + + if (startWithAsterisk && endWithAsterisk) { + op = SearchOperation.CONTAINS; + } else if (startWithAsterisk) { + op = SearchOperation.ENDS_WITH; + } else if (endWithAsterisk) { + op = SearchOperation.STARTS_WITH; + } + } + params.add(new SpecSearchCriteria(precedenceIndicator, key, op, value)); + } + return this; + } + + public Specification build(Function> converter) { + + if (params.size() == 0) { + return null; + } + + final List> specs = params.stream() + .map(converter) + .collect(Collectors.toCollection(ArrayList::new)); + + Specification result = specs.get(0); + + for (int idx = 1; idx < specs.size(); idx++) { + result = params.get(idx) + .isOrPredicate() + ? Specification.where(result) + .or(specs.get(idx)) + : Specification.where(result) + .and(specs.get(idx)); + } + + return result; + } + + public Specification build(Deque postFixedExprStack, Function> converter) { + + Deque> specStack = new LinkedList<>(); + + Collections.reverse((List) postFixedExprStack); + + while (!postFixedExprStack.isEmpty()) { + Object mayBeOperand = postFixedExprStack.pop(); + + if (!(mayBeOperand instanceof String)) { + specStack.push(converter.apply((SpecSearchCriteria) mayBeOperand)); + } else { + Specification operand1 = specStack.pop(); + Specification operand2 = specStack.pop(); + if (mayBeOperand.equals(SearchOperation.AND_OPERATOR)) + specStack.push(Specification.where(operand1) + .and(operand2)); + else if (mayBeOperand.equals(SearchOperation.OR_OPERATOR)) + specStack.push(Specification.where(operand1) + .or(operand2)); + } + + } + return specStack.pop(); + + } + +} diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/IUserDAO.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/IUserDAO.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/IUserDAO.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/IUserDAO.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserPredicate.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserPredicate.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserPredicate.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserPredicate.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserPredicatesBuilder.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserPredicatesBuilder.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserPredicatesBuilder.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserPredicatesBuilder.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserRepository.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserRepository.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserRepository.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/MyUserRepository.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserDAO.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserDAO.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserDAO.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserDAO.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserRepository.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserRepository.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserRepository.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserRepository.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSearchQueryCriteriaConsumer.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSearchQueryCriteriaConsumer.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSearchQueryCriteriaConsumer.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSearchQueryCriteriaConsumer.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSpecification.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSpecification.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSpecification.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSpecification.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSpecificationsBuilder.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSpecificationsBuilder.java similarity index 97% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSpecificationsBuilder.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSpecificationsBuilder.java index 72d7274226..eac1562294 100644 --- a/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSpecificationsBuilder.java +++ b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/UserSpecificationsBuilder.java @@ -1,70 +1,70 @@ -package com.baeldung.persistence.dao; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.data.jpa.domain.Specification; - -import com.baeldung.persistence.model.User; -import com.baeldung.web.util.SearchOperation; -import com.baeldung.web.util.SpecSearchCriteria; - -public final class UserSpecificationsBuilder { - - private final List params; - - public UserSpecificationsBuilder() { - params = new ArrayList<>(); - } - - // API - - public final UserSpecificationsBuilder with(final String key, final String operation, final Object value, final String prefix, final String suffix) { - return with(null, key, operation, value, prefix, suffix); - } - - public final UserSpecificationsBuilder with(final String orPredicate, final String key, final String operation, final Object value, final String prefix, final String suffix) { - SearchOperation op = SearchOperation.getSimpleOperation(operation.charAt(0)); - if (op != null) { - if (op == SearchOperation.EQUALITY) { // the operation may be complex operation - final boolean startWithAsterisk = prefix != null && prefix.contains(SearchOperation.ZERO_OR_MORE_REGEX); - final boolean endWithAsterisk = suffix != null && suffix.contains(SearchOperation.ZERO_OR_MORE_REGEX); - - if (startWithAsterisk && endWithAsterisk) { - op = SearchOperation.CONTAINS; - } else if (startWithAsterisk) { - op = SearchOperation.ENDS_WITH; - } else if (endWithAsterisk) { - op = SearchOperation.STARTS_WITH; - } - } - params.add(new SpecSearchCriteria(orPredicate, key, op, value)); - } - return this; - } - - public Specification build() { - if (params.size() == 0) - return null; - - Specification result = new UserSpecification(params.get(0)); - - for (int i = 1; i < params.size(); i++) { - result = params.get(i).isOrPredicate() - ? Specification.where(result).or(new UserSpecification(params.get(i))) - : Specification.where(result).and(new UserSpecification(params.get(i))); - } - - return result; - } - - public final UserSpecificationsBuilder with(UserSpecification spec) { - params.add(spec.getCriteria()); - return this; - } - - public final UserSpecificationsBuilder with(SpecSearchCriteria criteria) { - params.add(criteria); - return this; - } -} +package com.baeldung.persistence.dao; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.data.jpa.domain.Specification; + +import com.baeldung.persistence.model.User; +import com.baeldung.web.util.SearchOperation; +import com.baeldung.web.util.SpecSearchCriteria; + +public final class UserSpecificationsBuilder { + + private final List params; + + public UserSpecificationsBuilder() { + params = new ArrayList<>(); + } + + // API + + public final UserSpecificationsBuilder with(final String key, final String operation, final Object value, final String prefix, final String suffix) { + return with(null, key, operation, value, prefix, suffix); + } + + public final UserSpecificationsBuilder with(final String orPredicate, final String key, final String operation, final Object value, final String prefix, final String suffix) { + SearchOperation op = SearchOperation.getSimpleOperation(operation.charAt(0)); + if (op != null) { + if (op == SearchOperation.EQUALITY) { // the operation may be complex operation + final boolean startWithAsterisk = prefix != null && prefix.contains(SearchOperation.ZERO_OR_MORE_REGEX); + final boolean endWithAsterisk = suffix != null && suffix.contains(SearchOperation.ZERO_OR_MORE_REGEX); + + if (startWithAsterisk && endWithAsterisk) { + op = SearchOperation.CONTAINS; + } else if (startWithAsterisk) { + op = SearchOperation.ENDS_WITH; + } else if (endWithAsterisk) { + op = SearchOperation.STARTS_WITH; + } + } + params.add(new SpecSearchCriteria(orPredicate, key, op, value)); + } + return this; + } + + public Specification build() { + if (params.size() == 0) + return null; + + Specification result = new UserSpecification(params.get(0)); + + for (int i = 1; i < params.size(); i++) { + result = params.get(i).isOrPredicate() + ? Specification.where(result).or(new UserSpecification(params.get(i))) + : Specification.where(result).and(new UserSpecification(params.get(i))); + } + + return result; + } + + public final UserSpecificationsBuilder with(UserSpecification spec) { + params.add(spec.getCriteria()); + return this; + } + + public final UserSpecificationsBuilder with(SpecSearchCriteria criteria) { + params.add(criteria); + return this; + } +} diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/CustomRsqlVisitor.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/CustomRsqlVisitor.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/CustomRsqlVisitor.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/CustomRsqlVisitor.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/GenericRsqlSpecBuilder.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/GenericRsqlSpecBuilder.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/GenericRsqlSpecBuilder.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/GenericRsqlSpecBuilder.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/GenericRsqlSpecification.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/GenericRsqlSpecification.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/GenericRsqlSpecification.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/GenericRsqlSpecification.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/RsqlSearchOperation.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/RsqlSearchOperation.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/RsqlSearchOperation.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/dao/rsql/RsqlSearchOperation.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/model/MyUser.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/model/MyUser.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/model/MyUser.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/model/MyUser.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/model/User.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/model/User.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/model/User.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/model/User.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/persistence/model/User_.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/model/User_.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/persistence/model/User_.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/persistence/model/User_.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/spring/Application.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/spring/Application.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/spring/Application.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/spring/Application.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/spring/PersistenceConfig.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/spring/PersistenceConfig.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/spring/PersistenceConfig.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/spring/PersistenceConfig.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/spring/WebConfig.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/spring/WebConfig.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/spring/WebConfig.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/spring/WebConfig.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/web/controller/HomeController.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/controller/HomeController.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/web/controller/HomeController.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/controller/HomeController.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/web/controller/UserController.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/controller/UserController.java similarity index 97% rename from spring-rest-query-language/src/main/java/com/baeldung/web/controller/UserController.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/controller/UserController.java index 54e8618b27..73a97f84ae 100644 --- a/spring-rest-query-language/src/main/java/com/baeldung/web/controller/UserController.java +++ b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/controller/UserController.java @@ -1,171 +1,171 @@ -package com.baeldung.web.controller; - -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.jpa.domain.Specification; -import org.springframework.data.querydsl.binding.QuerydslPredicate; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; - -import com.baeldung.persistence.dao.GenericSpecificationsBuilder; -import com.baeldung.persistence.dao.IUserDAO; -import com.baeldung.persistence.dao.MyUserPredicatesBuilder; -import com.baeldung.persistence.dao.MyUserRepository; -import com.baeldung.persistence.dao.UserRepository; -import com.baeldung.persistence.dao.UserSpecification; -import com.baeldung.persistence.dao.UserSpecificationsBuilder; -import com.baeldung.persistence.dao.rsql.CustomRsqlVisitor; -import com.baeldung.persistence.model.MyUser; -import com.baeldung.persistence.model.User; -import com.baeldung.web.util.CriteriaParser; -import com.baeldung.web.util.SearchCriteria; -import com.baeldung.web.util.SearchOperation; -import com.google.common.base.Joiner; -import com.google.common.base.Preconditions; -import com.querydsl.core.types.Predicate; -import com.querydsl.core.types.dsl.BooleanExpression; - -import cz.jirutka.rsql.parser.RSQLParser; -import cz.jirutka.rsql.parser.ast.Node; - -//@EnableSpringDataWebSupport -@Controller -@RequestMapping(value = "/auth/") -public class UserController { - - @Autowired - private IUserDAO service; - - @Autowired - private UserRepository dao; - - @Autowired - private MyUserRepository myUserRepository; - - public UserController() { - super(); - } - - // API - READ - - @RequestMapping(method = RequestMethod.GET, value = "/users") - @ResponseBody - public List search(@RequestParam(value = "search", required = false) String search) { - List params = new ArrayList(); - if (search != null) { - Pattern pattern = Pattern.compile("(\\w+?)(:|<|>)(\\w+?),"); - Matcher matcher = pattern.matcher(search + ","); - while (matcher.find()) { - params.add(new SearchCriteria(matcher.group(1), matcher.group(2), matcher.group(3))); - } - } - return service.searchUser(params); - } - - @RequestMapping(method = RequestMethod.GET, value = "/users/spec") - @ResponseBody - public List findAllBySpecification(@RequestParam(value = "search") String search) { - UserSpecificationsBuilder builder = new UserSpecificationsBuilder(); - String operationSetExper = Joiner.on("|") - .join(SearchOperation.SIMPLE_OPERATION_SET); - Pattern pattern = Pattern.compile("(\\w+?)(" + operationSetExper + ")(\\p{Punct}?)(\\w+?)(\\p{Punct}?),"); - Matcher matcher = pattern.matcher(search + ","); - while (matcher.find()) { - builder.with(matcher.group(1), matcher.group(2), matcher.group(4), matcher.group(3), matcher.group(5)); - } - - Specification spec = builder.build(); - return dao.findAll(spec); - } - - @GetMapping(value = "/users/espec") - @ResponseBody - public List findAllByOrPredicate(@RequestParam(value = "search") String search) { - Specification spec = resolveSpecification(search); - return dao.findAll(spec); - } - - @GetMapping(value = "/users/spec/adv") - @ResponseBody - public List findAllByAdvPredicate(@RequestParam(value = "search") String search) { - Specification spec = resolveSpecificationFromInfixExpr(search); - return dao.findAll(spec); - } - - protected Specification resolveSpecificationFromInfixExpr(String searchParameters) { - CriteriaParser parser = new CriteriaParser(); - GenericSpecificationsBuilder specBuilder = new GenericSpecificationsBuilder<>(); - return specBuilder.build(parser.parse(searchParameters), UserSpecification::new); - } - - protected Specification resolveSpecification(String searchParameters) { - - UserSpecificationsBuilder builder = new UserSpecificationsBuilder(); - String operationSetExper = Joiner.on("|") - .join(SearchOperation.SIMPLE_OPERATION_SET); - Pattern pattern = Pattern.compile("(\\p{Punct}?)(\\w+?)(" + operationSetExper + ")(\\p{Punct}?)(\\w+?)(\\p{Punct}?),"); - Matcher matcher = pattern.matcher(searchParameters + ","); - while (matcher.find()) { - builder.with(matcher.group(1), matcher.group(2), matcher.group(3), matcher.group(5), matcher.group(4), matcher.group(6)); - } - return builder.build(); - } - - @RequestMapping(method = RequestMethod.GET, value = "/myusers") - @ResponseBody - public Iterable findAllByQuerydsl(@RequestParam(value = "search") String search) { - MyUserPredicatesBuilder builder = new MyUserPredicatesBuilder(); - if (search != null) { - Pattern pattern = Pattern.compile("(\\w+?)(:|<|>)(\\w+?),"); - Matcher matcher = pattern.matcher(search + ","); - while (matcher.find()) { - builder.with(matcher.group(1), matcher.group(2), matcher.group(3)); - } - } - BooleanExpression exp = builder.build(); - return myUserRepository.findAll(exp); - } - - @RequestMapping(method = RequestMethod.GET, value = "/users/rsql") - @ResponseBody - public List findAllByRsql(@RequestParam(value = "search") String search) { - Node rootNode = new RSQLParser().parse(search); - Specification spec = rootNode.accept(new CustomRsqlVisitor()); - return dao.findAll(spec); - } - - @RequestMapping(method = RequestMethod.GET, value = "/api/myusers") - @ResponseBody - public Iterable findAllByWebQuerydsl(@QuerydslPredicate(root = MyUser.class) Predicate predicate) { - return myUserRepository.findAll(predicate); - } - - // API - WRITE - - @RequestMapping(method = RequestMethod.POST, value = "/users") - @ResponseStatus(HttpStatus.CREATED) - public void create(@RequestBody User resource) { - Preconditions.checkNotNull(resource); - dao.save(resource); - } - - @RequestMapping(method = RequestMethod.POST, value = "/myusers") - @ResponseStatus(HttpStatus.CREATED) - public void addMyUser(@RequestBody MyUser resource) { - Preconditions.checkNotNull(resource); - myUserRepository.save(resource); - - } - -} +package com.baeldung.web.controller; + +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.data.querydsl.binding.QuerydslPredicate; +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; + +import com.baeldung.persistence.dao.GenericSpecificationsBuilder; +import com.baeldung.persistence.dao.IUserDAO; +import com.baeldung.persistence.dao.MyUserPredicatesBuilder; +import com.baeldung.persistence.dao.MyUserRepository; +import com.baeldung.persistence.dao.UserRepository; +import com.baeldung.persistence.dao.UserSpecification; +import com.baeldung.persistence.dao.UserSpecificationsBuilder; +import com.baeldung.persistence.dao.rsql.CustomRsqlVisitor; +import com.baeldung.persistence.model.MyUser; +import com.baeldung.persistence.model.User; +import com.baeldung.web.util.CriteriaParser; +import com.baeldung.web.util.SearchCriteria; +import com.baeldung.web.util.SearchOperation; +import com.google.common.base.Joiner; +import com.google.common.base.Preconditions; +import com.querydsl.core.types.Predicate; +import com.querydsl.core.types.dsl.BooleanExpression; + +import cz.jirutka.rsql.parser.RSQLParser; +import cz.jirutka.rsql.parser.ast.Node; + +//@EnableSpringDataWebSupport +@Controller +@RequestMapping(value = "/auth/") +public class UserController { + + @Autowired + private IUserDAO service; + + @Autowired + private UserRepository dao; + + @Autowired + private MyUserRepository myUserRepository; + + public UserController() { + super(); + } + + // API - READ + + @RequestMapping(method = RequestMethod.GET, value = "/users") + @ResponseBody + public List search(@RequestParam(value = "search", required = false) String search) { + List params = new ArrayList(); + if (search != null) { + Pattern pattern = Pattern.compile("(\\w+?)(:|<|>)(\\w+?),"); + Matcher matcher = pattern.matcher(search + ","); + while (matcher.find()) { + params.add(new SearchCriteria(matcher.group(1), matcher.group(2), matcher.group(3))); + } + } + return service.searchUser(params); + } + + @RequestMapping(method = RequestMethod.GET, value = "/users/spec") + @ResponseBody + public List findAllBySpecification(@RequestParam(value = "search") String search) { + UserSpecificationsBuilder builder = new UserSpecificationsBuilder(); + String operationSetExper = Joiner.on("|") + .join(SearchOperation.SIMPLE_OPERATION_SET); + Pattern pattern = Pattern.compile("(\\w+?)(" + operationSetExper + ")(\\p{Punct}?)(\\w+?)(\\p{Punct}?),"); + Matcher matcher = pattern.matcher(search + ","); + while (matcher.find()) { + builder.with(matcher.group(1), matcher.group(2), matcher.group(4), matcher.group(3), matcher.group(5)); + } + + Specification spec = builder.build(); + return dao.findAll(spec); + } + + @GetMapping(value = "/users/espec") + @ResponseBody + public List findAllByOrPredicate(@RequestParam(value = "search") String search) { + Specification spec = resolveSpecification(search); + return dao.findAll(spec); + } + + @GetMapping(value = "/users/spec/adv") + @ResponseBody + public List findAllByAdvPredicate(@RequestParam(value = "search") String search) { + Specification spec = resolveSpecificationFromInfixExpr(search); + return dao.findAll(spec); + } + + protected Specification resolveSpecificationFromInfixExpr(String searchParameters) { + CriteriaParser parser = new CriteriaParser(); + GenericSpecificationsBuilder specBuilder = new GenericSpecificationsBuilder<>(); + return specBuilder.build(parser.parse(searchParameters), UserSpecification::new); + } + + protected Specification resolveSpecification(String searchParameters) { + + UserSpecificationsBuilder builder = new UserSpecificationsBuilder(); + String operationSetExper = Joiner.on("|") + .join(SearchOperation.SIMPLE_OPERATION_SET); + Pattern pattern = Pattern.compile("(\\p{Punct}?)(\\w+?)(" + operationSetExper + ")(\\p{Punct}?)(\\w+?)(\\p{Punct}?),"); + Matcher matcher = pattern.matcher(searchParameters + ","); + while (matcher.find()) { + builder.with(matcher.group(1), matcher.group(2), matcher.group(3), matcher.group(5), matcher.group(4), matcher.group(6)); + } + return builder.build(); + } + + @RequestMapping(method = RequestMethod.GET, value = "/myusers") + @ResponseBody + public Iterable findAllByQuerydsl(@RequestParam(value = "search") String search) { + MyUserPredicatesBuilder builder = new MyUserPredicatesBuilder(); + if (search != null) { + Pattern pattern = Pattern.compile("(\\w+?)(:|<|>)(\\w+?),"); + Matcher matcher = pattern.matcher(search + ","); + while (matcher.find()) { + builder.with(matcher.group(1), matcher.group(2), matcher.group(3)); + } + } + BooleanExpression exp = builder.build(); + return myUserRepository.findAll(exp); + } + + @RequestMapping(method = RequestMethod.GET, value = "/users/rsql") + @ResponseBody + public List findAllByRsql(@RequestParam(value = "search") String search) { + Node rootNode = new RSQLParser().parse(search); + Specification spec = rootNode.accept(new CustomRsqlVisitor()); + return dao.findAll(spec); + } + + @RequestMapping(method = RequestMethod.GET, value = "/api/myusers") + @ResponseBody + public Iterable findAllByWebQuerydsl(@QuerydslPredicate(root = MyUser.class) Predicate predicate) { + return myUserRepository.findAll(predicate); + } + + // API - WRITE + + @RequestMapping(method = RequestMethod.POST, value = "/users") + @ResponseStatus(HttpStatus.CREATED) + public void create(@RequestBody User resource) { + Preconditions.checkNotNull(resource); + dao.save(resource); + } + + @RequestMapping(method = RequestMethod.POST, value = "/myusers") + @ResponseStatus(HttpStatus.CREATED) + public void addMyUser(@RequestBody MyUser resource) { + Preconditions.checkNotNull(resource); + myUserRepository.save(resource); + + } + +} diff --git a/spring-rest-query-language/src/main/java/com/baeldung/web/error/RestResponseEntityExceptionHandler.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/error/RestResponseEntityExceptionHandler.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/web/error/RestResponseEntityExceptionHandler.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/error/RestResponseEntityExceptionHandler.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/web/util/CriteriaParser.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/util/CriteriaParser.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/web/util/CriteriaParser.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/util/CriteriaParser.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/web/util/SearchCriteria.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/util/SearchCriteria.java similarity index 100% rename from spring-rest-query-language/src/main/java/com/baeldung/web/util/SearchCriteria.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/util/SearchCriteria.java diff --git a/spring-rest-query-language/src/main/java/com/baeldung/web/util/SearchOperation.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/util/SearchOperation.java similarity index 96% rename from spring-rest-query-language/src/main/java/com/baeldung/web/util/SearchOperation.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/util/SearchOperation.java index acc9e0c0a8..86ad9ad749 100644 --- a/spring-rest-query-language/src/main/java/com/baeldung/web/util/SearchOperation.java +++ b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/util/SearchOperation.java @@ -1,36 +1,36 @@ -package com.baeldung.web.util; - -public enum SearchOperation { - EQUALITY, NEGATION, GREATER_THAN, LESS_THAN, LIKE, STARTS_WITH, ENDS_WITH, CONTAINS; - - public static final String[] SIMPLE_OPERATION_SET = { ":", "!", ">", "<", "~" }; - - public static final String OR_PREDICATE_FLAG = "'"; - - public static final String ZERO_OR_MORE_REGEX = "*"; - - public static final String OR_OPERATOR = "OR"; - - public static final String AND_OPERATOR = "AND"; - - public static final String LEFT_PARANTHESIS = "("; - - public static final String RIGHT_PARANTHESIS = ")"; - - public static SearchOperation getSimpleOperation(final char input) { - switch (input) { - case ':': - return EQUALITY; - case '!': - return NEGATION; - case '>': - return GREATER_THAN; - case '<': - return LESS_THAN; - case '~': - return LIKE; - default: - return null; - } - } -} +package com.baeldung.web.util; + +public enum SearchOperation { + EQUALITY, NEGATION, GREATER_THAN, LESS_THAN, LIKE, STARTS_WITH, ENDS_WITH, CONTAINS; + + public static final String[] SIMPLE_OPERATION_SET = { ":", "!", ">", "<", "~" }; + + public static final String OR_PREDICATE_FLAG = "'"; + + public static final String ZERO_OR_MORE_REGEX = "*"; + + public static final String OR_OPERATOR = "OR"; + + public static final String AND_OPERATOR = "AND"; + + public static final String LEFT_PARANTHESIS = "("; + + public static final String RIGHT_PARANTHESIS = ")"; + + public static SearchOperation getSimpleOperation(final char input) { + switch (input) { + case ':': + return EQUALITY; + case '!': + return NEGATION; + case '>': + return GREATER_THAN; + case '<': + return LESS_THAN; + case '~': + return LIKE; + default: + return null; + } + } +} diff --git a/spring-rest-query-language/src/main/java/com/baeldung/web/util/SpecSearchCriteria.java b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/util/SpecSearchCriteria.java similarity index 96% rename from spring-rest-query-language/src/main/java/com/baeldung/web/util/SpecSearchCriteria.java rename to spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/util/SpecSearchCriteria.java index 73b690673b..22b55c78fb 100644 --- a/spring-rest-query-language/src/main/java/com/baeldung/web/util/SpecSearchCriteria.java +++ b/spring-web-modules/spring-rest-query-language/src/main/java/com/baeldung/web/util/SpecSearchCriteria.java @@ -1,82 +1,82 @@ -package com.baeldung.web.util; - -public class SpecSearchCriteria { - - private String key; - private SearchOperation operation; - private Object value; - private boolean orPredicate; - - public SpecSearchCriteria() { - - } - - public SpecSearchCriteria(final String key, final SearchOperation operation, final Object value) { - super(); - this.key = key; - this.operation = operation; - this.value = value; - } - - public SpecSearchCriteria(final String orPredicate, final String key, final SearchOperation operation, final Object value) { - super(); - this.orPredicate = orPredicate != null && orPredicate.equals(SearchOperation.OR_PREDICATE_FLAG); - this.key = key; - this.operation = operation; - this.value = value; - } - - public SpecSearchCriteria(String key, String operation, String prefix, String value, String suffix) { - SearchOperation op = SearchOperation.getSimpleOperation(operation.charAt(0)); - if (op != null) { - if (op == SearchOperation.EQUALITY) { // the operation may be complex operation - final boolean startWithAsterisk = prefix != null && prefix.contains(SearchOperation.ZERO_OR_MORE_REGEX); - final boolean endWithAsterisk = suffix != null && suffix.contains(SearchOperation.ZERO_OR_MORE_REGEX); - - if (startWithAsterisk && endWithAsterisk) { - op = SearchOperation.CONTAINS; - } else if (startWithAsterisk) { - op = SearchOperation.ENDS_WITH; - } else if (endWithAsterisk) { - op = SearchOperation.STARTS_WITH; - } - } - } - this.key = key; - this.operation = op; - this.value = value; - } - - public String getKey() { - return key; - } - - public void setKey(final String key) { - this.key = key; - } - - public SearchOperation getOperation() { - return operation; - } - - public void setOperation(final SearchOperation operation) { - this.operation = operation; - } - - public Object getValue() { - return value; - } - - public void setValue(final Object value) { - this.value = value; - } - - public boolean isOrPredicate() { - return orPredicate; - } - - public void setOrPredicate(boolean orPredicate) { - this.orPredicate = orPredicate; - } - -} +package com.baeldung.web.util; + +public class SpecSearchCriteria { + + private String key; + private SearchOperation operation; + private Object value; + private boolean orPredicate; + + public SpecSearchCriteria() { + + } + + public SpecSearchCriteria(final String key, final SearchOperation operation, final Object value) { + super(); + this.key = key; + this.operation = operation; + this.value = value; + } + + public SpecSearchCriteria(final String orPredicate, final String key, final SearchOperation operation, final Object value) { + super(); + this.orPredicate = orPredicate != null && orPredicate.equals(SearchOperation.OR_PREDICATE_FLAG); + this.key = key; + this.operation = operation; + this.value = value; + } + + public SpecSearchCriteria(String key, String operation, String prefix, String value, String suffix) { + SearchOperation op = SearchOperation.getSimpleOperation(operation.charAt(0)); + if (op != null) { + if (op == SearchOperation.EQUALITY) { // the operation may be complex operation + final boolean startWithAsterisk = prefix != null && prefix.contains(SearchOperation.ZERO_OR_MORE_REGEX); + final boolean endWithAsterisk = suffix != null && suffix.contains(SearchOperation.ZERO_OR_MORE_REGEX); + + if (startWithAsterisk && endWithAsterisk) { + op = SearchOperation.CONTAINS; + } else if (startWithAsterisk) { + op = SearchOperation.ENDS_WITH; + } else if (endWithAsterisk) { + op = SearchOperation.STARTS_WITH; + } + } + } + this.key = key; + this.operation = op; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(final String key) { + this.key = key; + } + + public SearchOperation getOperation() { + return operation; + } + + public void setOperation(final SearchOperation operation) { + this.operation = operation; + } + + public Object getValue() { + return value; + } + + public void setValue(final Object value) { + this.value = value; + } + + public boolean isOrPredicate() { + return orPredicate; + } + + public void setOrPredicate(boolean orPredicate) { + this.orPredicate = orPredicate; + } + +} diff --git a/spring-rest-query-language/src/main/resources/application.properties b/spring-web-modules/spring-rest-query-language/src/main/resources/application.properties similarity index 100% rename from spring-rest-query-language/src/main/resources/application.properties rename to spring-web-modules/spring-rest-query-language/src/main/resources/application.properties diff --git a/spring-rest-query-language/src/main/resources/data.sql b/spring-web-modules/spring-rest-query-language/src/main/resources/data.sql similarity index 100% rename from spring-rest-query-language/src/main/resources/data.sql rename to spring-web-modules/spring-rest-query-language/src/main/resources/data.sql diff --git a/spring-rest-query-language/src/main/resources/logback.xml b/spring-web-modules/spring-rest-query-language/src/main/resources/logback.xml similarity index 100% rename from spring-rest-query-language/src/main/resources/logback.xml rename to spring-web-modules/spring-rest-query-language/src/main/resources/logback.xml diff --git a/spring-rest-query-language/src/main/resources/persistence-h2.properties b/spring-web-modules/spring-rest-query-language/src/main/resources/persistence-h2.properties similarity index 100% rename from spring-rest-query-language/src/main/resources/persistence-h2.properties rename to spring-web-modules/spring-rest-query-language/src/main/resources/persistence-h2.properties diff --git a/spring-rest-query-language/src/main/resources/persistence-mysql.properties b/spring-web-modules/spring-rest-query-language/src/main/resources/persistence-mysql.properties similarity index 100% rename from spring-rest-query-language/src/main/resources/persistence-mysql.properties rename to spring-web-modules/spring-rest-query-language/src/main/resources/persistence-mysql.properties diff --git a/spring-rest-query-language/src/main/resources/springDataPersistenceConfig.xml b/spring-web-modules/spring-rest-query-language/src/main/resources/springDataPersistenceConfig.xml similarity index 100% rename from spring-rest-query-language/src/main/resources/springDataPersistenceConfig.xml rename to spring-web-modules/spring-rest-query-language/src/main/resources/springDataPersistenceConfig.xml diff --git a/spring-rest-query-language/src/main/webapp/WEB-INF/api-servlet.xml b/spring-web-modules/spring-rest-query-language/src/main/webapp/WEB-INF/api-servlet.xml similarity index 100% rename from spring-rest-query-language/src/main/webapp/WEB-INF/api-servlet.xml rename to spring-web-modules/spring-rest-query-language/src/main/webapp/WEB-INF/api-servlet.xml diff --git a/spring-rest-query-language/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-web-modules/spring-rest-query-language/src/main/webapp/WEB-INF/view/homepage.jsp similarity index 100% rename from spring-rest-query-language/src/main/webapp/WEB-INF/view/homepage.jsp rename to spring-web-modules/spring-rest-query-language/src/main/webapp/WEB-INF/view/homepage.jsp diff --git a/spring-rest-query-language/src/main/webapp/WEB-INF/web.xml b/spring-web-modules/spring-rest-query-language/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-rest-query-language/src/main/webapp/WEB-INF/web.xml rename to spring-web-modules/spring-rest-query-language/src/main/webapp/WEB-INF/web.xml diff --git a/spring-rest-query-language/src/test/java/com/baeldung/SpringContextTest.java b/spring-web-modules/spring-rest-query-language/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-rest-query-language/src/test/java/com/baeldung/SpringContextTest.java rename to spring-web-modules/spring-rest-query-language/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPACriteriaQueryIntegrationTest.java b/spring-web-modules/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPACriteriaQueryIntegrationTest.java similarity index 100% rename from spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPACriteriaQueryIntegrationTest.java rename to spring-web-modules/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPACriteriaQueryIntegrationTest.java diff --git a/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPAQuerydslIntegrationTest.java b/spring-web-modules/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPAQuerydslIntegrationTest.java similarity index 100% rename from spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPAQuerydslIntegrationTest.java rename to spring-web-modules/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPAQuerydslIntegrationTest.java diff --git a/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationIntegrationTest.java b/spring-web-modules/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationIntegrationTest.java similarity index 97% rename from spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationIntegrationTest.java rename to spring-web-modules/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationIntegrationTest.java index 707426769e..f6fff10506 100644 --- a/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationIntegrationTest.java +++ b/spring-web-modules/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationIntegrationTest.java @@ -1,180 +1,180 @@ -package com.baeldung.persistence.query; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.jpa.domain.Specification; -import org.springframework.test.annotation.Rollback; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.transaction.annotation.Transactional; - -import com.baeldung.persistence.dao.GenericSpecificationsBuilder; -import com.baeldung.persistence.dao.UserRepository; -import com.baeldung.persistence.dao.UserSpecification; -import com.baeldung.persistence.dao.UserSpecificationsBuilder; -import com.baeldung.persistence.model.User; -import com.baeldung.spring.PersistenceConfig; -import com.baeldung.web.util.CriteriaParser; -import com.baeldung.web.util.SearchOperation; -import com.baeldung.web.util.SpecSearchCriteria; - -import java.util.List; -import java.util.function.Function; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.collection.IsCollectionWithSize.hasSize; -import static org.hamcrest.collection.IsIn.isIn; -import static org.hamcrest.core.IsNot.not; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { PersistenceConfig.class }) -@Transactional -@Rollback -public class JPASpecificationIntegrationTest { - - @Autowired - private UserRepository repository; - - private User userJohn; - - private User userTom; - - private User userPercy; - - @Before - public void init() { - userJohn = new User(); - userJohn.setFirstName("john"); - userJohn.setLastName("doe"); - userJohn.setEmail("john@doe.com"); - userJohn.setAge(22); - repository.save(userJohn); - - userTom = new User(); - userTom.setFirstName("tom"); - userTom.setLastName("doe"); - userTom.setEmail("tom@doe.com"); - userTom.setAge(26); - repository.save(userTom); - - userPercy = new User(); - userPercy.setFirstName("percy"); - userPercy.setLastName("blackney"); - userPercy.setEmail("percy@blackney.com"); - userPercy.setAge(30); - repository.save(userPercy); - } - - @Test - public void givenFirstAndLastName_whenGettingListOfUsers_thenCorrect() { - final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("firstName", SearchOperation.EQUALITY, "john")); - final UserSpecification spec1 = new UserSpecification(new SpecSearchCriteria("lastName", SearchOperation.EQUALITY, "doe")); - final List results = repository.findAll(Specification - .where(spec) - .and(spec1)); - - assertThat(userJohn, isIn(results)); - assertThat(userTom, not(isIn(results))); - } - - @Test - public void givenFirstOrLastName_whenGettingListOfUsers_thenCorrect() { - UserSpecificationsBuilder builder = new UserSpecificationsBuilder(); - - SpecSearchCriteria spec = new SpecSearchCriteria("firstName", SearchOperation.EQUALITY, "john"); - SpecSearchCriteria spec1 = new SpecSearchCriteria("'","lastName", SearchOperation.EQUALITY, "doe"); - - List results = repository.findAll(builder - .with(spec) - .with(spec1) - .build()); - - assertThat(results, hasSize(2)); - assertThat(userJohn, isIn(results)); - assertThat(userTom, isIn(results)); - } - - @Test - public void givenFirstOrLastNameAndAgeGenericBuilder_whenGettingListOfUsers_thenCorrect() { - GenericSpecificationsBuilder builder = new GenericSpecificationsBuilder<>(); - Function> converter = UserSpecification::new; - - CriteriaParser parser=new CriteriaParser(); - List results = repository.findAll(builder.build(parser.parse("( lastName:doe OR firstName:john ) AND age:22"), converter)); - - assertThat(results, hasSize(1)); - assertThat(userJohn, isIn(results)); - assertThat(userTom, not(isIn(results))); - } - - @Test - public void givenFirstOrLastNameGenericBuilder_whenGettingListOfUsers_thenCorrect() { - GenericSpecificationsBuilder builder = new GenericSpecificationsBuilder<>(); - Function> converter = UserSpecification::new; - - builder.with("firstName", ":", "john", null, null); - builder.with("'", "lastName", ":", "doe", null, null); - - List results = repository.findAll(builder.build(converter)); - - assertThat(results, hasSize(2)); - assertThat(userJohn, isIn(results)); - assertThat(userTom, isIn(results)); - } - - @Test - public void givenFirstNameInverse_whenGettingListOfUsers_thenCorrect() { - final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("firstName", SearchOperation.NEGATION, "john")); - final List results = repository.findAll(Specification.where(spec)); - - assertThat(userTom, isIn(results)); - assertThat(userJohn, not(isIn(results))); - } - - @Test - public void givenMinAge_whenGettingListOfUsers_thenCorrect() { - final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("age", SearchOperation.GREATER_THAN, "25")); - final List results = repository.findAll(Specification.where(spec)); - assertThat(userTom, isIn(results)); - assertThat(userJohn, not(isIn(results))); - } - - @Test - public void givenFirstNamePrefix_whenGettingListOfUsers_thenCorrect() { - final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("firstName", SearchOperation.STARTS_WITH, "jo")); - final List results = repository.findAll(spec); - assertThat(userJohn, isIn(results)); - assertThat(userTom, not(isIn(results))); - } - - @Test - public void givenFirstNameSuffix_whenGettingListOfUsers_thenCorrect() { - final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("firstName", SearchOperation.ENDS_WITH, "n")); - final List results = repository.findAll(spec); - assertThat(userJohn, isIn(results)); - assertThat(userTom, not(isIn(results))); - } - - @Test - public void givenFirstNameSubstring_whenGettingListOfUsers_thenCorrect() { - final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("firstName", SearchOperation.CONTAINS, "oh")); - final List results = repository.findAll(spec); - - assertThat(userJohn, isIn(results)); - assertThat(userTom, not(isIn(results))); - } - - @Test - public void givenAgeRange_whenGettingListOfUsers_thenCorrect() { - final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("age", SearchOperation.GREATER_THAN, "20")); - final UserSpecification spec1 = new UserSpecification(new SpecSearchCriteria("age", SearchOperation.LESS_THAN, "25")); - final List results = repository.findAll(Specification - .where(spec) - .and(spec1)); - - assertThat(userJohn, isIn(results)); - assertThat(userTom, not(isIn(results))); - } -} +package com.baeldung.persistence.query; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.jpa.domain.Specification; +import org.springframework.test.annotation.Rollback; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.transaction.annotation.Transactional; + +import com.baeldung.persistence.dao.GenericSpecificationsBuilder; +import com.baeldung.persistence.dao.UserRepository; +import com.baeldung.persistence.dao.UserSpecification; +import com.baeldung.persistence.dao.UserSpecificationsBuilder; +import com.baeldung.persistence.model.User; +import com.baeldung.spring.PersistenceConfig; +import com.baeldung.web.util.CriteriaParser; +import com.baeldung.web.util.SearchOperation; +import com.baeldung.web.util.SpecSearchCriteria; + +import java.util.List; +import java.util.function.Function; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsCollectionWithSize.hasSize; +import static org.hamcrest.collection.IsIn.isIn; +import static org.hamcrest.core.IsNot.not; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }) +@Transactional +@Rollback +public class JPASpecificationIntegrationTest { + + @Autowired + private UserRepository repository; + + private User userJohn; + + private User userTom; + + private User userPercy; + + @Before + public void init() { + userJohn = new User(); + userJohn.setFirstName("john"); + userJohn.setLastName("doe"); + userJohn.setEmail("john@doe.com"); + userJohn.setAge(22); + repository.save(userJohn); + + userTom = new User(); + userTom.setFirstName("tom"); + userTom.setLastName("doe"); + userTom.setEmail("tom@doe.com"); + userTom.setAge(26); + repository.save(userTom); + + userPercy = new User(); + userPercy.setFirstName("percy"); + userPercy.setLastName("blackney"); + userPercy.setEmail("percy@blackney.com"); + userPercy.setAge(30); + repository.save(userPercy); + } + + @Test + public void givenFirstAndLastName_whenGettingListOfUsers_thenCorrect() { + final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("firstName", SearchOperation.EQUALITY, "john")); + final UserSpecification spec1 = new UserSpecification(new SpecSearchCriteria("lastName", SearchOperation.EQUALITY, "doe")); + final List results = repository.findAll(Specification + .where(spec) + .and(spec1)); + + assertThat(userJohn, isIn(results)); + assertThat(userTom, not(isIn(results))); + } + + @Test + public void givenFirstOrLastName_whenGettingListOfUsers_thenCorrect() { + UserSpecificationsBuilder builder = new UserSpecificationsBuilder(); + + SpecSearchCriteria spec = new SpecSearchCriteria("firstName", SearchOperation.EQUALITY, "john"); + SpecSearchCriteria spec1 = new SpecSearchCriteria("'","lastName", SearchOperation.EQUALITY, "doe"); + + List results = repository.findAll(builder + .with(spec) + .with(spec1) + .build()); + + assertThat(results, hasSize(2)); + assertThat(userJohn, isIn(results)); + assertThat(userTom, isIn(results)); + } + + @Test + public void givenFirstOrLastNameAndAgeGenericBuilder_whenGettingListOfUsers_thenCorrect() { + GenericSpecificationsBuilder builder = new GenericSpecificationsBuilder<>(); + Function> converter = UserSpecification::new; + + CriteriaParser parser=new CriteriaParser(); + List results = repository.findAll(builder.build(parser.parse("( lastName:doe OR firstName:john ) AND age:22"), converter)); + + assertThat(results, hasSize(1)); + assertThat(userJohn, isIn(results)); + assertThat(userTom, not(isIn(results))); + } + + @Test + public void givenFirstOrLastNameGenericBuilder_whenGettingListOfUsers_thenCorrect() { + GenericSpecificationsBuilder builder = new GenericSpecificationsBuilder<>(); + Function> converter = UserSpecification::new; + + builder.with("firstName", ":", "john", null, null); + builder.with("'", "lastName", ":", "doe", null, null); + + List results = repository.findAll(builder.build(converter)); + + assertThat(results, hasSize(2)); + assertThat(userJohn, isIn(results)); + assertThat(userTom, isIn(results)); + } + + @Test + public void givenFirstNameInverse_whenGettingListOfUsers_thenCorrect() { + final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("firstName", SearchOperation.NEGATION, "john")); + final List results = repository.findAll(Specification.where(spec)); + + assertThat(userTom, isIn(results)); + assertThat(userJohn, not(isIn(results))); + } + + @Test + public void givenMinAge_whenGettingListOfUsers_thenCorrect() { + final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("age", SearchOperation.GREATER_THAN, "25")); + final List results = repository.findAll(Specification.where(spec)); + assertThat(userTom, isIn(results)); + assertThat(userJohn, not(isIn(results))); + } + + @Test + public void givenFirstNamePrefix_whenGettingListOfUsers_thenCorrect() { + final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("firstName", SearchOperation.STARTS_WITH, "jo")); + final List results = repository.findAll(spec); + assertThat(userJohn, isIn(results)); + assertThat(userTom, not(isIn(results))); + } + + @Test + public void givenFirstNameSuffix_whenGettingListOfUsers_thenCorrect() { + final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("firstName", SearchOperation.ENDS_WITH, "n")); + final List results = repository.findAll(spec); + assertThat(userJohn, isIn(results)); + assertThat(userTom, not(isIn(results))); + } + + @Test + public void givenFirstNameSubstring_whenGettingListOfUsers_thenCorrect() { + final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("firstName", SearchOperation.CONTAINS, "oh")); + final List results = repository.findAll(spec); + + assertThat(userJohn, isIn(results)); + assertThat(userTom, not(isIn(results))); + } + + @Test + public void givenAgeRange_whenGettingListOfUsers_thenCorrect() { + final UserSpecification spec = new UserSpecification(new SpecSearchCriteria("age", SearchOperation.GREATER_THAN, "20")); + final UserSpecification spec1 = new UserSpecification(new SpecSearchCriteria("age", SearchOperation.LESS_THAN, "25")); + final List results = repository.findAll(Specification + .where(spec) + .and(spec1)); + + assertThat(userJohn, isIn(results)); + assertThat(userTom, not(isIn(results))); + } +} diff --git a/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationLiveTest.java b/spring-web-modules/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationLiveTest.java similarity index 97% rename from spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationLiveTest.java rename to spring-web-modules/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationLiveTest.java index ad6a4259e7..d1fded3f10 100644 --- a/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationLiveTest.java +++ b/spring-web-modules/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/JPASpecificationLiveTest.java @@ -1,147 +1,147 @@ -package com.baeldung.persistence.query; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import io.restassured.RestAssured; -import io.restassured.response.Response; - -import org.junit.Before; -import org.junit.Test; -import org.springframework.test.context.ActiveProfiles; - -import com.baeldung.persistence.model.User; - -//@RunWith(SpringJUnit4ClassRunner.class) -//@ContextConfiguration(classes = { ConfigTest.class, -// PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) -@ActiveProfiles("test") -public class JPASpecificationLiveTest { - - // @Autowired - // private UserRepository repository; - - private User userJohn; - - private User userTom; - - private final String URL_PREFIX = "http://localhost:8082/spring-rest-query-language/auth/users/spec?search="; - - @Before - public void init() { - userJohn = new User(); - userJohn.setFirstName("john"); - userJohn.setLastName("doe"); - userJohn.setEmail("john@doe.com"); - userJohn.setAge(22); - // repository.save(userJohn); - - userTom = new User(); - userTom.setFirstName("tom"); - userTom.setLastName("doe"); - userTom.setEmail("tom@doe.com"); - userTom.setAge(26); - // repository.save(userTom); - } - - private final String EURL_PREFIX = "http://localhost:8082/spring-rest-query-language/auth/users/espec?search="; - - @Test - public void givenFirstOrLastName_whenGettingListOfUsers_thenCorrect() { - final Response response = RestAssured.get(EURL_PREFIX + "firstName:john,'lastName:doe"); - final String result = response.body() - .asString(); - assertTrue(result.contains(userJohn.getEmail())); - assertTrue(result.contains(userTom.getEmail())); - } - - @Test - public void givenFirstAndLastName_whenGettingListOfUsers_thenCorrect() { - final Response response = RestAssured.get(URL_PREFIX + "firstName:john,lastName:doe"); - final String result = response.body() - .asString(); - - assertTrue(result.contains(userJohn.getEmail())); - assertFalse(result.contains(userTom.getEmail())); - } - - @Test - public void givenFirstNameInverse_whenGettingListOfUsers_thenCorrect() { - final Response response = RestAssured.get(URL_PREFIX + "firstName!john"); - final String result = response.body() - .asString(); - - assertTrue(result.contains(userTom.getEmail())); - assertFalse(result.contains(userJohn.getEmail())); - } - - @Test - public void givenMinAge_whenGettingListOfUsers_thenCorrect() { - final Response response = RestAssured.get(URL_PREFIX + "age>25"); - final String result = response.body() - .asString(); - - assertTrue(result.contains(userTom.getEmail())); - assertFalse(result.contains(userJohn.getEmail())); - } - - @Test - public void givenFirstNamePrefix_whenGettingListOfUsers_thenCorrect() { - final Response response = RestAssured.get(URL_PREFIX + "firstName:jo*"); - final String result = response.body() - .asString(); - - assertTrue(result.contains(userJohn.getEmail())); - assertFalse(result.contains(userTom.getEmail())); - } - - @Test - public void givenFirstNameSuffix_whenGettingListOfUsers_thenCorrect() { - final Response response = RestAssured.get(URL_PREFIX + "firstName:*n"); - final String result = response.body() - .asString(); - - assertTrue(result.contains(userJohn.getEmail())); - assertFalse(result.contains(userTom.getEmail())); - } - - @Test - public void givenFirstNameSubstring_whenGettingListOfUsers_thenCorrect() { - final Response response = RestAssured.get(URL_PREFIX + "firstName:*oh*"); - final String result = response.body() - .asString(); - - assertTrue(result.contains(userJohn.getEmail())); - assertFalse(result.contains(userTom.getEmail())); - } - - @Test - public void givenAgeRange_whenGettingListOfUsers_thenCorrect() { - final Response response = RestAssured.get(URL_PREFIX + "age>20,age<25"); - final String result = response.body() - .asString(); - - assertTrue(result.contains(userJohn.getEmail())); - assertFalse(result.contains(userTom.getEmail())); - } - - private final String ADV_URL_PREFIX = "http://localhost:8082/spring-rest-query-language/auth/users/spec/adv?search="; - - @Test - public void givenFirstOrLastName_whenGettingAdvListOfUsers_thenCorrect() { - final Response response = RestAssured.get(ADV_URL_PREFIX + "firstName:john OR lastName:doe"); - final String result = response.body() - .asString(); - assertTrue(result.contains(userJohn.getEmail())); - assertTrue(result.contains(userTom.getEmail())); - } - - @Test - public void givenFirstOrFirstNameAndAge_whenGettingAdvListOfUsers_thenCorrect() { - final Response response = RestAssured.get(ADV_URL_PREFIX + "( firstName:john OR firstName:tom ) AND age>22"); - final String result = response.body() - .asString(); - assertFalse(result.contains(userJohn.getEmail())); - assertTrue(result.contains(userTom.getEmail())); - } - -} +package com.baeldung.persistence.query; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import io.restassured.RestAssured; +import io.restassured.response.Response; + +import org.junit.Before; +import org.junit.Test; +import org.springframework.test.context.ActiveProfiles; + +import com.baeldung.persistence.model.User; + +//@RunWith(SpringJUnit4ClassRunner.class) +//@ContextConfiguration(classes = { ConfigTest.class, +// PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +@ActiveProfiles("test") +public class JPASpecificationLiveTest { + + // @Autowired + // private UserRepository repository; + + private User userJohn; + + private User userTom; + + private final String URL_PREFIX = "http://localhost:8082/spring-rest-query-language/auth/users/spec?search="; + + @Before + public void init() { + userJohn = new User(); + userJohn.setFirstName("john"); + userJohn.setLastName("doe"); + userJohn.setEmail("john@doe.com"); + userJohn.setAge(22); + // repository.save(userJohn); + + userTom = new User(); + userTom.setFirstName("tom"); + userTom.setLastName("doe"); + userTom.setEmail("tom@doe.com"); + userTom.setAge(26); + // repository.save(userTom); + } + + private final String EURL_PREFIX = "http://localhost:8082/spring-rest-query-language/auth/users/espec?search="; + + @Test + public void givenFirstOrLastName_whenGettingListOfUsers_thenCorrect() { + final Response response = RestAssured.get(EURL_PREFIX + "firstName:john,'lastName:doe"); + final String result = response.body() + .asString(); + assertTrue(result.contains(userJohn.getEmail())); + assertTrue(result.contains(userTom.getEmail())); + } + + @Test + public void givenFirstAndLastName_whenGettingListOfUsers_thenCorrect() { + final Response response = RestAssured.get(URL_PREFIX + "firstName:john,lastName:doe"); + final String result = response.body() + .asString(); + + assertTrue(result.contains(userJohn.getEmail())); + assertFalse(result.contains(userTom.getEmail())); + } + + @Test + public void givenFirstNameInverse_whenGettingListOfUsers_thenCorrect() { + final Response response = RestAssured.get(URL_PREFIX + "firstName!john"); + final String result = response.body() + .asString(); + + assertTrue(result.contains(userTom.getEmail())); + assertFalse(result.contains(userJohn.getEmail())); + } + + @Test + public void givenMinAge_whenGettingListOfUsers_thenCorrect() { + final Response response = RestAssured.get(URL_PREFIX + "age>25"); + final String result = response.body() + .asString(); + + assertTrue(result.contains(userTom.getEmail())); + assertFalse(result.contains(userJohn.getEmail())); + } + + @Test + public void givenFirstNamePrefix_whenGettingListOfUsers_thenCorrect() { + final Response response = RestAssured.get(URL_PREFIX + "firstName:jo*"); + final String result = response.body() + .asString(); + + assertTrue(result.contains(userJohn.getEmail())); + assertFalse(result.contains(userTom.getEmail())); + } + + @Test + public void givenFirstNameSuffix_whenGettingListOfUsers_thenCorrect() { + final Response response = RestAssured.get(URL_PREFIX + "firstName:*n"); + final String result = response.body() + .asString(); + + assertTrue(result.contains(userJohn.getEmail())); + assertFalse(result.contains(userTom.getEmail())); + } + + @Test + public void givenFirstNameSubstring_whenGettingListOfUsers_thenCorrect() { + final Response response = RestAssured.get(URL_PREFIX + "firstName:*oh*"); + final String result = response.body() + .asString(); + + assertTrue(result.contains(userJohn.getEmail())); + assertFalse(result.contains(userTom.getEmail())); + } + + @Test + public void givenAgeRange_whenGettingListOfUsers_thenCorrect() { + final Response response = RestAssured.get(URL_PREFIX + "age>20,age<25"); + final String result = response.body() + .asString(); + + assertTrue(result.contains(userJohn.getEmail())); + assertFalse(result.contains(userTom.getEmail())); + } + + private final String ADV_URL_PREFIX = "http://localhost:8082/spring-rest-query-language/auth/users/spec/adv?search="; + + @Test + public void givenFirstOrLastName_whenGettingAdvListOfUsers_thenCorrect() { + final Response response = RestAssured.get(ADV_URL_PREFIX + "firstName:john OR lastName:doe"); + final String result = response.body() + .asString(); + assertTrue(result.contains(userJohn.getEmail())); + assertTrue(result.contains(userTom.getEmail())); + } + + @Test + public void givenFirstOrFirstNameAndAge_whenGettingAdvListOfUsers_thenCorrect() { + final Response response = RestAssured.get(ADV_URL_PREFIX + "( firstName:john OR firstName:tom ) AND age>22"); + final String result = response.body() + .asString(); + assertFalse(result.contains(userJohn.getEmail())); + assertTrue(result.contains(userTom.getEmail())); + } + +} diff --git a/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/RsqlIntegrationTest.java b/spring-web-modules/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/RsqlIntegrationTest.java similarity index 100% rename from spring-rest-query-language/src/test/java/com/baeldung/persistence/query/RsqlIntegrationTest.java rename to spring-web-modules/spring-rest-query-language/src/test/java/com/baeldung/persistence/query/RsqlIntegrationTest.java diff --git a/spring-rest-query-language/src/test/java/com/baeldung/web/MyUserLiveTest.java b/spring-web-modules/spring-rest-query-language/src/test/java/com/baeldung/web/MyUserLiveTest.java similarity index 100% rename from spring-rest-query-language/src/test/java/com/baeldung/web/MyUserLiveTest.java rename to spring-web-modules/spring-rest-query-language/src/test/java/com/baeldung/web/MyUserLiveTest.java diff --git a/spring-rest-query-language/src/test/resources/.gitignore b/spring-web-modules/spring-rest-query-language/src/test/resources/.gitignore similarity index 100% rename from spring-rest-query-language/src/test/resources/.gitignore rename to spring-web-modules/spring-rest-query-language/src/test/resources/.gitignore From 6a0313b4db0deecd005308fd39bc2aeb3b91702b Mon Sep 17 00:00:00 2001 From: mikr Date: Wed, 30 Dec 2020 12:34:37 +0100 Subject: [PATCH 181/361] JAVA-3528 Move spring-mvc-velocity module --- pom.xml | 2 -- spring-web-modules/pom.xml | 1 + .../spring-mvc-velocity}/README.md | 0 .../spring-mvc-velocity}/pom.xml | 2 +- .../com/baeldung/mvc/velocity/controller/MainController.java | 0 .../main/java/com/baeldung/mvc/velocity/domain/Tutorial.java | 0 .../com/baeldung/mvc/velocity/service/ITutorialsService.java | 0 .../com/baeldung/mvc/velocity/service/TutorialsService.java | 0 .../mvc/velocity/spring/config/MainWebAppInitializer.java | 0 .../java/com/baeldung/mvc/velocity/spring/config/WebConfig.java | 0 .../spring-mvc-velocity}/src/main/resources/logback.xml | 0 .../src/main/webapp/WEB-INF/fragments/footer.vm | 0 .../src/main/webapp/WEB-INF/fragments/header.vm | 0 .../src/main/webapp/WEB-INF/layouts/layout.vm | 0 .../src/main/webapp/WEB-INF/mvc-servlet.xml | 0 .../src/main/webapp/WEB-INF/spring-context.xml | 0 .../spring-mvc-velocity}/src/main/webapp/WEB-INF/views/index.vm | 0 .../spring-mvc-velocity}/src/main/webapp/WEB-INF/views/list.vm | 0 .../spring-mvc-velocity}/src/main/webapp/WEB-INF/web_old.xml | 0 .../mvc/velocity/test/DataContentControllerIntegrationTest.java | 0 .../java/com/baeldung/mvc/velocity/test/config/TestConfig.java | 0 .../src/test/java/org/baeldung/SpringContextTest.java | 0 .../spring-mvc-velocity}/src/test/resources/mvc-servlet.xml | 0 23 files changed, 2 insertions(+), 3 deletions(-) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/README.md (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/pom.xml (98%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/main/java/com/baeldung/mvc/velocity/controller/MainController.java (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/main/java/com/baeldung/mvc/velocity/domain/Tutorial.java (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/main/java/com/baeldung/mvc/velocity/service/ITutorialsService.java (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/main/java/com/baeldung/mvc/velocity/service/TutorialsService.java (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/main/java/com/baeldung/mvc/velocity/spring/config/MainWebAppInitializer.java (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/main/java/com/baeldung/mvc/velocity/spring/config/WebConfig.java (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/main/resources/logback.xml (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/main/webapp/WEB-INF/fragments/footer.vm (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/main/webapp/WEB-INF/fragments/header.vm (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/main/webapp/WEB-INF/layouts/layout.vm (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/main/webapp/WEB-INF/mvc-servlet.xml (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/main/webapp/WEB-INF/spring-context.xml (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/main/webapp/WEB-INF/views/index.vm (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/main/webapp/WEB-INF/views/list.vm (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/main/webapp/WEB-INF/web_old.xml (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/test/java/com/baeldung/mvc/velocity/test/DataContentControllerIntegrationTest.java (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/test/java/com/baeldung/mvc/velocity/test/config/TestConfig.java (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/test/java/org/baeldung/SpringContextTest.java (100%) rename {spring-mvc-velocity => spring-web-modules/spring-mvc-velocity}/src/test/resources/mvc-servlet.xml (100%) diff --git a/pom.xml b/pom.xml index 79bf7d72b7..228b068fab 100644 --- a/pom.xml +++ b/pom.xml @@ -663,7 +663,6 @@ spring-mvc-java spring-mvc-java-2 - spring-mvc-velocity spring-mvc-views spring-mvc-webflow spring-mvc-xml @@ -1131,7 +1130,6 @@ spring-mvc-java spring-mvc-java-2 - spring-mvc-velocity spring-mvc-views spring-mvc-webflow spring-mvc-xml diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index ce0524f957..382ed99603 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -20,6 +20,7 @@ spring-mvc-basics-4 spring-mvc-crash spring-mvc-forms-jsp + spring-mvc-velocity spring-rest-angular spring-rest-http spring-resttemplate-2 diff --git a/spring-mvc-velocity/README.md b/spring-web-modules/spring-mvc-velocity/README.md similarity index 100% rename from spring-mvc-velocity/README.md rename to spring-web-modules/spring-mvc-velocity/README.md diff --git a/spring-mvc-velocity/pom.xml b/spring-web-modules/spring-mvc-velocity/pom.xml similarity index 98% rename from spring-mvc-velocity/pom.xml rename to spring-web-modules/spring-mvc-velocity/pom.xml index 2269f05fa4..05016962a5 100644 --- a/spring-mvc-velocity/pom.xml +++ b/spring-web-modules/spring-mvc-velocity/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-spring-4 0.0.1-SNAPSHOT - ../parent-spring-4 + ../../parent-spring-4 diff --git a/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/controller/MainController.java b/spring-web-modules/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/controller/MainController.java similarity index 100% rename from spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/controller/MainController.java rename to spring-web-modules/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/controller/MainController.java diff --git a/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/domain/Tutorial.java b/spring-web-modules/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/domain/Tutorial.java similarity index 100% rename from spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/domain/Tutorial.java rename to spring-web-modules/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/domain/Tutorial.java diff --git a/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/service/ITutorialsService.java b/spring-web-modules/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/service/ITutorialsService.java similarity index 100% rename from spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/service/ITutorialsService.java rename to spring-web-modules/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/service/ITutorialsService.java diff --git a/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/service/TutorialsService.java b/spring-web-modules/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/service/TutorialsService.java similarity index 100% rename from spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/service/TutorialsService.java rename to spring-web-modules/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/service/TutorialsService.java diff --git a/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/spring/config/MainWebAppInitializer.java b/spring-web-modules/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/spring/config/MainWebAppInitializer.java similarity index 100% rename from spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/spring/config/MainWebAppInitializer.java rename to spring-web-modules/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/spring/config/MainWebAppInitializer.java diff --git a/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/spring/config/WebConfig.java b/spring-web-modules/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/spring/config/WebConfig.java similarity index 100% rename from spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/spring/config/WebConfig.java rename to spring-web-modules/spring-mvc-velocity/src/main/java/com/baeldung/mvc/velocity/spring/config/WebConfig.java diff --git a/spring-mvc-velocity/src/main/resources/logback.xml b/spring-web-modules/spring-mvc-velocity/src/main/resources/logback.xml similarity index 100% rename from spring-mvc-velocity/src/main/resources/logback.xml rename to spring-web-modules/spring-mvc-velocity/src/main/resources/logback.xml diff --git a/spring-mvc-velocity/src/main/webapp/WEB-INF/fragments/footer.vm b/spring-web-modules/spring-mvc-velocity/src/main/webapp/WEB-INF/fragments/footer.vm similarity index 100% rename from spring-mvc-velocity/src/main/webapp/WEB-INF/fragments/footer.vm rename to spring-web-modules/spring-mvc-velocity/src/main/webapp/WEB-INF/fragments/footer.vm diff --git a/spring-mvc-velocity/src/main/webapp/WEB-INF/fragments/header.vm b/spring-web-modules/spring-mvc-velocity/src/main/webapp/WEB-INF/fragments/header.vm similarity index 100% rename from spring-mvc-velocity/src/main/webapp/WEB-INF/fragments/header.vm rename to spring-web-modules/spring-mvc-velocity/src/main/webapp/WEB-INF/fragments/header.vm diff --git a/spring-mvc-velocity/src/main/webapp/WEB-INF/layouts/layout.vm b/spring-web-modules/spring-mvc-velocity/src/main/webapp/WEB-INF/layouts/layout.vm similarity index 100% rename from spring-mvc-velocity/src/main/webapp/WEB-INF/layouts/layout.vm rename to spring-web-modules/spring-mvc-velocity/src/main/webapp/WEB-INF/layouts/layout.vm diff --git a/spring-mvc-velocity/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-web-modules/spring-mvc-velocity/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-mvc-velocity/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-web-modules/spring-mvc-velocity/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-mvc-velocity/src/main/webapp/WEB-INF/spring-context.xml b/spring-web-modules/spring-mvc-velocity/src/main/webapp/WEB-INF/spring-context.xml similarity index 100% rename from spring-mvc-velocity/src/main/webapp/WEB-INF/spring-context.xml rename to spring-web-modules/spring-mvc-velocity/src/main/webapp/WEB-INF/spring-context.xml diff --git a/spring-mvc-velocity/src/main/webapp/WEB-INF/views/index.vm b/spring-web-modules/spring-mvc-velocity/src/main/webapp/WEB-INF/views/index.vm similarity index 100% rename from spring-mvc-velocity/src/main/webapp/WEB-INF/views/index.vm rename to spring-web-modules/spring-mvc-velocity/src/main/webapp/WEB-INF/views/index.vm diff --git a/spring-mvc-velocity/src/main/webapp/WEB-INF/views/list.vm b/spring-web-modules/spring-mvc-velocity/src/main/webapp/WEB-INF/views/list.vm similarity index 100% rename from spring-mvc-velocity/src/main/webapp/WEB-INF/views/list.vm rename to spring-web-modules/spring-mvc-velocity/src/main/webapp/WEB-INF/views/list.vm diff --git a/spring-mvc-velocity/src/main/webapp/WEB-INF/web_old.xml b/spring-web-modules/spring-mvc-velocity/src/main/webapp/WEB-INF/web_old.xml similarity index 100% rename from spring-mvc-velocity/src/main/webapp/WEB-INF/web_old.xml rename to spring-web-modules/spring-mvc-velocity/src/main/webapp/WEB-INF/web_old.xml diff --git a/spring-mvc-velocity/src/test/java/com/baeldung/mvc/velocity/test/DataContentControllerIntegrationTest.java b/spring-web-modules/spring-mvc-velocity/src/test/java/com/baeldung/mvc/velocity/test/DataContentControllerIntegrationTest.java similarity index 100% rename from spring-mvc-velocity/src/test/java/com/baeldung/mvc/velocity/test/DataContentControllerIntegrationTest.java rename to spring-web-modules/spring-mvc-velocity/src/test/java/com/baeldung/mvc/velocity/test/DataContentControllerIntegrationTest.java diff --git a/spring-mvc-velocity/src/test/java/com/baeldung/mvc/velocity/test/config/TestConfig.java b/spring-web-modules/spring-mvc-velocity/src/test/java/com/baeldung/mvc/velocity/test/config/TestConfig.java similarity index 100% rename from spring-mvc-velocity/src/test/java/com/baeldung/mvc/velocity/test/config/TestConfig.java rename to spring-web-modules/spring-mvc-velocity/src/test/java/com/baeldung/mvc/velocity/test/config/TestConfig.java diff --git a/spring-mvc-velocity/src/test/java/org/baeldung/SpringContextTest.java b/spring-web-modules/spring-mvc-velocity/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-mvc-velocity/src/test/java/org/baeldung/SpringContextTest.java rename to spring-web-modules/spring-mvc-velocity/src/test/java/org/baeldung/SpringContextTest.java diff --git a/spring-mvc-velocity/src/test/resources/mvc-servlet.xml b/spring-web-modules/spring-mvc-velocity/src/test/resources/mvc-servlet.xml similarity index 100% rename from spring-mvc-velocity/src/test/resources/mvc-servlet.xml rename to spring-web-modules/spring-mvc-velocity/src/test/resources/mvc-servlet.xml From 078169109d789fd0a96cc5401485117f60f120bb Mon Sep 17 00:00:00 2001 From: kwoyke Date: Wed, 30 Dec 2020 12:39:45 +0100 Subject: [PATCH 182/361] BAEL-4755: Add Files.list example (#10356) --- .../main/java/com/baeldung/listfiles/ListFiles.java | 13 ++++++++++++- .../com/baeldung/listfiles/ListFilesUnitTest.java | 7 ++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/core-java-modules/core-java-io-2/src/main/java/com/baeldung/listfiles/ListFiles.java b/core-java-modules/core-java-io-2/src/main/java/com/baeldung/listfiles/ListFiles.java index 2275128dfe..c108d9ed96 100644 --- a/core-java-modules/core-java-io-2/src/main/java/com/baeldung/listfiles/ListFiles.java +++ b/core-java-modules/core-java-io-2/src/main/java/com/baeldung/listfiles/ListFiles.java @@ -24,9 +24,20 @@ public class ListFiles { .collect(Collectors.toSet()); } + public Set listFilesUsingFilesList(String dir) throws IOException { + try (Stream stream = Files.list(Paths.get(dir))) { + return stream + .filter(file -> !Files.isDirectory(file)) + .map(Path::getFileName) + .map(Path::toString) + .collect(Collectors.toSet()); + } + } + public Set listFilesUsingFileWalk(String dir, int depth) throws IOException { try (Stream stream = Files.walk(Paths.get(dir), depth)) { - return stream.filter(file -> !Files.isDirectory(file)) + return stream + .filter(file -> !Files.isDirectory(file)) .map(Path::getFileName) .map(Path::toString) .collect(Collectors.toSet()); diff --git a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/listfiles/ListFilesUnitTest.java b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/listfiles/ListFilesUnitTest.java index a87097f085..5b4efc9e58 100644 --- a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/listfiles/ListFilesUnitTest.java +++ b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/listfiles/ListFilesUnitTest.java @@ -25,10 +25,15 @@ public class ListFilesUnitTest { }; @Test - public void givenDir_whenUsingJAVAIO_thenListAllFiles() throws IOException { + public void givenDir_whenUsingJAVAIO_thenListAllFiles() { assertEquals(EXPECTED_FILE_LIST, listFiles.listFilesUsingJavaIO(DIRECTORY)); } + @Test + public void givenDir_whenUsingFilesList_thenListAllFiles() throws IOException { + assertEquals(EXPECTED_FILE_LIST, listFiles.listFilesUsingFilesList(DIRECTORY)); + } + @Test public void givenDir_whenWalkingTree_thenListAllFiles() throws IOException { assertEquals(EXPECTED_FILE_LIST, listFiles.listFilesUsingFileWalk(DIRECTORY,DEPTH)); From ad461edca2298ebe3e7d93b14480958404b157b5 Mon Sep 17 00:00:00 2001 From: mikr Date: Wed, 30 Dec 2020 21:46:25 +0100 Subject: [PATCH 183/361] JAVA-2824 Fix tests in Java 9 and above modules --- .../java9/process/OutputStreamExample.java | 3 +-- .../process/ProcessUnderstandingUnitTest.java | 19 ++++++++++++++++++- .../screenshot/ScreenshotUnitTest.java | 5 +++-- .../baeldung/time/LocalDateTimeUnitTest.java | 9 --------- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/OutputStreamExample.java b/core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/OutputStreamExample.java index 37378f9d6c..fc6d907bfd 100644 --- a/core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/OutputStreamExample.java +++ b/core-java-modules/core-java-os/src/main/java/com/baeldung/java9/process/OutputStreamExample.java @@ -6,8 +6,7 @@ import java.util.logging.Logger; public class OutputStreamExample { public static void main(String[] args) { - Logger log = Logger.getLogger(OutputStreamExample.class.getName()); - log.log(Level.INFO, Integer.toString(sum(1,2))); + System.out.println(sum(1,2)); } public static int sum(int a, int b) { diff --git a/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessUnderstandingUnitTest.java b/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessUnderstandingUnitTest.java index c8932efb4f..69b65852cc 100644 --- a/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessUnderstandingUnitTest.java +++ b/core-java-modules/core-java-os/src/test/java/com/baeldung/java9/process/ProcessUnderstandingUnitTest.java @@ -5,10 +5,10 @@ import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.*; import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.lang.String; -import java.util.Optional; import java.util.concurrent.TimeUnit; import java.lang.Integer; @@ -88,4 +88,21 @@ class ProcessUnderstandingUnitTest { .filter(ph -> (ph.pid() > 10000 && ph.pid() < 50000)) .count()) > 0); } + + @Test + public void givenSourceProgram_whenReadingInputStream_thenFirstLineEquals3() throws IOException { + + Runtime.getRuntime() + .exec("javac -cp src src/main/java/com/baeldung/java9/process/OutputStreamExample.java" + .replace("/", File.separator)); + + Process process = Runtime.getRuntime() + .exec("java -cp src/main/java com.baeldung.java9.process.OutputStreamExample" + .replace("/", File.separator)); + + BufferedReader output = new BufferedReader(new InputStreamReader(process.getInputStream())); + int value = Integer.parseInt(output.readLine()); + + assertEquals(3, value); + } } diff --git a/core-java-modules/core-java-os/src/test/java/com/baeldung/screenshot/ScreenshotUnitTest.java b/core-java-modules/core-java-os/src/test/java/com/baeldung/screenshot/ScreenshotUnitTest.java index ac358b4e71..bf271ef2cc 100644 --- a/core-java-modules/core-java-os/src/test/java/com/baeldung/screenshot/ScreenshotUnitTest.java +++ b/core-java-modules/core-java-os/src/test/java/com/baeldung/screenshot/ScreenshotUnitTest.java @@ -9,11 +9,13 @@ import java.awt.Robot; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.io.File; + +import org.junit.Ignore; import org.junit.Test; -import org.junit.jupiter.api.Disabled; import static org.junit.Assert.assertTrue; +@Ignore public class ScreenshotUnitTest { @Test @@ -43,7 +45,6 @@ public class ScreenshotUnitTest { // This methods needs a component as a parameter and can only be run from an application with a GUI @Test - @Disabled public void givenComponent_whenTakeScreenshot_thenSaveToFile(Component component) throws Exception { Rectangle componentRect = component.getBounds(); BufferedImage bufferedImage = new BufferedImage(componentRect.width, componentRect.height, BufferedImage.TYPE_INT_ARGB); diff --git a/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java b/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java index 1611a3002f..52dc9ba1c6 100644 --- a/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java +++ b/core-java-modules/core-java-time-measurements/src/test/java/com/baeldung/time/LocalDateTimeUnitTest.java @@ -18,15 +18,6 @@ import static org.powermock.api.mockito.PowerMockito.mockStatic; @PrepareForTest({ LocalDateTime.class }) public class LocalDateTimeUnitTest { - @Test - public void givenLocalDateTimeMock_whenNow_thenGetFixedLocalDateTime() { - Clock clock = Clock.fixed(Instant.parse("2014-12-22T10:15:30.00Z"), ZoneId.of("UTC")); - String dateTimeExpected = "2014-12-22T10:15:30"; - LocalDateTime now = LocalDateTime.now(clock); - - assertThat(now).isEqualTo(dateTimeExpected); - } - @Test public void givenFixedClock_whenNow_thenGetFixedLocalDateTime() { Clock clock = Clock.fixed(Instant.parse("2014-12-22T10:15:30.00Z"), ZoneId.of("UTC")); From de5f9940dd5d4226b16b10afae3d16a21ba1e670 Mon Sep 17 00:00:00 2001 From: mikr Date: Wed, 30 Dec 2020 22:26:14 +0100 Subject: [PATCH 184/361] JAVA-3531 Move spring-mvc-xml module --- pom.xml | 2 - .../src/main/resources/messages.properties | 2 - spring-web-modules/pom.xml | 1 + .../spring-mvc-xml}/.gitignore | 0 .../spring-mvc-xml}/README.md | 0 .../spring-mvc-xml}/pom.xml | 0 .../java/com/baeldung/jsp/ExampleOne.java | 0 .../java/com/baeldung/jsp/ExampleThree.java | 0 .../com/baeldung/spring/ClientWebConfig.java | 0 .../baeldung/spring/ClientWebConfigJava.java | 0 .../ConstraintViolationExceptionHandler.java | 0 .../spring/controller/ErrorController.java | 0 .../controller/GeoIPTestController.java | 0 .../spring/controller/GreetingController.java | 0 .../spring/controller/HelloController.java | 0 .../controller/HelloGuestController.java | 0 .../controller/HelloWorldController.java | 0 .../spring/controller/ImageController.java | 122 +++++++++--------- .../spring/controller/PersonController.java | 0 ...stAndPathVariableValidationController.java | 0 .../spring/controller/WelcomeController.java | 0 .../java/com/baeldung/spring/form/GeoIP.java | 0 .../java/com/baeldung/spring/form/Person.java | 0 .../RawDBDemoGeoIPLocationService.java | 0 .../spring/validator/PersonValidator.java | 42 +++--- .../contentManagementWebMvcConfig.xml | 0 .../src/main/resources/logback.xml | 0 .../src/main/resources/messages.properties | 2 + .../src/main/resources/webMvcConfig.xml | 0 .../src/main/webapp/GeoIpTest.jsp | 0 .../WEB-INF/crash/commands/message.groovy | 0 .../WEB-INF/crash/commands/message2.java | 0 .../webapp/WEB-INF/crash/crash.properties | 0 .../webapp/WEB-INF/crash/telnet.properties | 0 .../webapp/WEB-INF/images/image-example.jpg | Bin .../src/main/webapp/WEB-INF/mvc-servlet.xml | 0 .../src/main/webapp/WEB-INF/view/error.jsp | 0 .../main/webapp/WEB-INF/view/errorPage.jsp | 0 .../src/main/webapp/WEB-INF/view/greeting.jsp | 0 .../src/main/webapp/WEB-INF/view/hello.jsp | 0 .../main/webapp/WEB-INF/view/helloworld.jsp | 0 .../webapp/WEB-INF/view/image-download.jsp | 0 .../main/webapp/WEB-INF/view/personForm.jsp | 0 .../main/webapp/WEB-INF/view/personView.jsp | 0 .../src/main/webapp/WEB-INF/view/sample.jsp | 0 .../src/main/webapp/WEB-INF/view/welcome.jsp | 0 .../src/main/webapp/WEB-INF/web.xml | 0 .../spring-mvc-xml}/src/main/webapp/index.jsp | 0 .../src/main/webapp/jsp/ExampleThree.jsp | 0 .../src/main/webapp/jsp/ExampleTwo.jsp | 0 .../src/main/webapp/jsp/index.jsp | 0 .../src/main/webapp/spring-handler-index.jsp | 0 .../baeldung/geoip/GeoIpIntegrationTest.java | 0 ...leValidationControllerIntegrationTest.java | 0 .../java/org/baeldung/SpringContextTest.java | 2 +- 55 files changed, 86 insertions(+), 87 deletions(-) delete mode 100644 spring-mvc-xml/src/main/resources/messages.properties rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/.gitignore (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/README.md (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/pom.xml (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/jsp/ExampleOne.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/jsp/ExampleThree.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/ClientWebConfig.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/ClientWebConfigJava.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/controller/ConstraintViolationExceptionHandler.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/controller/ErrorController.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/controller/GeoIPTestController.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/controller/GreetingController.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/controller/HelloController.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/controller/HelloGuestController.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/controller/HelloWorldController.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/controller/ImageController.java (97%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/controller/PersonController.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/controller/RequestAndPathVariableValidationController.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/controller/WelcomeController.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/form/GeoIP.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/form/Person.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/service/RawDBDemoGeoIPLocationService.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/java/com/baeldung/spring/validator/PersonValidator.java (96%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/resources/contentManagementWebMvcConfig.xml (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/resources/logback.xml (100%) create mode 100644 spring-web-modules/spring-mvc-xml/src/main/resources/messages.properties rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/resources/webMvcConfig.xml (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/GeoIpTest.jsp (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/crash/commands/message.groovy (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/crash/commands/message2.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/crash/crash.properties (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/crash/telnet.properties (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/images/image-example.jpg (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/mvc-servlet.xml (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/view/error.jsp (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/view/errorPage.jsp (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/view/greeting.jsp (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/view/hello.jsp (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/view/helloworld.jsp (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/view/image-download.jsp (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/view/personForm.jsp (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/view/personView.jsp (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/view/sample.jsp (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/view/welcome.jsp (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/WEB-INF/web.xml (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/index.jsp (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/jsp/ExampleThree.jsp (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/jsp/ExampleTwo.jsp (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/jsp/index.jsp (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/main/webapp/spring-handler-index.jsp (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/test/java/com/baeldung/geoip/GeoIpIntegrationTest.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/test/java/com/baeldung/spring/controller/RequestAndPathVariableValidationControllerIntegrationTest.java (100%) rename {spring-mvc-xml => spring-web-modules/spring-mvc-xml}/src/test/java/org/baeldung/SpringContextTest.java (96%) diff --git a/pom.xml b/pom.xml index 67fa58293b..352d61660d 100644 --- a/pom.xml +++ b/pom.xml @@ -664,7 +664,6 @@ spring-mvc-java-2 spring-mvc-velocity - spring-mvc-xml spring-protobuf spring-quartz @@ -1130,7 +1129,6 @@ spring-mvc-java-2 spring-mvc-velocity - spring-mvc-xml spring-protobuf spring-quartz diff --git a/spring-mvc-xml/src/main/resources/messages.properties b/spring-mvc-xml/src/main/resources/messages.properties deleted file mode 100644 index 2a3cccf76c..0000000000 --- a/spring-mvc-xml/src/main/resources/messages.properties +++ /dev/null @@ -1,2 +0,0 @@ -required.name = Name is required! -NotEmpty.person.password = Password is required! \ No newline at end of file diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index c28ffbeab8..d9e7e8012d 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -22,6 +22,7 @@ spring-mvc-forms-jsp spring-mvc-views spring-mvc-webflow + spring-mvc-xml spring-rest-angular spring-rest-http spring-resttemplate-2 diff --git a/spring-mvc-xml/.gitignore b/spring-web-modules/spring-mvc-xml/.gitignore similarity index 100% rename from spring-mvc-xml/.gitignore rename to spring-web-modules/spring-mvc-xml/.gitignore diff --git a/spring-mvc-xml/README.md b/spring-web-modules/spring-mvc-xml/README.md similarity index 100% rename from spring-mvc-xml/README.md rename to spring-web-modules/spring-mvc-xml/README.md diff --git a/spring-mvc-xml/pom.xml b/spring-web-modules/spring-mvc-xml/pom.xml similarity index 100% rename from spring-mvc-xml/pom.xml rename to spring-web-modules/spring-mvc-xml/pom.xml diff --git a/spring-mvc-xml/src/main/java/com/baeldung/jsp/ExampleOne.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/jsp/ExampleOne.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/jsp/ExampleOne.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/jsp/ExampleOne.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/jsp/ExampleThree.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/jsp/ExampleThree.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/jsp/ExampleThree.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/jsp/ExampleThree.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/ClientWebConfig.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/ClientWebConfig.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/ClientWebConfig.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/ClientWebConfig.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/ClientWebConfigJava.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/ClientWebConfigJava.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/ClientWebConfigJava.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/ClientWebConfigJava.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ConstraintViolationExceptionHandler.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ConstraintViolationExceptionHandler.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ConstraintViolationExceptionHandler.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ConstraintViolationExceptionHandler.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ErrorController.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ErrorController.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ErrorController.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ErrorController.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/GeoIPTestController.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/GeoIPTestController.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/controller/GeoIPTestController.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/GeoIPTestController.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/GreetingController.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/GreetingController.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/controller/GreetingController.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/GreetingController.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/HelloController.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/HelloController.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/controller/HelloController.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/HelloController.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/HelloGuestController.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/HelloGuestController.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/controller/HelloGuestController.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/HelloGuestController.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/HelloWorldController.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/HelloWorldController.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/controller/HelloWorldController.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/HelloWorldController.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ImageController.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ImageController.java similarity index 97% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ImageController.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ImageController.java index fc46c07e06..c02e76d4c0 100644 --- a/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ImageController.java +++ b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/ImageController.java @@ -1,61 +1,61 @@ -package com.baeldung.spring.controller; - -import org.apache.commons.io.IOUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.Resource; -import org.springframework.http.*; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.context.support.ServletContextResource; - -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.InputStream; - -@Controller -public class ImageController { - - @Autowired - private ServletContext servletContext; - - @RequestMapping(value = "/image-view", method = RequestMethod.GET) - public String imageView() throws IOException { - return "image-download"; - } - - @RequestMapping(value = "/image-manual-response", method = RequestMethod.GET) - public void getImageAsByteArray(HttpServletResponse response) throws IOException { - final InputStream in = servletContext.getResourceAsStream("/WEB-INF/images/image-example.jpg"); - response.setContentType(MediaType.IMAGE_JPEG_VALUE); - IOUtils.copy(in, response.getOutputStream()); - } - - @RequestMapping(value = "/image-byte-array", method = RequestMethod.GET) - @ResponseBody - public byte[] getImageAsByteArray() throws IOException { - final InputStream in = servletContext.getResourceAsStream("/WEB-INF/images/image-example.jpg"); - return IOUtils.toByteArray(in); - } - - @RequestMapping(value = "/image-response-entity", method = RequestMethod.GET) - public ResponseEntity getImageAsResponseEntity() throws IOException { - ResponseEntity responseEntity; - final HttpHeaders headers = new HttpHeaders(); - final InputStream in = servletContext.getResourceAsStream("/WEB-INF/images/image-example.jpg"); - byte[] media = IOUtils.toByteArray(in); - headers.setCacheControl(CacheControl.noCache().getHeaderValue()); - responseEntity = new ResponseEntity<>(media, headers, HttpStatus.OK); - return responseEntity; - } - - @RequestMapping(value = "/image-resource", method = RequestMethod.GET) - @ResponseBody - public ResponseEntity getImageAsResource() { - final HttpHeaders headers = new HttpHeaders(); - Resource resource = new ServletContextResource(servletContext, "/WEB-INF/images/image-example.jpg"); - return new ResponseEntity<>(resource, headers, HttpStatus.OK); - } -} +package com.baeldung.spring.controller; + +import org.apache.commons.io.IOUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.Resource; +import org.springframework.http.*; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.context.support.ServletContextResource; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; + +@Controller +public class ImageController { + + @Autowired + private ServletContext servletContext; + + @RequestMapping(value = "/image-view", method = RequestMethod.GET) + public String imageView() throws IOException { + return "image-download"; + } + + @RequestMapping(value = "/image-manual-response", method = RequestMethod.GET) + public void getImageAsByteArray(HttpServletResponse response) throws IOException { + final InputStream in = servletContext.getResourceAsStream("/WEB-INF/images/image-example.jpg"); + response.setContentType(MediaType.IMAGE_JPEG_VALUE); + IOUtils.copy(in, response.getOutputStream()); + } + + @RequestMapping(value = "/image-byte-array", method = RequestMethod.GET) + @ResponseBody + public byte[] getImageAsByteArray() throws IOException { + final InputStream in = servletContext.getResourceAsStream("/WEB-INF/images/image-example.jpg"); + return IOUtils.toByteArray(in); + } + + @RequestMapping(value = "/image-response-entity", method = RequestMethod.GET) + public ResponseEntity getImageAsResponseEntity() throws IOException { + ResponseEntity responseEntity; + final HttpHeaders headers = new HttpHeaders(); + final InputStream in = servletContext.getResourceAsStream("/WEB-INF/images/image-example.jpg"); + byte[] media = IOUtils.toByteArray(in); + headers.setCacheControl(CacheControl.noCache().getHeaderValue()); + responseEntity = new ResponseEntity<>(media, headers, HttpStatus.OK); + return responseEntity; + } + + @RequestMapping(value = "/image-resource", method = RequestMethod.GET) + @ResponseBody + public ResponseEntity getImageAsResource() { + final HttpHeaders headers = new HttpHeaders(); + Resource resource = new ServletContextResource(servletContext, "/WEB-INF/images/image-example.jpg"); + return new ResponseEntity<>(resource, headers, HttpStatus.OK); + } +} diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/PersonController.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/PersonController.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/controller/PersonController.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/PersonController.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/RequestAndPathVariableValidationController.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/RequestAndPathVariableValidationController.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/controller/RequestAndPathVariableValidationController.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/RequestAndPathVariableValidationController.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/WelcomeController.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/WelcomeController.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/controller/WelcomeController.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/controller/WelcomeController.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/form/GeoIP.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/form/GeoIP.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/form/GeoIP.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/form/GeoIP.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/form/Person.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/form/Person.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/form/Person.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/form/Person.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/service/RawDBDemoGeoIPLocationService.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/service/RawDBDemoGeoIPLocationService.java similarity index 100% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/service/RawDBDemoGeoIPLocationService.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/service/RawDBDemoGeoIPLocationService.java diff --git a/spring-mvc-xml/src/main/java/com/baeldung/spring/validator/PersonValidator.java b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/validator/PersonValidator.java similarity index 96% rename from spring-mvc-xml/src/main/java/com/baeldung/spring/validator/PersonValidator.java rename to spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/validator/PersonValidator.java index f7625bacd9..cda756cdfc 100644 --- a/spring-mvc-xml/src/main/java/com/baeldung/spring/validator/PersonValidator.java +++ b/spring-web-modules/spring-mvc-xml/src/main/java/com/baeldung/spring/validator/PersonValidator.java @@ -1,22 +1,22 @@ -package com.baeldung.spring.validator; - -import com.baeldung.spring.form.Person; -import org.springframework.stereotype.Component; -import org.springframework.validation.Errors; -import org.springframework.validation.ValidationUtils; -import org.springframework.validation.Validator; - -@Component -public class PersonValidator implements Validator { - - @Override - public boolean supports(final Class calzz) { - return Person.class.isAssignableFrom(calzz); - } - - @Override - public void validate(final Object obj, final Errors errors) { - - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "required.name"); - } +package com.baeldung.spring.validator; + +import com.baeldung.spring.form.Person; +import org.springframework.stereotype.Component; +import org.springframework.validation.Errors; +import org.springframework.validation.ValidationUtils; +import org.springframework.validation.Validator; + +@Component +public class PersonValidator implements Validator { + + @Override + public boolean supports(final Class calzz) { + return Person.class.isAssignableFrom(calzz); + } + + @Override + public void validate(final Object obj, final Errors errors) { + + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "required.name"); + } } \ No newline at end of file diff --git a/spring-mvc-xml/src/main/resources/contentManagementWebMvcConfig.xml b/spring-web-modules/spring-mvc-xml/src/main/resources/contentManagementWebMvcConfig.xml similarity index 100% rename from spring-mvc-xml/src/main/resources/contentManagementWebMvcConfig.xml rename to spring-web-modules/spring-mvc-xml/src/main/resources/contentManagementWebMvcConfig.xml diff --git a/spring-mvc-xml/src/main/resources/logback.xml b/spring-web-modules/spring-mvc-xml/src/main/resources/logback.xml similarity index 100% rename from spring-mvc-xml/src/main/resources/logback.xml rename to spring-web-modules/spring-mvc-xml/src/main/resources/logback.xml diff --git a/spring-web-modules/spring-mvc-xml/src/main/resources/messages.properties b/spring-web-modules/spring-mvc-xml/src/main/resources/messages.properties new file mode 100644 index 0000000000..8d886c8449 --- /dev/null +++ b/spring-web-modules/spring-mvc-xml/src/main/resources/messages.properties @@ -0,0 +1,2 @@ +required.name = Name is required! +NotEmpty.person.password = Password is required! \ No newline at end of file diff --git a/spring-mvc-xml/src/main/resources/webMvcConfig.xml b/spring-web-modules/spring-mvc-xml/src/main/resources/webMvcConfig.xml similarity index 100% rename from spring-mvc-xml/src/main/resources/webMvcConfig.xml rename to spring-web-modules/spring-mvc-xml/src/main/resources/webMvcConfig.xml diff --git a/spring-mvc-xml/src/main/webapp/GeoIpTest.jsp b/spring-web-modules/spring-mvc-xml/src/main/webapp/GeoIpTest.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/GeoIpTest.jsp rename to spring-web-modules/spring-mvc-xml/src/main/webapp/GeoIpTest.jsp diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/crash/commands/message.groovy b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/crash/commands/message.groovy similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/crash/commands/message.groovy rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/crash/commands/message.groovy diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/crash/commands/message2.java b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/crash/commands/message2.java similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/crash/commands/message2.java rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/crash/commands/message2.java diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/crash/crash.properties b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/crash/crash.properties similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/crash/crash.properties rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/crash/crash.properties diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/crash/telnet.properties b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/crash/telnet.properties similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/crash/telnet.properties rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/crash/telnet.properties diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/images/image-example.jpg b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/images/image-example.jpg similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/images/image-example.jpg rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/images/image-example.jpg diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/mvc-servlet.xml diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/error.jsp b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/error.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/view/error.jsp rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/error.jsp diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/errorPage.jsp b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/errorPage.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/view/errorPage.jsp rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/errorPage.jsp diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/greeting.jsp b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/greeting.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/view/greeting.jsp rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/greeting.jsp diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/hello.jsp b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/hello.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/view/hello.jsp rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/hello.jsp diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/helloworld.jsp b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/helloworld.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/view/helloworld.jsp rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/helloworld.jsp diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/image-download.jsp b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/image-download.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/view/image-download.jsp rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/image-download.jsp diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/personForm.jsp diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/personView.jsp b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/personView.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/view/personView.jsp rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/personView.jsp diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/sample.jsp b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/sample.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/view/sample.jsp rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/sample.jsp diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/view/welcome.jsp b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/welcome.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/view/welcome.jsp rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/view/welcome.jsp diff --git a/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml b/spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-mvc-xml/src/main/webapp/WEB-INF/web.xml rename to spring-web-modules/spring-mvc-xml/src/main/webapp/WEB-INF/web.xml diff --git a/spring-mvc-xml/src/main/webapp/index.jsp b/spring-web-modules/spring-mvc-xml/src/main/webapp/index.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/index.jsp rename to spring-web-modules/spring-mvc-xml/src/main/webapp/index.jsp diff --git a/spring-mvc-xml/src/main/webapp/jsp/ExampleThree.jsp b/spring-web-modules/spring-mvc-xml/src/main/webapp/jsp/ExampleThree.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/jsp/ExampleThree.jsp rename to spring-web-modules/spring-mvc-xml/src/main/webapp/jsp/ExampleThree.jsp diff --git a/spring-mvc-xml/src/main/webapp/jsp/ExampleTwo.jsp b/spring-web-modules/spring-mvc-xml/src/main/webapp/jsp/ExampleTwo.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/jsp/ExampleTwo.jsp rename to spring-web-modules/spring-mvc-xml/src/main/webapp/jsp/ExampleTwo.jsp diff --git a/spring-mvc-xml/src/main/webapp/jsp/index.jsp b/spring-web-modules/spring-mvc-xml/src/main/webapp/jsp/index.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/jsp/index.jsp rename to spring-web-modules/spring-mvc-xml/src/main/webapp/jsp/index.jsp diff --git a/spring-mvc-xml/src/main/webapp/spring-handler-index.jsp b/spring-web-modules/spring-mvc-xml/src/main/webapp/spring-handler-index.jsp similarity index 100% rename from spring-mvc-xml/src/main/webapp/spring-handler-index.jsp rename to spring-web-modules/spring-mvc-xml/src/main/webapp/spring-handler-index.jsp diff --git a/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpIntegrationTest.java b/spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpIntegrationTest.java similarity index 100% rename from spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpIntegrationTest.java rename to spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/geoip/GeoIpIntegrationTest.java diff --git a/spring-mvc-xml/src/test/java/com/baeldung/spring/controller/RequestAndPathVariableValidationControllerIntegrationTest.java b/spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/spring/controller/RequestAndPathVariableValidationControllerIntegrationTest.java similarity index 100% rename from spring-mvc-xml/src/test/java/com/baeldung/spring/controller/RequestAndPathVariableValidationControllerIntegrationTest.java rename to spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/spring/controller/RequestAndPathVariableValidationControllerIntegrationTest.java diff --git a/spring-mvc-xml/src/test/java/org/baeldung/SpringContextTest.java b/spring-web-modules/spring-mvc-xml/src/test/java/org/baeldung/SpringContextTest.java similarity index 96% rename from spring-mvc-xml/src/test/java/org/baeldung/SpringContextTest.java rename to spring-web-modules/spring-mvc-xml/src/test/java/org/baeldung/SpringContextTest.java index 62e34859ee..27dcb83bd4 100644 --- a/spring-mvc-xml/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-web-modules/spring-mvc-xml/src/test/java/org/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package com.baeldung; +package org.baeldung; import org.junit.Test; import org.junit.runner.RunWith; From 8f843980820d537980a124367424386efb169b8f Mon Sep 17 00:00:00 2001 From: mikr Date: Wed, 30 Dec 2020 22:37:42 +0100 Subject: [PATCH 185/361] JAVA-3531 Move spring-mvc-xml module (correct package for test) --- .../src/test/java/{org => com}/baeldung/SpringContextTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename spring-web-modules/spring-mvc-xml/src/test/java/{org => com}/baeldung/SpringContextTest.java (96%) diff --git a/spring-web-modules/spring-mvc-xml/src/test/java/org/baeldung/SpringContextTest.java b/spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/SpringContextTest.java similarity index 96% rename from spring-web-modules/spring-mvc-xml/src/test/java/org/baeldung/SpringContextTest.java rename to spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/SpringContextTest.java index 27dcb83bd4..62e34859ee 100644 --- a/spring-web-modules/spring-mvc-xml/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-web-modules/spring-mvc-xml/src/test/java/com/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; From 08435be1909f31bef139b724ba0790dde736df55 Mon Sep 17 00:00:00 2001 From: mikr Date: Wed, 30 Dec 2020 22:57:22 +0100 Subject: [PATCH 186/361] JAVA-3536 Move spring-rest-shell module --- pom.xml | 2 -- spring-web-modules/pom.xml | 1 + .../spring-rest-shell}/README.md | 0 .../spring-rest-shell}/pom.xml | 2 +- .../src/main/java/com/baeldung/Application.java | 0 .../src/main/java/com/baeldung/acticle/Article.java | 0 .../src/main/java/com/baeldung/acticle/ArticleRepository.java | 0 .../spring-rest-shell}/src/main/resources/logback.xml | 0 8 files changed, 2 insertions(+), 3 deletions(-) rename {spring-rest-shell => spring-web-modules/spring-rest-shell}/README.md (100%) rename {spring-rest-shell => spring-web-modules/spring-rest-shell}/pom.xml (96%) rename {spring-rest-shell => spring-web-modules/spring-rest-shell}/src/main/java/com/baeldung/Application.java (100%) rename {spring-rest-shell => spring-web-modules/spring-rest-shell}/src/main/java/com/baeldung/acticle/Article.java (100%) rename {spring-rest-shell => spring-web-modules/spring-rest-shell}/src/main/java/com/baeldung/acticle/ArticleRepository.java (100%) rename {spring-rest-shell => spring-web-modules/spring-rest-shell}/src/main/resources/logback.xml (100%) diff --git a/pom.xml b/pom.xml index 67fa58293b..44a87ecd3c 100644 --- a/pom.xml +++ b/pom.xml @@ -673,7 +673,6 @@ spring-remoting spring-rest-http-2 spring-rest-query-language - spring-rest-shell spring-rest-simple spring-resttemplate spring-rest-testing @@ -1138,7 +1137,6 @@ spring-reactor spring-remoting spring-rest-query-language - spring-rest-shell spring-rest-simple spring-resttemplate spring-rest-testing diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index c28ffbeab8..9fb40a1ed3 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -24,6 +24,7 @@ spring-mvc-webflow spring-rest-angular spring-rest-http + spring-rest-shell spring-resttemplate-2 spring-thymeleaf spring-thymeleaf-2 diff --git a/spring-rest-shell/README.md b/spring-web-modules/spring-rest-shell/README.md similarity index 100% rename from spring-rest-shell/README.md rename to spring-web-modules/spring-rest-shell/README.md diff --git a/spring-rest-shell/pom.xml b/spring-web-modules/spring-rest-shell/pom.xml similarity index 96% rename from spring-rest-shell/pom.xml rename to spring-web-modules/spring-rest-shell/pom.xml index 1148a5c093..f5792fd6ca 100644 --- a/spring-rest-shell/pom.xml +++ b/spring-web-modules/spring-rest-shell/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-rest-shell/src/main/java/com/baeldung/Application.java b/spring-web-modules/spring-rest-shell/src/main/java/com/baeldung/Application.java similarity index 100% rename from spring-rest-shell/src/main/java/com/baeldung/Application.java rename to spring-web-modules/spring-rest-shell/src/main/java/com/baeldung/Application.java diff --git a/spring-rest-shell/src/main/java/com/baeldung/acticle/Article.java b/spring-web-modules/spring-rest-shell/src/main/java/com/baeldung/acticle/Article.java similarity index 100% rename from spring-rest-shell/src/main/java/com/baeldung/acticle/Article.java rename to spring-web-modules/spring-rest-shell/src/main/java/com/baeldung/acticle/Article.java diff --git a/spring-rest-shell/src/main/java/com/baeldung/acticle/ArticleRepository.java b/spring-web-modules/spring-rest-shell/src/main/java/com/baeldung/acticle/ArticleRepository.java similarity index 100% rename from spring-rest-shell/src/main/java/com/baeldung/acticle/ArticleRepository.java rename to spring-web-modules/spring-rest-shell/src/main/java/com/baeldung/acticle/ArticleRepository.java diff --git a/spring-rest-shell/src/main/resources/logback.xml b/spring-web-modules/spring-rest-shell/src/main/resources/logback.xml similarity index 100% rename from spring-rest-shell/src/main/resources/logback.xml rename to spring-web-modules/spring-rest-shell/src/main/resources/logback.xml From 90562c22a4c8a37db5f0c0189559c424eb8f9285 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Thu, 31 Dec 2020 10:46:33 +0100 Subject: [PATCH 187/361] JAVA-4130: Fix README.md for Using JaVers for Data Model Auditing in Spring Data --- spring-boot-modules/spring-boot-data/README.md | 1 + .../src/main/java/com/baeldung/javers/README.md | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) delete mode 100644 spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/README.md diff --git a/spring-boot-modules/spring-boot-data/README.md b/spring-boot-modules/spring-boot-data/README.md index da22b62128..f72864e6d9 100644 --- a/spring-boot-modules/spring-boot-data/README.md +++ b/spring-boot-modules/spring-boot-data/README.md @@ -11,3 +11,4 @@ This module contains articles about Spring Boot with Spring Data - [Spring Custom Property Editor](https://www.baeldung.com/spring-mvc-custom-property-editor) - [Using @JsonComponent in Spring Boot](https://www.baeldung.com/spring-boot-jsoncomponent) - [Guide To Running Logic on Startup in Spring](https://www.baeldung.com/running-setup-logic-on-startup-in-spring) +- [Using JaVers for Data Model Auditing in Spring Data](https://www.baeldung.com/spring-data-javers-audit) diff --git a/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/README.md b/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/README.md deleted file mode 100644 index 4f8dd4abff..0000000000 --- a/spring-boot-modules/spring-boot-data/src/main/java/com/baeldung/javers/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles - -- [Using JaVers for Data Model Auditing in Spring Data](https://www.baeldung.com/spring-data-javers-audit) From 47ada8bdcad728c5e86450916af1e3bf72584c4c Mon Sep 17 00:00:00 2001 From: mikr Date: Thu, 31 Dec 2020 12:19:30 +0100 Subject: [PATCH 188/361] JAVA-3498 Fix integration test in spring-cloud-zuul --- ...=> GreetingControllerIntegrationTest.java} | 57 +++++++++++-------- 1 file changed, 32 insertions(+), 25 deletions(-) rename spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/{GreetingControllerManualTest.java => GreetingControllerIntegrationTest.java} (72%) diff --git a/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerManualTest.java b/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerIntegrationTest.java similarity index 72% rename from spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerManualTest.java rename to spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerIntegrationTest.java index 4d3cede534..62e57992cb 100644 --- a/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerManualTest.java +++ b/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerIntegrationTest.java @@ -5,14 +5,17 @@ import static com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.support.RateL import static com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.support.RateLimitConstants.HEADER_REMAINING; import static com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.support.RateLimitConstants.HEADER_REMAINING_QUOTA; import static com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.support.RateLimitConstants.HEADER_RESET; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static java.lang.Integer.parseInt; +import static org.hamcrest.Matchers.both; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.lessThanOrEqualTo; import static org.springframework.http.HttpStatus.OK; import static org.springframework.http.HttpStatus.TOO_MANY_REQUESTS; import java.util.concurrent.TimeUnit; + +import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -26,7 +29,7 @@ import org.springframework.test.context.junit4.SpringRunner; @AutoConfigureTestDatabase @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -public class GreetingControllerManualTest { +public class GreetingControllerIntegrationTest { private static final String SIMPLE_GREETING = "/greeting/simple"; private static final String ADVANCED_GREETING = "/greeting/advanced"; @@ -44,11 +47,15 @@ public class GreetingControllerManualTest { String remaining = headers.getFirst(HEADER_REMAINING + key); String reset = headers.getFirst(HEADER_RESET + key); - assertEquals(limit, "5"); - assertEquals(remaining, "4"); - assertEquals(reset, "60000"); + Assert.assertEquals("5", limit); + Assert.assertEquals(remaining, "4", remaining); + Assert.assertNotNull(reset); + Assert.assertThat( + parseInt(reset), + is(both(greaterThanOrEqualTo(0)).and(lessThanOrEqualTo(60000))) + ); - assertEquals(OK, response.getStatusCode()); + Assert.assertEquals(OK, response.getStatusCode()); } @Test @@ -57,7 +64,7 @@ public class GreetingControllerManualTest { HttpHeaders headers = response.getHeaders(); String key = "rate-limit-application_serviceAdvanced_127.0.0.1"; assertHeaders(headers, key, false, false); - assertEquals(OK, response.getStatusCode()); + Assert.assertEquals(OK, response.getStatusCode()); for (int i = 0; i < 2; i++) { response = this.restTemplate.getForEntity(ADVANCED_GREETING, String.class); @@ -68,18 +75,18 @@ public class GreetingControllerManualTest { String remaining = headers.getFirst(HEADER_REMAINING + key); String reset = headers.getFirst(HEADER_RESET + key); - assertEquals(limit, "1"); - assertEquals(remaining, "0"); - assertNotEquals(reset, "2000"); + Assert.assertEquals(limit, "1"); + Assert.assertEquals(remaining, "0"); + Assert.assertNotEquals(reset, "2000"); - assertEquals(TOO_MANY_REQUESTS, response.getStatusCode()); + Assert.assertEquals(TOO_MANY_REQUESTS, response.getStatusCode()); TimeUnit.SECONDS.sleep(2); response = this.restTemplate.getForEntity(ADVANCED_GREETING, String.class); headers = response.getHeaders(); assertHeaders(headers, key, false, false); - assertEquals(OK, response.getStatusCode()); + Assert.assertEquals(OK, response.getStatusCode()); } private void assertHeaders(HttpHeaders headers, String key, boolean nullable, boolean quotaHeaders) { @@ -91,22 +98,22 @@ public class GreetingControllerManualTest { if (nullable) { if (quotaHeaders) { - assertNull(quota); - assertNull(remainingQuota); + Assert.assertNull(quota); + Assert.assertNull(remainingQuota); } else { - assertNull(limit); - assertNull(remaining); + Assert.assertNull(limit); + Assert.assertNull(remaining); } - assertNull(reset); + Assert.assertNull(reset); } else { if (quotaHeaders) { - assertNotNull(quota); - assertNotNull(remainingQuota); + Assert.assertNotNull(quota); + Assert.assertNotNull(remainingQuota); } else { - assertNotNull(limit); - assertNotNull(remaining); + Assert.assertNotNull(limit); + Assert.assertNotNull(remaining); } - assertNotNull(reset); + Assert.assertNotNull(reset); } } } From bef161cc5df86f6cbd6e08dc9f43a6211196204c Mon Sep 17 00:00:00 2001 From: mikr Date: Thu, 31 Dec 2020 12:22:01 +0100 Subject: [PATCH 189/361] JAVA-3498 Fix integration test in spring-cloud-zuul (fix imports) --- .../GreetingControllerIntegrationTest.java | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerIntegrationTest.java b/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerIntegrationTest.java index 62e57992cb..a234bc8972 100644 --- a/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerIntegrationTest.java +++ b/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerIntegrationTest.java @@ -10,6 +10,9 @@ import static org.hamcrest.Matchers.both; import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.lessThanOrEqualTo; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; import static org.springframework.http.HttpStatus.OK; import static org.springframework.http.HttpStatus.TOO_MANY_REQUESTS; @@ -47,15 +50,15 @@ public class GreetingControllerIntegrationTest { String remaining = headers.getFirst(HEADER_REMAINING + key); String reset = headers.getFirst(HEADER_RESET + key); - Assert.assertEquals("5", limit); - Assert.assertEquals(remaining, "4", remaining); - Assert.assertNotNull(reset); - Assert.assertThat( + assertEquals("5", limit); + assertEquals(remaining, "4", remaining); + assertNotNull(reset); + assertThat( parseInt(reset), is(both(greaterThanOrEqualTo(0)).and(lessThanOrEqualTo(60000))) ); - Assert.assertEquals(OK, response.getStatusCode()); + assertEquals(OK, response.getStatusCode()); } @Test @@ -64,7 +67,7 @@ public class GreetingControllerIntegrationTest { HttpHeaders headers = response.getHeaders(); String key = "rate-limit-application_serviceAdvanced_127.0.0.1"; assertHeaders(headers, key, false, false); - Assert.assertEquals(OK, response.getStatusCode()); + assertEquals(OK, response.getStatusCode()); for (int i = 0; i < 2; i++) { response = this.restTemplate.getForEntity(ADVANCED_GREETING, String.class); @@ -75,18 +78,18 @@ public class GreetingControllerIntegrationTest { String remaining = headers.getFirst(HEADER_REMAINING + key); String reset = headers.getFirst(HEADER_RESET + key); - Assert.assertEquals(limit, "1"); - Assert.assertEquals(remaining, "0"); + assertEquals(limit, "1"); + assertEquals(remaining, "0"); Assert.assertNotEquals(reset, "2000"); - Assert.assertEquals(TOO_MANY_REQUESTS, response.getStatusCode()); + assertEquals(TOO_MANY_REQUESTS, response.getStatusCode()); TimeUnit.SECONDS.sleep(2); response = this.restTemplate.getForEntity(ADVANCED_GREETING, String.class); headers = response.getHeaders(); assertHeaders(headers, key, false, false); - Assert.assertEquals(OK, response.getStatusCode()); + assertEquals(OK, response.getStatusCode()); } private void assertHeaders(HttpHeaders headers, String key, boolean nullable, boolean quotaHeaders) { @@ -107,13 +110,13 @@ public class GreetingControllerIntegrationTest { Assert.assertNull(reset); } else { if (quotaHeaders) { - Assert.assertNotNull(quota); - Assert.assertNotNull(remainingQuota); + assertNotNull(quota); + assertNotNull(remainingQuota); } else { - Assert.assertNotNull(limit); - Assert.assertNotNull(remaining); + assertNotNull(limit); + assertNotNull(remaining); } - Assert.assertNotNull(reset); + assertNotNull(reset); } } } From cb7c9406eed01e9f44d2dd2573443841e2ef7208 Mon Sep 17 00:00:00 2001 From: mikr Date: Thu, 31 Dec 2020 12:24:17 +0100 Subject: [PATCH 190/361] JAVA-3498 Fix integration test in spring-cloud-zuul (fix imports - 2) --- .../GreetingControllerIntegrationTest.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerIntegrationTest.java b/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerIntegrationTest.java index a234bc8972..7fdc723305 100644 --- a/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerIntegrationTest.java +++ b/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/GreetingControllerIntegrationTest.java @@ -11,14 +11,15 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.lessThanOrEqualTo; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.springframework.http.HttpStatus.OK; import static org.springframework.http.HttpStatus.TOO_MANY_REQUESTS; import java.util.concurrent.TimeUnit; -import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -80,7 +81,7 @@ public class GreetingControllerIntegrationTest { assertEquals(limit, "1"); assertEquals(remaining, "0"); - Assert.assertNotEquals(reset, "2000"); + assertNotEquals(reset, "2000"); assertEquals(TOO_MANY_REQUESTS, response.getStatusCode()); @@ -101,13 +102,13 @@ public class GreetingControllerIntegrationTest { if (nullable) { if (quotaHeaders) { - Assert.assertNull(quota); - Assert.assertNull(remainingQuota); + assertNull(quota); + assertNull(remainingQuota); } else { - Assert.assertNull(limit); - Assert.assertNull(remaining); + assertNull(limit); + assertNull(remaining); } - Assert.assertNull(reset); + assertNull(reset); } else { if (quotaHeaders) { assertNotNull(quota); From 926f273a2d94ff36005f9ba82af6c9c64b9e94eb Mon Sep 17 00:00:00 2001 From: Daniel Strmecki Date: Sat, 2 Jan 2021 12:08:15 +0100 Subject: [PATCH 191/361] Feature/bael 4749 java 11 features (#10308) * BAEL-4749: Added examples for Java 11 * BAEL-4749: Refactor test examples * BAEL-4749: Refactor test examples 2 * BAEL-4749: Fix PR comments * BAEL-4749: Update nestmates examples * BAEL-4749: Use method reference in Predicate.not example * BAEL-4749: Use String::isBlank in Predicate.not example * BAEL-4749: Two space indents when continuing a line * BAEL-4749: Two space indents when continuing a line (2) --- core-java-modules/core-java-11-2/pom.xml | 25 ++++++++ .../java/com/baeldung/features/MainClass.java | 17 ++++++ .../features/HttpClientIntegrationTest.java | 54 ++++++++++++++++ .../features/JavaElevenFeaturesUnitTest.java | 61 +++++++++++++++++++ .../features/NestedClassesUnitTest.java | 37 +++++++++++ 5 files changed, 194 insertions(+) create mode 100644 core-java-modules/core-java-11-2/src/main/java/com/baeldung/features/MainClass.java create mode 100644 core-java-modules/core-java-11-2/src/test/java/com/baeldung/features/HttpClientIntegrationTest.java create mode 100644 core-java-modules/core-java-11-2/src/test/java/com/baeldung/features/JavaElevenFeaturesUnitTest.java create mode 100644 core-java-modules/core-java-11-2/src/test/java/com/baeldung/features/NestedClassesUnitTest.java diff --git a/core-java-modules/core-java-11-2/pom.xml b/core-java-modules/core-java-11-2/pom.xml index e2b129ae00..b92963a5c8 100644 --- a/core-java-modules/core-java-11-2/pom.xml +++ b/core-java-modules/core-java-11-2/pom.xml @@ -28,6 +28,29 @@ ${assertj.version} test + + org.mock-server + mockserver-junit-jupiter + ${mockserver.version} + + + org.junit.jupiter + junit-jupiter-engine + ${junit.jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-params + ${junit.jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-api + ${junit.jupiter.version} + test + @@ -48,7 +71,9 @@ 11 11 29.0-jre + 5.7.0 3.17.2 + 5.11.1 diff --git a/core-java-modules/core-java-11-2/src/main/java/com/baeldung/features/MainClass.java b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/features/MainClass.java new file mode 100644 index 0000000000..b00c56fcd7 --- /dev/null +++ b/core-java-modules/core-java-11-2/src/main/java/com/baeldung/features/MainClass.java @@ -0,0 +1,17 @@ +package com.baeldung.features; + +public class MainClass { + + private static boolean mainPrivateMethod() { + return true; + } + + public static class NestedClass { + + boolean nestedPublicMethod() { + return mainPrivateMethod(); + } + + } + +} diff --git a/core-java-modules/core-java-11-2/src/test/java/com/baeldung/features/HttpClientIntegrationTest.java b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/features/HttpClientIntegrationTest.java new file mode 100644 index 0000000000..1d49f5dbd1 --- /dev/null +++ b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/features/HttpClientIntegrationTest.java @@ -0,0 +1,54 @@ +package com.baeldung.features; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.mockserver.integration.ClientAndServer; +import org.mockserver.model.HttpStatusCode; +import org.mockserver.socket.PortFactory; + +import java.io.IOException; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockserver.integration.ClientAndServer.startClientAndServer; + +class HttpClientIntegrationTest { + + private static ClientAndServer mockServer; + private static int port; + + @BeforeAll + static void startServer() { + port = PortFactory.findFreePort(); + mockServer = startClientAndServer(port); + mockServer.when(new org.mockserver.model.HttpRequest().withMethod("GET")) + .respond(new org.mockserver.model.HttpResponse() + .withStatusCode(HttpStatusCode.OK_200.code()) + .withBody("Hello from the server!")); + } + + @AfterAll + static void stopServer() { + mockServer.stop(); + } + + @Test + void givenSampleHttpRequest_whenRequestIsSent_thenServerResponseIsReceived() throws IOException, InterruptedException { + HttpClient httpClient = HttpClient.newBuilder() + .version(HttpClient.Version.HTTP_2) + .connectTimeout(Duration.ofSeconds(20)) + .build(); + HttpRequest httpRequest = HttpRequest.newBuilder() + .GET() + .uri(URI.create("http://localhost:" + port)) + .build(); + HttpResponse httpResponse = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString()); + assertThat(httpResponse.body()).isEqualTo("Hello from the server!"); + } + +} diff --git a/core-java-modules/core-java-11-2/src/test/java/com/baeldung/features/JavaElevenFeaturesUnitTest.java b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/features/JavaElevenFeaturesUnitTest.java new file mode 100644 index 0000000000..61ce9c7c13 --- /dev/null +++ b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/features/JavaElevenFeaturesUnitTest.java @@ -0,0 +1,61 @@ +package com.baeldung.features; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import javax.annotation.Nonnull; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.List; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; + +class JavaElevenFeaturesUnitTest { + + @Test + void givenMultilineString_whenExtractingNonBlankStrippedLines_thenLinesAreReturned() { + String multilineString = "Baeldung helps \n \n developers \n explore Java."; + List lines = multilineString.lines() + .filter(line -> !line.isBlank()) + .map(String::strip) + .collect(Collectors.toList()); + assertThat(lines).containsExactly("Baeldung helps", "developers", "explore Java."); + } + + @Test + void givenTemporaryFile_whenReadingStringContent_thenContentIsReturned(@TempDir Path tempDir) throws IOException { + Path filePath = Files.writeString(Files.createTempFile(tempDir, "demo", ".txt"), "Sample text"); + String fileContent = Files.readString(filePath); + assertThat(fileContent).isEqualTo("Sample text"); + } + + @Test + void givenSampleList_whenConvertingToArray_thenItemsRemainUnchanged() { + List sampleList = Arrays.asList("Java", "Kotlin"); + String[] sampleArray = sampleList.toArray(String[]::new); + assertThat(sampleArray).containsExactly("Java", "Kotlin"); + } + + @Test + void givenSampleList_whenConvertingToUppercaseString_thenUppercaseIsReturned() { + List sampleList = Arrays.asList("Java", "Kotlin"); + String resultString = sampleList.stream() + .map((@Nonnull var x) -> x.toUpperCase()) + .collect(Collectors.joining(", ")); + assertThat(resultString).isEqualTo("JAVA, KOTLIN"); + } + + @Test + void givenSampleList_whenExtractingNonBlankValues_thenOnlyNonBlanksAreReturned() { + List sampleList = Arrays.asList("Java", "\n \n", "Kotlin", " "); + List withoutBlanks = sampleList.stream() + .filter(Predicate.not(String::isBlank)) + .collect(Collectors.toList()); + assertThat(withoutBlanks).containsExactly("Java", "Kotlin"); + } + +} diff --git a/core-java-modules/core-java-11-2/src/test/java/com/baeldung/features/NestedClassesUnitTest.java b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/features/NestedClassesUnitTest.java new file mode 100644 index 0000000000..902ad9c6f8 --- /dev/null +++ b/core-java-modules/core-java-11-2/src/test/java/com/baeldung/features/NestedClassesUnitTest.java @@ -0,0 +1,37 @@ +package com.baeldung.features; + +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; + +class NestedClassesUnitTest { + + @Test + public void giveNestedClass_whenCallingMainClassPrivateMethod_thenNoExceptionIsThrown() { + MainClass.NestedClass nestedInstance = new MainClass.NestedClass(); + assertThat(nestedInstance.nestedPublicMethod()).isTrue(); + } + + @Test + public void giveNestedClass_whenCheckingNestmate_thenNestedClassIsReturned() { + assertThat(MainClass.class.isNestmateOf(MainClass.NestedClass.class)).isTrue(); + } + + @Test + public void giveNestedClass_whenCheckingNestHost_thenMainClassIsReturned() { + assertThat(MainClass.NestedClass.class.getNestHost()).isEqualTo(MainClass.class); + } + + @Test + public void giveNestedClass_whenCheckingNestMembers_thenNestMembersAreReturned() { + Set nestedMembers = Arrays.stream(MainClass.NestedClass.class.getNestMembers()) + .map(Class::getName) + .collect(Collectors.toSet()); + assertThat(nestedMembers).contains(MainClass.class.getName(), MainClass.NestedClass.class.getName()); + } + +} From f210b5ae2967688b38879b0165adf59c44cee49e Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 3 Jan 2021 00:11:41 +0530 Subject: [PATCH 192/361] JAVA-4166: Fix test in spring-5-reactive --- .../com/baeldung/functional/FunctionalWebApplication.java | 7 ++++--- .../FunctionalWebApplicationIntegrationTest.java | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-5-reactive/src/main/java/com/baeldung/functional/FunctionalWebApplication.java b/spring-5-reactive/src/main/java/com/baeldung/functional/FunctionalWebApplication.java index 1f40798ada..b89f74ad92 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/functional/FunctionalWebApplication.java +++ b/spring-5-reactive/src/main/java/com/baeldung/functional/FunctionalWebApplication.java @@ -3,7 +3,7 @@ package com.baeldung.functional; import static org.springframework.web.reactive.function.BodyInserters.fromObject; import static org.springframework.web.reactive.function.server.RequestPredicates.GET; import static org.springframework.web.reactive.function.server.RequestPredicates.POST; -import static org.springframework.web.reactive.function.server.RequestPredicates.path; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; import static org.springframework.web.reactive.function.server.RouterFunctions.route; import static org.springframework.web.reactive.function.server.RouterFunctions.toHttpHandler; import static org.springframework.web.reactive.function.server.ServerResponse.ok; @@ -18,6 +18,7 @@ import org.apache.catalina.startup.Tomcat; import org.springframework.boot.web.embedded.tomcat.TomcatWebServer; import org.springframework.boot.web.server.WebServer; import org.springframework.core.io.ClassPathResource; +import org.springframework.http.MediaType; import org.springframework.http.server.reactive.HttpHandler; import org.springframework.http.server.reactive.ServletHttpHandlerAdapter; import org.springframework.web.reactive.function.server.RouterFunction; @@ -37,14 +38,14 @@ public class FunctionalWebApplication { private RouterFunction routingFunction() { FormHandler formHandler = new FormHandler(); - RouterFunction restfulRouter = route(GET("/"), serverRequest -> ok().body(Flux.fromIterable(actors), Actor.class)).andRoute(POST("/"), serverRequest -> serverRequest.bodyToMono(Actor.class) + RouterFunction restfulRouter = route(GET("/actor"), serverRequest -> ok().body(Flux.fromIterable(actors), Actor.class)).andRoute(POST("/actor"), serverRequest -> serverRequest.bodyToMono(Actor.class) .doOnNext(actors::add) .then(ok().build())); return route(GET("/test"), serverRequest -> ok().body(fromObject("helloworld"))).andRoute(POST("/login"), formHandler::handleLogin) .andRoute(POST("/upload"), formHandler::handleUpload) .and(RouterFunctions.resources("/files/**", new ClassPathResource("files/"))) - .andNest(path("/actor"), restfulRouter) + .andNest(accept(MediaType.APPLICATION_JSON), restfulRouter) .filter((request, next) -> { System.out.println("Before handler invocation: " + request.path()); return next.handle(request); diff --git a/spring-5-reactive/src/test/java/com/baeldung/functional/FunctionalWebApplicationIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/functional/FunctionalWebApplicationIntegrationTest.java index 38496d3500..5c0b4f69d0 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/functional/FunctionalWebApplicationIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/functional/FunctionalWebApplicationIntegrationTest.java @@ -103,7 +103,6 @@ public class FunctionalWebApplicationIntegrationTest { .isEqualTo(String.valueOf(resource.contentLength())); } - @Ignore("We get 404 after Spring Boot 2.4 upgrade. We need to solve it in a new task.") @Test public void givenActors_whenAddActor_thenAdded() throws Exception { client.get() From 71bbdb7fede51f7b275eac1b4fe6c13a6aea8901 Mon Sep 17 00:00:00 2001 From: Tapan Avasthi Date: Sat, 2 Jan 2021 04:03:44 +0530 Subject: [PATCH 193/361] Use shouldNotFilter to exclude URLs for a Filter Jira ticket: http://jira.baeldung.com/browse/BAEL-4703 The existing article uses an out-dated way is used to excluded filtering for certain urls, instead shouldNotFilter should be used. --- .../filter/HeaderValidatorFilter.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java index 2af90badae..d6c1777326 100644 --- a/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java +++ b/spring-web-modules/spring-mvc-basics-3/src/main/java/com/baeldung/exclude_urls_filter/filter/HeaderValidatorFilter.java @@ -11,20 +11,23 @@ import java.io.IOException; @Order(1) public class HeaderValidatorFilter extends OncePerRequestFilter { - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) - throws ServletException, IOException { - String path = request.getRequestURI(); - if ("/health".equals(path)) { - filterChain.doFilter(request, response); - return; - } - String countryCode = request.getHeader("X-Country-Code"); - if (!"US".equals(countryCode)) { - response.sendError(HttpStatus.BAD_REQUEST.value(), "Invalid Locale"); - return; - } - - filterChain.doFilter(request, response); - } -} \ No newline at end of file + @Override + protected void doFilterInternal(HttpServletRequest request, + HttpServletResponse response, + FilterChain filterChain) + throws ServletException, + IOException { + String countryCode = request.getHeader("X-Country-Code"); + if (!"US".equals(countryCode)) { + response.sendError(HttpStatus.BAD_REQUEST.value(), "Invalid Locale"); + return; + } + filterChain.doFilter(request, response); + } + + @Override + protected boolean shouldNotFilter(HttpServletRequest request) throws ServletException { + String path = request.getRequestURI(); + return "/health".equals(path); + } +} From 1a2bd7348762bf5b1b505d8c78fd3fb41665e4bf Mon Sep 17 00:00:00 2001 From: "Kent@lhind.hp.g5" Date: Thu, 31 Dec 2020 23:20:27 +0100 Subject: [PATCH 194/361] [BAEL-2547] jackson deserialization class-casting exception --- .../baeldung/jackson/tocollection/Book.java | 70 ++++++++++ .../tocollection/JsonToCollectionUtil.java | 24 ++++ .../resources/to-java-collection/books.json | 13 ++ .../resources/to-java-collection/books.xml | 17 +++ .../DeserializeToJavaCollectionUnitTest.java | 130 ++++++++++++++++++ .../JsonToCollectionUtilUnitTest.java | 51 +++++++ 6 files changed, 305 insertions(+) create mode 100644 jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/tocollection/Book.java create mode 100644 jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/tocollection/JsonToCollectionUtil.java create mode 100644 jackson-modules/jackson-conversions-2/src/main/resources/to-java-collection/books.json create mode 100644 jackson-modules/jackson-conversions-2/src/main/resources/to-java-collection/books.xml create mode 100644 jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/tocollection/DeserializeToJavaCollectionUnitTest.java create mode 100644 jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/tocollection/JsonToCollectionUtilUnitTest.java diff --git a/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/tocollection/Book.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/tocollection/Book.java new file mode 100644 index 0000000000..e9cb1343e9 --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/tocollection/Book.java @@ -0,0 +1,70 @@ +package com.baeldung.jackson.tocollection; + + +import java.util.Objects; + +public class Book { + private Integer bookId; + private String title; + private String author; + + public Book() {} + + public Book(Integer bookId, String title, String author) { + this.bookId = bookId; + this.title = title; + this.author = author; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Book)) { + return false; + } + + Book book = (Book) o; + + if (!Objects.equals(bookId, book.bookId)) { + return false; + } + if (!Objects.equals(title, book.title)) { + return false; + } + return Objects.equals(author, book.author); + } + + @Override + public int hashCode() { + int result = bookId != null ? bookId.hashCode() : 0; + result = 31 * result + (title != null ? title.hashCode() : 0); + result = 31 * result + (author != null ? author.hashCode() : 0); + return result; + } + + public Integer getBookId() { + return bookId; + } + + public void setBookId(Integer bookId) { + this.bookId = bookId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } +} diff --git a/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/tocollection/JsonToCollectionUtil.java b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/tocollection/JsonToCollectionUtil.java new file mode 100644 index 0000000000..83e2de2c3b --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/main/java/com/baeldung/jackson/tocollection/JsonToCollectionUtil.java @@ -0,0 +1,24 @@ +package com.baeldung.jackson.tocollection; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.type.CollectionType; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class JsonToCollectionUtil { + + private JsonToCollectionUtil(){} + + public static List jsonArrayToList(String json, Class elementClass) throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + CollectionType listType = objectMapper.getTypeFactory().constructCollectionType(ArrayList.class, elementClass); + return objectMapper.readValue(json, listType); + } + + public static List jsonArrayToList2(String json, Class elementClass) throws IOException { + return new ObjectMapper().readValue(json, new TypeReference>() {}); + } +} diff --git a/jackson-modules/jackson-conversions-2/src/main/resources/to-java-collection/books.json b/jackson-modules/jackson-conversions-2/src/main/resources/to-java-collection/books.json new file mode 100644 index 0000000000..6daf426736 --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/main/resources/to-java-collection/books.json @@ -0,0 +1,13 @@ +[ { + "bookId" : 1, + "title" : "A Song of Ice and Fire", + "author" : "George R. R. Martin" +}, { + "bookId" : 2, + "title" : "The Hitchhiker's Guide to the Galaxy", + "author" : "Douglas Adams" +}, { + "bookId" : 3, + "title" : "Hackers And Painters", + "author" : "Paul Graham" +} ] diff --git a/jackson-modules/jackson-conversions-2/src/main/resources/to-java-collection/books.xml b/jackson-modules/jackson-conversions-2/src/main/resources/to-java-collection/books.xml new file mode 100644 index 0000000000..b2f951315b --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/main/resources/to-java-collection/books.xml @@ -0,0 +1,17 @@ + + + 1 + A Song of Ice and Fire + George R. R. Martin + + + 2 + The Hitchhiker's Guide to the Galaxy + Douglas Adams + + + 3 + Hackers And Painters + Paul Graham + + diff --git a/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/tocollection/DeserializeToJavaCollectionUnitTest.java b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/tocollection/DeserializeToJavaCollectionUnitTest.java new file mode 100644 index 0000000000..8ddcc2d69a --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/tocollection/DeserializeToJavaCollectionUnitTest.java @@ -0,0 +1,130 @@ +package com.baeldung.jackson.tocollection; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.type.CollectionType; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import org.assertj.core.util.Lists; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + +public class DeserializeToJavaCollectionUnitTest { + private ObjectMapper objectMapper; + private XmlMapper xmlMapper; + private List expectedBookList; + + + @BeforeEach + void setup() { + objectMapper = new ObjectMapper(); + xmlMapper = new XmlMapper(); + expectedBookList = Lists.newArrayList( + new Book(1, "A Song of Ice and Fire", "George R. R. Martin"), + new Book(2, "The Hitchhiker's Guide to the Galaxy", "Douglas Adams"), + new Book(3, "Hackers And Painters", "Paul Graham")); + } + + private String readFile(String path) { + try (Scanner scanner = new Scanner(getClass().getResourceAsStream(path), "UTF-8")) { + return scanner.useDelimiter("\\A").next(); + } + } + + /*==================== + * JSON tests + *==================== + */ + @Test + void givenJsonString_whenDeserializingToList_thenThrowingClassCastException() throws JsonProcessingException { + String jsonString = readFile("/to-java-collection/books.json"); + List bookList = objectMapper.readValue(jsonString, ArrayList.class); + assertThat(bookList).size().isEqualTo(3); + assertThatExceptionOfType(ClassCastException.class) + .isThrownBy(() -> bookList.get(0).getBookId()) + .withMessageMatching(".*java.util.LinkedHashMap cannot be cast to .*com.baeldung.jackson.tocollection.Book.*"); + } + + @Test + void givenJsonString_whenDeserializingWithTypeReference_thenGetExpectedList() throws JsonProcessingException { + String jsonString = readFile("/to-java-collection/books.json"); + List bookList = objectMapper.readValue(jsonString, new TypeReference>() {}); + assertThat(bookList.get(0)).isInstanceOf(Book.class); + assertThat(bookList).isEqualTo(expectedBookList); + } + + @Test + void givenJsonString_whenDeserializingWithJavaType_thenGetExpectedList() throws JsonProcessingException { + String jsonString = readFile("/to-java-collection/books.json"); + CollectionType listType = objectMapper.getTypeFactory().constructCollectionType(ArrayList.class, Book.class); + List bookList = objectMapper.readValue(jsonString, listType); + assertThat(bookList.get(0)).isInstanceOf(Book.class); + assertThat(bookList).isEqualTo(expectedBookList); + } + + @Test + void givenJsonString_whenDeserializingWithConvertValueAndTypeReference_thenGetExpectedList() throws JsonProcessingException { + String jsonString = readFile("/to-java-collection/books.json"); + JsonNode jsonNode = objectMapper.readTree(jsonString); + List bookList = objectMapper.convertValue(jsonNode, new TypeReference>() {}); + assertThat(bookList.get(0)).isInstanceOf(Book.class); + assertThat(bookList).isEqualTo(expectedBookList); + } + + @Test + void givenJsonString_whenDeserializingWithConvertValueAndJavaType_thenGetExpectedList() throws JsonProcessingException { + String jsonString = readFile("/to-java-collection/books.json"); + JsonNode jsonNode = objectMapper.readTree(jsonString); + List bookList = objectMapper.convertValue(jsonNode, objectMapper.getTypeFactory().constructCollectionType(ArrayList.class, Book.class)); + assertThat(bookList.get(0)).isInstanceOf(Book.class); + assertThat(bookList).isEqualTo(expectedBookList); + } + + /*==================== + * XML tests + *==================== + */ + @Test + void givenXml_whenDeserializingToList_thenThrowingClassCastException() throws JsonProcessingException { + String xml = readFile("/to-java-collection/books.xml"); + List bookList = xmlMapper.readValue(xml, ArrayList.class); + assertThat(bookList).size().isEqualTo(3); + assertThatExceptionOfType(ClassCastException.class) + .isThrownBy(() -> bookList.get(0).getBookId()) + .withMessageMatching(".*java.util.LinkedHashMap cannot be cast to .*com.baeldung.jackson.tocollection.Book.*"); + } + + @Test + void givenXml_whenDeserializingWithTypeReference_thenGetExpectedList() throws JsonProcessingException { + String xml = readFile("/to-java-collection/books.xml"); + List bookList = xmlMapper.readValue(xml, new TypeReference>() {}); + assertThat(bookList.get(0)).isInstanceOf(Book.class); + assertThat(bookList).isEqualTo(expectedBookList); + } + + @Test + void givenXml_whenDeserializingWithConvertValueAndTypeReference_thenGetExpectedList() throws JsonProcessingException { + String xml = readFile("/to-java-collection/books.xml"); + List node = xmlMapper.readValue(xml, List.class); + List bookList = xmlMapper.convertValue(node, new TypeReference>() {}); + assertThat(bookList.get(0)).isInstanceOf(Book.class); + assertThat(bookList).isEqualTo(expectedBookList); + } + + @Test + void givenXml_whenDeserializingWithConvertValueAndJavaType_thenGetExpectedList() throws JsonProcessingException { + String xml = readFile("/to-java-collection/books.xml"); + List node = xmlMapper.readValue(xml, List.class); + List bookList = xmlMapper.convertValue(node, objectMapper.getTypeFactory().constructCollectionType(ArrayList.class, Book.class)); + assertThat(bookList.get(0)).isInstanceOf(Book.class); + assertThat(bookList).isEqualTo(expectedBookList); + } +} diff --git a/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/tocollection/JsonToCollectionUtilUnitTest.java b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/tocollection/JsonToCollectionUtilUnitTest.java new file mode 100644 index 0000000000..a08e48e069 --- /dev/null +++ b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/tocollection/JsonToCollectionUtilUnitTest.java @@ -0,0 +1,51 @@ +package com.baeldung.jackson.tocollection; + +import org.assertj.core.util.Lists; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.util.List; +import java.util.Scanner; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + +class JsonToCollectionUtilUnitTest { + + private List expectedBookList; + + + @BeforeEach + void setup() { + expectedBookList = Lists.newArrayList( + new Book(1, "A Song of Ice and Fire", "George R. R. Martin"), + new Book(2, "The Hitchhiker's Guide to the Galaxy", "Douglas Adams"), + new Book(3, "Hackers And Painters", "Paul Graham")); + } + + private String readFile(String path) { + try (Scanner scanner = new Scanner(getClass().getResourceAsStream(path), "UTF-8")) { + return scanner.useDelimiter("\\A").next(); + } + } + + @Test + void givenJsonString_whenCalljsonArrayToList_thenGetExpectedList() throws IOException { + String jsonString = readFile("/to-java-collection/books.json"); + List bookList = JsonToCollectionUtil.jsonArrayToList(jsonString, Book.class); + assertThat(bookList.get(0)).isInstanceOf(Book.class); + assertThat(bookList).isEqualTo(expectedBookList); + } + + @Test + void givenJsonString_whenCalljsonArrayToList2_thenGetException() throws IOException { + String jsonString = readFile("/to-java-collection/books.json"); + List bookList = JsonToCollectionUtil.jsonArrayToList2(jsonString, Book.class); + assertThat(bookList).size().isEqualTo(3); + assertThatExceptionOfType(ClassCastException.class) + .isThrownBy(() -> bookList.get(0).getBookId()) + .withMessageMatching(".*java.util.LinkedHashMap cannot be cast to .*com.baeldung.jackson.tocollection.Book.*"); + } + +} From 5d9cb02da9070e9742a172877d0220d841a559f8 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Sun, 3 Jan 2021 16:36:16 -0300 Subject: [PATCH 195/361] fixed error updating deprecated 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 5d4e170226..e63dc1eb54 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.hasText(name) ? path : name); + super(!StringUtils.hasText(name) ? path : name); try { this.propertiesConfiguration = new PropertiesConfiguration(path); FileChangedReloadingStrategy strategy = new FileChangedReloadingStrategy(); From bbdcf57afb63dda1b6e020ba22c5d1a780ef1c92 Mon Sep 17 00:00:00 2001 From: Anshul BANSAL Date: Tue, 29 Dec 2020 11:02:52 +0200 Subject: [PATCH 196/361] BAEL-4472- Binary Semaphore vs a ReentrantLock - new module added --- .../core-java-concurrency-advanced-4/pom.xml | 47 +++++++++++++++ ...inarySemaphoreVsReentrantLockUnitTest.java | 58 +++++++++++++++++++ core-java-modules/pom.xml | 1 + 3 files changed, 106 insertions(+) create mode 100644 core-java-modules/core-java-concurrency-advanced-4/pom.xml create mode 100644 core-java-modules/core-java-concurrency-advanced-4/src/test/java/com/baeldung/binarysemaphorereentrantlock/BinarySemaphoreVsReentrantLockUnitTest.java diff --git a/core-java-modules/core-java-concurrency-advanced-4/pom.xml b/core-java-modules/core-java-concurrency-advanced-4/pom.xml new file mode 100644 index 0000000000..eb9ed3adc1 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-4/pom.xml @@ -0,0 +1,47 @@ + + + + 4.0.0 + core-java-concurrency-advanced-4 + 0.1.0-SNAPSHOT + core-java-concurrency-advanced-4 + jar + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + ../ + + + + + + + core-java-concurrency-advanced-4 + + + org.apache.maven.plugins + maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + src/main/resources + true + + + + + + 1.8 + 1.8 + + + diff --git a/core-java-modules/core-java-concurrency-advanced-4/src/test/java/com/baeldung/binarysemaphorereentrantlock/BinarySemaphoreVsReentrantLockUnitTest.java b/core-java-modules/core-java-concurrency-advanced-4/src/test/java/com/baeldung/binarysemaphorereentrantlock/BinarySemaphoreVsReentrantLockUnitTest.java new file mode 100644 index 0000000000..f456e82f39 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-4/src/test/java/com/baeldung/binarysemaphorereentrantlock/BinarySemaphoreVsReentrantLockUnitTest.java @@ -0,0 +1,58 @@ +package com.baeldung.binarysemaphorereentrantlock; + +import static org.junit.Assert.assertEquals; +import java.util.concurrent.Semaphore; +import java.util.concurrent.locks.ReentrantLock; + +import org.junit.Test; + +public class BinarySemaphoreVsReentrantLockUnitTest { + + @Test + public void givenBinarySemaphore_whenAcquireAndRelease_thenCheckAvailablePermits() throws InterruptedException { + Semaphore binarySemaphore = new Semaphore(1); + try { + binarySemaphore.acquire(); + assertEquals(0, binarySemaphore.availablePermits()); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + binarySemaphore.release(); + assertEquals(1, binarySemaphore.availablePermits()); + } + } + + @Test + public void givenReentrantLock_whenLockAndUnlock_thenCheckHoldCountAndIsLocked() throws InterruptedException { + ReentrantLock reentrantLock = new ReentrantLock(); + try { + reentrantLock.lock(); + assertEquals(1, reentrantLock.getHoldCount()); + assertEquals(true, reentrantLock.isLocked()); + } finally { + reentrantLock.unlock(); + assertEquals(0, reentrantLock.getHoldCount()); + assertEquals(false, reentrantLock.isLocked()); + } + } + + @Test + public void givenReentrantLock_whenLockMultipleTimes_thenUnlockMultipleTimesToRelease() throws InterruptedException { + ReentrantLock reentrantLock = new ReentrantLock(); + try { + reentrantLock.lock(); + reentrantLock.lock(); + assertEquals(2, reentrantLock.getHoldCount()); + assertEquals(true, reentrantLock.isLocked()); + } finally { + reentrantLock.unlock(); + assertEquals(1, reentrantLock.getHoldCount()); + assertEquals(true, reentrantLock.isLocked()); + + reentrantLock.unlock(); + assertEquals(0, reentrantLock.getHoldCount()); + assertEquals(false, reentrantLock.isLocked()); + } + } + +} diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 0a9e818156..00ed22c3bd 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -47,6 +47,7 @@ core-java-concurrency-advanced core-java-concurrency-advanced-2 core-java-concurrency-advanced-3 + core-java-concurrency-advanced-4 core-java-concurrency-basic core-java-concurrency-basic-2 core-java-concurrency-collections From 1b4e5782ec11316b254c8faec298dc66d433dfdc Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Mon, 4 Jan 2021 09:05:55 +0530 Subject: [PATCH 197/361] BAEL-4624: Review comments --- .../com/baeldung/spring/transaction/CourseDao.java | 11 ----------- .../baeldung/spring/transaction/CourseService.java | 10 +++++++--- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseDao.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseDao.java index 489784bb40..adf138ba67 100644 --- a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseDao.java +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseDao.java @@ -1,8 +1,5 @@ package com.baeldung.spring.transaction; -import java.sql.SQLException; - -import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Repository; import com.baeldung.spring.hibernate.AbstractHibernateDao; @@ -13,12 +10,4 @@ public class CourseDao extends AbstractHibernateDao { super(); setClazz(Course.class); } - - public Course createWithRuntimeException(final Course entity) { - throw new DataIntegrityViolationException("Throwing exception for demoing Rollback!!!"); - } - - public Course createWithCheckedException(final Course entity) throws SQLException { - throw new SQLException("Throwing exception for demoing Rollback!!!"); - } } diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseService.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseService.java index 21f947a925..400c7d4843 100644 --- a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseService.java +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseService.java @@ -3,6 +3,7 @@ package com.baeldung.spring.transaction; import java.sql.SQLException; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataIntegrityViolationException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; @@ -15,17 +16,20 @@ public class CourseService { @Transactional public void createCourseDeclarativeWithRuntimeException(Course course) { - courseDao.createWithRuntimeException(course); + courseDao.create(course); + throw new DataIntegrityViolationException("Throwing exception for demoing Rollback!!!"); } @Transactional(rollbackFor = { SQLException.class }) public void createCourseDeclarativeWithCheckedException(Course course) throws SQLException { - courseDao.createWithCheckedException(course); + courseDao.create(course); + throw new SQLException("Throwing exception for demoing Rollback!!!"); } public void createCourseDefaultRatingProgramatic(Course course) { try { - courseDao.createWithRuntimeException(course); + courseDao.create(course); + throw new DataIntegrityViolationException("Throwing exception for demoing Rollback!!!"); } catch (Exception e) { TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } From 68d3abae10124c5d5d2b103252be20d54d209cdb Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 4 Jan 2021 10:50:19 +0100 Subject: [PATCH 198/361] JAVA-3537: Move spring-rest-simple into spring-web-modules --- pom.xml | 2 -- spring-web-modules/pom.xml | 1 + .../spring-rest-simple}/README.md | 0 .../spring-rest-simple}/pom.xml | 2 +- .../src/main/java/com/baeldung/Application.java | 0 .../java/com/baeldung/apachefileupload/UploadController.java | 0 .../src/main/java/com/baeldung/config/MvcConfig.java | 0 .../com/baeldung/config/converter/KryoHttpMessageConverter.java | 0 .../src/main/java/com/baeldung/repository/BookRepository.java | 0 .../java/com/baeldung/web/controller/ApiExceptionHandler.java | 0 .../main/java/com/baeldung/web/controller/BookController.java | 0 .../main/java/com/baeldung/web/controller/FooController.java | 0 .../src/main/java/com/baeldung/web/dto/Bazz.java | 0 .../src/main/java/com/baeldung/web/dto/Book.java | 0 .../src/main/java/com/baeldung/web/dto/Foo.java | 0 .../src/main/java/com/baeldung/web/dto/FooProtos.java | 0 .../src/main/java/com/baeldung/web/error/ApiErrorResponse.java | 0 .../main/java/com/baeldung/web/error/BookNotFoundException.java | 0 .../src/main/java/com/baeldung/web/util/LinkUtil.java | 0 .../src/main/resources/application.properties | 0 .../spring-rest-simple}/src/main/resources/logback.xml | 0 .../spring-rest-simple}/src/main/webapp/WEB-INF/company.html | 0 .../src/main/webapp/WEB-INF/spring-views.xml | 0 .../src/main/webapp/WEB-INF/spring-web-config.xml | 0 .../src/test/java/com/baeldung/SpringContextTest.java | 0 .../java/com/baeldung/repository/BookRepositoryUnitTest.java | 0 .../baeldung/web/controller/BookControllerIntegrationTest.java | 0 .../java/com/baeldung/web/controller/mediatypes/TestConfig.java | 0 .../test/java/com/baeldung/web/test/RequestMappingLiveTest.java | 0 .../java/com/baeldung/web/test/RestTemplateBasicLiveTest.java | 0 .../baeldung/web/test/SpringHttpMessageConvertersLiveTest.java | 0 .../com/baeldung/web/test/TestRestTemplateBasicLiveTest.java | 0 .../src/test/java/com/baeldung/web/util/HTTPLinkHeaderUtil.java | 0 .../spring-rest-simple}/src/test/resources/.gitignore | 0 34 files changed, 2 insertions(+), 3 deletions(-) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/README.md (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/pom.xml (99%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/java/com/baeldung/Application.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/java/com/baeldung/apachefileupload/UploadController.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/java/com/baeldung/config/MvcConfig.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/java/com/baeldung/config/converter/KryoHttpMessageConverter.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/java/com/baeldung/repository/BookRepository.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/java/com/baeldung/web/controller/ApiExceptionHandler.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/java/com/baeldung/web/controller/BookController.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/java/com/baeldung/web/controller/FooController.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/java/com/baeldung/web/dto/Bazz.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/java/com/baeldung/web/dto/Book.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/java/com/baeldung/web/dto/Foo.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/java/com/baeldung/web/dto/FooProtos.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/java/com/baeldung/web/error/ApiErrorResponse.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/java/com/baeldung/web/error/BookNotFoundException.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/java/com/baeldung/web/util/LinkUtil.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/resources/application.properties (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/resources/logback.xml (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/webapp/WEB-INF/company.html (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/webapp/WEB-INF/spring-views.xml (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/main/webapp/WEB-INF/spring-web-config.xml (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/test/java/com/baeldung/SpringContextTest.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/test/java/com/baeldung/repository/BookRepositoryUnitTest.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/test/java/com/baeldung/web/controller/BookControllerIntegrationTest.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/test/java/com/baeldung/web/test/RequestMappingLiveTest.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/test/java/com/baeldung/web/test/RestTemplateBasicLiveTest.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/test/java/com/baeldung/web/test/SpringHttpMessageConvertersLiveTest.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/test/java/com/baeldung/web/test/TestRestTemplateBasicLiveTest.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/test/java/com/baeldung/web/util/HTTPLinkHeaderUtil.java (100%) rename {spring-rest-simple => spring-web-modules/spring-rest-simple}/src/test/resources/.gitignore (100%) diff --git a/pom.xml b/pom.xml index 16de220d8c..208a0f5d87 100644 --- a/pom.xml +++ b/pom.xml @@ -663,7 +663,6 @@ spring-reactor spring-remoting - spring-rest-simple spring-resttemplate spring-rest-testing spring-roo @@ -1119,7 +1118,6 @@ spring-reactor spring-remoting - spring-rest-simple spring-resttemplate spring-rest-testing spring-roo diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index d2d8b5d816..6252a6360f 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -32,6 +32,7 @@ spring-rest-http-2 spring-rest-query-language spring-rest-shell + spring-rest-simple spring-resttemplate-2 spring-thymeleaf spring-thymeleaf-2 diff --git a/spring-rest-simple/README.md b/spring-web-modules/spring-rest-simple/README.md similarity index 100% rename from spring-rest-simple/README.md rename to spring-web-modules/spring-rest-simple/README.md diff --git a/spring-rest-simple/pom.xml b/spring-web-modules/spring-rest-simple/pom.xml similarity index 99% rename from spring-rest-simple/pom.xml rename to spring-web-modules/spring-rest-simple/pom.xml index 291053c87f..37a0b99de2 100644 --- a/spring-rest-simple/pom.xml +++ b/spring-web-modules/spring-rest-simple/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-rest-simple/src/main/java/com/baeldung/Application.java b/spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/Application.java similarity index 100% rename from spring-rest-simple/src/main/java/com/baeldung/Application.java rename to spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/Application.java diff --git a/spring-rest-simple/src/main/java/com/baeldung/apachefileupload/UploadController.java b/spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/apachefileupload/UploadController.java similarity index 100% rename from spring-rest-simple/src/main/java/com/baeldung/apachefileupload/UploadController.java rename to spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/apachefileupload/UploadController.java diff --git a/spring-rest-simple/src/main/java/com/baeldung/config/MvcConfig.java b/spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/config/MvcConfig.java similarity index 100% rename from spring-rest-simple/src/main/java/com/baeldung/config/MvcConfig.java rename to spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/config/MvcConfig.java diff --git a/spring-rest-simple/src/main/java/com/baeldung/config/converter/KryoHttpMessageConverter.java b/spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/config/converter/KryoHttpMessageConverter.java similarity index 100% rename from spring-rest-simple/src/main/java/com/baeldung/config/converter/KryoHttpMessageConverter.java rename to spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/config/converter/KryoHttpMessageConverter.java diff --git a/spring-rest-simple/src/main/java/com/baeldung/repository/BookRepository.java b/spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/repository/BookRepository.java similarity index 100% rename from spring-rest-simple/src/main/java/com/baeldung/repository/BookRepository.java rename to spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/repository/BookRepository.java diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/controller/ApiExceptionHandler.java b/spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/controller/ApiExceptionHandler.java similarity index 100% rename from spring-rest-simple/src/main/java/com/baeldung/web/controller/ApiExceptionHandler.java rename to spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/controller/ApiExceptionHandler.java diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/controller/BookController.java b/spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/controller/BookController.java similarity index 100% rename from spring-rest-simple/src/main/java/com/baeldung/web/controller/BookController.java rename to spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/controller/BookController.java diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/controller/FooController.java b/spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/controller/FooController.java similarity index 100% rename from spring-rest-simple/src/main/java/com/baeldung/web/controller/FooController.java rename to spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/controller/FooController.java diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/dto/Bazz.java b/spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/dto/Bazz.java similarity index 100% rename from spring-rest-simple/src/main/java/com/baeldung/web/dto/Bazz.java rename to spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/dto/Bazz.java diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/dto/Book.java b/spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/dto/Book.java similarity index 100% rename from spring-rest-simple/src/main/java/com/baeldung/web/dto/Book.java rename to spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/dto/Book.java diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/dto/Foo.java b/spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/dto/Foo.java similarity index 100% rename from spring-rest-simple/src/main/java/com/baeldung/web/dto/Foo.java rename to spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/dto/Foo.java diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/dto/FooProtos.java b/spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/dto/FooProtos.java similarity index 100% rename from spring-rest-simple/src/main/java/com/baeldung/web/dto/FooProtos.java rename to spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/dto/FooProtos.java diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/error/ApiErrorResponse.java b/spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/error/ApiErrorResponse.java similarity index 100% rename from spring-rest-simple/src/main/java/com/baeldung/web/error/ApiErrorResponse.java rename to spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/error/ApiErrorResponse.java diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/error/BookNotFoundException.java b/spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/error/BookNotFoundException.java similarity index 100% rename from spring-rest-simple/src/main/java/com/baeldung/web/error/BookNotFoundException.java rename to spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/error/BookNotFoundException.java diff --git a/spring-rest-simple/src/main/java/com/baeldung/web/util/LinkUtil.java b/spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/util/LinkUtil.java similarity index 100% rename from spring-rest-simple/src/main/java/com/baeldung/web/util/LinkUtil.java rename to spring-web-modules/spring-rest-simple/src/main/java/com/baeldung/web/util/LinkUtil.java diff --git a/spring-rest-simple/src/main/resources/application.properties b/spring-web-modules/spring-rest-simple/src/main/resources/application.properties similarity index 100% rename from spring-rest-simple/src/main/resources/application.properties rename to spring-web-modules/spring-rest-simple/src/main/resources/application.properties diff --git a/spring-rest-simple/src/main/resources/logback.xml b/spring-web-modules/spring-rest-simple/src/main/resources/logback.xml similarity index 100% rename from spring-rest-simple/src/main/resources/logback.xml rename to spring-web-modules/spring-rest-simple/src/main/resources/logback.xml diff --git a/spring-rest-simple/src/main/webapp/WEB-INF/company.html b/spring-web-modules/spring-rest-simple/src/main/webapp/WEB-INF/company.html similarity index 100% rename from spring-rest-simple/src/main/webapp/WEB-INF/company.html rename to spring-web-modules/spring-rest-simple/src/main/webapp/WEB-INF/company.html diff --git a/spring-rest-simple/src/main/webapp/WEB-INF/spring-views.xml b/spring-web-modules/spring-rest-simple/src/main/webapp/WEB-INF/spring-views.xml similarity index 100% rename from spring-rest-simple/src/main/webapp/WEB-INF/spring-views.xml rename to spring-web-modules/spring-rest-simple/src/main/webapp/WEB-INF/spring-views.xml diff --git a/spring-rest-simple/src/main/webapp/WEB-INF/spring-web-config.xml b/spring-web-modules/spring-rest-simple/src/main/webapp/WEB-INF/spring-web-config.xml similarity index 100% rename from spring-rest-simple/src/main/webapp/WEB-INF/spring-web-config.xml rename to spring-web-modules/spring-rest-simple/src/main/webapp/WEB-INF/spring-web-config.xml diff --git a/spring-rest-simple/src/test/java/com/baeldung/SpringContextTest.java b/spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-rest-simple/src/test/java/com/baeldung/SpringContextTest.java rename to spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-rest-simple/src/test/java/com/baeldung/repository/BookRepositoryUnitTest.java b/spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/repository/BookRepositoryUnitTest.java similarity index 100% rename from spring-rest-simple/src/test/java/com/baeldung/repository/BookRepositoryUnitTest.java rename to spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/repository/BookRepositoryUnitTest.java diff --git a/spring-rest-simple/src/test/java/com/baeldung/web/controller/BookControllerIntegrationTest.java b/spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/web/controller/BookControllerIntegrationTest.java similarity index 100% rename from spring-rest-simple/src/test/java/com/baeldung/web/controller/BookControllerIntegrationTest.java rename to spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/web/controller/BookControllerIntegrationTest.java diff --git a/spring-rest-simple/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java b/spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java similarity index 100% rename from spring-rest-simple/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java rename to spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/web/controller/mediatypes/TestConfig.java diff --git a/spring-rest-simple/src/test/java/com/baeldung/web/test/RequestMappingLiveTest.java b/spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/web/test/RequestMappingLiveTest.java similarity index 100% rename from spring-rest-simple/src/test/java/com/baeldung/web/test/RequestMappingLiveTest.java rename to spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/web/test/RequestMappingLiveTest.java diff --git a/spring-rest-simple/src/test/java/com/baeldung/web/test/RestTemplateBasicLiveTest.java b/spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/web/test/RestTemplateBasicLiveTest.java similarity index 100% rename from spring-rest-simple/src/test/java/com/baeldung/web/test/RestTemplateBasicLiveTest.java rename to spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/web/test/RestTemplateBasicLiveTest.java diff --git a/spring-rest-simple/src/test/java/com/baeldung/web/test/SpringHttpMessageConvertersLiveTest.java b/spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/web/test/SpringHttpMessageConvertersLiveTest.java similarity index 100% rename from spring-rest-simple/src/test/java/com/baeldung/web/test/SpringHttpMessageConvertersLiveTest.java rename to spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/web/test/SpringHttpMessageConvertersLiveTest.java diff --git a/spring-rest-simple/src/test/java/com/baeldung/web/test/TestRestTemplateBasicLiveTest.java b/spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/web/test/TestRestTemplateBasicLiveTest.java similarity index 100% rename from spring-rest-simple/src/test/java/com/baeldung/web/test/TestRestTemplateBasicLiveTest.java rename to spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/web/test/TestRestTemplateBasicLiveTest.java diff --git a/spring-rest-simple/src/test/java/com/baeldung/web/util/HTTPLinkHeaderUtil.java b/spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/web/util/HTTPLinkHeaderUtil.java similarity index 100% rename from spring-rest-simple/src/test/java/com/baeldung/web/util/HTTPLinkHeaderUtil.java rename to spring-web-modules/spring-rest-simple/src/test/java/com/baeldung/web/util/HTTPLinkHeaderUtil.java diff --git a/spring-rest-simple/src/test/resources/.gitignore b/spring-web-modules/spring-rest-simple/src/test/resources/.gitignore similarity index 100% rename from spring-rest-simple/src/test/resources/.gitignore rename to spring-web-modules/spring-rest-simple/src/test/resources/.gitignore From f49df277d4e40d46034cd4a047fdaaf39f853556 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 4 Jan 2021 12:29:07 +0100 Subject: [PATCH 199/361] JAVA-3586: Upgrade commons-lang3 to 3.11 in the main pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 16de220d8c..41274250cd 100644 --- a/pom.xml +++ b/pom.xml @@ -1385,7 +1385,7 @@ 2.21.0 2.5 2.6 - 3.5 + 3.11 1.4 3.0.0 3.1.0 From 3cb1b8536f89fc90ff9bd9dd38f59185c67b979b Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 4 Jan 2021 12:50:24 +0100 Subject: [PATCH 200/361] JAVA-3586: Use commons-lang3.version property --- core-java-modules/core-java-15/pom.xml | 3 +-- core-java-modules/core-java-9/pom.xml | 2 +- core-java-modules/core-java-collections-3/pom.xml | 2 +- java-numbers-3/pom.xml | 3 +-- java-numbers-4/pom.xml | 3 +-- jhipster/jhipster-microservice/car-app/pom.xml | 3 +-- jhipster/jhipster-microservice/dealer-app/pom.xml | 3 +-- jhipster/jhipster-microservice/gateway-app/pom.xml | 3 +-- jhipster/jhipster-monolithic/pom.xml | 3 +-- maven-modules/versions-maven-plugin/pom.xml | 3 +-- persistence-modules/hibernate-annotations/pom.xml | 3 +-- quarkus/pom.xml | 2 +- 12 files changed, 12 insertions(+), 21 deletions(-) diff --git a/core-java-modules/core-java-15/pom.xml b/core-java-modules/core-java-15/pom.xml index df8aeafca9..3b0d324d10 100644 --- a/core-java-modules/core-java-15/pom.xml +++ b/core-java-modules/core-java-15/pom.xml @@ -20,7 +20,7 @@ org.apache.commons commons-lang3 - ${apache-commons-lang3.version} + ${commons-lang3.version} org.assertj @@ -68,7 +68,6 @@ 15 - 3.11 3.17.2 3.8.1 3.0.0-M3 diff --git a/core-java-modules/core-java-9/pom.xml b/core-java-modules/core-java-9/pom.xml index d7894934b1..05dc8ba5eb 100644 --- a/core-java-modules/core-java-9/pom.xml +++ b/core-java-modules/core-java-9/pom.xml @@ -47,7 +47,7 @@ org.apache.commons commons-lang3 - 3.11 + ${commons-lang3.version} commons-io diff --git a/core-java-modules/core-java-collections-3/pom.xml b/core-java-modules/core-java-collections-3/pom.xml index a9a05f5092..602fcf60f4 100644 --- a/core-java-modules/core-java-collections-3/pom.xml +++ b/core-java-modules/core-java-collections-3/pom.xml @@ -35,7 +35,7 @@ org.apache.commons commons-lang3 - 3.10 + ${commons-lang3.version} diff --git a/java-numbers-3/pom.xml b/java-numbers-3/pom.xml index 495618885a..62225a898f 100644 --- a/java-numbers-3/pom.xml +++ b/java-numbers-3/pom.xml @@ -27,7 +27,7 @@ org.apache.commons commons-lang3 - ${commons.version} + ${commons-lang3.version} test @@ -51,7 +51,6 @@ 2.6.0 0.10.2 - 3.9 3.6.1 diff --git a/java-numbers-4/pom.xml b/java-numbers-4/pom.xml index e1722fb039..f4b0e23bd7 100644 --- a/java-numbers-4/pom.xml +++ b/java-numbers-4/pom.xml @@ -22,7 +22,7 @@ org.apache.commons commons-lang3 - ${commons.version} + ${commons-lang3.version} test @@ -45,7 +45,6 @@ 0.10.2 - 3.9 3.6.1 diff --git a/jhipster/jhipster-microservice/car-app/pom.xml b/jhipster/jhipster-microservice/car-app/pom.xml index c53ea8358e..603d53299c 100644 --- a/jhipster/jhipster-microservice/car-app/pom.xml +++ b/jhipster/jhipster-microservice/car-app/pom.xml @@ -22,7 +22,6 @@ 3.6.2 2.0.0 2.5 - 3.5 0.4.13 1.2 5.2.8.Final @@ -267,7 +266,7 @@ org.apache.commons commons-lang3 - ${commons-lang.version} + ${commons-lang3.version} org.assertj diff --git a/jhipster/jhipster-microservice/dealer-app/pom.xml b/jhipster/jhipster-microservice/dealer-app/pom.xml index a0bcc73e31..0e492d3d13 100644 --- a/jhipster/jhipster-microservice/dealer-app/pom.xml +++ b/jhipster/jhipster-microservice/dealer-app/pom.xml @@ -21,7 +21,6 @@ 3.6.2 2.0.0 2.5 - 3.5 0.4.13 1.2 5.2.8.Final @@ -266,7 +265,7 @@ org.apache.commons commons-lang3 - ${commons-lang.version} + ${commons-lang3.version} org.assertj diff --git a/jhipster/jhipster-microservice/gateway-app/pom.xml b/jhipster/jhipster-microservice/gateway-app/pom.xml index c6dcbb3f3e..c5e7364f57 100644 --- a/jhipster/jhipster-microservice/gateway-app/pom.xml +++ b/jhipster/jhipster-microservice/gateway-app/pom.xml @@ -23,7 +23,6 @@ 3.6.0 1.10 2.5 - 3.5 0.4.13 1.3 1.2 @@ -299,7 +298,7 @@ org.apache.commons commons-lang3 - ${commons-lang.version} + ${commons-lang3.version} org.assertj diff --git a/jhipster/jhipster-monolithic/pom.xml b/jhipster/jhipster-monolithic/pom.xml index 04f790faf5..103f48424f 100644 --- a/jhipster/jhipster-monolithic/pom.xml +++ b/jhipster/jhipster-monolithic/pom.xml @@ -171,7 +171,7 @@ org.apache.commons commons-lang3 - ${commons-lang.version} + ${commons-lang3.version} org.assertj @@ -888,7 +888,6 @@ 3.6.2 2.0.0 2.5 - 3.5 0.4.13 1.3 2.2.1 diff --git a/maven-modules/versions-maven-plugin/pom.xml b/maven-modules/versions-maven-plugin/pom.xml index 3a9134ff40..3c6f2eeb3e 100644 --- a/maven-modules/versions-maven-plugin/pom.xml +++ b/maven-modules/versions-maven-plugin/pom.xml @@ -24,7 +24,7 @@ org.apache.commons commons-lang3 - ${commons.lang3.version} + ${commons-lang3.version} @@ -74,7 +74,6 @@ 2.3 2.7 1.9.1 - 3.0 4.0 diff --git a/persistence-modules/hibernate-annotations/pom.xml b/persistence-modules/hibernate-annotations/pom.xml index 5367921f31..368eee2115 100644 --- a/persistence-modules/hibernate-annotations/pom.xml +++ b/persistence-modules/hibernate-annotations/pom.xml @@ -30,7 +30,7 @@ org.apache.commons commons-lang3 - ${commons.lang3.version} + ${commons-lang3.version} @@ -67,7 +67,6 @@ 2.1.7.RELEASE 5.4.7.Final 1.4.200 - 3.8.1 0.9 diff --git a/quarkus/pom.xml b/quarkus/pom.xml index 7fdf1557fb..9c14afca3c 100644 --- a/quarkus/pom.xml +++ b/quarkus/pom.xml @@ -48,7 +48,7 @@ org.apache.commons commons-lang3 - 3.9 + ${commons-lang3.version} org.projectlombok From 5f78600cf7df8efd88c4f0e64c33d2d8437ed43b Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 4 Jan 2021 13:33:47 +0100 Subject: [PATCH 201/361] JAVA-3586: Fix versions-maven-plugin pom.xml --- maven-modules/versions-maven-plugin/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/maven-modules/versions-maven-plugin/pom.xml b/maven-modules/versions-maven-plugin/pom.xml index 3c6f2eeb3e..ff49811430 100644 --- a/maven-modules/versions-maven-plugin/pom.xml +++ b/maven-modules/versions-maven-plugin/pom.xml @@ -24,7 +24,7 @@ org.apache.commons commons-lang3 - ${commons-lang3.version} + ${commons.lang3.version} @@ -75,6 +75,7 @@ 2.7 1.9.1 4.0 + 3.11 \ No newline at end of file From 7dc8fdba7eaab562793c96c3c52888669b824d04 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 4 Jan 2021 16:27:21 +0100 Subject: [PATCH 202/361] JAVA-3538: Move spring-rest-testing into spring-web-modules --- pom.xml | 2 - spring-web-modules/pom.xml | 1 + .../spring-rest-testing}/.gitignore | 0 .../spring-rest-testing}/README.md | 0 .../spring-rest-testing}/pom.xml | 2 +- .../ExceptionTestingApplication.java | 48 +++---- .../controller/ExceptionController.java | 62 ++++----- .../exception/BadArgumentsException.java | 26 ++-- .../exception/InternalException.java | 26 ++-- .../exception/ResourceNotFoundException.java | 26 ++-- .../com/baeldung/persistence/IOperations.java | 0 .../com/baeldung/persistence/dao/IFooDao.java | 0 .../com/baeldung/persistence/model/Foo.java | 0 .../com/baeldung/persistence/model/User.java | 0 .../persistence/service/IFooService.java | 0 .../service/common/AbstractService.java | 0 .../persistence/service/impl/FooService.java | 0 .../java/com/baeldung/spring/Application.java | 0 .../baeldung/spring/PersistenceConfig.java | 0 .../java/com/baeldung/spring/WebConfig.java | 0 .../web/controller/FooController.java | 0 .../web/controller/HomeController.java | 0 .../web/controller/RootController.java | 0 .../MyResourceNotFoundException.java | 0 .../web/metric/ActuatorMetricService.java | 0 .../metric/CustomActuatorMetricService.java | 0 .../web/metric/IActuatorMetricService.java | 0 .../metric/ICustomActuatorMetricService.java | 0 .../baeldung/web/metric/IMetricService.java | 0 .../com/baeldung/web/metric/MetricFilter.java | 0 .../baeldung/web/metric/MetricService.java | 0 .../baeldung/web/util/RestPreconditions.java | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/logback.xml | 0 .../main/resources/persistence-h2.properties | 0 .../resources/persistence-mysql.properties | 0 .../resources/springDataPersistenceConfig.xml | 0 .../src/main/webapp/WEB-INF/api-servlet.xml | 0 .../src/main/webapp/WEB-INF/view/graph.jsp | 0 .../src/main/webapp/WEB-INF/view/homepage.jsp | 0 .../src/main/webapp/WEB-INF/web.xml | 0 .../src/test/java/com/baeldung/Consts.java | 0 .../SpringContextIntegrationTest.java | 0 .../java/com/baeldung/SpringContextTest.java | 0 .../ExceptionControllerUnitTest.java | 130 +++++++++--------- .../persistence/PersistenceTestSuite.java | 0 ...ractServicePersistenceIntegrationTest.java | 0 .../FooServicePersistenceIntegrationTest.java | 0 .../test/java/com/baeldung/util/IDUtil.java | 0 .../src/test/resources/.gitignore | 0 .../spring-rest-testing}/src/testFile | 0 51 files changed, 161 insertions(+), 162 deletions(-) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/.gitignore (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/README.md (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/pom.xml (99%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/exceptiontesting/ExceptionTestingApplication.java (97%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/exceptiontesting/controller/ExceptionController.java (97%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/exceptiontesting/exception/BadArgumentsException.java (96%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/exceptiontesting/exception/InternalException.java (96%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/exceptiontesting/exception/ResourceNotFoundException.java (96%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/persistence/IOperations.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/persistence/dao/IFooDao.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/persistence/model/Foo.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/persistence/model/User.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/persistence/service/IFooService.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/persistence/service/common/AbstractService.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/persistence/service/impl/FooService.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/spring/Application.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/spring/PersistenceConfig.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/spring/WebConfig.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/web/controller/FooController.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/web/controller/HomeController.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/web/controller/RootController.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/web/metric/ActuatorMetricService.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/web/metric/CustomActuatorMetricService.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/web/metric/IActuatorMetricService.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/web/metric/ICustomActuatorMetricService.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/web/metric/IMetricService.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/web/metric/MetricFilter.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/web/metric/MetricService.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/java/com/baeldung/web/util/RestPreconditions.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/resources/application.properties (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/resources/logback.xml (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/resources/persistence-h2.properties (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/resources/persistence-mysql.properties (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/resources/springDataPersistenceConfig.xml (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/webapp/WEB-INF/api-servlet.xml (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/webapp/WEB-INF/view/graph.jsp (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/webapp/WEB-INF/view/homepage.jsp (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/main/webapp/WEB-INF/web.xml (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/test/java/com/baeldung/Consts.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/test/java/com/baeldung/SpringContextIntegrationTest.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/test/java/com/baeldung/SpringContextTest.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/test/java/com/baeldung/exceptiontesting/controller/ExceptionControllerUnitTest.java (97%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/test/java/com/baeldung/persistence/PersistenceTestSuite.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/test/java/com/baeldung/persistence/service/AbstractServicePersistenceIntegrationTest.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/test/java/com/baeldung/util/IDUtil.java (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/test/resources/.gitignore (100%) rename {spring-rest-testing => spring-web-modules/spring-rest-testing}/src/testFile (100%) diff --git a/pom.xml b/pom.xml index 208a0f5d87..d27d7350b3 100644 --- a/pom.xml +++ b/pom.xml @@ -664,7 +664,6 @@ spring-reactor spring-remoting spring-resttemplate - spring-rest-testing spring-roo spring-scheduling @@ -1119,7 +1118,6 @@ spring-reactor spring-remoting spring-resttemplate - spring-rest-testing spring-roo spring-scheduling diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index 6252a6360f..640c7c3660 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -33,6 +33,7 @@ spring-rest-query-language spring-rest-shell spring-rest-simple + spring-rest-testing spring-resttemplate-2 spring-thymeleaf spring-thymeleaf-2 diff --git a/spring-rest-testing/.gitignore b/spring-web-modules/spring-rest-testing/.gitignore similarity index 100% rename from spring-rest-testing/.gitignore rename to spring-web-modules/spring-rest-testing/.gitignore diff --git a/spring-rest-testing/README.md b/spring-web-modules/spring-rest-testing/README.md similarity index 100% rename from spring-rest-testing/README.md rename to spring-web-modules/spring-rest-testing/README.md diff --git a/spring-rest-testing/pom.xml b/spring-web-modules/spring-rest-testing/pom.xml similarity index 99% rename from spring-rest-testing/pom.xml rename to spring-web-modules/spring-rest-testing/pom.xml index 0e947260f4..fea8d25e4d 100644 --- a/spring-rest-testing/pom.xml +++ b/spring-web-modules/spring-rest-testing/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/ExceptionTestingApplication.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/ExceptionTestingApplication.java similarity index 97% rename from spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/ExceptionTestingApplication.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/ExceptionTestingApplication.java index facc300dfa..b6e62b7295 100644 --- a/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/ExceptionTestingApplication.java +++ b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/ExceptionTestingApplication.java @@ -1,25 +1,25 @@ -package com.baeldung.exceptiontesting; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.scheduling.annotation.EnableScheduling; - -/** - * Main Application Class - uses Spring Boot. Just run this as a normal Java - * class to run up a Jetty Server (on http://localhost:8082/spring-rest-full) - * - */ -@EnableScheduling -@EnableAutoConfiguration -@ComponentScan("com.baeldung.exceptiontesting") -@SpringBootApplication -public class ExceptionTestingApplication extends SpringBootServletInitializer { - - public static void main(final String[] args) { - SpringApplication.run(ExceptionTestingApplication.class, args); - } - +package com.baeldung.exceptiontesting; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.scheduling.annotation.EnableScheduling; + +/** + * Main Application Class - uses Spring Boot. Just run this as a normal Java + * class to run up a Jetty Server (on http://localhost:8082/spring-rest-full) + * + */ +@EnableScheduling +@EnableAutoConfiguration +@ComponentScan("com.baeldung.exceptiontesting") +@SpringBootApplication +public class ExceptionTestingApplication extends SpringBootServletInitializer { + + public static void main(final String[] args) { + SpringApplication.run(ExceptionTestingApplication.class, args); + } + } \ No newline at end of file diff --git a/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/controller/ExceptionController.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/controller/ExceptionController.java similarity index 97% rename from spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/controller/ExceptionController.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/controller/ExceptionController.java index 0f458b5f10..6d98337e40 100644 --- a/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/controller/ExceptionController.java +++ b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/controller/ExceptionController.java @@ -1,31 +1,31 @@ -package com.baeldung.exceptiontesting.controller; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - -import com.baeldung.exceptiontesting.exception.BadArgumentsException; -import com.baeldung.exceptiontesting.exception.InternalException; -import com.baeldung.exceptiontesting.exception.ResourceNotFoundException; - -@RestController -public class ExceptionController { - - @GetMapping("/exception/{exception_id}") - public void getSpecificException(@PathVariable("exception_id") String pException) { - if("not_found".equals(pException)) { - throw new ResourceNotFoundException("resource not found"); - } - else if("bad_arguments".equals(pException)) { - throw new BadArgumentsException("bad arguments"); - } - else { - throw new InternalException("internal error"); - } - } - - @GetMapping("/exception/throw") - public void getException() throws Exception { - throw new Exception("error"); - } -} +package com.baeldung.exceptiontesting.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.exceptiontesting.exception.BadArgumentsException; +import com.baeldung.exceptiontesting.exception.InternalException; +import com.baeldung.exceptiontesting.exception.ResourceNotFoundException; + +@RestController +public class ExceptionController { + + @GetMapping("/exception/{exception_id}") + public void getSpecificException(@PathVariable("exception_id") String pException) { + if("not_found".equals(pException)) { + throw new ResourceNotFoundException("resource not found"); + } + else if("bad_arguments".equals(pException)) { + throw new BadArgumentsException("bad arguments"); + } + else { + throw new InternalException("internal error"); + } + } + + @GetMapping("/exception/throw") + public void getException() throws Exception { + throw new Exception("error"); + } +} diff --git a/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/BadArgumentsException.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/BadArgumentsException.java similarity index 96% rename from spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/BadArgumentsException.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/BadArgumentsException.java index 1eb1e6a3c9..1f0e1c1ddb 100644 --- a/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/BadArgumentsException.java +++ b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/BadArgumentsException.java @@ -1,13 +1,13 @@ -package com.baeldung.exceptiontesting.exception; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ResponseStatus; - -@SuppressWarnings("serial") -@ResponseStatus(HttpStatus.BAD_REQUEST) -public class BadArgumentsException extends RuntimeException { - - public BadArgumentsException(String message) { - super(message); - } -} +package com.baeldung.exceptiontesting.exception; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +@SuppressWarnings("serial") +@ResponseStatus(HttpStatus.BAD_REQUEST) +public class BadArgumentsException extends RuntimeException { + + public BadArgumentsException(String message) { + super(message); + } +} diff --git a/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/InternalException.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/InternalException.java similarity index 96% rename from spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/InternalException.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/InternalException.java index 8e9f0f60f3..854d6a57f0 100644 --- a/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/InternalException.java +++ b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/InternalException.java @@ -1,13 +1,13 @@ -package com.baeldung.exceptiontesting.exception; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ResponseStatus; - -@SuppressWarnings("serial") -@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) -public class InternalException extends RuntimeException { - - public InternalException(String message) { - super(message); - } -} +package com.baeldung.exceptiontesting.exception; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +@SuppressWarnings("serial") +@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) +public class InternalException extends RuntimeException { + + public InternalException(String message) { + super(message); + } +} diff --git a/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/ResourceNotFoundException.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/ResourceNotFoundException.java similarity index 96% rename from spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/ResourceNotFoundException.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/ResourceNotFoundException.java index 469d5af96f..6d6e6ef712 100644 --- a/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/ResourceNotFoundException.java +++ b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/exceptiontesting/exception/ResourceNotFoundException.java @@ -1,13 +1,13 @@ -package com.baeldung.exceptiontesting.exception; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ResponseStatus; - -@SuppressWarnings("serial") -@ResponseStatus(HttpStatus.NOT_FOUND) -public class ResourceNotFoundException extends RuntimeException { - - public ResourceNotFoundException(String message) { - super(message); - } -} +package com.baeldung.exceptiontesting.exception; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +@SuppressWarnings("serial") +@ResponseStatus(HttpStatus.NOT_FOUND) +public class ResourceNotFoundException extends RuntimeException { + + public ResourceNotFoundException(String message) { + super(message); + } +} diff --git a/spring-rest-testing/src/main/java/com/baeldung/persistence/IOperations.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/persistence/IOperations.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/persistence/IOperations.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/persistence/IOperations.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/persistence/dao/IFooDao.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/persistence/dao/IFooDao.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/persistence/dao/IFooDao.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/persistence/dao/IFooDao.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/persistence/model/Foo.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/persistence/model/Foo.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/persistence/model/Foo.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/persistence/model/Foo.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/persistence/model/User.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/persistence/model/User.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/persistence/model/User.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/persistence/model/User.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/persistence/service/IFooService.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/persistence/service/IFooService.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/persistence/service/IFooService.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/persistence/service/IFooService.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/persistence/service/common/AbstractService.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/persistence/service/common/AbstractService.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/persistence/service/common/AbstractService.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/persistence/service/common/AbstractService.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/persistence/service/impl/FooService.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/persistence/service/impl/FooService.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/persistence/service/impl/FooService.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/persistence/service/impl/FooService.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/spring/Application.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/spring/Application.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/spring/Application.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/spring/Application.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/spring/PersistenceConfig.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/spring/PersistenceConfig.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/spring/PersistenceConfig.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/spring/PersistenceConfig.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/spring/WebConfig.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/spring/WebConfig.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/spring/WebConfig.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/spring/WebConfig.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/web/controller/FooController.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/controller/FooController.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/web/controller/FooController.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/controller/FooController.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/web/controller/HomeController.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/controller/HomeController.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/web/controller/HomeController.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/controller/HomeController.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/web/controller/RootController.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/controller/RootController.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/web/controller/RootController.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/controller/RootController.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/exception/MyResourceNotFoundException.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/web/metric/ActuatorMetricService.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/metric/ActuatorMetricService.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/web/metric/ActuatorMetricService.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/metric/ActuatorMetricService.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/web/metric/CustomActuatorMetricService.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/metric/CustomActuatorMetricService.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/web/metric/CustomActuatorMetricService.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/metric/CustomActuatorMetricService.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/web/metric/IActuatorMetricService.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/metric/IActuatorMetricService.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/web/metric/IActuatorMetricService.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/metric/IActuatorMetricService.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/web/metric/ICustomActuatorMetricService.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/metric/ICustomActuatorMetricService.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/web/metric/ICustomActuatorMetricService.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/metric/ICustomActuatorMetricService.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/web/metric/IMetricService.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/metric/IMetricService.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/web/metric/IMetricService.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/metric/IMetricService.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/web/metric/MetricFilter.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/metric/MetricFilter.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/web/metric/MetricFilter.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/metric/MetricFilter.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/web/metric/MetricService.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/metric/MetricService.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/web/metric/MetricService.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/metric/MetricService.java diff --git a/spring-rest-testing/src/main/java/com/baeldung/web/util/RestPreconditions.java b/spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/util/RestPreconditions.java similarity index 100% rename from spring-rest-testing/src/main/java/com/baeldung/web/util/RestPreconditions.java rename to spring-web-modules/spring-rest-testing/src/main/java/com/baeldung/web/util/RestPreconditions.java diff --git a/spring-rest-testing/src/main/resources/application.properties b/spring-web-modules/spring-rest-testing/src/main/resources/application.properties similarity index 100% rename from spring-rest-testing/src/main/resources/application.properties rename to spring-web-modules/spring-rest-testing/src/main/resources/application.properties diff --git a/spring-rest-testing/src/main/resources/logback.xml b/spring-web-modules/spring-rest-testing/src/main/resources/logback.xml similarity index 100% rename from spring-rest-testing/src/main/resources/logback.xml rename to spring-web-modules/spring-rest-testing/src/main/resources/logback.xml diff --git a/spring-rest-testing/src/main/resources/persistence-h2.properties b/spring-web-modules/spring-rest-testing/src/main/resources/persistence-h2.properties similarity index 100% rename from spring-rest-testing/src/main/resources/persistence-h2.properties rename to spring-web-modules/spring-rest-testing/src/main/resources/persistence-h2.properties diff --git a/spring-rest-testing/src/main/resources/persistence-mysql.properties b/spring-web-modules/spring-rest-testing/src/main/resources/persistence-mysql.properties similarity index 100% rename from spring-rest-testing/src/main/resources/persistence-mysql.properties rename to spring-web-modules/spring-rest-testing/src/main/resources/persistence-mysql.properties diff --git a/spring-rest-testing/src/main/resources/springDataPersistenceConfig.xml b/spring-web-modules/spring-rest-testing/src/main/resources/springDataPersistenceConfig.xml similarity index 100% rename from spring-rest-testing/src/main/resources/springDataPersistenceConfig.xml rename to spring-web-modules/spring-rest-testing/src/main/resources/springDataPersistenceConfig.xml diff --git a/spring-rest-testing/src/main/webapp/WEB-INF/api-servlet.xml b/spring-web-modules/spring-rest-testing/src/main/webapp/WEB-INF/api-servlet.xml similarity index 100% rename from spring-rest-testing/src/main/webapp/WEB-INF/api-servlet.xml rename to spring-web-modules/spring-rest-testing/src/main/webapp/WEB-INF/api-servlet.xml diff --git a/spring-rest-testing/src/main/webapp/WEB-INF/view/graph.jsp b/spring-web-modules/spring-rest-testing/src/main/webapp/WEB-INF/view/graph.jsp similarity index 100% rename from spring-rest-testing/src/main/webapp/WEB-INF/view/graph.jsp rename to spring-web-modules/spring-rest-testing/src/main/webapp/WEB-INF/view/graph.jsp diff --git a/spring-rest-testing/src/main/webapp/WEB-INF/view/homepage.jsp b/spring-web-modules/spring-rest-testing/src/main/webapp/WEB-INF/view/homepage.jsp similarity index 100% rename from spring-rest-testing/src/main/webapp/WEB-INF/view/homepage.jsp rename to spring-web-modules/spring-rest-testing/src/main/webapp/WEB-INF/view/homepage.jsp diff --git a/spring-rest-testing/src/main/webapp/WEB-INF/web.xml b/spring-web-modules/spring-rest-testing/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-rest-testing/src/main/webapp/WEB-INF/web.xml rename to spring-web-modules/spring-rest-testing/src/main/webapp/WEB-INF/web.xml diff --git a/spring-rest-testing/src/test/java/com/baeldung/Consts.java b/spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/Consts.java similarity index 100% rename from spring-rest-testing/src/test/java/com/baeldung/Consts.java rename to spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/Consts.java diff --git a/spring-rest-testing/src/test/java/com/baeldung/SpringContextIntegrationTest.java b/spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/SpringContextIntegrationTest.java similarity index 100% rename from spring-rest-testing/src/test/java/com/baeldung/SpringContextIntegrationTest.java rename to spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/SpringContextIntegrationTest.java diff --git a/spring-rest-testing/src/test/java/com/baeldung/SpringContextTest.java b/spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-rest-testing/src/test/java/com/baeldung/SpringContextTest.java rename to spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-rest-testing/src/test/java/com/baeldung/exceptiontesting/controller/ExceptionControllerUnitTest.java b/spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/exceptiontesting/controller/ExceptionControllerUnitTest.java similarity index 97% rename from spring-rest-testing/src/test/java/com/baeldung/exceptiontesting/controller/ExceptionControllerUnitTest.java rename to spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/exceptiontesting/controller/ExceptionControllerUnitTest.java index d624efcdd0..8e1eaad977 100644 --- a/spring-rest-testing/src/test/java/com/baeldung/exceptiontesting/controller/ExceptionControllerUnitTest.java +++ b/spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/exceptiontesting/controller/ExceptionControllerUnitTest.java @@ -1,65 +1,65 @@ -package com.baeldung.exceptiontesting.controller; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.http.MediaType; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; - -import com.baeldung.exceptiontesting.controller.ExceptionController; -import com.baeldung.exceptiontesting.exception.BadArgumentsException; -import com.baeldung.exceptiontesting.exception.InternalException; -import com.baeldung.exceptiontesting.exception.ResourceNotFoundException; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; - -@RunWith(SpringRunner.class) -@WebMvcTest(ExceptionController.class) -public class ExceptionControllerUnitTest{ - - @Autowired - private MockMvc mvc; - - @Test - public void givenNotFound_whenGetSpecificException_thenNotFoundCode() throws Exception { - String exceptionParam = "not_found"; - - mvc.perform(get("/exception/{exception_id}", exceptionParam) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isNotFound()) - .andExpect(result -> assertTrue(result.getResolvedException() instanceof ResourceNotFoundException)) - .andExpect(result -> assertEquals("resource not found", result.getResolvedException().getMessage())); - } - - @Test - public void givenBadArguments_whenGetSpecificException_thenBadRequest() throws Exception { - String exceptionParam = "bad_arguments"; - - mvc.perform(get("/exception/{exception_id}", exceptionParam) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isBadRequest()) - .andExpect(result -> assertTrue(result.getResolvedException() instanceof BadArgumentsException)) - .andExpect(result -> assertEquals("bad arguments", result.getResolvedException().getMessage())); - } - - @Test - public void givenOther_whenGetSpecificException_thenInternalServerError() throws Exception { - String exceptionParam = "dummy"; - - mvc.perform(get("/exception/{exception_id}", exceptionParam) - .contentType(MediaType.APPLICATION_JSON)) - .andExpect(status().isInternalServerError()) - .andExpect(result -> assertTrue(result.getResolvedException() instanceof InternalException)) - .andExpect(result -> assertEquals("internal error", result.getResolvedException().getMessage())); - } - - @Test(expected = Exception.class) - public void whenGetException_thenInternalServerError() throws Exception { - mvc.perform(get("/exception/throw") - .contentType(MediaType.APPLICATION_JSON)); - } -} +package com.baeldung.exceptiontesting.controller; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +import com.baeldung.exceptiontesting.controller.ExceptionController; +import com.baeldung.exceptiontesting.exception.BadArgumentsException; +import com.baeldung.exceptiontesting.exception.InternalException; +import com.baeldung.exceptiontesting.exception.ResourceNotFoundException; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +@RunWith(SpringRunner.class) +@WebMvcTest(ExceptionController.class) +public class ExceptionControllerUnitTest{ + + @Autowired + private MockMvc mvc; + + @Test + public void givenNotFound_whenGetSpecificException_thenNotFoundCode() throws Exception { + String exceptionParam = "not_found"; + + mvc.perform(get("/exception/{exception_id}", exceptionParam) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isNotFound()) + .andExpect(result -> assertTrue(result.getResolvedException() instanceof ResourceNotFoundException)) + .andExpect(result -> assertEquals("resource not found", result.getResolvedException().getMessage())); + } + + @Test + public void givenBadArguments_whenGetSpecificException_thenBadRequest() throws Exception { + String exceptionParam = "bad_arguments"; + + mvc.perform(get("/exception/{exception_id}", exceptionParam) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isBadRequest()) + .andExpect(result -> assertTrue(result.getResolvedException() instanceof BadArgumentsException)) + .andExpect(result -> assertEquals("bad arguments", result.getResolvedException().getMessage())); + } + + @Test + public void givenOther_whenGetSpecificException_thenInternalServerError() throws Exception { + String exceptionParam = "dummy"; + + mvc.perform(get("/exception/{exception_id}", exceptionParam) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isInternalServerError()) + .andExpect(result -> assertTrue(result.getResolvedException() instanceof InternalException)) + .andExpect(result -> assertEquals("internal error", result.getResolvedException().getMessage())); + } + + @Test(expected = Exception.class) + public void whenGetException_thenInternalServerError() throws Exception { + mvc.perform(get("/exception/throw") + .contentType(MediaType.APPLICATION_JSON)); + } +} diff --git a/spring-rest-testing/src/test/java/com/baeldung/persistence/PersistenceTestSuite.java b/spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/persistence/PersistenceTestSuite.java similarity index 100% rename from spring-rest-testing/src/test/java/com/baeldung/persistence/PersistenceTestSuite.java rename to spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/persistence/PersistenceTestSuite.java diff --git a/spring-rest-testing/src/test/java/com/baeldung/persistence/service/AbstractServicePersistenceIntegrationTest.java b/spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/persistence/service/AbstractServicePersistenceIntegrationTest.java similarity index 100% rename from spring-rest-testing/src/test/java/com/baeldung/persistence/service/AbstractServicePersistenceIntegrationTest.java rename to spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/persistence/service/AbstractServicePersistenceIntegrationTest.java diff --git a/spring-rest-testing/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java b/spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java similarity index 100% rename from spring-rest-testing/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java rename to spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/persistence/service/FooServicePersistenceIntegrationTest.java diff --git a/spring-rest-testing/src/test/java/com/baeldung/util/IDUtil.java b/spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/util/IDUtil.java similarity index 100% rename from spring-rest-testing/src/test/java/com/baeldung/util/IDUtil.java rename to spring-web-modules/spring-rest-testing/src/test/java/com/baeldung/util/IDUtil.java diff --git a/spring-rest-testing/src/test/resources/.gitignore b/spring-web-modules/spring-rest-testing/src/test/resources/.gitignore similarity index 100% rename from spring-rest-testing/src/test/resources/.gitignore rename to spring-web-modules/spring-rest-testing/src/test/resources/.gitignore diff --git a/spring-rest-testing/src/testFile b/spring-web-modules/spring-rest-testing/src/testFile similarity index 100% rename from spring-rest-testing/src/testFile rename to spring-web-modules/spring-rest-testing/src/testFile From 6daa38007c206871ad2d1af496ab390a8322e84c Mon Sep 17 00:00:00 2001 From: Emmanuel Yasa Date: Tue, 5 Jan 2021 01:32:23 +0800 Subject: [PATCH 203/361] [BAEL-4601] How to convert a Hibernate proxy to a real entity object * Adds Domain Models * Adds Integration Tests --- .../hibernateunproxy/CreditCardPayment.java | 20 +++++ .../jpa/hibernateunproxy/Payment.java | 47 ++++++++++++ .../jpa/hibernateunproxy/PaymentReceipt.java | 53 +++++++++++++ .../jpa/hibernateunproxy/WebUser.java | 42 +++++++++++ .../main/resources/META-INF/persistence.xml | 20 +++++ .../HibernateProxyIntegrationTest.java | 75 +++++++++++++++++++ 6 files changed, 257 insertions(+) create mode 100644 persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/hibernateunproxy/CreditCardPayment.java create mode 100644 persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/hibernateunproxy/Payment.java create mode 100644 persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/hibernateunproxy/PaymentReceipt.java create mode 100644 persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/hibernateunproxy/WebUser.java create mode 100644 persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/hibernateunproxy/HibernateProxyIntegrationTest.java diff --git a/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/hibernateunproxy/CreditCardPayment.java b/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/hibernateunproxy/CreditCardPayment.java new file mode 100644 index 0000000000..6eb41f7ccc --- /dev/null +++ b/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/hibernateunproxy/CreditCardPayment.java @@ -0,0 +1,20 @@ +package com.baeldung.jpa.hibernateunproxy; + +import javax.persistence.Entity; +import java.math.BigDecimal; + +@Entity +public class CreditCardPayment extends Payment { + + private String cardNumber; + + CreditCardPayment(BigDecimal amount, WebUser webUser, String cardNumber) { + this.amount = amount; + this.webUser = webUser; + this.cardNumber = cardNumber; + } + + protected CreditCardPayment() { + } + +} diff --git a/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/hibernateunproxy/Payment.java b/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/hibernateunproxy/Payment.java new file mode 100644 index 0000000000..9e70da5f65 --- /dev/null +++ b/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/hibernateunproxy/Payment.java @@ -0,0 +1,47 @@ +package com.baeldung.jpa.hibernateunproxy; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Inheritance; +import javax.persistence.InheritanceType; +import javax.persistence.ManyToOne; +import java.math.BigDecimal; +import java.util.Objects; + +@Entity +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +public abstract class Payment { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + protected WebUser webUser; + + protected BigDecimal amount; + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Payment payment = (Payment) o; + + return Objects.equals(id, payment.id); + } + + @Override + public int hashCode() { + return id != null ? id.hashCode() : 0; + } + + protected Payment() { + } + +} diff --git a/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/hibernateunproxy/PaymentReceipt.java b/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/hibernateunproxy/PaymentReceipt.java new file mode 100644 index 0000000000..530839eef4 --- /dev/null +++ b/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/hibernateunproxy/PaymentReceipt.java @@ -0,0 +1,53 @@ +package com.baeldung.jpa.hibernateunproxy; + +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.OneToOne; +import java.util.Objects; +import java.util.UUID; + +@Entity +public class PaymentReceipt { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @OneToOne(fetch = FetchType.LAZY) + private Payment payment; + + private String transactionNumber; + + PaymentReceipt(Payment payment) { + this.payment = payment; + this.transactionNumber = UUID.randomUUID().toString(); + } + + public Payment getPayment() { + return payment; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + PaymentReceipt that = (PaymentReceipt) o; + + return Objects.equals(id, that.id); + } + + @Override + public int hashCode() { + return id != null ? id.hashCode() : 0; + } + + protected PaymentReceipt() { + } + +} diff --git a/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/hibernateunproxy/WebUser.java b/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/hibernateunproxy/WebUser.java new file mode 100644 index 0000000000..d3f82bacd4 --- /dev/null +++ b/persistence-modules/java-jpa-3/src/main/java/com/baeldung/jpa/hibernateunproxy/WebUser.java @@ -0,0 +1,42 @@ +package com.baeldung.jpa.hibernateunproxy; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import java.util.Objects; + +@Entity +public class WebUser { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + private String name; + + WebUser(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + WebUser webUser = (WebUser) o; + + return Objects.equals(id, webUser.id); + } + + @Override + public int hashCode() { + return id != null ? id.hashCode() : 0; + } + + protected WebUser() { + } + +} diff --git a/persistence-modules/java-jpa-3/src/main/resources/META-INF/persistence.xml b/persistence-modules/java-jpa-3/src/main/resources/META-INF/persistence.xml index f428fea07b..19ecae8491 100644 --- a/persistence-modules/java-jpa-3/src/main/resources/META-INF/persistence.xml +++ b/persistence-modules/java-jpa-3/src/main/resources/META-INF/persistence.xml @@ -77,4 +77,24 @@ + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.hibernateunproxy.Payment + com.baeldung.jpa.hibernateunproxy.CreditCardPayment + com.baeldung.jpa.hibernateunproxy.PaymentReceipt + com.baeldung.jpa.hibernateunproxy.WebUser + true + + + + + + + + + + + + + diff --git a/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/hibernateunproxy/HibernateProxyIntegrationTest.java b/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/hibernateunproxy/HibernateProxyIntegrationTest.java new file mode 100644 index 0000000000..a831639f5d --- /dev/null +++ b/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/hibernateunproxy/HibernateProxyIntegrationTest.java @@ -0,0 +1,75 @@ +package com.baeldung.jpa.hibernateunproxy; + +import org.hibernate.Hibernate; +import org.hibernate.proxy.HibernateProxy; +import org.junit.Assert; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.Persistence; +import java.math.BigDecimal; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class HibernateProxyIntegrationTest { + + private static EntityManager entityManager; + + @BeforeAll + public static void setup() { + EntityManagerFactory factory = Persistence.createEntityManagerFactory("jpa-h2-hibernate-unproxy"); + entityManager = factory.createEntityManager(); + populateH2DB(); + } + + @Test + public void givenPaymentReceipt_whenAccessingPayment_thenVerifyType() { + PaymentReceipt paymentReceipt = entityManager.find(PaymentReceipt.class, 3L); + Assert.assertEquals(true, paymentReceipt.getPayment() instanceof HibernateProxy); + } + + @Test + public void givenWebUserProxy_whenCreatingPayment_thenExecuteSingleStatement() { + entityManager.getTransaction().begin(); + + WebUser webUser = entityManager.getReference(WebUser.class, 1L); + Payment payment = new CreditCardPayment(new BigDecimal(100), webUser, "CN-1234"); + entityManager.persist(payment); + + entityManager.getTransaction().commit(); + Assert.assertEquals(true, webUser instanceof HibernateProxy); + } + + @Test + public void givenPaymentReceipt_whenCastingPaymentToConcreteClass_thenThrowClassCastException() { + PaymentReceipt paymentReceipt = entityManager.find(PaymentReceipt.class, 3L); + assertThrows(ClassCastException.class, () -> { + CreditCardPayment creditCardPayment = (CreditCardPayment) paymentReceipt.getPayment(); + }); + } + + @Test + public void givenPaymentReceipt_whenPaymentIsUnproxied_thenReturnRealEntityObject() { + PaymentReceipt paymentReceipt = entityManager.find(PaymentReceipt.class, 3L); + Assert.assertEquals(true, Hibernate.unproxy(paymentReceipt.getPayment()) instanceof CreditCardPayment); + } + + private static void populateH2DB() { + entityManager.getTransaction().begin(); + + WebUser webUser = new WebUser("name"); + entityManager.persist(webUser); + + Payment payment = new CreditCardPayment(new BigDecimal(100), webUser, "CN-1234"); + entityManager.persist(payment); + + PaymentReceipt receipt = new PaymentReceipt(payment); + entityManager.persist(receipt); + + entityManager.getTransaction().commit(); + entityManager.clear(); + } + +} From d8c26b6adb3e9a0a147276832a2b7523b4f7ca34 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Mon, 4 Jan 2021 23:01:41 +0100 Subject: [PATCH 204/361] JAVA-3586: Get rid of the overriden commons-lang3.version property --- blade/pom.xml | 1 - .../core-java-arrays-operations-advanced/pom.xml | 2 -- core-java-modules/core-java-arrays-operations-basic/pom.xml | 4 ---- core-java-modules/core-java-arrays-sorting/pom.xml | 4 ---- core-java-modules/core-java-collections-list/pom.xml | 1 - core-java-modules/core-java-lang-2/pom.xml | 1 - core-java-modules/core-java-string-algorithms-2/pom.xml | 1 - core-java-modules/core-java-string-algorithms-3/pom.xml | 1 - core-java-modules/core-java-string-algorithms/pom.xml | 1 - core-java-modules/core-java-string-operations-2/pom.xml | 1 - core-java-modules/core-java-string-operations/pom.xml | 1 - json-2/pom.xml | 1 - libraries-apache-commons/pom.xml | 1 - maven-modules/versions-maven-plugin/original/pom.xml | 1 - persistence-modules/hibernate-annotations/pom.xml | 1 - persistence-modules/hibernate-mapping/pom.xml | 1 - spring-web-modules/spring-mvc-java/pom.xml | 1 - xml/pom.xml | 1 - 18 files changed, 25 deletions(-) diff --git a/blade/pom.xml b/blade/pom.xml index 178d1afb52..458ec40051 100644 --- a/blade/pom.xml +++ b/blade/pom.xml @@ -154,7 +154,6 @@ 2.0.14.RELEASE 4.2.1 - 3.8.1 1.18.4 4.5.6 4.5.6 diff --git a/core-java-modules/core-java-arrays-operations-advanced/pom.xml b/core-java-modules/core-java-arrays-operations-advanced/pom.xml index d73fdcee28..c7ea09c616 100644 --- a/core-java-modules/core-java-arrays-operations-advanced/pom.xml +++ b/core-java-modules/core-java-arrays-operations-advanced/pom.xml @@ -29,8 +29,6 @@ - 3.9 - 3.10.0 \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-operations-basic/pom.xml b/core-java-modules/core-java-arrays-operations-basic/pom.xml index 64856d9b39..dcee6547a0 100644 --- a/core-java-modules/core-java-arrays-operations-basic/pom.xml +++ b/core-java-modules/core-java-arrays-operations-basic/pom.xml @@ -68,11 +68,7 @@ 3.2.0 - - 3.9 - 1.19 - 3.10.0 \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-sorting/pom.xml b/core-java-modules/core-java-arrays-sorting/pom.xml index 9b307870a1..9b900c3de6 100644 --- a/core-java-modules/core-java-arrays-sorting/pom.xml +++ b/core-java-modules/core-java-arrays-sorting/pom.xml @@ -76,12 +76,8 @@ 3.2.0 - - 3.9 28.2-jre - 1.19 - 3.10.0 \ No newline at end of file diff --git a/core-java-modules/core-java-collections-list/pom.xml b/core-java-modules/core-java-collections-list/pom.xml index 509f58ea61..76ca66fe70 100644 --- a/core-java-modules/core-java-collections-list/pom.xml +++ b/core-java-modules/core-java-collections-list/pom.xml @@ -36,7 +36,6 @@ 4.1 - 3.8.1 3.11.1 diff --git a/core-java-modules/core-java-lang-2/pom.xml b/core-java-modules/core-java-lang-2/pom.xml index 5f2d4ec901..d395e8efb1 100644 --- a/core-java-modules/core-java-lang-2/pom.xml +++ b/core-java-modules/core-java-lang-2/pom.xml @@ -69,7 +69,6 @@ 1.19 3.12.2 1.9.4 - 3.10 29.0-jre diff --git a/core-java-modules/core-java-string-algorithms-2/pom.xml b/core-java-modules/core-java-string-algorithms-2/pom.xml index a635cd8022..2a84cebb4c 100644 --- a/core-java-modules/core-java-string-algorithms-2/pom.xml +++ b/core-java-modules/core-java-string-algorithms-2/pom.xml @@ -61,7 +61,6 @@ - 3.8.1 3.6.1 1.2 diff --git a/core-java-modules/core-java-string-algorithms-3/pom.xml b/core-java-modules/core-java-string-algorithms-3/pom.xml index 2725ba84c6..610956588e 100644 --- a/core-java-modules/core-java-string-algorithms-3/pom.xml +++ b/core-java-modules/core-java-string-algorithms-3/pom.xml @@ -59,7 +59,6 @@ - 3.8.1 3.6.1 28.1-jre diff --git a/core-java-modules/core-java-string-algorithms/pom.xml b/core-java-modules/core-java-string-algorithms/pom.xml index 85879d74e2..6ba9ae7bb3 100644 --- a/core-java-modules/core-java-string-algorithms/pom.xml +++ b/core-java-modules/core-java-string-algorithms/pom.xml @@ -65,7 +65,6 @@ - 3.8.1 27.0.1-jre 0.4.0 3.6.1 diff --git a/core-java-modules/core-java-string-operations-2/pom.xml b/core-java-modules/core-java-string-operations-2/pom.xml index db32bf97a1..5865d9a776 100644 --- a/core-java-modules/core-java-string-operations-2/pom.xml +++ b/core-java-modules/core-java-string-operations-2/pom.xml @@ -112,7 +112,6 @@ 3.6.1 2.0.0.Final - 3.8.1 28.2-jre 6.0.2.Final 3.0.0 diff --git a/core-java-modules/core-java-string-operations/pom.xml b/core-java-modules/core-java-string-operations/pom.xml index c5791e929e..9632988392 100644 --- a/core-java-modules/core-java-string-operations/pom.xml +++ b/core-java-modules/core-java-string-operations/pom.xml @@ -60,7 +60,6 @@ - 3.9 3.6.1 1.10 diff --git a/json-2/pom.xml b/json-2/pom.xml index 0bdede3b1a..e27d1c83f6 100644 --- a/json-2/pom.xml +++ b/json-2/pom.xml @@ -114,7 +114,6 @@ 0.9.23 3.11.1 1.9.2 - 3.9 diff --git a/libraries-apache-commons/pom.xml b/libraries-apache-commons/pom.xml index 74adddabcf..08dddac880 100644 --- a/libraries-apache-commons/pom.xml +++ b/libraries-apache-commons/pom.xml @@ -65,7 +65,6 @@ - 3.6 1.1 1.9.3 1.2 diff --git a/maven-modules/versions-maven-plugin/original/pom.xml b/maven-modules/versions-maven-plugin/original/pom.xml index f705dae5c5..c36a5913c2 100644 --- a/maven-modules/versions-maven-plugin/original/pom.xml +++ b/maven-modules/versions-maven-plugin/original/pom.xml @@ -74,7 +74,6 @@ 1.15 2.3 4.0 - 3.0 1.9.1 2.7 diff --git a/persistence-modules/hibernate-annotations/pom.xml b/persistence-modules/hibernate-annotations/pom.xml index 368eee2115..230de2e17e 100644 --- a/persistence-modules/hibernate-annotations/pom.xml +++ b/persistence-modules/hibernate-annotations/pom.xml @@ -62,7 +62,6 @@ 5.4.7.Final 1.4.200 - 3.8.1 true 2.1.7.RELEASE 5.4.7.Final diff --git a/persistence-modules/hibernate-mapping/pom.xml b/persistence-modules/hibernate-mapping/pom.xml index 4eabc5d298..155eefa526 100644 --- a/persistence-modules/hibernate-mapping/pom.xml +++ b/persistence-modules/hibernate-mapping/pom.xml @@ -71,7 +71,6 @@ 3.0.1-b11 1.0.3 1.3 - 3.9 2.6 diff --git a/spring-web-modules/spring-mvc-java/pom.xml b/spring-web-modules/spring-mvc-java/pom.xml index 179ac0fb54..ec302eed57 100644 --- a/spring-web-modules/spring-mvc-java/pom.xml +++ b/spring-web-modules/spring-mvc-java/pom.xml @@ -234,7 +234,6 @@ 19.0 - 3.5 1.3.2 2.5 1.4 diff --git a/xml/pom.xml b/xml/pom.xml index 8b2df41af6..cbad5b37f0 100644 --- a/xml/pom.xml +++ b/xml/pom.xml @@ -379,7 +379,6 @@ 2.3.29 0.9.6 - 3.5 2.4 1.8 From f361ccc834363018a7d5f924e21c88b3ab0a0105 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Tue, 5 Jan 2021 14:10:30 +0100 Subject: [PATCH 205/361] JAVA-3540: Move spring-resttemplate into spring-web-modules --- pom.xml | 2 -- spring-web-modules/pom.xml | 1 + .../spring-resttemplate}/.gitignore | 0 .../spring-resttemplate}/README.md | 0 .../spring-resttemplate}/pom.xml | 2 +- .../baeldung/responseheaders/ResponseHeadersApplication.java | 0 .../controllers/FilterResponseHeaderController.java | 0 .../responseheaders/controllers/ResponseHeaderController.java | 0 .../responseheaders/filter/AddResponseHeaderFilter.java | 0 .../resttemplate/RestTemplateConfigurationApplication.java | 0 .../configuration/CustomClientHttpRequestInterceptor.java | 0 .../configuration/CustomRestTemplateCustomizer.java | 0 .../com/baeldung/resttemplate/configuration/FooController.java | 0 .../baeldung/resttemplate/configuration/HelloController.java | 0 .../com/baeldung/resttemplate/configuration/SpringConfig.java | 0 .../com/baeldung/resttemplate/lists/EmployeeApplication.java | 0 .../com/baeldung/resttemplate/lists/client/EmployeeClient.java | 0 .../resttemplate/lists/controller/EmployeeResource.java | 0 .../main/java/com/baeldung/resttemplate/lists/dto/Employee.java | 0 .../java/com/baeldung/resttemplate/lists/dto/EmployeeList.java | 0 .../baeldung/resttemplate/lists/service/EmployeeService.java | 0 .../src/main/java/com/baeldung/resttemplate/web/dto/Foo.java | 0 .../baeldung/resttemplate/web/exception/NotFoundException.java | 0 .../web/handler/RestTemplateResponseErrorHandler.java | 0 .../src/main/java/com/baeldung/resttemplate/web/model/Bar.java | 0 .../main/java/com/baeldung/resttemplate/web/model/Employee.java | 0 .../baeldung/resttemplate/web/service/BarConsumerService.java | 0 .../com/baeldung/resttemplate/web/service/EmployeeService.java | 0 .../java/com/baeldung/sampleapp/config/MainApplication.java | 0 .../java/com/baeldung/sampleapp/config/RestClientConfig.java | 0 .../src/main/java/com/baeldung/sampleapp/config/WebConfig.java | 0 .../interceptors/RestTemplateHeaderModifierInterceptor.java | 0 .../baeldung/sampleapp/repository/HeavyResourceRepository.java | 0 .../sampleapp/web/controller/BarMappingExamplesController.java | 0 .../baeldung/sampleapp/web/controller/CompanyController.java | 0 .../sampleapp/web/controller/DeferredResultController.java | 0 .../sampleapp/web/controller/HeavyResourceController.java | 0 .../com/baeldung/sampleapp/web/controller/ItemController.java | 0 .../com/baeldung/sampleapp/web/controller/MyFooController.java | 0 .../com/baeldung/sampleapp/web/controller/PactController.java | 0 .../baeldung/sampleapp/web/controller/SimplePostController.java | 0 .../sampleapp/web/controller/redirect/RedirectController.java | 0 .../src/main/java/com/baeldung/sampleapp/web/dto/Company.java | 0 .../src/main/java/com/baeldung/sampleapp/web/dto/Foo.java | 0 .../main/java/com/baeldung/sampleapp/web/dto/HeavyResource.java | 0 .../baeldung/sampleapp/web/dto/HeavyResourceAddressOnly.java | 0 .../sampleapp/web/dto/HeavyResourceAddressPartialUpdate.java | 0 .../src/main/java/com/baeldung/sampleapp/web/dto/Item.java | 0 .../main/java/com/baeldung/sampleapp/web/dto/ItemManager.java | 0 .../src/main/java/com/baeldung/sampleapp/web/dto/PactDto.java | 0 .../src/main/java/com/baeldung/sampleapp/web/dto/Views.java | 0 .../sampleapp/web/exception/ResourceNotFoundException.java | 0 .../src/main/java/com/baeldung/transfer/LoginForm.java | 0 .../java/com/baeldung/web/upload/app/UploadApplication.java | 0 .../baeldung/web/upload/client/MultipartFileUploadClient.java | 0 .../com/baeldung/web/upload/controller/FileServerResource.java | 0 .../src/main/resources/application.properties | 0 .../spring-resttemplate}/src/main/resources/logback.xml | 0 .../src/test/java/com/baeldung/SpringContextTest.java | 0 .../src/test/java/com/baeldung/SpringTestConfig.java | 0 .../src/test/java/com/baeldung/client/Consts.java | 0 .../java/com/baeldung/client/TestRestTemplateBasicLiveTest.java | 0 .../src/test/java/com/baeldung/pact/PactProviderLiveTest.java | 0 .../baeldung/resttemplate/LargeFileDownloadIntegrationTest.java | 0 .../com/baeldung/resttemplate/RestTemplateBasicLiveTest.java | 0 .../java/com/baeldung/resttemplate/RestTemplateLiveTest.java | 0 .../controller/redirect/RedirectControllerIntegrationTest.java | 0 .../RestTemplateResponseErrorHandlerIntegrationTest.java | 0 .../service/EmployeeServiceMockRestServiceServerUnitTest.java | 0 .../java/com/baeldung/web/service/EmployeeServiceUnitTest.java | 0 .../spring-resttemplate}/src/test/resources/.gitignore | 0 .../spring-resttemplate}/src/test/resources/logback-test.xml | 0 72 files changed, 2 insertions(+), 3 deletions(-) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/.gitignore (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/README.md (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/pom.xml (99%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/responseheaders/ResponseHeadersApplication.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/responseheaders/controllers/FilterResponseHeaderController.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/responseheaders/controllers/ResponseHeaderController.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/responseheaders/filter/AddResponseHeaderFilter.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/RestTemplateConfigurationApplication.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/configuration/CustomClientHttpRequestInterceptor.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/configuration/CustomRestTemplateCustomizer.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/configuration/FooController.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/configuration/HelloController.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/configuration/SpringConfig.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/lists/EmployeeApplication.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/lists/controller/EmployeeResource.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/lists/dto/Employee.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/lists/dto/EmployeeList.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/lists/service/EmployeeService.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/web/dto/Foo.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/web/exception/NotFoundException.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/web/handler/RestTemplateResponseErrorHandler.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/web/model/Bar.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/web/model/Employee.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/web/service/BarConsumerService.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/resttemplate/web/service/EmployeeService.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/config/MainApplication.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/config/RestClientConfig.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/config/WebConfig.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/interceptors/RestTemplateHeaderModifierInterceptor.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/repository/HeavyResourceRepository.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/controller/BarMappingExamplesController.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/controller/CompanyController.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/controller/DeferredResultController.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/controller/HeavyResourceController.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/controller/ItemController.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/controller/MyFooController.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/controller/PactController.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/controller/SimplePostController.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/controller/redirect/RedirectController.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/dto/Company.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/dto/Foo.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResource.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressOnly.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressPartialUpdate.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/dto/Item.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/dto/ItemManager.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/dto/PactDto.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/dto/Views.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/sampleapp/web/exception/ResourceNotFoundException.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/transfer/LoginForm.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/web/upload/app/UploadApplication.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/web/upload/client/MultipartFileUploadClient.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/java/com/baeldung/web/upload/controller/FileServerResource.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/resources/application.properties (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/main/resources/logback.xml (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/test/java/com/baeldung/SpringContextTest.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/test/java/com/baeldung/SpringTestConfig.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/test/java/com/baeldung/client/Consts.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/test/java/com/baeldung/client/TestRestTemplateBasicLiveTest.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/test/java/com/baeldung/pact/PactProviderLiveTest.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/test/java/com/baeldung/resttemplate/LargeFileDownloadIntegrationTest.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/test/java/com/baeldung/resttemplate/RestTemplateBasicLiveTest.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/test/java/com/baeldung/web/controller/redirect/RedirectControllerIntegrationTest.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/test/java/com/baeldung/web/handler/RestTemplateResponseErrorHandlerIntegrationTest.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/test/java/com/baeldung/web/service/EmployeeServiceMockRestServiceServerUnitTest.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/test/java/com/baeldung/web/service/EmployeeServiceUnitTest.java (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/test/resources/.gitignore (100%) rename {spring-resttemplate => spring-web-modules/spring-resttemplate}/src/test/resources/logback-test.xml (100%) diff --git a/pom.xml b/pom.xml index d27d7350b3..464134b572 100644 --- a/pom.xml +++ b/pom.xml @@ -663,7 +663,6 @@ spring-reactor spring-remoting - spring-resttemplate spring-roo spring-scheduling @@ -1117,7 +1116,6 @@ spring-reactor spring-remoting - spring-resttemplate spring-roo spring-scheduling diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index 640c7c3660..e00ae3e899 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -34,6 +34,7 @@ spring-rest-shell spring-rest-simple spring-rest-testing + spring-resttemplate spring-resttemplate-2 spring-thymeleaf spring-thymeleaf-2 diff --git a/spring-resttemplate/.gitignore b/spring-web-modules/spring-resttemplate/.gitignore similarity index 100% rename from spring-resttemplate/.gitignore rename to spring-web-modules/spring-resttemplate/.gitignore diff --git a/spring-resttemplate/README.md b/spring-web-modules/spring-resttemplate/README.md similarity index 100% rename from spring-resttemplate/README.md rename to spring-web-modules/spring-resttemplate/README.md diff --git a/spring-resttemplate/pom.xml b/spring-web-modules/spring-resttemplate/pom.xml similarity index 99% rename from spring-resttemplate/pom.xml rename to spring-web-modules/spring-resttemplate/pom.xml index 05660f5210..c0f266fd62 100644 --- a/spring-resttemplate/pom.xml +++ b/spring-web-modules/spring-resttemplate/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-resttemplate/src/main/java/com/baeldung/responseheaders/ResponseHeadersApplication.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/responseheaders/ResponseHeadersApplication.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/responseheaders/ResponseHeadersApplication.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/responseheaders/ResponseHeadersApplication.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/responseheaders/controllers/FilterResponseHeaderController.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/responseheaders/controllers/FilterResponseHeaderController.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/responseheaders/controllers/FilterResponseHeaderController.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/responseheaders/controllers/FilterResponseHeaderController.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/responseheaders/controllers/ResponseHeaderController.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/responseheaders/controllers/ResponseHeaderController.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/responseheaders/controllers/ResponseHeaderController.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/responseheaders/controllers/ResponseHeaderController.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/responseheaders/filter/AddResponseHeaderFilter.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/responseheaders/filter/AddResponseHeaderFilter.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/responseheaders/filter/AddResponseHeaderFilter.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/responseheaders/filter/AddResponseHeaderFilter.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/RestTemplateConfigurationApplication.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/RestTemplateConfigurationApplication.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/RestTemplateConfigurationApplication.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/RestTemplateConfigurationApplication.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/CustomClientHttpRequestInterceptor.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/CustomClientHttpRequestInterceptor.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/CustomClientHttpRequestInterceptor.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/CustomClientHttpRequestInterceptor.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/CustomRestTemplateCustomizer.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/CustomRestTemplateCustomizer.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/CustomRestTemplateCustomizer.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/CustomRestTemplateCustomizer.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/FooController.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/FooController.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/FooController.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/FooController.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/HelloController.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/HelloController.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/HelloController.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/HelloController.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/SpringConfig.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/SpringConfig.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/SpringConfig.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/configuration/SpringConfig.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/EmployeeApplication.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/EmployeeApplication.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/EmployeeApplication.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/EmployeeApplication.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/controller/EmployeeResource.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/controller/EmployeeResource.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/controller/EmployeeResource.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/controller/EmployeeResource.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/dto/Employee.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/dto/Employee.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/dto/Employee.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/dto/Employee.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/dto/EmployeeList.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/dto/EmployeeList.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/dto/EmployeeList.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/dto/EmployeeList.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/service/EmployeeService.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/service/EmployeeService.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/service/EmployeeService.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/service/EmployeeService.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/dto/Foo.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/dto/Foo.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/dto/Foo.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/dto/Foo.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/exception/NotFoundException.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/exception/NotFoundException.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/exception/NotFoundException.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/exception/NotFoundException.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/handler/RestTemplateResponseErrorHandler.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/handler/RestTemplateResponseErrorHandler.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/handler/RestTemplateResponseErrorHandler.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/handler/RestTemplateResponseErrorHandler.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/model/Bar.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/model/Bar.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/model/Bar.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/model/Bar.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/model/Employee.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/model/Employee.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/model/Employee.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/model/Employee.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/service/BarConsumerService.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/service/BarConsumerService.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/service/BarConsumerService.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/service/BarConsumerService.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/service/EmployeeService.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/service/EmployeeService.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/service/EmployeeService.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/service/EmployeeService.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/config/MainApplication.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/config/MainApplication.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/config/MainApplication.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/config/MainApplication.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/config/RestClientConfig.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/config/RestClientConfig.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/config/RestClientConfig.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/config/RestClientConfig.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/config/WebConfig.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/config/WebConfig.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/config/WebConfig.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/config/WebConfig.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/interceptors/RestTemplateHeaderModifierInterceptor.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/interceptors/RestTemplateHeaderModifierInterceptor.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/interceptors/RestTemplateHeaderModifierInterceptor.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/interceptors/RestTemplateHeaderModifierInterceptor.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/repository/HeavyResourceRepository.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/repository/HeavyResourceRepository.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/repository/HeavyResourceRepository.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/repository/HeavyResourceRepository.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/BarMappingExamplesController.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/BarMappingExamplesController.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/BarMappingExamplesController.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/BarMappingExamplesController.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/CompanyController.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/CompanyController.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/CompanyController.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/CompanyController.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/DeferredResultController.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/DeferredResultController.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/DeferredResultController.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/DeferredResultController.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/HeavyResourceController.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/HeavyResourceController.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/HeavyResourceController.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/HeavyResourceController.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/ItemController.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/ItemController.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/ItemController.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/ItemController.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/MyFooController.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/MyFooController.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/MyFooController.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/MyFooController.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/PactController.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/PactController.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/PactController.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/PactController.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/SimplePostController.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/SimplePostController.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/SimplePostController.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/SimplePostController.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/redirect/RedirectController.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/redirect/RedirectController.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/redirect/RedirectController.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/redirect/RedirectController.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/Company.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/Company.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/Company.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/Company.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/Foo.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/Foo.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/Foo.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/Foo.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResource.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResource.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResource.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResource.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressOnly.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressOnly.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressOnly.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressOnly.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressPartialUpdate.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressPartialUpdate.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressPartialUpdate.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/HeavyResourceAddressPartialUpdate.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/Item.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/Item.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/Item.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/Item.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/ItemManager.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/ItemManager.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/ItemManager.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/ItemManager.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/PactDto.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/PactDto.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/PactDto.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/PactDto.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/Views.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/Views.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/Views.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/dto/Views.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/exception/ResourceNotFoundException.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/exception/ResourceNotFoundException.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/exception/ResourceNotFoundException.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/exception/ResourceNotFoundException.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/transfer/LoginForm.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/transfer/LoginForm.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/transfer/LoginForm.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/transfer/LoginForm.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/web/upload/app/UploadApplication.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/app/UploadApplication.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/web/upload/app/UploadApplication.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/app/UploadApplication.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/web/upload/client/MultipartFileUploadClient.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/client/MultipartFileUploadClient.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/web/upload/client/MultipartFileUploadClient.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/client/MultipartFileUploadClient.java diff --git a/spring-resttemplate/src/main/java/com/baeldung/web/upload/controller/FileServerResource.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/controller/FileServerResource.java similarity index 100% rename from spring-resttemplate/src/main/java/com/baeldung/web/upload/controller/FileServerResource.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/controller/FileServerResource.java diff --git a/spring-resttemplate/src/main/resources/application.properties b/spring-web-modules/spring-resttemplate/src/main/resources/application.properties similarity index 100% rename from spring-resttemplate/src/main/resources/application.properties rename to spring-web-modules/spring-resttemplate/src/main/resources/application.properties diff --git a/spring-resttemplate/src/main/resources/logback.xml b/spring-web-modules/spring-resttemplate/src/main/resources/logback.xml similarity index 100% rename from spring-resttemplate/src/main/resources/logback.xml rename to spring-web-modules/spring-resttemplate/src/main/resources/logback.xml diff --git a/spring-resttemplate/src/test/java/com/baeldung/SpringContextTest.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/SpringContextTest.java rename to spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/SpringTestConfig.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/SpringTestConfig.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/SpringTestConfig.java rename to spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/SpringTestConfig.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/client/Consts.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/client/Consts.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/client/Consts.java rename to spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/client/Consts.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/client/TestRestTemplateBasicLiveTest.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/client/TestRestTemplateBasicLiveTest.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/client/TestRestTemplateBasicLiveTest.java rename to spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/client/TestRestTemplateBasicLiveTest.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/pact/PactProviderLiveTest.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/pact/PactProviderLiveTest.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/pact/PactProviderLiveTest.java rename to spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/pact/PactProviderLiveTest.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/resttemplate/LargeFileDownloadIntegrationTest.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/resttemplate/LargeFileDownloadIntegrationTest.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/resttemplate/LargeFileDownloadIntegrationTest.java rename to spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/resttemplate/LargeFileDownloadIntegrationTest.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/resttemplate/RestTemplateBasicLiveTest.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/resttemplate/RestTemplateBasicLiveTest.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/resttemplate/RestTemplateBasicLiveTest.java rename to spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/resttemplate/RestTemplateBasicLiveTest.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java rename to spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/resttemplate/RestTemplateLiveTest.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/web/controller/redirect/RedirectControllerIntegrationTest.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/web/controller/redirect/RedirectControllerIntegrationTest.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/web/controller/redirect/RedirectControllerIntegrationTest.java rename to spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/web/controller/redirect/RedirectControllerIntegrationTest.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/web/handler/RestTemplateResponseErrorHandlerIntegrationTest.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/web/handler/RestTemplateResponseErrorHandlerIntegrationTest.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/web/handler/RestTemplateResponseErrorHandlerIntegrationTest.java rename to spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/web/handler/RestTemplateResponseErrorHandlerIntegrationTest.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/web/service/EmployeeServiceMockRestServiceServerUnitTest.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/web/service/EmployeeServiceMockRestServiceServerUnitTest.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/web/service/EmployeeServiceMockRestServiceServerUnitTest.java rename to spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/web/service/EmployeeServiceMockRestServiceServerUnitTest.java diff --git a/spring-resttemplate/src/test/java/com/baeldung/web/service/EmployeeServiceUnitTest.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/web/service/EmployeeServiceUnitTest.java similarity index 100% rename from spring-resttemplate/src/test/java/com/baeldung/web/service/EmployeeServiceUnitTest.java rename to spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/web/service/EmployeeServiceUnitTest.java diff --git a/spring-resttemplate/src/test/resources/.gitignore b/spring-web-modules/spring-resttemplate/src/test/resources/.gitignore similarity index 100% rename from spring-resttemplate/src/test/resources/.gitignore rename to spring-web-modules/spring-resttemplate/src/test/resources/.gitignore diff --git a/spring-resttemplate/src/test/resources/logback-test.xml b/spring-web-modules/spring-resttemplate/src/test/resources/logback-test.xml similarity index 100% rename from spring-resttemplate/src/test/resources/logback-test.xml rename to spring-web-modules/spring-resttemplate/src/test/resources/logback-test.xml From 3bf9bf40948c308eeaaed1e9dc5943d37bfe98c8 Mon Sep 17 00:00:00 2001 From: Amitabh Tiwari Date: Tue, 5 Jan 2021 20:17:31 +0530 Subject: [PATCH 206/361] Added no roll back example --- .../java/com/baeldung/spring/transaction/CourseService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseService.java b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseService.java index 400c7d4843..05e3f32cee 100644 --- a/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseService.java +++ b/persistence-modules/spring-jpa-2/src/main/java/com/baeldung/spring/transaction/CourseService.java @@ -35,4 +35,10 @@ public class CourseService { } } + @Transactional(noRollbackFor = { SQLException.class }) + public void createCourseDeclarativeWithNoRollBack(Course course) throws SQLException { + courseDao.create(course); + throw new SQLException("Throwing exception for demoing Rollback!!!"); + } + } From af51e73604d96e45b75d2b076d9d0f14a1f125e8 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 5 Jan 2021 23:00:14 +0530 Subject: [PATCH 207/361] JAVA-4011: Moved 1 article from spring-5-security to spring-boot-security --- .../src/main/java/com/baeldung/securityprofile/Application.java | 0 .../java/com/baeldung/securityprofile/ApplicationNoSecurity.java | 0 .../java/com/baeldung/securityprofile/ApplicationSecurity.java | 0 .../java/com/baeldung/securityprofile/EmployeeController.java | 0 .../securityprofile/EmployeeControllerNoSecurityUnitTest.java | 0 .../com/baeldung/securityprofile/EmployeeControllerUnitTest.java | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename {spring-security-modules/spring-5-security => spring-boot-modules/spring-boot-security}/src/main/java/com/baeldung/securityprofile/Application.java (100%) rename {spring-security-modules/spring-5-security => spring-boot-modules/spring-boot-security}/src/main/java/com/baeldung/securityprofile/ApplicationNoSecurity.java (100%) rename {spring-security-modules/spring-5-security => spring-boot-modules/spring-boot-security}/src/main/java/com/baeldung/securityprofile/ApplicationSecurity.java (100%) rename {spring-security-modules/spring-5-security => spring-boot-modules/spring-boot-security}/src/main/java/com/baeldung/securityprofile/EmployeeController.java (100%) rename {spring-security-modules/spring-5-security => spring-boot-modules/spring-boot-security}/src/test/java/com/baeldung/securityprofile/EmployeeControllerNoSecurityUnitTest.java (100%) rename {spring-security-modules/spring-5-security => spring-boot-modules/spring-boot-security}/src/test/java/com/baeldung/securityprofile/EmployeeControllerUnitTest.java (100%) diff --git a/spring-security-modules/spring-5-security/src/main/java/com/baeldung/securityprofile/Application.java b/spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/securityprofile/Application.java similarity index 100% rename from spring-security-modules/spring-5-security/src/main/java/com/baeldung/securityprofile/Application.java rename to spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/securityprofile/Application.java diff --git a/spring-security-modules/spring-5-security/src/main/java/com/baeldung/securityprofile/ApplicationNoSecurity.java b/spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/securityprofile/ApplicationNoSecurity.java similarity index 100% rename from spring-security-modules/spring-5-security/src/main/java/com/baeldung/securityprofile/ApplicationNoSecurity.java rename to spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/securityprofile/ApplicationNoSecurity.java diff --git a/spring-security-modules/spring-5-security/src/main/java/com/baeldung/securityprofile/ApplicationSecurity.java b/spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/securityprofile/ApplicationSecurity.java similarity index 100% rename from spring-security-modules/spring-5-security/src/main/java/com/baeldung/securityprofile/ApplicationSecurity.java rename to spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/securityprofile/ApplicationSecurity.java diff --git a/spring-security-modules/spring-5-security/src/main/java/com/baeldung/securityprofile/EmployeeController.java b/spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/securityprofile/EmployeeController.java similarity index 100% rename from spring-security-modules/spring-5-security/src/main/java/com/baeldung/securityprofile/EmployeeController.java rename to spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/securityprofile/EmployeeController.java diff --git a/spring-security-modules/spring-5-security/src/test/java/com/baeldung/securityprofile/EmployeeControllerNoSecurityUnitTest.java b/spring-boot-modules/spring-boot-security/src/test/java/com/baeldung/securityprofile/EmployeeControllerNoSecurityUnitTest.java similarity index 100% rename from spring-security-modules/spring-5-security/src/test/java/com/baeldung/securityprofile/EmployeeControllerNoSecurityUnitTest.java rename to spring-boot-modules/spring-boot-security/src/test/java/com/baeldung/securityprofile/EmployeeControllerNoSecurityUnitTest.java diff --git a/spring-security-modules/spring-5-security/src/test/java/com/baeldung/securityprofile/EmployeeControllerUnitTest.java b/spring-boot-modules/spring-boot-security/src/test/java/com/baeldung/securityprofile/EmployeeControllerUnitTest.java similarity index 100% rename from spring-security-modules/spring-5-security/src/test/java/com/baeldung/securityprofile/EmployeeControllerUnitTest.java rename to spring-boot-modules/spring-boot-security/src/test/java/com/baeldung/securityprofile/EmployeeControllerUnitTest.java From 5fcec971af06230b6fd077f417b0ae30e4a901d8 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 5 Jan 2021 23:01:01 +0530 Subject: [PATCH 208/361] JAVA-4011: README changes --- spring-boot-modules/spring-boot-security/README.md | 2 ++ spring-security-modules/spring-5-security/README.md | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-security/README.md b/spring-boot-modules/spring-boot-security/README.md index 7229ba0f4a..2c9d37eac0 100644 --- a/spring-boot-modules/spring-boot-security/README.md +++ b/spring-boot-modules/spring-boot-security/README.md @@ -8,6 +8,8 @@ This module contains articles about Spring Boot Security - [Spring Security for Spring Boot Integration Tests](https://www.baeldung.com/spring-security-integration-tests) - [Introduction to Spring Security Taglibs](https://www.baeldung.com/spring-security-taglibs) - [Guide to @CurrentSecurityContext in Spring Security](https://www.baeldung.com/spring-currentsecuritycontext) +- [Disable Security for a Profile in Spring Boot](https://www.baeldung.com/spring-security-disable-profile) + ### Spring Boot Security Auto-Configuration diff --git a/spring-security-modules/spring-5-security/README.md b/spring-security-modules/spring-5-security/README.md index 6847d4bf5c..1917d347fb 100644 --- a/spring-security-modules/spring-5-security/README.md +++ b/spring-security-modules/spring-5-security/README.md @@ -9,6 +9,5 @@ This module contains articles about Spring Security 5 - [New Password Storage In Spring Security 5](https://www.baeldung.com/spring-security-5-password-storage) - [Default Password Encoder in Spring Security 5](https://www.baeldung.com/spring-security-5-default-password-encoder) - [Guide to the AuthenticationManagerResolver in Spring Security](https://www.baeldung.com/spring-security-authenticationmanagerresolver) -- [Disable Security for a Profile in Spring Boot](https://www.baeldung.com/spring-security-disable-profile) - [Manual Logout With Spring Security](https://www.baeldung.com/spring-security-manual-logout) - [How to Disable Spring Security Logout Redirects](https://www.baeldung.com/spring-security-disable-logout-redirects) From bfa1d207dfc8d7271a4e48e070e4d6714e2f8d9b Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 6 Jan 2021 15:03:21 +0800 Subject: [PATCH 209/361] Update README.md --- core-java-modules/core-java-char/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-char/README.md b/core-java-modules/core-java-char/README.md index 71f8e943aa..fd79da15ab 100644 --- a/core-java-modules/core-java-char/README.md +++ b/core-java-modules/core-java-char/README.md @@ -3,4 +3,4 @@ This module contains articles about Java Character Class ### Relevant Articles: -- Character#isAlphabetic vs Character#isLetter +- [Character#isAlphabetic vs Character#isLetter](https://www.baeldung.com/java-character-isletter-isalphabetic) From 6ba3be6c81535b1e8976beae5a98dfac3de9da12 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 6 Jan 2021 15:21:03 +0800 Subject: [PATCH 210/361] Update README.md --- spring-boot-modules/spring-boot-artifacts-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-artifacts-2/README.md b/spring-boot-modules/spring-boot-artifacts-2/README.md index 80e3d95d14..35f9cfab32 100644 --- a/spring-boot-modules/spring-boot-artifacts-2/README.md +++ b/spring-boot-modules/spring-boot-artifacts-2/README.md @@ -4,4 +4,4 @@ This module contains articles about configuring the Spring Boot build process 2. ### Relevant Articles: -TBD \ No newline at end of file +- [Difference Between spring-boot:repackage and Maven package](https://www.baeldung.com/spring-boot-repackage-vs-mvn-package) From cc6a351836ee0f29467b45348f4e9aaa521a4076 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 6 Jan 2021 15:23:20 +0800 Subject: [PATCH 211/361] Update README.md --- core-java-modules/core-java-11-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-11-2/README.md b/core-java-modules/core-java-11-2/README.md index 834f310fce..c87936b07d 100644 --- a/core-java-modules/core-java-11-2/README.md +++ b/core-java-modules/core-java-11-2/README.md @@ -6,3 +6,4 @@ This module contains articles about Java 11 core features - [Guide to Java 8 Optional](https://www.baeldung.com/java-optional) - [Guide to Java Reflection](http://www.baeldung.com/java-reflection) - [Guide to Java 8’s Collectors](https://www.baeldung.com/java-8-collectors) +- [New Features in Java 11](https://www.baeldung.com/java-11-new-features) From eedd1fd70bfab9a73417c099afc0d7f5d4db4cef Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 6 Jan 2021 15:25:50 +0800 Subject: [PATCH 212/361] Update README.md --- core-java-modules/core-java-12/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-12/README.md b/core-java-modules/core-java-12/README.md index 6c603e4dea..c28df26c6f 100644 --- a/core-java-modules/core-java-12/README.md +++ b/core-java-modules/core-java-12/README.md @@ -2,3 +2,4 @@ - [String API Updates in Java 12](https://www.baeldung.com/java12-string-api) +- [Java 12 New Features](https://www.baeldung.com/java-12-new-features) From 108522e190261b1795fd55b9beb3c94b81af84fd Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Wed, 6 Jan 2021 11:16:55 +0100 Subject: [PATCH 213/361] JAVA-3541: Move spring-5-mvc into spring-web-modules --- pom.xml | 2 - spring-web-modules/pom.xml | 1 + .../spring-5-mvc}/.gitignore | 0 .../spring-5-mvc}/README.md | 0 .../spring-5-mvc}/pom.xml | 3 +- .../src/main/java/com/baeldung/Constants.java | 0 .../java/com/baeldung/Spring5Application.java | 0 .../com/baeldung/html/HtmlApplication.java | 0 .../com/baeldung/html/HtmlController.java | 0 .../java/com/baeldung/idc/Application.java | 0 .../src/main/java/com/baeldung/idc/Book.java | 0 .../java/com/baeldung/idc/BookController.java | 0 .../java/com/baeldung/idc/BookOperations.java | 0 .../java/com/baeldung/idc/BookRepository.java | 0 .../src/main/java/com/baeldung/model/Foo.java | 0 .../baeldung/persistence/DataSetupBean.java | 0 .../baeldung/persistence/FooRepository.java | 0 .../java/com/baeldung/web/FooController.java | 130 +++++++++--------- .../web/ResponseBodyEmitterController.java | 0 .../baeldung/web/SseEmitterController.java | 0 .../web/StreamingResponseBodyController.java | 0 .../src/main/resources/application.properties | 0 .../src/main/resources/logback.xml | 0 .../src/main/webapp/WEB-INF/jsp/index.jsp | 0 .../src/main/webapp/WEB-INF/web.xml | 0 .../src/test/java/com/baeldung/LiveTest.java | 0 .../Spring5ApplicationIntegrationTest.java | 0 .../com/baeldung/html/HtmlControllerTest.java | 0 28 files changed, 67 insertions(+), 69 deletions(-) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/.gitignore (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/README.md (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/pom.xml (97%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/Constants.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/Spring5Application.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/html/HtmlApplication.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/html/HtmlController.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/idc/Application.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/idc/Book.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/idc/BookController.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/idc/BookOperations.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/idc/BookRepository.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/model/Foo.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/persistence/DataSetupBean.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/persistence/FooRepository.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/web/FooController.java (97%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/web/ResponseBodyEmitterController.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/web/SseEmitterController.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/java/com/baeldung/web/StreamingResponseBodyController.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/resources/application.properties (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/resources/logback.xml (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/webapp/WEB-INF/jsp/index.jsp (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/main/webapp/WEB-INF/web.xml (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/test/java/com/baeldung/LiveTest.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/test/java/com/baeldung/Spring5ApplicationIntegrationTest.java (100%) rename {spring-5-mvc => spring-web-modules/spring-5-mvc}/src/test/java/com/baeldung/html/HtmlControllerTest.java (100%) diff --git a/pom.xml b/pom.xml index 464134b572..3eca22c173 100644 --- a/pom.xml +++ b/pom.xml @@ -601,7 +601,6 @@ spring-5 spring-5-data-reactive - spring-5-mvc spring-5-reactive spring-5-reactive-2 spring-5-reactive-client @@ -1055,7 +1054,6 @@ spring-5 spring-5-data-reactive - spring-5-mvc spring-5-reactive spring-5-reactive-2 spring-5-reactive-client diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index e00ae3e899..cc2ffcf762 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -14,6 +14,7 @@ + spring-5-mvc spring-mvc-basics spring-mvc-basics-2 spring-mvc-basics-3 diff --git a/spring-5-mvc/.gitignore b/spring-web-modules/spring-5-mvc/.gitignore similarity index 100% rename from spring-5-mvc/.gitignore rename to spring-web-modules/spring-5-mvc/.gitignore diff --git a/spring-5-mvc/README.md b/spring-web-modules/spring-5-mvc/README.md similarity index 100% rename from spring-5-mvc/README.md rename to spring-web-modules/spring-5-mvc/README.md diff --git a/spring-5-mvc/pom.xml b/spring-web-modules/spring-5-mvc/pom.xml similarity index 97% rename from spring-5-mvc/pom.xml rename to spring-web-modules/spring-5-mvc/pom.xml index 39fcd22824..ddcce8207b 100644 --- a/spring-5-mvc/pom.xml +++ b/spring-web-modules/spring-5-mvc/pom.xml @@ -12,8 +12,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 - + ../../parent-boot-2 diff --git a/spring-5-mvc/src/main/java/com/baeldung/Constants.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/Constants.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/Constants.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/Constants.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/Spring5Application.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/Spring5Application.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/Spring5Application.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/Spring5Application.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/html/HtmlApplication.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/html/HtmlApplication.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/html/HtmlApplication.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/html/HtmlApplication.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/html/HtmlController.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/html/HtmlController.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/html/HtmlController.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/html/HtmlController.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/idc/Application.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/Application.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/idc/Application.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/Application.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/idc/Book.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/Book.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/idc/Book.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/Book.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/idc/BookController.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/BookController.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/idc/BookController.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/BookController.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/idc/BookOperations.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/BookOperations.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/idc/BookOperations.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/BookOperations.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/idc/BookRepository.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/BookRepository.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/idc/BookRepository.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/idc/BookRepository.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/model/Foo.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/model/Foo.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/model/Foo.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/model/Foo.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/persistence/DataSetupBean.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/persistence/DataSetupBean.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/persistence/DataSetupBean.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/persistence/DataSetupBean.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/persistence/FooRepository.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/persistence/FooRepository.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/persistence/FooRepository.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/persistence/FooRepository.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/web/FooController.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/FooController.java similarity index 97% rename from spring-5-mvc/src/main/java/com/baeldung/web/FooController.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/FooController.java index 137864cddd..8d8e03bbaf 100644 --- a/spring-5-mvc/src/main/java/com/baeldung/web/FooController.java +++ b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/FooController.java @@ -1,66 +1,66 @@ -package com.baeldung.web; - -import java.util.List; - -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.PageRequest; -import org.springframework.http.HttpStatus; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.server.ResponseStatusException; - -import com.baeldung.model.Foo; -import com.baeldung.persistence.FooRepository; - -@RestController -public class FooController { - - @Autowired - private FooRepository repo; - - // API - read - - @GetMapping("/foos/{id}") - @Validated - public Foo findById(@PathVariable @Min(0) final long id) { - return repo.findById(id).orElse(null); - } - - @GetMapping("/foos") - public List findAll() { - return repo.findAll(); - } - - @GetMapping( value="/foos", params = { "page", "size" }) - @Validated - public List findPaginated(@RequestParam("page") @Min(0) final int page, @Max(100) @RequestParam("size") final int size) { - return repo.findAll(PageRequest.of(page, size)).getContent(); - } - - // API - write - - @PutMapping("/foos/{id}") - @ResponseStatus(HttpStatus.OK) - public Foo update(@PathVariable("id") final String id, @RequestBody final Foo foo) { - return foo; - } - - @PostMapping("/foos") - @ResponseStatus(HttpStatus.CREATED) - public void create( @RequestBody final Foo foo) { - if (null == foo || null == foo.getName()) { - throw new ResponseStatusException(HttpStatus.BAD_REQUEST," 'name' is required"); - } - repo.save(foo); - } +package com.baeldung.web; + +import java.util.List; + +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.http.HttpStatus; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ResponseStatusException; + +import com.baeldung.model.Foo; +import com.baeldung.persistence.FooRepository; + +@RestController +public class FooController { + + @Autowired + private FooRepository repo; + + // API - read + + @GetMapping("/foos/{id}") + @Validated + public Foo findById(@PathVariable @Min(0) final long id) { + return repo.findById(id).orElse(null); + } + + @GetMapping("/foos") + public List findAll() { + return repo.findAll(); + } + + @GetMapping( value="/foos", params = { "page", "size" }) + @Validated + public List findPaginated(@RequestParam("page") @Min(0) final int page, @Max(100) @RequestParam("size") final int size) { + return repo.findAll(PageRequest.of(page, size)).getContent(); + } + + // API - write + + @PutMapping("/foos/{id}") + @ResponseStatus(HttpStatus.OK) + public Foo update(@PathVariable("id") final String id, @RequestBody final Foo foo) { + return foo; + } + + @PostMapping("/foos") + @ResponseStatus(HttpStatus.CREATED) + public void create( @RequestBody final Foo foo) { + if (null == foo || null == foo.getName()) { + throw new ResponseStatusException(HttpStatus.BAD_REQUEST," 'name' is required"); + } + repo.save(foo); + } } \ No newline at end of file diff --git a/spring-5-mvc/src/main/java/com/baeldung/web/ResponseBodyEmitterController.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/ResponseBodyEmitterController.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/web/ResponseBodyEmitterController.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/ResponseBodyEmitterController.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/web/SseEmitterController.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/SseEmitterController.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/web/SseEmitterController.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/SseEmitterController.java diff --git a/spring-5-mvc/src/main/java/com/baeldung/web/StreamingResponseBodyController.java b/spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/StreamingResponseBodyController.java similarity index 100% rename from spring-5-mvc/src/main/java/com/baeldung/web/StreamingResponseBodyController.java rename to spring-web-modules/spring-5-mvc/src/main/java/com/baeldung/web/StreamingResponseBodyController.java diff --git a/spring-5-mvc/src/main/resources/application.properties b/spring-web-modules/spring-5-mvc/src/main/resources/application.properties similarity index 100% rename from spring-5-mvc/src/main/resources/application.properties rename to spring-web-modules/spring-5-mvc/src/main/resources/application.properties diff --git a/spring-5-mvc/src/main/resources/logback.xml b/spring-web-modules/spring-5-mvc/src/main/resources/logback.xml similarity index 100% rename from spring-5-mvc/src/main/resources/logback.xml rename to spring-web-modules/spring-5-mvc/src/main/resources/logback.xml diff --git a/spring-5-mvc/src/main/webapp/WEB-INF/jsp/index.jsp b/spring-web-modules/spring-5-mvc/src/main/webapp/WEB-INF/jsp/index.jsp similarity index 100% rename from spring-5-mvc/src/main/webapp/WEB-INF/jsp/index.jsp rename to spring-web-modules/spring-5-mvc/src/main/webapp/WEB-INF/jsp/index.jsp diff --git a/spring-5-mvc/src/main/webapp/WEB-INF/web.xml b/spring-web-modules/spring-5-mvc/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-5-mvc/src/main/webapp/WEB-INF/web.xml rename to spring-web-modules/spring-5-mvc/src/main/webapp/WEB-INF/web.xml diff --git a/spring-5-mvc/src/test/java/com/baeldung/LiveTest.java b/spring-web-modules/spring-5-mvc/src/test/java/com/baeldung/LiveTest.java similarity index 100% rename from spring-5-mvc/src/test/java/com/baeldung/LiveTest.java rename to spring-web-modules/spring-5-mvc/src/test/java/com/baeldung/LiveTest.java diff --git a/spring-5-mvc/src/test/java/com/baeldung/Spring5ApplicationIntegrationTest.java b/spring-web-modules/spring-5-mvc/src/test/java/com/baeldung/Spring5ApplicationIntegrationTest.java similarity index 100% rename from spring-5-mvc/src/test/java/com/baeldung/Spring5ApplicationIntegrationTest.java rename to spring-web-modules/spring-5-mvc/src/test/java/com/baeldung/Spring5ApplicationIntegrationTest.java diff --git a/spring-5-mvc/src/test/java/com/baeldung/html/HtmlControllerTest.java b/spring-web-modules/spring-5-mvc/src/test/java/com/baeldung/html/HtmlControllerTest.java similarity index 100% rename from spring-5-mvc/src/test/java/com/baeldung/html/HtmlControllerTest.java rename to spring-web-modules/spring-5-mvc/src/test/java/com/baeldung/html/HtmlControllerTest.java From 83664977f035d37e14f4a075330fa2fb71d66216 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Wed, 6 Jan 2021 11:48:27 -0300 Subject: [PATCH 214/361] Updated deprecated ConfigFileApplicationContextInitializer usage, now using ConfigDataApplicationContextInitializer --- .../properties/yamllist/YamlComplexListsUnitTest.java | 4 ++-- .../baeldung/properties/yamllist/YamlSimpleListUnitTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/yamllist/YamlComplexListsUnitTest.java b/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/yamllist/YamlComplexListsUnitTest.java index 6dc5d61d09..ce9ec38551 100644 --- a/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/yamllist/YamlComplexListsUnitTest.java +++ b/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/yamllist/YamlComplexListsUnitTest.java @@ -6,14 +6,14 @@ 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.ConfigFileApplicationContextInitializer; +import org.springframework.boot.test.context.ConfigDataApplicationContextInitializer; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; import com.baeldung.properties.yamllist.pojo.ApplicationProps; @ExtendWith(SpringExtension.class) -@ContextConfiguration(initializers = ConfigFileApplicationContextInitializer.class) +@ContextConfiguration(initializers = ConfigDataApplicationContextInitializer.class) @EnableConfigurationProperties(value = ApplicationProps.class) class YamlComplexListsUnitTest { diff --git a/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/yamllist/YamlSimpleListUnitTest.java b/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/yamllist/YamlSimpleListUnitTest.java index 475a73c7d7..5315c7b9bc 100644 --- a/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/yamllist/YamlSimpleListUnitTest.java +++ b/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/yamllist/YamlSimpleListUnitTest.java @@ -6,14 +6,14 @@ 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.ConfigFileApplicationContextInitializer; +import org.springframework.boot.test.context.ConfigDataApplicationContextInitializer; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; import com.baeldung.properties.yamllist.pojo.ApplicationProps; @ExtendWith(SpringExtension.class) -@ContextConfiguration(initializers = ConfigFileApplicationContextInitializer.class) +@ContextConfiguration(initializers = ConfigDataApplicationContextInitializer.class) @EnableConfigurationProperties(value = ApplicationProps.class) class YamlSimpleListUnitTest { From 1112f95497583488dbdf9f13f9feb38a401be2ad Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Wed, 6 Jan 2021 11:49:12 -0300 Subject: [PATCH 215/361] updated deprecated Assert. method usage. This is not related to this 2.4.0 boot update --- .../value/defaults/ValuesWithDefaultsApp.java | 14 +++++++------- .../properties/lists/ListsPropertiesUnitTest.java | 5 +++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/spring-boot-modules/spring-boot-properties-2/src/main/java/com/baeldung/properties/value/defaults/ValuesWithDefaultsApp.java b/spring-boot-modules/spring-boot-properties-2/src/main/java/com/baeldung/properties/value/defaults/ValuesWithDefaultsApp.java index 72fa0e03c0..2a2b535be7 100644 --- a/spring-boot-modules/spring-boot-properties-2/src/main/java/com/baeldung/properties/value/defaults/ValuesWithDefaultsApp.java +++ b/spring-boot-modules/spring-boot-properties-2/src/main/java/com/baeldung/properties/value/defaults/ValuesWithDefaultsApp.java @@ -51,21 +51,21 @@ public class ValuesWithDefaultsApp { @PostConstruct public void afterInitialize() { // strings - Assert.isTrue(stringWithDefaultValue.equals("my default value")); - Assert.isTrue(stringWithBlankDefaultValue.equals("")); + Assert.isTrue(stringWithDefaultValue.equals("my default value"), "unexpected value for stringWithDefaultValue"); + Assert.isTrue(stringWithBlankDefaultValue.equals(""), "unexpected value for stringWithBlankDefaultValue"); // other primitives - Assert.isTrue(booleanWithDefaultValue); - Assert.isTrue(intWithDefaultValue == 42); + Assert.isTrue(booleanWithDefaultValue, "unexpected value for booleanWithDefaultValue"); + Assert.isTrue(intWithDefaultValue == 42, "unexpected value for intWithDefaultValue"); // arrays List stringListValues = Arrays.asList("one", "two", "three"); - Assert.isTrue(Arrays.asList(stringArrayWithDefaults).containsAll(stringListValues)); + Assert.isTrue(Arrays.asList(stringArrayWithDefaults).containsAll(stringListValues), "unexpected value for stringArrayWithDefaults"); List intListValues = Arrays.asList(1, 2, 3); - Assert.isTrue(Arrays.asList(ArrayUtils.toObject(intArrayWithDefaults)).containsAll(intListValues)); + Assert.isTrue(Arrays.asList(ArrayUtils.toObject(intArrayWithDefaults)).containsAll(intListValues), "unexpected value for intArrayWithDefaults"); // SpEL - Assert.isTrue(spelWithDefaultValue.equals("my default system property value")); + Assert.isTrue(spelWithDefaultValue.equals("my default system property value"), "unexpected value for spelWithDefaultValue"); } } diff --git a/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/lists/ListsPropertiesUnitTest.java b/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/lists/ListsPropertiesUnitTest.java index 60ba4cc108..1abb643d75 100644 --- a/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/lists/ListsPropertiesUnitTest.java +++ b/spring-boot-modules/spring-boot-properties-2/src/test/java/com/baeldung/properties/lists/ListsPropertiesUnitTest.java @@ -13,6 +13,7 @@ import java.util.Collections; import java.util.List; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertArrayEquals; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = SpringListPropertiesApplication.class) @@ -47,7 +48,7 @@ public class ListsPropertiesUnitTest { @Test public void whenContextIsInitialized_thenInjectedArrayContainsExpectedValues() { - assertEquals(new String[] {"Baeldung", "dot", "com"}, arrayOfStrings); + assertArrayEquals(new String[] {"Baeldung", "dot", "com"}, arrayOfStrings); } @Test @@ -82,7 +83,7 @@ public class ListsPropertiesUnitTest { String[] arrayOfStrings = environment.getProperty("arrayOfStrings", String[].class); List listOfStrings = (List)environment.getProperty("arrayOfStrings", List.class); - assertEquals(new String[] {"Baeldung", "dot", "com"}, arrayOfStrings); + assertArrayEquals(new String[] {"Baeldung", "dot", "com"}, arrayOfStrings); assertEquals(Arrays.asList("Baeldung", "dot", "com"), listOfStrings); } } From 567e9109038dcdd0bc2536c3d4f24c7622d74120 Mon Sep 17 00:00:00 2001 From: MeenaGawande <45625809+MeenaGawande@users.noreply.github.com> Date: Wed, 6 Jan 2021 23:36:07 +0530 Subject: [PATCH 216/361] [BAEL-4720] Java File.separator vs File.pathSeparator (#10330) * [BAEL-4720] Java File.separator vs File.pathSeparator Removed src code and modified junit tests * [BAEL-4720] Java File.separator vs File.pathSeparator Code formatting: Removed extra spaces in the code * [BAEL-4720] Java File.separator vs File.pathSeparator Added more junit tests * [BAEL-4720] Java File.separator vs File.pathSeparator Added new module core-java-io4 and moved the code from core-java-io3 module. Co-authored-by: MeenaGawande --- core-java-modules/core-java-io-4/.gitignore | 2 + core-java-modules/core-java-io-4/README.md | 8 +++ core-java-modules/core-java-io-4/pom.xml | 52 +++++++++++++++ .../FilePathSeparatorUnitTest.java | 63 +++++++++++++++++++ .../fileseparator/FileSeparatorUnitTest.java | 63 +++++++++++++++++++ core-java-modules/pom.xml | 1 + 6 files changed, 189 insertions(+) create mode 100644 core-java-modules/core-java-io-4/.gitignore create mode 100644 core-java-modules/core-java-io-4/README.md create mode 100644 core-java-modules/core-java-io-4/pom.xml create mode 100644 core-java-modules/core-java-io-4/src/test/java/com/baeldung/fileseparator/FilePathSeparatorUnitTest.java create mode 100644 core-java-modules/core-java-io-4/src/test/java/com/baeldung/fileseparator/FileSeparatorUnitTest.java diff --git a/core-java-modules/core-java-io-4/.gitignore b/core-java-modules/core-java-io-4/.gitignore new file mode 100644 index 0000000000..0c0cd871c5 --- /dev/null +++ b/core-java-modules/core-java-io-4/.gitignore @@ -0,0 +1,2 @@ +test-link* +0.* \ No newline at end of file diff --git a/core-java-modules/core-java-io-4/README.md b/core-java-modules/core-java-io-4/README.md new file mode 100644 index 0000000000..7cc38bb9fe --- /dev/null +++ b/core-java-modules/core-java-io-4/README.md @@ -0,0 +1,8 @@ +## Core Java IO + +This module contains articles about core Java input and output (IO) + +### Relevant Articles: + +- [Java File Separator vs File Path Separator] +- [[<-- Prev]](/core-java-modules/core-java-io-3) diff --git a/core-java-modules/core-java-io-4/pom.xml b/core-java-modules/core-java-io-4/pom.xml new file mode 100644 index 0000000000..ee31b35ba9 --- /dev/null +++ b/core-java-modules/core-java-io-4/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + core-java-io-4 + 0.1.0-SNAPSHOT + core-java-io-4 + jar + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + ../ + + + + + + commons-io + commons-io + ${commons-io.version} + + + + log4j + log4j + ${log4j.version} + + + org.slf4j + log4j-over-slf4j + ${org.slf4j.version} + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + + + + 3.6.1 + + + \ No newline at end of file diff --git a/core-java-modules/core-java-io-4/src/test/java/com/baeldung/fileseparator/FilePathSeparatorUnitTest.java b/core-java-modules/core-java-io-4/src/test/java/com/baeldung/fileseparator/FilePathSeparatorUnitTest.java new file mode 100644 index 0000000000..959aae8aff --- /dev/null +++ b/core-java-modules/core-java-io-4/src/test/java/com/baeldung/fileseparator/FilePathSeparatorUnitTest.java @@ -0,0 +1,63 @@ +package com.baeldung.fileseparator; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.util.StringJoiner; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledOnOs; +import org.junit.jupiter.api.condition.OS; + +public class FilePathSeparatorUnitTest { + + @Test + @EnabledOnOs(OS.WINDOWS) + public void whenCheckPathSeparator_thenResultIsAsExpectedOnWindows() throws IOException { + assertEquals(";", File.pathSeparator); + assertEquals(';', File.pathSeparatorChar); + } + + @Test + @EnabledOnOs({ OS.LINUX, OS.MAC }) + public void whenCheckPathSeparator_thenResultIsAsExpected() throws IOException { + assertEquals(":", File.pathSeparator); + assertEquals(':', File.pathSeparatorChar); + } + + @Test + @EnabledOnOs(OS.WINDOWS) + public void whenBuildPathUsingString_thenResultIsAsExpectedOnWindows() throws IOException { + String[] pathNames = { "path1", "path2", "path3" }; + String path = String.join(File.pathSeparator, pathNames); + assertEquals("path1;path2;path3",path); + } + + @Test + @EnabledOnOs({ OS.LINUX, OS.MAC }) + public void whenBuildPathUsingString_thenResultIsAsExpected() throws IOException { + String[] pathNames = { "path1", "path2", "path3" }; + String path = String.join(File.pathSeparator, pathNames); + assertEquals("path1:path2:path3", path); + } + + @Test + @EnabledOnOs(OS.WINDOWS) + public void whenbuildPathUsingStringJoiner_thenResultIsAsExpectedOnWindows() throws IOException { + assertEquals("path1;path2", buildPathUsingStringJoiner("path1", "path2")); + } + + @Test + @EnabledOnOs({ OS.LINUX, OS.MAC }) + public void whenbuildPathUsingStringJoiner_thenResultIsAsExpected() throws IOException { + assertEquals("path1:path2", buildPathUsingStringJoiner("path1", "path2")); + } + + private String buildPathUsingStringJoiner(String path1, String path2) { + StringJoiner joiner = new StringJoiner(File.pathSeparator); + joiner.add(path1); + joiner.add(path2); + return joiner.toString(); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-io-4/src/test/java/com/baeldung/fileseparator/FileSeparatorUnitTest.java b/core-java-modules/core-java-io-4/src/test/java/com/baeldung/fileseparator/FileSeparatorUnitTest.java new file mode 100644 index 0000000000..f908dcc9bb --- /dev/null +++ b/core-java-modules/core-java-io-4/src/test/java/com/baeldung/fileseparator/FileSeparatorUnitTest.java @@ -0,0 +1,63 @@ +package com.baeldung.fileseparator; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.File; +import java.nio.file.FileSystems; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledOnOs; +import org.junit.jupiter.api.condition.OS; + +public class FileSeparatorUnitTest { + + @Test + @EnabledOnOs(OS.WINDOWS) + public void whenCheckFileSeparator_thenCorrectOnWindows() { + assertEquals("\\", File.separator); + assertEquals('\\', File.separatorChar); + + String fileSeparator = FileSystems.getDefault().getSeparator(); + assertEquals("\\",fileSeparator); + } + + @Test + @EnabledOnOs({ OS.LINUX, OS.MAC }) + public void whenCheckFileSeparator_thenCorrect() { + assertEquals("/", File.separator); + assertEquals('/', File.separatorChar); + + String fileSeparator = FileSystems.getDefault().getSeparator(); + assertEquals("/",fileSeparator); + } + + @Test + @EnabledOnOs(OS.WINDOWS) + public void whenBuildFilePathUsingPathsClass_thenCorrectOnWindows() { + Path path = Paths.get("dir1", "dir2"); + assertEquals("dir1\\dir2", path.toString()); + } + + @Test + @EnabledOnOs({ OS.LINUX, OS.MAC }) + public void whenBuildFilePathUsingPathsClass_thenCorrect() { + Path path = Paths.get("dir1", "dir2"); + assertEquals("dir1/dir2", path.toString()); + } + + @Test + @EnabledOnOs(OS.WINDOWS) + public void whenBuildFilePathUsingFileClass_thenOutputIsAsExpectedOnWindows() { + File file = new File("file1", "file2"); + assertEquals("file1\\file2", file.toString()); + } + + @Test + @EnabledOnOs({ OS.LINUX, OS.MAC }) + public void whenBuildFilePathUsingFileClass_thenOutputIsAsExpected() { + File file = new File("file1", "file2"); + assertEquals("file1/file2", file.toString()); + } +} \ No newline at end of file diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 0a9e818156..711d1e03b9 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -67,6 +67,7 @@ core-java-io core-java-io-2 core-java-io-3 + core-java-io-4 core-java-io-apis core-java-io-conversions core-java-io-conversions-2 From e136bfb7dfea608c1dac957170c6bad5f77924d1 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Thu, 7 Jan 2021 11:06:50 +0530 Subject: [PATCH 217/361] JAVA-4214: Fix issue with geodb repo --- persistence-modules/hibernate-annotations/pom.xml | 14 -------------- persistence-modules/hibernate-queries/pom.xml | 14 -------------- persistence-modules/hibernate5/pom.xml | 14 -------------- 3 files changed, 42 deletions(-) diff --git a/persistence-modules/hibernate-annotations/pom.xml b/persistence-modules/hibernate-annotations/pom.xml index 230de2e17e..d3b786d6c8 100644 --- a/persistence-modules/hibernate-annotations/pom.xml +++ b/persistence-modules/hibernate-annotations/pom.xml @@ -44,21 +44,8 @@ hibernate-spatial ${hibernate-core.version} - - org.opengeo - geodb - ${geodb.version} - - - - geodb-repo - GeoDB repository - http://repo.boundlessgeo.com/main/ - - - 5.4.7.Final 1.4.200 @@ -66,7 +53,6 @@ 2.1.7.RELEASE 5.4.7.Final 1.4.200 - 0.9 diff --git a/persistence-modules/hibernate-queries/pom.xml b/persistence-modules/hibernate-queries/pom.xml index 06f7f42088..4374c833c2 100644 --- a/persistence-modules/hibernate-queries/pom.xml +++ b/persistence-modules/hibernate-queries/pom.xml @@ -35,11 +35,6 @@ hibernate-spatial ${hibernate.version} - - org.opengeo - geodb - ${geodb.version} - mysql mysql-connector-java @@ -62,19 +57,10 @@ - - - geodb-repo - GeoDB repository - http://repo.boundlessgeo.com/main/ - - - 6.0.6 2.2.3 3.8.0 - 0.9 1.21 diff --git a/persistence-modules/hibernate5/pom.xml b/persistence-modules/hibernate5/pom.xml index 7f04abc09f..3feffc98fd 100644 --- a/persistence-modules/hibernate5/pom.xml +++ b/persistence-modules/hibernate5/pom.xml @@ -35,11 +35,6 @@ hibernate-spatial ${hibernate.version} - - org.opengeo - geodb - ${geodb.version} - mysql mysql-connector-java @@ -68,21 +63,12 @@ - - - geodb-repo - GeoDB repository - http://repo.boundlessgeo.com/main/ - - - 5.4.12.Final 6.0.6 2.2.3 3.8.0 1.21 - 0.9 From 28d61c77efda4b80321c233a4d0bcb2b352fe585 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Thu, 7 Jan 2021 16:30:52 +0200 Subject: [PATCH 218/361] move main class to graphql package --- spring-boot-modules/spring-boot-libraries/pom.xml | 2 +- .../java/com/baeldung/{demo => graphql}/DemoApplication.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/{demo => graphql}/DemoApplication.java (96%) diff --git a/spring-boot-modules/spring-boot-libraries/pom.xml b/spring-boot-modules/spring-boot-libraries/pom.xml index cec035cf93..c96a881573 100644 --- a/spring-boot-modules/spring-boot-libraries/pom.xml +++ b/spring-boot-modules/spring-boot-libraries/pom.xml @@ -239,7 +239,7 @@ - com.baeldung.intro.App + com.baeldung.graphql.DemoApplication 8.5.11 2.4.1.Final 1.9.0 diff --git a/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/demo/DemoApplication.java b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/graphql/DemoApplication.java similarity index 96% rename from spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/demo/DemoApplication.java rename to spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/graphql/DemoApplication.java index e30ee6104d..1fd93af3b7 100644 --- a/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/demo/DemoApplication.java +++ b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/graphql/DemoApplication.java @@ -1,4 +1,4 @@ -package com.baeldung.demo; +package com.baeldung.graphql; import com.baeldung.graphql.GraphqlConfiguration; import org.springframework.boot.SpringApplication; From 75aa478d80aa0f249351ac0dec0731773059604a Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 7 Jan 2021 20:26:18 +0100 Subject: [PATCH 219/361] JAVA-3585: Upgrade commons-io in the main pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 09cba54b87..e4a2632bf4 100644 --- a/pom.xml +++ b/pom.xml @@ -1375,7 +1375,7 @@ 1.19 1.6.0 2.21.0 - 2.5 + 2.8.0 2.6 3.11 1.4 From ba5343cab27965460f29ec889fa1a03a30d2cb78 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 7 Jan 2021 20:42:57 +0100 Subject: [PATCH 220/361] JAVA-3585: Use common commons-io.version property in all child modules --- aws-lambda/lambda/pom.xml | 1 - core-java-modules/core-java-9/pom.xml | 2 +- jhipster/jhipster-microservice/car-app/pom.xml | 1 - jhipster/jhipster-microservice/dealer-app/pom.xml | 1 - jhipster/jhipster-microservice/gateway-app/pom.xml | 1 - jhipster/jhipster-monolithic/pom.xml | 1 - libraries-6/pom.xml | 3 +-- libraries-data/pom.xml | 3 +-- parent-java/pom.xml | 3 +-- persistence-modules/hibernate-mapping/pom.xml | 1 - spring-boot-modules/pom.xml | 1 - spring-boot-modules/spring-boot-mvc-3/pom.xml | 4 ---- spring-core/pom.xml | 3 +-- spring-di/pom.xml | 3 +-- spring-web-modules/spring-mvc-java/pom.xml | 1 - xml/pom.xml | 1 - 16 files changed, 6 insertions(+), 24 deletions(-) diff --git a/aws-lambda/lambda/pom.xml b/aws-lambda/lambda/pom.xml index 2d903aabc5..1f446e04c0 100644 --- a/aws-lambda/lambda/pom.xml +++ b/aws-lambda/lambda/pom.xml @@ -89,7 +89,6 @@ 1.1.1 - 2.5 1.3.0 1.2.0 2.8.2 diff --git a/core-java-modules/core-java-9/pom.xml b/core-java-modules/core-java-9/pom.xml index 05dc8ba5eb..001faf88cb 100644 --- a/core-java-modules/core-java-9/pom.xml +++ b/core-java-modules/core-java-9/pom.xml @@ -52,7 +52,7 @@ commons-io commons-io - 2.7 + ${commons-io.version} diff --git a/jhipster/jhipster-microservice/car-app/pom.xml b/jhipster/jhipster-microservice/car-app/pom.xml index 603d53299c..477192438f 100644 --- a/jhipster/jhipster-microservice/car-app/pom.xml +++ b/jhipster/jhipster-microservice/car-app/pom.xml @@ -21,7 +21,6 @@ -Djava.security.egd=file:/dev/./urandom -Xmx256m 3.6.2 2.0.0 - 2.5 0.4.13 1.2 5.2.8.Final diff --git a/jhipster/jhipster-microservice/dealer-app/pom.xml b/jhipster/jhipster-microservice/dealer-app/pom.xml index 0e492d3d13..59df7d3b69 100644 --- a/jhipster/jhipster-microservice/dealer-app/pom.xml +++ b/jhipster/jhipster-microservice/dealer-app/pom.xml @@ -20,7 +20,6 @@ -Djava.security.egd=file:/dev/./urandom -Xmx256m 3.6.2 2.0.0 - 2.5 0.4.13 1.2 5.2.8.Final diff --git a/jhipster/jhipster-microservice/gateway-app/pom.xml b/jhipster/jhipster-microservice/gateway-app/pom.xml index c5e7364f57..a50c2bbdd1 100644 --- a/jhipster/jhipster-microservice/gateway-app/pom.xml +++ b/jhipster/jhipster-microservice/gateway-app/pom.xml @@ -22,7 +22,6 @@ 2.0.0 3.6.0 1.10 - 2.5 0.4.13 1.3 1.2 diff --git a/jhipster/jhipster-monolithic/pom.xml b/jhipster/jhipster-monolithic/pom.xml index 103f48424f..97f2b85b2f 100644 --- a/jhipster/jhipster-monolithic/pom.xml +++ b/jhipster/jhipster-monolithic/pom.xml @@ -887,7 +887,6 @@ -Djava.security.egd=file:/dev/./urandom -Xmx256m 3.6.2 2.0.0 - 2.5 0.4.13 1.3 2.2.1 diff --git a/libraries-6/pom.xml b/libraries-6/pom.xml index 0f129c27c9..caaebbb922 100644 --- a/libraries-6/pom.xml +++ b/libraries-6/pom.xml @@ -94,7 +94,7 @@ commons-io commons-io - ${commonsio.version} + ${commons-io.version} test @@ -157,7 +157,6 @@ 1.15 3.6 3.6.2 - 2.6 RELEASE 3.0 1.8.1 diff --git a/libraries-data/pom.xml b/libraries-data/pom.xml index 95d771ce4e..5adb490e96 100644 --- a/libraries-data/pom.xml +++ b/libraries-data/pom.xml @@ -80,7 +80,7 @@ commons-io commons-io - ${commons.io.version} + ${commons-io.version} provided @@ -165,7 +165,6 @@ 2.3 1.2 - 2.1 3.0.1 1.2.2 1.0.0 diff --git a/parent-java/pom.xml b/parent-java/pom.xml index d251adcdd3..9170f45bbe 100644 --- a/parent-java/pom.xml +++ b/parent-java/pom.xml @@ -27,7 +27,7 @@ commons-io commons-io - ${commons.io.version} + ${commons-io.version} org.openjdk.jmh @@ -43,7 +43,6 @@ 29.0-jre - 2.6 1.19 2.3.7 2.2 diff --git a/persistence-modules/hibernate-mapping/pom.xml b/persistence-modules/hibernate-mapping/pom.xml index 155eefa526..ebc854a621 100644 --- a/persistence-modules/hibernate-mapping/pom.xml +++ b/persistence-modules/hibernate-mapping/pom.xml @@ -71,7 +71,6 @@ 3.0.1-b11 1.0.3 1.3 - 2.6 diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index c562d522e2..ee088c357a 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -116,6 +116,5 @@ 5.6.2 - 2.6 diff --git a/spring-boot-modules/spring-boot-mvc-3/pom.xml b/spring-boot-modules/spring-boot-mvc-3/pom.xml index 1290b0432f..5a5d4c3cd8 100644 --- a/spring-boot-modules/spring-boot-mvc-3/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-3/pom.xml @@ -37,8 +37,4 @@ - - 2.7 - - diff --git a/spring-core/pom.xml b/spring-core/pom.xml index eb25bcd517..7d83fc198c 100644 --- a/spring-core/pom.xml +++ b/spring-core/pom.xml @@ -65,7 +65,7 @@ commons-io commons-io - ${commons.io.version} + ${commons-io.version} @@ -86,7 +86,6 @@ 1.4.4.RELEASE 1 20.0 - 2.5 1.5.2.RELEASE 1.10.19 3.12.2 diff --git a/spring-di/pom.xml b/spring-di/pom.xml index 48cdf60673..df0b685ae2 100644 --- a/spring-di/pom.xml +++ b/spring-di/pom.xml @@ -83,7 +83,7 @@ commons-io commons-io - ${commons.io.version} + ${commons-io.version} org.aspectj @@ -159,7 +159,6 @@ 1.4.4.RELEASE 1 20.0 - 2.5 1.5.2.RELEASE 1.10.19 3.12.2 diff --git a/spring-web-modules/spring-mvc-java/pom.xml b/spring-web-modules/spring-mvc-java/pom.xml index ec302eed57..474bbb2a06 100644 --- a/spring-web-modules/spring-mvc-java/pom.xml +++ b/spring-web-modules/spring-mvc-java/pom.xml @@ -235,7 +235,6 @@ 19.0 1.3.2 - 2.5 1.4 2.2.0 diff --git a/xml/pom.xml b/xml/pom.xml index cbad5b37f0..837f918b46 100644 --- a/xml/pom.xml +++ b/xml/pom.xml @@ -364,7 +364,6 @@ 1.2.0 2.0.6 1.6.2 - 2.5 4.1 1.2.4.5 2.3.1 From d25080b689972a08a53d82891af20e98cec45d5e Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 7 Jan 2021 23:14:19 +0100 Subject: [PATCH 221/361] JAVA-4217: Update batch dependencies --- spring-batch-2/pom.xml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/spring-batch-2/pom.xml b/spring-batch-2/pom.xml index 54df6d43e8..183ad610f3 100644 --- a/spring-batch-2/pom.xml +++ b/spring-batch-2/pom.xml @@ -20,7 +20,6 @@ org.springframework.boot spring-boot-starter-batch - 2.3.6.RELEASE org.hsqldb @@ -31,7 +30,6 @@ org.springframework.boot spring-boot-starter-test - ${spring.boot.batch.version} test @@ -43,14 +41,13 @@ org.springframework.batch spring-batch-test - ${spring.batch.test.version} + ${spring.batch.version} test - 2.3.6.RELEASE - 4.2.4.RELEASE + 4.3.0 2.5.1 From 51189b8d4058b637fd9ce1091fe4ea8b120e6158 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 8 Jan 2021 18:22:46 +0530 Subject: [PATCH 222/361] JAVA-4216: Fix issue in jnosql-artemis project --- persistence-modules/jnosql/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/jnosql/pom.xml b/persistence-modules/jnosql/pom.xml index fb7ac72b05..81c62ee562 100644 --- a/persistence-modules/jnosql/pom.xml +++ b/persistence-modules/jnosql/pom.xml @@ -21,7 +21,7 @@ - 0.0.5 + 0.0.6 From 989216338f7b2ee7b00a5672dd60cfa11a4b64cd Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Fri, 8 Jan 2021 19:56:04 +0100 Subject: [PATCH 223/361] JAVA-3588: Upgrade commons-fileupload in the main pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e4a2632bf4..2d1850bb79 100644 --- a/pom.xml +++ b/pom.xml @@ -1385,7 +1385,7 @@ 2.3.1 1.2 2.11.1 - 1.3 + 1.4 1.2.0 5.2.0 0.3.1 From d450e4a2f81748ada5b89fd8cc5a8a976d35d095 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Fri, 8 Jan 2021 20:01:27 +0100 Subject: [PATCH 224/361] JAVA-3588: Use common commons-fileupload.version property in all child modules --- javax-servlets/pom.xml | 1 - spring-security-modules/spring-security-web-rest/pom.xml | 2 -- spring-web-modules/spring-mvc-basics-2/pom.xml | 1 - spring-web-modules/spring-mvc-forms-jsp/pom.xml | 3 +-- spring-web-modules/spring-mvc-java/pom.xml | 2 -- spring-web-modules/spring-rest-simple/pom.xml | 1 - 6 files changed, 1 insertion(+), 9 deletions(-) diff --git a/javax-servlets/pom.xml b/javax-servlets/pom.xml index 5fc9fef24a..700b823a6e 100644 --- a/javax-servlets/pom.xml +++ b/javax-servlets/pom.xml @@ -59,7 +59,6 @@ 4.5.3 2.8.2 3.9.1 - 1.3.3 4.0.1 diff --git a/spring-security-modules/spring-security-web-rest/pom.xml b/spring-security-modules/spring-security-web-rest/pom.xml index d2468152da..2330243aa6 100644 --- a/spring-security-modules/spring-security-web-rest/pom.xml +++ b/spring-security-modules/spring-security-web-rest/pom.xml @@ -168,7 +168,6 @@ ${springfox-swagger.version} - commons-fileupload commons-fileupload @@ -271,7 +270,6 @@ 26.0-jre - 1.3.2 2.9.0 diff --git a/spring-web-modules/spring-mvc-basics-2/pom.xml b/spring-web-modules/spring-mvc-basics-2/pom.xml index e16b54b2c8..0b4515994b 100644 --- a/spring-web-modules/spring-mvc-basics-2/pom.xml +++ b/spring-web-modules/spring-mvc-basics-2/pom.xml @@ -168,7 +168,6 @@ 4.0.0 6.0.10.Final enter-location-of-server - 1.3.2 3.0.11.RELEASE 2.4.12 2.3.27-incubating diff --git a/spring-web-modules/spring-mvc-forms-jsp/pom.xml b/spring-web-modules/spring-mvc-forms-jsp/pom.xml index aba16236da..0ca23bd6cb 100644 --- a/spring-web-modules/spring-mvc-forms-jsp/pom.xml +++ b/spring-web-modules/spring-mvc-forms-jsp/pom.xml @@ -54,7 +54,7 @@ commons-fileupload commons-fileupload - ${fileupload.version} + ${commons-fileupload.version} com.fasterxml.jackson.core @@ -98,7 +98,6 @@ 6.0.10.Final - 1.3.3 5.2.5.Final 6.0.6 diff --git a/spring-web-modules/spring-mvc-java/pom.xml b/spring-web-modules/spring-mvc-java/pom.xml index 474bbb2a06..1324511215 100644 --- a/spring-web-modules/spring-mvc-java/pom.xml +++ b/spring-web-modules/spring-mvc-java/pom.xml @@ -234,8 +234,6 @@ 19.0 - 1.3.2 - 1.4 2.2.0 diff --git a/spring-web-modules/spring-rest-simple/pom.xml b/spring-web-modules/spring-rest-simple/pom.xml index 37a0b99de2..b9d5100fbf 100644 --- a/spring-web-modules/spring-rest-simple/pom.xml +++ b/spring-web-modules/spring-rest-simple/pom.xml @@ -314,7 +314,6 @@ - 1.3.3 4.0.0 1.4 3.1.0 From 195f4aab7bf8dd5147d1d538cad41504056cf70d Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Fri, 8 Jan 2021 18:14:01 -0300 Subject: [PATCH 225/361] cleaned up boot version override in spring-boot-properties, since the parent-boot-2 module has been updated --- spring-boot-modules/spring-boot-properties/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-properties/pom.xml b/spring-boot-modules/spring-boot-properties/pom.xml index 0260a4a72e..40668f47fd 100644 --- a/spring-boot-modules/spring-boot-properties/pom.xml +++ b/spring-boot-modules/spring-boot-properties/pom.xml @@ -141,7 +141,6 @@ @ com.baeldung.yaml.MyApplication - 2.4.0 From d3c73637c287229ae619d020140fe433dc33f34a Mon Sep 17 00:00:00 2001 From: Roger Yates <587230+rojyates@users.noreply.github.com> Date: Sat, 9 Jan 2021 07:54:57 +1000 Subject: [PATCH 226/361] BAEL-4614 JVM property java.security.egd --- .../baeldung/egd/JavaSecurityEgdTester.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 core-java-modules/core-java-security-2/src/main/java/com/baeldung/egd/JavaSecurityEgdTester.java diff --git a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/egd/JavaSecurityEgdTester.java b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/egd/JavaSecurityEgdTester.java new file mode 100644 index 0000000000..347d3b4cba --- /dev/null +++ b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/egd/JavaSecurityEgdTester.java @@ -0,0 +1,23 @@ +package com.baeldung.egd; + +import java.security.SecureRandom; + +/** + * JavaSecurityEgdTester - run this with JVM parameter java.security.egd, e.g.: + * java -Djava.security.egd=file:/dev/urandom -cp . com.baeldung.egd.JavaSecurityEgdTester + */ +public class JavaSecurityEgdTester { + public static final double NANOSECS = 1000000000.0; + public static final String JAVA_SECURITY_EGD = "java.security.egd"; + + public static void main(String[] args) { + SecureRandom secureRandom = new SecureRandom(); + long start = System.nanoTime(); + byte[] randomBytes = new byte[256]; + secureRandom.nextBytes(randomBytes); + double duration = (System.nanoTime() - start) / NANOSECS; + + String message = String.format("java.security.egd=%s took %.3f seconds and used the %s algorithm", System.getProperty(JAVA_SECURITY_EGD), duration, secureRandom.getAlgorithm()); + System.out.println(message); + } +} From dfe902f0a68ccb9071165130d06319c01cf3eb02 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 9 Jan 2021 12:59:21 +0530 Subject: [PATCH 227/361] JAVA-3542: Moved spring-jooq inside persistence-modules --- {spring-jooq => persistence-modules/spring-jooq}/.gitignore | 0 {spring-jooq => persistence-modules/spring-jooq}/README.md | 0 {spring-jooq => persistence-modules/spring-jooq}/pom.xml | 2 +- .../spring-jooq}/src/main/resources/application.properties | 0 .../spring-jooq}/src/main/resources/intro_config.properties | 0 .../spring-jooq}/src/main/resources/intro_schema.sql | 0 .../spring-jooq}/src/main/resources/logback.xml | 0 .../com/baeldung/jooq/introduction/ExceptionTranslator.java | 0 .../jooq/introduction/PersistenceContextIntegrationTest.java | 0 .../com/baeldung/jooq/introduction/QueryIntegrationTest.java | 0 .../src/test/java/com/baeldung/jooq/springboot/Application.java | 0 .../java/com/baeldung/jooq/springboot/InitialConfiguration.java | 0 .../com/baeldung/jooq/springboot/SpringBootIntegrationTest.java | 0 .../spring-jooq}/src/test/resources/application.properties | 0 14 files changed, 1 insertion(+), 1 deletion(-) rename {spring-jooq => persistence-modules/spring-jooq}/.gitignore (100%) rename {spring-jooq => persistence-modules/spring-jooq}/README.md (100%) rename {spring-jooq => persistence-modules/spring-jooq}/pom.xml (99%) rename {spring-jooq => persistence-modules/spring-jooq}/src/main/resources/application.properties (100%) rename {spring-jooq => persistence-modules/spring-jooq}/src/main/resources/intro_config.properties (100%) rename {spring-jooq => persistence-modules/spring-jooq}/src/main/resources/intro_schema.sql (100%) rename {spring-jooq => persistence-modules/spring-jooq}/src/main/resources/logback.xml (100%) rename {spring-jooq => persistence-modules/spring-jooq}/src/test/java/com/baeldung/jooq/introduction/ExceptionTranslator.java (100%) rename {spring-jooq => persistence-modules/spring-jooq}/src/test/java/com/baeldung/jooq/introduction/PersistenceContextIntegrationTest.java (100%) rename {spring-jooq => persistence-modules/spring-jooq}/src/test/java/com/baeldung/jooq/introduction/QueryIntegrationTest.java (100%) rename {spring-jooq => persistence-modules/spring-jooq}/src/test/java/com/baeldung/jooq/springboot/Application.java (100%) rename {spring-jooq => persistence-modules/spring-jooq}/src/test/java/com/baeldung/jooq/springboot/InitialConfiguration.java (100%) rename {spring-jooq => persistence-modules/spring-jooq}/src/test/java/com/baeldung/jooq/springboot/SpringBootIntegrationTest.java (100%) rename {spring-jooq => persistence-modules/spring-jooq}/src/test/resources/application.properties (100%) diff --git a/spring-jooq/.gitignore b/persistence-modules/spring-jooq/.gitignore similarity index 100% rename from spring-jooq/.gitignore rename to persistence-modules/spring-jooq/.gitignore diff --git a/spring-jooq/README.md b/persistence-modules/spring-jooq/README.md similarity index 100% rename from spring-jooq/README.md rename to persistence-modules/spring-jooq/README.md diff --git a/spring-jooq/pom.xml b/persistence-modules/spring-jooq/pom.xml similarity index 99% rename from spring-jooq/pom.xml rename to persistence-modules/spring-jooq/pom.xml index 550d49b5b2..6b3d565175 100644 --- a/spring-jooq/pom.xml +++ b/persistence-modules/spring-jooq/pom.xml @@ -9,7 +9,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-2 + ../../parent-boot-2 diff --git a/spring-jooq/src/main/resources/application.properties b/persistence-modules/spring-jooq/src/main/resources/application.properties similarity index 100% rename from spring-jooq/src/main/resources/application.properties rename to persistence-modules/spring-jooq/src/main/resources/application.properties diff --git a/spring-jooq/src/main/resources/intro_config.properties b/persistence-modules/spring-jooq/src/main/resources/intro_config.properties similarity index 100% rename from spring-jooq/src/main/resources/intro_config.properties rename to persistence-modules/spring-jooq/src/main/resources/intro_config.properties diff --git a/spring-jooq/src/main/resources/intro_schema.sql b/persistence-modules/spring-jooq/src/main/resources/intro_schema.sql similarity index 100% rename from spring-jooq/src/main/resources/intro_schema.sql rename to persistence-modules/spring-jooq/src/main/resources/intro_schema.sql diff --git a/spring-jooq/src/main/resources/logback.xml b/persistence-modules/spring-jooq/src/main/resources/logback.xml similarity index 100% rename from spring-jooq/src/main/resources/logback.xml rename to persistence-modules/spring-jooq/src/main/resources/logback.xml diff --git a/spring-jooq/src/test/java/com/baeldung/jooq/introduction/ExceptionTranslator.java b/persistence-modules/spring-jooq/src/test/java/com/baeldung/jooq/introduction/ExceptionTranslator.java similarity index 100% rename from spring-jooq/src/test/java/com/baeldung/jooq/introduction/ExceptionTranslator.java rename to persistence-modules/spring-jooq/src/test/java/com/baeldung/jooq/introduction/ExceptionTranslator.java diff --git a/spring-jooq/src/test/java/com/baeldung/jooq/introduction/PersistenceContextIntegrationTest.java b/persistence-modules/spring-jooq/src/test/java/com/baeldung/jooq/introduction/PersistenceContextIntegrationTest.java similarity index 100% rename from spring-jooq/src/test/java/com/baeldung/jooq/introduction/PersistenceContextIntegrationTest.java rename to persistence-modules/spring-jooq/src/test/java/com/baeldung/jooq/introduction/PersistenceContextIntegrationTest.java diff --git a/spring-jooq/src/test/java/com/baeldung/jooq/introduction/QueryIntegrationTest.java b/persistence-modules/spring-jooq/src/test/java/com/baeldung/jooq/introduction/QueryIntegrationTest.java similarity index 100% rename from spring-jooq/src/test/java/com/baeldung/jooq/introduction/QueryIntegrationTest.java rename to persistence-modules/spring-jooq/src/test/java/com/baeldung/jooq/introduction/QueryIntegrationTest.java diff --git a/spring-jooq/src/test/java/com/baeldung/jooq/springboot/Application.java b/persistence-modules/spring-jooq/src/test/java/com/baeldung/jooq/springboot/Application.java similarity index 100% rename from spring-jooq/src/test/java/com/baeldung/jooq/springboot/Application.java rename to persistence-modules/spring-jooq/src/test/java/com/baeldung/jooq/springboot/Application.java diff --git a/spring-jooq/src/test/java/com/baeldung/jooq/springboot/InitialConfiguration.java b/persistence-modules/spring-jooq/src/test/java/com/baeldung/jooq/springboot/InitialConfiguration.java similarity index 100% rename from spring-jooq/src/test/java/com/baeldung/jooq/springboot/InitialConfiguration.java rename to persistence-modules/spring-jooq/src/test/java/com/baeldung/jooq/springboot/InitialConfiguration.java diff --git a/spring-jooq/src/test/java/com/baeldung/jooq/springboot/SpringBootIntegrationTest.java b/persistence-modules/spring-jooq/src/test/java/com/baeldung/jooq/springboot/SpringBootIntegrationTest.java similarity index 100% rename from spring-jooq/src/test/java/com/baeldung/jooq/springboot/SpringBootIntegrationTest.java rename to persistence-modules/spring-jooq/src/test/java/com/baeldung/jooq/springboot/SpringBootIntegrationTest.java diff --git a/spring-jooq/src/test/resources/application.properties b/persistence-modules/spring-jooq/src/test/resources/application.properties similarity index 100% rename from spring-jooq/src/test/resources/application.properties rename to persistence-modules/spring-jooq/src/test/resources/application.properties From 3dbc22182ff3220becfb321b351bea10ea3556c7 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 9 Jan 2021 13:00:07 +0530 Subject: [PATCH 228/361] JAVA-3542: Added module to new parent's pom --- persistence-modules/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index c7905a178d..8789a8473b 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -86,6 +86,7 @@ spring-jpa spring-jpa-2 spring-jdbc + spring-jooq spring-persistence-simple From 1f70c884377d18195ae838aa8d8579ffefa4ac80 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 9 Jan 2021 13:01:08 +0530 Subject: [PATCH 229/361] JAVA-3542: Removed module from main pom --- pom.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pom.xml b/pom.xml index e4a2632bf4..e923c3711c 100644 --- a/pom.xml +++ b/pom.xml @@ -650,7 +650,6 @@ spring-jersey spring-jinq spring-jms - spring-jooq spring-kafka spring-katharsis @@ -1101,7 +1100,6 @@ spring-jersey spring-jinq spring-jms - spring-jooq spring-kafka spring-katharsis From df31e606c3d8486dfb99a0be50491e74097b2810 Mon Sep 17 00:00:00 2001 From: Trixi Turny Date: Sat, 9 Jan 2021 15:55:24 +0000 Subject: [PATCH 230/361] BAEL-4748 implement UserConsumerService with webClient and write UnitTests --- .../webclient/json/UserConsumerService.java | 16 ++++ .../json/UserConsumerServiceImpl.java | 90 +++++++++++++++++++ .../webclient/json/model/Address.java | 29 ++++++ .../baeldung/webclient/json/model/User.java | 30 +++++++ .../json/UserConsumerServiceImplUnitTest.java | 74 +++++++++++++++ 5 files changed, 239 insertions(+) create mode 100644 spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/UserConsumerService.java create mode 100644 spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/UserConsumerServiceImpl.java create mode 100644 spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Address.java create mode 100644 spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/User.java create mode 100644 spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/UserConsumerServiceImplUnitTest.java diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/UserConsumerService.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/UserConsumerService.java new file mode 100644 index 0000000000..9afc207ff2 --- /dev/null +++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/UserConsumerService.java @@ -0,0 +1,16 @@ +package com.baeldung.webclient.json; + +import java.util.List; + +public interface UserConsumerService { + + List processUserDataFromObjectArray(); + + List processUserDataFromUserArray(); + + List processUserDataFromUserList(); + + List processNestedUserDataFromUserArray(); + + List processNestedUserDataFromUserList(); +} diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/UserConsumerServiceImpl.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/UserConsumerServiceImpl.java new file mode 100644 index 0000000000..30cd4a5617 --- /dev/null +++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/UserConsumerServiceImpl.java @@ -0,0 +1,90 @@ +package com.baeldung.webclient.json; + +import com.baeldung.webclient.json.model.Address; +import com.baeldung.webclient.json.model.User; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.client.WebClient; +import reactor.core.publisher.Mono; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class UserConsumerServiceImpl implements UserConsumerService { + + private final WebClient webClient; + private static final ObjectMapper mapper = new ObjectMapper(); + + public UserConsumerServiceImpl(WebClient webClient) { + this.webClient = webClient; + } + @Override + public List processUserDataFromObjectArray() { + Mono response = webClient.get() + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(Object[].class).log(); + Object[] objects = response.block(); + return Arrays.stream(objects) + .map(object -> mapper.convertValue(object, User.class)) + .map(User::getName) + .collect(Collectors.toList()); + } + + @Override + public List processUserDataFromUserArray() { + Mono response = + webClient.get() + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(User[].class).log(); + + User[] userArray = response.block(); + return Arrays.stream(userArray) + .map(User::getName) + .collect(Collectors.toList()); + } + + @Override + public List processUserDataFromUserList() { + Mono> response = webClient.get() + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(new ParameterizedTypeReference>() {}); + List userList = response.block(); + + return userList.stream() + .map(User::getName) + .collect(Collectors.toList()); + } + + @Override + public List processNestedUserDataFromUserArray() { + Mono response = webClient.get() + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(User[].class).log(); + User[] userArray = response.block(); + + return Arrays.stream(userArray) + .flatMap(user -> user.getAddressList().stream()) + .map(Address::getPostCode) + .collect(Collectors.toList()); + } + + @Override + public List processNestedUserDataFromUserList() { + Mono> response = webClient.get() + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(new ParameterizedTypeReference>() {}); + + List userList = response.block(); + return userList.stream() + .flatMap(user -> user.getAddressList().stream()) + .map(Address::getPostCode) + .collect(Collectors.toList()); + } +} \ No newline at end of file diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Address.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Address.java new file mode 100644 index 0000000000..cc4323b72b --- /dev/null +++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Address.java @@ -0,0 +1,29 @@ +package com.baeldung.webclient.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-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/User.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/User.java new file mode 100644 index 0000000000..6ed359f9db --- /dev/null +++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/User.java @@ -0,0 +1,30 @@ +package com.baeldung.webclient.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-5-reactive-client/src/test/java/com/baeldung/webclient/json/UserConsumerServiceImplUnitTest.java b/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/UserConsumerServiceImplUnitTest.java new file mode 100644 index 0000000000..151554efde --- /dev/null +++ b/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/UserConsumerServiceImplUnitTest.java @@ -0,0 +1,74 @@ +package com.baeldung.webclient.json; + +import org.junit.jupiter.api.Test; +import org.springframework.http.HttpStatus; +import org.springframework.web.reactive.function.client.ClientResponse; +import org.springframework.web.reactive.function.client.WebClient; +import reactor.core.publisher.Mono; + +import java.util.Arrays; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; + +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 static String BASE_URL = "http://localhost:8080"; + + WebClient webClientMock = WebClient.builder() + .exchangeFunction(clientRequest -> Mono.just(ClientResponse.create(HttpStatus.OK) + .header("content-type", "application/json") + .body(USER_JSON) + .build())) + .build(); + + private final UserConsumerService tested = new UserConsumerServiceImpl(webClientMock); + + @Test + void when_processUserDataFromObjectArray_then_OK() { + List expected = Arrays.asList("user1", "user2"); + List actual = tested.processUserDataFromObjectArray(); + assertThat(actual, contains(expected.get(0), expected.get(1))); + } + + @Test + void when_processUserDataFromUserArray_then_OK() { + List expected = Arrays.asList("user1", "user2"); + List actual = tested.processUserDataFromUserArray(); + assertThat(actual, contains(expected.get(0), expected.get(1))); + } + + @Test + void when_processUserDataFromUserList_then_OK() { + List expected = Arrays.asList("user1", "user2"); + List actual = tested.processUserDataFromUserList(); + assertThat(actual, contains(expected.get(0), expected.get(1))); + } + + @Test + void when_processNestedUserDataFromUserArray_then_OK() { + List expected = Arrays.asList( + "user1_address1_postCode", + "user1_address2_postCode", + "user2_address1_postCode"); + + List actual = tested.processNestedUserDataFromUserArray(); + assertThat(actual, contains(expected.get(0), expected.get(1), expected.get(2))); + } + + @Test + void when_processNestedUserDataFromUserList_then_OK() { + List expected = Arrays.asList( + "user1_address1_postCode", + "user1_address2_postCode", + "user2_address1_postCode"); + + List actual = tested.processNestedUserDataFromUserList(); + assertThat(actual, contains(expected.get(0), expected.get(1), expected.get(2))); + } +} \ No newline at end of file From adfede63ba31352ca99e0631330a5e9856646096 Mon Sep 17 00:00:00 2001 From: Anshul BANSAL Date: Sat, 9 Jan 2021 21:18:07 +0200 Subject: [PATCH 231/361] BAEL-4472 - old file removed --- ...inarySemaphoreVsReentrantLockUnitTest.java | 58 ------------------- 1 file changed, 58 deletions(-) delete mode 100644 core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/binarysemaphorereentrantlock/BinarySemaphoreVsReentrantLockUnitTest.java diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/binarysemaphorereentrantlock/BinarySemaphoreVsReentrantLockUnitTest.java b/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/binarysemaphorereentrantlock/BinarySemaphoreVsReentrantLockUnitTest.java deleted file mode 100644 index f456e82f39..0000000000 --- a/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/binarysemaphorereentrantlock/BinarySemaphoreVsReentrantLockUnitTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.baeldung.binarysemaphorereentrantlock; - -import static org.junit.Assert.assertEquals; -import java.util.concurrent.Semaphore; -import java.util.concurrent.locks.ReentrantLock; - -import org.junit.Test; - -public class BinarySemaphoreVsReentrantLockUnitTest { - - @Test - public void givenBinarySemaphore_whenAcquireAndRelease_thenCheckAvailablePermits() throws InterruptedException { - Semaphore binarySemaphore = new Semaphore(1); - try { - binarySemaphore.acquire(); - assertEquals(0, binarySemaphore.availablePermits()); - } catch (InterruptedException e) { - e.printStackTrace(); - } finally { - binarySemaphore.release(); - assertEquals(1, binarySemaphore.availablePermits()); - } - } - - @Test - public void givenReentrantLock_whenLockAndUnlock_thenCheckHoldCountAndIsLocked() throws InterruptedException { - ReentrantLock reentrantLock = new ReentrantLock(); - try { - reentrantLock.lock(); - assertEquals(1, reentrantLock.getHoldCount()); - assertEquals(true, reentrantLock.isLocked()); - } finally { - reentrantLock.unlock(); - assertEquals(0, reentrantLock.getHoldCount()); - assertEquals(false, reentrantLock.isLocked()); - } - } - - @Test - public void givenReentrantLock_whenLockMultipleTimes_thenUnlockMultipleTimesToRelease() throws InterruptedException { - ReentrantLock reentrantLock = new ReentrantLock(); - try { - reentrantLock.lock(); - reentrantLock.lock(); - assertEquals(2, reentrantLock.getHoldCount()); - assertEquals(true, reentrantLock.isLocked()); - } finally { - reentrantLock.unlock(); - assertEquals(1, reentrantLock.getHoldCount()); - assertEquals(true, reentrantLock.isLocked()); - - reentrantLock.unlock(); - assertEquals(0, reentrantLock.getHoldCount()); - assertEquals(false, reentrantLock.isLocked()); - } - } - -} From 5e26ff97d9e41166fdd59c6192278838e9785d80 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Sat, 9 Jan 2021 23:09:00 -0300 Subject: [PATCH 232/361] removed starter-test vintage engine exclusion, not needed since Boot 2.4.0 --- spring-boot-modules/spring-boot-properties-3/pom.xml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/spring-boot-modules/spring-boot-properties-3/pom.xml b/spring-boot-modules/spring-boot-properties-3/pom.xml index 44e2ef52ac..809fd6e2d4 100644 --- a/spring-boot-modules/spring-boot-properties-3/pom.xml +++ b/spring-boot-modules/spring-boot-properties-3/pom.xml @@ -26,12 +26,6 @@ org.springframework.boot spring-boot-starter-test test - - - org.junit.vintage - junit-vintage-engine - - org.springframework.boot From c0955b04f7c91c22d669bec3a212f58959f18def Mon Sep 17 00:00:00 2001 From: wolkenschieber Date: Sun, 10 Jan 2021 14:03:17 +0100 Subject: [PATCH 233/361] Update packages to match declaration --- .../src/test/java/{org => com}/baeldung/SpringContextTest.java | 0 .../src/test/java/{org => com}/baeldung/SpringContextTest.java | 0 .../src/test/java/{org => com}/baeldung/SpringContextTest.java | 0 .../src/test/java/{org => com}/baeldung/SpringContextTest.java | 0 .../src/test/java/{org => com}/baeldung/SpringContextTest.java | 0 .../src/test/java/{org => com}/baeldung/SpringContextTest.java | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/{org => com}/baeldung/SpringContextTest.java (100%) rename spring-boot-modules/spring-boot-angular/src/test/java/{org => com}/baeldung/SpringContextTest.java (100%) rename spring-boot-modules/spring-boot-ctx-fluent/src/test/java/{org => com}/baeldung/SpringContextTest.java (100%) rename spring-boot-modules/spring-boot-jasypt/src/test/java/{org => com}/baeldung/SpringContextTest.java (100%) rename spring-boot-modules/spring-boot-logging-log4j2/src/test/java/{org => com}/baeldung/SpringContextTest.java (100%) rename spring-boot-modules/spring-boot-vue/src/test/java/{org => com}/baeldung/SpringContextTest.java (100%) diff --git a/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-boot-modules/spring-boot-angular/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-angular/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-modules/spring-boot-angular/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-angular/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-boot-modules/spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-ctx-fluent/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-modules/spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-ctx-fluent/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-boot-modules/spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-jasypt/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-modules/spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-jasypt/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-boot-modules/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-logging-log4j2/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-modules/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-logging-log4j2/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-boot-modules/spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-vue/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-modules/spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-vue/src/test/java/com/baeldung/SpringContextTest.java From 4af05b2230e35453f39a6708b9f2bef5a17580a6 Mon Sep 17 00:00:00 2001 From: wolkenschieber Date: Sun, 10 Jan 2021 15:04:09 +0100 Subject: [PATCH 234/361] Update packages to match declaration --- .../src/test/java/{org => com}/baeldung/SpringContextTest.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/{org => com}/baeldung/SpringContextTest.java (100%) diff --git a/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/com/baeldung/SpringContextTest.java From 7347c8fe16d7d26de2f01e24c9869450209341ba Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Sat, 9 Jan 2021 23:10:12 -0300 Subject: [PATCH 235/361] added example for multidocument properties files --- .../src/main/resources/application.properties | 6 ++++- ...documentPropertiesFileIntegrationTest.java | 22 +++++++++++++++++ ...documentPropertiesFileIntegrationTest.java | 24 +++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DefaultMultidocumentPropertiesFileIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/ProdMultidocumentPropertiesFileIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.properties b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.properties index eace1f0e46..bf89182d8a 100644 --- a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.properties +++ b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.properties @@ -8,4 +8,8 @@ spring.datasource.url=jdbc:h2:dev spring.datasource.username=SA spring.datasource.password=password app.name=MyApp -app.description=${app.name} is a Spring Boot application \ No newline at end of file +app.description=${app.name} is a Spring Boot application +bael.property=defaultValue +#--- +spring.config.activate.on-profile=prod +bael.property=prodValue \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DefaultMultidocumentPropertiesFileIntegrationTest.java b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DefaultMultidocumentPropertiesFileIntegrationTest.java new file mode 100644 index 0000000000..61c76aef84 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DefaultMultidocumentPropertiesFileIntegrationTest.java @@ -0,0 +1,22 @@ +package com.baeldung.boot.properties.multidocument; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; + +import com.baeldung.boot.properties.DemoApplication; + +@SpringBootTest(classes = { DemoApplication.class }, webEnvironment = WebEnvironment.MOCK) +public class DefaultMultidocumentPropertiesFileIntegrationTest { + + @Value("${bael.property}") + private String baelCustomProperty; + + @Test + public void givenDefaultProfileActive_whenApplicationStarts_thenDefaultPropertiesUser() { + assertThat(baelCustomProperty).isEqualTo("defaultValue"); + } +} diff --git a/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/ProdMultidocumentPropertiesFileIntegrationTest.java b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/ProdMultidocumentPropertiesFileIntegrationTest.java new file mode 100644 index 0000000000..39bc2da3ba --- /dev/null +++ b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/ProdMultidocumentPropertiesFileIntegrationTest.java @@ -0,0 +1,24 @@ +package com.baeldung.boot.properties.multidocument; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.ActiveProfiles; + +import com.baeldung.boot.properties.DemoApplication; + +@SpringBootTest(classes = { DemoApplication.class }, webEnvironment = WebEnvironment.MOCK) +@ActiveProfiles("prod") +public class ProdMultidocumentPropertiesFileIntegrationTest { + + @Value("${bael.property}") + private String baelCustomProperty; + + @Test + public void givenProductionProfileActive_whenApplicationStarts_thenDefaultPropertiesUser() { + assertThat(baelCustomProperty).isEqualTo("prodValue"); + } +} From 0de32373657be04f4d28ed50bc558a263fd0cb00 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Mon, 11 Jan 2021 14:23:27 -0300 Subject: [PATCH 236/361] improved and updated spring-boot-yaml-vs-properties article code --- ...ation-multidocument-integration.properties | 4 +++ .../src/main/resources/application.properties | 12 +++++++- .../src/main/resources/application.yml | 20 ++++++------- ...ultMultidocumentFilesIntegrationTest.java} | 6 +++- .../DevMultidocumentFilesIntegrationTest.java | 28 +++++++++++++++++++ ...tionMultidocumentFilesIntegrationTest.java | 28 +++++++++++++++++++ ...rodMultidocumentFilesIntegrationTest.java} | 8 ++++-- ...gingMultidocumentFilesIntegrationTest.java | 28 +++++++++++++++++++ 8 files changed, 120 insertions(+), 14 deletions(-) create mode 100644 spring-boot-modules/spring-boot-properties-3/src/main/resources/application-multidocument-integration.properties rename spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/{DefaultMultidocumentPropertiesFileIntegrationTest.java => DefaultMultidocumentFilesIntegrationTest.java} (77%) create mode 100644 spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DevMultidocumentFilesIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/IntegrationMultidocumentFilesIntegrationTest.java rename spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/{ProdMultidocumentPropertiesFileIntegrationTest.java => ProdMultidocumentFilesIntegrationTest.java} (76%) create mode 100644 spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/StagingMultidocumentFilesIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application-multidocument-integration.properties b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application-multidocument-integration.properties new file mode 100644 index 0000000000..c4eeba2589 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application-multidocument-integration.properties @@ -0,0 +1,4 @@ +spring.datasource.password: 'password' +spring.datasource.url: jdbc:mysql://localhost:3306/db_integration +spring.datasource.username: user +bael.property=integrationValue \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.properties b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.properties index bf89182d8a..c2bb5deb45 100644 --- a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.properties +++ b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.properties @@ -9,7 +9,17 @@ spring.datasource.username=SA spring.datasource.password=password app.name=MyApp app.description=${app.name} is a Spring Boot application +logging.file.name=myapplication.log bael.property=defaultValue #--- -spring.config.activate.on-profile=prod +spring.config.activate.on-profile=multidocument-dev +spring.datasource.password=password +spring.datasource.url=jdbc:h2:dev +spring.datasource.username=SA +bael.property=devValue +#--- +spring.config.activate.on-profile=multidocument-prod +spring.datasource.password=password +spring.datasource.url=jdbc:h2:prod +spring.datasource.username=prodUser bael.property=prodValue \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.yml b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.yml index 00baeade9c..33aabb2459 100644 --- a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.yml +++ b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.yml @@ -1,17 +1,17 @@ -logging: - file: - name: myapplication.log -spring: - datasource: - password: 'password' - url: jdbc:h2:dev - username: SA +bael: + root-level-property: defaultRootLevelValue --- spring: + config: + activate: + on-profile: multidocument-staging datasource: password: 'password' - url: jdbc:mysql://localhost:3306/db_production - username: user + url: jdbc:h2:staging + username: SA +bael: + property: stagingValue +--- application: servers: - ip: '127.0.0.1' diff --git a/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DefaultMultidocumentPropertiesFileIntegrationTest.java b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DefaultMultidocumentFilesIntegrationTest.java similarity index 77% rename from spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DefaultMultidocumentPropertiesFileIntegrationTest.java rename to spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DefaultMultidocumentFilesIntegrationTest.java index 61c76aef84..af1f7f705f 100644 --- a/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DefaultMultidocumentPropertiesFileIntegrationTest.java +++ b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DefaultMultidocumentFilesIntegrationTest.java @@ -10,13 +10,17 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import com.baeldung.boot.properties.DemoApplication; @SpringBootTest(classes = { DemoApplication.class }, webEnvironment = WebEnvironment.MOCK) -public class DefaultMultidocumentPropertiesFileIntegrationTest { +public class DefaultMultidocumentFilesIntegrationTest { @Value("${bael.property}") private String baelCustomProperty; + + @Value("${bael.root-level-property}") + private String baelRootProperty; @Test public void givenDefaultProfileActive_whenApplicationStarts_thenDefaultPropertiesUser() { assertThat(baelCustomProperty).isEqualTo("defaultValue"); + assertThat(baelRootProperty).isEqualTo("defaultRootLevelValue"); } } diff --git a/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DevMultidocumentFilesIntegrationTest.java b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DevMultidocumentFilesIntegrationTest.java new file mode 100644 index 0000000000..54188595c0 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/DevMultidocumentFilesIntegrationTest.java @@ -0,0 +1,28 @@ +package com.baeldung.boot.properties.multidocument; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.ActiveProfiles; + +import com.baeldung.boot.properties.DemoApplication; + +@SpringBootTest(classes = { DemoApplication.class }, webEnvironment = WebEnvironment.MOCK) +@ActiveProfiles("multidocument-dev") +public class DevMultidocumentFilesIntegrationTest { + + @Value("${bael.property}") + private String baelCustomProperty; + + @Value("${bael.root-level-property}") + private String baelRootProperty; + + @Test + public void givenDefaultProfileActive_whenApplicationStarts_thenDefaultPropertiesUser() { + assertThat(baelCustomProperty).isEqualTo("devValue"); + assertThat(baelRootProperty).isEqualTo("defaultRootLevelValue"); + } +} diff --git a/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/IntegrationMultidocumentFilesIntegrationTest.java b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/IntegrationMultidocumentFilesIntegrationTest.java new file mode 100644 index 0000000000..f7968f51ad --- /dev/null +++ b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/IntegrationMultidocumentFilesIntegrationTest.java @@ -0,0 +1,28 @@ +package com.baeldung.boot.properties.multidocument; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.ActiveProfiles; + +import com.baeldung.boot.properties.DemoApplication; + +@SpringBootTest(classes = { DemoApplication.class }, webEnvironment = WebEnvironment.MOCK) +@ActiveProfiles("multidocument-integration") +public class IntegrationMultidocumentFilesIntegrationTest { + + @Value("${bael.property}") + private String baelCustomProperty; + + @Value("${bael.root-level-property}") + private String baelRootProperty; + + @Test + public void givenProductionProfileActive_whenApplicationStarts_thenDefaultPropertiesUser() { + assertThat(baelCustomProperty).isEqualTo("integrationValue"); + assertThat(baelRootProperty).isEqualTo("defaultRootLevelValue"); + } +} diff --git a/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/ProdMultidocumentPropertiesFileIntegrationTest.java b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/ProdMultidocumentFilesIntegrationTest.java similarity index 76% rename from spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/ProdMultidocumentPropertiesFileIntegrationTest.java rename to spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/ProdMultidocumentFilesIntegrationTest.java index 39bc2da3ba..9270995da0 100644 --- a/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/ProdMultidocumentPropertiesFileIntegrationTest.java +++ b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/ProdMultidocumentFilesIntegrationTest.java @@ -11,14 +11,18 @@ import org.springframework.test.context.ActiveProfiles; import com.baeldung.boot.properties.DemoApplication; @SpringBootTest(classes = { DemoApplication.class }, webEnvironment = WebEnvironment.MOCK) -@ActiveProfiles("prod") -public class ProdMultidocumentPropertiesFileIntegrationTest { +@ActiveProfiles("multidocument-prod") +public class ProdMultidocumentFilesIntegrationTest { @Value("${bael.property}") private String baelCustomProperty; + + @Value("${bael.root-level-property}") + private String baelRootProperty; @Test public void givenProductionProfileActive_whenApplicationStarts_thenDefaultPropertiesUser() { assertThat(baelCustomProperty).isEqualTo("prodValue"); + assertThat(baelRootProperty).isEqualTo("defaultRootLevelValue"); } } diff --git a/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/StagingMultidocumentFilesIntegrationTest.java b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/StagingMultidocumentFilesIntegrationTest.java new file mode 100644 index 0000000000..8040c93ee0 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/StagingMultidocumentFilesIntegrationTest.java @@ -0,0 +1,28 @@ +package com.baeldung.boot.properties.multidocument; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.ActiveProfiles; + +import com.baeldung.boot.properties.DemoApplication; + +@SpringBootTest(classes = { DemoApplication.class }, webEnvironment = WebEnvironment.MOCK) +@ActiveProfiles("multidocument-staging") +public class StagingMultidocumentFilesIntegrationTest { + + @Value("${bael.property}") + private String baelCustomProperty; + + @Value("${bael.root-level-property}") + private String baelRootProperty; + + @Test + public void givenProductionProfileActive_whenApplicationStarts_thenDefaultPropertiesUser() { + assertThat(baelCustomProperty).isEqualTo("stagingValue"); + assertThat(baelRootProperty).isEqualTo("defaultRootLevelValue"); + } +} From 93e15677438aeebf523d40bdbb003e237261c764 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 12 Jan 2021 19:12:12 +0530 Subject: [PATCH 237/361] JAVA-4013: Moved 1 article to spring-boot-data-2 --- spring-boot-modules/spring-boot-data-2/pom.xml | 9 +++++++++ .../hikari/ApplicationWithHikariConnectionPool.java | 0 .../java/com/baeldung/hikari/HikariIntegrationTest.java | 0 3 files changed, 9 insertions(+) rename {spring-5 => spring-boot-modules/spring-boot-data-2}/src/test/java/com/baeldung/hikari/ApplicationWithHikariConnectionPool.java (100%) rename {spring-5 => spring-boot-modules/spring-boot-data-2}/src/test/java/com/baeldung/hikari/HikariIntegrationTest.java (100%) diff --git a/spring-boot-modules/spring-boot-data-2/pom.xml b/spring-boot-modules/spring-boot-data-2/pom.xml index 199a204500..fb0d5f2053 100644 --- a/spring-boot-modules/spring-boot-data-2/pom.xml +++ b/spring-boot-modules/spring-boot-data-2/pom.xml @@ -16,6 +16,15 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-data-jpa + + + com.h2database + h2 + runtime + \ No newline at end of file diff --git a/spring-5/src/test/java/com/baeldung/hikari/ApplicationWithHikariConnectionPool.java b/spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/hikari/ApplicationWithHikariConnectionPool.java similarity index 100% rename from spring-5/src/test/java/com/baeldung/hikari/ApplicationWithHikariConnectionPool.java rename to spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/hikari/ApplicationWithHikariConnectionPool.java diff --git a/spring-5/src/test/java/com/baeldung/hikari/HikariIntegrationTest.java b/spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/hikari/HikariIntegrationTest.java similarity index 100% rename from spring-5/src/test/java/com/baeldung/hikari/HikariIntegrationTest.java rename to spring-boot-modules/spring-boot-data-2/src/test/java/com/baeldung/hikari/HikariIntegrationTest.java From 6052fd6bc85e12d1ddfe9d2b9e7054d307074858 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 12 Jan 2021 19:14:11 +0530 Subject: [PATCH 238/361] JAVA-4013: Moved 2 articles to spring-testing-2 --- spring-5/pom.xml | 13 +------------ testing-modules/spring-testing-2/pom.xml | 17 +++++++++++++++++ .../Spring5JUnit4ConcurrentIntegrationTest.java | 2 +- .../com/baeldung/enabledif}/EnabledOnJava8.java | 2 +- ...Spring5EnabledAnnotationIntegrationTest.java | 2 +- 5 files changed, 21 insertions(+), 15 deletions(-) rename {spring-5/src/test/java/com/baeldung => testing-modules/spring-testing-2/src/test/java/com/baeldung/concurrent}/Spring5JUnit4ConcurrentIntegrationTest.java (98%) rename {spring-5/src/test/java/com/baeldung/jupiter => testing-modules/spring-testing-2/src/test/java/com/baeldung/enabledif}/EnabledOnJava8.java (93%) rename {spring-5/src/test/java/com/baeldung/jupiter => testing-modules/spring-testing-2/src/test/java/com/baeldung/enabledif}/Spring5EnabledAnnotationIntegrationTest.java (97%) diff --git a/spring-5/pom.xml b/spring-5/pom.xml index eadfb5e512..e368bcacba 100644 --- a/spring-5/pom.xml +++ b/spring-5/pom.xml @@ -133,18 +133,7 @@ - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - methods - true - - + diff --git a/testing-modules/spring-testing-2/pom.xml b/testing-modules/spring-testing-2/pom.xml index 807b84c676..4686a20202 100644 --- a/testing-modules/spring-testing-2/pom.xml +++ b/testing-modules/spring-testing-2/pom.xml @@ -54,8 +54,25 @@ + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + methods + true + + + + 1.12.2 + 2.21.0 \ No newline at end of file diff --git a/spring-5/src/test/java/com/baeldung/Spring5JUnit4ConcurrentIntegrationTest.java b/testing-modules/spring-testing-2/src/test/java/com/baeldung/concurrent/Spring5JUnit4ConcurrentIntegrationTest.java similarity index 98% rename from spring-5/src/test/java/com/baeldung/Spring5JUnit4ConcurrentIntegrationTest.java rename to testing-modules/spring-testing-2/src/test/java/com/baeldung/concurrent/Spring5JUnit4ConcurrentIntegrationTest.java index 7e494465b2..8a0947ba44 100644 --- a/spring-5/src/test/java/com/baeldung/Spring5JUnit4ConcurrentIntegrationTest.java +++ b/testing-modules/spring-testing-2/src/test/java/com/baeldung/concurrent/Spring5JUnit4ConcurrentIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.concurrent; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-5/src/test/java/com/baeldung/jupiter/EnabledOnJava8.java b/testing-modules/spring-testing-2/src/test/java/com/baeldung/enabledif/EnabledOnJava8.java similarity index 93% rename from spring-5/src/test/java/com/baeldung/jupiter/EnabledOnJava8.java rename to testing-modules/spring-testing-2/src/test/java/com/baeldung/enabledif/EnabledOnJava8.java index c6d3b7ff10..01bdc176e0 100644 --- a/spring-5/src/test/java/com/baeldung/jupiter/EnabledOnJava8.java +++ b/testing-modules/spring-testing-2/src/test/java/com/baeldung/enabledif/EnabledOnJava8.java @@ -1,4 +1,4 @@ -package com.baeldung.jupiter; +package com.baeldung.enabledif; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/spring-5/src/test/java/com/baeldung/jupiter/Spring5EnabledAnnotationIntegrationTest.java b/testing-modules/spring-testing-2/src/test/java/com/baeldung/enabledif/Spring5EnabledAnnotationIntegrationTest.java similarity index 97% rename from spring-5/src/test/java/com/baeldung/jupiter/Spring5EnabledAnnotationIntegrationTest.java rename to testing-modules/spring-testing-2/src/test/java/com/baeldung/enabledif/Spring5EnabledAnnotationIntegrationTest.java index 35363e0ea3..b6ccb2204b 100644 --- a/spring-5/src/test/java/com/baeldung/jupiter/Spring5EnabledAnnotationIntegrationTest.java +++ b/testing-modules/spring-testing-2/src/test/java/com/baeldung/enabledif/Spring5EnabledAnnotationIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.jupiter; +package com.baeldung.enabledif; import static org.junit.jupiter.api.Assertions.assertTrue; From 013902b25364fe5044361f2b536b8af5c2b6557a Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 12 Jan 2021 19:14:50 +0530 Subject: [PATCH 239/361] JAVA-4013: README changes --- spring-5/README.md | 3 --- spring-boot-modules/spring-boot-data-2/README.md | 1 + testing-modules/spring-testing-2/README.md | 2 ++ 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-5/README.md b/spring-5/README.md index cef0fedb4f..cce18bedf8 100644 --- a/spring-5/README.md +++ b/spring-5/README.md @@ -4,13 +4,10 @@ This module contains articles about Spring 5 ### Relevant Articles -- [Concurrent Test Execution in Spring 5](https://www.baeldung.com/spring-5-concurrent-tests) - [Spring 5 Functional Bean Registration](https://www.baeldung.com/spring-5-functional-beans) - [The SpringJUnitConfig and SpringJUnitWebConfig Annotations in Spring 5](https://www.baeldung.com/spring-5-junit-config) -- [Spring 5 Testing with @EnabledIf Annotation](https://www.baeldung.com/spring-5-enabledIf) - [Introduction to Spring REST Docs](https://www.baeldung.com/spring-rest-docs) - [Spring ResponseStatusException](https://www.baeldung.com/spring-response-status-exception) - [Spring Assert Statements](https://www.baeldung.com/spring-assert) -- [Configuring a Hikari Connection Pool with Spring Boot](https://www.baeldung.com/spring-boot-hikari) - [Difference between \ vs \](https://www.baeldung.com/spring-contextannotation-contextcomponentscan) - [Finding the Spring Version](https://www.baeldung.com/spring-find-version) diff --git a/spring-boot-modules/spring-boot-data-2/README.md b/spring-boot-modules/spring-boot-data-2/README.md index d5020ce354..c21ce02a2e 100644 --- a/spring-boot-modules/spring-boot-data-2/README.md +++ b/spring-boot-modules/spring-boot-data-2/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Spring Boot: Customize the Jackson ObjectMapper](https://www.baeldung.com/spring-boot-customize-jackson-objectmapper) +- [Configuring a Hikari Connection Pool with Spring Boot](https://www.baeldung.com/spring-boot-hikari) diff --git a/testing-modules/spring-testing-2/README.md b/testing-modules/spring-testing-2/README.md index 702a02ff27..16b47adeac 100644 --- a/testing-modules/spring-testing-2/README.md +++ b/testing-modules/spring-testing-2/README.md @@ -1,3 +1,5 @@ ## Relevant Articles: - [Guide to @DynamicPropertySource in Spring](https://www.baeldung.com/spring-dynamicpropertysource) +- [Concurrent Test Execution in Spring 5](https://www.baeldung.com/spring-5-concurrent-tests) +- [Spring 5 Testing with @EnabledIf Annotation](https://www.baeldung.com/spring-5-enabledIf) From 1a0655a189734d2d9b50611acf2987d69a2e02f7 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Wed, 13 Jan 2021 10:26:38 -0300 Subject: [PATCH 240/361] added junit-vintage-engine dependency to avoid issues with existing JUnit4 tests These are potential issues, since the dependency is included in the root pom --- testing-modules/spring-testing/pom.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/testing-modules/spring-testing/pom.xml b/testing-modules/spring-testing/pom.xml index 9fe0fd8895..9e0c986bb2 100644 --- a/testing-modules/spring-testing/pom.xml +++ b/testing-modules/spring-testing/pom.xml @@ -39,6 +39,17 @@ spring-boot-starter-test test + + org.junit.vintage + junit-vintage-engine + test + + + org.hamcrest + hamcrest-core + + + org.springframework spring-core From 1ed7c56596a3f29f55b79b85c1a88e7279a2f2bc Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Wed, 13 Jan 2021 11:28:41 -0300 Subject: [PATCH 241/361] changes related to spring-boot-modules/spring-boot-testing boot 2.4.0 upgrade --- spring-boot-modules/spring-boot-testing/pom.xml | 11 +++++++++++ .../BindingYMLPropertiesUnitTest.java | 4 ++-- .../execution/LoadSpringContextIntegrationTest.java | 4 ++-- .../src/test/resources/application.yml | 8 ++++++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/spring-boot-modules/spring-boot-testing/pom.xml b/spring-boot-modules/spring-boot-testing/pom.xml index 5bf626f165..50a1ace2fa 100644 --- a/spring-boot-modules/spring-boot-testing/pom.xml +++ b/spring-boot-modules/spring-boot-testing/pom.xml @@ -51,6 +51,17 @@ spring-boot-starter-test test + + org.junit.vintage + junit-vintage-engine + test + + + org.hamcrest + hamcrest-core + + + diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/configurationproperties/BindingYMLPropertiesUnitTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/configurationproperties/BindingYMLPropertiesUnitTest.java index 5543f5e9e8..99c128997e 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/configurationproperties/BindingYMLPropertiesUnitTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/boot/configurationproperties/BindingYMLPropertiesUnitTest.java @@ -7,13 +7,13 @@ 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.ConfigFileApplicationContextInitializer; +import org.springframework.boot.test.context.ConfigDataApplicationContextInitializer; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) -@ContextConfiguration(initializers = ConfigFileApplicationContextInitializer.class) +@ContextConfiguration(initializers = ConfigDataApplicationContextInitializer.class) @EnableConfigurationProperties(value = ServerConfig.class) @ActiveProfiles("test") public class BindingYMLPropertiesUnitTest { diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java index 6698094550..483c67b7a2 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java @@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.ApplicationRunner; import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer; +import org.springframework.boot.test.context.ConfigDataApplicationContextInitializer; import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -19,7 +19,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { ApplicationCommandLineRunnerApp.class }, - initializers = ConfigFileApplicationContextInitializer.class) + initializers = ConfigDataApplicationContextInitializer.class) public class LoadSpringContextIntegrationTest { @SpyBean TaskService taskService; diff --git a/spring-boot-modules/spring-boot-testing/src/test/resources/application.yml b/spring-boot-modules/spring-boot-testing/src/test/resources/application.yml index 1b46b0f1ff..056b5baffc 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/resources/application.yml +++ b/spring-boot-modules/spring-boot-testing/src/test/resources/application.yml @@ -1,5 +1,7 @@ spring: - profiles: test + config: + activate: + on-profile: test server: address: ip: 192.168.0.4 @@ -7,7 +9,9 @@ server: imgs: /etc/test/imgs --- spring: - profiles: dev + config: + activate: + on-profile: dev server: address: ip: 192.168.0.5 From 3af803eb73f0ea9b3e643c66f6cba20fc8d52dd2 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 14 Jan 2021 00:11:46 +0800 Subject: [PATCH 242/361] Update README.md --- core-java-modules/core-java-io-4/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-io-4/README.md b/core-java-modules/core-java-io-4/README.md index 7cc38bb9fe..c837e2bffc 100644 --- a/core-java-modules/core-java-io-4/README.md +++ b/core-java-modules/core-java-io-4/README.md @@ -4,5 +4,5 @@ This module contains articles about core Java input and output (IO) ### Relevant Articles: -- [Java File Separator vs File Path Separator] +- [Java File Separator vs File Path Separator](https://www.baeldung.com/java-file-vs-file-path-separator) - [[<-- Prev]](/core-java-modules/core-java-io-3) From 974f0f34273b65f08a5f64fd08ebf68133d54383 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 14 Jan 2021 00:13:45 +0800 Subject: [PATCH 243/361] Update README.md --- jackson-modules/jackson-conversions-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/jackson-modules/jackson-conversions-2/README.md b/jackson-modules/jackson-conversions-2/README.md index 71c5578525..9986fe75b5 100644 --- a/jackson-modules/jackson-conversions-2/README.md +++ b/jackson-modules/jackson-conversions-2/README.md @@ -9,4 +9,5 @@ This module contains articles about Jackson conversions. - [Converting JSON to CSV in Java](https://www.baeldung.com/java-converting-json-to-csv) - [How to Process YAML with Jackson](https://www.baeldung.com/jackson-yaml) - [Jackson Streaming API](https://www.baeldung.com/jackson-streaming-api) +- [Jackson: java.util.LinkedHashMap cannot be cast to X](https://www.baeldung.com/jackson-linkedhashmap-cannot-be-cast) - More articles: [[<-- prev]](../jackson-conversions) From 5d14cdd74619575db8617f54ec0dc682ea2961a4 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 14 Jan 2021 00:15:43 +0800 Subject: [PATCH 244/361] Create README.md --- core-java-modules/core-java-concurrency-advanced-4/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 core-java-modules/core-java-concurrency-advanced-4/README.md diff --git a/core-java-modules/core-java-concurrency-advanced-4/README.md b/core-java-modules/core-java-concurrency-advanced-4/README.md new file mode 100644 index 0000000000..98f2894515 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-4/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Binary Semaphore vs Reentrant Lock](https://www.baeldung.com/java-binary-semaphore-vs-reentrant-lock) From eddab4c557548bce7c83bcdacf8800eb0f6c7e64 Mon Sep 17 00:00:00 2001 From: Emmanuel Yasa Date: Thu, 14 Jan 2021 01:36:35 +0800 Subject: [PATCH 245/361] [BAEL-4601] Revision: Simplifies assertions --- .../jpa/hibernateunproxy/HibernateProxyIntegrationTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/hibernateunproxy/HibernateProxyIntegrationTest.java b/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/hibernateunproxy/HibernateProxyIntegrationTest.java index a831639f5d..717745bb13 100644 --- a/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/hibernateunproxy/HibernateProxyIntegrationTest.java +++ b/persistence-modules/java-jpa-3/src/test/java/com/baeldung/jpa/hibernateunproxy/HibernateProxyIntegrationTest.java @@ -27,7 +27,7 @@ public class HibernateProxyIntegrationTest { @Test public void givenPaymentReceipt_whenAccessingPayment_thenVerifyType() { PaymentReceipt paymentReceipt = entityManager.find(PaymentReceipt.class, 3L); - Assert.assertEquals(true, paymentReceipt.getPayment() instanceof HibernateProxy); + Assert.assertTrue(paymentReceipt.getPayment() instanceof HibernateProxy); } @Test @@ -39,7 +39,7 @@ public class HibernateProxyIntegrationTest { entityManager.persist(payment); entityManager.getTransaction().commit(); - Assert.assertEquals(true, webUser instanceof HibernateProxy); + Assert.assertTrue(webUser instanceof HibernateProxy); } @Test @@ -53,7 +53,7 @@ public class HibernateProxyIntegrationTest { @Test public void givenPaymentReceipt_whenPaymentIsUnproxied_thenReturnRealEntityObject() { PaymentReceipt paymentReceipt = entityManager.find(PaymentReceipt.class, 3L); - Assert.assertEquals(true, Hibernate.unproxy(paymentReceipt.getPayment()) instanceof CreditCardPayment); + Assert.assertTrue(Hibernate.unproxy(paymentReceipt.getPayment()) instanceof CreditCardPayment); } private static void populateH2DB() { From 0785727da410d21dcf1b67660d84210583a93dd9 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 14 Jan 2021 13:45:12 +0800 Subject: [PATCH 246/361] Create README.md --- guest/core-kotlin/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 guest/core-kotlin/README.md diff --git a/guest/core-kotlin/README.md b/guest/core-kotlin/README.md new file mode 100644 index 0000000000..c211773f27 --- /dev/null +++ b/guest/core-kotlin/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Kotlin vs Java](https://www.baeldung.com/kotlin/kotlin-vs-java) From 7e51af38d962b0f26f630bc0db1527778a7c4f87 Mon Sep 17 00:00:00 2001 From: CHANDRAKANT Kumar Date: Thu, 14 Jan 2021 15:18:33 +0530 Subject: [PATCH 247/361] Corrected the name of unit test to mark them as manual. --- ....java => MyCounterJCStressManualTest.java} | 8 ++- ...> MyCounterMultithreadedTCManualTest.java} | 12 ++-- .../concurrent/MyCounterSimpleManualTest.java | 63 +++++++++++++++++++ .../concurrent/MyCounterSimpleUnitTest.java | 60 ------------------ .../MyCounterTempusFugitManualTest.java | 41 ++++++++++++ .../MyCounterTempusFugitUnitTest.java | 37 ----------- .../MyCounterThreadWeaverManualTest.java | 48 ++++++++++++++ .../MyCounterThreadWeaverUnitTest.java | 44 ------------- 8 files changed, 167 insertions(+), 146 deletions(-) rename core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/{MyCounterJCStressUnitTest.java => MyCounterJCStressManualTest.java} (74%) rename core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/{MyCounterMultithreadedTCUnitTest.java => MyCounterMultithreadedTCManualTest.java} (59%) create mode 100644 core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterSimpleManualTest.java delete mode 100644 core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java create mode 100644 core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitManualTest.java delete mode 100644 core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java create mode 100644 core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverManualTest.java delete mode 100644 core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java diff --git a/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterJCStressUnitTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterJCStressManualTest.java similarity index 74% rename from core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterJCStressUnitTest.java rename to core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterJCStressManualTest.java index 6c76505347..0e6b41d1e9 100644 --- a/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterJCStressUnitTest.java +++ b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterJCStressManualTest.java @@ -10,11 +10,17 @@ import org.openjdk.jcstress.annotations.Outcome; import org.openjdk.jcstress.annotations.State; import org.openjdk.jcstress.infra.results.I_Result; +/** + * This is defined as a manual test because it tries to simulate the race conditions + * in a concurrent program that is poorly designed and hence may fail nondeterministically. + * This will help the CI jobs to ignore these tests and a developer to run them manually. + * + */ @JCStressTest @Outcome(id = "1", expect = ACCEPTABLE_INTERESTING, desc = "One update lost.") @Outcome(id = "2", expect = ACCEPTABLE, desc = "Both updates.") @State -public class MyCounterJCStressUnitTest { +public class MyCounterJCStressManualTest { private MyCounter counter; diff --git a/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCUnitTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCManualTest.java similarity index 59% rename from core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCUnitTest.java rename to core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCManualTest.java index 8a0bedf6c2..985e316635 100644 --- a/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCUnitTest.java +++ b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCManualTest.java @@ -1,12 +1,17 @@ package com.baeldung.concurrent; -import org.junit.Ignore; import org.junit.Test; import edu.umd.cs.mtc.MultithreadedTestCase; import edu.umd.cs.mtc.TestFramework; -public class MyCounterMultithreadedTCUnitTest extends MultithreadedTestCase { +/** + * This is defined as a manual test because it tries to simulate the race conditions + * in a concurrent program that is poorly designed and hence may fail nondeterministically. + * This will help the CI jobs to ignore these tests and a developer to run them manually. + * + */ +public class MyCounterMultithreadedTCManualTest extends MultithreadedTestCase { private MyCounter counter; @@ -29,9 +34,8 @@ public class MyCounterMultithreadedTCUnitTest extends MultithreadedTestCase { assertEquals(2, counter.getCount()); } - @Ignore @Test public void testCounter() throws Throwable { - TestFramework.runManyTimes(new MyCounterMultithreadedTCUnitTest(), 1000); + TestFramework.runManyTimes(new MyCounterMultithreadedTCManualTest(), 1000); } } diff --git a/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterSimpleManualTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterSimpleManualTest.java new file mode 100644 index 0000000000..cba30da34b --- /dev/null +++ b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterSimpleManualTest.java @@ -0,0 +1,63 @@ +package com.baeldung.concurrent; + +import static org.junit.Assert.assertEquals; + +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import org.junit.Test; + +/** + * This is defined as a manual test because it tries to simulate the race conditions + * in a concurrent program that is poorly designed and hence may fail nondeterministically. + * This will help the CI jobs to ignore these tests and a developer to run them manually. + * + */ +public class MyCounterSimpleManualTest { + + @Test + public void testCounter() { + MyCounter counter = new MyCounter(); + for (int i = 0; i < 500; i++) + counter.increment(); + assertEquals(500, counter.getCount()); + } + + @Test + public void testCounterWithConcurrency() throws InterruptedException { + int numberOfThreads = 100; + ExecutorService service = Executors.newFixedThreadPool(10); + CountDownLatch latch = new CountDownLatch(numberOfThreads); + MyCounter counter = new MyCounter(); + for (int i = 0; i < numberOfThreads; i++) { + service.execute(() -> { + counter.increment(); + latch.countDown(); + }); + } + latch.await(); + assertEquals(numberOfThreads, counter.getCount()); + } + + @Test + public void testSummationWithConcurrencyAndWait() throws InterruptedException { + int numberOfThreads = 2; + ExecutorService service = Executors.newFixedThreadPool(10); + CountDownLatch latch = new CountDownLatch(numberOfThreads); + MyCounter counter = new MyCounter(); + for (int i = 0; i < numberOfThreads; i++) { + service.submit(() -> { + try { + counter.incrementWithWait(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + latch.countDown(); + }); + } + latch.await(); + assertEquals(numberOfThreads, counter.getCount()); + } + +} diff --git a/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java deleted file mode 100644 index 9a405e7e24..0000000000 --- a/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.baeldung.concurrent; - -import static org.junit.Assert.assertEquals; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import org.junit.Ignore; -import org.junit.Test; - -public class MyCounterSimpleUnitTest { - - @Test - public void testCounter() { - MyCounter counter = new MyCounter(); - for (int i = 0; i < 500; i++) - counter.increment(); - assertEquals(500, counter.getCount()); - } - - @Ignore - @Test - public void testCounterWithConcurrency() throws InterruptedException { - int numberOfThreads = 100; - ExecutorService service = Executors.newFixedThreadPool(10); - CountDownLatch latch = new CountDownLatch(numberOfThreads); - MyCounter counter = new MyCounter(); - for (int i = 0; i < numberOfThreads; i++) { - service.execute(() -> { - counter.increment(); - latch.countDown(); - }); - } - latch.await(); - assertEquals(numberOfThreads, counter.getCount()); - } - - @Ignore - @Test - public void testSummationWithConcurrencyAndWait() throws InterruptedException { - int numberOfThreads = 2; - ExecutorService service = Executors.newFixedThreadPool(10); - CountDownLatch latch = new CountDownLatch(numberOfThreads); - MyCounter counter = new MyCounter(); - for (int i = 0; i < numberOfThreads; i++) { - service.submit(() -> { - try { - counter.incrementWithWait(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - latch.countDown(); - }); - } - latch.await(); - assertEquals(numberOfThreads, counter.getCount()); - } - -} diff --git a/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitManualTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitManualTest.java new file mode 100644 index 0000000000..a4ac643f7e --- /dev/null +++ b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitManualTest.java @@ -0,0 +1,41 @@ +package com.baeldung.concurrent; + +import static org.junit.Assert.assertEquals; + +import org.junit.AfterClass; +import org.junit.Rule; +import org.junit.Test; + +import com.google.code.tempusfugit.concurrency.ConcurrentRule; +import com.google.code.tempusfugit.concurrency.RepeatingRule; +import com.google.code.tempusfugit.concurrency.annotations.Concurrent; +import com.google.code.tempusfugit.concurrency.annotations.Repeating; + +/** + * This is defined as a manual test because it tries to simulate the race conditions + * in a concurrent program that is poorly designed and hence may fail nondeterministically. + * This will help the CI jobs to ignore these tests and a developer to run them manually. + * + */ +public class MyCounterTempusFugitManualTest { + + @Rule + public ConcurrentRule concurrently = new ConcurrentRule(); + @Rule + public RepeatingRule rule = new RepeatingRule(); + + private static MyCounter counter = new MyCounter(); + + @Test + @Concurrent(count = 2) + @Repeating(repetition = 10) + public void runsMultipleTimes() { + counter.increment(); + } + + @AfterClass + public static void annotatedTestRunsMultipleTimes() throws InterruptedException { + assertEquals(counter.getCount(), 20); + } + +} diff --git a/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java deleted file mode 100644 index 36a2031e78..0000000000 --- a/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.baeldung.concurrent; - -import static org.junit.Assert.assertEquals; - -import org.junit.AfterClass; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; - -import com.google.code.tempusfugit.concurrency.ConcurrentRule; -import com.google.code.tempusfugit.concurrency.RepeatingRule; -import com.google.code.tempusfugit.concurrency.annotations.Concurrent; -import com.google.code.tempusfugit.concurrency.annotations.Repeating; - -public class MyCounterTempusFugitUnitTest { - - @Rule - public ConcurrentRule concurrently = new ConcurrentRule(); - @Rule - public RepeatingRule rule = new RepeatingRule(); - - private static MyCounter counter = new MyCounter(); - - @Ignore - @Test - @Concurrent(count = 2) - @Repeating(repetition = 10) - public void runsMultipleTimes() { - counter.increment(); - } - - @AfterClass - public static void annotatedTestRunsMultipleTimes() throws InterruptedException { - assertEquals(counter.getCount(), 20); - } - -} diff --git a/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverManualTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverManualTest.java new file mode 100644 index 0000000000..2acfc4ee71 --- /dev/null +++ b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverManualTest.java @@ -0,0 +1,48 @@ +package com.baeldung.concurrent; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.google.testing.threadtester.AnnotatedTestRunner; +import com.google.testing.threadtester.ThreadedAfter; +import com.google.testing.threadtester.ThreadedBefore; +import com.google.testing.threadtester.ThreadedMain; +import com.google.testing.threadtester.ThreadedSecondary; + +/** + * This is defined as a manual test because it tries to simulate the race conditions + * in a concurrent program that is poorly designed and hence may fail nondeterministically. + * This will help the CI jobs to ignore these tests and a developer to run them manually. + * + */ +public class MyCounterThreadWeaverManualTest { + + private MyCounter counter; + + @ThreadedBefore + public void before() { + counter = new MyCounter(); + } + + @ThreadedMain + public void mainThread() { + counter.increment(); + } + + @ThreadedSecondary + public void secondThread() { + counter.increment(); + } + + @ThreadedAfter + public void after() { + assertEquals(2, counter.getCount()); + } + + @Test + public void testCounter() { + new AnnotatedTestRunner().runTests(this.getClass(), MyCounter.class); + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java deleted file mode 100644 index e65a963584..0000000000 --- a/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.baeldung.concurrent; - -import static org.junit.Assert.assertEquals; - -import org.junit.Ignore; -import org.junit.Test; - -import com.google.testing.threadtester.AnnotatedTestRunner; -import com.google.testing.threadtester.ThreadedAfter; -import com.google.testing.threadtester.ThreadedBefore; -import com.google.testing.threadtester.ThreadedMain; -import com.google.testing.threadtester.ThreadedSecondary; - -public class MyCounterThreadWeaverUnitTest { - - private MyCounter counter; - - @ThreadedBefore - public void before() { - counter = new MyCounter(); - } - - @ThreadedMain - public void mainThread() { - counter.increment(); - } - - @ThreadedSecondary - public void secondThread() { - counter.increment(); - } - - @ThreadedAfter - public void after() { - assertEquals(2, counter.getCount()); - } - - @Ignore - @Test - public void testCounter() { - new AnnotatedTestRunner().runTests(this.getClass(), MyCounter.class); - } - -} \ No newline at end of file From 1c5185b54940c2089fc7a558f2bb614e3d256217 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Thu, 14 Jan 2021 11:43:32 -0300 Subject: [PATCH 248/361] added junit-vintage-engine dependency to avoid issues with existing JUnit4 tests --- spring-boot-modules/spring-boot-environment/pom.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spring-boot-modules/spring-boot-environment/pom.xml b/spring-boot-modules/spring-boot-environment/pom.xml index d34bbd18c0..e3a8186cbf 100644 --- a/spring-boot-modules/spring-boot-environment/pom.xml +++ b/spring-boot-modules/spring-boot-environment/pom.xml @@ -33,6 +33,17 @@ spring-boot-starter-test test + + org.junit.vintage + junit-vintage-engine + test + + + org.hamcrest + hamcrest-core + + + org.springframework.boot From 52db422b6c303b1b9018a85d842981ff427eece4 Mon Sep 17 00:00:00 2001 From: Umang Budhwar Date: Fri, 15 Jan 2021 04:34:00 +0530 Subject: [PATCH 249/361] BAEL-4695 - Evaluating a Math Expression in Java (#10345) * Added code for checking if a class is abstract or not. * Renamed test name as per review comments. * BAEL-4695 - Added code to evaluate math expressions. * BAEL-4695 - Added test case for math function. * BAEL-4695 Added consistent examples and entry in parent pom. * BAEL-4695 - Added more examples --- .../core-java-lang-math-3/pom.xml | 35 +++++++ .../EvalauteMathExpressionsUnitTest.java | 91 +++++++++++++++++++ core-java-modules/pom.xml | 1 + 3 files changed, 127 insertions(+) create mode 100644 core-java-modules/core-java-lang-math-3/pom.xml create mode 100644 core-java-modules/core-java-lang-math-3/src/test/java/com/baeldung/math/evaluate/EvalauteMathExpressionsUnitTest.java diff --git a/core-java-modules/core-java-lang-math-3/pom.xml b/core-java-modules/core-java-lang-math-3/pom.xml new file mode 100644 index 0000000000..27c2372ab6 --- /dev/null +++ b/core-java-modules/core-java-lang-math-3/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + core-java-lang-math-3 + 0.0.1-SNAPSHOT + core-java-lang-math-3 + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + ../ + + + + + net.objecthunter + exp4j + 0.4.8 + + + + com.fathzer + javaluator + 3.0.3 + + + + + + + + + diff --git a/core-java-modules/core-java-lang-math-3/src/test/java/com/baeldung/math/evaluate/EvalauteMathExpressionsUnitTest.java b/core-java-modules/core-java-lang-math-3/src/test/java/com/baeldung/math/evaluate/EvalauteMathExpressionsUnitTest.java new file mode 100644 index 0000000000..a251e8d545 --- /dev/null +++ b/core-java-modules/core-java-lang-math-3/src/test/java/com/baeldung/math/evaluate/EvalauteMathExpressionsUnitTest.java @@ -0,0 +1,91 @@ +package com.baeldung.math.evaluate; + +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.ScriptException; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import com.fathzer.soft.javaluator.DoubleEvaluator; +import com.fathzer.soft.javaluator.StaticVariableSet; + +import net.objecthunter.exp4j.Expression; +import net.objecthunter.exp4j.ExpressionBuilder; + +public class EvalauteMathExpressionsUnitTest { + + @Test + public void givenSimpleExpression_whenCallEvaluateMethod_thenSuccess() { + Expression expression = new ExpressionBuilder("3+2").build(); + double result = expression.evaluate(); + Assertions.assertEquals(5, result); + } + + @Test + public void givenTwoVariables_whenCallEvaluateMethod_thenSuccess() { + Expression expression = new ExpressionBuilder("3x+2y").variables("x", "y") + .build() + .setVariable("x", 2) + .setVariable("y", 3); + double result = expression.evaluate(); + Assertions.assertEquals(12, result); + } + + @Test + public void givenMathFunctions_whenCallEvaluateMethod_thenSuccess() { + Expression expression = new ExpressionBuilder("sin(x)*sin(x)+cos(x)*cos(x)").variables("x") + .build() + .setVariable("x", 0.5); + double result = expression.evaluate(); + Assertions.assertEquals(1, result); + } + + @Test + public void givenExpression_whenCallEvaluateMethod_thenSuccess() { + String expression = "3+2"; + DoubleEvaluator eval = new DoubleEvaluator(); + Double result = eval.evaluate(expression); + Assertions.assertEquals(5, result); + } + + @Test + public void givenVariables_whenCallEvaluateMethod_thenSuccess() { + String expression = "3*x+2*y"; + DoubleEvaluator eval = new DoubleEvaluator(); + StaticVariableSet variables = new StaticVariableSet(); + variables.set("x", 2.0); + variables.set("y", 3.0); + Double result = eval.evaluate(expression, variables); + Assertions.assertEquals(12, result); + } + + @Test + public void givenMathFunction_whenCallEvaluateMethod_thenSuccess() { + String expression = "sin(x)*sin(x)+cos(x)*cos(x)"; + DoubleEvaluator eval = new DoubleEvaluator(); + StaticVariableSet variables = new StaticVariableSet(); + variables.set("x", 0.5); + Double result = eval.evaluate(expression, variables); + Assertions.assertEquals(1, result); + } + + @Test + public void givenJavaScriptingApiAndSimpleExpression_whenCallEvalMethod_thenSuccess() throws ScriptException { + ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); + ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("JavaScript"); + String expression = "3+2"; + Integer result = (Integer) scriptEngine.eval(expression); + Assertions.assertEquals(5, result); + } + + @Test + public void givenJavaScriptingApi_whenCallEvalMethod_thenSuccess() throws ScriptException { + ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); + ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("JavaScript"); + String expression = "x=2; y=3; 3*x+2*y;"; + Double result = (Double) scriptEngine.eval(expression); + Assertions.assertEquals(12, result); + } + +} diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 140d5efe3b..2d342c4216 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -84,6 +84,7 @@ core-java-lang-3 core-java-lang-math core-java-lang-math-2 + core-java-lang-math-3 core-java-lang-oop-constructors core-java-lang-oop-patterns core-java-lang-oop-generics From e54423ce83c48abda00ca295eb1d29ef6501a28e Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 15 Jan 2021 23:15:41 +0530 Subject: [PATCH 250/361] JAVA-4010: Added new module and moved 3 articles to it --- .../spring-resttemplate-3/.gitignore | 12 ++ .../spring-resttemplate-3/README.md | 11 ++ .../spring-resttemplate-3/pom.xml | 29 +++++ .../lists/EmployeeApplication.java | 16 +++ .../lists/client/EmployeeClient.java | 120 ++++++++++++++++++ .../lists/controller/EmployeeResource.java | 46 +++++++ .../resttemplate/lists/dto/Employee.java | 40 ++++++ .../resttemplate/lists/dto/EmployeeList.java | 29 +++++ .../lists/service/EmployeeService.java | 25 ++++ .../web/upload/app/UploadApplication.java | 17 +++ .../client/MultipartFileUploadClient.java | 61 +++++++++ .../upload/controller/FileServerResource.java | 43 +++++++ .../src/main/resources/application.properties | 2 + .../src/main/resources/logback.xml | 23 ++++ .../java/com/baeldung/SpringContextTest.java | 15 +++ .../LargeFileDownloadIntegrationTest.java | 105 +++++++++++++++ .../src/test/resources/.gitignore | 13 ++ .../src/test/resources/logback-test.xml | 23 ++++ 18 files changed, 630 insertions(+) create mode 100644 spring-web-modules/spring-resttemplate-3/.gitignore create mode 100644 spring-web-modules/spring-resttemplate-3/README.md create mode 100644 spring-web-modules/spring-resttemplate-3/pom.xml create mode 100644 spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/EmployeeApplication.java create mode 100644 spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java create mode 100644 spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/controller/EmployeeResource.java create mode 100644 spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/dto/Employee.java create mode 100644 spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/dto/EmployeeList.java create mode 100644 spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/service/EmployeeService.java create mode 100644 spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/web/upload/app/UploadApplication.java create mode 100644 spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/web/upload/client/MultipartFileUploadClient.java create mode 100644 spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/web/upload/controller/FileServerResource.java create mode 100644 spring-web-modules/spring-resttemplate-3/src/main/resources/application.properties create mode 100644 spring-web-modules/spring-resttemplate-3/src/main/resources/logback.xml create mode 100644 spring-web-modules/spring-resttemplate-3/src/test/java/com/baeldung/SpringContextTest.java create mode 100644 spring-web-modules/spring-resttemplate-3/src/test/java/com/baeldung/largefile/LargeFileDownloadIntegrationTest.java create mode 100644 spring-web-modules/spring-resttemplate-3/src/test/resources/.gitignore create mode 100644 spring-web-modules/spring-resttemplate-3/src/test/resources/logback-test.xml diff --git a/spring-web-modules/spring-resttemplate-3/.gitignore b/spring-web-modules/spring-resttemplate-3/.gitignore new file mode 100644 index 0000000000..8f98975dc9 --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/.gitignore @@ -0,0 +1,12 @@ +*.class + +#folders# +/target +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-web-modules/spring-resttemplate-3/README.md b/spring-web-modules/spring-resttemplate-3/README.md new file mode 100644 index 0000000000..6a00d226db --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/README.md @@ -0,0 +1,11 @@ +## Spring RestTemplate + +This module contains articles about Spring RestTemplate + +### The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring + +### Relevant Articles: +- [Uploading MultipartFile with Spring RestTemplate](https://www.baeldung.com/spring-rest-template-multipart-upload) +- [Get and Post Lists of Objects with RestTemplate](https://www.baeldung.com/spring-rest-template-list) +- [Download a Large File Through a Spring RestTemplate](https://www.baeldung.com/spring-resttemplate-download-large-file) \ No newline at end of file diff --git a/spring-web-modules/spring-resttemplate-3/pom.xml b/spring-web-modules/spring-resttemplate-3/pom.xml new file mode 100644 index 0000000000..b1c26e002f --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/pom.xml @@ -0,0 +1,29 @@ + + + 4.0.0 + spring-resttemplate-3 + 0.1-SNAPSHOT + spring-resttemplate-3 + war + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + + + + diff --git a/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/EmployeeApplication.java b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/EmployeeApplication.java new file mode 100644 index 0000000000..1967d4f2aa --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/EmployeeApplication.java @@ -0,0 +1,16 @@ +package com.baeldung.resttemplate.lists; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Sample application used to demonstrate working with Lists and RestTemplate. + */ +@SpringBootApplication +public class EmployeeApplication +{ + public static void main(String[] args) + { + SpringApplication.run(EmployeeApplication.class, args); + } +} diff --git a/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java new file mode 100644 index 0000000000..49e375f9cc --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java @@ -0,0 +1,120 @@ +package com.baeldung.resttemplate.lists.client; + +import com.baeldung.resttemplate.lists.dto.Employee; +import com.baeldung.resttemplate.lists.dto.EmployeeList; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; + +import java.util.ArrayList; +import java.util.List; + +import static java.util.Arrays.asList; + +/** + * Application that shows how to use Lists with RestTemplate. + */ +public class EmployeeClient { + public static void main(String[] args) { + EmployeeClient employeeClient = new EmployeeClient(); + + System.out.println("Calling GET for entity using arrays"); + employeeClient.getForEntityEmployeesAsArray(); + + System.out.println("Calling GET using ParameterizedTypeReference"); + employeeClient.getAllEmployeesUsingParameterizedTypeReference(); + + System.out.println("Calling GET using wrapper class"); + employeeClient.getAllEmployeesUsingWrapperClass(); + + System.out.println("Calling POST using normal lists"); + employeeClient.createEmployeesUsingLists(); + + System.out.println("Calling POST using wrapper class"); + employeeClient.createEmployeesUsingWrapperClass(); + } + + public EmployeeClient() { + + } + + public Employee[] getForEntityEmployeesAsArray() { + + RestTemplate restTemplate = new RestTemplate(); + + ResponseEntity response = + restTemplate.getForEntity( + "http://localhost:8082/spring-rest/employees/", + Employee[].class); + + Employee[] employees = response.getBody(); + + assert employees != null; + asList(employees).forEach(System.out::println); + + return employees; + + } + + + public List getAllEmployeesUsingParameterizedTypeReference() { + RestTemplate restTemplate = new RestTemplate(); + + ResponseEntity> response = + restTemplate.exchange( + "http://localhost:8082/spring-rest/employees/", + HttpMethod.GET, + null, + new ParameterizedTypeReference>() { + }); + + List employees = response.getBody(); + + assert employees != null; + employees.forEach(System.out::println); + + return employees; + } + + public List getAllEmployeesUsingWrapperClass() { + RestTemplate restTemplate = new RestTemplate(); + + EmployeeList response = + restTemplate.getForObject( + "http://localhost:8082/spring-rest/employees/v2", + EmployeeList.class); + + List employees = response.getEmployees(); + + employees.forEach(System.out::println); + + return employees; + } + + public void createEmployeesUsingLists() { + RestTemplate restTemplate = new RestTemplate(); + + List newEmployees = new ArrayList<>(); + newEmployees.add(new Employee(3, "Intern")); + newEmployees.add(new Employee(4, "CEO")); + + restTemplate.postForObject( + "http://localhost:8082/spring-rest/employees/", + newEmployees, + ResponseEntity.class); + } + + public void createEmployeesUsingWrapperClass() { + RestTemplate restTemplate = new RestTemplate(); + + List newEmployees = new ArrayList<>(); + newEmployees.add(new Employee(3, "Intern")); + newEmployees.add(new Employee(4, "CEO")); + + restTemplate.postForObject( + "http://localhost:8082/spring-rest/employees/v2/", + new EmployeeList(newEmployees), + ResponseEntity.class); + } +} diff --git a/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/controller/EmployeeResource.java b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/controller/EmployeeResource.java new file mode 100644 index 0000000000..8a4d510f63 --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/controller/EmployeeResource.java @@ -0,0 +1,46 @@ +package com.baeldung.resttemplate.lists.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.resttemplate.lists.dto.Employee; +import com.baeldung.resttemplate.lists.dto.EmployeeList; +import com.baeldung.resttemplate.lists.service.EmployeeService; + +import java.util.List; + +@RestController +@RequestMapping("/employees") +public class EmployeeResource +{ + @Autowired + private EmployeeService employeeService; + + @RequestMapping(method = RequestMethod.GET, path = "/") + public List getEmployees() + { + return employeeService.getAllEmployees(); + } + + @RequestMapping(method = RequestMethod.GET, path = "/v2") + public EmployeeList getEmployeesUsingWrapperClass() + { + List employees = employeeService.getAllEmployees(); + return new EmployeeList(employees); + } + + @RequestMapping(method = RequestMethod.POST, path = "/") + public void addEmployees(@RequestBody List employees) + { + employeeService.addEmployees(employees); + } + + @RequestMapping(method = RequestMethod.POST, path = "/v2") + public void addEmployeesUsingWrapperClass(@RequestBody EmployeeList employeeWrapper) + { + employeeService.addEmployees(employeeWrapper.getEmployees()); + } +} diff --git a/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/dto/Employee.java b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/dto/Employee.java new file mode 100644 index 0000000000..0754c13c5b --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/dto/Employee.java @@ -0,0 +1,40 @@ +package com.baeldung.resttemplate.lists.dto; + +public class Employee { + + public long id; + public String title; + + public Employee() + { + + } + + public Employee(long id, String title) + { + this.id = id; + this.title = title; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + @Override + public String toString() + { + return "Employee #" + id + "[" + title + "]"; + } +} diff --git a/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/dto/EmployeeList.java b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/dto/EmployeeList.java new file mode 100644 index 0000000000..eeabbfe450 --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/dto/EmployeeList.java @@ -0,0 +1,29 @@ +package com.baeldung.resttemplate.lists.dto; + +import java.util.ArrayList; +import java.util.List; + +public class EmployeeList +{ + public List employees; + + public EmployeeList() + { + employees = new ArrayList<>(); + } + + public EmployeeList(List employees) + { + this.employees = employees; + } + + public void setEmployees(List employees) + { + this.employees = employees; + } + + public List getEmployees() + { + return employees; + } +} diff --git a/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/service/EmployeeService.java b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/service/EmployeeService.java new file mode 100644 index 0000000000..8a1773483a --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/resttemplate/lists/service/EmployeeService.java @@ -0,0 +1,25 @@ +package com.baeldung.resttemplate.lists.service; + +import org.springframework.stereotype.Service; + +import com.baeldung.resttemplate.lists.dto.Employee; + +import java.util.ArrayList; +import java.util.List; + +@Service("EmployeeListService") +public class EmployeeService +{ + public List getAllEmployees() + { + List employees = new ArrayList<>(); + employees.add(new Employee(1, "Manager")); + employees.add(new Employee(2, "Java Developer")); + return employees; + } + + public void addEmployees(List employees) + { + employees.forEach(e -> System.out.println("Adding new employee " + e)); + } +} diff --git a/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/web/upload/app/UploadApplication.java b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/web/upload/app/UploadApplication.java new file mode 100644 index 0000000000..f3b1c0dc6f --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/web/upload/app/UploadApplication.java @@ -0,0 +1,17 @@ +package com.baeldung.web.upload.app; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.context.annotation.ComponentScan; + +@EnableAutoConfiguration +@ComponentScan("com.baeldung.web.upload") +@SpringBootApplication +public class UploadApplication extends SpringBootServletInitializer { + + public static void main(final String[] args) { + SpringApplication.run(UploadApplication.class, args); + } +} \ No newline at end of file diff --git a/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/web/upload/client/MultipartFileUploadClient.java b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/web/upload/client/MultipartFileUploadClient.java new file mode 100644 index 0000000000..547aec17a0 --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/web/upload/client/MultipartFileUploadClient.java @@ -0,0 +1,61 @@ +package com.baeldung.web.upload.client; + +import org.springframework.core.io.FileSystemResource; +import org.springframework.core.io.Resource; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +public class MultipartFileUploadClient { + + public static void main(String[] args) throws IOException { + uploadSingleFile(); + uploadMultipleFile(); + } + + private static void uploadSingleFile() throws IOException { + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.MULTIPART_FORM_DATA); + + MultiValueMap body = new LinkedMultiValueMap<>(); + body.add("file", getTestFile()); + + + HttpEntity> requestEntity = new HttpEntity<>(body, headers); + String serverUrl = "http://localhost:8082/spring-rest/fileserver/singlefileupload/"; + RestTemplate restTemplate = new RestTemplate(); + ResponseEntity response = restTemplate.postForEntity(serverUrl, requestEntity, String.class); + System.out.println("Response code: " + response.getStatusCode()); + } + + private static void uploadMultipleFile() throws IOException { + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.MULTIPART_FORM_DATA); + + MultiValueMap body = new LinkedMultiValueMap<>(); + body.add("files", getTestFile()); + body.add("files", getTestFile()); + body.add("files", getTestFile()); + + HttpEntity> requestEntity = new HttpEntity<>(body, headers); + String serverUrl = "http://localhost:8082/spring-rest/fileserver/multiplefileupload/"; + RestTemplate restTemplate = new RestTemplate(); + ResponseEntity response = restTemplate.postForEntity(serverUrl, requestEntity, String.class); + System.out.println("Response code: " + response.getStatusCode()); + } + + public static Resource getTestFile() throws IOException { + Path testFile = Files.createTempFile("test-file", ".txt"); + System.out.println("Creating and Uploading Test File: " + testFile); + Files.write(testFile, "Hello World !!, This is a test file.".getBytes()); + return new FileSystemResource(testFile.toFile()); + } +} diff --git a/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/web/upload/controller/FileServerResource.java b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/web/upload/controller/FileServerResource.java new file mode 100644 index 0000000000..3863a8f20d --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/web/upload/controller/FileServerResource.java @@ -0,0 +1,43 @@ +package com.baeldung.web.upload.controller; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.List; + +@RestController +@RequestMapping("/fileserver") +public class FileServerResource { + + @RequestMapping(path = "/singlefileupload/", method = RequestMethod.POST) + public ResponseEntity processFile(@RequestParam("file") MultipartFile file) throws IOException { + + byte[] bytes = file.getBytes(); + + System.out.println("File Name: " + file.getOriginalFilename()); + System.out.println("File Content Type: " + file.getContentType()); + System.out.println("File Content:\n" + new String(bytes)); + + return (new ResponseEntity<>("Successful", null, HttpStatus.OK)); + } + + @RequestMapping(path = "/multiplefileupload/", method = RequestMethod.POST) + public ResponseEntity processFile(@RequestParam("files") List files) throws IOException { + + for (MultipartFile file : files) { + byte[] bytes = file.getBytes(); + + System.out.println("File Name: " + file.getOriginalFilename()); + System.out.println("File Content Type: " + file.getContentType()); + System.out.println("File Content:\n" + new String(bytes)); + } + + return (new ResponseEntity<>("Successful", null, HttpStatus.OK)); + } +} \ No newline at end of file diff --git a/spring-web-modules/spring-resttemplate-3/src/main/resources/application.properties b/spring-web-modules/spring-resttemplate-3/src/main/resources/application.properties new file mode 100644 index 0000000000..1a26e3ad99 --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/src/main/resources/application.properties @@ -0,0 +1,2 @@ +server.port=8082 +server.servlet.context-path=/spring-rest \ No newline at end of file diff --git a/spring-web-modules/spring-resttemplate-3/src/main/resources/logback.xml b/spring-web-modules/spring-resttemplate-3/src/main/resources/logback.xml new file mode 100644 index 0000000000..9f48d36486 --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/src/main/resources/logback.xml @@ -0,0 +1,23 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-web-modules/spring-resttemplate-3/src/test/java/com/baeldung/SpringContextTest.java b/spring-web-modules/spring-resttemplate-3/src/test/java/com/baeldung/SpringContextTest.java new file mode 100644 index 0000000000..26972a0aca --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/src/test/java/com/baeldung/SpringContextTest.java @@ -0,0 +1,15 @@ +package com.baeldung; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = { com.baeldung.web.upload.app.UploadApplication.class, }) +public class SpringContextTest { + + @Test + public void whenSpringContextIsBootstrapped_thenNoExceptions() { + } +} diff --git a/spring-web-modules/spring-resttemplate-3/src/test/java/com/baeldung/largefile/LargeFileDownloadIntegrationTest.java b/spring-web-modules/spring-resttemplate-3/src/test/java/com/baeldung/largefile/LargeFileDownloadIntegrationTest.java new file mode 100644 index 0000000000..d8fc58319f --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/src/test/java/com/baeldung/largefile/LargeFileDownloadIntegrationTest.java @@ -0,0 +1,105 @@ +package com.baeldung.largefile; + +import java.io.File; +import java.io.FileOutputStream; + +import org.assertj.core.api.Assertions; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.util.StreamUtils; +import org.springframework.web.client.RestTemplate; + +public class LargeFileDownloadIntegrationTest { + + static String FILE_URL = "http://ovh.net/files/1Mio.dat"; + + RestTemplate restTemplate; + + @Before + public void setUp() { + restTemplate = new RestTemplate(); + } + + @Test + public void givenResumableUrl_whenUrlCalledByHeadOption_thenExpectHeadersAvailable() { + HttpHeaders headers = restTemplate.headForHeaders(FILE_URL); + Assertions + .assertThat(headers.get("Accept-Ranges")) + .contains("bytes"); + Assertions + .assertThat(headers.getContentLength()) + .isGreaterThan(0); + } + + @Test + public void givenResumableUrl_whenDownloadCompletely_thenExpectCorrectFileSize() { + HttpHeaders headers = restTemplate.headForHeaders(FILE_URL); + long contentLength = headers.getContentLength(); + File file = restTemplate.execute(FILE_URL, HttpMethod.GET, null, clientHttpResponse -> { + File ret = File.createTempFile("download", "tmp"); + StreamUtils.copy(clientHttpResponse.getBody(), new FileOutputStream(ret)); + return ret; + }); + + Assert.assertNotNull(file); + Assertions + .assertThat(file.length()) + .isEqualTo(contentLength); + } + + @Test + public void givenResumableUrl_whenDownloadRange_thenExpectFileSizeEqualOrLessThanRange() { + int range = 10; + File file = restTemplate.execute(FILE_URL, HttpMethod.GET, clientHttpRequest -> clientHttpRequest + .getHeaders() + .set("Range", String.format("bytes=0-%d", range - 1)), clientHttpResponse -> { + File ret = File.createTempFile("download", "tmp"); + StreamUtils.copy(clientHttpResponse.getBody(), new FileOutputStream(ret)); + return ret; + }); + + Assert.assertNotNull(file); + Assertions + .assertThat(file.length()) + .isLessThanOrEqualTo(range); + } + + @Test + public void givenResumableUrl_whenPauseDownloadAndResume_thenExpectCorrectFileSize() { + + int range = 10; + + HttpHeaders headers = restTemplate.headForHeaders(FILE_URL); + long contentLength = headers.getContentLength(); + + File file = restTemplate.execute(FILE_URL, HttpMethod.GET, clientHttpRequest -> clientHttpRequest + .getHeaders() + .set("Range", String.format("bytes=0-%d", range - 1)), clientHttpResponse -> { + File ret = File.createTempFile("download", "tmp"); + StreamUtils.copy(clientHttpResponse.getBody(), new FileOutputStream(ret)); + return ret; + }); + + Assert.assertNotNull(file); + + Assertions + .assertThat(file.length()) + .isLessThanOrEqualTo(range); + + restTemplate.execute(FILE_URL, HttpMethod.GET, clientHttpRequest -> clientHttpRequest + .getHeaders() + .set("Range", String.format("bytes=%d-%d", file.length(), contentLength)), clientHttpResponse -> { + StreamUtils.copy(clientHttpResponse.getBody(), new FileOutputStream(file, true)); + return file; + }); + + Assertions + .assertThat(file.length()) + .isEqualTo(contentLength); + + } + +} diff --git a/spring-web-modules/spring-resttemplate-3/src/test/resources/.gitignore b/spring-web-modules/spring-resttemplate-3/src/test/resources/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-web-modules/spring-resttemplate-3/src/test/resources/logback-test.xml b/spring-web-modules/spring-resttemplate-3/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..9f48d36486 --- /dev/null +++ b/spring-web-modules/spring-resttemplate-3/src/test/resources/logback-test.xml @@ -0,0 +1,23 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + + + + + \ No newline at end of file From 2931dcbeb495abfac95cfbb28eaa2f1a97d69a28 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 15 Jan 2021 23:16:39 +0530 Subject: [PATCH 251/361] JAVA-4010: Moved 3 articles from this module --- .../spring-resttemplate/README.md | 3 - .../lists/EmployeeApplication.java | 16 --- .../lists/client/EmployeeClient.java | 120 ------------------ .../lists/controller/EmployeeResource.java | 46 ------- .../resttemplate/lists/dto/Employee.java | 40 ------ .../resttemplate/lists/dto/EmployeeList.java | 29 ----- .../lists/service/EmployeeService.java | 25 ---- .../web/upload/app/UploadApplication.java | 17 --- .../client/MultipartFileUploadClient.java | 61 --------- .../upload/controller/FileServerResource.java | 43 ------- .../java/com/baeldung/SpringContextTest.java | 6 +- .../LargeFileDownloadIntegrationTest.java | 109 ---------------- 12 files changed, 2 insertions(+), 513 deletions(-) delete mode 100644 spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/EmployeeApplication.java delete mode 100644 spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java delete mode 100644 spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/controller/EmployeeResource.java delete mode 100644 spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/dto/Employee.java delete mode 100644 spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/dto/EmployeeList.java delete mode 100644 spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/service/EmployeeService.java delete mode 100644 spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/app/UploadApplication.java delete mode 100644 spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/client/MultipartFileUploadClient.java delete mode 100644 spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/controller/FileServerResource.java delete mode 100644 spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/resttemplate/LargeFileDownloadIntegrationTest.java diff --git a/spring-web-modules/spring-resttemplate/README.md b/spring-web-modules/spring-resttemplate/README.md index 952f35e90b..e8c240d86b 100644 --- a/spring-web-modules/spring-resttemplate/README.md +++ b/spring-web-modules/spring-resttemplate/README.md @@ -11,10 +11,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Spring RestTemplate Error Handling](https://www.baeldung.com/spring-rest-template-error-handling) - [Configure a RestTemplate with RestTemplateBuilder](https://www.baeldung.com/spring-rest-template-builder) - [Mocking a RestTemplate in Spring](https://www.baeldung.com/spring-mock-rest-template) -- [Download a Large File Through a Spring RestTemplate](https://www.baeldung.com/spring-resttemplate-download-large-file) - [Using the Spring RestTemplate Interceptor](https://www.baeldung.com/spring-rest-template-interceptor) -- [Uploading MultipartFile with Spring RestTemplate](https://www.baeldung.com/spring-rest-template-multipart-upload) -- [Get and Post Lists of Objects with RestTemplate](https://www.baeldung.com/spring-rest-template-list) - [HTTP PUT vs HTTP PATCH in a REST API](https://www.baeldung.com/http-put-patch-difference-spring) ### NOTE: diff --git a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/EmployeeApplication.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/EmployeeApplication.java deleted file mode 100644 index 1967d4f2aa..0000000000 --- a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/EmployeeApplication.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.resttemplate.lists; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Sample application used to demonstrate working with Lists and RestTemplate. - */ -@SpringBootApplication -public class EmployeeApplication -{ - public static void main(String[] args) - { - SpringApplication.run(EmployeeApplication.class, args); - } -} diff --git a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java deleted file mode 100644 index 49e375f9cc..0000000000 --- a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.baeldung.resttemplate.lists.client; - -import com.baeldung.resttemplate.lists.dto.Employee; -import com.baeldung.resttemplate.lists.dto.EmployeeList; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; - -import java.util.ArrayList; -import java.util.List; - -import static java.util.Arrays.asList; - -/** - * Application that shows how to use Lists with RestTemplate. - */ -public class EmployeeClient { - public static void main(String[] args) { - EmployeeClient employeeClient = new EmployeeClient(); - - System.out.println("Calling GET for entity using arrays"); - employeeClient.getForEntityEmployeesAsArray(); - - System.out.println("Calling GET using ParameterizedTypeReference"); - employeeClient.getAllEmployeesUsingParameterizedTypeReference(); - - System.out.println("Calling GET using wrapper class"); - employeeClient.getAllEmployeesUsingWrapperClass(); - - System.out.println("Calling POST using normal lists"); - employeeClient.createEmployeesUsingLists(); - - System.out.println("Calling POST using wrapper class"); - employeeClient.createEmployeesUsingWrapperClass(); - } - - public EmployeeClient() { - - } - - public Employee[] getForEntityEmployeesAsArray() { - - RestTemplate restTemplate = new RestTemplate(); - - ResponseEntity response = - restTemplate.getForEntity( - "http://localhost:8082/spring-rest/employees/", - Employee[].class); - - Employee[] employees = response.getBody(); - - assert employees != null; - asList(employees).forEach(System.out::println); - - return employees; - - } - - - public List getAllEmployeesUsingParameterizedTypeReference() { - RestTemplate restTemplate = new RestTemplate(); - - ResponseEntity> response = - restTemplate.exchange( - "http://localhost:8082/spring-rest/employees/", - HttpMethod.GET, - null, - new ParameterizedTypeReference>() { - }); - - List employees = response.getBody(); - - assert employees != null; - employees.forEach(System.out::println); - - return employees; - } - - public List getAllEmployeesUsingWrapperClass() { - RestTemplate restTemplate = new RestTemplate(); - - EmployeeList response = - restTemplate.getForObject( - "http://localhost:8082/spring-rest/employees/v2", - EmployeeList.class); - - List employees = response.getEmployees(); - - employees.forEach(System.out::println); - - return employees; - } - - public void createEmployeesUsingLists() { - RestTemplate restTemplate = new RestTemplate(); - - List newEmployees = new ArrayList<>(); - newEmployees.add(new Employee(3, "Intern")); - newEmployees.add(new Employee(4, "CEO")); - - restTemplate.postForObject( - "http://localhost:8082/spring-rest/employees/", - newEmployees, - ResponseEntity.class); - } - - public void createEmployeesUsingWrapperClass() { - RestTemplate restTemplate = new RestTemplate(); - - List newEmployees = new ArrayList<>(); - newEmployees.add(new Employee(3, "Intern")); - newEmployees.add(new Employee(4, "CEO")); - - restTemplate.postForObject( - "http://localhost:8082/spring-rest/employees/v2/", - new EmployeeList(newEmployees), - ResponseEntity.class); - } -} diff --git a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/controller/EmployeeResource.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/controller/EmployeeResource.java deleted file mode 100644 index 8a4d510f63..0000000000 --- a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/controller/EmployeeResource.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.baeldung.resttemplate.lists.controller; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import com.baeldung.resttemplate.lists.dto.Employee; -import com.baeldung.resttemplate.lists.dto.EmployeeList; -import com.baeldung.resttemplate.lists.service.EmployeeService; - -import java.util.List; - -@RestController -@RequestMapping("/employees") -public class EmployeeResource -{ - @Autowired - private EmployeeService employeeService; - - @RequestMapping(method = RequestMethod.GET, path = "/") - public List getEmployees() - { - return employeeService.getAllEmployees(); - } - - @RequestMapping(method = RequestMethod.GET, path = "/v2") - public EmployeeList getEmployeesUsingWrapperClass() - { - List employees = employeeService.getAllEmployees(); - return new EmployeeList(employees); - } - - @RequestMapping(method = RequestMethod.POST, path = "/") - public void addEmployees(@RequestBody List employees) - { - employeeService.addEmployees(employees); - } - - @RequestMapping(method = RequestMethod.POST, path = "/v2") - public void addEmployeesUsingWrapperClass(@RequestBody EmployeeList employeeWrapper) - { - employeeService.addEmployees(employeeWrapper.getEmployees()); - } -} diff --git a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/dto/Employee.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/dto/Employee.java deleted file mode 100644 index 0754c13c5b..0000000000 --- a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/dto/Employee.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.baeldung.resttemplate.lists.dto; - -public class Employee { - - public long id; - public String title; - - public Employee() - { - - } - - public Employee(long id, String title) - { - this.id = id; - this.title = title; - } - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - @Override - public String toString() - { - return "Employee #" + id + "[" + title + "]"; - } -} diff --git a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/dto/EmployeeList.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/dto/EmployeeList.java deleted file mode 100644 index eeabbfe450..0000000000 --- a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/dto/EmployeeList.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.resttemplate.lists.dto; - -import java.util.ArrayList; -import java.util.List; - -public class EmployeeList -{ - public List employees; - - public EmployeeList() - { - employees = new ArrayList<>(); - } - - public EmployeeList(List employees) - { - this.employees = employees; - } - - public void setEmployees(List employees) - { - this.employees = employees; - } - - public List getEmployees() - { - return employees; - } -} diff --git a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/service/EmployeeService.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/service/EmployeeService.java deleted file mode 100644 index 8a1773483a..0000000000 --- a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/lists/service/EmployeeService.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.resttemplate.lists.service; - -import org.springframework.stereotype.Service; - -import com.baeldung.resttemplate.lists.dto.Employee; - -import java.util.ArrayList; -import java.util.List; - -@Service("EmployeeListService") -public class EmployeeService -{ - public List getAllEmployees() - { - List employees = new ArrayList<>(); - employees.add(new Employee(1, "Manager")); - employees.add(new Employee(2, "Java Developer")); - return employees; - } - - public void addEmployees(List employees) - { - employees.forEach(e -> System.out.println("Adding new employee " + e)); - } -} diff --git a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/app/UploadApplication.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/app/UploadApplication.java deleted file mode 100644 index f3b1c0dc6f..0000000000 --- a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/app/UploadApplication.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.web.upload.app; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; -import org.springframework.context.annotation.ComponentScan; - -@EnableAutoConfiguration -@ComponentScan("com.baeldung.web.upload") -@SpringBootApplication -public class UploadApplication extends SpringBootServletInitializer { - - public static void main(final String[] args) { - SpringApplication.run(UploadApplication.class, args); - } -} \ No newline at end of file diff --git a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/client/MultipartFileUploadClient.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/client/MultipartFileUploadClient.java deleted file mode 100644 index 547aec17a0..0000000000 --- a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/client/MultipartFileUploadClient.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.baeldung.web.upload.client; - -import org.springframework.core.io.FileSystemResource; -import org.springframework.core.io.Resource; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; - -public class MultipartFileUploadClient { - - public static void main(String[] args) throws IOException { - uploadSingleFile(); - uploadMultipleFile(); - } - - private static void uploadSingleFile() throws IOException { - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.MULTIPART_FORM_DATA); - - MultiValueMap body = new LinkedMultiValueMap<>(); - body.add("file", getTestFile()); - - - HttpEntity> requestEntity = new HttpEntity<>(body, headers); - String serverUrl = "http://localhost:8082/spring-rest/fileserver/singlefileupload/"; - RestTemplate restTemplate = new RestTemplate(); - ResponseEntity response = restTemplate.postForEntity(serverUrl, requestEntity, String.class); - System.out.println("Response code: " + response.getStatusCode()); - } - - private static void uploadMultipleFile() throws IOException { - HttpHeaders headers = new HttpHeaders(); - headers.setContentType(MediaType.MULTIPART_FORM_DATA); - - MultiValueMap body = new LinkedMultiValueMap<>(); - body.add("files", getTestFile()); - body.add("files", getTestFile()); - body.add("files", getTestFile()); - - HttpEntity> requestEntity = new HttpEntity<>(body, headers); - String serverUrl = "http://localhost:8082/spring-rest/fileserver/multiplefileupload/"; - RestTemplate restTemplate = new RestTemplate(); - ResponseEntity response = restTemplate.postForEntity(serverUrl, requestEntity, String.class); - System.out.println("Response code: " + response.getStatusCode()); - } - - public static Resource getTestFile() throws IOException { - Path testFile = Files.createTempFile("test-file", ".txt"); - System.out.println("Creating and Uploading Test File: " + testFile); - Files.write(testFile, "Hello World !!, This is a test file.".getBytes()); - return new FileSystemResource(testFile.toFile()); - } -} diff --git a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/controller/FileServerResource.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/controller/FileServerResource.java deleted file mode 100644 index 3863a8f20d..0000000000 --- a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/web/upload/controller/FileServerResource.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.baeldung.web.upload.controller; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -import java.io.IOException; -import java.util.List; - -@RestController -@RequestMapping("/fileserver") -public class FileServerResource { - - @RequestMapping(path = "/singlefileupload/", method = RequestMethod.POST) - public ResponseEntity processFile(@RequestParam("file") MultipartFile file) throws IOException { - - byte[] bytes = file.getBytes(); - - System.out.println("File Name: " + file.getOriginalFilename()); - System.out.println("File Content Type: " + file.getContentType()); - System.out.println("File Content:\n" + new String(bytes)); - - return (new ResponseEntity<>("Successful", null, HttpStatus.OK)); - } - - @RequestMapping(path = "/multiplefileupload/", method = RequestMethod.POST) - public ResponseEntity processFile(@RequestParam("files") List files) throws IOException { - - for (MultipartFile file : files) { - byte[] bytes = file.getBytes(); - - System.out.println("File Name: " + file.getOriginalFilename()); - System.out.println("File Content Type: " + file.getContentType()); - System.out.println("File Content:\n" + new String(bytes)); - } - - return (new ResponseEntity<>("Successful", null, HttpStatus.OK)); - } -} \ No newline at end of file diff --git a/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/SpringContextTest.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/SpringContextTest.java index 43901cf37f..dc176f5322 100644 --- a/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/SpringContextTest.java +++ b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/SpringContextTest.java @@ -8,12 +8,10 @@ import org.springframework.test.context.junit4.SpringRunner; import com.baeldung.responseheaders.ResponseHeadersApplication; @RunWith(SpringRunner.class) -@SpringBootTest(classes = { ResponseHeadersApplication.class, - com.baeldung.web.upload.app.UploadApplication.class, - }) +@SpringBootTest(classes = { ResponseHeadersApplication.class }) public class SpringContextTest { @Test - public void whenSpringContextIsBootstrapped_thenNoExceptions() { + public void whenSpringContextIsBootstrapped_thenNoExceptions() { } } diff --git a/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/resttemplate/LargeFileDownloadIntegrationTest.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/resttemplate/LargeFileDownloadIntegrationTest.java deleted file mode 100644 index eb5d01d06f..0000000000 --- a/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/resttemplate/LargeFileDownloadIntegrationTest.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.baeldung.resttemplate; - -import org.assertj.core.api.Assertions; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.springframework.core.io.FileSystemResource; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.util.StreamUtils; -import org.springframework.web.client.RestTemplate; - -import java.io.File; -import java.io.FileOutputStream; -import java.util.ArrayList; -import java.util.List; - -public class LargeFileDownloadIntegrationTest { - - static String FILE_URL = "http://ovh.net/files/1Mio.dat"; - - RestTemplate restTemplate; - - @Before - public void setUp() { - restTemplate = new RestTemplate(); - } - - @Test - public void givenResumableUrl_whenUrlCalledByHeadOption_thenExpectHeadersAvailable() { - HttpHeaders headers = restTemplate.headForHeaders(FILE_URL); - Assertions - .assertThat(headers.get("Accept-Ranges")) - .contains("bytes"); - Assertions - .assertThat(headers.getContentLength()) - .isGreaterThan(0); - } - - @Test - public void givenResumableUrl_whenDownloadCompletely_thenExpectCorrectFileSize() { - HttpHeaders headers = restTemplate.headForHeaders(FILE_URL); - long contentLength = headers.getContentLength(); - File file = restTemplate.execute(FILE_URL, HttpMethod.GET, null, clientHttpResponse -> { - File ret = File.createTempFile("download", "tmp"); - StreamUtils.copy(clientHttpResponse.getBody(), new FileOutputStream(ret)); - return ret; - }); - - Assert.assertNotNull(file); - Assertions - .assertThat(file.length()) - .isEqualTo(contentLength); - } - - @Test - public void givenResumableUrl_whenDownloadRange_thenExpectFileSizeEqualOrLessThanRange() { - int range = 10; - File file = restTemplate.execute(FILE_URL, HttpMethod.GET, clientHttpRequest -> clientHttpRequest - .getHeaders() - .set("Range", String.format("bytes=0-%d", range - 1)), clientHttpResponse -> { - File ret = File.createTempFile("download", "tmp"); - StreamUtils.copy(clientHttpResponse.getBody(), new FileOutputStream(ret)); - return ret; - }); - - Assert.assertNotNull(file); - Assertions - .assertThat(file.length()) - .isLessThanOrEqualTo(range); - } - - @Test - public void givenResumableUrl_whenPauseDownloadAndResume_thenExpectCorrectFileSize() { - - int range = 10; - - HttpHeaders headers = restTemplate.headForHeaders(FILE_URL); - long contentLength = headers.getContentLength(); - - File file = restTemplate.execute(FILE_URL, HttpMethod.GET, clientHttpRequest -> clientHttpRequest - .getHeaders() - .set("Range", String.format("bytes=0-%d", range - 1)), clientHttpResponse -> { - File ret = File.createTempFile("download", "tmp"); - StreamUtils.copy(clientHttpResponse.getBody(), new FileOutputStream(ret)); - return ret; - }); - - Assert.assertNotNull(file); - - Assertions - .assertThat(file.length()) - .isLessThanOrEqualTo(range); - - restTemplate.execute(FILE_URL, HttpMethod.GET, clientHttpRequest -> clientHttpRequest - .getHeaders() - .set("Range", String.format("bytes=%d-%d", file.length(), contentLength)), clientHttpResponse -> { - StreamUtils.copy(clientHttpResponse.getBody(), new FileOutputStream(file, true)); - return file; - }); - - Assertions - .assertThat(file.length()) - .isEqualTo(contentLength); - - } - -} From a0e7e3bf8005102b12167382e92988c93802b115 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 15 Jan 2021 23:17:03 +0530 Subject: [PATCH 252/361] JAVA-4010: Added new module to parent 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 cc2ffcf762..37ee84da25 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -37,6 +37,7 @@ spring-rest-testing spring-resttemplate spring-resttemplate-2 + spring-resttemplate-3 spring-thymeleaf spring-thymeleaf-2 spring-thymeleaf-3 From 6b462cd6c69679fedd58fe58e15df788a7e9faa2 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Fri, 15 Jan 2021 16:00:03 -0300 Subject: [PATCH 253/361] Improved spring-properties-file-outside-jar with new 2.4.0 feature --- .../additional.properties | 1 + .../spring-boot-environment/pom.xml | 21 +++++++++++++----- .../src/main/resources/application.properties | 5 +++-- ...ertyImportExternalFileIntegrationTest.java | 22 +++++++++++++++++++ 4 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 spring-boot-modules/spring-boot-environment/additional.properties create mode 100644 spring-boot-modules/spring-boot-environment/src/test/java/com/baeldung/properties/ApplicationPropertyImportExternalFileIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-environment/additional.properties b/spring-boot-modules/spring-boot-environment/additional.properties new file mode 100644 index 0000000000..676536efa5 --- /dev/null +++ b/spring-boot-modules/spring-boot-environment/additional.properties @@ -0,0 +1 @@ +bael.property1=value1 \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-environment/pom.xml b/spring-boot-modules/spring-boot-environment/pom.xml index e3a8186cbf..a3aab63a2d 100644 --- a/spring-boot-modules/spring-boot-environment/pom.xml +++ b/spring-boot-modules/spring-boot-environment/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 @@ -88,7 +89,6 @@ org.springframework.cloud spring-cloud-context - ${springcloud.version} @@ -99,6 +99,18 @@ + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring.cloud-version} + pom + import + + + + ${project.artifactId} @@ -153,9 +165,8 @@ 2.2 18.0 3.1.7 - 2.0.2.RELEASE 4.5.8 - 2.3.3.RELEASE + 2020.0.0 diff --git a/spring-boot-modules/spring-boot-environment/src/main/resources/application.properties b/spring-boot-modules/spring-boot-environment/src/main/resources/application.properties index 27b7915cff..3d6f37230c 100644 --- a/spring-boot-modules/spring-boot-environment/src/main/resources/application.properties +++ b/spring-boot-modules/spring-boot-environment/src/main/resources/application.properties @@ -2,6 +2,7 @@ management.endpoints.web.exposure.include=* management.metrics.enable.root=true management.metrics.enable.jvm=true management.endpoint.restart.enabled=true -spring.datasource.jmx-enabled=false +spring.datasource.tomcat.jmx-enabled=false spring.main.allow-bean-definition-overriding=true -management.endpoint.shutdown.enabled=true \ No newline at end of file +management.endpoint.shutdown.enabled=true +spring.config.import=file:./additional.properties,optional:file:/Users/home/config/jdbc.properties \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-environment/src/test/java/com/baeldung/properties/ApplicationPropertyImportExternalFileIntegrationTest.java b/spring-boot-modules/spring-boot-environment/src/test/java/com/baeldung/properties/ApplicationPropertyImportExternalFileIntegrationTest.java new file mode 100644 index 0000000000..04f5445639 --- /dev/null +++ b/spring-boot-modules/spring-boot-environment/src/test/java/com/baeldung/properties/ApplicationPropertyImportExternalFileIntegrationTest.java @@ -0,0 +1,22 @@ +package com.baeldung.properties; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +public class ApplicationPropertyImportExternalFileIntegrationTest { + + @Value("${bael.property1}") + String baelProperty; + + @Test + public void whenExternalisedPropertiesLoadedUsinApplicationProperties_thenReadValues() throws IOException { + assertEquals(baelProperty, "value1"); + } + +} From dce6c4fe126268493f334b278bd282856ab7bf05 Mon Sep 17 00:00:00 2001 From: KevinGilmore Date: Fri, 15 Jan 2021 17:21:00 -0600 Subject: [PATCH 254/361] BAEL-4695: create and update README files (#10425) --- core-java-modules/core-java-lang-math-2/README.md | 2 +- core-java-modules/core-java-lang-math-3/README.md | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 core-java-modules/core-java-lang-math-3/README.md diff --git a/core-java-modules/core-java-lang-math-2/README.md b/core-java-modules/core-java-lang-math-2/README.md index a98ff863ac..5e1dc5af0e 100644 --- a/core-java-modules/core-java-lang-math-2/README.md +++ b/core-java-modules/core-java-lang-math-2/README.md @@ -14,4 +14,4 @@ - [Debugging with Eclipse](https://www.baeldung.com/eclipse-debugging) - [Matrix Multiplication in Java](https://www.baeldung.com/java-matrix-multiplication) - [Largest Power of 2 That Is Less Than the Given Number with Java](https://www.baeldung.com/java-largest-power-of-2-less-than-number) -- More articles: [[<-- Prev]](/core-java-modules/core-java-lang-math) +- More articles: [[<-- Prev]](/core-java-modules/core-java-lang-math)[[Next -->]](/core-java-modules/core-java-lang-math-3) diff --git a/core-java-modules/core-java-lang-math-3/README.md b/core-java-modules/core-java-lang-math-3/README.md new file mode 100644 index 0000000000..9eee021f8f --- /dev/null +++ b/core-java-modules/core-java-lang-math-3/README.md @@ -0,0 +1,8 @@ +========= + +## Core Java 8 Cookbooks and Examples - Part 3 + +### Relevant articles: + +- [Calculate Factorial in Java](https://www.baeldung.com/java-calculate-factorial) +- More articles: [[<-- Prev]](/core-java-modules/core-java-lang-math-2) From 77b00187def78bd518b51b2ba1603d49cdd76d08 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Sat, 16 Jan 2021 16:27:02 +0200 Subject: [PATCH 255/361] fix channel type, callback --- webrtc/src/main/resources/static/client.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/webrtc/src/main/resources/static/client.js b/webrtc/src/main/resources/static/client.js index 059dc84bcb..9b3de9ef6d 100644 --- a/webrtc/src/main/resources/static/client.js +++ b/webrtc/src/main/resources/static/client.js @@ -38,11 +38,7 @@ var input = document.getElementById("messageInput"); function initialize() { var configuration = null; - peerConnection = new RTCPeerConnection(configuration, { - optional : [ { - RtpDataChannels : true - } ] - }); + peerConnection = new RTCPeerConnection(configuration); // Setup ice handling peerConnection.onicecandidate = function(event) { @@ -71,6 +67,11 @@ function initialize() { dataChannel.onclose = function() { console.log("data channel is closed"); }; + + peerConnection.ondatachannel = function (event) { + dataChannel = event.channel; + }; + } function createOffer() { From 72ca7fde484f8645078a0031e4bcf1a5db5587da Mon Sep 17 00:00:00 2001 From: Gilvan Ornelas Fernandes Filho Date: Sat, 16 Jan 2021 11:36:20 -0300 Subject: [PATCH 256/361] Fixing valid password condition --- .../pattern/cleanarchitecture/usercreation/CommonUser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/CommonUser.java b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/CommonUser.java index f7ba9dacc0..c4f105fad5 100644 --- a/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/CommonUser.java +++ b/patterns/clean-architecture/src/main/java/com/baeldung/pattern/cleanarchitecture/usercreation/CommonUser.java @@ -15,7 +15,7 @@ class CommonUser implements User { @Override public boolean passwordIsValid() { - return password == null || password.length() > 5; + return password != null && password.length() > 5; } @Override From 82b5316bc444fe0032563b7d0511a4e90fff65cb Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Sat, 16 Jan 2021 12:20:54 -0300 Subject: [PATCH 257/361] fixed properties files notation --- .../application-multidocument-integration.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application-multidocument-integration.properties b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application-multidocument-integration.properties index c4eeba2589..f3bac4c614 100644 --- a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application-multidocument-integration.properties +++ b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application-multidocument-integration.properties @@ -1,4 +1,4 @@ -spring.datasource.password: 'password' -spring.datasource.url: jdbc:mysql://localhost:3306/db_integration -spring.datasource.username: user +spring.datasource.password=password +spring.datasource.url=jdbc:mysql://localhost:3306/db_integration +spring.datasource.username=user bael.property=integrationValue \ No newline at end of file From 100e3b652dd7bdfc7369799a292c089dde77a9fb Mon Sep 17 00:00:00 2001 From: Azhwani Date: Sun, 17 Jan 2021 02:08:18 +0100 Subject: [PATCH 258/361] first commit --- .../RestTemplateExceptionApplication.java | 13 +++++ .../controller/ProductApi.java | 50 +++++++++++++++++ .../model/Criterion.java | 28 ++++++++++ .../resttemplateexception/model/Product.java | 43 +++++++++++++++ .../RestTemplateExceptionLiveTest.java | 53 +++++++++++++++++++ 5 files changed, 187 insertions(+) create mode 100644 spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/RestTemplateExceptionApplication.java create mode 100644 spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/controller/ProductApi.java create mode 100644 spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/model/Criterion.java create mode 100644 spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/model/Product.java create mode 100644 spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplateexception/RestTemplateExceptionLiveTest.java diff --git a/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/RestTemplateExceptionApplication.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/RestTemplateExceptionApplication.java new file mode 100644 index 0000000000..84a337f5ee --- /dev/null +++ b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/RestTemplateExceptionApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.resttemplateexception; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class RestTemplateExceptionApplication { + + public static void main(String[] args) { + SpringApplication.run(RestTemplateExceptionApplication.class, args); + } + +} diff --git a/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/controller/ProductApi.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/controller/ProductApi.java new file mode 100644 index 0000000000..66fbfa487d --- /dev/null +++ b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/controller/ProductApi.java @@ -0,0 +1,50 @@ +package com.baeldung.resttemplateexception.controller; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.resttemplateexception.model.Criterion; +import com.baeldung.resttemplateexception.model.Product; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +@RestController +@RequestMapping("/api") +public class ProductApi { + + private List productList = new ArrayList<>(Arrays.asList(new Product(1, "Acer Aspire 5", 437), new Product(2, "ASUS VivoBook", 650), new Product(3, "Lenovo Legion", 990))); + + @GetMapping("/get") + public Product get(@RequestParam String criterion) throws JsonMappingException, JsonProcessingException { + + ObjectMapper objectMapper = new ObjectMapper(); + Criterion crt; + + crt = objectMapper.readValue(criterion, Criterion.class); + if (crt.getProp().equals("name")) + return findByName(crt.getValue()); + + // Search by other properties (id,price) + + return null; + } + + private Product findByName(String name) { + for (Product product : this.productList) { + if (product.getName().equals(name)) { + return product; + } + } + return null; + } + + // Other methods + +} diff --git a/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/model/Criterion.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/model/Criterion.java new file mode 100644 index 0000000000..9a96ad4dc3 --- /dev/null +++ b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/model/Criterion.java @@ -0,0 +1,28 @@ +package com.baeldung.resttemplateexception.model; + +public class Criterion { + + private String prop; + private String value; + + public Criterion() { + + } + + public String getProp() { + return prop; + } + + public void setProp(String prop) { + this.prop = prop; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/model/Product.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/model/Product.java new file mode 100644 index 0000000000..e4cc29279c --- /dev/null +++ b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/model/Product.java @@ -0,0 +1,43 @@ +package com.baeldung.resttemplateexception.model; + +public class Product { + + private int id; + private String name; + private double price; + + public Product() { + + } + + public Product(int id, String name, double price) { + this.id = id; + this.name = name; + this.price = price; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + +} diff --git a/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplateexception/RestTemplateExceptionLiveTest.java b/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplateexception/RestTemplateExceptionLiveTest.java new file mode 100644 index 0000000000..f5938e1f0a --- /dev/null +++ b/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplateexception/RestTemplateExceptionLiveTest.java @@ -0,0 +1,53 @@ +package com.baeldung.resttemplateexception; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; + +import com.baeldung.resttemplateexception.model.Product; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = { RestTemplate.class, RestTemplateExceptionApplication.class }) +public class RestTemplateExceptionLiveTest { + + @Autowired + RestTemplate restTemplate; + + @Test(expected = IllegalArgumentException.class) + public void givenGetUrl_whenJsonIsPassed_thenThrowException() { + + String url = "http://localhost:8080/spring-rest/api/get?criterion={\"prop\":\"name\",\"value\":\"ASUS VivoBook\"}"; + Product product = restTemplate.getForObject(url, Product.class); + + } + + @Test + public void givenGetUrl_whenJsonIsPassed_thenGetProduct() { + + String criterion = "{\"prop\":\"name\",\"value\":\"ASUS VivoBook\"}"; + String url = "http://localhost:8080/spring-rest/api/get?criterion={criterion}"; + Product product = restTemplate.getForObject(url, Product.class, criterion); + + assertEquals(product.getPrice(), 650, 0); + + } + + @Test + public void givenGetUrl_whenJsonIsPassed_thenReturnProduct() { + + String criterion = "{\"prop\":\"name\",\"value\":\"Acer Aspire 5\"}"; + String url = "http://localhost:8080/spring-rest/api/get"; + + UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(url).queryParam("criterion", criterion); + Product product = restTemplate.getForObject(builder.build().toUri(), Product.class); + + assertEquals(product.getId(), 1, 0); + + } +} From 8396dabf774f1b66bc8a74015b2b6385fc105af3 Mon Sep 17 00:00:00 2001 From: Azhwani Date: Sun, 17 Jan 2021 02:27:34 +0100 Subject: [PATCH 259/361] quick fix --- .../resttemplateexception/controller/ProductApi.java | 6 +----- .../RestTemplateExceptionLiveTest.java | 6 ------ 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/controller/ProductApi.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/controller/ProductApi.java index 66fbfa487d..2c530cae2b 100644 --- a/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/controller/ProductApi.java +++ b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/resttemplateexception/controller/ProductApi.java @@ -23,11 +23,8 @@ public class ProductApi { @GetMapping("/get") public Product get(@RequestParam String criterion) throws JsonMappingException, JsonProcessingException { - ObjectMapper objectMapper = new ObjectMapper(); - Criterion crt; - - crt = objectMapper.readValue(criterion, Criterion.class); + Criterion crt = objectMapper.readValue(criterion, Criterion.class); if (crt.getProp().equals("name")) return findByName(crt.getValue()); @@ -46,5 +43,4 @@ public class ProductApi { } // Other methods - } diff --git a/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplateexception/RestTemplateExceptionLiveTest.java b/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplateexception/RestTemplateExceptionLiveTest.java index f5938e1f0a..adfb8ffa4e 100644 --- a/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplateexception/RestTemplateExceptionLiveTest.java +++ b/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/resttemplateexception/RestTemplateExceptionLiveTest.java @@ -21,26 +21,21 @@ public class RestTemplateExceptionLiveTest { @Test(expected = IllegalArgumentException.class) public void givenGetUrl_whenJsonIsPassed_thenThrowException() { - String url = "http://localhost:8080/spring-rest/api/get?criterion={\"prop\":\"name\",\"value\":\"ASUS VivoBook\"}"; Product product = restTemplate.getForObject(url, Product.class); - } @Test public void givenGetUrl_whenJsonIsPassed_thenGetProduct() { - String criterion = "{\"prop\":\"name\",\"value\":\"ASUS VivoBook\"}"; String url = "http://localhost:8080/spring-rest/api/get?criterion={criterion}"; Product product = restTemplate.getForObject(url, Product.class, criterion); assertEquals(product.getPrice(), 650, 0); - } @Test public void givenGetUrl_whenJsonIsPassed_thenReturnProduct() { - String criterion = "{\"prop\":\"name\",\"value\":\"Acer Aspire 5\"}"; String url = "http://localhost:8080/spring-rest/api/get"; @@ -48,6 +43,5 @@ public class RestTemplateExceptionLiveTest { Product product = restTemplate.getForObject(builder.build().toUri(), Product.class); assertEquals(product.getId(), 1, 0); - } } From b9c81b0cedbcaa40ecb9978d3072a1f7939299ec Mon Sep 17 00:00:00 2001 From: Jonathan Cook Date: Sun, 17 Jan 2021 11:39:53 +0100 Subject: [PATCH 260/361] BAEL-4756 - Mockito MockSettings (#10423) * 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 * BAEL-4756 - Mockito MockSettings Co-authored-by: Jonathan Cook --- .../mockito/mocksettings/AbstractCoffee.java | 15 +++++ .../mockito/mocksettings/SimpleService.java | 10 ++++ .../mocksettings/SpecialInterface.java | 5 ++ .../mocksettings/MockSettingsUnitTest.java | 56 +++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 testing-modules/mockito-2/src/main/java/com/baeldung/mockito/mocksettings/AbstractCoffee.java create mode 100644 testing-modules/mockito-2/src/main/java/com/baeldung/mockito/mocksettings/SimpleService.java create mode 100644 testing-modules/mockito-2/src/main/java/com/baeldung/mockito/mocksettings/SpecialInterface.java create mode 100644 testing-modules/mockito-2/src/test/java/com/baeldung/mockito/mocksettings/MockSettingsUnitTest.java diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/mocksettings/AbstractCoffee.java b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/mocksettings/AbstractCoffee.java new file mode 100644 index 0000000000..99fd686951 --- /dev/null +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/mocksettings/AbstractCoffee.java @@ -0,0 +1,15 @@ +package com.baeldung.mockito.mocksettings; + +public abstract class AbstractCoffee { + + protected String name; + + protected AbstractCoffee(String name) { + this.name = name; + } + + protected String getName() { + return name; + } + +} diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/mocksettings/SimpleService.java b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/mocksettings/SimpleService.java new file mode 100644 index 0000000000..034517acbf --- /dev/null +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/mocksettings/SimpleService.java @@ -0,0 +1,10 @@ +package com.baeldung.mockito.mocksettings; + +public class SimpleService { + + public SimpleService(SpecialInterface special) { + Runnable runnable = (Runnable) special; + runnable.run(); + } + +} diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/mocksettings/SpecialInterface.java b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/mocksettings/SpecialInterface.java new file mode 100644 index 0000000000..e5f88247d6 --- /dev/null +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/mocksettings/SpecialInterface.java @@ -0,0 +1,5 @@ +package com.baeldung.mockito.mocksettings; + +public interface SpecialInterface { + +} diff --git a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/mocksettings/MockSettingsUnitTest.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/mocksettings/MockSettingsUnitTest.java new file mode 100644 index 0000000000..596baf1954 --- /dev/null +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/mocksettings/MockSettingsUnitTest.java @@ -0,0 +1,56 @@ +package com.baeldung.mockito.mocksettings; + +import static org.mockito.Answers.RETURNS_SMART_NULLS; +import static org.junit.Assert.assertEquals; +import static org.mockito.Answers.CALLS_REAL_METHODS; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.withSettings; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.exceptions.verification.SmartNullPointerException; +import org.mockito.junit.MockitoJUnitRunner; + +import com.baeldung.mockito.fluentapi.Pizza; +import com.baeldung.mockito.fluentapi.PizzaService; + +@RunWith(MockitoJUnitRunner.class) +public class MockSettingsUnitTest { + + @Test(expected = SmartNullPointerException.class) + public void whenServiceMockedWithSmartNulls_thenExceptionHasExtraInfo() { + PizzaService service = mock(PizzaService.class, withSettings().defaultAnswer(RETURNS_SMART_NULLS)); + Pizza pizza = service.orderHouseSpecial(); + pizza.getSize(); + } + + @Test + public void whenServiceMockedWithNameAndVerboseLogging_thenLogsMethodInvocations() { + PizzaService service = mock(PizzaService.class, withSettings().name("pizzaServiceMock") + .verboseLogging()); + + Pizza pizza = mock(Pizza.class); + when(service.orderHouseSpecial()).thenReturn(pizza); + + service.orderHouseSpecial(); + + verify(service).orderHouseSpecial(); + } + + @Test + public void whenServiceMockedWithExtraInterfaces_thenConstructorSuccess() { + SpecialInterface specialMock = mock(SpecialInterface.class, withSettings().extraInterfaces(Runnable.class)); + new SimpleService(specialMock); + } + + @Test + public void whenMockSetupWithConstructor_thenConstructorIsInvoked() { + AbstractCoffee coffeeSpy = mock(AbstractCoffee.class, withSettings().useConstructor("expresso") + .defaultAnswer(CALLS_REAL_METHODS)); + + assertEquals("Coffee name: ", "expresso", coffeeSpy.getName()); + } + +} From 1b127b9b00b1cb9bc25e606c2f74a107b3bb0d6b Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Mon, 18 Jan 2021 12:55:30 -0300 Subject: [PATCH 261/361] removed Sprng Boot version override, upgraded cloud version and added junit-vintage-engine dependency to avoid issues with existing JUnit4 tests --- spring-cloud/spring-cloud-config/client/pom.xml | 15 +++++++++++++-- spring-cloud/spring-cloud-config/pom.xml | 3 +-- spring-cloud/spring-cloud-config/server/pom.xml | 17 ++++++++++++++--- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/spring-cloud/spring-cloud-config/client/pom.xml b/spring-cloud/spring-cloud-config/client/pom.xml index 805a50bfdb..2400520d2b 100644 --- a/spring-cloud/spring-cloud-config/client/pom.xml +++ b/spring-cloud/spring-cloud-config/client/pom.xml @@ -1,7 +1,7 @@ + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 client client @@ -26,6 +26,17 @@ spring-boot-starter-test test + + org.junit.vintage + junit-vintage-engine + test + + + org.hamcrest + hamcrest-core + + + diff --git a/spring-cloud/spring-cloud-config/pom.xml b/spring-cloud/spring-cloud-config/pom.xml index 5db18a7245..bfe17044e0 100644 --- a/spring-cloud/spring-cloud-config/pom.xml +++ b/spring-cloud/spring-cloud-config/pom.xml @@ -33,8 +33,7 @@ - Hoxton.SR4 - 2.3.3.RELEASE + 2020.0.0 diff --git a/spring-cloud/spring-cloud-config/server/pom.xml b/spring-cloud/spring-cloud-config/server/pom.xml index e32a473cd6..f0f1e43612 100644 --- a/spring-cloud/spring-cloud-config/server/pom.xml +++ b/spring-cloud/spring-cloud-config/server/pom.xml @@ -1,11 +1,11 @@ + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 server server - + com.baeldung.spring.cloud spring-cloud-config @@ -30,6 +30,17 @@ spring-boot-starter-test test + + org.junit.vintage + junit-vintage-engine + test + + + org.hamcrest + hamcrest-core + + + From b33fd1ee9c03cac4c3a5f919babc9728f2a38c2b Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Mon, 18 Jan 2021 15:50:55 -0300 Subject: [PATCH 262/361] Added additional scenario to reflect scenario mentioned in spring-feature-flags (even though the article does not point to any module in the codebase) --- .../src/main/resources/application.properties | 4 ++++ .../src/main/resources/application.yml | 3 +++ .../IntegrationMultidocumentFilesIntegrationTest.java | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.properties b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.properties index c2bb5deb45..a079837942 100644 --- a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.properties +++ b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.properties @@ -11,6 +11,7 @@ app.name=MyApp app.description=${app.name} is a Spring Boot application logging.file.name=myapplication.log bael.property=defaultValue +bael.otherProperty=defaultOtherValue #--- spring.config.activate.on-profile=multidocument-dev spring.datasource.password=password @@ -18,6 +19,9 @@ spring.datasource.url=jdbc:h2:dev spring.datasource.username=SA bael.property=devValue #--- +spring.config.activate.on-profile=multidocument-integration-extension +bael.otherProperty=integrationExtensionOtherValue +#--- spring.config.activate.on-profile=multidocument-prod spring.datasource.password=password spring.datasource.url=jdbc:h2:prod diff --git a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.yml b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.yml index 33aabb2459..da398f5beb 100644 --- a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.yml +++ b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.yml @@ -2,6 +2,9 @@ bael: root-level-property: defaultRootLevelValue --- spring: + profiles: + group: + multidocument-integration: multidocument-integration-extension config: activate: on-profile: multidocument-staging diff --git a/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/IntegrationMultidocumentFilesIntegrationTest.java b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/IntegrationMultidocumentFilesIntegrationTest.java index f7968f51ad..e0727154d0 100644 --- a/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/IntegrationMultidocumentFilesIntegrationTest.java +++ b/spring-boot-modules/spring-boot-properties-3/src/test/java/com/baeldung/boot/properties/multidocument/IntegrationMultidocumentFilesIntegrationTest.java @@ -17,12 +17,16 @@ public class IntegrationMultidocumentFilesIntegrationTest { @Value("${bael.property}") private String baelCustomProperty; + @Value("${bael.otherProperty}") + private String baelCustomOtherProperty; + @Value("${bael.root-level-property}") private String baelRootProperty; @Test public void givenProductionProfileActive_whenApplicationStarts_thenDefaultPropertiesUser() { assertThat(baelCustomProperty).isEqualTo("integrationValue"); + assertThat(baelCustomOtherProperty).isEqualTo("integrationExtensionOtherValue"); assertThat(baelRootProperty).isEqualTo("defaultRootLevelValue"); } } From caadfb7a911bdba043de472d9c30843a57d0d781 Mon Sep 17 00:00:00 2001 From: Bruno Fontana Date: Tue, 19 Jan 2021 08:58:58 -0300 Subject: [PATCH 263/361] Adding clean-architecture to parent POM. Fixing UserResponseFormatter test name. --- ...seFormatterTests.java => UserResponseFormatterUnitTest.java} | 2 +- patterns/pom.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) rename patterns/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/{UserResponseFormatterTests.java => UserResponseFormatterUnitTest.java} (96%) diff --git a/patterns/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseFormatterTests.java b/patterns/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseFormatterUnitTest.java similarity index 96% rename from patterns/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseFormatterTests.java rename to patterns/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseFormatterUnitTest.java index f8ebde5f10..e394cbbf94 100644 --- a/patterns/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseFormatterTests.java +++ b/patterns/clean-architecture/src/test/java/com/baeldung/pattern/cleanarchitecture/usercreation/UserResponseFormatterUnitTest.java @@ -9,7 +9,7 @@ import org.springframework.web.server.ResponseStatusException; import com.baeldung.pattern.cleanarchitecture.usercreation.UserResponseFormatter; import com.baeldung.pattern.cleanarchitecture.usercreation.UserResponseModel; -class UserResponseFormatterTests { +class UserResponseFormatterUnitTest { UserResponseFormatter userResponseFormatter = new UserResponseFormatter(); diff --git a/patterns/pom.xml b/patterns/pom.xml index a179d75ffe..112eecb606 100644 --- a/patterns/pom.xml +++ b/patterns/pom.xml @@ -24,6 +24,7 @@ hexagonal-architecture intercepting-filter solid + clean-architecture From 8f428d768807b78be053957082e053aacfe04b26 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Tue, 19 Jan 2021 12:22:02 -0300 Subject: [PATCH 264/361] fix extra test configuration properties error --- .../src/main/resources/application.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.yml b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.yml index da398f5beb..10570bb738 100644 --- a/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.yml +++ b/spring-boot-modules/spring-boot-properties-3/src/main/resources/application.yml @@ -1,10 +1,11 @@ bael: root-level-property: defaultRootLevelValue ---- spring: profiles: group: multidocument-integration: multidocument-integration-extension +--- +spring: config: activate: on-profile: multidocument-staging From 42ca93dbbf17207d806cbcd2a9fc35429bfca406 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Tue, 19 Jan 2021 15:44:33 -0300 Subject: [PATCH 265/361] added junit-vintage-engine dependency to avoid issues with existing JUnit4 tests for spring-boot module --- spring-boot-modules/spring-boot/pom.xml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/spring-boot-modules/spring-boot/pom.xml b/spring-boot-modules/spring-boot/pom.xml index c1f1ea3072..9023ae92f3 100644 --- a/spring-boot-modules/spring-boot/pom.xml +++ b/spring-boot-modules/spring-boot/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 @@ -58,6 +58,17 @@ spring-boot-starter-test test + + org.junit.vintage + junit-vintage-engine + test + + + org.hamcrest + hamcrest-core + + + io.dropwizard.metrics From a41309f4c65af08cf0bd609388d2bb59810808f1 Mon Sep 17 00:00:00 2001 From: Mateusz Szablak 'Saber-k Date: Tue, 19 Jan 2021 21:40:10 +0100 Subject: [PATCH 266/361] [BAEL-4214] Converting java.util.Properties to HashMap --- .../core-java-collections-maps-3/pom.xml | 4 + .../PropertiesToHashMapConverter.java | 39 ++++ .../PropertiesToHashMapConverterUnitTest.java | 192 ++++++++++++++++++ .../src/test/resources/toHashMap.properties | 3 + 4 files changed, 238 insertions(+) create mode 100644 core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverter.java create mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverterUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps-3/src/test/resources/toHashMap.properties diff --git a/core-java-modules/core-java-collections-maps-3/pom.xml b/core-java-modules/core-java-collections-maps-3/pom.xml index 577ad58255..2561f891f1 100644 --- a/core-java-modules/core-java-collections-maps-3/pom.xml +++ b/core-java-modules/core-java-collections-maps-3/pom.xml @@ -20,6 +20,10 @@ jmh-core ${jmh-core.version} + + com.google.guava + guava + diff --git a/core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverter.java b/core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverter.java new file mode 100644 index 0000000000..2f333638a9 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverter.java @@ -0,0 +1,39 @@ +package com.baeldung.map.propertieshashmap; + +import com.google.common.collect.Maps; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.stream.Collectors; + +public class PropertiesToHashMapConverter { + + @SuppressWarnings({"rawtypes", "unchecked"}) + public static HashMap typeCastConvert(Properties prop) { + Map step1 = prop; + Map step2 = (Map) step1; + return new HashMap<>(step2); + } + + public static HashMap loopConvert(Properties prop) { + HashMap retMap = new HashMap<>(); + for (Map.Entry entry : prop.entrySet()) { + retMap.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())); + } + return retMap; + } + + public static HashMap streamConvert(Properties prop) { + return prop.entrySet().stream().collect( + Collectors.toMap( + e -> String.valueOf(e.getKey()), + e -> String.valueOf(e.getValue()), + (prev, next) -> next, HashMap::new + )); + } + + public static HashMap guavaConvert(Properties prop) { + return Maps.newHashMap(Maps.fromProperties(prop)); + } +} diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverterUnitTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverterUnitTest.java new file mode 100644 index 0000000000..b1370dcfbf --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverterUnitTest.java @@ -0,0 +1,192 @@ +package com.baeldung.map.propertieshashmap; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Properties; + +import static org.junit.jupiter.api.Assertions.*; + +class PropertiesToHashMapConverterUnitTest { + + private Properties properties; + + private final static String propertyFileName = "toHashMap.properties"; + + @BeforeEach + public void setup() throws IOException { + properties = new Properties(); + try (InputStream is = getClass().getClassLoader().getResourceAsStream(propertyFileName)) { + if (is != null) { + properties.load(is); + } + } + } + + @Test + public void havingPropertiesLoaded_whenCheck_thenEquals() { + assertEquals(3, properties.size()); + assertEquals("str_value", properties.get("property1")); + assertEquals("123", properties.get("property2")); + assertEquals("", properties.get("property3")); + } + + @Test + public void whenPropertiesModified_thenTypeSafeIssues() { + compromiseProperties(properties); + + assertEquals(5, properties.size()); + + assertNull(properties.getProperty("property4")); + assertNotEquals(String.class, properties.get("property4").getClass()); + assertEquals(456, properties.get("property4")); + + + assertNull(properties.getProperty("5")); + assertNotEquals(String.class, properties.get(5).getClass()); + assertEquals(10.11, properties.get(5)); + } + + @Test + public void havingNonModifiedProperties_whenTypeCastConvert_thenNoTypeSafeIssues() { + HashMap hMap = PropertiesToHashMapConverter.typeCastConvert(properties); + + assertEquals(3, hMap.size()); + assertEquals(String.class, hMap.get("property1").getClass()); + assertEquals(properties.get("property1"), hMap.get("property1")); + assertEquals(String.class, hMap.get("property2").getClass()); + assertEquals(properties.get("property2"), hMap.get("property2")); + assertEquals(String.class, hMap.get("property3").getClass()); + assertEquals(properties.get("property3"), hMap.get("property3")); + } + + @Test + public void havingModifiedProperties_whenTypeCastConvert_thenClassCastException() { + compromiseProperties(properties); + HashMap hMap = PropertiesToHashMapConverter.typeCastConvert(properties); + assertEquals(5, hMap.size()); + + assertThrows(ClassCastException.class, () -> { + String s = hMap.get("property4"); + }); + assertEquals(Integer.class, ((Object) hMap.get("property4")).getClass()); + + assertNull(hMap.get("5")); + assertNotNull(hMap.get(5)); + assertThrows(ClassCastException.class, () -> { + String s = hMap.get(5); + }); + assertEquals(Double.class, ((Object) hMap.get(5)).getClass()); + } + + @Test + public void havingNonModifiedProperties_whenLoopConvert_thenNoTypeSafeIssues() { + HashMap hMap = PropertiesToHashMapConverter.loopConvert(properties); + + assertEquals(3, hMap.size()); + assertEquals(String.class, hMap.get("property1").getClass()); + assertEquals(properties.get("property1"), hMap.get("property1")); + assertEquals(String.class, hMap.get("property2").getClass()); + assertEquals(properties.get("property2"), hMap.get("property2")); + assertEquals(String.class, hMap.get("property3").getClass()); + assertEquals(properties.get("property3"), hMap.get("property3")); + } + + @Test + public void havingModifiedProperties_whenLoopConvert_thenNoClassCastException() { + compromiseProperties(properties); + HashMap hMap = PropertiesToHashMapConverter.loopConvert(properties); + assertEquals(5, hMap.size()); + + assertDoesNotThrow(() -> { + String s = hMap.get("property4"); + }); + assertEquals(String.class, hMap.get("property4").getClass()); + assertEquals("456", hMap.get("property4")); + + assertDoesNotThrow(() -> { + String s = hMap.get("5"); + }); + assertEquals("10.11", hMap.get("5")); + } + + @Test + public void havingNonModifiedProperties_whenStreamConvert_thenNoTypeSafeIssues() { + HashMap hMap = PropertiesToHashMapConverter.streamConvert(properties); + + assertEquals(3, hMap.size()); + assertEquals(String.class, hMap.get("property1").getClass()); + assertEquals(properties.get("property1"), hMap.get("property1")); + assertEquals(String.class, hMap.get("property2").getClass()); + assertEquals(properties.get("property2"), hMap.get("property2")); + assertEquals(String.class, hMap.get("property3").getClass()); + assertEquals(properties.get("property3"), hMap.get("property3")); + } + + @Test + public void havingModifiedProperties_whenStreamConvert_thenNoClassCastException() { + compromiseProperties(properties); + HashMap hMap = PropertiesToHashMapConverter.streamConvert(properties); + assertEquals(5, hMap.size()); + + assertDoesNotThrow(() -> { + String s = hMap.get("property4"); + }); + assertEquals(String.class, hMap.get("property4").getClass()); + assertEquals("456", hMap.get("property4")); + + assertDoesNotThrow(() -> { + String s = hMap.get("5"); + }); + assertEquals("10.11", hMap.get("5")); + } + + @Test + public void havingModifiedProperties_whenLoopConvertAndStreamConvert_thenHashMapsSame() { + compromiseProperties(properties); + HashMap hMap1 = PropertiesToHashMapConverter.loopConvert(properties); + HashMap hMap2 = PropertiesToHashMapConverter.streamConvert(properties); + + assertEquals(hMap2, hMap1); + } + + @Test + public void havingNonModifiedProperties_whenGuavaConvert_thenNoTypeSafeIssues() { + HashMap hMap = PropertiesToHashMapConverter.guavaConvert(properties); + + assertEquals(3, hMap.size()); + assertEquals(String.class, hMap.get("property1").getClass()); + assertEquals(properties.get("property1"), hMap.get("property1")); + assertEquals(String.class, hMap.get("property2").getClass()); + assertEquals(properties.get("property2"), hMap.get("property2")); + assertEquals(String.class, hMap.get("property3").getClass()); + assertEquals(properties.get("property3"), hMap.get("property3")); + } + + @Test + public void havingModifiedProperties_whenGuavaConvert_thenUnableToConvertAndThrowException() { + compromiseProperties(properties); + assertThrows(Exception.class, () -> PropertiesToHashMapConverter.guavaConvert(properties)); + } + + @Test + public void havingModifiedPropertiesWithNoIntegerValue_whenGuavaConvert_thenNullPointerException() { + properties.put("property4", 456); + assertThrows(NullPointerException.class, () -> PropertiesToHashMapConverter.guavaConvert(properties)); + } + + @Test + public void havingModifiedPropertiesWithNoIntegerKey_whenGuavaConvert_thenClassCastException() { + properties.put(5, 10.11); + assertThrows(ClassCastException.class, () -> PropertiesToHashMapConverter.guavaConvert(properties)); + } + + + private void compromiseProperties(Properties prop) { + prop.put("property4", 456); + prop.put(5, 10.11); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps-3/src/test/resources/toHashMap.properties b/core-java-modules/core-java-collections-maps-3/src/test/resources/toHashMap.properties new file mode 100644 index 0000000000..b731aa94bb --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/test/resources/toHashMap.properties @@ -0,0 +1,3 @@ +property1=str_value +property2=123 +property3= \ No newline at end of file From 27c423c4e026c02395059c7a41e31782e514da73 Mon Sep 17 00:00:00 2001 From: Mateusz Szablak 'Saber-k Date: Tue, 19 Jan 2021 21:40:10 +0100 Subject: [PATCH 267/361] [BAEL-4214] Converting java.util.Properties to HashMap --- .../core-java-collections-maps-3/pom.xml | 4 + .../PropertiesToHashMapConverter.java | 39 ++++ .../PropertiesToHashMapConverterUnitTest.java | 192 ++++++++++++++++++ .../src/test/resources/toHashMap.properties | 3 + 4 files changed, 238 insertions(+) create mode 100644 core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverter.java create mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverterUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps-3/src/test/resources/toHashMap.properties diff --git a/core-java-modules/core-java-collections-maps-3/pom.xml b/core-java-modules/core-java-collections-maps-3/pom.xml index 577ad58255..2561f891f1 100644 --- a/core-java-modules/core-java-collections-maps-3/pom.xml +++ b/core-java-modules/core-java-collections-maps-3/pom.xml @@ -20,6 +20,10 @@ jmh-core ${jmh-core.version} + + com.google.guava + guava + diff --git a/core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverter.java b/core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverter.java new file mode 100644 index 0000000000..2f333638a9 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverter.java @@ -0,0 +1,39 @@ +package com.baeldung.map.propertieshashmap; + +import com.google.common.collect.Maps; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import java.util.stream.Collectors; + +public class PropertiesToHashMapConverter { + + @SuppressWarnings({"rawtypes", "unchecked"}) + public static HashMap typeCastConvert(Properties prop) { + Map step1 = prop; + Map step2 = (Map) step1; + return new HashMap<>(step2); + } + + public static HashMap loopConvert(Properties prop) { + HashMap retMap = new HashMap<>(); + for (Map.Entry entry : prop.entrySet()) { + retMap.put(String.valueOf(entry.getKey()), String.valueOf(entry.getValue())); + } + return retMap; + } + + public static HashMap streamConvert(Properties prop) { + return prop.entrySet().stream().collect( + Collectors.toMap( + e -> String.valueOf(e.getKey()), + e -> String.valueOf(e.getValue()), + (prev, next) -> next, HashMap::new + )); + } + + public static HashMap guavaConvert(Properties prop) { + return Maps.newHashMap(Maps.fromProperties(prop)); + } +} diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverterUnitTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverterUnitTest.java new file mode 100644 index 0000000000..1985fbe673 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverterUnitTest.java @@ -0,0 +1,192 @@ +package com.baeldung.map.propertieshashmap; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Properties; + +import static org.junit.jupiter.api.Assertions.*; + +class PropertiesToHashMapConverterUnitTest { + + private Properties properties; + + private final static String propertyFileName = "toHashMap.properties"; + + @BeforeEach + public void setup() throws IOException { + properties = new Properties(); + try (InputStream is = getClass().getClassLoader().getResourceAsStream(propertyFileName)) { + if (is != null) { + properties.load(is); + } + } + } + + @Test + public void havingPropertiesLoaded_whenCheck_thenEquals() { + assertEquals(3, properties.size()); + assertEquals("str_value", properties.get("property1")); + assertEquals("123", properties.get("property2")); + assertEquals("", properties.get("property3")); + } + + @Test + public void whenPropertiesModified_thenTypeSafeIssues() { + compromiseProperties(properties); + + assertEquals(5, properties.size()); + + assertNull(properties.getProperty("property4")); + assertNotEquals(String.class, properties.get("property4").getClass()); + assertEquals(456, properties.get("property4")); + + + assertNull(properties.getProperty("5")); + assertNotEquals(String.class, properties.get(5).getClass()); + assertEquals(10.11, properties.get(5)); + } + + @Test + public void havingNonModifiedProperties_whenTypeCastConvert_thenNoTypeSafeIssues() { + HashMap hMap = PropertiesToHashMapConverter.typeCastConvert(properties); + + assertEquals(3, hMap.size()); + assertEquals(String.class, hMap.get("property1").getClass()); + assertEquals(properties.get("property1"), hMap.get("property1")); + assertEquals(String.class, hMap.get("property2").getClass()); + assertEquals(properties.get("property2"), hMap.get("property2")); + assertEquals(String.class, hMap.get("property3").getClass()); + assertEquals(properties.get("property3"), hMap.get("property3")); + } + + @Test + public void havingModifiedProperties_whenTypeCastConvert_thenClassCastException() { + compromiseProperties(properties); + HashMap hMap = PropertiesToHashMapConverter.typeCastConvert(properties); + assertEquals(5, hMap.size()); + + assertThrows(ClassCastException.class, () -> { + String s = hMap.get("property4"); + }); + assertEquals(Integer.class, ((Object) hMap.get("property4")).getClass()); + + assertNull(hMap.get("5")); + assertNotNull(hMap.get(5)); + assertThrows(ClassCastException.class, () -> { + String s = hMap.get(5); + }); + assertEquals(Double.class, ((Object) hMap.get(5)).getClass()); + } + + @Test + public void havingNonModifiedProperties_whenLoopConvert_thenNoTypeSafeIssues() { + HashMap hMap = PropertiesToHashMapConverter.loopConvert(properties); + + assertEquals(3, hMap.size()); + assertEquals(String.class, hMap.get("property1").getClass()); + assertEquals(properties.get("property1"), hMap.get("property1")); + assertEquals(String.class, hMap.get("property2").getClass()); + assertEquals(properties.get("property2"), hMap.get("property2")); + assertEquals(String.class, hMap.get("property3").getClass()); + assertEquals(properties.get("property3"), hMap.get("property3")); + } + + @Test + public void havingModifiedProperties_whenLoopConvert_thenNoClassCastException() { + compromiseProperties(properties); + HashMap hMap = PropertiesToHashMapConverter.loopConvert(properties); + assertEquals(5, hMap.size()); + + assertDoesNotThrow(() -> { + String s = hMap.get("property4"); + }); + assertEquals(String.class, hMap.get("property4").getClass()); + assertEquals("456", hMap.get("property4")); + + assertDoesNotThrow(() -> { + String s = hMap.get("5"); + }); + assertEquals("10.11", hMap.get("5")); + } + + @Test + public void havingNonModifiedProperties_whenStreamConvert_thenNoTypeSafeIssues() { + HashMap hMap = PropertiesToHashMapConverter.streamConvert(properties); + + assertEquals(3, hMap.size()); + assertEquals(String.class, hMap.get("property1").getClass()); + assertEquals(properties.get("property1"), hMap.get("property1")); + assertEquals(String.class, hMap.get("property2").getClass()); + assertEquals(properties.get("property2"), hMap.get("property2")); + assertEquals(String.class, hMap.get("property3").getClass()); + assertEquals(properties.get("property3"), hMap.get("property3")); + } + + @Test + public void havingModifiedProperties_whenStreamConvert_thenNoClassCastException() { + compromiseProperties(properties); + HashMap hMap = PropertiesToHashMapConverter.streamConvert(properties); + assertEquals(5, hMap.size()); + + assertDoesNotThrow(() -> { + String s = hMap.get("property4"); + }); + assertEquals(String.class, hMap.get("property4").getClass()); + assertEquals("456", hMap.get("property4")); + + assertDoesNotThrow(() -> { + String s = hMap.get("5"); + }); + assertEquals("10.11", hMap.get("5")); + } + + @Test + public void havingModifiedProperties_whenLoopConvertAndStreamConvert_thenHashMapsSame() { + compromiseProperties(properties); + HashMap hMap1 = PropertiesToHashMapConverter.loopConvert(properties); + HashMap hMap2 = PropertiesToHashMapConverter.streamConvert(properties); + + assertEquals(hMap2, hMap1); + } + + @Test + public void havingNonModifiedProperties_whenGuavaConvert_thenNoTypeSafeIssues() { + HashMap hMap = PropertiesToHashMapConverter.guavaConvert(properties); + + assertEquals(3, hMap.size()); + assertEquals(String.class, hMap.get("property1").getClass()); + assertEquals(properties.get("property1"), hMap.get("property1")); + assertEquals(String.class, hMap.get("property2").getClass()); + assertEquals(properties.get("property2"), hMap.get("property2")); + assertEquals(String.class, hMap.get("property3").getClass()); + assertEquals(properties.get("property3"), hMap.get("property3")); + } + + @Test + public void havingModifiedProperties_whenGuavaConvert_thenUnableToConvertAndThrowException() { + compromiseProperties(properties); + assertThrows(Exception.class, () -> PropertiesToHashMapConverter.guavaConvert(properties)); + } + + @Test + public void havingModifiedPropertiesWithNoIntegerValue_whenGuavaConvert_thenNullPointerException() { + properties.put("property4", 456); + assertThrows(NullPointerException.class, () -> PropertiesToHashMapConverter.guavaConvert(properties)); + } + + @Test + public void havingModifiedPropertiesWithNoIntegerKey_whenGuavaConvert_thenClassCastException() { + properties.put(5, 10.11); + assertThrows(ClassCastException.class, () -> PropertiesToHashMapConverter.guavaConvert(properties)); + } + + + private void compromiseProperties(Properties prop) { + prop.put("property4", 456); + prop.put(5, 10.11); + } +} diff --git a/core-java-modules/core-java-collections-maps-3/src/test/resources/toHashMap.properties b/core-java-modules/core-java-collections-maps-3/src/test/resources/toHashMap.properties new file mode 100644 index 0000000000..727e858a8c --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/test/resources/toHashMap.properties @@ -0,0 +1,3 @@ +property1=str_value +property2=123 +property3= From d3156e1034f14b96336a76ff52e72b4852cf44f4 Mon Sep 17 00:00:00 2001 From: MeenaGawande Date: Wed, 20 Jan 2021 11:29:38 +0530 Subject: [PATCH 268/361] [BAEL-4715] Java HashMap Load Factor [BAEL-4715] Java HashMap Load Factor --- .../loadfactor/HashMapLoadFactorUnitTest.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/hashmap/loadfactor/HashMapLoadFactorUnitTest.java diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/hashmap/loadfactor/HashMapLoadFactorUnitTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/hashmap/loadfactor/HashMapLoadFactorUnitTest.java new file mode 100644 index 0000000000..89e2a189fe --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/hashmap/loadfactor/HashMapLoadFactorUnitTest.java @@ -0,0 +1,49 @@ +package com.baeldung.map.hashmap.loadfactor; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.jupiter.api.Test; + +public class HashMapLoadFactorUnitTest { + + @Test + public void whenCreateMapWithDefaultParam_thenSucces() { + Map mapWithDefaultParams = new HashMap(); + mapWithDefaultParams.put("1", "One"); + mapWithDefaultParams.put("2", "two"); + mapWithDefaultParams.put("3", "three"); + mapWithDefaultParams.put("4", "four"); + mapWithDefaultParams.put("5", "five"); + + Assert.assertEquals(5, mapWithDefaultParams.size()); + } + + @Test + public void whenCreateMapWithInitialCapacity_thenSucces() { + Map mapWithInitialCapacity = new HashMap(5); + mapWithInitialCapacity.put("1", "One"); + mapWithInitialCapacity.put("2", "two"); + mapWithInitialCapacity.put("3", "three"); + + Assert.assertEquals(3, mapWithInitialCapacity.size()); + } + + @Test + public void whenCreateMapWithInitialCapacityAndLF_thenSucces() { + Map mapWithInitialCapacityAndLF = new HashMap(5, 0.5f); + mapWithInitialCapacityAndLF.put("1", "one"); + mapWithInitialCapacityAndLF.put("2", "two"); + mapWithInitialCapacityAndLF.put("3", "three"); + mapWithInitialCapacityAndLF.put("4", "four"); + mapWithInitialCapacityAndLF.put("5", "five"); + mapWithInitialCapacityAndLF.put("6", "six"); + mapWithInitialCapacityAndLF.put("7", "seven"); + mapWithInitialCapacityAndLF.put("8", "eight"); + mapWithInitialCapacityAndLF.put("9", "nine"); + mapWithInitialCapacityAndLF.put("10", "ten"); + + Assert.assertEquals(10, mapWithInitialCapacityAndLF.size()); + } +} From 98cce29a737a390516a024404dab9ea8a7e9ca32 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 20 Jan 2021 22:39:59 +0800 Subject: [PATCH 269/361] Update README.md --- java-collections-maps-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/java-collections-maps-3/README.md b/java-collections-maps-3/README.md index 4da8547824..39ac8575fa 100644 --- a/java-collections-maps-3/README.md +++ b/java-collections-maps-3/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Java Map With Case-Insensitive Keys](https://www.baeldung.com/java-map-with-case-insensitive-keys) +- [Using a Byte Array as Map Key in Java](https://www.baeldung.com/java-map-key-byte-array) From 1e16299ac522244bccbb84557c612ed8d316dbef Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 20 Jan 2021 22:42:24 +0800 Subject: [PATCH 270/361] Update README.md --- java-numbers-4/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/java-numbers-4/README.md b/java-numbers-4/README.md index 7db25b283c..cdd53692e0 100644 --- a/java-numbers-4/README.md +++ b/java-numbers-4/README.md @@ -2,3 +2,4 @@ - [Probability in Java](https://www.baeldung.com/java-probability) - [Understanding the & 0xff Value in Java](https://www.baeldung.com/java-and-0xff) +- [Determine if an Integer’s Square Root Is an Integer in Java](https://www.baeldung.com/java-find-if-square-root-is-integer) From 093fb533fa14d317f95b9a966442132d8d0b4378 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 20 Jan 2021 22:44:10 +0800 Subject: [PATCH 271/361] Update README.md --- core-java-modules/core-java-lang-math-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-lang-math-3/README.md b/core-java-modules/core-java-lang-math-3/README.md index 9eee021f8f..dda3013407 100644 --- a/core-java-modules/core-java-lang-math-3/README.md +++ b/core-java-modules/core-java-lang-math-3/README.md @@ -5,4 +5,5 @@ ### Relevant articles: - [Calculate Factorial in Java](https://www.baeldung.com/java-calculate-factorial) +- [Evaluating a Math Expression in Java](https://www.baeldung.com/java-evaluate-math-expression-string) - More articles: [[<-- Prev]](/core-java-modules/core-java-lang-math-2) From f7f017037f4f0a7be3583721d9f171b0b0b33a27 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 20 Jan 2021 22:46:34 +0800 Subject: [PATCH 272/361] Update README.md --- persistence-modules/java-jpa-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/java-jpa-3/README.md b/persistence-modules/java-jpa-3/README.md index 1949207364..9c9e040825 100644 --- a/persistence-modules/java-jpa-3/README.md +++ b/persistence-modules/java-jpa-3/README.md @@ -9,3 +9,4 @@ This module contains articles about the Java Persistence API (JPA) in Java. - [Defining Indexes in JPA](https://www.baeldung.com/jpa-indexes) - [JPA CascadeType.REMOVE vs orphanRemoval](https://www.baeldung.com/jpa-cascade-remove-vs-orphanremoval) - [A Guide to MultipleBagFetchException in Hibernate](https://www.baeldung.com/java-hibernate-multiplebagfetchexception) +- [How to Convert a Hibernate Proxy to a Real Entity Object](https://www.baeldung.com/hibernate-proxy-to-real-entity-object) From c3f92c8b3846e571ff3ded44692fd8fb1b5b0cb7 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 20 Jan 2021 22:50:15 +0800 Subject: [PATCH 273/361] Create README.md --- patterns/clean-architecture/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 patterns/clean-architecture/README.md diff --git a/patterns/clean-architecture/README.md b/patterns/clean-architecture/README.md new file mode 100644 index 0000000000..aad8608447 --- /dev/null +++ b/patterns/clean-architecture/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Clean Architecture with Spring Boot](https://www.baeldung.com/spring-boot-clean-architecture) From 59e4bd98114616735188ffcb3171bcecb8c8e4be Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Wed, 20 Jan 2021 12:37:10 -0300 Subject: [PATCH 274/361] updated deprecation: HandlerInterceptorAdapter class -> HandlerInterceptor interface --- .../baeldung/loginredirect/LoginPageInterceptor.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-security-modules/spring-security-web-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageInterceptor.java b/spring-security-modules/spring-security-web-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageInterceptor.java index aa93201f37..f08b824369 100644 --- a/spring-security-modules/spring-security-web-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageInterceptor.java +++ b/spring-security-modules/spring-security-web-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageInterceptor.java @@ -1,16 +1,16 @@ package com.baeldung.loginredirect; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.apache.http.HttpStatus; import org.springframework.security.authentication.AnonymousAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; +import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.util.UrlPathHelper; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -class LoginPageInterceptor extends HandlerInterceptorAdapter { +class LoginPageInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { From c5a57eb06572f3baa619eea20ae666d96a7d3b69 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Wed, 20 Jan 2021 22:31:35 +0530 Subject: [PATCH 275/361] JAVA-4012: Moved 1 article to spring-boot-persistence-mongodb --- .../src/main/resources/mongoConfig.xml | 31 ++++++++++++++++++ .../src/main/resources/test.png | Bin .../com/baeldung/gridfs/GridFSLiveTest.java | 0 .../src/main/resources/mongoConfig.xml | 5 --- 4 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 persistence-modules/spring-boot-persistence-mongodb/src/main/resources/mongoConfig.xml rename persistence-modules/{spring-data-mongodb => spring-boot-persistence-mongodb}/src/main/resources/test.png (100%) rename persistence-modules/{spring-data-mongodb => spring-boot-persistence-mongodb}/src/test/java/com/baeldung/gridfs/GridFSLiveTest.java (100%) diff --git a/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/mongoConfig.xml b/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/mongoConfig.xml new file mode 100644 index 0000000000..c5b9068de3 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/mongoConfig.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-mongodb/src/main/resources/test.png b/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/test.png similarity index 100% rename from persistence-modules/spring-data-mongodb/src/main/resources/test.png rename to persistence-modules/spring-boot-persistence-mongodb/src/main/resources/test.png diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/gridfs/GridFSLiveTest.java b/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/gridfs/GridFSLiveTest.java similarity index 100% rename from persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/gridfs/GridFSLiveTest.java rename to persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/gridfs/GridFSLiveTest.java diff --git a/persistence-modules/spring-data-mongodb/src/main/resources/mongoConfig.xml b/persistence-modules/spring-data-mongodb/src/main/resources/mongoConfig.xml index 074a203b1a..5067bec78e 100644 --- a/persistence-modules/spring-data-mongodb/src/main/resources/mongoConfig.xml +++ b/persistence-modules/spring-data-mongodb/src/main/resources/mongoConfig.xml @@ -14,11 +14,6 @@ - - - - - From 52c492f679220b77ec0488da155e766b40b165e1 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Wed, 20 Jan 2021 22:32:54 +0530 Subject: [PATCH 276/361] JAVA-4012: README changes --- persistence-modules/spring-boot-persistence-mongodb/README.md | 1 + persistence-modules/spring-data-mongodb/README.md | 2 -- persistence-modules/spring-jpa/README.md | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/persistence-modules/spring-boot-persistence-mongodb/README.md b/persistence-modules/spring-boot-persistence-mongodb/README.md index f277ef66ca..aade8eb1c0 100644 --- a/persistence-modules/spring-boot-persistence-mongodb/README.md +++ b/persistence-modules/spring-boot-persistence-mongodb/README.md @@ -3,3 +3,4 @@ - [Auto-Generated Field for MongoDB using Spring Boot](https://www.baeldung.com/spring-boot-mongodb-auto-generated-field) - [Spring Boot Integration Testing with Embedded MongoDB](http://www.baeldung.com/spring-boot-embedded-mongodb) - [Upload and Retrieve Files Using MongoDB and Spring Boot](https://www.baeldung.com/spring-boot-mongodb-upload-file) +- [GridFS in Spring Data MongoDB](http://www.baeldung.com/spring-data-mongodb-gridfs) diff --git a/persistence-modules/spring-data-mongodb/README.md b/persistence-modules/spring-data-mongodb/README.md index 381bf83fa8..0be8c57036 100644 --- a/persistence-modules/spring-data-mongodb/README.md +++ b/persistence-modules/spring-data-mongodb/README.md @@ -7,10 +7,8 @@ - [A Guide to Queries in Spring Data MongoDB](http://www.baeldung.com/queries-in-spring-data-mongodb) - [Spring Data MongoDB – Indexes, Annotations and Converters](http://www.baeldung.com/spring-data-mongodb-index-annotations-converter) - [Custom Cascading in Spring Data MongoDB](http://www.baeldung.com/cascading-with-dbref-and-lifecycle-events-in-spring-data-mongodb) -- [GridFS in Spring Data MongoDB](http://www.baeldung.com/spring-data-mongodb-gridfs) - [Introduction to Spring Data MongoDB](http://www.baeldung.com/spring-data-mongodb-tutorial) - [Spring Data MongoDB: Projections and Aggregations](http://www.baeldung.com/spring-data-mongodb-projections-aggregations) -- [Spring Data Annotations](http://www.baeldung.com/spring-data-annotations) - [Spring Data MongoDB Transactions](https://www.baeldung.com/spring-data-mongodb-transactions ) - [ZonedDateTime with Spring Data MongoDB](https://www.baeldung.com/spring-data-mongodb-zoneddatetime) diff --git a/persistence-modules/spring-jpa/README.md b/persistence-modules/spring-jpa/README.md index f60609e0de..937890cd13 100644 --- a/persistence-modules/spring-jpa/README.md +++ b/persistence-modules/spring-jpa/README.md @@ -7,6 +7,7 @@ - [Self-Contained Testing Using an In-Memory Database](https://www.baeldung.com/spring-jpa-test-in-memory-database) - [A Guide to Spring AbstractRoutingDatasource](https://www.baeldung.com/spring-abstract-routing-data-source) - [Obtaining Auto-generated Keys in Spring JDBC](https://www.baeldung.com/spring-jdbc-autogenerated-keys) +- [Spring Data Annotations](http://www.baeldung.com/spring-data-annotations) - More articles: [[next -->]](/spring-jpa-2) ### Eclipse Config From a679b1997864a78543c1fdc4522a3743f0b448f1 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Wed, 20 Jan 2021 22:39:36 +0530 Subject: [PATCH 277/361] JAVA-4012: removed entry for article --- persistence-modules/spring-data-jpa-annotations/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/persistence-modules/spring-data-jpa-annotations/README.md b/persistence-modules/spring-data-jpa-annotations/README.md index 5f1c8dbc27..1ee579cf6c 100644 --- a/persistence-modules/spring-data-jpa-annotations/README.md +++ b/persistence-modules/spring-data-jpa-annotations/README.md @@ -4,7 +4,6 @@ This module contains articles about annotations used in Spring Data JPA ### Relevant articles -- [Spring Data Annotations](https://www.baeldung.com/spring-data-annotations) - [DDD Aggregates and @DomainEvents](https://www.baeldung.com/spring-data-ddd) - [JPA @Embedded And @Embeddable](https://www.baeldung.com/jpa-embedded-embeddable) - [Spring Data JPA @Modifying Annotation](https://www.baeldung.com/spring-data-jpa-modifying-annotation) From 5b1e5979782cbf0d6b468adcb01ef370df43a09a Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Thu, 21 Jan 2021 11:47:41 -0300 Subject: [PATCH 278/361] Updated deprecated BodyInserters.fromObject method, in favor of BodyInserters.fromValue --- .../com/baeldung/web/reactive/client/WebClientController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java index a719259328..09134701e9 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java +++ b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java @@ -38,7 +38,7 @@ public class WebClientController { // request header specification WebClient.RequestHeadersSpec requestSpec1 = uri1.body(BodyInserters.fromPublisher(Mono.just("data"), String.class)); - WebClient.RequestHeadersSpec requestSpec2 = uri2.body(BodyInserters.fromObject("data")); + WebClient.RequestHeadersSpec requestSpec2 = uri2.body(BodyInserters.fromValue("data")); // inserters BodyInserter, ReactiveHttpOutputMessage> inserter1 = BodyInserters @@ -49,7 +49,7 @@ public class WebClientController { map.add("key2", "value2"); // BodyInserter, ClientHttpRequest> inserter2 = BodyInserters.fromMultipartData(map); - BodyInserter inserter3 = BodyInserters.fromObject("body"); + BodyInserter inserter3 = BodyInserters.fromValue("body"); // responses WebClient.ResponseSpec response1 = uri1.body(inserter3) From 14506a542df37ff132f307a35eeb91dfeba7dd66 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Thu, 21 Jan 2021 11:50:55 -0300 Subject: [PATCH 279/361] removed unused reactor-spring version property --- spring-5-reactive/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-5-reactive/pom.xml b/spring-5-reactive/pom.xml index 3b7383f726..60c8b90e16 100644 --- a/spring-5-reactive/pom.xml +++ b/spring-5-reactive/pom.xml @@ -149,7 +149,6 @@ - 1.0.1.RELEASE 1.1.3 1.0 1.0 From 52d458c05f5c1dd2eec3bb6aca1b2b0f9d362de7 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Thu, 21 Jan 2021 12:43:26 -0300 Subject: [PATCH 280/361] formatted WebClientController class --- .../reactive/client/WebClientController.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java index 09134701e9..7c0dc1cff7 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java +++ b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java @@ -1,8 +1,17 @@ package com.baeldung.web.reactive.client; +import java.net.URI; +import java.nio.charset.Charset; +import java.time.ZonedDateTime; +import java.util.Collections; + import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; -import org.springframework.http.*; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ReactiveHttpOutputMessage; import org.springframework.util.LinkedMultiValueMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseStatus; @@ -10,12 +19,8 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.reactive.function.BodyInserter; import org.springframework.web.reactive.function.BodyInserters; import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Mono; -import java.net.URI; -import java.nio.charset.Charset; -import java.time.ZonedDateTime; -import java.util.Collections; +import reactor.core.publisher.Mono; @RestController public class WebClientController { @@ -41,8 +46,7 @@ public class WebClientController { WebClient.RequestHeadersSpec requestSpec2 = uri2.body(BodyInserters.fromValue("data")); // inserters - BodyInserter, ReactiveHttpOutputMessage> inserter1 = BodyInserters - .fromPublisher(Subscriber::onComplete, String.class); + BodyInserter, ReactiveHttpOutputMessage> inserter1 = BodyInserters.fromPublisher(Subscriber::onComplete, String.class); LinkedMultiValueMap map = new LinkedMultiValueMap<>(); map.add("key1", "value1"); From dd60782928c438d33d05c07889eba964c3f62318 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Thu, 21 Jan 2021 12:44:06 -0300 Subject: [PATCH 281/361] Added timeout WebClient configuration, as in article --- .../reactive/client/WebClientController.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java index 7c0dc1cff7..3132a4173d 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java +++ b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java @@ -4,6 +4,7 @@ import java.net.URI; import java.nio.charset.Charset; import java.time.ZonedDateTime; import java.util.Collections; +import java.util.concurrent.TimeUnit; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; @@ -12,6 +13,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ReactiveHttpOutputMessage; +import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.util.LinkedMultiValueMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseStatus; @@ -20,7 +22,12 @@ import org.springframework.web.reactive.function.BodyInserter; import org.springframework.web.reactive.function.BodyInserters; import org.springframework.web.reactive.function.client.WebClient; +import io.netty.channel.ChannelOption; +import io.netty.handler.timeout.ReadTimeoutHandler; +import io.netty.handler.timeout.WriteTimeoutHandler; import reactor.core.publisher.Mono; +import reactor.netty.http.client.HttpClient; +import reactor.netty.tcp.TcpClient; @RestController public class WebClientController { @@ -75,6 +82,19 @@ public class WebClientController { return WebClient.create("http://localhost:8081"); } + private WebClient createWebClientConfiguringTimeout() { + TcpClient tcpClient = TcpClient.create() + .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000) + .doOnConnected(connection -> { + connection.addHandlerLast(new ReadTimeoutHandler(5000, TimeUnit.MILLISECONDS)); + connection.addHandlerLast(new WriteTimeoutHandler(5000, TimeUnit.MILLISECONDS)); + }); + + return WebClient.builder() + .clientConnector(new ReactorClientHttpConnector(HttpClient.from(tcpClient))) + .build(); + } + private WebClient createWebClientWithServerURLAndDefaultValues() { return WebClient.builder() .baseUrl("http://localhost:8081") From 1f7e0f06b6d8286f8a053ad38a385ef41bd55bec Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Thu, 21 Jan 2021 14:25:30 -0300 Subject: [PATCH 282/361] updated timeout logic due to deprecation --- .../web/reactive/client/WebClientController.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java index 3132a4173d..66f787eda3 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java +++ b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java @@ -27,7 +27,6 @@ import io.netty.handler.timeout.ReadTimeoutHandler; import io.netty.handler.timeout.WriteTimeoutHandler; import reactor.core.publisher.Mono; import reactor.netty.http.client.HttpClient; -import reactor.netty.tcp.TcpClient; @RestController public class WebClientController { @@ -83,15 +82,13 @@ public class WebClientController { } private WebClient createWebClientConfiguringTimeout() { - TcpClient tcpClient = TcpClient.create() + HttpClient httpClient = HttpClient.create() .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000) - .doOnConnected(connection -> { - connection.addHandlerLast(new ReadTimeoutHandler(5000, TimeUnit.MILLISECONDS)); - connection.addHandlerLast(new WriteTimeoutHandler(5000, TimeUnit.MILLISECONDS)); - }); + .doOnConnected(conn -> conn.addHandlerLast(new ReadTimeoutHandler(5000, TimeUnit.MILLISECONDS)) + .addHandlerLast(new WriteTimeoutHandler(5000, TimeUnit.MILLISECONDS))); return WebClient.builder() - .clientConnector(new ReactorClientHttpConnector(HttpClient.from(tcpClient))) + .clientConnector(new ReactorClientHttpConnector(httpClient)) .build(); } From e6ab521b6127a9949515da3ad47aac66e8963cf9 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Thu, 21 Jan 2021 14:57:06 -0300 Subject: [PATCH 283/361] added LinkedMultiValueMap usage for inserter declaration, as in article --- .../com/baeldung/web/reactive/client/WebClientController.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java index 66f787eda3..34de13bc28 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java +++ b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java @@ -13,8 +13,10 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ReactiveHttpOutputMessage; +import org.springframework.http.client.reactive.ClientHttpRequest; import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; @@ -58,7 +60,7 @@ public class WebClientController { map.add("key1", "value1"); map.add("key2", "value2"); - // BodyInserter, ClientHttpRequest> inserter2 = BodyInserters.fromMultipartData(map); + BodyInserter, ClientHttpRequest> inserter2 = BodyInserters.fromMultipartData(map); BodyInserter inserter3 = BodyInserters.fromValue("body"); // responses From d90c7fed48fd86207471f821305ec8bbc109df54 Mon Sep 17 00:00:00 2001 From: Daniel Strmecki Date: Fri, 22 Jan 2021 08:53:02 +0100 Subject: [PATCH 284/361] =?UTF-8?q?BAEL-4644:=20Small=20test=20to=20check?= =?UTF-8?q?=20Java=20JIT=20compiler=20performances=20vs=20C++=20=E2=80=A6?= =?UTF-8?q?=20(#10412)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * BAEL-4644: Small test to check Java JIT compiler performances vs C++ and JS * BAEL-4644: Remove CSV with performance test results * Revert "BAEL-4644: Remove CSV with performance test results" This reverts commit a69c9667 --- .../src/main/external/Fibonacci.cpp | 19 ++++ .../src/main/external/Fibonacci.js | 14 +++ .../performancetests/jit/Fibonacci.java | 20 ++++ .../FibonacciPerformancesResults.csv | 103 ++++++++++++++++++ 4 files changed, 156 insertions(+) create mode 100644 performance-tests/src/main/external/Fibonacci.cpp create mode 100644 performance-tests/src/main/external/Fibonacci.js create mode 100644 performance-tests/src/main/java/com/baeldung/performancetests/jit/Fibonacci.java create mode 100644 performance-tests/src/main/resources/FibonacciPerformancesResults.csv diff --git a/performance-tests/src/main/external/Fibonacci.cpp b/performance-tests/src/main/external/Fibonacci.cpp new file mode 100644 index 0000000000..d23603c2ea --- /dev/null +++ b/performance-tests/src/main/external/Fibonacci.cpp @@ -0,0 +1,19 @@ +#include +#include + +using namespace std; + +int fibonacci(int n) { + if (n <= 1) + return n; + return fibonacci(n - 1) + fibonacci(n - 2); +} + +int main() { + for (int i = 0; i < 100; i++) { + auto startTime = chrono::high_resolution_clock::now().time_since_epoch(); + int result = fibonacci(12); + auto totalTime = chrono::high_resolution_clock::now().time_since_epoch() - startTime; + cout << totalTime << "\n"; + } +} \ No newline at end of file diff --git a/performance-tests/src/main/external/Fibonacci.js b/performance-tests/src/main/external/Fibonacci.js new file mode 100644 index 0000000000..ba41bf3ab9 --- /dev/null +++ b/performance-tests/src/main/external/Fibonacci.js @@ -0,0 +1,14 @@ +function fibonacci(index) { + if (index <= 1) + return index; + return fibonacci(index-1) + fibonacci(index-2); +} + +for (var i=0; i<100; i++) { + var startTime = process.hrtime.bigint(); + var result = fibonacci(12); + var totalTime = process.hrtime.bigint() - startTime; + console.log(totalTime); +} + + \ No newline at end of file diff --git a/performance-tests/src/main/java/com/baeldung/performancetests/jit/Fibonacci.java b/performance-tests/src/main/java/com/baeldung/performancetests/jit/Fibonacci.java new file mode 100644 index 0000000000..c980093128 --- /dev/null +++ b/performance-tests/src/main/java/com/baeldung/performancetests/jit/Fibonacci.java @@ -0,0 +1,20 @@ +package com.baeldung.performancetests.jit; + +public class Fibonacci { + + public static void main(String[] args) { + for (int i=0; i<100; i++) { + long startTime = System.nanoTime(); + int result = fibonacci(12); + long totalTime = System.nanoTime() - startTime; + System.out.println(totalTime); + } + } + + private static int fibonacci(int index) { + if (index <= 1) + return index; + return fibonacci(index-1) + fibonacci(index-2); + } + +} diff --git a/performance-tests/src/main/resources/FibonacciPerformancesResults.csv b/performance-tests/src/main/resources/FibonacciPerformancesResults.csv new file mode 100644 index 0000000000..01a1f3dd90 --- /dev/null +++ b/performance-tests/src/main/resources/FibonacciPerformancesResults.csv @@ -0,0 +1,103 @@ +Runs;Java using JIT;Java without JIT;C++ without O2;C++ with O2;JavaScript +1;21900;10572;8684;2643;35115 +2;60790;10572;8306;2643;20389 +3;1888;24543;7551;2265;20390 +4;4153;25675;8307;2265;19256 +5;1888;26053;8307;2265;19257 +6;5664;25675;8307;1887;35115 +7;1510;25676;29829;2266;20012 +8;1510;26053;7929;2643;35493 +9;1511;23787;7929;1888;40023 +10;3776;26431;26053;3776;20012 +11;1510;25676;7929;2265;35115 +12;1510;10195;7552;3775;19256 +13;17746;10572;7552;1888;40024 +14;26431;10194;7552;2265;19257 +15;1133;10195;8685;2265;18501 +16;1133;10572;7929;2265;18879 +17;1133;10572;7929;1888;53995 +18;756;10195;7929;1888;35115 +19;1133;10195;7930;2266;19634 +20;756;10573;7552;2266;37003 +21;1133;9817;7552;1888;35115 +22;1133;10194;7930;2266;32472 +23;1133;10195;7929;2266;18879 +24;755;10195;8307;3776;19257 +25;755;10195;7551;1888;34738 +26;1510;10194;7551;2265;18501 +27;3776;10194;7929;2266;33227 +28;1888;37758;9440;1888;19634 +29;1133;10573;8306;1888;32472 +30;1133;26430;7929;2265;32849 +31;1133;24165;8306;4153;32850 +32;755;24166;7929;2643;18879 +33;1133;10572;24920;4153;32850 +34;755;23788;10194;2643;19257 +35;756;23788;12837;4154;18501 +36;755;11328;8307;2643;33227 +37;1132;29829;8307;7174;1000211 +38;755;36625;8307;4531;39646 +39;1133;10950;7929;2643;34360 +40;1133;10950;7929;4531;3021 +41;1133;10573;7929;2643;2643 +42;755;29829;15104;2643;2643 +43;755;29829;13971;2643;3398 +44;1133;10950;8685;5664;3021 +45;1133;10950;9817;3020;3398 +46;1133;10950;8684;3776;3020 +47;1888;30962;7930;3020;3021 +48;1132;10950;8307;2643;3399 +49;1133;29451;7929;2265;2266 +50;1133;29452;8307;23033;2265 +51;755;10950;7929;2643;2266 +52;755;10950;7930;2643;2643 +53;755;11327;7929;4908;2265 +54;755;11328;7929;2265;2643 +55;1133;10572;7929;18879;16236 +56;756;36248;7929;2643;2643 +57;755;10572;7929;2265;2643 +58;755;10950;9818;2644;2643 +59;1132;10950;7929;2266;2643 +60;20012;30206;7929;2266;3021 +61;1133;30206;7929;2266;16613 +62;1511;30206;7552;2266;2643 +63;3021;30207;8307;1888;2643 +64;1510;10950;7929;1888;2266 +65;1510;30207;7929;2266;2644 +66;1888;30207;8307;2265;2643 +67;1511;29829;7929;2266;2643 +68;1888;10950;7930;2265;2266 +69;1510;29829;7929;21145;3020 +70;1511;29829;7929;1888;16613 +71;1510;30206;7929;2643;2265 +72;1510;10950;7929;2266;2644 +73;1888;10573;24921;18124;2266 +74;1888;10573;9062;6797;2644 +75;1888;10950;7929;2265;2643 +76;1133;10950;7929;2266;2644 +77;1133;29829;12460;2266;3020 +78;755;11328;8307;2643;2266 +79;755;11327;8684;2266;2643 +80;1133;30206;8307;2266;2643 +81;1133;29829;7929;2266;2266 +82;1888;30206;7929;2266;16236 +83;1510;11327;8307;2266;16613 +84;1888;11327;7929;2265;2643 +85;1133;10573;8307;6042;2266 +86;1133;10950;7929;2643;2266 +87;1133;10950;9817;2265;2265 +88;755;10950;24165;2643;2643 +89;755;11328;7929;3399;2643 +90;755;10950;8307;4909;3020 +91;755;10572;7552;23787;3020 +92;1133;10572;7929;2643;3021 +93;1132;10572;8307;2643;2643 +94;1132;10950;7551;2266;3398 +95;755;10950;23788;2265;2644 +96;755;10573;7551;1888;2265 +97;755;29829;12460;2266;2643 +98;1132;30207;7929;2266;2265 +99;1133;30206;7929;2265;2266 +100;755;10572;7929;2265;2643 +;;;;; +;;;;; From 10318d1145c2d2a87ec3e5d718aa8122c2609a9a Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Fri, 22 Jan 2021 10:29:15 -0300 Subject: [PATCH 285/361] updated inserter3 as in article --- .../com/baeldung/web/reactive/client/WebClientController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java index 34de13bc28..70919d8a2e 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java +++ b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java @@ -61,7 +61,8 @@ public class WebClientController { map.add("key2", "value2"); BodyInserter, ClientHttpRequest> inserter2 = BodyInserters.fromMultipartData(map); - BodyInserter inserter3 = BodyInserters.fromValue("body"); + BodyInserter inserter3 = BodyInserters.fromValue(new Object()); + BodyInserter inserter4 = BodyInserters.fromValue("body"); // responses WebClient.ResponseSpec response1 = uri1.body(inserter3) From 814369e38cf68f9e3ff428c92bca3f044520bcf2 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Fri, 22 Jan 2021 10:49:47 -0300 Subject: [PATCH 286/361] added exchange and retrieve examples as in teh article, updated due to deprecation --- .../baeldung/web/reactive/client/WebClientController.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java index 70919d8a2e..de4f20a13f 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java +++ b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java @@ -72,8 +72,12 @@ public class WebClientController { .ifNoneMatch("*") .ifModifiedSince(ZonedDateTime.now()) .retrieve(); - WebClient.ResponseSpec response2 = requestSpec2.retrieve(); - + String response2 = uri1.exchangeToMono(response -> response.bodyToMono(String.class)) + .block(); + String response3 = uri2.retrieve() + .bodyToMono(String.class) + .block(); + WebClient.ResponseSpec response4 = requestSpec2.retrieve(); } private WebClient createWebClient() { From 1b78d4be310efbb6dbaacac028b2e14305738e60 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Fri, 22 Jan 2021 12:33:54 -0300 Subject: [PATCH 287/361] fixed and improved WebClient integration test --- .../reactive/client/WebClientApplication.java | 13 +++++ .../reactive/client/WebClientController.java | 7 ++- .../client/WebTestClientIntegrationTest.java | 54 ++++++++++++++++--- 3 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientApplication.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientApplication.java b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientApplication.java new file mode 100644 index 0000000000..f104ad30f1 --- /dev/null +++ b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.web.reactive.client; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class WebClientApplication{ + + public static void main(String[] args) { + SpringApplication.run(WebClientApplication.class, args); + } + +} diff --git a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java index de4f20a13f..2d42e848b2 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java +++ b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java @@ -4,6 +4,8 @@ import java.net.URI; import java.nio.charset.Charset; import java.time.ZonedDateTime; import java.util.Collections; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.TimeUnit; import org.reactivestreams.Publisher; @@ -35,7 +37,10 @@ public class WebClientController { @ResponseStatus(HttpStatus.OK) @GetMapping("/resource") - public void getResource() { + public Map getResource() { + Map response = new HashMap<>(); + response.put("field", "value"); + return response; } public void demonstrateWebClient() { diff --git a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebTestClientIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebTestClientIntegrationTest.java index 2e37f2ffbd..07a4c81c91 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebTestClientIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebTestClientIntegrationTest.java @@ -1,11 +1,11 @@ package com.baeldung.web.client; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.context.ApplicationContext; import org.springframework.security.test.context.support.WithMockUser; -import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.web.reactive.function.server.RequestPredicates; import org.springframework.web.reactive.function.server.RouterFunction; @@ -13,18 +13,23 @@ import org.springframework.web.reactive.function.server.RouterFunctions; import org.springframework.web.reactive.function.server.ServerResponse; import org.springframework.web.server.WebHandler; -import com.baeldung.reactive.Spring5ReactiveApplication; +import com.baeldung.web.reactive.client.WebClientApplication; +import com.baeldung.web.reactive.client.WebClientController; import reactor.core.publisher.Mono; -@RunWith(SpringRunner.class) -@SpringBootTest(classes = Spring5ReactiveApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@WithMockUser +@SpringBootTest(classes = WebClientApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class WebTestClientIntegrationTest { @LocalServerPort private int port; + @Autowired + private ApplicationContext context; + + @Autowired + private WebClientController controller; + private final RouterFunction ROUTER_FUNCTION = RouterFunctions.route(RequestPredicates.GET("/resource"), request -> ServerResponse.ok() .build()); private final WebHandler WEB_HANDLER = exchange -> Mono.empty(); @@ -49,6 +54,7 @@ public class WebTestClientIntegrationTest { } @Test + @WithMockUser public void testWebTestClientWithServerURL() { WebTestClient.bindToServer() .baseUrl("http://localhost:" + port) @@ -58,7 +64,39 @@ public class WebTestClientIntegrationTest { .exchange() .expectStatus() .isOk() - .expectBody(); + .expectBody() + .jsonPath("field") + .isEqualTo("value"); + ; + } + + @Test + @WithMockUser + public void testWebTestClientWithApplicationContext() { + WebTestClient.bindToApplicationContext(context) + .build() + .get() + .uri("/resource") + .exchange() + .expectStatus() + .isOk() + .expectBody() + .jsonPath("field") + .isEqualTo("value"); + } + + @Test + public void testWebTestClientWithController() { + WebTestClient.bindToController(controller) + .build() + .get() + .uri("/resource") + .exchange() + .expectStatus() + .isOk() + .expectBody() + .jsonPath("field") + .isEqualTo("value"); } } From 30f0c13ef637377122af55df319774d31c66ce53 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Fri, 22 Jan 2021 12:48:34 -0300 Subject: [PATCH 288/361] added context test for new WebClientApplication --- .../com/baeldung/web/client/SpringContextTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 spring-5-reactive/src/test/java/com/baeldung/web/client/SpringContextTest.java diff --git a/spring-5-reactive/src/test/java/com/baeldung/web/client/SpringContextTest.java b/spring-5-reactive/src/test/java/com/baeldung/web/client/SpringContextTest.java new file mode 100644 index 0000000000..8d2ca41451 --- /dev/null +++ b/spring-5-reactive/src/test/java/com/baeldung/web/client/SpringContextTest.java @@ -0,0 +1,14 @@ +package com.baeldung.web.client; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +import com.baeldung.web.reactive.client.WebClientApplication; + +@SpringBootTest(classes = WebClientApplication.class) +public class SpringContextTest { + + @Test + public void whenSpringContextIsBootstrapped_thenNoExceptions() { + } +} From 0c5441380750ef523d88d39469af1102d4e2d711 Mon Sep 17 00:00:00 2001 From: "Kent@lhind.hp.g5" Date: Fri, 22 Jan 2021 19:56:18 +0100 Subject: [PATCH 289/361] BAEL-2517 --- .../core-java-lang-oop-generics/pom.xml | 28 ++++++++++++ .../UncheckedConversion.java | 45 +++++++++++++++++++ .../UncheckedConversionUnitTest.java | 39 ++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/uncheckedconversion/UncheckedConversion.java create mode 100644 core-java-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/uncheckedconversion/UncheckedConversionUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-generics/pom.xml b/core-java-modules/core-java-lang-oop-generics/pom.xml index 65a0aeac59..1a538edac9 100644 --- a/core-java-modules/core-java-lang-oop-generics/pom.xml +++ b/core-java-modules/core-java-lang-oop-generics/pom.xml @@ -13,4 +13,32 @@ core-java-lang-oop-generics jar + + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + + + + 1.8 + 1.8 + + \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/uncheckedconversion/UncheckedConversion.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/uncheckedconversion/UncheckedConversion.java new file mode 100644 index 0000000000..9ad4a92077 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/uncheckedconversion/UncheckedConversion.java @@ -0,0 +1,45 @@ +package com.baeldung.uncheckedconversion; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; + +public class UncheckedConversion { + public static List getRawList() { + List result = new ArrayList(); + result.add("I am the 1st String."); + result.add("I am the 2nd String."); + result.add("I am the 3rd String."); + return result; + } + + public static List getRawListWithMixedTypes() { + List result = new ArrayList(); + result.add("I am the 1st String."); + result.add("I am the 2nd String."); + result.add("I am the 3rd String."); + result.add(new Date()); + return result; + } + + public static List castList(Class clazz, Collection rawCollection) { + List result = new ArrayList<>(rawCollection.size()); + for (Object o : rawCollection) { + try { + result.add(clazz.cast(o)); + } catch (ClassCastException e) { + // log the exception or other error handling + } + } + return result; + } + + public static List castList2(Class clazz, Collection rawCollection) throws ClassCastException { + List result = new ArrayList<>(rawCollection.size()); + for (Object o : rawCollection) { + result.add(clazz.cast(o)); + } + return result; + } +} diff --git a/core-java-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/uncheckedconversion/UncheckedConversionUnitTest.java b/core-java-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/uncheckedconversion/UncheckedConversionUnitTest.java new file mode 100644 index 0000000000..37b9a878d3 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/uncheckedconversion/UncheckedConversionUnitTest.java @@ -0,0 +1,39 @@ +package com.baeldung.uncheckedconversion; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.List; + +public class UncheckedConversionUnitTest { + + @Test + public void givenRawList_whenAssignToTypedList_shouldHaveCompilerWarning() { + List fromRawList = UncheckedConversion.getRawList(); + Assert.assertEquals(3, fromRawList.size()); + Assert.assertEquals("I am the 1st String.", fromRawList.get(0)); + } + + @Test(expected = ClassCastException.class) + public void givenRawList_whenListHasMixedType_shouldThrowClassCastException() { + List fromRawList = UncheckedConversion.getRawListWithMixedTypes(); + Assert.assertEquals(4, fromRawList.size()); + Assert.assertFalse(fromRawList.get(3).endsWith("String.")); + } + + @Test + public void givenRawList_whenAssignToTypedListAfterCallingCastList_shouldOnlyHaveElementsWithExpectedType() { + List rawList = UncheckedConversion.getRawListWithMixedTypes(); + List strList = UncheckedConversion.castList(String.class, rawList); + Assert.assertEquals(4, rawList.size()); + Assert.assertEquals("One element with the wrong type has been filtered out.", 3, strList.size()); + Assert.assertTrue(strList.stream().allMatch(el -> el.endsWith("String."))); + } + + @Test(expected = ClassCastException.class) + public void givenRawListWithWrongType_whenAssignToTypedListAfterCallingCastList2_shouldThrowException() { + List rawList = UncheckedConversion.getRawListWithMixedTypes(); + UncheckedConversion.castList2(String.class, rawList); + } + +} From 9144660a72defa218e1d0fbc64c98a592c323b28 Mon Sep 17 00:00:00 2001 From: Jonathan Cook Date: Sat, 23 Jan 2021 07:08:50 +0100 Subject: [PATCH 290/361] BAEL-4756 - Mockito MockSettings - fix spelling (#10438) * 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 * BAEL-4756 - Mockito MockSettings * BAEL-4756 - Mockito MockSettings - fix spelling Co-authored-by: Jonathan Cook --- .../baeldung/mockito/mocksettings/MockSettingsUnitTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/mocksettings/MockSettingsUnitTest.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/mocksettings/MockSettingsUnitTest.java index 596baf1954..907abc3d76 100644 --- a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/mocksettings/MockSettingsUnitTest.java +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/mocksettings/MockSettingsUnitTest.java @@ -47,10 +47,10 @@ public class MockSettingsUnitTest { @Test public void whenMockSetupWithConstructor_thenConstructorIsInvoked() { - AbstractCoffee coffeeSpy = mock(AbstractCoffee.class, withSettings().useConstructor("expresso") + AbstractCoffee coffeeSpy = mock(AbstractCoffee.class, withSettings().useConstructor("espresso") .defaultAnswer(CALLS_REAL_METHODS)); - assertEquals("Coffee name: ", "expresso", coffeeSpy.getName()); + assertEquals("Coffee name: ", "espresso", coffeeSpy.getName()); } } From 70a0e0de969efdcb8da019e01a1ca122b47cb6e1 Mon Sep 17 00:00:00 2001 From: Trixi Turny Date: Sat, 23 Jan 2021 11:19:30 +0000 Subject: [PATCH 291/361] BAEL-4748 change user to reader and address to favouriteBooks --- .../webclient/json/ReaderConsumerService.java | 16 ++++ .../json/ReaderConsumerServiceImpl.java | 90 +++++++++++++++++++ .../webclient/json/UserConsumerService.java | 16 ---- .../json/UserConsumerServiceImpl.java | 90 ------------------- .../webclient/json/model/Address.java | 29 ------ .../baeldung/webclient/json/model/Book.java | 22 +++++ .../baeldung/webclient/json/model/Reader.java | 0 .../baeldung/webclient/json/model/User.java | 30 ------- .../ReaderConsumerServiceImplUnitTest.java | 77 ++++++++++++++++ .../json/UserConsumerServiceImplUnitTest.java | 74 --------------- 10 files changed, 205 insertions(+), 239 deletions(-) create mode 100644 spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerService.java create mode 100644 spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerServiceImpl.java delete mode 100644 spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/UserConsumerService.java delete mode 100644 spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/UserConsumerServiceImpl.java delete mode 100644 spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Address.java create mode 100644 spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Book.java create mode 100644 spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Reader.java delete mode 100644 spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/User.java create mode 100644 spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/ReaderConsumerServiceImplUnitTest.java delete mode 100644 spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/UserConsumerServiceImplUnitTest.java diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerService.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerService.java new file mode 100644 index 0000000000..b0bc71d2ed --- /dev/null +++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerService.java @@ -0,0 +1,16 @@ +package com.baeldung.webclient.json; + +import java.util.List; + +public interface ReaderConsumerService { + + List processReaderDataFromObjectArray(); + + List processReaderDataFromReaderArray(); + + List processReaderDataFromReaderList(); + + List processNestedReaderDataFromReaderArray(); + + List processNestedReaderDataFromReaderList(); +} diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerServiceImpl.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerServiceImpl.java new file mode 100644 index 0000000000..d1800a7f65 --- /dev/null +++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerServiceImpl.java @@ -0,0 +1,90 @@ +package com.baeldung.webclient.json; + +import com.baeldung.webclient.json.model.Book; +import com.baeldung.webclient.json.model.Reader; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.client.WebClient; +import reactor.core.publisher.Mono; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class ReaderConsumerServiceImpl implements ReaderConsumerService { + + private final WebClient webClient; + private static final ObjectMapper mapper = new ObjectMapper(); + + public ReaderConsumerServiceImpl(WebClient webClient) { + this.webClient = webClient; + } + @Override + public List processReaderDataFromObjectArray() { + Mono response = webClient.get() + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(Object[].class).log(); + Object[] objects = response.block(); + return Arrays.stream(objects) + .map(object -> mapper.convertValue(object, Reader.class)) + .map(Reader::getName) + .collect(Collectors.toList()); + } + + @Override + public List processReaderDataFromReaderArray() { + Mono response = + webClient.get() + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(Reader[].class).log(); + + Reader[] readers = response.block(); + return Arrays.stream(readers) + .map(Reader::getName) + .collect(Collectors.toList()); + } + + @Override + public List processReaderDataFromReaderList() { + Mono> response = webClient.get() + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(new ParameterizedTypeReference>() {}); + List readers = response.block(); + + return readers.stream() + .map(Reader::getName) + .collect(Collectors.toList()); + } + + @Override + public List processNestedReaderDataFromReaderArray() { + Mono response = webClient.get() + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(Reader[].class).log(); + Reader[] readers = response.block(); + + return Arrays.stream(readers) + .flatMap(reader -> reader.getFavouriteBooks().stream()) + .map(Book::getAuthor) + .collect(Collectors.toList()); + } + + @Override + public List processNestedReaderDataFromReaderList() { + Mono> response = webClient.get() + .accept(MediaType.APPLICATION_JSON) + .retrieve() + .bodyToMono(new ParameterizedTypeReference>() {}); + + List readers = response.block(); + return readers.stream() + .flatMap(reader -> reader.getFavouriteBooks().stream()) + .map(Book::getAuthor) + .collect(Collectors.toList()); + } +} \ No newline at end of file diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/UserConsumerService.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/UserConsumerService.java deleted file mode 100644 index 9afc207ff2..0000000000 --- a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/UserConsumerService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.webclient.json; - -import java.util.List; - -public interface UserConsumerService { - - List processUserDataFromObjectArray(); - - List processUserDataFromUserArray(); - - List processUserDataFromUserList(); - - List processNestedUserDataFromUserArray(); - - List processNestedUserDataFromUserList(); -} diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/UserConsumerServiceImpl.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/UserConsumerServiceImpl.java deleted file mode 100644 index 30cd4a5617..0000000000 --- a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/UserConsumerServiceImpl.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.baeldung.webclient.json; - -import com.baeldung.webclient.json.model.Address; -import com.baeldung.webclient.json.model.User; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Mono; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -public class UserConsumerServiceImpl implements UserConsumerService { - - private final WebClient webClient; - private static final ObjectMapper mapper = new ObjectMapper(); - - public UserConsumerServiceImpl(WebClient webClient) { - this.webClient = webClient; - } - @Override - public List processUserDataFromObjectArray() { - Mono response = webClient.get() - .accept(MediaType.APPLICATION_JSON) - .retrieve() - .bodyToMono(Object[].class).log(); - Object[] objects = response.block(); - return Arrays.stream(objects) - .map(object -> mapper.convertValue(object, User.class)) - .map(User::getName) - .collect(Collectors.toList()); - } - - @Override - public List processUserDataFromUserArray() { - Mono response = - webClient.get() - .accept(MediaType.APPLICATION_JSON) - .retrieve() - .bodyToMono(User[].class).log(); - - User[] userArray = response.block(); - return Arrays.stream(userArray) - .map(User::getName) - .collect(Collectors.toList()); - } - - @Override - public List processUserDataFromUserList() { - Mono> response = webClient.get() - .accept(MediaType.APPLICATION_JSON) - .retrieve() - .bodyToMono(new ParameterizedTypeReference>() {}); - List userList = response.block(); - - return userList.stream() - .map(User::getName) - .collect(Collectors.toList()); - } - - @Override - public List processNestedUserDataFromUserArray() { - Mono response = webClient.get() - .accept(MediaType.APPLICATION_JSON) - .retrieve() - .bodyToMono(User[].class).log(); - User[] userArray = response.block(); - - return Arrays.stream(userArray) - .flatMap(user -> user.getAddressList().stream()) - .map(Address::getPostCode) - .collect(Collectors.toList()); - } - - @Override - public List processNestedUserDataFromUserList() { - Mono> response = webClient.get() - .accept(MediaType.APPLICATION_JSON) - .retrieve() - .bodyToMono(new ParameterizedTypeReference>() {}); - - List userList = response.block(); - return userList.stream() - .flatMap(user -> user.getAddressList().stream()) - .map(Address::getPostCode) - .collect(Collectors.toList()); - } -} \ No newline at end of file diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Address.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Address.java deleted file mode 100644 index cc4323b72b..0000000000 --- a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Address.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.webclient.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-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Book.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Book.java new file mode 100644 index 0000000000..cb3fb258d4 --- /dev/null +++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Book.java @@ -0,0 +1,22 @@ +package com.baeldung.webclient.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 Book { + private final String author; + private final String title; + + @JsonCreator + public Book( + @JsonProperty("author") String author, + @JsonProperty("title") String title) { + this.author = author; + this.title = title; + } + public String getAuthor() { + return this.author; + } +} diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Reader.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Reader.java new file mode 100644 index 0000000000..e69de29bb2 diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/User.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/User.java deleted file mode 100644 index 6ed359f9db..0000000000 --- a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/User.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.baeldung.webclient.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-5-reactive-client/src/test/java/com/baeldung/webclient/json/ReaderConsumerServiceImplUnitTest.java b/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/ReaderConsumerServiceImplUnitTest.java new file mode 100644 index 0000000000..92f7bf4f3f --- /dev/null +++ b/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/ReaderConsumerServiceImplUnitTest.java @@ -0,0 +1,77 @@ +package com.baeldung.webclient.json; + +import org.junit.jupiter.api.Test; +import org.springframework.http.HttpStatus; +import org.springframework.web.reactive.function.client.ClientResponse; +import org.springframework.web.reactive.function.client.WebClient; +import reactor.core.publisher.Mono; + +import java.util.Arrays; +import java.util.List; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; + +public class ReaderConsumerServiceImplUnitTest { + + private static String READER_JSON = "[{\"id\":1,\"name\":\"reader1\",\"favouriteBooks\":[{\"author\":\"Milan Kundera\",\"title\":\"The Unbearable Lightness of Being\"}," + + "{\"author\":\"Charles Dickens\",\"title\":\"Oliver Twist\"}]}," + + "{\"id\":2,\"name\":\"reader2\",\"favouriteBooks\":[{\"author\":\"J.R.R. Tolkien\",\"title\":\"Lord of the Rings\"}, " + + "{\"author\":\"Douglas Adams\",\"title\":\"The Hitchhiker\'s Guide to the Galaxy\"}]}]"; + + private static String BASE_URL = "http://localhost:8080"; + + WebClient webClientMock = WebClient.builder() + .exchangeFunction(clientRequest -> Mono.just(ClientResponse.create(HttpStatus.OK) + .header("content-type", "application/json") + .body(READER_JSON) + .build())) + .build(); + + private final ReaderConsumerService tested = new ReaderConsumerServiceImpl(webClientMock); + + @Test + void when_processReaderDataFromObjectArray_then_OK() { + List expected = Arrays.asList("reader1", "reader2"); + List actual = tested.processReaderDataFromObjectArray(); + assertThat(actual, contains(expected.get(0), expected.get(1))); + } + + @Test + void when_processReaderDataFromReaderArray_then_OK() { + List expected = Arrays.asList("reader1", "reader2"); + List actual = tested.processReaderDataFromReaderArray(); + assertThat(actual, contains(expected.get(0), expected.get(1))); + } + + @Test + void when_processReaderDataFromReaderList_then_OK() { + List expected = Arrays.asList("reader1", "reader2"); + List actual = tested.processReaderDataFromReaderList(); + assertThat(actual, contains(expected.get(0), expected.get(1))); + } + + @Test + void when_processNestedReaderDataFromReaderArray_then_OK() { + List expected = Arrays.asList( + "Milan Kundera", + "Charles Dickens", + "J.R.R. Tolkien", + "Douglas Adams"); + + List actual = tested.processNestedReaderDataFromReaderArray(); + assertThat(actual, contains(expected.get(0), expected.get(1), expected.get(2), expected.get(3))); + } + + @Test + void when_processNestedReaderDataFromReaderList_then_OK() { + List expected = Arrays.asList( + "Milan Kundera", + "Charles Dickens", + "J.R.R. Tolkien", + "Douglas Adams"); + + List actual = tested.processNestedReaderDataFromReaderList(); + assertThat(actual, contains(expected.get(0), expected.get(1), expected.get(2), expected.get(3))); + } +} \ No newline at end of file diff --git a/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/UserConsumerServiceImplUnitTest.java b/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/UserConsumerServiceImplUnitTest.java deleted file mode 100644 index 151554efde..0000000000 --- a/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/UserConsumerServiceImplUnitTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.baeldung.webclient.json; - -import org.junit.jupiter.api.Test; -import org.springframework.http.HttpStatus; -import org.springframework.web.reactive.function.client.ClientResponse; -import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Mono; - -import java.util.Arrays; -import java.util.List; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; - -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 static String BASE_URL = "http://localhost:8080"; - - WebClient webClientMock = WebClient.builder() - .exchangeFunction(clientRequest -> Mono.just(ClientResponse.create(HttpStatus.OK) - .header("content-type", "application/json") - .body(USER_JSON) - .build())) - .build(); - - private final UserConsumerService tested = new UserConsumerServiceImpl(webClientMock); - - @Test - void when_processUserDataFromObjectArray_then_OK() { - List expected = Arrays.asList("user1", "user2"); - List actual = tested.processUserDataFromObjectArray(); - assertThat(actual, contains(expected.get(0), expected.get(1))); - } - - @Test - void when_processUserDataFromUserArray_then_OK() { - List expected = Arrays.asList("user1", "user2"); - List actual = tested.processUserDataFromUserArray(); - assertThat(actual, contains(expected.get(0), expected.get(1))); - } - - @Test - void when_processUserDataFromUserList_then_OK() { - List expected = Arrays.asList("user1", "user2"); - List actual = tested.processUserDataFromUserList(); - assertThat(actual, contains(expected.get(0), expected.get(1))); - } - - @Test - void when_processNestedUserDataFromUserArray_then_OK() { - List expected = Arrays.asList( - "user1_address1_postCode", - "user1_address2_postCode", - "user2_address1_postCode"); - - List actual = tested.processNestedUserDataFromUserArray(); - assertThat(actual, contains(expected.get(0), expected.get(1), expected.get(2))); - } - - @Test - void when_processNestedUserDataFromUserList_then_OK() { - List expected = Arrays.asList( - "user1_address1_postCode", - "user1_address2_postCode", - "user2_address1_postCode"); - - List actual = tested.processNestedUserDataFromUserList(); - assertThat(actual, contains(expected.get(0), expected.get(1), expected.get(2))); - } -} \ No newline at end of file From a0425afd1b8710216221e0c16ba4a473f1cac373 Mon Sep 17 00:00:00 2001 From: Trixi Turny Date: Sat, 23 Jan 2021 11:25:11 +0000 Subject: [PATCH 292/361] MASH-4748 fix Reader object and url with WebClient --- .../baeldung/webclient/json/model/Reader.java | 30 +++++++++++++++++++ .../ReaderConsumerServiceImplUnitTest.java | 4 +-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Reader.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Reader.java index e69de29bb2..9fc480c3df 100644 --- a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Reader.java +++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Reader.java @@ -0,0 +1,30 @@ +package com.baeldung.webclient.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 Reader { + private final int id; + private final String name; + private final List favouriteBooks; + + @JsonCreator + public Reader( + @JsonProperty("id") int id, + @JsonProperty("name") String name, + @JsonProperty("favouriteBooks") List favoriteBooks) { + this.id = id; + this.name = name; + this.favouriteBooks = favoriteBooks; + } + + public String getName() { + return name; + } + + public List getFavouriteBooks() { return favouriteBooks; } +} diff --git a/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/ReaderConsumerServiceImplUnitTest.java b/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/ReaderConsumerServiceImplUnitTest.java index 92f7bf4f3f..065f1dc11a 100644 --- a/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/ReaderConsumerServiceImplUnitTest.java +++ b/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/ReaderConsumerServiceImplUnitTest.java @@ -19,9 +19,9 @@ public class ReaderConsumerServiceImplUnitTest { "{\"id\":2,\"name\":\"reader2\",\"favouriteBooks\":[{\"author\":\"J.R.R. Tolkien\",\"title\":\"Lord of the Rings\"}, " + "{\"author\":\"Douglas Adams\",\"title\":\"The Hitchhiker\'s Guide to the Galaxy\"}]}]"; - private static String BASE_URL = "http://localhost:8080"; + private static String BASE_URL = "http://localhost:8080/readers"; - WebClient webClientMock = WebClient.builder() + WebClient webClientMock = WebClient.builder().baseUrl(BASE_URL) .exchangeFunction(clientRequest -> Mono.just(ClientResponse.create(HttpStatus.OK) .header("content-type", "application/json") .body(READER_JSON) From c3741487d89705dc28eac515330d9e4adb301c1f Mon Sep 17 00:00:00 2001 From: Trixi Turny Date: Sat, 23 Jan 2021 12:56:18 +0000 Subject: [PATCH 293/361] BAEL-4748 update examples with favouriteBook --- .../webclient/json/ReaderConsumerService.java | 8 ++-- .../json/ReaderConsumerServiceImpl.java | 16 ++++---- .../baeldung/webclient/json/model/Reader.java | 15 ++++--- .../ReaderConsumerServiceImplUnitTest.java | 41 ++++++++++++------- 4 files changed, 48 insertions(+), 32 deletions(-) diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerService.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerService.java index b0bc71d2ed..17676b3f33 100644 --- a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerService.java +++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerService.java @@ -1,14 +1,16 @@ package com.baeldung.webclient.json; +import com.baeldung.webclient.json.model.Book; + import java.util.List; public interface ReaderConsumerService { - List processReaderDataFromObjectArray(); + List processReaderDataFromObjectArray(); - List processReaderDataFromReaderArray(); + List processReaderDataFromReaderArray(); - List processReaderDataFromReaderList(); + List processReaderDataFromReaderList(); List processNestedReaderDataFromReaderArray(); diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerServiceImpl.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerServiceImpl.java index d1800a7f65..8f1a4c019a 100644 --- a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerServiceImpl.java +++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerServiceImpl.java @@ -21,7 +21,7 @@ public class ReaderConsumerServiceImpl implements ReaderConsumerService { this.webClient = webClient; } @Override - public List processReaderDataFromObjectArray() { + public List processReaderDataFromObjectArray() { Mono response = webClient.get() .accept(MediaType.APPLICATION_JSON) .retrieve() @@ -29,12 +29,12 @@ public class ReaderConsumerServiceImpl implements ReaderConsumerService { Object[] objects = response.block(); return Arrays.stream(objects) .map(object -> mapper.convertValue(object, Reader.class)) - .map(Reader::getName) + .map(Reader::getFavouriteBook) .collect(Collectors.toList()); } @Override - public List processReaderDataFromReaderArray() { + public List processReaderDataFromReaderArray() { Mono response = webClient.get() .accept(MediaType.APPLICATION_JSON) @@ -43,12 +43,12 @@ public class ReaderConsumerServiceImpl implements ReaderConsumerService { Reader[] readers = response.block(); return Arrays.stream(readers) - .map(Reader::getName) + .map(Reader::getFavouriteBook) .collect(Collectors.toList()); } @Override - public List processReaderDataFromReaderList() { + public List processReaderDataFromReaderList() { Mono> response = webClient.get() .accept(MediaType.APPLICATION_JSON) .retrieve() @@ -56,7 +56,7 @@ public class ReaderConsumerServiceImpl implements ReaderConsumerService { List readers = response.block(); return readers.stream() - .map(Reader::getName) + .map(Reader::getFavouriteBook) .collect(Collectors.toList()); } @@ -69,7 +69,7 @@ public class ReaderConsumerServiceImpl implements ReaderConsumerService { Reader[] readers = response.block(); return Arrays.stream(readers) - .flatMap(reader -> reader.getFavouriteBooks().stream()) + .flatMap(reader -> reader.getBooksRead().stream()) .map(Book::getAuthor) .collect(Collectors.toList()); } @@ -83,7 +83,7 @@ public class ReaderConsumerServiceImpl implements ReaderConsumerService { List readers = response.block(); return readers.stream() - .flatMap(reader -> reader.getFavouriteBooks().stream()) + .flatMap(reader -> reader.getBooksRead().stream()) .map(Book::getAuthor) .collect(Collectors.toList()); } diff --git a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Reader.java b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Reader.java index 9fc480c3df..7d02853ea1 100644 --- a/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Reader.java +++ b/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Reader.java @@ -10,21 +10,24 @@ import java.util.List; public class Reader { private final int id; private final String name; - private final List favouriteBooks; + private final Book favouriteBook; + private final List booksRead; @JsonCreator public Reader( @JsonProperty("id") int id, @JsonProperty("name") String name, - @JsonProperty("favouriteBooks") List favoriteBooks) { + @JsonProperty("favouriteBook") Book favouriteBook, + @JsonProperty("booksRead") List booksRead) { this.id = id; this.name = name; - this.favouriteBooks = favoriteBooks; + this.favouriteBook = favouriteBook; + this.booksRead =booksRead; } - public String getName() { - return name; + public Book getFavouriteBook() { + return favouriteBook; } - public List getFavouriteBooks() { return favouriteBooks; } + public List getBooksRead() { return booksRead; } } diff --git a/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/ReaderConsumerServiceImplUnitTest.java b/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/ReaderConsumerServiceImplUnitTest.java index 065f1dc11a..51f0a5c1bb 100644 --- a/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/ReaderConsumerServiceImplUnitTest.java +++ b/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/ReaderConsumerServiceImplUnitTest.java @@ -1,5 +1,6 @@ package com.baeldung.webclient.json; +import com.baeldung.webclient.json.model.Book; import org.junit.jupiter.api.Test; import org.springframework.http.HttpStatus; import org.springframework.web.reactive.function.client.ClientResponse; @@ -10,13 +11,16 @@ import java.util.Arrays; import java.util.List; import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; +import static org.hamcrest.CoreMatchers.hasItems; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.hasProperty; public class ReaderConsumerServiceImplUnitTest { - private static String READER_JSON = "[{\"id\":1,\"name\":\"reader1\",\"favouriteBooks\":[{\"author\":\"Milan Kundera\",\"title\":\"The Unbearable Lightness of Being\"}," + - "{\"author\":\"Charles Dickens\",\"title\":\"Oliver Twist\"}]}," + - "{\"id\":2,\"name\":\"reader2\",\"favouriteBooks\":[{\"author\":\"J.R.R. Tolkien\",\"title\":\"Lord of the Rings\"}, " + + private static String READER_JSON = "[{\"id\":1,\"name\":\"reader1\",\"favouriteBook\":{\"author\":\"Milan Kundera\",\"title\":\"The Unbearable Lightness of Being\"}," + + "\"booksRead\":[{\"author\":\"Charles Dickens\",\"title\":\"Oliver Twist\"},{\"author\":\"Milan Kundera\",\"title\":\"The Unbearable Lightness of Being\"}]}," + + "{\"id\":2,\"name\":\"reader2\",\"favouriteBook\":{\"author\":\"Douglas Adams\",\"title\":\"The Hitchhiker\'s Guide to the Galaxy\"}," + + "\"booksRead\":[{\"author\":\"J.R.R. Tolkien\",\"title\":\"Lord of the Rings\"}, " + "{\"author\":\"Douglas Adams\",\"title\":\"The Hitchhiker\'s Guide to the Galaxy\"}]}]"; private static String BASE_URL = "http://localhost:8080/readers"; @@ -32,23 +36,30 @@ public class ReaderConsumerServiceImplUnitTest { @Test void when_processReaderDataFromObjectArray_then_OK() { - List expected = Arrays.asList("reader1", "reader2"); - List actual = tested.processReaderDataFromObjectArray(); - assertThat(actual, contains(expected.get(0), expected.get(1))); + String expectedAuthor1 = "Milan Kundera"; + String expectedAuthor2 = "Douglas Adams"; + List actual = tested.processReaderDataFromObjectArray(); + assertThat(actual, hasItems(hasProperty("author", is(expectedAuthor1)), + hasProperty("author", is(expectedAuthor2)))); } @Test void when_processReaderDataFromReaderArray_then_OK() { - List expected = Arrays.asList("reader1", "reader2"); - List actual = tested.processReaderDataFromReaderArray(); - assertThat(actual, contains(expected.get(0), expected.get(1))); + String expectedAuthor1 = "Milan Kundera"; + String expectedAuthor2 = "Douglas Adams"; + List actual = tested.processReaderDataFromReaderArray(); + assertThat(actual, hasItems(hasProperty("author", is(expectedAuthor1)), + hasProperty("author", is(expectedAuthor2)))); } @Test void when_processReaderDataFromReaderList_then_OK() { - List expected = Arrays.asList("reader1", "reader2"); - List actual = tested.processReaderDataFromReaderList(); - assertThat(actual, contains(expected.get(0), expected.get(1))); + String expectedAuthor1 = "Milan Kundera"; + String expectedAuthor2 = "Douglas Adams"; + List actual = tested.processReaderDataFromReaderList(); + assertThat(actual, hasItems(hasProperty("author", is(expectedAuthor1)), + hasProperty("author", is(expectedAuthor2)))); + } @Test @@ -60,7 +71,7 @@ public class ReaderConsumerServiceImplUnitTest { "Douglas Adams"); List actual = tested.processNestedReaderDataFromReaderArray(); - assertThat(actual, contains(expected.get(0), expected.get(1), expected.get(2), expected.get(3))); + assertThat(actual, hasItems(expected.get(0), expected.get(1), expected.get(2), expected.get(3))); } @Test @@ -72,6 +83,6 @@ public class ReaderConsumerServiceImplUnitTest { "Douglas Adams"); List actual = tested.processNestedReaderDataFromReaderList(); - assertThat(actual, contains(expected.get(0), expected.get(1), expected.get(2), expected.get(3))); + assertThat(actual, hasItems(expected.get(0), expected.get(1), expected.get(2), expected.get(3))); } } \ No newline at end of file From 0de9172dc6035454d7b923d5cf40aef327544e83 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Sat, 23 Jan 2021 11:36:58 -0300 Subject: [PATCH 294/361] Moved spring-5-webclient example code to new test class, to verify everything is working as expected --- .../reactive/client/WebClientController.java | 95 --------------- .../web/client/WebClientIntegrationTest.java | 110 ++++++++++++++++++ 2 files changed, 110 insertions(+), 95 deletions(-) create mode 100644 spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java index 2d42e848b2..765cd561d8 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java +++ b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java @@ -1,36 +1,12 @@ package com.baeldung.web.reactive.client; -import java.net.URI; -import java.nio.charset.Charset; -import java.time.ZonedDateTime; -import java.util.Collections; import java.util.HashMap; import java.util.Map; -import java.util.concurrent.TimeUnit; -import org.reactivestreams.Publisher; -import org.reactivestreams.Subscriber; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ReactiveHttpOutputMessage; -import org.springframework.http.client.reactive.ClientHttpRequest; -import org.springframework.http.client.reactive.ReactorClientHttpConnector; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.reactive.function.BodyInserter; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.client.WebClient; - -import io.netty.channel.ChannelOption; -import io.netty.handler.timeout.ReadTimeoutHandler; -import io.netty.handler.timeout.WriteTimeoutHandler; -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClient; @RestController public class WebClientController { @@ -42,75 +18,4 @@ public class WebClientController { response.put("field", "value"); return response; } - - public void demonstrateWebClient() { - // request - WebClient.UriSpec request1 = createWebClientWithServerURLAndDefaultValues().method(HttpMethod.POST); - WebClient.UriSpec request2 = createWebClientWithServerURLAndDefaultValues().post(); - - // request body specifications - WebClient.RequestBodySpec uri1 = createWebClientWithServerURLAndDefaultValues().method(HttpMethod.POST) - .uri("/resource"); - WebClient.RequestBodySpec uri2 = createWebClientWithServerURLAndDefaultValues().post() - .uri(URI.create("/resource")); - - // request header specification - WebClient.RequestHeadersSpec requestSpec1 = uri1.body(BodyInserters.fromPublisher(Mono.just("data"), String.class)); - WebClient.RequestHeadersSpec requestSpec2 = uri2.body(BodyInserters.fromValue("data")); - - // inserters - BodyInserter, ReactiveHttpOutputMessage> inserter1 = BodyInserters.fromPublisher(Subscriber::onComplete, String.class); - - LinkedMultiValueMap map = new LinkedMultiValueMap<>(); - map.add("key1", "value1"); - map.add("key2", "value2"); - - BodyInserter, ClientHttpRequest> inserter2 = BodyInserters.fromMultipartData(map); - BodyInserter inserter3 = BodyInserters.fromValue(new Object()); - BodyInserter inserter4 = BodyInserters.fromValue("body"); - - // responses - WebClient.ResponseSpec response1 = uri1.body(inserter3) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) - .accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML) - .acceptCharset(Charset.forName("UTF-8")) - .ifNoneMatch("*") - .ifModifiedSince(ZonedDateTime.now()) - .retrieve(); - String response2 = uri1.exchangeToMono(response -> response.bodyToMono(String.class)) - .block(); - String response3 = uri2.retrieve() - .bodyToMono(String.class) - .block(); - WebClient.ResponseSpec response4 = requestSpec2.retrieve(); - } - - private WebClient createWebClient() { - return WebClient.create(); - } - - private WebClient createWebClientWithServerURL() { - return WebClient.create("http://localhost:8081"); - } - - private WebClient createWebClientConfiguringTimeout() { - HttpClient httpClient = HttpClient.create() - .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000) - .doOnConnected(conn -> conn.addHandlerLast(new ReadTimeoutHandler(5000, TimeUnit.MILLISECONDS)) - .addHandlerLast(new WriteTimeoutHandler(5000, TimeUnit.MILLISECONDS))); - - return WebClient.builder() - .clientConnector(new ReactorClientHttpConnector(httpClient)) - .build(); - } - - private WebClient createWebClientWithServerURLAndDefaultValues() { - return WebClient.builder() - .baseUrl("http://localhost:8081") - .defaultCookie("cookieKey", "cookieValue") - .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) - .defaultUriVariables(Collections.singletonMap("url", "http://localhost:8080")) - .build(); - } - } diff --git a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java new file mode 100644 index 0000000000..df873c618d --- /dev/null +++ b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java @@ -0,0 +1,110 @@ +package com.baeldung.web.client; + +import java.net.URI; +import java.nio.charset.Charset; +import java.time.ZonedDateTime; +import java.util.Collections; +import java.util.concurrent.TimeUnit; + +import org.junit.jupiter.api.Test; +import org.reactivestreams.Publisher; +import org.reactivestreams.Subscriber; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ReactiveHttpOutputMessage; +import org.springframework.http.client.reactive.ClientHttpRequest; +import org.springframework.http.client.reactive.ReactorClientHttpConnector; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.reactive.function.BodyInserter; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.client.WebClient; + +import com.baeldung.web.reactive.client.WebClientApplication; + +import io.netty.channel.ChannelOption; +import io.netty.handler.timeout.ReadTimeoutHandler; +import io.netty.handler.timeout.WriteTimeoutHandler; +import reactor.core.publisher.Mono; +import reactor.netty.http.client.HttpClient; + +@SpringBootTest(classes = WebClientApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class WebClientIntegrationTest { + + @LocalServerPort + private int port; + + @Test + public void demonstrateWebClient() { + // request + WebClient.UriSpec request1 = createWebClientWithServerURLAndDefaultValues().method(HttpMethod.POST); + WebClient.UriSpec request2 = createWebClientWithServerURLAndDefaultValues().post(); + + // request body specifications + WebClient.RequestBodySpec uri1 = createWebClientWithServerURLAndDefaultValues().method(HttpMethod.POST) + .uri("/resource"); + WebClient.RequestBodySpec uri2 = createWebClientWithServerURLAndDefaultValues().post() + .uri(URI.create("/resource")); + + // request header specification + WebClient.RequestHeadersSpec requestSpec1 = uri1.body(BodyInserters.fromPublisher(Mono.just("data"), String.class)); + WebClient.RequestHeadersSpec requestSpec2 = uri2.body(BodyInserters.fromValue("data")); + + // inserters + BodyInserter, ReactiveHttpOutputMessage> inserter1 = BodyInserters.fromPublisher(Subscriber::onComplete, String.class); + + LinkedMultiValueMap map = new LinkedMultiValueMap<>(); + map.add("key1", "value1"); + map.add("key2", "value2"); + + BodyInserter, ClientHttpRequest> inserter2 = BodyInserters.fromMultipartData(map); + BodyInserter inserter3 = BodyInserters.fromValue(new Object()); + BodyInserter inserter4 = BodyInserters.fromValue("body"); + + // responses + WebClient.ResponseSpec response1 = uri1.body(inserter3) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML) + .acceptCharset(Charset.forName("UTF-8")) + .ifNoneMatch("*") + .ifModifiedSince(ZonedDateTime.now()) + .retrieve(); + String response2 = uri1.exchangeToMono(response -> response.bodyToMono(String.class)) + .block(); + String response3 = uri2.retrieve() + .bodyToMono(String.class) + .block(); + WebClient.ResponseSpec response4 = requestSpec2.retrieve(); + } + + private WebClient createWebClient() { + return WebClient.create(); + } + + private WebClient createWebClientWithServerURL() { + return WebClient.create("http://localhost:8081"); + } + + private WebClient createWebClientConfiguringTimeout() { + HttpClient httpClient = HttpClient.create() + .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000) + .doOnConnected(conn -> conn.addHandlerLast(new ReadTimeoutHandler(5000, TimeUnit.MILLISECONDS)) + .addHandlerLast(new WriteTimeoutHandler(5000, TimeUnit.MILLISECONDS))); + + return WebClient.builder() + .clientConnector(new ReactorClientHttpConnector(httpClient)) + .build(); + } + + private WebClient createWebClientWithServerURLAndDefaultValues() { + return WebClient.builder() + .baseUrl("http://localhost:8081") + .defaultCookie("cookieKey", "cookieValue") + .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .defaultUriVariables(Collections.singletonMap("url", "http://localhost:8080")) + .build(); + } +} From 3e5a1f3e50c4d18ee4e7a7be34c8aa9821aa31c8 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Sat, 23 Jan 2021 12:40:28 -0300 Subject: [PATCH 295/361] added endpoints to test functionality properly --- .../web/reactive/client/WebClientController.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java index 765cd561d8..2dfcd7533b 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java +++ b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java @@ -4,7 +4,11 @@ import java.util.HashMap; import java.util.Map; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; @@ -18,4 +22,14 @@ public class WebClientController { response.put("field", "value"); return response; } + + @PostMapping("/resource") + public String postResource(@RequestBody String bodyString) { + return "processed-" + bodyString; + } + + @PostMapping(value = "/resource-multipart", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public String handleFormUpload(@RequestPart("key1") String value1, @RequestPart("key2") String value2) { + return "processed-" + value1 + value2; + } } From 725465b0b6e42202a5f66498773ced8b00ec5355 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Sat, 23 Jan 2021 12:41:13 -0300 Subject: [PATCH 296/361] disabled security for WebClient codebase application --- .../baeldung/web/reactive/client/WebClientApplication.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientApplication.java b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientApplication.java index f104ad30f1..aa9b81de4f 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientApplication.java +++ b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientApplication.java @@ -2,9 +2,10 @@ package com.baeldung.web.reactive.client; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration; -@SpringBootApplication -public class WebClientApplication{ +@SpringBootApplication(exclude = { ReactiveSecurityAutoConfiguration.class }) +public class WebClientApplication { public static void main(String[] args) { SpringApplication.run(WebClientApplication.class, args); From 268fe2dfe65da6315c59b1e84bcb7d88e357f3cd Mon Sep 17 00:00:00 2001 From: Daniel Strmecki Date: Sun, 24 Jan 2021 12:33:05 +0100 Subject: [PATCH 297/361] BASE-4535: Example for overriding compareTo --- .../com/baeldung/compareto/BankAccount.java | 16 ++++++++ .../baeldung/compareto/BankAccountFix.java | 16 ++++++++ .../baeldung/compareto/FootballPlayer.java | 28 +++++++++++++ .../baeldung/compareto/HandballPlayer.java | 12 ++++++ .../compareto/ArraysSortingUnitTest.java | 25 ++++++++++++ .../compareto/BankAccountFixUnitTest.java | 25 ++++++++++++ .../compareto/BankAccountUnitTest.java | 25 ++++++++++++ .../compareto/FootballPlayerUnitTest.java | 40 +++++++++++++++++++ .../compareto/HandballPlayerUnitTest.java | 26 ++++++++++++ 9 files changed, 213 insertions(+) create mode 100644 core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/BankAccount.java create mode 100644 core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/BankAccountFix.java create mode 100644 core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/FootballPlayer.java create mode 100644 core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/HandballPlayer.java create mode 100644 core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/ArraysSortingUnitTest.java create mode 100644 core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/BankAccountFixUnitTest.java create mode 100644 core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/BankAccountUnitTest.java create mode 100644 core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/FootballPlayerUnitTest.java create mode 100644 core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/HandballPlayerUnitTest.java diff --git a/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/BankAccount.java b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/BankAccount.java new file mode 100644 index 0000000000..db1f41e6df --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/BankAccount.java @@ -0,0 +1,16 @@ +package com.baeldung.compareto; + +public class BankAccount implements Comparable { + + private final int balance; + + public BankAccount(int balance) { + this.balance = balance; + } + + @Override + public int compareTo(BankAccount anotherAccount) { + return this.balance - anotherAccount.balance; + } + +} diff --git a/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/BankAccountFix.java b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/BankAccountFix.java new file mode 100644 index 0000000000..95e55fdf22 --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/BankAccountFix.java @@ -0,0 +1,16 @@ +package com.baeldung.compareto; + +public class BankAccountFix implements Comparable { + + private final int balance; + + public BankAccountFix(int balance) { + this.balance = balance; + } + + @Override + public int compareTo(BankAccountFix anotherAccount) { + return Integer.compare(this.balance, anotherAccount.balance); + } + +} diff --git a/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/FootballPlayer.java b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/FootballPlayer.java new file mode 100644 index 0000000000..5d065aa298 --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/FootballPlayer.java @@ -0,0 +1,28 @@ +package com.baeldung.compareto; + +public class FootballPlayer implements Comparable { + + private final String name; + private final int goalsScored; + + public FootballPlayer(String name, int goalsScored) { + this.name = name; + this.goalsScored = goalsScored; + } + + @Override + public int compareTo(FootballPlayer anotherPlayer) { + return this.goalsScored - anotherPlayer.goalsScored; + } + + @Override + public boolean equals(Object object) { + if (this == object) + return true; + if (object == null || getClass() != object.getClass()) + return false; + FootballPlayer player = (FootballPlayer) object; + return name.equals(player.name); + } + +} diff --git a/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/HandballPlayer.java b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/HandballPlayer.java new file mode 100644 index 0000000000..022155ccae --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/HandballPlayer.java @@ -0,0 +1,12 @@ +package com.baeldung.compareto; + +public class HandballPlayer { + + private final String name; + private final int height; + + public HandballPlayer(String name, int height) { + this.name = name; + this.height = height; + } +} diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/ArraysSortingUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/ArraysSortingUnitTest.java new file mode 100644 index 0000000000..2082386dba --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/ArraysSortingUnitTest.java @@ -0,0 +1,25 @@ +package com.baeldung.compareto; + +import org.junit.jupiter.api.Test; + +import java.util.Arrays; + +import static org.assertj.core.api.Assertions.assertThat; + +public class ArraysSortingUnitTest { + + @Test + public void givenArrayOfNumbers_whenSortingArray_thenNumbersAreSortedAscending() { + int[] numbers = new int[] {5, 3, 9, 11, 1, 7}; + Arrays.sort(numbers); + assertThat(numbers).containsExactly(1, 3, 5, 7, 9, 11); + } + + @Test + public void givenArrayOfStrings_whenSortingArray_thenStringsAreSortedAlphabetically() { + String[] players = new String[] {"ronaldo", "modric", "ramos", "messi"}; + Arrays.sort(players); + assertThat(players).containsExactly("messi", "modric", "ramos", "ronaldo"); + } + +} diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/BankAccountFixUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/BankAccountFixUnitTest.java new file mode 100644 index 0000000000..9ca16d1372 --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/BankAccountFixUnitTest.java @@ -0,0 +1,25 @@ +package com.baeldung.compareto; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class BankAccountFixUnitTest { + + @Test + public void givenComparisonBasedImpl_whenUsingSmallIntegers_thenComparisonWorks() { + BankAccountFix accountOne = new BankAccountFix(5000); + BankAccountFix accountTwo = new BankAccountFix(1000); + int comparison = accountOne.compareTo(accountTwo); + assertThat(comparison).isPositive(); + } + + @Test + public void givenComparisonBasedImpl_whenUsingLargeIntegers_thenComparisonWorks() { + BankAccountFix accountOne = new BankAccountFix(1900000000); + BankAccountFix accountTwo = new BankAccountFix(-2000000000); + int comparison = accountOne.compareTo(accountTwo); + assertThat(comparison).isPositive(); + } + +} diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/BankAccountUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/BankAccountUnitTest.java new file mode 100644 index 0000000000..6ef9372ff9 --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/BankAccountUnitTest.java @@ -0,0 +1,25 @@ +package com.baeldung.compareto; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.*; + +public class BankAccountUnitTest { + + @Test + public void givenSubtractionBasedImpl_whenUsingSmallIntegers_thenComparisonWorks() { + BankAccount accountOne = new BankAccount(5000); + BankAccount accountTwo = new BankAccount(1000); + int comparison = accountOne.compareTo(accountTwo); + assertThat(comparison).isPositive(); + } + + @Test + public void givenSubtractionBasedImpl_whenUsingLargeIntegers_thenComparisonBreaks() { + BankAccount accountOne = new BankAccount(1900000000); + BankAccount accountTwo = new BankAccount(-2000000000); + int comparison = accountOne.compareTo(accountTwo); + assertThat(comparison).isNegative(); + } + +} diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/FootballPlayerUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/FootballPlayerUnitTest.java new file mode 100644 index 0000000000..11a8a10585 --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/FootballPlayerUnitTest.java @@ -0,0 +1,40 @@ +package com.baeldung.compareto; + +import org.junit.jupiter.api.Test; + +import java.util.Map; +import java.util.TreeMap; +import java.util.TreeSet; + +import static org.assertj.core.api.Assertions.assertThat; + +public class FootballPlayerUnitTest { + + @Test + public void givenInconsistentCompareToAndEqualsImpl_whenUsingSortedSet_thenElementsAreNotAdded() { + FootballPlayer messi = new FootballPlayer("Messi", 800); + FootballPlayer ronaldo = new FootballPlayer("Ronaldo", 800); + + TreeSet set = new TreeSet<>(); + set.add(messi); + set.add(ronaldo); + + assertThat(set).hasSize(1); + assertThat(set).doesNotContain(ronaldo); + } + + @Test + public void givenCompareToImpl_whenSavingElementsInTreeMap_thenKeysAreSortedUsingCompareTo() { + FootballPlayer ronaldo = new FootballPlayer("Ronaldo", 900); + FootballPlayer messi = new FootballPlayer("Messi", 800); + FootballPlayer modric = new FootballPlayer("modric", 100); + + Map players = new TreeMap<>(); + players.put(ronaldo, "forward"); + players.put(messi, "forward"); + players.put(modric, "midfielder"); + + assertThat(players.keySet()).containsExactly(modric, messi, ronaldo); + } + +} diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/HandballPlayerUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/HandballPlayerUnitTest.java new file mode 100644 index 0000000000..cd017a5c0c --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/HandballPlayerUnitTest.java @@ -0,0 +1,26 @@ +package com.baeldung.compareto; + +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.TreeSet; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; + +public class HandballPlayerUnitTest { + + @Test + public void givenComparableIsNotImplemented_whenSortingArray_thenExceptionIsThrown() { + HandballPlayer duvnjak = new HandballPlayer("Duvnjak", 197); + HandballPlayer hansen = new HandballPlayer("Hansen", 196); + + HandballPlayer[] players = new HandballPlayer[] {duvnjak, hansen}; + + assertThatExceptionOfType(ClassCastException.class).isThrownBy(() -> Arrays.sort(players)); + } + +} From 51e2fe20b1132c9e6262d03fedaee1b92f335596 Mon Sep 17 00:00:00 2001 From: Daniel Strmecki Date: Sun, 24 Jan 2021 16:37:24 +0100 Subject: [PATCH 298/361] BASE-4535: Update examples for overriding compareTo --- .../baeldung/compareto/FootballPlayer.java | 6 +++++- .../compareto/FootballPlayerUnitTest.java | 21 +++++++++++++++++-- .../compareto/HandballPlayerUnitTest.java | 6 ------ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/FootballPlayer.java b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/FootballPlayer.java index 5d065aa298..173ee32434 100644 --- a/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/FootballPlayer.java +++ b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/compareto/FootballPlayer.java @@ -10,9 +10,13 @@ public class FootballPlayer implements Comparable { this.goalsScored = goalsScored; } + public String getName() { + return name; + } + @Override public int compareTo(FootballPlayer anotherPlayer) { - return this.goalsScored - anotherPlayer.goalsScored; + return Integer.compare(this.goalsScored, anotherPlayer.goalsScored); } @Override diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/FootballPlayerUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/FootballPlayerUnitTest.java index 11a8a10585..6abd1e113b 100644 --- a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/FootballPlayerUnitTest.java +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/FootballPlayerUnitTest.java @@ -2,6 +2,10 @@ package com.baeldung.compareto; import org.junit.jupiter.api.Test; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.TreeSet; @@ -11,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class FootballPlayerUnitTest { @Test - public void givenInconsistentCompareToAndEqualsImpl_whenUsingSortedSet_thenElementsAreNotAdded() { + public void givenInconsistentCompareToAndEqualsImpl_whenUsingSortedSet_thenSomeElementsAreNotAdded() { FootballPlayer messi = new FootballPlayer("Messi", 800); FootballPlayer ronaldo = new FootballPlayer("Ronaldo", 800); @@ -23,11 +27,24 @@ public class FootballPlayerUnitTest { assertThat(set).doesNotContain(ronaldo); } + @Test + public void givenCompareToImpl_whenUsingCustomComparator_thenComparatorLogicIsApplied() { + FootballPlayer ronaldo = new FootballPlayer("Ronaldo", 900); + FootballPlayer messi = new FootballPlayer("Messi", 800); + FootballPlayer modric = new FootballPlayer("Modric", 100); + + List players = Arrays.asList(ronaldo, messi, modric); + Comparator nameComparator = Comparator.comparing(FootballPlayer::getName); + Collections.sort(players, nameComparator); + + assertThat(players).containsExactly(messi, modric, ronaldo); + } + @Test public void givenCompareToImpl_whenSavingElementsInTreeMap_thenKeysAreSortedUsingCompareTo() { FootballPlayer ronaldo = new FootballPlayer("Ronaldo", 900); FootballPlayer messi = new FootballPlayer("Messi", 800); - FootballPlayer modric = new FootballPlayer("modric", 100); + FootballPlayer modric = new FootballPlayer("Modric", 100); Map players = new TreeMap<>(); players.put(ronaldo, "forward"); diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/HandballPlayerUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/HandballPlayerUnitTest.java index cd017a5c0c..143286f15f 100644 --- a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/HandballPlayerUnitTest.java +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/compareto/HandballPlayerUnitTest.java @@ -2,13 +2,7 @@ package com.baeldung.compareto; import org.junit.jupiter.api.Test; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.TreeSet; - -import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; public class HandballPlayerUnitTest { From 0fe15633887f0e47baf0c8118269e39a7448c8f7 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 24 Jan 2021 23:40:00 +0530 Subject: [PATCH 299/361] JAVA-4012: Moved 1 article from spring-data-mongodb to spring-boot-persistence-mongodb --- .../spring-boot-persistence-mongodb/README.md | 2 + .../zoneddatetime/config/MongoConfig.java | 53 +++++++++++++++++++ .../converter/ZonedDateTimeReadConverter.java | 2 +- .../ZonedDateTimeWriteConverter.java | 2 +- .../baeldung/zoneddatetime}/model/Action.java | 2 +- .../repository/ActionRepository.java | 5 +- .../ActionRepositoryLiveTest.java | 8 +-- .../spring-data-mongodb/README.md | 5 +- .../java/com/baeldung/config/MongoConfig.java | 5 -- 9 files changed, 68 insertions(+), 16 deletions(-) create mode 100644 persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/config/MongoConfig.java rename persistence-modules/{spring-data-mongodb/src/main/java => spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime}/converter/ZonedDateTimeReadConverter.java (88%) rename persistence-modules/{spring-data-mongodb/src/main/java => spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime}/converter/ZonedDateTimeWriteConverter.java (87%) rename persistence-modules/{spring-data-mongodb/src/main/java/com/baeldung => spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime}/model/Action.java (96%) rename persistence-modules/{spring-data-mongodb/src/main/java/com/baeldung => spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime}/repository/ActionRepository.java (55%) rename persistence-modules/{spring-data-mongodb/src/test/java/com/baeldung/repository => spring-boot-persistence-mongodb/src/test/java/com/baeldung/zoneddatetime}/ActionRepositoryLiveTest.java (87%) diff --git a/persistence-modules/spring-boot-persistence-mongodb/README.md b/persistence-modules/spring-boot-persistence-mongodb/README.md index aade8eb1c0..97241ad464 100644 --- a/persistence-modules/spring-boot-persistence-mongodb/README.md +++ b/persistence-modules/spring-boot-persistence-mongodb/README.md @@ -4,3 +4,5 @@ - [Spring Boot Integration Testing with Embedded MongoDB](http://www.baeldung.com/spring-boot-embedded-mongodb) - [Upload and Retrieve Files Using MongoDB and Spring Boot](https://www.baeldung.com/spring-boot-mongodb-upload-file) - [GridFS in Spring Data MongoDB](http://www.baeldung.com/spring-data-mongodb-gridfs) +- [ZonedDateTime with Spring Data MongoDB](https://www.baeldung.com/spring-data-mongodb-zoneddatetime) + diff --git a/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/config/MongoConfig.java b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/config/MongoConfig.java new file mode 100644 index 0000000000..3cfefa099c --- /dev/null +++ b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/config/MongoConfig.java @@ -0,0 +1,53 @@ +package com.baeldung.zoneddatetime.config; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.springframework.context.annotation.Configuration; +import org.springframework.core.convert.converter.Converter; +import org.springframework.data.mongodb.config.AbstractMongoClientConfiguration; +import org.springframework.data.mongodb.core.convert.MongoCustomConversions; +import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; + +import com.baeldung.zoneddatetime.converter.ZonedDateTimeReadConverter; +import com.baeldung.zoneddatetime.converter.ZonedDateTimeWriteConverter; +import com.mongodb.ConnectionString; +import com.mongodb.MongoClientSettings; +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; + +@Configuration +@EnableMongoRepositories(basePackages = { "com.baeldung" }) +public class MongoConfig extends AbstractMongoClientConfiguration { + + private final List> converters = new ArrayList>(); + + @Override + protected String getDatabaseName() { + return "test"; + } + + @Override + public MongoClient mongoClient() { + final ConnectionString connectionString = new ConnectionString("mongodb://localhost:27017/test"); + final MongoClientSettings mongoClientSettings = MongoClientSettings.builder() + .applyConnectionString(connectionString) + .build(); + return MongoClients.create(mongoClientSettings); + } + + @Override + public Collection getMappingBasePackages() { + return Collections.singleton("com.baeldung"); + } + + @Override + public MongoCustomConversions customConversions() { + converters.add(new ZonedDateTimeReadConverter()); + converters.add(new ZonedDateTimeWriteConverter()); + return new MongoCustomConversions(converters); + } + +} diff --git a/persistence-modules/spring-data-mongodb/src/main/java/converter/ZonedDateTimeReadConverter.java b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/converter/ZonedDateTimeReadConverter.java similarity index 88% rename from persistence-modules/spring-data-mongodb/src/main/java/converter/ZonedDateTimeReadConverter.java rename to persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/converter/ZonedDateTimeReadConverter.java index a2d847957b..f4a4c2d040 100644 --- a/persistence-modules/spring-data-mongodb/src/main/java/converter/ZonedDateTimeReadConverter.java +++ b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/converter/ZonedDateTimeReadConverter.java @@ -1,4 +1,4 @@ -package converter; +package com.baeldung.zoneddatetime.converter; import org.springframework.core.convert.converter.Converter; diff --git a/persistence-modules/spring-data-mongodb/src/main/java/converter/ZonedDateTimeWriteConverter.java b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/converter/ZonedDateTimeWriteConverter.java similarity index 87% rename from persistence-modules/spring-data-mongodb/src/main/java/converter/ZonedDateTimeWriteConverter.java rename to persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/converter/ZonedDateTimeWriteConverter.java index e13ac2d130..2244a1460a 100644 --- a/persistence-modules/spring-data-mongodb/src/main/java/converter/ZonedDateTimeWriteConverter.java +++ b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/converter/ZonedDateTimeWriteConverter.java @@ -1,4 +1,4 @@ -package converter; +package com.baeldung.zoneddatetime.converter; import org.springframework.core.convert.converter.Converter; diff --git a/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/model/Action.java b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/model/Action.java similarity index 96% rename from persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/model/Action.java rename to persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/model/Action.java index aa480dbdf7..06202fe465 100644 --- a/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/model/Action.java +++ b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/model/Action.java @@ -1,4 +1,4 @@ -package com.baeldung.model; +package com.baeldung.zoneddatetime.model; import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.Document; diff --git a/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/repository/ActionRepository.java b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/repository/ActionRepository.java similarity index 55% rename from persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/repository/ActionRepository.java rename to persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/repository/ActionRepository.java index bdca490fe6..e214c4b3c4 100644 --- a/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/repository/ActionRepository.java +++ b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/repository/ActionRepository.java @@ -1,6 +1,7 @@ -package com.baeldung.repository; +package com.baeldung.zoneddatetime.repository; -import com.baeldung.model.Action; import org.springframework.data.mongodb.repository.MongoRepository; +import com.baeldung.zoneddatetime.model.Action; + public interface ActionRepository extends MongoRepository { } \ No newline at end of file diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/ActionRepositoryLiveTest.java b/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/zoneddatetime/ActionRepositoryLiveTest.java similarity index 87% rename from persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/ActionRepositoryLiveTest.java rename to persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/zoneddatetime/ActionRepositoryLiveTest.java index 79648f1a20..3a241418ca 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/repository/ActionRepositoryLiveTest.java +++ b/persistence-modules/spring-boot-persistence-mongodb/src/test/java/com/baeldung/zoneddatetime/ActionRepositoryLiveTest.java @@ -1,7 +1,5 @@ -package com.baeldung.repository; +package com.baeldung.zoneddatetime; -import com.baeldung.config.MongoConfig; -import com.baeldung.model.Action; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -12,6 +10,10 @@ import org.springframework.data.mongodb.core.MongoOperations; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import com.baeldung.zoneddatetime.config.MongoConfig; +import com.baeldung.zoneddatetime.model.Action; +import com.baeldung.zoneddatetime.repository.ActionRepository; + import java.time.ZoneOffset; import java.time.ZonedDateTime; diff --git a/persistence-modules/spring-data-mongodb/README.md b/persistence-modules/spring-data-mongodb/README.md index 0be8c57036..acc978c68e 100644 --- a/persistence-modules/spring-data-mongodb/README.md +++ b/persistence-modules/spring-data-mongodb/README.md @@ -9,9 +9,8 @@ - [Custom Cascading in Spring Data MongoDB](http://www.baeldung.com/cascading-with-dbref-and-lifecycle-events-in-spring-data-mongodb) - [Introduction to Spring Data MongoDB](http://www.baeldung.com/spring-data-mongodb-tutorial) - [Spring Data MongoDB: Projections and Aggregations](http://www.baeldung.com/spring-data-mongodb-projections-aggregations) -- [Spring Data MongoDB Transactions](https://www.baeldung.com/spring-data-mongodb-transactions ) -- [ZonedDateTime with Spring Data MongoDB](https://www.baeldung.com/spring-data-mongodb-zoneddatetime) - +- [Spring Data Annotations](http://www.baeldung.com/spring-data-annotations) +- [Spring Data MongoDB Transactions](https://www.baeldung.com/spring-data-mongodb-transactions) ## Spring Data MongoDB Live Testing diff --git a/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java b/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java index 8036bbbca2..3819558e8b 100644 --- a/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java +++ b/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java @@ -25,9 +25,6 @@ import com.mongodb.MongoClientSettings; import com.mongodb.client.MongoClient; import com.mongodb.client.MongoClients; -import converter.ZonedDateTimeReadConverter; -import converter.ZonedDateTimeWriteConverter; - @Configuration @EnableMongoRepositories(basePackages = "com.baeldung.repository") public class MongoConfig extends AbstractMongoClientConfiguration { @@ -69,8 +66,6 @@ public class MongoConfig extends AbstractMongoClientConfiguration { @Override public MongoCustomConversions customConversions() { converters.add(new UserWriterConverter()); - converters.add(new ZonedDateTimeReadConverter()); - converters.add(new ZonedDateTimeWriteConverter()); return new MongoCustomConversions(converters); } From 992a33fe7dd6f2c766df2ddee288243a2c2e7a16 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 24 Jan 2021 23:46:39 +0530 Subject: [PATCH 300/361] JAVA-4012: clean-up --- .../main/java/com/baeldung/config/MongoConfig.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java b/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java index 3819558e8b..90b1268133 100644 --- a/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java +++ b/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java @@ -5,16 +5,13 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.convert.converter.Converter; import org.springframework.data.mongodb.MongoDatabaseFactory; import org.springframework.data.mongodb.MongoTransactionManager; import org.springframework.data.mongodb.config.AbstractMongoClientConfiguration; -import org.springframework.data.mongodb.core.convert.MappingMongoConverter; import org.springframework.data.mongodb.core.convert.MongoCustomConversions; -import org.springframework.data.mongodb.gridfs.GridFsTemplate; import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; import com.baeldung.converter.UserWriterConverter; @@ -31,9 +28,6 @@ public class MongoConfig extends AbstractMongoClientConfiguration { private final List> converters = new ArrayList>(); - @Autowired - private MappingMongoConverter mongoConverter; - @Override protected String getDatabaseName() { return "test"; @@ -69,11 +63,6 @@ public class MongoConfig extends AbstractMongoClientConfiguration { return new MongoCustomConversions(converters); } - @Bean - public GridFsTemplate gridFsTemplate() throws Exception { - return new GridFsTemplate(mongoDbFactory(), mongoConverter); - } - @Bean MongoTransactionManager transactionManager(MongoDatabaseFactory dbFactory) { return new MongoTransactionManager(dbFactory); From 2bc7dbc70868ac34ac8d3e7edb8113338fa991d4 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Sun, 24 Jan 2021 15:18:29 -0300 Subject: [PATCH 301/361] added and ordered tests in WebClientIntegrationTest to match article - test not passing (reusing specs) --- .../web/client/WebClientIntegrationTest.java | 82 +++++++++++++------ 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java index df873c618d..837ea679d2 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java @@ -1,7 +1,7 @@ package com.baeldung.web.client; import java.net.URI; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.time.ZonedDateTime; import java.util.Collections; import java.util.concurrent.TimeUnit; @@ -10,6 +10,7 @@ import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -22,6 +23,10 @@ import org.springframework.util.MultiValueMap; import org.springframework.web.reactive.function.BodyInserter; import org.springframework.web.reactive.function.BodyInserters; import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.reactive.function.client.WebClient.RequestBodySpec; +import org.springframework.web.reactive.function.client.WebClient.RequestHeadersSpec; +import org.springframework.web.reactive.function.client.WebClient.ResponseSpec; +import org.springframework.web.reactive.function.client.WebClient.UriSpec; import com.baeldung.web.reactive.client.WebClientApplication; @@ -31,7 +36,7 @@ import io.netty.handler.timeout.WriteTimeoutHandler; import reactor.core.publisher.Mono; import reactor.netty.http.client.HttpClient; -@SpringBootTest(classes = WebClientApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest(classes = WebClientApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) public class WebClientIntegrationTest { @LocalServerPort @@ -40,44 +45,73 @@ public class WebClientIntegrationTest { @Test public void demonstrateWebClient() { // request - WebClient.UriSpec request1 = createWebClientWithServerURLAndDefaultValues().method(HttpMethod.POST); - WebClient.UriSpec request2 = createWebClientWithServerURLAndDefaultValues().post(); + UriSpec requestPost1 = createWebClientWithServerURLAndDefaultValues().method(HttpMethod.POST); + UriSpec requestPost2 = createWebClientWithServerURLAndDefaultValues().post(); + UriSpec requestGet = createWebClientWithServerURLAndDefaultValues().get(); // request body specifications - WebClient.RequestBodySpec uri1 = createWebClientWithServerURLAndDefaultValues().method(HttpMethod.POST) - .uri("/resource"); - WebClient.RequestBodySpec uri2 = createWebClientWithServerURLAndDefaultValues().post() - .uri(URI.create("/resource")); + RequestBodySpec bodySpecPost = requestPost1.uri("/resource"); + RequestBodySpec bodySpecPostMultipart = requestPost2.uri(uriBuilder -> uriBuilder.pathSegment("resource-multipart") + .build()); + RequestBodySpec bodySpecOverridenBaseUri = requestPost2.uri(URI.create("/resource")); // request header specification - WebClient.RequestHeadersSpec requestSpec1 = uri1.body(BodyInserters.fromPublisher(Mono.just("data"), String.class)); - WebClient.RequestHeadersSpec requestSpec2 = uri2.body(BodyInserters.fromValue("data")); + String bodyValue = "bodyValue"; + RequestHeadersSpec headerSpecPost1 = bodySpecPost.body(BodyInserters.fromPublisher(Mono.just(bodyValue), String.class)); + RequestHeadersSpec headerSpecPost2 = bodySpecPost.body(BodyInserters.fromValue(bodyValue)); + RequestHeadersSpec headerSpecGet = requestGet.uri("/resource"); - // inserters - BodyInserter, ReactiveHttpOutputMessage> inserter1 = BodyInserters.fromPublisher(Subscriber::onComplete, String.class); + // request header specification using inserters + BodyInserter, ReactiveHttpOutputMessage> inserterCompleteSuscriber = BodyInserters.fromPublisher(Subscriber::onComplete, String.class); LinkedMultiValueMap map = new LinkedMultiValueMap<>(); - map.add("key1", "value1"); - map.add("key2", "value2"); + map.add("key1", "multipartValue1"); + map.add("key2", "multipartValue2"); - BodyInserter, ClientHttpRequest> inserter2 = BodyInserters.fromMultipartData(map); - BodyInserter inserter3 = BodyInserters.fromValue(new Object()); - BodyInserter inserter4 = BodyInserters.fromValue("body"); + BodyInserter, ClientHttpRequest> inserterMultipart = BodyInserters.fromMultipartData(map); + BodyInserter inserterObject = BodyInserters.fromValue(new Object()); + BodyInserter inserterString = BodyInserters.fromValue(bodyValue); + + RequestHeadersSpec headerSpecInserterCompleteSuscriber = bodySpecPost.body(inserterCompleteSuscriber); + RequestHeadersSpec headerSpecInserterMultipart = bodySpecPostMultipart.body(inserterMultipart); + RequestHeadersSpec headerSpecInserterObject = bodySpecPost.body(inserterObject); + RequestHeadersSpec headerSpecInserterString = bodySpecPost.body(inserterString); // responses - WebClient.ResponseSpec response1 = uri1.body(inserter3) - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + ResponseSpec responsePostObject = headerSpecInserterObject.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) .accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML) - .acceptCharset(Charset.forName("UTF-8")) + .acceptCharset(StandardCharsets.UTF_8) .ifNoneMatch("*") .ifModifiedSince(ZonedDateTime.now()) .retrieve(); - String response2 = uri1.exchangeToMono(response -> response.bodyToMono(String.class)) + String responsePostString = headerSpecInserterString.exchangeToMono(response -> response.bodyToMono(String.class)) .block(); - String response3 = uri2.retrieve() + String responsePostMultipart = headerSpecInserterMultipart.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE) + .retrieve() .bodyToMono(String.class) .block(); - WebClient.ResponseSpec response4 = requestSpec2.retrieve(); + String responsePostCompleteSubsciber = headerSpecInserterCompleteSuscriber.retrieve() + .bodyToMono(String.class) + .block(); + String responsePostWithBody1 = headerSpecPost1.retrieve() + .bodyToMono(String.class) + .block(); + String responsePostWithBody3 = headerSpecPost2.retrieve() + .bodyToMono(String.class) + .block(); + String responseGet = headerSpecGet.retrieve() + .bodyToMono(String.class) + .block(); + String responsePostWithNoBody = bodySpecPost.retrieve() + .bodyToMono(String.class) + .block(); + try { + bodySpecOverridenBaseUri.retrieve() + .bodyToMono(String.class) + .block(); + } catch (Exception ex) { + System.out.println(ex.getClass()); + } } private WebClient createWebClient() { @@ -101,7 +135,7 @@ public class WebClientIntegrationTest { private WebClient createWebClientWithServerURLAndDefaultValues() { return WebClient.builder() - .baseUrl("http://localhost:8081") + .baseUrl("http://localhost:" + port) .defaultCookie("cookieKey", "cookieValue") .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) .defaultUriVariables(Collections.singletonMap("url", "http://localhost:8080")) From 84737e1056097486bdce4f7b6bc65cfafd930065 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Sun, 24 Jan 2021 17:41:34 -0300 Subject: [PATCH 302/361] added Foo for post Object scenario, removed Subscriber::onComplete scenario, fixed some other errors in examples --- .../com/baeldung/web/reactive/client/Foo.java | 20 +++ .../reactive/client/WebClientController.java | 7 +- .../web/client/WebClientIntegrationTest.java | 141 +++++++++++------- 3 files changed, 116 insertions(+), 52 deletions(-) create mode 100644 spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/Foo.java diff --git a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/Foo.java b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/Foo.java new file mode 100644 index 0000000000..1fc4834cfa --- /dev/null +++ b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/Foo.java @@ -0,0 +1,20 @@ +package com.baeldung.web.reactive.client; + +public class Foo { + + private String name; + + public Foo(String name) { + super(); + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java index 2dfcd7533b..4c7941ac35 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java +++ b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java @@ -28,8 +28,13 @@ public class WebClientController { return "processed-" + bodyString; } + @PostMapping("/resource-foo") + public String postResource(@RequestBody Foo bodyFoo) { + return "processedFoo-" + bodyFoo.getName(); + } + @PostMapping(value = "/resource-multipart", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public String handleFormUpload(@RequestPart("key1") String value1, @RequestPart("key2") String value2) { - return "processed-" + value1 + value2; + return "processed-" + value1 + "-" + value2; } } diff --git a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java index 837ea679d2..b49aff9575 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java @@ -1,9 +1,13 @@ package com.baeldung.web.client; +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + import java.net.URI; import java.nio.charset.StandardCharsets; import java.time.ZonedDateTime; import java.util.Collections; +import java.util.Map; import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.Test; @@ -12,6 +16,7 @@ import org.reactivestreams.Subscriber; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; @@ -24,13 +29,17 @@ import org.springframework.web.reactive.function.BodyInserter; import org.springframework.web.reactive.function.BodyInserters; import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClient.RequestBodySpec; +import org.springframework.web.reactive.function.client.WebClient.RequestBodyUriSpec; import org.springframework.web.reactive.function.client.WebClient.RequestHeadersSpec; import org.springframework.web.reactive.function.client.WebClient.ResponseSpec; import org.springframework.web.reactive.function.client.WebClient.UriSpec; +import org.springframework.web.reactive.function.client.WebClientRequestException; +import com.baeldung.web.reactive.client.Foo; import com.baeldung.web.reactive.client.WebClientApplication; import io.netty.channel.ChannelOption; +import io.netty.channel.ConnectTimeoutException; import io.netty.handler.timeout.ReadTimeoutHandler; import io.netty.handler.timeout.WriteTimeoutHandler; import reactor.core.publisher.Mono; @@ -43,27 +52,37 @@ public class WebClientIntegrationTest { private int port; @Test - public void demonstrateWebClient() { - // request - UriSpec requestPost1 = createWebClientWithServerURLAndDefaultValues().method(HttpMethod.POST); - UriSpec requestPost2 = createWebClientWithServerURLAndDefaultValues().post(); - UriSpec requestGet = createWebClientWithServerURLAndDefaultValues().get(); + public void givenDifferentScenarios_whenRequestsSent_thenObtainExpectedResponses() { + // WebClient + WebClient client1 = WebClient.create(); + WebClient client2 = WebClient.create("http://localhost:" + port); + WebClient client3 = WebClient.builder() + .baseUrl("http://localhost:" + port) + .defaultCookie("cookieKey", "cookieValue") + .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + .defaultUriVariables(Collections.singletonMap("url", "http://localhost:8080")) + .build(); + + // request specification + UriSpec uriSpecPost1 = client1.method(HttpMethod.POST); + UriSpec uriSpecPost2 = client2.post(); + UriSpec requestGet = client3.get(); + + // uri specification + RequestBodySpec bodySpecPost = uriSpecPost1.uri("http://localhost:" + port + "/resource"); + RequestBodySpec bodySpecPostMultipart = uriSpecPost2.uri(uriBuilder -> uriBuilder.pathSegment("resource-multipart") + .build()); + RequestBodySpec bodySpecOverridenBaseUri = createDefaultPostRequest().uri(URI.create("/resource")); + RequestBodySpec fooBodySpecPost = createDefaultPostRequest().uri(URI.create("/resource-foo")); // request body specifications - RequestBodySpec bodySpecPost = requestPost1.uri("/resource"); - RequestBodySpec bodySpecPostMultipart = requestPost2.uri(uriBuilder -> uriBuilder.pathSegment("resource-multipart") - .build()); - RequestBodySpec bodySpecOverridenBaseUri = requestPost2.uri(URI.create("/resource")); - - // request header specification String bodyValue = "bodyValue"; RequestHeadersSpec headerSpecPost1 = bodySpecPost.body(BodyInserters.fromPublisher(Mono.just(bodyValue), String.class)); - RequestHeadersSpec headerSpecPost2 = bodySpecPost.body(BodyInserters.fromValue(bodyValue)); + RequestHeadersSpec headerSpecPost2 = createDefaultPostResourceRequest().body(BodyInserters.fromValue(bodyValue)); + RequestHeadersSpec headerSpecFooPost = fooBodySpecPost.body(BodyInserters.fromValue(new Foo("fooName"))); RequestHeadersSpec headerSpecGet = requestGet.uri("/resource"); - // request header specification using inserters - BodyInserter, ReactiveHttpOutputMessage> inserterCompleteSuscriber = BodyInserters.fromPublisher(Subscriber::onComplete, String.class); - + // request body specifications - using inserters LinkedMultiValueMap map = new LinkedMultiValueMap<>(); map.add("key1", "multipartValue1"); map.add("key2", "multipartValue2"); @@ -72,73 +91,93 @@ public class WebClientIntegrationTest { BodyInserter inserterObject = BodyInserters.fromValue(new Object()); BodyInserter inserterString = BodyInserters.fromValue(bodyValue); - RequestHeadersSpec headerSpecInserterCompleteSuscriber = bodySpecPost.body(inserterCompleteSuscriber); RequestHeadersSpec headerSpecInserterMultipart = bodySpecPostMultipart.body(inserterMultipart); - RequestHeadersSpec headerSpecInserterObject = bodySpecPost.body(inserterObject); - RequestHeadersSpec headerSpecInserterString = bodySpecPost.body(inserterString); + RequestHeadersSpec headerSpecInserterObject = createDefaultPostResourceRequest().body(inserterObject); + RequestHeadersSpec headerSpecInserterString = createDefaultPostResourceRequest().body(inserterString); - // responses - ResponseSpec responsePostObject = headerSpecInserterObject.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + // request header specification + RequestHeadersSpec headerSpecInserterStringWithHeaders = headerSpecInserterString.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) .accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML) .acceptCharset(StandardCharsets.UTF_8) .ifNoneMatch("*") - .ifModifiedSince(ZonedDateTime.now()) - .retrieve(); - String responsePostString = headerSpecInserterString.exchangeToMono(response -> response.bodyToMono(String.class)) + .ifModifiedSince(ZonedDateTime.now()); + + // request + ResponseSpec responseSpecPostString = headerSpecInserterStringWithHeaders.retrieve(); + String responsePostString = responseSpecPostString.bodyToMono(String.class) .block(); String responsePostMultipart = headerSpecInserterMultipart.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE) .retrieve() .bodyToMono(String.class) .block(); - String responsePostCompleteSubsciber = headerSpecInserterCompleteSuscriber.retrieve() - .bodyToMono(String.class) - .block(); String responsePostWithBody1 = headerSpecPost1.retrieve() .bodyToMono(String.class) .block(); String responsePostWithBody3 = headerSpecPost2.retrieve() .bodyToMono(String.class) .block(); - String responseGet = headerSpecGet.retrieve() + String responsePostFoo = headerSpecFooPost.retrieve() .bodyToMono(String.class) .block(); + ParameterizedTypeReference> ref = new ParameterizedTypeReference>() { + }; + Map responseGet = headerSpecGet.retrieve() + .bodyToMono(ref) + .block(); String responsePostWithNoBody = bodySpecPost.retrieve() .bodyToMono(String.class) .block(); - try { + + // response assertions + assertThat(responsePostString).isEqualTo("processed-bodyValue"); + assertThat(responsePostMultipart).isEqualTo("processed-multipartValue1-multipartValue2"); + assertThat(responsePostWithBody1).isEqualTo("processed-"); + assertThat(responsePostWithBody3).isEqualTo("processed-"); + assertThat(responseGet).containsEntry("field", "value"); + assertThat(responsePostWithNoBody).isEqualTo("processed-"); + assertThat(responsePostFoo).isEqualTo("processed-fooName"); + + assertThrows(WebClientRequestException.class, () -> { + String responsePostObject = headerSpecInserterObject.exchangeToMono(response -> response.bodyToMono(String.class)) + .block(); + }); + assertThrows(WebClientRequestException.class, () -> { bodySpecOverridenBaseUri.retrieve() .bodyToMono(String.class) .block(); - } catch (Exception ex) { - System.out.println(ex.getClass()); - } + }); + } - private WebClient createWebClient() { - return WebClient.create(); - } - - private WebClient createWebClientWithServerURL() { - return WebClient.create("http://localhost:8081"); - } - - private WebClient createWebClientConfiguringTimeout() { + @Test + public void givenWebClientWithTimeoutConfigurations_whenRequestUsingWronglyConfiguredPublisher_thenObtainTimeout() { HttpClient httpClient = HttpClient.create() - .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000) - .doOnConnected(conn -> conn.addHandlerLast(new ReadTimeoutHandler(5000, TimeUnit.MILLISECONDS)) - .addHandlerLast(new WriteTimeoutHandler(5000, TimeUnit.MILLISECONDS))); + .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000) + .doOnConnected(conn -> conn.addHandlerLast(new ReadTimeoutHandler(1000, TimeUnit.MILLISECONDS)) + .addHandlerLast(new WriteTimeoutHandler(1000, TimeUnit.MILLISECONDS))); - return WebClient.builder() + WebClient timeoutClient = WebClient.builder() .clientConnector(new ReactorClientHttpConnector(httpClient)) .build(); + + BodyInserter, ReactiveHttpOutputMessage> inserterCompleteSuscriber = BodyInserters.fromPublisher(Subscriber::onComplete, String.class); + RequestHeadersSpec headerSpecInserterCompleteSuscriber = timeoutClient.post() + .uri("/resource") + .body(inserterCompleteSuscriber); + WebClientRequestException exception = assertThrows(WebClientRequestException.class, () -> { + headerSpecInserterCompleteSuscriber.retrieve() + .bodyToMono(String.class) + .block(); + }); + assertThat(exception.getCause()).isInstanceOf(ConnectTimeoutException.class); } - private WebClient createWebClientWithServerURLAndDefaultValues() { - return WebClient.builder() - .baseUrl("http://localhost:" + port) - .defaultCookie("cookieKey", "cookieValue") - .defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) - .defaultUriVariables(Collections.singletonMap("url", "http://localhost:8080")) - .build(); + private RequestBodyUriSpec createDefaultPostRequest() { + return WebClient.create("http://localhost:" + port) + .post(); + } + + private RequestBodySpec createDefaultPostResourceRequest() { + return createDefaultPostRequest().uri("/resource"); } } From 431442e3cab7bd575b1f136f362517aecab0d279 Mon Sep 17 00:00:00 2001 From: Anshul BANSAL Date: Mon, 25 Jan 2021 12:29:01 +0200 Subject: [PATCH 303/361] BAEL-4499 - Synchronization bad practice and solution example --- .../AnimalBadPractice.java | 35 +++++++++++++ .../AnimalSolution.java | 42 +++++++++++++++ .../SynchronizationBadPracticeExample.java | 51 +++++++++++++++++++ .../SynchronizationSolutionExample.java | 30 +++++++++++ 4 files changed, 158 insertions(+) create mode 100644 core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/synchronizationbadpractices/AnimalBadPractice.java create mode 100644 core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/synchronizationbadpractices/AnimalSolution.java create mode 100644 core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/synchronizationbadpractices/SynchronizationBadPracticeExample.java create mode 100644 core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/synchronizationbadpractices/SynchronizationSolutionExample.java diff --git a/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/synchronizationbadpractices/AnimalBadPractice.java b/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/synchronizationbadpractices/AnimalBadPractice.java new file mode 100644 index 0000000000..ca6b7db765 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/synchronizationbadpractices/AnimalBadPractice.java @@ -0,0 +1,35 @@ +package com.baeldung.synchronizationbadpractices; + +public class AnimalBadPractice { + + private String name; + private String owner; + + public String getName() { + return name; + } + + public String getOwner() { + return owner; + } + + public synchronized void setName(String name) { + this.name = name; + } + + public void setOwner(String owner) { + synchronized(this) { + this.owner = owner; + } + } + + public AnimalBadPractice() { + + } + + public AnimalBadPractice(String name, String owner) { + this.name = name; + this.owner = owner; + } + +} diff --git a/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/synchronizationbadpractices/AnimalSolution.java b/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/synchronizationbadpractices/AnimalSolution.java new file mode 100644 index 0000000000..b49cfa05d4 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/synchronizationbadpractices/AnimalSolution.java @@ -0,0 +1,42 @@ +package com.baeldung.synchronizationbadpractices; + +public class AnimalSolution { + + private final Object objLock1 = new Object(); + private final Object objLock2 = new Object(); + + private String name; + private String owner; + + public String getName() { + return name; + } + + public String getOwner() { + return owner; + } + + + public void setName(String name) { + synchronized(objLock1) { + this.name = name; + } + } + + public void setOwner(String owner) { + synchronized(objLock2) { + this.owner = owner; + } + } + + public AnimalSolution() { + + } + + public AnimalSolution(String name, String owner) { + this.name = name; + this.owner = owner; + } + + +} \ No newline at end of file diff --git a/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/synchronizationbadpractices/SynchronizationBadPracticeExample.java b/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/synchronizationbadpractices/SynchronizationBadPracticeExample.java new file mode 100644 index 0000000000..84d2e1cbb6 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/synchronizationbadpractices/SynchronizationBadPracticeExample.java @@ -0,0 +1,51 @@ +package com.baeldung.synchronizationbadpractices; + +public class SynchronizationBadPracticeExample { + + public void stringBadPractice1() { + String stringLock = "LOCK_STRING"; + synchronized (stringLock) { + // ... + } + } + + private final String stringLock = "LOCK_STRING"; + public void stringBadPractice2() { + synchronized (stringLock) { + // ... + } + } + + private final String internedStringLock = new String("LOCK_STRING").intern(); + public void stringBadPractice3() { + synchronized (internedStringLock) { + // ... + } + } + + private final Boolean booleanLock = Boolean.FALSE; + public void booleanBadPractice() { + synchronized (booleanLock) { + // ... + } + } + + private int count = 0; + private final Integer intLock = count; + public void boxedPrimitiveBadPractice() { + synchronized (intLock) { + count++; + // ... + } + } + + public void classBadPractice() throws InterruptedException { + AnimalBadPractice animalObj = new AnimalBadPractice("Tommy", "John"); + synchronized(animalObj) { + while (true) { + Thread.sleep(Integer.MAX_VALUE); + } + } + } + +} diff --git a/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/synchronizationbadpractices/SynchronizationSolutionExample.java b/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/synchronizationbadpractices/SynchronizationSolutionExample.java new file mode 100644 index 0000000000..a3ab8a2cee --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-4/src/main/java/com/baeldung/synchronizationbadpractices/SynchronizationSolutionExample.java @@ -0,0 +1,30 @@ +package com.baeldung.synchronizationbadpractices; + +public class SynchronizationSolutionExample { + + private final String stringLock = new String("LOCK_STRING"); + public void stringSolution() { + synchronized (stringLock) { + // ... + } + } + + private int count = 0; + private final Integer intLock = new Integer(count); + public void boxedPrimitiveSolution() { + synchronized(intLock) { + count++; + // ... + } + } + + private static int staticCount = 0; + private static final Object staticObjLock = new Object(); + public void staticVariableSolution() { + synchronized(staticObjLock) { + staticCount++; + // ... + } + } + +} From cfe47f772a434eb3b1c462144c9a2301e3418cf4 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Mon, 25 Jan 2021 11:37:12 -0300 Subject: [PATCH 304/361] fixed rest of tests --- .../com/baeldung/web/reactive/client/Foo.java | 4 ++++ .../reactive/client/WebClientController.java | 10 ++++---- .../web/client/WebClientIntegrationTest.java | 24 ++++++++++++------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/Foo.java b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/Foo.java index 1fc4834cfa..c6e3678832 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/Foo.java +++ b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/Foo.java @@ -4,6 +4,10 @@ public class Foo { private String name; + public Foo() { + super(); + } + public Foo(String name) { super(); this.name = name; diff --git a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java index 4c7941ac35..1a91001807 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java +++ b/spring-5-reactive/src/main/java/com/baeldung/web/reactive/client/WebClientController.java @@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; +import reactor.core.publisher.Mono; + @RestController public class WebClientController { @@ -24,13 +26,13 @@ public class WebClientController { } @PostMapping("/resource") - public String postResource(@RequestBody String bodyString) { - return "processed-" + bodyString; + public Mono postStringResource(@RequestBody Mono bodyString) { + return bodyString.map(body -> "processed-" + body); } @PostMapping("/resource-foo") - public String postResource(@RequestBody Foo bodyFoo) { - return "processedFoo-" + bodyFoo.getName(); + public Mono postFooResource(@RequestBody Mono bodyFoo) { + return bodyFoo.map(foo -> "processedFoo-" + foo.getName()); } @PostMapping(value = "/resource-multipart", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) diff --git a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java index b49aff9575..04a4031c62 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java @@ -17,8 +17,10 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.core.ParameterizedTypeReference; +import org.springframework.core.codec.CodecException; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ReactiveHttpOutputMessage; import org.springframework.http.client.reactive.ClientHttpRequest; @@ -72,8 +74,8 @@ public class WebClientIntegrationTest { RequestBodySpec bodySpecPost = uriSpecPost1.uri("http://localhost:" + port + "/resource"); RequestBodySpec bodySpecPostMultipart = uriSpecPost2.uri(uriBuilder -> uriBuilder.pathSegment("resource-multipart") .build()); + RequestBodySpec fooBodySpecPost = createDefaultPostRequest().uri("/resource-foo"); RequestBodySpec bodySpecOverridenBaseUri = createDefaultPostRequest().uri(URI.create("/resource")); - RequestBodySpec fooBodySpecPost = createDefaultPostRequest().uri(URI.create("/resource-foo")); // request body specifications String bodyValue = "bodyValue"; @@ -124,23 +126,27 @@ public class WebClientIntegrationTest { Map responseGet = headerSpecGet.retrieve() .bodyToMono(ref) .block(); - String responsePostWithNoBody = bodySpecPost.retrieve() - .bodyToMono(String.class) + Map responsePostWithNoBody = createDefaultPostResourceRequest().exchangeToMono(responseHandler -> { + assertThat(responseHandler.statusCode()).isEqualTo(HttpStatus.BAD_REQUEST); + return responseHandler.bodyToMono(ref); + }) .block(); // response assertions assertThat(responsePostString).isEqualTo("processed-bodyValue"); assertThat(responsePostMultipart).isEqualTo("processed-multipartValue1-multipartValue2"); - assertThat(responsePostWithBody1).isEqualTo("processed-"); - assertThat(responsePostWithBody3).isEqualTo("processed-"); + assertThat(responsePostWithBody1).isEqualTo("processed-bodyValue"); + assertThat(responsePostWithBody3).isEqualTo("processed-bodyValue"); assertThat(responseGet).containsEntry("field", "value"); - assertThat(responsePostWithNoBody).isEqualTo("processed-"); - assertThat(responsePostFoo).isEqualTo("processed-fooName"); + assertThat(responsePostFoo).isEqualTo("processedFoo-fooName"); + assertThat(responsePostWithNoBody).containsEntry("error", "Bad Request"); - assertThrows(WebClientRequestException.class, () -> { - String responsePostObject = headerSpecInserterObject.exchangeToMono(response -> response.bodyToMono(String.class)) + // assert sending plain `new Object()` as request body + assertThrows(CodecException.class, () -> { + headerSpecInserterObject.exchangeToMono(response -> response.bodyToMono(String.class)) .block(); }); + // assert sending request overriding base uri assertThrows(WebClientRequestException.class, () -> { bodySpecOverridenBaseUri.retrieve() .bodyToMono(String.class) From 0cda08a95e6326c4e5dfec76c54e2a865974b1d5 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Mon, 25 Jan 2021 11:41:57 -0300 Subject: [PATCH 305/361] replaced existing scenario to use an alternative body method --- .../java/com/baeldung/web/client/WebClientIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java index 04a4031c62..34627b00ed 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java @@ -81,7 +81,7 @@ public class WebClientIntegrationTest { String bodyValue = "bodyValue"; RequestHeadersSpec headerSpecPost1 = bodySpecPost.body(BodyInserters.fromPublisher(Mono.just(bodyValue), String.class)); RequestHeadersSpec headerSpecPost2 = createDefaultPostResourceRequest().body(BodyInserters.fromValue(bodyValue)); - RequestHeadersSpec headerSpecFooPost = fooBodySpecPost.body(BodyInserters.fromValue(new Foo("fooName"))); + RequestHeadersSpec headerSpecFooPost = fooBodySpecPost.body(Mono.just(new Foo("fooName")), Foo.class); RequestHeadersSpec headerSpecGet = requestGet.uri("/resource"); // request body specifications - using inserters From a37812ce04cb20c7a1a76deabbe15137c6fb5c26 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Mon, 25 Jan 2021 11:44:44 -0300 Subject: [PATCH 306/361] added additional scenario using bodyValue method --- .../com/baeldung/web/client/WebClientIntegrationTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java index 34627b00ed..032d62b04d 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java @@ -81,6 +81,7 @@ public class WebClientIntegrationTest { String bodyValue = "bodyValue"; RequestHeadersSpec headerSpecPost1 = bodySpecPost.body(BodyInserters.fromPublisher(Mono.just(bodyValue), String.class)); RequestHeadersSpec headerSpecPost2 = createDefaultPostResourceRequest().body(BodyInserters.fromValue(bodyValue)); + RequestHeadersSpec headerSpecPost3 = createDefaultPostResourceRequest().bodyValue(bodyValue); RequestHeadersSpec headerSpecFooPost = fooBodySpecPost.body(Mono.just(new Foo("fooName")), Foo.class); RequestHeadersSpec headerSpecGet = requestGet.uri("/resource"); @@ -115,6 +116,9 @@ public class WebClientIntegrationTest { String responsePostWithBody1 = headerSpecPost1.retrieve() .bodyToMono(String.class) .block(); + String responsePostWithBody2 = headerSpecPost2.retrieve() + .bodyToMono(String.class) + .block(); String responsePostWithBody3 = headerSpecPost2.retrieve() .bodyToMono(String.class) .block(); @@ -136,6 +140,7 @@ public class WebClientIntegrationTest { assertThat(responsePostString).isEqualTo("processed-bodyValue"); assertThat(responsePostMultipart).isEqualTo("processed-multipartValue1-multipartValue2"); assertThat(responsePostWithBody1).isEqualTo("processed-bodyValue"); + assertThat(responsePostWithBody2).isEqualTo("processed-bodyValue"); assertThat(responsePostWithBody3).isEqualTo("processed-bodyValue"); assertThat(responseGet).containsEntry("field", "value"); assertThat(responsePostFoo).isEqualTo("processedFoo-fooName"); From 615322468ecf4093d2e96c453b6c389dac7e9e5c Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Mon, 25 Jan 2021 12:26:37 -0300 Subject: [PATCH 307/361] made tests assertions non-blocking --- spring-5-reactive/pom.xml | 11 ++- .../web/client/WebClientIntegrationTest.java | 68 ++++++++++--------- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/spring-5-reactive/pom.xml b/spring-5-reactive/pom.xml index 60c8b90e16..40791faaaf 100644 --- a/spring-5-reactive/pom.xml +++ b/spring-5-reactive/pom.xml @@ -1,6 +1,7 @@ - + 4.0.0 spring-5-reactive 0.0.1-SNAPSHOT @@ -73,6 +74,12 @@ spring-security-test test + + io.projectreactor + reactor-test + test + + diff --git a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java index 032d62b04d..01de550a9c 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java @@ -46,6 +46,7 @@ import io.netty.handler.timeout.ReadTimeoutHandler; import io.netty.handler.timeout.WriteTimeoutHandler; import reactor.core.publisher.Mono; import reactor.netty.http.client.HttpClient; +import reactor.test.StepVerifier; @SpringBootTest(classes = WebClientApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) public class WebClientIntegrationTest { @@ -107,44 +108,46 @@ public class WebClientIntegrationTest { // request ResponseSpec responseSpecPostString = headerSpecInserterStringWithHeaders.retrieve(); - String responsePostString = responseSpecPostString.bodyToMono(String.class) - .block(); - String responsePostMultipart = headerSpecInserterMultipart.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE) + Mono responsePostString = responseSpecPostString.bodyToMono(String.class); + Mono responsePostMultipart = headerSpecInserterMultipart.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE) .retrieve() - .bodyToMono(String.class) - .block(); - String responsePostWithBody1 = headerSpecPost1.retrieve() - .bodyToMono(String.class) - .block(); - String responsePostWithBody2 = headerSpecPost2.retrieve() - .bodyToMono(String.class) - .block(); - String responsePostWithBody3 = headerSpecPost2.retrieve() - .bodyToMono(String.class) - .block(); - String responsePostFoo = headerSpecFooPost.retrieve() - .bodyToMono(String.class) - .block(); + .bodyToMono(String.class); + Mono responsePostWithBody1 = headerSpecPost1.retrieve() + .bodyToMono(String.class); + Mono responsePostWithBody2 = headerSpecPost2.retrieve() + .bodyToMono(String.class); + Mono responsePostWithBody3 = headerSpecPost2.retrieve() + .bodyToMono(String.class); + Mono responsePostFoo = headerSpecFooPost.retrieve() + .bodyToMono(String.class); ParameterizedTypeReference> ref = new ParameterizedTypeReference>() { }; - Map responseGet = headerSpecGet.retrieve() - .bodyToMono(ref) - .block(); - Map responsePostWithNoBody = createDefaultPostResourceRequest().exchangeToMono(responseHandler -> { + Mono> responseGet = headerSpecGet.retrieve() + .bodyToMono(ref); + Mono> responsePostWithNoBody = createDefaultPostResourceRequest().exchangeToMono(responseHandler -> { assertThat(responseHandler.statusCode()).isEqualTo(HttpStatus.BAD_REQUEST); return responseHandler.bodyToMono(ref); - }) - .block(); + }); // response assertions - assertThat(responsePostString).isEqualTo("processed-bodyValue"); - assertThat(responsePostMultipart).isEqualTo("processed-multipartValue1-multipartValue2"); - assertThat(responsePostWithBody1).isEqualTo("processed-bodyValue"); - assertThat(responsePostWithBody2).isEqualTo("processed-bodyValue"); - assertThat(responsePostWithBody3).isEqualTo("processed-bodyValue"); - assertThat(responseGet).containsEntry("field", "value"); - assertThat(responsePostFoo).isEqualTo("processedFoo-fooName"); - assertThat(responsePostWithNoBody).containsEntry("error", "Bad Request"); + StepVerifier.create(responsePostString) + .expectNext("processed-bodyValue"); + StepVerifier.create(responsePostMultipart) + .expectNext("processed-multipartValue1-multipartValue2"); + StepVerifier.create(responsePostWithBody1) + .expectNext("processed-bodyValue"); + StepVerifier.create(responsePostWithBody2) + .expectNext("processed-bodyValue"); + StepVerifier.create(responsePostWithBody3) + .expectNext("processed-bodyValue"); + StepVerifier.create(responseGet) + .expectNextMatches(nextMap -> nextMap.get("field") + .equals("value")); + StepVerifier.create(responsePostFoo) + .expectNext("processedFoo-fooName"); + StepVerifier.create(responsePostWithNoBody) + .expectNextMatches(nextMap -> nextMap.get("error") + .equals("Bad Request")); // assert sending plain `new Object()` as request body assertThrows(CodecException.class, () -> { @@ -152,11 +155,12 @@ public class WebClientIntegrationTest { .block(); }); // assert sending request overriding base uri - assertThrows(WebClientRequestException.class, () -> { + Exception exception = assertThrows(WebClientRequestException.class, () -> { bodySpecOverridenBaseUri.retrieve() .bodyToMono(String.class) .block(); }); + assertThat(exception.getMessage()).contains("Connection refused"); } From e8569d56b0eb251b49baf091ecaf3dc792f74bca Mon Sep 17 00:00:00 2001 From: Usman Mohyuddin Date: Tue, 26 Jan 2021 04:09:58 +0500 Subject: [PATCH 308/361] add file for constantpool (#10442) * Create ConstantPool.java add file for constantpool * update the module with most relevant update the module with most relevant --- .../main/java/com/baeldung/constantpool/ConstantPool.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 core-java-modules/core-java-jvm-2/src/main/java/com/baeldung/constantpool/ConstantPool.java diff --git a/core-java-modules/core-java-jvm-2/src/main/java/com/baeldung/constantpool/ConstantPool.java b/core-java-modules/core-java-jvm-2/src/main/java/com/baeldung/constantpool/ConstantPool.java new file mode 100644 index 0000000000..b9aea05272 --- /dev/null +++ b/core-java-modules/core-java-jvm-2/src/main/java/com/baeldung/constantpool/ConstantPool.java @@ -0,0 +1,8 @@ +package com.baeldung.constantpool; + +public class ConstantPool { + + public void sayHello() { + System.out.println("Hello World"); + } +} From b018825dc40e2b0a2d0e242bcf88ed4d6253a488 Mon Sep 17 00:00:00 2001 From: Umang Budhwar Date: Tue, 26 Jan 2021 20:36:04 +0530 Subject: [PATCH 309/361] BAEL-4710 - Hiding endpoints using @Hidden (#10431) * Added code for checking if a class is abstract or not. * Renamed test name as per review comments. * BAEL-4695 - Added code to evaluate math expressions. * BAEL-4695 - Added test case for math function. * BAEL-4695 Added consistent examples and entry in parent pom. * BAEL-4695 - Added more examples * BAEL-4710 - Hiding endpoints using @Hidden --- .../controller/RegularRestController.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/controller/RegularRestController.java diff --git a/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/controller/RegularRestController.java b/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/controller/RegularRestController.java new file mode 100644 index 0000000000..f3135229d6 --- /dev/null +++ b/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/controller/RegularRestController.java @@ -0,0 +1,31 @@ +package com.baeldung.springdoc.controller; + +import java.time.LocalDate; +import java.time.LocalTime; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.swagger.v3.oas.annotations.Hidden; + +@Hidden +@RestController +public class RegularRestController { + + @Hidden + @GetMapping("/getAuthor") + public String getAuthor() { + return "Umang Budhwar"; + } + + @GetMapping("/getDate") + public LocalDate getDate() { + return LocalDate.now(); + } + + @GetMapping("/getTime") + public LocalTime getTime() { + return LocalTime.now(); + } + +} From 609c4db4fba6764034ea94394ed4ec8c4413a3c5 Mon Sep 17 00:00:00 2001 From: Yavuz Tas <12643010+yavuztas@users.noreply.github.com> Date: Tue, 26 Jan 2021 16:10:30 +0100 Subject: [PATCH 310/361] BAEL-3828 Where Should @Service Annotation Be Kept? (#10430) * BAEL-3828 add code samples and tests for the article * BAEL-3828 fix maven test folder structure and test executions * BAEL-3828 fix indentation in continuation lines --- .../annotations/service/AuthApplication.java | 22 ++++++++ .../AbstractAuthenticationService.java | 12 +++++ .../InMemoryAuthenticationService.java | 14 +++++ .../concretes/LdapAuthenticationService.java | 14 +++++ .../interfaces/AuthenticationService.java | 10 ++++ .../EmployeeApplicationUnitTest.java} | 2 +- .../service/AuthApplicationUnitTest.java | 51 +++++++++++++++++++ .../AbstractsAnnotatedTestConfiguration.java | 10 ++++ ...reteClassesAnnotatedTestConfiguration.java | 10 ++++ .../InterfacesAnnotatedTestConfiguration.java | 10 ++++ 10 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/AuthApplication.java create mode 100644 spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/abstracts/AbstractAuthenticationService.java create mode 100644 spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/concretes/InMemoryAuthenticationService.java create mode 100644 spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/concretes/LdapAuthenticationService.java create mode 100644 spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/interfaces/AuthenticationService.java rename spring-boot-modules/spring-boot-annotations/src/{main/test/com.baeldung.annotations/EmployeeApplicationTest.java => test/java/com.baeldung.annotations/EmployeeApplicationUnitTest.java} (96%) create mode 100644 spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/service/AuthApplicationUnitTest.java create mode 100644 spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/service/config/AbstractsAnnotatedTestConfiguration.java create mode 100644 spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/service/config/ConcreteClassesAnnotatedTestConfiguration.java create mode 100644 spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/service/config/InterfacesAnnotatedTestConfiguration.java diff --git a/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/AuthApplication.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/AuthApplication.java new file mode 100644 index 0000000000..fa5770b08e --- /dev/null +++ b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/AuthApplication.java @@ -0,0 +1,22 @@ +package com.baeldung.annotations.service; + +import com.baeldung.annotations.service.abstracts.AbstractAuthenticationService; +import com.baeldung.annotations.service.interfaces.AuthenticationService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class AuthApplication { + + @Autowired + private AuthenticationService inMemoryAuthService; + + @Autowired + private AbstractAuthenticationService ldapAuthService; + + public static void main(String[] args) { + SpringApplication.run(AuthApplication.class, args); + } + +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/abstracts/AbstractAuthenticationService.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/abstracts/AbstractAuthenticationService.java new file mode 100644 index 0000000000..47fac229f7 --- /dev/null +++ b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/abstracts/AbstractAuthenticationService.java @@ -0,0 +1,12 @@ +package com.baeldung.annotations.service.abstracts; + +import org.springframework.stereotype.Service; + +@Service +public abstract class AbstractAuthenticationService { + + public boolean authenticate(String username, String password) { + return false; + } + +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/concretes/InMemoryAuthenticationService.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/concretes/InMemoryAuthenticationService.java new file mode 100644 index 0000000000..8f80cb8593 --- /dev/null +++ b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/concretes/InMemoryAuthenticationService.java @@ -0,0 +1,14 @@ +package com.baeldung.annotations.service.concretes; + +import com.baeldung.annotations.service.interfaces.AuthenticationService; +import org.springframework.stereotype.Service; + +@Service +public class InMemoryAuthenticationService implements AuthenticationService { + + @Override + public boolean authenticate(String username, String password) { + return false; + } + +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/concretes/LdapAuthenticationService.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/concretes/LdapAuthenticationService.java new file mode 100644 index 0000000000..af93ea13be --- /dev/null +++ b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/concretes/LdapAuthenticationService.java @@ -0,0 +1,14 @@ +package com.baeldung.annotations.service.concretes; + +import com.baeldung.annotations.service.abstracts.AbstractAuthenticationService; +import org.springframework.stereotype.Service; + +@Service +public class LdapAuthenticationService extends AbstractAuthenticationService { + + @Override + public boolean authenticate(String username, String password) { + return true; + } + +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/interfaces/AuthenticationService.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/interfaces/AuthenticationService.java new file mode 100644 index 0000000000..0537343266 --- /dev/null +++ b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/service/interfaces/AuthenticationService.java @@ -0,0 +1,10 @@ +package com.baeldung.annotations.service.interfaces; + +import org.springframework.stereotype.Service; + +@Service +public interface AuthenticationService { + + boolean authenticate(String username, String password); + +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-annotations/src/main/test/com.baeldung.annotations/EmployeeApplicationTest.java b/spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/EmployeeApplicationUnitTest.java similarity index 96% rename from spring-boot-modules/spring-boot-annotations/src/main/test/com.baeldung.annotations/EmployeeApplicationTest.java rename to spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/EmployeeApplicationUnitTest.java index 66700cf781..8dfc743f3d 100644 --- a/spring-boot-modules/spring-boot-annotations/src/main/test/com.baeldung.annotations/EmployeeApplicationTest.java +++ b/spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/EmployeeApplicationUnitTest.java @@ -6,7 +6,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertAll; -public class EmployeeApplicationTest { +public class EmployeeApplicationUnitTest { private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withUserConfiguration(EmployeeApplication.class); diff --git a/spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/service/AuthApplicationUnitTest.java b/spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/service/AuthApplicationUnitTest.java new file mode 100644 index 0000000000..ecbf1b38e5 --- /dev/null +++ b/spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/service/AuthApplicationUnitTest.java @@ -0,0 +1,51 @@ +package com.baeldung.annotations.service; + +import com.baeldung.annotations.service.abstracts.AbstractAuthenticationService; +import com.baeldung.annotations.service.config.AbstractsAnnotatedTestConfiguration; +import com.baeldung.annotations.service.config.ConcreteClassesAnnotatedTestConfiguration; +import com.baeldung.annotations.service.config.InterfacesAnnotatedTestConfiguration; +import com.baeldung.annotations.service.interfaces.AuthenticationService; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.boot.test.context.runner.ApplicationContextRunner; + +public class AuthApplicationUnitTest { + + private final ApplicationContextRunner contextRunner = new ApplicationContextRunner(); + + @Test + void whenOnlyInterfacesAnnotated_noSuchBeanDefinitionExceptionThrown() { + contextRunner + .withUserConfiguration(InterfacesAnnotatedTestConfiguration.class) + .run(context -> { + Assertions.assertThrows(NoSuchBeanDefinitionException.class, () -> { + context.getBean(AuthenticationService.class); + }); + }); + } + + @Test + void whenOnlyAbstractClassesAnnotated_noSuchBeanDefinitionExceptionThrown() { + contextRunner + .withUserConfiguration(AbstractsAnnotatedTestConfiguration.class) + .run(context -> { + Assertions.assertThrows(NoSuchBeanDefinitionException.class, () -> { + context.getBean(AbstractAuthenticationService.class); + }); + }); + } + + @Test + void whenConcreteClassesAnnotated_noExceptionThrown() { + contextRunner + .withUserConfiguration(ConcreteClassesAnnotatedTestConfiguration.class) + .run(context -> { + AuthenticationService inMemoryAuthService = context.getBean(AuthenticationService.class); + AbstractAuthenticationService ldapAuthService = context.getBean(AbstractAuthenticationService.class); + + Assertions.assertNotNull(inMemoryAuthService); + Assertions.assertNotNull(ldapAuthService); + }); + } +} diff --git a/spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/service/config/AbstractsAnnotatedTestConfiguration.java b/spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/service/config/AbstractsAnnotatedTestConfiguration.java new file mode 100644 index 0000000000..4c52401a06 --- /dev/null +++ b/spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/service/config/AbstractsAnnotatedTestConfiguration.java @@ -0,0 +1,10 @@ +package com.baeldung.annotations.service.config; + +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.context.annotation.ComponentScan; + +@TestConfiguration +@ComponentScan("com.baeldung.annotations.service.abstracts") +public class AbstractsAnnotatedTestConfiguration { + +} diff --git a/spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/service/config/ConcreteClassesAnnotatedTestConfiguration.java b/spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/service/config/ConcreteClassesAnnotatedTestConfiguration.java new file mode 100644 index 0000000000..baf7fb970c --- /dev/null +++ b/spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/service/config/ConcreteClassesAnnotatedTestConfiguration.java @@ -0,0 +1,10 @@ +package com.baeldung.annotations.service.config; + +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.context.annotation.ComponentScan; + +@TestConfiguration +@ComponentScan("com.baeldung.annotations.service.concretes") +public class ConcreteClassesAnnotatedTestConfiguration { + +} diff --git a/spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/service/config/InterfacesAnnotatedTestConfiguration.java b/spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/service/config/InterfacesAnnotatedTestConfiguration.java new file mode 100644 index 0000000000..94659902a1 --- /dev/null +++ b/spring-boot-modules/spring-boot-annotations/src/test/java/com.baeldung.annotations/service/config/InterfacesAnnotatedTestConfiguration.java @@ -0,0 +1,10 @@ +package com.baeldung.annotations.service.config; + +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.context.annotation.ComponentScan; + +@TestConfiguration +@ComponentScan("com.baeldung.annotations.service.interfaces") +public class InterfacesAnnotatedTestConfiguration { + +} From 384b89d3ea78c39568fadf8e6a051f670952e398 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Tue, 26 Jan 2021 12:57:49 -0300 Subject: [PATCH 311/361] added response timeout to timeout configuration --- .../com/baeldung/web/client/WebClientIntegrationTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java index 01de550a9c..f54d8a6c3d 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java @@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import java.net.URI; import java.nio.charset.StandardCharsets; +import java.time.Duration; import java.time.ZonedDateTime; import java.util.Collections; import java.util.Map; @@ -116,7 +117,7 @@ public class WebClientIntegrationTest { .bodyToMono(String.class); Mono responsePostWithBody2 = headerSpecPost2.retrieve() .bodyToMono(String.class); - Mono responsePostWithBody3 = headerSpecPost2.retrieve() + Mono responsePostWithBody3 = headerSpecPost3.retrieve() .bodyToMono(String.class); Mono responsePostFoo = headerSpecFooPost.retrieve() .bodyToMono(String.class); @@ -168,6 +169,7 @@ public class WebClientIntegrationTest { public void givenWebClientWithTimeoutConfigurations_whenRequestUsingWronglyConfiguredPublisher_thenObtainTimeout() { HttpClient httpClient = HttpClient.create() .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 1000) + .responseTimeout(Duration.ofMillis(1000)) .doOnConnected(conn -> conn.addHandlerLast(new ReadTimeoutHandler(1000, TimeUnit.MILLISECONDS)) .addHandlerLast(new WriteTimeoutHandler(1000, TimeUnit.MILLISECONDS))); From f8ca77bc71323ac704fb138db497e05b4bd11562 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Tue, 26 Jan 2021 16:05:31 -0300 Subject: [PATCH 312/361] fixed and improved reactive tests not getting verified --- .../web/client/WebClientIntegrationTest.java | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java index f54d8a6c3d..cbf11766e1 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java @@ -1,7 +1,6 @@ package com.baeldung.web.client; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.api.Assertions.assertThrows; import java.net.URI; import java.nio.charset.StandardCharsets; @@ -42,7 +41,6 @@ import com.baeldung.web.reactive.client.Foo; import com.baeldung.web.reactive.client.WebClientApplication; import io.netty.channel.ChannelOption; -import io.netty.channel.ConnectTimeoutException; import io.netty.handler.timeout.ReadTimeoutHandler; import io.netty.handler.timeout.WriteTimeoutHandler; import reactor.core.publisher.Mono; @@ -129,40 +127,45 @@ public class WebClientIntegrationTest { assertThat(responseHandler.statusCode()).isEqualTo(HttpStatus.BAD_REQUEST); return responseHandler.bodyToMono(ref); }); + Mono responsePostOverridenBaseUri = bodySpecOverridenBaseUri.retrieve() + .bodyToMono(String.class); // response assertions StepVerifier.create(responsePostString) - .expectNext("processed-bodyValue"); + .expectNext("processed-bodyValue") + .verifyComplete(); StepVerifier.create(responsePostMultipart) - .expectNext("processed-multipartValue1-multipartValue2"); + .expectNext("processed-multipartValue1-multipartValue2") + .verifyComplete(); StepVerifier.create(responsePostWithBody1) - .expectNext("processed-bodyValue"); + .expectNext("processed-bodyValue") + .verifyComplete(); StepVerifier.create(responsePostWithBody2) - .expectNext("processed-bodyValue"); + .expectNext("processed-bodyValue") + .verifyComplete(); StepVerifier.create(responsePostWithBody3) - .expectNext("processed-bodyValue"); + .expectNext("processed-bodyValue") + .verifyComplete(); StepVerifier.create(responseGet) .expectNextMatches(nextMap -> nextMap.get("field") - .equals("value")); + .equals("value")) + .verifyComplete(); StepVerifier.create(responsePostFoo) - .expectNext("processedFoo-fooName"); + .expectNext("processedFoo-fooName") + .verifyComplete(); StepVerifier.create(responsePostWithNoBody) .expectNextMatches(nextMap -> nextMap.get("error") - .equals("Bad Request")); - - // assert sending plain `new Object()` as request body - assertThrows(CodecException.class, () -> { - headerSpecInserterObject.exchangeToMono(response -> response.bodyToMono(String.class)) - .block(); - }); + .equals("Bad Request")) + .verifyComplete(); // assert sending request overriding base uri - Exception exception = assertThrows(WebClientRequestException.class, () -> { - bodySpecOverridenBaseUri.retrieve() - .bodyToMono(String.class) - .block(); - }); - assertThat(exception.getMessage()).contains("Connection refused"); - + StepVerifier.create(responsePostOverridenBaseUri) + .expectErrorMatches(ex -> WebClientRequestException.class.isAssignableFrom(ex.getClass()) && ex.getMessage() + .contains("Connection refused")) + .verify(); + // assert error plain `new Object()` as request body + StepVerifier.create(headerSpecInserterObject.exchangeToMono(response -> response.bodyToMono(String.class))) + .expectError(CodecException.class) + .verify(); } @Test @@ -181,12 +184,11 @@ public class WebClientIntegrationTest { RequestHeadersSpec headerSpecInserterCompleteSuscriber = timeoutClient.post() .uri("/resource") .body(inserterCompleteSuscriber); - WebClientRequestException exception = assertThrows(WebClientRequestException.class, () -> { - headerSpecInserterCompleteSuscriber.retrieve() - .bodyToMono(String.class) - .block(); - }); - assertThat(exception.getCause()).isInstanceOf(ConnectTimeoutException.class); + + StepVerifier.create(headerSpecInserterCompleteSuscriber.retrieve() + .bodyToMono(String.class)) + .expectTimeout(Duration.ofMillis(2000)) + .verify(); } private RequestBodyUriSpec createDefaultPostRequest() { From d87cd065aa9ecb87dd080cce8b9b4dc14203a341 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Tue, 26 Jan 2021 16:31:14 -0300 Subject: [PATCH 313/361] cleaned WebClient. definition for spec, for consistency and simplicity --- .../com/baeldung/web/client/WebClientIntegrationTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java index cbf11766e1..c8a306c4bc 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java @@ -66,8 +66,8 @@ public class WebClientIntegrationTest { .build(); // request specification - UriSpec uriSpecPost1 = client1.method(HttpMethod.POST); - UriSpec uriSpecPost2 = client2.post(); + UriSpec uriSpecPost1 = client1.method(HttpMethod.POST); + UriSpec uriSpecPost2 = client2.post(); UriSpec requestGet = client3.get(); // uri specification From 32f35285754fc004ad48e08a645dc2759b0b851a Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Tue, 26 Jan 2021 17:41:44 -0300 Subject: [PATCH 314/361] added more common exchangeToMono example for article --- .../web/client/WebClientIntegrationTest.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java index c8a306c4bc..9116ff3e63 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java @@ -115,8 +115,18 @@ public class WebClientIntegrationTest { .bodyToMono(String.class); Mono responsePostWithBody2 = headerSpecPost2.retrieve() .bodyToMono(String.class); - Mono responsePostWithBody3 = headerSpecPost3.retrieve() - .bodyToMono(String.class); + Mono responsePostWithBody3 = headerSpecPost3.exchangeToMono(response -> { + if (response.statusCode() + .equals(HttpStatus.OK)) { + return response.bodyToMono(String.class); + } else if (response.statusCode() + .is4xxClientError()) { + return Mono.just("Error response"); + } else { + return response.createException() + .flatMap(Mono::error); + } + }); Mono responsePostFoo = headerSpecFooPost.retrieve() .bodyToMono(String.class); ParameterizedTypeReference> ref = new ParameterizedTypeReference>() { From 0f668a63b91dadf4a9e5dc479a38f1d8c954a33b Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Tue, 26 Jan 2021 17:53:48 -0300 Subject: [PATCH 315/361] renamed headersSpec to match article --- .../web/client/WebClientIntegrationTest.java | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java index 9116ff3e63..49edf422b0 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java @@ -79,11 +79,11 @@ public class WebClientIntegrationTest { // request body specifications String bodyValue = "bodyValue"; - RequestHeadersSpec headerSpecPost1 = bodySpecPost.body(BodyInserters.fromPublisher(Mono.just(bodyValue), String.class)); - RequestHeadersSpec headerSpecPost2 = createDefaultPostResourceRequest().body(BodyInserters.fromValue(bodyValue)); - RequestHeadersSpec headerSpecPost3 = createDefaultPostResourceRequest().bodyValue(bodyValue); - RequestHeadersSpec headerSpecFooPost = fooBodySpecPost.body(Mono.just(new Foo("fooName")), Foo.class); - RequestHeadersSpec headerSpecGet = requestGet.uri("/resource"); + RequestHeadersSpec headersSpecPost1 = bodySpecPost.body(BodyInserters.fromPublisher(Mono.just(bodyValue), String.class)); + RequestHeadersSpec headersSpecPost2 = createDefaultPostResourceRequest().body(BodyInserters.fromValue(bodyValue)); + RequestHeadersSpec headersSpecPost3 = createDefaultPostResourceRequest().bodyValue(bodyValue); + RequestHeadersSpec headersSpecFooPost = fooBodySpecPost.body(Mono.just(new Foo("fooName")), Foo.class); + RequestHeadersSpec headersSpecGet = requestGet.uri("/resource"); // request body specifications - using inserters LinkedMultiValueMap map = new LinkedMultiValueMap<>(); @@ -94,28 +94,28 @@ public class WebClientIntegrationTest { BodyInserter inserterObject = BodyInserters.fromValue(new Object()); BodyInserter inserterString = BodyInserters.fromValue(bodyValue); - RequestHeadersSpec headerSpecInserterMultipart = bodySpecPostMultipart.body(inserterMultipart); - RequestHeadersSpec headerSpecInserterObject = createDefaultPostResourceRequest().body(inserterObject); - RequestHeadersSpec headerSpecInserterString = createDefaultPostResourceRequest().body(inserterString); + RequestHeadersSpec headersSpecInserterMultipart = bodySpecPostMultipart.body(inserterMultipart); + RequestHeadersSpec headersSpecInserterObject = createDefaultPostResourceRequest().body(inserterObject); + RequestHeadersSpec headersSpecInserterString = createDefaultPostResourceRequest().body(inserterString); // request header specification - RequestHeadersSpec headerSpecInserterStringWithHeaders = headerSpecInserterString.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + RequestHeadersSpec headersSpecInserterStringWithHeaders = headersSpecInserterString.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) .accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML) .acceptCharset(StandardCharsets.UTF_8) .ifNoneMatch("*") .ifModifiedSince(ZonedDateTime.now()); // request - ResponseSpec responseSpecPostString = headerSpecInserterStringWithHeaders.retrieve(); + ResponseSpec responseSpecPostString = headersSpecInserterStringWithHeaders.retrieve(); Mono responsePostString = responseSpecPostString.bodyToMono(String.class); - Mono responsePostMultipart = headerSpecInserterMultipart.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE) + Mono responsePostMultipart = headersSpecInserterMultipart.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE) .retrieve() .bodyToMono(String.class); - Mono responsePostWithBody1 = headerSpecPost1.retrieve() + Mono responsePostWithBody1 = headersSpecPost1.retrieve() .bodyToMono(String.class); - Mono responsePostWithBody2 = headerSpecPost2.retrieve() + Mono responsePostWithBody2 = headersSpecPost2.retrieve() .bodyToMono(String.class); - Mono responsePostWithBody3 = headerSpecPost3.exchangeToMono(response -> { + Mono responsePostWithBody3 = headersSpecPost3.exchangeToMono(response -> { if (response.statusCode() .equals(HttpStatus.OK)) { return response.bodyToMono(String.class); @@ -127,11 +127,11 @@ public class WebClientIntegrationTest { .flatMap(Mono::error); } }); - Mono responsePostFoo = headerSpecFooPost.retrieve() + Mono responsePostFoo = headersSpecFooPost.retrieve() .bodyToMono(String.class); ParameterizedTypeReference> ref = new ParameterizedTypeReference>() { }; - Mono> responseGet = headerSpecGet.retrieve() + Mono> responseGet = headersSpecGet.retrieve() .bodyToMono(ref); Mono> responsePostWithNoBody = createDefaultPostResourceRequest().exchangeToMono(responseHandler -> { assertThat(responseHandler.statusCode()).isEqualTo(HttpStatus.BAD_REQUEST); @@ -173,7 +173,7 @@ public class WebClientIntegrationTest { .contains("Connection refused")) .verify(); // assert error plain `new Object()` as request body - StepVerifier.create(headerSpecInserterObject.exchangeToMono(response -> response.bodyToMono(String.class))) + StepVerifier.create(headersSpecInserterObject.exchangeToMono(response -> response.bodyToMono(String.class))) .expectError(CodecException.class) .verify(); } @@ -191,11 +191,11 @@ public class WebClientIntegrationTest { .build(); BodyInserter, ReactiveHttpOutputMessage> inserterCompleteSuscriber = BodyInserters.fromPublisher(Subscriber::onComplete, String.class); - RequestHeadersSpec headerSpecInserterCompleteSuscriber = timeoutClient.post() + RequestHeadersSpec headersSpecInserterCompleteSuscriber = timeoutClient.post() .uri("/resource") .body(inserterCompleteSuscriber); - StepVerifier.create(headerSpecInserterCompleteSuscriber.retrieve() + StepVerifier.create(headersSpecInserterCompleteSuscriber.retrieve() .bodyToMono(String.class)) .expectTimeout(Duration.ofMillis(2000)) .verify(); From c477f22f27fbe4c3900fa5e5ea79223e9dc255b6 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Tue, 26 Jan 2021 18:17:17 -0300 Subject: [PATCH 316/361] modified url override example, to use the client3 (the one defining the baseUrl) --- .../java/com/baeldung/web/client/WebClientIntegrationTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java index 49edf422b0..eddbf74868 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java @@ -75,7 +75,8 @@ public class WebClientIntegrationTest { RequestBodySpec bodySpecPostMultipart = uriSpecPost2.uri(uriBuilder -> uriBuilder.pathSegment("resource-multipart") .build()); RequestBodySpec fooBodySpecPost = createDefaultPostRequest().uri("/resource-foo"); - RequestBodySpec bodySpecOverridenBaseUri = createDefaultPostRequest().uri(URI.create("/resource")); + RequestBodySpec bodySpecOverridenBaseUri = client3.post() + .uri(URI.create("/resource")); // request body specifications String bodyValue = "bodyValue"; From 047dfdef258719a8c91bde81329075f2dc5dc589 Mon Sep 17 00:00:00 2001 From: Gerardo Roza Date: Wed, 27 Jan 2021 12:28:41 -0300 Subject: [PATCH 317/361] split integration test into different test scenarios, one for each step in the webclient process --- .../web/client/WebClientIntegrationTest.java | 266 +++++++++++++----- 1 file changed, 192 insertions(+), 74 deletions(-) diff --git a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java index eddbf74868..39adf0b5c0 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/web/client/WebClientIntegrationTest.java @@ -33,8 +33,8 @@ import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClient.RequestBodySpec; import org.springframework.web.reactive.function.client.WebClient.RequestBodyUriSpec; import org.springframework.web.reactive.function.client.WebClient.RequestHeadersSpec; +import org.springframework.web.reactive.function.client.WebClient.RequestHeadersUriSpec; import org.springframework.web.reactive.function.client.WebClient.ResponseSpec; -import org.springframework.web.reactive.function.client.WebClient.UriSpec; import org.springframework.web.reactive.function.client.WebClientRequestException; import com.baeldung.web.reactive.client.Foo; @@ -53,9 +53,13 @@ public class WebClientIntegrationTest { @LocalServerPort private int port; + private static final String BODY_VALUE = "bodyValue"; + private static final ParameterizedTypeReference> MAP_RESPONSE_REF = new ParameterizedTypeReference>() { + }; + @Test - public void givenDifferentScenarios_whenRequestsSent_thenObtainExpectedResponses() { - // WebClient + public void givenDifferentWebClientCreationMethods_whenUsed_thenObtainExpectedResponse() { + // WebClient creation WebClient client1 = WebClient.create(); WebClient client2 = WebClient.create("http://localhost:" + port); WebClient client3 = WebClient.builder() @@ -65,58 +69,149 @@ public class WebClientIntegrationTest { .defaultUriVariables(Collections.singletonMap("url", "http://localhost:8080")) .build(); - // request specification - UriSpec uriSpecPost1 = client1.method(HttpMethod.POST); - UriSpec uriSpecPost2 = client2.post(); - UriSpec requestGet = client3.get(); + // response assertions + StepVerifier.create(retrieveResponse(client1.post() + .uri("http://localhost:" + port + "/resource"))) + .expectNext("processed-bodyValue") + .verifyComplete(); + StepVerifier.create(retrieveResponse(client2)) + .expectNext("processed-bodyValue") + .verifyComplete(); + StepVerifier.create(retrieveResponse(client3)) + .expectNext("processed-bodyValue") + .verifyComplete(); + // assert response without specifying URI + StepVerifier.create(retrieveResponse(client1)) + .expectErrorMatches(ex -> WebClientRequestException.class.isAssignableFrom(ex.getClass()) && ex.getMessage() + .contains("Connection refused")) + .verify(); + } + @Test + public void givenDifferentMethodSpecifications_whenUsed_thenObtainExpectedResponse() { + // request specification + RequestBodyUriSpec uriSpecPost1 = createDefaultClient().method(HttpMethod.POST); + RequestBodyUriSpec uriSpecPost2 = createDefaultClient().post(); + RequestHeadersUriSpec requestGet = createDefaultClient().get(); + + // response assertions + StepVerifier.create(retrieveResponse(uriSpecPost1)) + .expectNext("processed-bodyValue") + .verifyComplete(); + StepVerifier.create(retrieveResponse(uriSpecPost2)) + .expectNext("processed-bodyValue") + .verifyComplete(); + StepVerifier.create(retrieveGetResponse(requestGet)) + .expectNextMatches(nextMap -> nextMap.get("field") + .equals("value")) + .verifyComplete(); + } + + @Test + public void givenDifferentUriSpecifications_whenUsed_thenObtainExpectedResponse() { // uri specification - RequestBodySpec bodySpecPost = uriSpecPost1.uri("http://localhost:" + port + "/resource"); - RequestBodySpec bodySpecPostMultipart = uriSpecPost2.uri(uriBuilder -> uriBuilder.pathSegment("resource-multipart") + RequestBodySpec bodySpecUsingString = createDefaultPostRequest().uri("/resource"); + RequestBodySpec bodySpecUsingUriBuilder = createDefaultPostRequest().uri(uriBuilder -> uriBuilder.pathSegment("resource") .build()); - RequestBodySpec fooBodySpecPost = createDefaultPostRequest().uri("/resource-foo"); - RequestBodySpec bodySpecOverridenBaseUri = client3.post() + RequestBodySpec bodySpecusingURI = createDefaultPostRequest().uri(URI.create("http://localhost:" + port + "/resource")); + RequestBodySpec bodySpecOverridenBaseUri = createDefaultPostRequest().uri(URI.create("/resource")); + RequestBodySpec bodySpecOverridenBaseUri2 = WebClient.builder() + .baseUrl("http://localhost:" + port) + .build() + .post() .uri(URI.create("/resource")); - // request body specifications - String bodyValue = "bodyValue"; - RequestHeadersSpec headersSpecPost1 = bodySpecPost.body(BodyInserters.fromPublisher(Mono.just(bodyValue), String.class)); - RequestHeadersSpec headersSpecPost2 = createDefaultPostResourceRequest().body(BodyInserters.fromValue(bodyValue)); - RequestHeadersSpec headersSpecPost3 = createDefaultPostResourceRequest().bodyValue(bodyValue); - RequestHeadersSpec headersSpecFooPost = fooBodySpecPost.body(Mono.just(new Foo("fooName")), Foo.class); - RequestHeadersSpec headersSpecGet = requestGet.uri("/resource"); + // response assertions + StepVerifier.create(retrieveResponse(bodySpecUsingString)) + .expectNext("processed-bodyValue") + .verifyComplete(); + StepVerifier.create(retrieveResponse(bodySpecUsingUriBuilder)) + .expectNext("processed-bodyValue") + .verifyComplete(); + StepVerifier.create(retrieveResponse(bodySpecusingURI)) + .expectNext("processed-bodyValue") + .verifyComplete(); + // assert sending request overriding base URI + StepVerifier.create(retrieveResponse(bodySpecOverridenBaseUri)) + .expectErrorMatches(ex -> WebClientRequestException.class.isAssignableFrom(ex.getClass()) && ex.getMessage() + .contains("Connection refused")) + .verify(); + StepVerifier.create(retrieveResponse(bodySpecOverridenBaseUri2)) + .expectErrorMatches(ex -> WebClientRequestException.class.isAssignableFrom(ex.getClass()) && ex.getMessage() + .contains("Connection refused")) + .verify(); + } - // request body specifications - using inserters + @Test + public void givenDifferentBodySpecifications_whenUsed_thenObtainExpectedResponse() { + // request body specifications + RequestHeadersSpec headersSpecPost1 = createDefaultPostResourceRequest().body(BodyInserters.fromPublisher(Mono.just(BODY_VALUE), String.class)); + RequestHeadersSpec headersSpecPost2 = createDefaultPostResourceRequest().body(BodyInserters.fromValue(BODY_VALUE)); + RequestHeadersSpec headersSpecPost3 = createDefaultPostResourceRequest().bodyValue(BODY_VALUE); + RequestHeadersSpec headersSpecFooPost = createDefaultPostRequest().uri("/resource-foo") + .body(Mono.just(new Foo("fooName")), Foo.class); + BodyInserter inserterPlainObject = BodyInserters.fromValue(new Object()); + RequestHeadersSpec headersSpecPlainObject = createDefaultPostResourceRequest().body(inserterPlainObject); + + // request body specifications - using other inserter method (multipart request) LinkedMultiValueMap map = new LinkedMultiValueMap<>(); map.add("key1", "multipartValue1"); map.add("key2", "multipartValue2"); - BodyInserter, ClientHttpRequest> inserterMultipart = BodyInserters.fromMultipartData(map); - BodyInserter inserterObject = BodyInserters.fromValue(new Object()); - BodyInserter inserterString = BodyInserters.fromValue(bodyValue); + RequestHeadersSpec headersSpecInserterMultipart = createDefaultPostRequest().uri("/resource-multipart") + .body(inserterMultipart); - RequestHeadersSpec headersSpecInserterMultipart = bodySpecPostMultipart.body(inserterMultipart); - RequestHeadersSpec headersSpecInserterObject = createDefaultPostResourceRequest().body(inserterObject); - RequestHeadersSpec headersSpecInserterString = createDefaultPostResourceRequest().body(inserterString); + // response assertions + StepVerifier.create(retrieveResponse(headersSpecPost1)) + .expectNext("processed-bodyValue") + .verifyComplete(); + StepVerifier.create(retrieveResponse(headersSpecPost2)) + .expectNext("processed-bodyValue") + .verifyComplete(); + StepVerifier.create(retrieveResponse(headersSpecPost3)) + .expectNext("processed-bodyValue") + .verifyComplete(); + StepVerifier.create(retrieveResponse(headersSpecFooPost)) + .expectNext("processedFoo-fooName") + .verifyComplete(); + StepVerifier.create(retrieveResponse(headersSpecInserterMultipart)) + .expectNext("processed-multipartValue1-multipartValue2") + .verifyComplete(); + // assert error plain `new Object()` as request body + StepVerifier.create(retrieveResponse(headersSpecPlainObject)) + .expectError(CodecException.class) + .verify(); + // assert response for request with no body + Mono> responsePostWithNoBody = createDefaultPostResourceRequest().exchangeToMono(responseHandler -> { + assertThat(responseHandler.statusCode()).isEqualTo(HttpStatus.BAD_REQUEST); + return responseHandler.bodyToMono(MAP_RESPONSE_REF); + }); + StepVerifier.create(responsePostWithNoBody) + .expectNextMatches(nextMap -> nextMap.get("error") + .equals("Bad Request")) + .verifyComplete(); + } + @Test + public void givenPostSpecifications_whenHeadersAdded_thenObtainExpectedResponse() { // request header specification - RequestHeadersSpec headersSpecInserterStringWithHeaders = headersSpecInserterString.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) + RequestHeadersSpec headersSpecInserterStringWithHeaders = createDefaultPostResourceRequestResponse().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) .accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML) .acceptCharset(StandardCharsets.UTF_8) .ifNoneMatch("*") .ifModifiedSince(ZonedDateTime.now()); - // request - ResponseSpec responseSpecPostString = headersSpecInserterStringWithHeaders.retrieve(); + // response assertions + StepVerifier.create(retrieveResponse(headersSpecInserterStringWithHeaders)) + .expectNext("processed-bodyValue") + .verifyComplete(); + } + + @Test + public void givenDifferentResponseSpecifications_whenUsed_thenObtainExpectedResponse() { + ResponseSpec responseSpecPostString = createDefaultPostResourceRequestResponse().retrieve(); Mono responsePostString = responseSpecPostString.bodyToMono(String.class); - Mono responsePostMultipart = headersSpecInserterMultipart.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE) - .retrieve() - .bodyToMono(String.class); - Mono responsePostWithBody1 = headersSpecPost1.retrieve() - .bodyToMono(String.class); - Mono responsePostWithBody2 = headersSpecPost2.retrieve() - .bodyToMono(String.class); - Mono responsePostWithBody3 = headersSpecPost3.exchangeToMono(response -> { + Mono responsePostString2 = createDefaultPostResourceRequestResponse().exchangeToMono(response -> { if (response.statusCode() .equals(HttpStatus.OK)) { return response.bodyToMono(String.class); @@ -128,55 +223,37 @@ public class WebClientIntegrationTest { .flatMap(Mono::error); } }); - Mono responsePostFoo = headersSpecFooPost.retrieve() - .bodyToMono(String.class); - ParameterizedTypeReference> ref = new ParameterizedTypeReference>() { - }; - Mono> responseGet = headersSpecGet.retrieve() - .bodyToMono(ref); - Mono> responsePostWithNoBody = createDefaultPostResourceRequest().exchangeToMono(responseHandler -> { - assertThat(responseHandler.statusCode()).isEqualTo(HttpStatus.BAD_REQUEST); - return responseHandler.bodyToMono(ref); + Mono responsePostNoBody = createDefaultPostResourceRequest().exchangeToMono(response -> { + if (response.statusCode() + .equals(HttpStatus.OK)) { + return response.bodyToMono(String.class); + } else if (response.statusCode() + .is4xxClientError()) { + return Mono.just("Error response"); + } else { + return response.createException() + .flatMap(Mono::error); + } }); - Mono responsePostOverridenBaseUri = bodySpecOverridenBaseUri.retrieve() - .bodyToMono(String.class); + Mono> responseGet = createDefaultClient().get() + .uri("/resource") + .retrieve() + .bodyToMono(MAP_RESPONSE_REF); // response assertions StepVerifier.create(responsePostString) .expectNext("processed-bodyValue") .verifyComplete(); - StepVerifier.create(responsePostMultipart) - .expectNext("processed-multipartValue1-multipartValue2") - .verifyComplete(); - StepVerifier.create(responsePostWithBody1) + StepVerifier.create(responsePostString2) .expectNext("processed-bodyValue") .verifyComplete(); - StepVerifier.create(responsePostWithBody2) - .expectNext("processed-bodyValue") - .verifyComplete(); - StepVerifier.create(responsePostWithBody3) - .expectNext("processed-bodyValue") + StepVerifier.create(responsePostNoBody) + .expectNext("Error response") .verifyComplete(); StepVerifier.create(responseGet) .expectNextMatches(nextMap -> nextMap.get("field") .equals("value")) .verifyComplete(); - StepVerifier.create(responsePostFoo) - .expectNext("processedFoo-fooName") - .verifyComplete(); - StepVerifier.create(responsePostWithNoBody) - .expectNextMatches(nextMap -> nextMap.get("error") - .equals("Bad Request")) - .verifyComplete(); - // assert sending request overriding base uri - StepVerifier.create(responsePostOverridenBaseUri) - .expectErrorMatches(ex -> WebClientRequestException.class.isAssignableFrom(ex.getClass()) && ex.getMessage() - .contains("Connection refused")) - .verify(); - // assert error plain `new Object()` as request body - StepVerifier.create(headersSpecInserterObject.exchangeToMono(response -> response.bodyToMono(String.class))) - .expectError(CodecException.class) - .verify(); } @Test @@ -202,12 +279,53 @@ public class WebClientIntegrationTest { .verify(); } + // helper methods to create default instances + private WebClient createDefaultClient() { + return WebClient.create("http://localhost:" + port); + } + private RequestBodyUriSpec createDefaultPostRequest() { - return WebClient.create("http://localhost:" + port) - .post(); + return createDefaultClient().post(); } private RequestBodySpec createDefaultPostResourceRequest() { return createDefaultPostRequest().uri("/resource"); } + + private RequestHeadersSpec createDefaultPostResourceRequestResponse() { + return createDefaultPostResourceRequest().bodyValue(BODY_VALUE); + } + + // helper methods to retrieve a response based on different steps of the process (specs) + private Mono retrieveResponse(WebClient client) { + return client.post() + .uri("/resource") + .bodyValue(BODY_VALUE) + .retrieve() + .bodyToMono(String.class); + } + + private Mono retrieveResponse(RequestBodyUriSpec spec) { + return spec.uri("/resource") + .bodyValue(BODY_VALUE) + .retrieve() + .bodyToMono(String.class); + } + + private Mono> retrieveGetResponse(RequestHeadersUriSpec spec) { + return spec.uri("/resource") + .retrieve() + .bodyToMono(MAP_RESPONSE_REF); + } + + private Mono retrieveResponse(RequestBodySpec spec) { + return spec.bodyValue(BODY_VALUE) + .retrieve() + .bodyToMono(String.class); + } + + private Mono retrieveResponse(RequestHeadersSpec spec) { + return spec.retrieve() + .bodyToMono(String.class); + } } From b6570de6379a1818164aa401ddce8c12f787306c Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 28 Jan 2021 01:11:32 +0800 Subject: [PATCH 318/361] Update README.md --- testing-modules/mockito-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/testing-modules/mockito-2/README.md b/testing-modules/mockito-2/README.md index c7b62182b5..4bd2ff9759 100644 --- a/testing-modules/mockito-2/README.md +++ b/testing-modules/mockito-2/README.md @@ -9,3 +9,4 @@ - [Mockito – Using Spies](https://www.baeldung.com/mockito-spy) - [Using Mockito ArgumentCaptor](https://www.baeldung.com/mockito-argumentcaptor) - [Difference Between when() and doXxx() Methods in Mockito](https://www.baeldung.com/java-mockito-when-vs-do) +- [Overview of Mockito MockSettings](https://www.baeldung.com/mockito-mocksettings) From fe2aab7fb9ccfbd53c54f4e867111f187d357ed4 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 28 Jan 2021 01:21:00 +0800 Subject: [PATCH 319/361] Update README.md --- spring-web-modules/spring-rest-http-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-web-modules/spring-rest-http-2/README.md b/spring-web-modules/spring-rest-http-2/README.md index 97cdc2d068..b5358f888f 100644 --- a/spring-web-modules/spring-rest-http-2/README.md +++ b/spring-web-modules/spring-rest-http-2/README.md @@ -8,3 +8,4 @@ The "REST With Spring 2" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [How to Turn Off Swagger-ui in Production](https://www.baeldung.com/swagger-ui-turn-off-in-production) +- [Setting a Request Timeout for a Spring REST API](https://www.baeldung.com/spring-rest-timeout) From 7634f6a6bd281294188f5056f048477659d3bfd2 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 28 Jan 2021 01:23:32 +0800 Subject: [PATCH 320/361] Update README.md --- performance-tests/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/performance-tests/README.md b/performance-tests/README.md index 27c0363010..09bf6dba1f 100644 --- a/performance-tests/README.md +++ b/performance-tests/README.md @@ -6,6 +6,7 @@ This module contains articles about performance testing. - [Performance of Java Mapping Frameworks](https://www.baeldung.com/java-performance-mapping-frameworks) - [Performance Effects of Exceptions in Java](https://www.baeldung.com/java-exceptions-performance) +- [Is Java a Compiled or Interpreted Language?](https://www.baeldung.com/java-compiled-interpreted) ### Running From a65de428fd776ed6fd10849b172ca2001834fdce Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 28 Jan 2021 01:26:15 +0800 Subject: [PATCH 321/361] Update README.md --- spring-boot-modules/spring-boot-annotations/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-annotations/README.md b/spring-boot-modules/spring-boot-annotations/README.md index 6ead94de86..1b2bca435c 100644 --- a/spring-boot-modules/spring-boot-annotations/README.md +++ b/spring-boot-modules/spring-boot-annotations/README.md @@ -10,3 +10,4 @@ This module contains articles about Spring Boot annotations - [Spring Core Annotations](https://www.baeldung.com/spring-core-annotations) - [Spring Bean Annotations](https://www.baeldung.com/spring-bean-annotations) - [Difference Between @ComponentScan and @EnableAutoConfiguration in Spring Boot](https://www.baeldung.com/spring-componentscan-vs-enableautoconfiguration) +- [Where Should the Spring @Service Annotation Be Kept?](https://www.baeldung.com/spring-service-annotation-placement) From d11f1163abe40a87787fed5c6d0e31ee26357adf Mon Sep 17 00:00:00 2001 From: dvyshd <34768329+dvyshd@users.noreply.github.com> Date: Thu, 28 Jan 2021 23:53:49 +0000 Subject: [PATCH 322/361] BAEL-4719 - Using the Map.Entry Java Class (#10428) * BAEL-4719 Using the Map.Entry Java Class * BAEL-4719 Using the Map.Entry Java Class * BAEL-4719 Change description * BAEL-4719 Feedback from first draft --- .../java/com/baeldung/map/entry/Book.java | 35 +++++++++++++++++++ .../map/entry/MapEntryEfficiencyExample.java | 34 ++++++++++++++++++ .../map/entry/MapEntryTupleExample.java | 25 +++++++++++++ .../baeldung/map/entry/MapEntryUnitTest.java | 33 +++++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 java-collections-maps-3/src/main/java/com/baeldung/map/entry/Book.java create mode 100644 java-collections-maps-3/src/main/java/com/baeldung/map/entry/MapEntryEfficiencyExample.java create mode 100644 java-collections-maps-3/src/main/java/com/baeldung/map/entry/MapEntryTupleExample.java create mode 100644 java-collections-maps-3/src/test/java/com/baeldung/map/entry/MapEntryUnitTest.java diff --git a/java-collections-maps-3/src/main/java/com/baeldung/map/entry/Book.java b/java-collections-maps-3/src/main/java/com/baeldung/map/entry/Book.java new file mode 100644 index 0000000000..7e47e22908 --- /dev/null +++ b/java-collections-maps-3/src/main/java/com/baeldung/map/entry/Book.java @@ -0,0 +1,35 @@ +package com.baeldung.map.entry; + +public class Book { + private String title; + private String author; + + public Book(String title, String author) { + this.title = title; + this.author = author; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + + @Override + public String toString() { + return "Book{" + + "title='" + title + '\'' + + ", author='" + author + '\'' + + '}'; + } +} diff --git a/java-collections-maps-3/src/main/java/com/baeldung/map/entry/MapEntryEfficiencyExample.java b/java-collections-maps-3/src/main/java/com/baeldung/map/entry/MapEntryEfficiencyExample.java new file mode 100644 index 0000000000..d64bcb38df --- /dev/null +++ b/java-collections-maps-3/src/main/java/com/baeldung/map/entry/MapEntryEfficiencyExample.java @@ -0,0 +1,34 @@ +package com.baeldung.map.entry; + +import java.util.HashMap; +import java.util.Map; + +public class MapEntryEfficiencyExample { + + public static void main(String[] args) { + MapEntryEfficiencyExample mapEntryEfficiencyExample = new MapEntryEfficiencyExample(); + Map map = new HashMap<>(); + + map.put("Robert C. Martin", "Clean Code"); + map.put("Joshua Bloch", "Effective Java"); + + System.out.println("Iterating Using Map.KeySet - 2 operations"); + mapEntryEfficiencyExample.usingKeySet(map); + + System.out.println("Iterating Using Map.Entry - 1 operation"); + mapEntryEfficiencyExample.usingEntrySet(map); + + } + + public void usingKeySet(Map bookMap) { + for (String key : bookMap.keySet()) { + System.out.println("key: " + key + " value: " + bookMap.get(key)); + } + } + + public void usingEntrySet(Map bookMap) { + for (Map.Entry book: bookMap.entrySet()) { + System.out.println("key: " + book.getKey() + " value: " + book.getValue()); + } + } +} diff --git a/java-collections-maps-3/src/main/java/com/baeldung/map/entry/MapEntryTupleExample.java b/java-collections-maps-3/src/main/java/com/baeldung/map/entry/MapEntryTupleExample.java new file mode 100644 index 0000000000..edcbd263fe --- /dev/null +++ b/java-collections-maps-3/src/main/java/com/baeldung/map/entry/MapEntryTupleExample.java @@ -0,0 +1,25 @@ +package com.baeldung.map.entry; + +import java.util.*; + +public class MapEntryTupleExample { + + public static void main(String[] args) { + Map.Entry tuple1; + Map.Entry tuple2; + Map.Entry tuple3; + + tuple1 = new AbstractMap.SimpleEntry<>("9780134685991", new Book("Effective Java 3d Edition", "Joshua Bloch")); + tuple2 = new AbstractMap.SimpleEntry<>("9780132350884", new Book("Clean Code", "Robert C Martin")); + tuple3 = new AbstractMap.SimpleEntry<>("9780132350884", new Book("Clean Code", "Robert C Martin")); + + List> orderedTuples = new ArrayList<>(); + orderedTuples.add(tuple1); + orderedTuples.add(tuple2); + orderedTuples.add(tuple3); + + for (Map.Entry tuple : orderedTuples) { + System.out.println("key: " + tuple.getKey() + " value: " + tuple.getValue()); + } + } +} diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/entry/MapEntryUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/entry/MapEntryUnitTest.java new file mode 100644 index 0000000000..7340558023 --- /dev/null +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/entry/MapEntryUnitTest.java @@ -0,0 +1,33 @@ +package com.baeldung.map.entry; + +import org.junit.Test; + +import java.util.*; + +import static org.junit.Assert.assertEquals; + +public class MapEntryUnitTest { + + @Test + public void givenSimpleEntryList_whenAddDuplicateKey_thenDoesNotOverwriteExistingKey() { + List> orderedTuples = new ArrayList<>(); + orderedTuples.add(new AbstractMap.SimpleEntry<>("9780134685991", new Book("Effective Java 3d Edition", "Joshua Bloch"))); + orderedTuples.add(new AbstractMap.SimpleEntry<>("9780132350884", new Book("Clean Code", "Robert C Martin"))); + orderedTuples.add(new AbstractMap.SimpleEntry<>("9780132350884", new Book("Clean Code", "Robert C Martin"))); + + assertEquals(3, orderedTuples.size()); + assertEquals("9780134685991", orderedTuples.get(0).getKey()); + assertEquals("9780132350884", orderedTuples.get(1).getKey()); + assertEquals("9780132350884", orderedTuples.get(2).getKey()); + } + + @Test + public void givenRegularMap_whenAddDuplicateKey_thenOverwritesExistingKey() { + Map entries = new HashMap<>(); + entries.put("9780134685991", new Book("Effective Java 3d Edition", "Joshua Bloch")); + entries.put("9780132350884", new Book("Clean Code", "Robert C Martin")); + entries.put("9780132350884", new Book("Clean Code", "Robert C Martin")); + + assertEquals(2, entries.size()); + } +} From 28fe37cac435bc65feef7fac44c7cc1336762658 Mon Sep 17 00:00:00 2001 From: sampada07 <46674082+sampada07@users.noreply.github.com> Date: Sun, 31 Jan 2021 23:09:23 +0530 Subject: [PATCH 323/361] BAEL-3820: Multiple submit button to a Form (#10457) --- .../springmvcforms/controller/EmployeeController.java | 8 +++++++- .../src/main/webapp/WEB-INF/views/employeeHome.jsp | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/EmployeeController.java b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/EmployeeController.java index 3ece77bb18..478b3532fe 100644 --- a/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/EmployeeController.java +++ b/spring-web-modules/spring-mvc-forms-jsp/src/main/java/com/baeldung/springmvcforms/controller/EmployeeController.java @@ -26,7 +26,7 @@ public class EmployeeController { return employeeMap.get(Id); } - @RequestMapping(value = "/addEmployee", method = RequestMethod.POST) + @RequestMapping(value = "/addEmployee", method = RequestMethod.POST, params = "submit") public String submit(@Valid @ModelAttribute("employee") final Employee employee, final BindingResult result, final ModelMap model) { if (result.hasErrors()) { return "error"; @@ -37,5 +37,11 @@ public class EmployeeController { employeeMap.put(employee.getId(), employee); return "employeeView"; } + + @RequestMapping(value = "/addEmployee", method = RequestMethod.POST, params = "cancel") + public String cancel(@Valid @ModelAttribute("employee") final Employee employee, final BindingResult result, final ModelMap model) { + model.addAttribute("message", "You clicked cancel, please re-enter employee details:"); + return "employeeHome"; + } } diff --git a/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/employeeHome.jsp b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/employeeHome.jsp index 5ed572000a..82f2cbae00 100644 --- a/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/employeeHome.jsp +++ b/spring-web-modules/spring-mvc-forms-jsp/src/main/webapp/WEB-INF/views/employeeHome.jsp @@ -7,6 +7,7 @@

Welcome, Enter The Employee Details

+

${message}

@@ -23,7 +24,8 @@ - + +
From f5bb8ab648a19a0214e88858e00b2bef27943f75 Mon Sep 17 00:00:00 2001 From: "Kent@lhind.hp.g5" Date: Sun, 31 Jan 2021 16:40:50 +0100 Subject: [PATCH 324/361] improvement --- .../check/abstractclass/InterfaceExample.java | 4 +++ .../AbstractExampleUnitTest.java | 26 ++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/check/abstractclass/InterfaceExample.java diff --git a/core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/check/abstractclass/InterfaceExample.java b/core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/check/abstractclass/InterfaceExample.java new file mode 100644 index 0000000000..d226611084 --- /dev/null +++ b/core-java-modules/core-java-reflection-2/src/main/java/com/baeldung/reflection/check/abstractclass/InterfaceExample.java @@ -0,0 +1,4 @@ +package com.baeldung.reflection.check.abstractclass; + +public interface InterfaceExample { +} diff --git a/core-java-modules/core-java-reflection-2/src/test/java/com/baeldung/reflection/check/abstractclass/AbstractExampleUnitTest.java b/core-java-modules/core-java-reflection-2/src/test/java/com/baeldung/reflection/check/abstractclass/AbstractExampleUnitTest.java index cb5d927c23..d9a955ca6d 100644 --- a/core-java-modules/core-java-reflection-2/src/test/java/com/baeldung/reflection/check/abstractclass/AbstractExampleUnitTest.java +++ b/core-java-modules/core-java-reflection-2/src/test/java/com/baeldung/reflection/check/abstractclass/AbstractExampleUnitTest.java @@ -1,16 +1,36 @@ package com.baeldung.reflection.check.abstractclass; -import java.lang.reflect.Modifier; - import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import java.lang.reflect.Modifier; +import java.util.Date; + class AbstractExampleUnitTest { @Test - void givenAbstractClass_whenCheckModifierIsAbstract_thenTrue() throws Exception { + void givenAbstractClass_whenCheckModifierIsAbstract_thenTrue() { Class clazz = AbstractExample.class; Assertions.assertTrue(Modifier.isAbstract(clazz.getModifiers())); } + @Test + void givenInterface_whenCheckModifierIsAbstract_thenTrue() { + Class clazz = InterfaceExample.class; + Assertions.assertTrue(Modifier.isAbstract(clazz.getModifiers())); + } + + @Test + void givenAbstractClass_whenCheckIsAbstractClass_thenTrue() { + Class clazz = AbstractExample.class; + int mod = clazz.getModifiers(); + Assertions.assertTrue(Modifier.isAbstract(mod) && !Modifier.isInterface(mod)); + } + + @Test + void givenConcreteClass_whenCheckIsAbstractClass_thenFalse() { + Class clazz = Date.class; + int mod = clazz.getModifiers(); + Assertions.assertFalse(Modifier.isAbstract(mod) && !Modifier.isInterface(mod)); + } } From b689760b0752e9e3f6697ec699eee59313a5578d Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 1 Feb 2021 11:04:42 +0530 Subject: [PATCH 325/361] JAVA-4312: Update deprecations in spring-5-reactive module --- .../main/java/com/baeldung/functional/FormHandler.java | 4 ++-- .../functional/FunctionalSpringBootApplication.java | 4 ++-- .../baeldung/functional/FunctionalWebApplication.java | 4 ++-- .../main/java/com/baeldung/functional/RootServlet.java | 6 +++--- .../errorhandling/GlobalErrorWebExceptionHandler.java | 10 ++++++---- .../reactive/errorhandling/handlers/Handler1.java | 2 +- .../reactive/errorhandling/handlers/Handler2.java | 4 ++-- .../reactive/errorhandling/handlers/Handler3.java | 4 ++-- .../ExploreSpring5URLPatternUsingRouterFunctions.java | 10 +++++----- .../com/baeldung/reactive/urlmatch/FormHandler.java | 4 ++-- .../reactive/urlmatch/FunctionalWebApplication.java | 4 ++-- .../FunctionalWebApplicationIntegrationTest.java | 6 ++---- .../errorhandling/ErrorHandlingIntegrationTest.java | 4 ++-- 13 files changed, 33 insertions(+), 33 deletions(-) diff --git a/spring-5-reactive/src/main/java/com/baeldung/functional/FormHandler.java b/spring-5-reactive/src/main/java/com/baeldung/functional/FormHandler.java index c4f8c9f41f..2b415d5f1e 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/functional/FormHandler.java +++ b/spring-5-reactive/src/main/java/com/baeldung/functional/FormHandler.java @@ -11,7 +11,7 @@ import java.util.concurrent.atomic.AtomicLong; import static org.springframework.web.reactive.function.BodyExtractors.toDataBuffers; import static org.springframework.web.reactive.function.BodyExtractors.toFormData; -import static org.springframework.web.reactive.function.BodyInserters.fromObject; +import static org.springframework.web.reactive.function.BodyInserters.fromValue; import static org.springframework.web.reactive.function.server.ServerResponse.ok; public class FormHandler { @@ -29,7 +29,7 @@ public class FormHandler { Mono handleUpload(ServerRequest request) { return request.body(toDataBuffers()) .collectList() - .flatMap(dataBuffers -> ok().body(fromObject(extractData(dataBuffers).toString()))); + .flatMap(dataBuffers -> ok().body(fromValue(extractData(dataBuffers).toString()))); } private AtomicLong extractData(List dataBuffers) { diff --git a/spring-5-reactive/src/main/java/com/baeldung/functional/FunctionalSpringBootApplication.java b/spring-5-reactive/src/main/java/com/baeldung/functional/FunctionalSpringBootApplication.java index 9cbc1b7669..9bfd0afe7e 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/functional/FunctionalSpringBootApplication.java +++ b/spring-5-reactive/src/main/java/com/baeldung/functional/FunctionalSpringBootApplication.java @@ -1,6 +1,6 @@ package com.baeldung.functional; -import static org.springframework.web.reactive.function.BodyInserters.fromObject; +import static org.springframework.web.reactive.function.BodyInserters.fromValue; import static org.springframework.web.reactive.function.server.RequestPredicates.GET; import static org.springframework.web.reactive.function.server.RequestPredicates.POST; import static org.springframework.web.reactive.function.server.RequestPredicates.path; @@ -44,7 +44,7 @@ public class FunctionalSpringBootApplication { .doOnNext(actors::add) .then(ok().build())); - return route(GET("/test"), serverRequest -> ok().body(fromObject("helloworld"))) + return route(GET("/test"), serverRequest -> ok().body(fromValue("helloworld"))) .andRoute(POST("/login"), formHandler::handleLogin) .andRoute(POST("/upload"), formHandler::handleUpload) .and(RouterFunctions.resources("/files/**", new ClassPathResource("files/"))) diff --git a/spring-5-reactive/src/main/java/com/baeldung/functional/FunctionalWebApplication.java b/spring-5-reactive/src/main/java/com/baeldung/functional/FunctionalWebApplication.java index b89f74ad92..9930ffb474 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/functional/FunctionalWebApplication.java +++ b/spring-5-reactive/src/main/java/com/baeldung/functional/FunctionalWebApplication.java @@ -1,6 +1,6 @@ package com.baeldung.functional; -import static org.springframework.web.reactive.function.BodyInserters.fromObject; +import static org.springframework.web.reactive.function.BodyInserters.fromValue; import static org.springframework.web.reactive.function.server.RequestPredicates.GET; import static org.springframework.web.reactive.function.server.RequestPredicates.POST; import static org.springframework.web.reactive.function.server.RequestPredicates.accept; @@ -42,7 +42,7 @@ public class FunctionalWebApplication { .doOnNext(actors::add) .then(ok().build())); - return route(GET("/test"), serverRequest -> ok().body(fromObject("helloworld"))).andRoute(POST("/login"), formHandler::handleLogin) + return route(GET("/test"), serverRequest -> ok().body(fromValue("helloworld"))).andRoute(POST("/login"), formHandler::handleLogin) .andRoute(POST("/upload"), formHandler::handleUpload) .and(RouterFunctions.resources("/files/**", new ClassPathResource("files/"))) .andNest(accept(MediaType.APPLICATION_JSON), restfulRouter) diff --git a/spring-5-reactive/src/main/java/com/baeldung/functional/RootServlet.java b/spring-5-reactive/src/main/java/com/baeldung/functional/RootServlet.java index 8fe24821de..6c36b7fa03 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/functional/RootServlet.java +++ b/spring-5-reactive/src/main/java/com/baeldung/functional/RootServlet.java @@ -2,7 +2,7 @@ package com.baeldung.functional; import static org.springframework.web.reactive.function.BodyExtractors.toDataBuffers; import static org.springframework.web.reactive.function.BodyExtractors.toFormData; -import static org.springframework.web.reactive.function.BodyInserters.fromObject; +import static org.springframework.web.reactive.function.BodyInserters.fromValue; import static org.springframework.web.reactive.function.server.RequestPredicates.GET; import static org.springframework.web.reactive.function.server.RequestPredicates.POST; import static org.springframework.web.reactive.function.server.RequestPredicates.path; @@ -46,7 +46,7 @@ public class RootServlet extends ServletHttpHandlerAdapter { private static RouterFunction routingFunction() { - return route(GET("/test"), serverRequest -> ok().body(fromObject("helloworld"))).andRoute(POST("/login"), serverRequest -> serverRequest.body(toFormData()) + return route(GET("/test"), serverRequest -> ok().body(fromValue("helloworld"))).andRoute(POST("/login"), serverRequest -> serverRequest.body(toFormData()) .map(MultiValueMap::toSingleValueMap) .map(formData -> { System.out.println("form data: " + formData.toString()); @@ -65,7 +65,7 @@ public class RootServlet extends ServletHttpHandlerAdapter { dataBuffers.forEach(d -> atomicLong.addAndGet(d.asByteBuffer() .array().length)); System.out.println("data length:" + atomicLong.get()); - return ok().body(fromObject(atomicLong.toString())) + return ok().body(fromValue(atomicLong.toString())) .block(); })) .and(RouterFunctions.resources("/files/**", new ClassPathResource("files/"))) diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorWebExceptionHandler.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorWebExceptionHandler.java index 051e4b8df5..4f3f1795da 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorWebExceptionHandler.java +++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorWebExceptionHandler.java @@ -2,7 +2,8 @@ package com.baeldung.reactive.errorhandling; import java.util.Map; -import org.springframework.boot.autoconfigure.web.ResourceProperties; + +import org.springframework.boot.autoconfigure.web.WebProperties; import org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler; import org.springframework.boot.web.error.ErrorAttributeOptions; import org.springframework.boot.web.reactive.error.ErrorAttributes; @@ -18,6 +19,7 @@ import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.RouterFunctions; import org.springframework.web.reactive.function.server.ServerRequest; import org.springframework.web.reactive.function.server.ServerResponse; + import reactor.core.publisher.Mono; @Component @@ -26,7 +28,7 @@ public class GlobalErrorWebExceptionHandler extends AbstractErrorWebExceptionHan public GlobalErrorWebExceptionHandler(GlobalErrorAttributes g, ApplicationContext applicationContext, ServerCodecConfigurer serverCodecConfigurer) { - super(g, new ResourceProperties(), applicationContext); + super(g, new WebProperties.Resources(), applicationContext); super.setMessageWriters(serverCodecConfigurer.getWriters()); super.setMessageReaders(serverCodecConfigurer.getReaders()); } @@ -41,8 +43,8 @@ public class GlobalErrorWebExceptionHandler extends AbstractErrorWebExceptionHan final Map errorPropertiesMap = getErrorAttributes(request, ErrorAttributeOptions.defaults()); return ServerResponse.status(HttpStatus.BAD_REQUEST) - .contentType(MediaType.APPLICATION_JSON_UTF8) - .body(BodyInserters.fromObject(errorPropertiesMap)); + .contentType(MediaType.APPLICATION_JSON) + .body(BodyInserters.fromValue(errorPropertiesMap)); } } diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/handlers/Handler1.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/handlers/Handler1.java index 87b78a4654..c71c8ecac0 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/handlers/Handler1.java +++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/handlers/Handler1.java @@ -14,7 +14,7 @@ public class Handler1 { return sayHello(request).onErrorReturn("Hello, Stranger") .flatMap(s -> ServerResponse.ok() .contentType(MediaType.TEXT_PLAIN) - .syncBody(s)); + .bodyValue(s)); } private Mono sayHello(ServerRequest request) { diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/handlers/Handler2.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/handlers/Handler2.java index 12172a0f54..92e881543e 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/handlers/Handler2.java +++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/handlers/Handler2.java @@ -15,11 +15,11 @@ public Mono handleRequest2(ServerRequest request) { sayHello(request) .flatMap(s -> ServerResponse.ok() .contentType(MediaType.TEXT_PLAIN) - .syncBody(s)) + .bodyValue(s)) .onErrorResume(e -> sayHelloFallback() .flatMap(s -> ServerResponse.ok() .contentType(MediaType.TEXT_PLAIN) - .syncBody(s))); + .bodyValue(s))); } private Mono sayHello(ServerRequest request) { diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/handlers/Handler3.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/handlers/Handler3.java index e95b039cce..8c988a6633 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/handlers/Handler3.java +++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/errorhandling/handlers/Handler3.java @@ -15,11 +15,11 @@ public class Handler3 { sayHello(request) .flatMap(s -> ServerResponse.ok() .contentType(MediaType.TEXT_PLAIN) - .syncBody(s)) + .bodyValue(s)) .onErrorResume(e -> (Mono.just("Hi, I looked around for your name but found: " + e.getMessage())).flatMap(s -> ServerResponse.ok() .contentType(MediaType.TEXT_PLAIN) - .syncBody(s))); + .bodyValue(s))); } private Mono sayHello(ServerRequest request) { diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/ExploreSpring5URLPatternUsingRouterFunctions.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/ExploreSpring5URLPatternUsingRouterFunctions.java index 115a057915..34abada2f1 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/ExploreSpring5URLPatternUsingRouterFunctions.java +++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/ExploreSpring5URLPatternUsingRouterFunctions.java @@ -1,6 +1,6 @@ package com.baeldung.reactive.urlmatch; -import static org.springframework.web.reactive.function.BodyInserters.fromObject; +import static org.springframework.web.reactive.function.BodyInserters.fromValue; import static org.springframework.web.reactive.function.server.RequestPredicates.GET; import static org.springframework.web.reactive.function.server.RouterFunctions.route; import static org.springframework.web.reactive.function.server.RouterFunctions.toHttpHandler; @@ -24,10 +24,10 @@ public class ExploreSpring5URLPatternUsingRouterFunctions { private RouterFunction routingFunction() { - return route(GET("/p?ths"), serverRequest -> ok().body(fromObject("/p?ths"))).andRoute(GET("/test/{*id}"), serverRequest -> ok().body(fromObject(serverRequest.pathVariable("id")))) - .andRoute(GET("/*card"), serverRequest -> ok().body(fromObject("/*card path was accessed"))) - .andRoute(GET("/{var1}_{var2}"), serverRequest -> ok().body(fromObject(serverRequest.pathVariable("var1") + " , " + serverRequest.pathVariable("var2")))) - .andRoute(GET("/{baeldung:[a-z]+}"), serverRequest -> ok().body(fromObject("/{baeldung:[a-z]+} was accessed and baeldung=" + serverRequest.pathVariable("baeldung")))) + return route(GET("/p?ths"), serverRequest -> ok().body(fromValue("/p?ths"))).andRoute(GET("/test/{*id}"), serverRequest -> ok().body(fromValue(serverRequest.pathVariable("id")))) + .andRoute(GET("/*card"), serverRequest -> ok().body(fromValue("/*card path was accessed"))) + .andRoute(GET("/{var1}_{var2}"), serverRequest -> ok().body(fromValue(serverRequest.pathVariable("var1") + " , " + serverRequest.pathVariable("var2")))) + .andRoute(GET("/{baeldung:[a-z]+}"), serverRequest -> ok().body(fromValue("/{baeldung:[a-z]+} was accessed and baeldung=" + serverRequest.pathVariable("baeldung")))) .and(RouterFunctions.resources("/files/{*filepaths}", new ClassPathResource("files/"))); } diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/FormHandler.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/FormHandler.java index 0781230379..7b1fb06459 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/FormHandler.java +++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/FormHandler.java @@ -11,7 +11,7 @@ import java.util.concurrent.atomic.AtomicLong; import static org.springframework.web.reactive.function.BodyExtractors.toDataBuffers; import static org.springframework.web.reactive.function.BodyExtractors.toFormData; -import static org.springframework.web.reactive.function.BodyInserters.fromObject; +import static org.springframework.web.reactive.function.BodyInserters.fromValue; import static org.springframework.web.reactive.function.server.ServerResponse.ok; public class FormHandler { @@ -29,7 +29,7 @@ public class FormHandler { Mono handleUpload(ServerRequest request) { return request.body(toDataBuffers()) .collectList() - .flatMap(dataBuffers -> ok().body(fromObject(extractData(dataBuffers).toString()))); + .flatMap(dataBuffers -> ok().body(fromValue(extractData(dataBuffers).toString()))); } private AtomicLong extractData(List dataBuffers) { diff --git a/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/FunctionalWebApplication.java b/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/FunctionalWebApplication.java index 2ea5420a2b..6cec902a0d 100644 --- a/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/FunctionalWebApplication.java +++ b/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/FunctionalWebApplication.java @@ -1,6 +1,6 @@ package com.baeldung.reactive.urlmatch; -import static org.springframework.web.reactive.function.BodyInserters.fromObject; +import static org.springframework.web.reactive.function.BodyInserters.fromValue; import static org.springframework.web.reactive.function.server.RequestPredicates.GET; import static org.springframework.web.reactive.function.server.RequestPredicates.POST; import static org.springframework.web.reactive.function.server.RequestPredicates.path; @@ -40,7 +40,7 @@ public class FunctionalWebApplication { .doOnNext(actors::add) .then(ok().build())); - return route(GET("/test"), serverRequest -> ok().body(fromObject("helloworld"))).andRoute(POST("/login"), formHandler::handleLogin) + return route(GET("/test"), serverRequest -> ok().body(fromValue("helloworld"))).andRoute(POST("/login"), formHandler::handleLogin) .andRoute(POST("/upload"), formHandler::handleUpload) .and(RouterFunctions.resources("/files/**", new ClassPathResource("files/"))) .andNest(path("/actor"), restfulRouter) diff --git a/spring-5-reactive/src/test/java/com/baeldung/functional/FunctionalWebApplicationIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/functional/FunctionalWebApplicationIntegrationTest.java index 5c0b4f69d0..3164adbe4a 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/functional/FunctionalWebApplicationIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/functional/FunctionalWebApplicationIntegrationTest.java @@ -1,17 +1,15 @@ package com.baeldung.functional; -import static org.springframework.web.reactive.function.BodyInserters.fromObject; +import static org.springframework.web.reactive.function.BodyInserters.fromValue; import static org.springframework.web.reactive.function.BodyInserters.fromResource; import org.junit.AfterClass; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; import org.springframework.boot.web.server.WebServer; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.http.MediaType; -import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; @@ -115,7 +113,7 @@ public class FunctionalWebApplicationIntegrationTest { client.post() .uri("/actor") - .body(fromObject(new Actor("Clint", "Eastwood"))) + .body(fromValue(new Actor("Clint", "Eastwood"))) .exchange() .expectStatus() .isOk(); diff --git a/spring-5-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java index 3bbbed0d77..38443a4eac 100644 --- a/spring-5-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java +++ b/spring-5-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java @@ -133,7 +133,7 @@ public class ErrorHandlingIntegrationTest { .expectStatus() .isBadRequest() .expectHeader() - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .expectBody() .jsonPath("$.message") .isNotEmpty() @@ -164,7 +164,7 @@ public class ErrorHandlingIntegrationTest { .expectStatus() .isBadRequest() .expectHeader() - .contentType(MediaType.APPLICATION_JSON_UTF8) + .contentType(MediaType.APPLICATION_JSON) .expectBody() .jsonPath("$.message") .isNotEmpty() From e07bcb53153e8d8929c75d4979958fc1823f7fbe Mon Sep 17 00:00:00 2001 From: Jonathan Cook Date: Mon, 1 Feb 2021 17:44:05 +0100 Subject: [PATCH 326/361] BAEL-2674 - Upgrade the Okhttp article (#10462) * 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 * BAEL-4756 - Mockito MockSettings * BAEL-4756 - Mockito MockSettings - fix spelling * BAEL-2674 - Upgrade the Okhttp article Co-authored-by: Jonathan Cook --- libraries-http/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries-http/pom.xml b/libraries-http/pom.xml index 74e00a7291..257cb988d6 100644 --- a/libraries-http/pom.xml +++ b/libraries-http/pom.xml @@ -120,7 +120,7 @@ 4.5.3 3.6.2 - 3.14.2 + 4.9.1 1.23.0 2.2.0 2.3.0 From a50cec28827e1ef662471f1792883f5ebed98bdb Mon Sep 17 00:00:00 2001 From: MeenaGawande Date: Tue, 2 Feb 2021 11:25:34 +0530 Subject: [PATCH 327/361] [BAEL-4715] Java HashMap Load Factor Fixed HashMap creation and few entries --- .../hashmap/loadfactor/HashMapLoadFactorUnitTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/hashmap/loadfactor/HashMapLoadFactorUnitTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/hashmap/loadfactor/HashMapLoadFactorUnitTest.java index 89e2a189fe..94967a4905 100644 --- a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/hashmap/loadfactor/HashMapLoadFactorUnitTest.java +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/hashmap/loadfactor/HashMapLoadFactorUnitTest.java @@ -10,8 +10,8 @@ public class HashMapLoadFactorUnitTest { @Test public void whenCreateMapWithDefaultParam_thenSucces() { - Map mapWithDefaultParams = new HashMap(); - mapWithDefaultParams.put("1", "One"); + Map mapWithDefaultParams = new HashMap<>(); + mapWithDefaultParams.put("1", "one"); mapWithDefaultParams.put("2", "two"); mapWithDefaultParams.put("3", "three"); mapWithDefaultParams.put("4", "four"); @@ -22,8 +22,8 @@ public class HashMapLoadFactorUnitTest { @Test public void whenCreateMapWithInitialCapacity_thenSucces() { - Map mapWithInitialCapacity = new HashMap(5); - mapWithInitialCapacity.put("1", "One"); + Map mapWithInitialCapacity = new HashMap<>(5); + mapWithInitialCapacity.put("1", "one"); mapWithInitialCapacity.put("2", "two"); mapWithInitialCapacity.put("3", "three"); @@ -32,7 +32,7 @@ public class HashMapLoadFactorUnitTest { @Test public void whenCreateMapWithInitialCapacityAndLF_thenSucces() { - Map mapWithInitialCapacityAndLF = new HashMap(5, 0.5f); + Map mapWithInitialCapacityAndLF = new HashMap<>(5, 0.5f); mapWithInitialCapacityAndLF.put("1", "one"); mapWithInitialCapacityAndLF.put("2", "two"); mapWithInitialCapacityAndLF.put("3", "three"); From 387ee88c2d3b5f746b062065f062751db418060e Mon Sep 17 00:00:00 2001 From: "Kent@lhind.hp.g5" Date: Tue, 2 Feb 2021 10:32:22 +0100 Subject: [PATCH 328/361] upgrade to springboot 2.3.2 and fix application properties --- spring-boot-modules/spring-boot-actuator/pom.xml | 2 +- .../src/main/resources/application.properties | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/spring-boot-modules/spring-boot-actuator/pom.xml b/spring-boot-modules/spring-boot-actuator/pom.xml index 18da6d3a9a..a808b8cb1b 100644 --- a/spring-boot-modules/spring-boot-actuator/pom.xml +++ b/spring-boot-modules/spring-boot-actuator/pom.xml @@ -11,7 +11,7 @@ org.springframework.boot spring-boot-starter-parent - 2.3.0.RELEASE + 2.3.2.RELEASE diff --git a/spring-boot-modules/spring-boot-actuator/src/main/resources/application.properties b/spring-boot-modules/spring-boot-actuator/src/main/resources/application.properties index 00100d6d97..de7be417a8 100644 --- a/spring-boot-modules/spring-boot-actuator/src/main/resources/application.properties +++ b/spring-boot-modules/spring-boot-actuator/src/main/resources/application.properties @@ -1,4 +1,6 @@ -management.health.probes.enabled=true +management.endpoint.health.probes.enabled=true +management.health.livenessState.enabled=true +management.health.readinessState.enabled=true management.endpoint.health.show-details=always management.endpoint.health.status.http-mapping.down=500 management.endpoint.health.status.http-mapping.out_of_service=503 @@ -8,4 +10,4 @@ management.endpoint.health.status.http-mapping.warning=500 info.app.name=Spring Sample Application info.app.description=This is my first spring boot application G1 info.app.version=1.0.0 -info.java-vendor = ${java.specification.vendor} \ No newline at end of file +info.java-vendor = ${java.specification.vendor} From 7d78e63edfdd759800d1b9e25605db0cd87c0b1a Mon Sep 17 00:00:00 2001 From: osser-sam <46674082+osser-sam@users.noreply.github.com> Date: Wed, 3 Feb 2021 01:12:29 +0530 Subject: [PATCH 329/361] JAVA-4277: Fix tests in spring-resttemplate module (#10447) * JAVA-4277: Fix tests in spring-resttemplate module * JAVA-4277: Moved article from spring-resttemplate to spring-resttemplate-2 --- .../spring-resttemplate-2/README.md | 1 + .../spring-resttemplate-2/pom.xml | 2 +- .../redirect/RedirectController.java | 0 .../src/main/webapp/WEB-INF/api-servlet.xml | 36 +++++++++++++++++++ .../src/main/webapp/WEB-INF/spring-views.xml | 10 ++++++ .../RedirectControllerIntegrationTest.java | 0 .../spring-resttemplate/pom.xml | 4 +-- .../web/service => mock}/EmployeeService.java | 2 +- .../client/TestRestTemplateBasicLiveTest.java | 1 + ...eServiceMockRestServiceServerUnitTest.java | 5 +-- .../EmployeeServiceUnitTest.java | 5 +-- .../RestTemplateBasicLiveTest.java | 1 + 12 files changed, 59 insertions(+), 8 deletions(-) rename spring-web-modules/{spring-resttemplate => spring-resttemplate-2}/src/main/java/com/baeldung/sampleapp/web/controller/redirect/RedirectController.java (100%) create mode 100644 spring-web-modules/spring-resttemplate-2/src/main/webapp/WEB-INF/api-servlet.xml create mode 100644 spring-web-modules/spring-resttemplate-2/src/main/webapp/WEB-INF/spring-views.xml rename spring-web-modules/{spring-resttemplate => spring-resttemplate-2}/src/test/java/com/baeldung/web/controller/redirect/RedirectControllerIntegrationTest.java (100%) rename spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/{resttemplate/web/service => mock}/EmployeeService.java (95%) rename spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/{web/service => mock}/EmployeeServiceMockRestServiceServerUnitTest.java (96%) rename spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/{web/service => mock}/EmployeeServiceUnitTest.java (92%) diff --git a/spring-web-modules/spring-resttemplate-2/README.md b/spring-web-modules/spring-resttemplate-2/README.md index a903757bb4..b2000e0481 100644 --- a/spring-web-modules/spring-resttemplate-2/README.md +++ b/spring-web-modules/spring-resttemplate-2/README.md @@ -10,3 +10,4 @@ This module contains articles about Spring RestTemplate - [RestTemplate Post Request with JSON](https://www.baeldung.com/spring-resttemplate-post-json) - [How to Compress Requests Using the Spring RestTemplate](https://www.baeldung.com/spring-resttemplate-compressing-requests) - [Get list of JSON objects with Spring RestTemplate](https://www.baeldung.com/spring-resttemplate-json-list) +- [A Guide To Spring Redirects](https://www.baeldung.com/spring-redirect-and-forward) diff --git a/spring-web-modules/spring-resttemplate-2/pom.xml b/spring-web-modules/spring-resttemplate-2/pom.xml index 04be058638..158380b403 100644 --- a/spring-web-modules/spring-resttemplate-2/pom.xml +++ b/spring-web-modules/spring-resttemplate-2/pom.xml @@ -11,7 +11,7 @@ com.baeldung parent-boot-2 0.0.1-SNAPSHOT - parent-boot-2/pom.xml + ../../parent-boot-2/pom.xml diff --git a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/redirect/RedirectController.java b/spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/controller/redirect/RedirectController.java similarity index 100% rename from spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/sampleapp/web/controller/redirect/RedirectController.java rename to spring-web-modules/spring-resttemplate-2/src/main/java/com/baeldung/sampleapp/web/controller/redirect/RedirectController.java diff --git a/spring-web-modules/spring-resttemplate-2/src/main/webapp/WEB-INF/api-servlet.xml b/spring-web-modules/spring-resttemplate-2/src/main/webapp/WEB-INF/api-servlet.xml new file mode 100644 index 0000000000..ed37a962e9 --- /dev/null +++ b/spring-web-modules/spring-resttemplate-2/src/main/webapp/WEB-INF/api-servlet.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + /WEB-INF/spring-views.xml + + + + + + + + + + + + + diff --git a/spring-web-modules/spring-resttemplate-2/src/main/webapp/WEB-INF/spring-views.xml b/spring-web-modules/spring-resttemplate-2/src/main/webapp/WEB-INF/spring-views.xml new file mode 100644 index 0000000000..2944828d6d --- /dev/null +++ b/spring-web-modules/spring-resttemplate-2/src/main/webapp/WEB-INF/spring-views.xml @@ -0,0 +1,10 @@ + + + + + + + \ No newline at end of file diff --git a/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/web/controller/redirect/RedirectControllerIntegrationTest.java b/spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/web/controller/redirect/RedirectControllerIntegrationTest.java similarity index 100% rename from spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/web/controller/redirect/RedirectControllerIntegrationTest.java rename to spring-web-modules/spring-resttemplate-2/src/test/java/com/baeldung/web/controller/redirect/RedirectControllerIntegrationTest.java diff --git a/spring-web-modules/spring-resttemplate/pom.xml b/spring-web-modules/spring-resttemplate/pom.xml index c0f266fd62..1db6b5db57 100644 --- a/spring-web-modules/spring-resttemplate/pom.xml +++ b/spring-web-modules/spring-resttemplate/pom.xml @@ -188,7 +188,7 @@ cargo-maven2-plugin ${cargo-maven2-plugin.version} - + true tomcat8x embedded @@ -297,7 +297,7 @@ 20.0 - 1.6.0 + 1.6.1 3.0.4 diff --git a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/service/EmployeeService.java b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/mock/EmployeeService.java similarity index 95% rename from spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/service/EmployeeService.java rename to spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/mock/EmployeeService.java index 18dff3db1b..16180a3640 100644 --- a/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/resttemplate/web/service/EmployeeService.java +++ b/spring-web-modules/spring-resttemplate/src/main/java/com/baeldung/mock/EmployeeService.java @@ -1,4 +1,4 @@ -package com.baeldung.resttemplate.web.service; +package com.baeldung.mock; import com.baeldung.resttemplate.web.model.Employee; import org.slf4j.Logger; diff --git a/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/client/TestRestTemplateBasicLiveTest.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/client/TestRestTemplateBasicLiveTest.java index 9f4b3c9b35..406dd5979b 100644 --- a/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/client/TestRestTemplateBasicLiveTest.java +++ b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/client/TestRestTemplateBasicLiveTest.java @@ -18,6 +18,7 @@ import org.springframework.web.client.RestTemplate; import okhttp3.Request; import okhttp3.RequestBody; +// This test needs RestTemplateConfigurationApplication to be up and running public class TestRestTemplateBasicLiveTest { private RestTemplate restTemplate; diff --git a/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/web/service/EmployeeServiceMockRestServiceServerUnitTest.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/mock/EmployeeServiceMockRestServiceServerUnitTest.java similarity index 96% rename from spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/web/service/EmployeeServiceMockRestServiceServerUnitTest.java rename to spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/mock/EmployeeServiceMockRestServiceServerUnitTest.java index ee01cb6a50..309e0635a4 100644 --- a/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/web/service/EmployeeServiceMockRestServiceServerUnitTest.java +++ b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/mock/EmployeeServiceMockRestServiceServerUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.web.service; +package com.baeldung.mock; import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; @@ -7,8 +7,9 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat import java.net.URI; import com.baeldung.SpringTestConfig; +import com.baeldung.mock.EmployeeService; import com.baeldung.resttemplate.web.model.Employee; -import com.baeldung.resttemplate.web.service.EmployeeService; + import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/web/service/EmployeeServiceUnitTest.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/mock/EmployeeServiceUnitTest.java similarity index 92% rename from spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/web/service/EmployeeServiceUnitTest.java rename to spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/mock/EmployeeServiceUnitTest.java index 6eb040414b..9a992f390a 100644 --- a/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/web/service/EmployeeServiceUnitTest.java +++ b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/mock/EmployeeServiceUnitTest.java @@ -1,7 +1,8 @@ -package com.baeldung.web.service; +package com.baeldung.mock; +import com.baeldung.mock.EmployeeService; import com.baeldung.resttemplate.web.model.Employee; -import com.baeldung.resttemplate.web.service.EmployeeService; + import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/resttemplate/RestTemplateBasicLiveTest.java b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/resttemplate/RestTemplateBasicLiveTest.java index 0dab124316..8d52394dd1 100644 --- a/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/resttemplate/RestTemplateBasicLiveTest.java +++ b/spring-web-modules/spring-resttemplate/src/test/java/com/baeldung/resttemplate/RestTemplateBasicLiveTest.java @@ -38,6 +38,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper; import com.google.common.base.Charsets; +// This test needs RestTemplateConfigurationApplication to be up and running public class RestTemplateBasicLiveTest { private RestTemplate restTemplate; From cfbdbe1001aa330905eb15c0c60c0b27d80fcc54 Mon Sep 17 00:00:00 2001 From: osser-sam <46674082+osser-sam@users.noreply.github.com> Date: Wed, 3 Feb 2021 01:16:00 +0530 Subject: [PATCH 330/361] JAVA-4012: fix failing test (#10455) --- .../zoneddatetime/config/MongoConfig.java | 22 ------------------- .../src/main/resources/mongoConfig.xml | 4 ++-- 2 files changed, 2 insertions(+), 24 deletions(-) diff --git a/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/config/MongoConfig.java b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/config/MongoConfig.java index 3cfefa099c..4eb3872e34 100644 --- a/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/config/MongoConfig.java +++ b/persistence-modules/spring-boot-persistence-mongodb/src/main/java/com/baeldung/zoneddatetime/config/MongoConfig.java @@ -1,11 +1,8 @@ package com.baeldung.zoneddatetime.config; import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; import java.util.List; -import org.springframework.context.annotation.Configuration; import org.springframework.core.convert.converter.Converter; import org.springframework.data.mongodb.config.AbstractMongoClientConfiguration; import org.springframework.data.mongodb.core.convert.MongoCustomConversions; @@ -13,12 +10,7 @@ import org.springframework.data.mongodb.repository.config.EnableMongoRepositorie import com.baeldung.zoneddatetime.converter.ZonedDateTimeReadConverter; import com.baeldung.zoneddatetime.converter.ZonedDateTimeWriteConverter; -import com.mongodb.ConnectionString; -import com.mongodb.MongoClientSettings; -import com.mongodb.client.MongoClient; -import com.mongodb.client.MongoClients; -@Configuration @EnableMongoRepositories(basePackages = { "com.baeldung" }) public class MongoConfig extends AbstractMongoClientConfiguration { @@ -29,20 +21,6 @@ public class MongoConfig extends AbstractMongoClientConfiguration { return "test"; } - @Override - public MongoClient mongoClient() { - final ConnectionString connectionString = new ConnectionString("mongodb://localhost:27017/test"); - final MongoClientSettings mongoClientSettings = MongoClientSettings.builder() - .applyConnectionString(connectionString) - .build(); - return MongoClients.create(mongoClientSettings); - } - - @Override - public Collection getMappingBasePackages() { - return Collections.singleton("com.baeldung"); - } - @Override public MongoCustomConversions customConversions() { converters.add(new ZonedDateTimeReadConverter()); diff --git a/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/mongoConfig.xml b/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/mongoConfig.xml index c5b9068de3..7a10ef6a69 100644 --- a/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/mongoConfig.xml +++ b/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/mongoConfig.xml @@ -24,8 +24,8 @@ - - + + \ No newline at end of file From 6f2e23e1665ce746d66ca779ba74e3f70b37193f Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 3 Feb 2021 23:59:04 +0800 Subject: [PATCH 331/361] Update README.md --- core-java-modules/core-java-jvm-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-jvm-2/README.md b/core-java-modules/core-java-jvm-2/README.md index 36cafd3288..ccca3a11ac 100644 --- a/core-java-modules/core-java-jvm-2/README.md +++ b/core-java-modules/core-java-jvm-2/README.md @@ -11,4 +11,5 @@ This module contains articles about working with the Java Virtual Machine (JVM). - [Where Is the Array Length Stored in JVM?](https://www.baeldung.com/java-jvm-array-length) - [Memory Address of Objects in Java](https://www.baeldung.com/java-object-memory-address) - [List All Classes Loaded in a Specific Class Loader](https://www.baeldung.com/java-list-classes-class-loader) +- [An Introduction to the Constant Pool in the JVM](https://www.baeldung.com/jvm-constant-pool) - More articles: [[<-- prev]](/core-java-modules/core-java-jvm) From 5774d53d0b5f45937ed26166ce0856dc791bb5b7 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 4 Feb 2021 00:02:05 +0800 Subject: [PATCH 332/361] Update README.md --- java-collections-maps-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/java-collections-maps-3/README.md b/java-collections-maps-3/README.md index 39ac8575fa..bd1029c9cf 100644 --- a/java-collections-maps-3/README.md +++ b/java-collections-maps-3/README.md @@ -2,3 +2,4 @@ - [Java Map With Case-Insensitive Keys](https://www.baeldung.com/java-map-with-case-insensitive-keys) - [Using a Byte Array as Map Key in Java](https://www.baeldung.com/java-map-key-byte-array) +- [Using the Map.Entry Java Class](https://www.baeldung.com/java-map-entry) From 3ff1ba2185ac0571764d0e148ebc933cb4ba1652 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 4 Feb 2021 00:03:53 +0800 Subject: [PATCH 333/361] Update README.md --- core-java-modules/core-java-lang-oop-generics/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-lang-oop-generics/README.md b/core-java-modules/core-java-lang-oop-generics/README.md index 74b9df7c65..9c9080ece3 100644 --- a/core-java-modules/core-java-lang-oop-generics/README.md +++ b/core-java-modules/core-java-lang-oop-generics/README.md @@ -7,3 +7,4 @@ This module contains articles about generics in Java - [Type Erasure in Java Explained](https://www.baeldung.com/java-type-erasure) - [Raw Types in Java](https://www.baeldung.com/raw-types-java) - [Super Type Tokens in Java Generics](https://www.baeldung.com/java-super-type-tokens) +- [Java Warning “unchecked conversion”](https://www.baeldung.com/java-unchecked-conversion) From 2a365df31834bb042f9039cb3fb082a478e5a7f9 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 4 Feb 2021 00:07:17 +0800 Subject: [PATCH 334/361] Update README.md --- spring-aop/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-aop/README.md b/spring-aop/README.md index 91cccbd114..c92e132d1e 100644 --- a/spring-aop/README.md +++ b/spring-aop/README.md @@ -11,3 +11,4 @@ This module contains articles about Spring aspect oriented programming (AOP) - [Introduction to Pointcut Expressions in Spring](https://www.baeldung.com/spring-aop-pointcut-tutorial) - [Introduction to Advice Types in Spring](https://www.baeldung.com/spring-aop-advice-tutorial) - [When Does Java Throw UndeclaredThrowableException?](https://www.baeldung.com/java-undeclaredthrowableexception) +- [Get Advised Method Info in Spring AOP](https://www.baeldung.com/spring-aop-get-advised-method-info) From 1bc84889aa660fce20c3ad2f6835e193eb4727e0 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 4 Feb 2021 00:09:00 +0800 Subject: [PATCH 335/361] Update README.md --- core-java-modules/core-java-concurrency-advanced-4/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-concurrency-advanced-4/README.md b/core-java-modules/core-java-concurrency-advanced-4/README.md index 98f2894515..5b93cec0dd 100644 --- a/core-java-modules/core-java-concurrency-advanced-4/README.md +++ b/core-java-modules/core-java-concurrency-advanced-4/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Binary Semaphore vs Reentrant Lock](https://www.baeldung.com/java-binary-semaphore-vs-reentrant-lock) +- [Bad Practices With Synchronization](https://www.baeldung.com/java-synchronization-bad-practices) From 44552d1fa42f1413194a0af1a09a505655c6fe87 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 4 Feb 2021 00:10:36 +0800 Subject: [PATCH 336/361] Update README.md --- spring-5-reactive-client/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-5-reactive-client/README.md b/spring-5-reactive-client/README.md index eebdc23aed..b247a1669b 100644 --- a/spring-5-reactive-client/README.md +++ b/spring-5-reactive-client/README.md @@ -11,3 +11,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Logging Spring WebClient Calls](https://www.baeldung.com/spring-log-webclient-calls) - [Mocking a WebClient in Spring](https://www.baeldung.com/spring-mocking-webclient) - [Spring WebClient Filters](https://www.baeldung.com/spring-webclient-filters) +- [Get List of JSON Objects with WebClient](https://www.baeldung.com/spring-webclient-json-list) From d779223e57296fab6c8895baaaa46c54f7c874a6 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 4 Feb 2021 00:13:24 +0800 Subject: [PATCH 337/361] Update README.md --- spring-web-modules/spring-resttemplate-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-web-modules/spring-resttemplate-2/README.md b/spring-web-modules/spring-resttemplate-2/README.md index b2000e0481..54fad5e01b 100644 --- a/spring-web-modules/spring-resttemplate-2/README.md +++ b/spring-web-modules/spring-resttemplate-2/README.md @@ -11,3 +11,4 @@ This module contains articles about Spring RestTemplate - [How to Compress Requests Using the Spring RestTemplate](https://www.baeldung.com/spring-resttemplate-compressing-requests) - [Get list of JSON objects with Spring RestTemplate](https://www.baeldung.com/spring-resttemplate-json-list) - [A Guide To Spring Redirects](https://www.baeldung.com/spring-redirect-and-forward) +- [Spring RestTemplate Exception: “Not enough variables available to expand”](https://www.baeldung.com/spring-not-enough-variables-available) From bb5c2386317c533b759b8bbb4015ec5fe50c8495 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 4 Feb 2021 00:14:49 +0800 Subject: [PATCH 338/361] Update README.md --- spring-web-modules/spring-mvc-forms-jsp/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-web-modules/spring-mvc-forms-jsp/README.md b/spring-web-modules/spring-mvc-forms-jsp/README.md index 2c077f5171..afbf7afe40 100644 --- a/spring-web-modules/spring-mvc-forms-jsp/README.md +++ b/spring-web-modules/spring-mvc-forms-jsp/README.md @@ -7,3 +7,4 @@ This module contains articles about Spring MVC Forms using JSP - [Getting Started with Forms in Spring MVC](https://www.baeldung.com/spring-mvc-form-tutorial) - [Form Validation with AngularJS and Spring MVC](https://www.baeldung.com/validation-angularjs-spring-mvc) - [A Guide to the JSTL Library](https://www.baeldung.com/jstl) +- [Multiple Submit Buttons on a Form](https://www.baeldung.com/spring-form-multiple-submit-buttons) From 23ee2df79e36362ea7aced96489afbaccb3158e9 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Mon, 8 Feb 2021 22:48:54 +0100 Subject: [PATCH 339/361] JAVA-4395: Fix typo in addTagsOfOtherProduct method --- .../src/main/java/com/baeldung/map/Product.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/Product.java b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/Product.java index 5559895730..09b1a8847d 100644 --- a/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/Product.java +++ b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/Product.java @@ -26,7 +26,7 @@ public class Product { return tags; } - public Product addTagsOfOtherProdcut(Product product) { + public Product addTagsOfOtherProduct(Product product) { this.tags.addAll(product.getTags()); return this; } @@ -100,11 +100,11 @@ public class Product { HashMap productsByName = new HashMap<>(); Product eBike2 = new Product("E-Bike", "A bike with a battery"); eBike2.getTags().add("sport"); - productsByName.merge("E-Bike", eBike2, Product::addTagsOfOtherProdcut); + productsByName.merge("E-Bike", eBike2, Product::addTagsOfOtherProduct); //Prior to Java 8: if(productsByName.containsKey("E-Bike")) { - productsByName.get("E-Bike").addTagsOfOtherProdcut(eBike2); + productsByName.get("E-Bike").addTagsOfOtherProduct(eBike2); } else { productsByName.put("E-Bike", eBike2); } @@ -117,7 +117,7 @@ public class Product { productsByName.compute("E-Bike", (k,v) -> { if(v != null) { - return v.addTagsOfOtherProdcut(eBike2); + return v.addTagsOfOtherProduct(eBike2); } else { return eBike2; } @@ -125,7 +125,7 @@ public class Product { //Prior to Java 8: if(productsByName.containsKey("E-Bike")) { - productsByName.get("E-Bike").addTagsOfOtherProdcut(eBike2); + productsByName.get("E-Bike").addTagsOfOtherProduct(eBike2); } else { productsByName.put("E-Bike", eBike2); } From 6c5c6fe3174e4a70a9049e6157401c7f7a4cfbbd Mon Sep 17 00:00:00 2001 From: Amy DeGregorio Date: Mon, 8 Feb 2021 21:11:25 -0500 Subject: [PATCH 340/361] BAEL-4331 (#10460) * BAEL-4331 * Add an integration test --- spring-boot-modules/pom.xml | 1 + .../spring-boot-runtime-2/README.md | 6 ++ .../spring-boot-runtime-2/pom.xml | 66 +++++++++++++++++++ .../heap/HeapSizeDemoApplication.java | 12 ++++ .../java/com/baeldung/heap/MemoryStats.java | 31 +++++++++ .../baeldung/heap/MemoryStatusController.java | 20 ++++++ .../resources/heap/spring-boot-runtime-2.conf | 1 + ...MemoryStatusControllerIntegrationTest.java | 32 +++++++++ 8 files changed, 169 insertions(+) create mode 100644 spring-boot-modules/spring-boot-runtime-2/README.md create mode 100644 spring-boot-modules/spring-boot-runtime-2/pom.xml create mode 100644 spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/heap/HeapSizeDemoApplication.java create mode 100644 spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/heap/MemoryStats.java create mode 100644 spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/heap/MemoryStatusController.java create mode 100644 spring-boot-modules/spring-boot-runtime-2/src/main/resources/heap/spring-boot-runtime-2.conf create mode 100644 spring-boot-modules/spring-boot-runtime-2/src/test/java/com/baeldung/heap/MemoryStatusControllerIntegrationTest.java diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index ee088c357a..263d2af089 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -62,6 +62,7 @@ spring-boot-properties-3 spring-boot-property-exp spring-boot-runtime + spring-boot-runtime-2 spring-boot-security spring-boot-springdoc spring-boot-swagger diff --git a/spring-boot-modules/spring-boot-runtime-2/README.md b/spring-boot-modules/spring-boot-runtime-2/README.md new file mode 100644 index 0000000000..f997f2473d --- /dev/null +++ b/spring-boot-modules/spring-boot-runtime-2/README.md @@ -0,0 +1,6 @@ +## Spring Boot Runtime 2 + +This module contains articles about administering a Spring Boot runtime + +### Relevant Articles: + - diff --git a/spring-boot-modules/spring-boot-runtime-2/pom.xml b/spring-boot-modules/spring-boot-runtime-2/pom.xml new file mode 100644 index 0000000000..8f6351165a --- /dev/null +++ b/spring-boot-modules/spring-boot-runtime-2/pom.xml @@ -0,0 +1,66 @@ + + + 4.0.0 + + + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + + + spring-boot-runtime-2 + jar + + spring-boot-runtime-2 + Demo project for Spring Boot + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + ${project.artifactId} + + + src/main/resources/heap + ${project.build.directory} + true + + ${project.name}.conf + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + com.baeldung.heap.HeapSizeDemoApplication + + + + + true + + -Xms256m + -Xmx1g + + + + + + diff --git a/spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/heap/HeapSizeDemoApplication.java b/spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/heap/HeapSizeDemoApplication.java new file mode 100644 index 0000000000..60d4bf7bab --- /dev/null +++ b/spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/heap/HeapSizeDemoApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.heap; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class HeapSizeDemoApplication { + + public static void main(String[] args) { + SpringApplication.run(HeapSizeDemoApplication.class, args); + } +} diff --git a/spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/heap/MemoryStats.java b/spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/heap/MemoryStats.java new file mode 100644 index 0000000000..0d2f471a12 --- /dev/null +++ b/spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/heap/MemoryStats.java @@ -0,0 +1,31 @@ +package com.baeldung.heap; + +public class MemoryStats { + private long heapSize; + private long heapMaxSize; + private long heapFreeSize; + + public long getHeapSize() { + return heapSize; + } + + public void setHeapSize(long heapSize) { + this.heapSize = heapSize; + } + + public long getHeapMaxSize() { + return heapMaxSize; + } + + public void setHeapMaxSize(long heapMaxSize) { + this.heapMaxSize = heapMaxSize; + } + + public long getHeapFreeSize() { + return heapFreeSize; + } + + public void setHeapFreeSize(long heapFreeSize) { + this.heapFreeSize = heapFreeSize; + } +} diff --git a/spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/heap/MemoryStatusController.java b/spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/heap/MemoryStatusController.java new file mode 100644 index 0000000000..293747fbd1 --- /dev/null +++ b/spring-boot-modules/spring-boot-runtime-2/src/main/java/com/baeldung/heap/MemoryStatusController.java @@ -0,0 +1,20 @@ +package com.baeldung.heap; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class MemoryStatusController { + + @GetMapping("memory-status") + public MemoryStats getMemoryStatistics() { + MemoryStats stats = new MemoryStats(); + stats.setHeapSize(Runtime.getRuntime() + .totalMemory()); + stats.setHeapMaxSize(Runtime.getRuntime() + .maxMemory()); + stats.setHeapFreeSize(Runtime.getRuntime() + .freeMemory()); + return stats; + } +} diff --git a/spring-boot-modules/spring-boot-runtime-2/src/main/resources/heap/spring-boot-runtime-2.conf b/spring-boot-modules/spring-boot-runtime-2/src/main/resources/heap/spring-boot-runtime-2.conf new file mode 100644 index 0000000000..3bfde4e3d9 --- /dev/null +++ b/spring-boot-modules/spring-boot-runtime-2/src/main/resources/heap/spring-boot-runtime-2.conf @@ -0,0 +1 @@ +JAVA_OPTS="-Xms512m -Xmx1024m" \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-runtime-2/src/test/java/com/baeldung/heap/MemoryStatusControllerIntegrationTest.java b/spring-boot-modules/spring-boot-runtime-2/src/test/java/com/baeldung/heap/MemoryStatusControllerIntegrationTest.java new file mode 100644 index 0000000000..2e744285d8 --- /dev/null +++ b/spring-boot-modules/spring-boot-runtime-2/src/test/java/com/baeldung/heap/MemoryStatusControllerIntegrationTest.java @@ -0,0 +1,32 @@ +package com.baeldung.heap; + +import static org.hamcrest.Matchers.notANumber; +import static org.hamcrest.Matchers.not; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +@RunWith(SpringRunner.class) +@WebMvcTest(MemoryStatusController.class) +public class MemoryStatusControllerIntegrationTest { + + @Autowired + private MockMvc mvc; + + @Test + public void whenGetMemoryStatistics_thenReturnJsonArray() throws Exception { + mvc.perform(get("/memory-status").contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("heapSize", not(notANumber()))) + .andExpect(jsonPath("heapMaxSize", not(notANumber()))) + .andExpect(jsonPath("heapFreeSize", not(notANumber()))); + } +} From 4f0173ebae5eb50b8f5423f6501dbd291e6df7f9 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Feb 2021 01:08:46 +0800 Subject: [PATCH 341/361] Update README.md --- spring-web-modules/spring-resttemplate-2/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-web-modules/spring-resttemplate-2/README.md b/spring-web-modules/spring-resttemplate-2/README.md index 54fad5e01b..ace7ae817b 100644 --- a/spring-web-modules/spring-resttemplate-2/README.md +++ b/spring-web-modules/spring-resttemplate-2/README.md @@ -10,5 +10,4 @@ This module contains articles about Spring RestTemplate - [RestTemplate Post Request with JSON](https://www.baeldung.com/spring-resttemplate-post-json) - [How to Compress Requests Using the Spring RestTemplate](https://www.baeldung.com/spring-resttemplate-compressing-requests) - [Get list of JSON objects with Spring RestTemplate](https://www.baeldung.com/spring-resttemplate-json-list) -- [A Guide To Spring Redirects](https://www.baeldung.com/spring-redirect-and-forward) - [Spring RestTemplate Exception: “Not enough variables available to expand”](https://www.baeldung.com/spring-not-enough-variables-available) From 9ed2982f8f0d9691dcc0ad7366cb1d94b456286a Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Feb 2021 01:12:06 +0800 Subject: [PATCH 342/361] Update README.md --- spring-5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-5/README.md b/spring-5/README.md index cce18bedf8..845d602480 100644 --- a/spring-5/README.md +++ b/spring-5/README.md @@ -11,3 +11,4 @@ This module contains articles about Spring 5 - [Spring Assert Statements](https://www.baeldung.com/spring-assert) - [Difference between \ vs \](https://www.baeldung.com/spring-contextannotation-contextcomponentscan) - [Finding the Spring Version](https://www.baeldung.com/spring-find-version) +- [Spring 5 Testing with @EnabledIf Annotation](https://www.baeldung.com/spring-5-enabledIf) From 59da123a98e892e10eea60c2580a367ef76d1d85 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Feb 2021 01:15:15 +0800 Subject: [PATCH 343/361] Create README.md --- spring-5/src/test/java/com/baeldung/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 spring-5/src/test/java/com/baeldung/README.md diff --git a/spring-5/src/test/java/com/baeldung/README.md b/spring-5/src/test/java/com/baeldung/README.md new file mode 100644 index 0000000000..0ff61914d5 --- /dev/null +++ b/spring-5/src/test/java/com/baeldung/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Concurrent Test Execution in Spring 5](https://www.baeldung.com/spring-5-concurrent-tests) From 944c965952a4a06f9b5663961927303c6a0213f7 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Feb 2021 01:17:27 +0800 Subject: [PATCH 344/361] Update README.md --- core-java-modules/core-java-lang-math-3/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/core-java-modules/core-java-lang-math-3/README.md b/core-java-modules/core-java-lang-math-3/README.md index dda3013407..1dd3a3c7e0 100644 --- a/core-java-modules/core-java-lang-math-3/README.md +++ b/core-java-modules/core-java-lang-math-3/README.md @@ -4,6 +4,5 @@ ### Relevant articles: -- [Calculate Factorial in Java](https://www.baeldung.com/java-calculate-factorial) - [Evaluating a Math Expression in Java](https://www.baeldung.com/java-evaluate-math-expression-string) - More articles: [[<-- Prev]](/core-java-modules/core-java-lang-math-2) From 9e867ffc0d35523c5a7ea8b9a2b7e57f6ad00cab Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Feb 2021 01:20:19 +0800 Subject: [PATCH 345/361] Update README.md --- spring-boot-modules/spring-boot-data-2/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-data-2/README.md b/spring-boot-modules/spring-boot-data-2/README.md index c21ce02a2e..d5020ce354 100644 --- a/spring-boot-modules/spring-boot-data-2/README.md +++ b/spring-boot-modules/spring-boot-data-2/README.md @@ -1,4 +1,3 @@ ### Relevant Articles: - [Spring Boot: Customize the Jackson ObjectMapper](https://www.baeldung.com/spring-boot-customize-jackson-objectmapper) -- [Configuring a Hikari Connection Pool with Spring Boot](https://www.baeldung.com/spring-boot-hikari) From 43efec8e232a3450cf5c8f3dcbe3912ec223594c Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Feb 2021 01:44:24 +0800 Subject: [PATCH 346/361] Update README.md --- spring-web-modules/spring-mvc-basics-4/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-web-modules/spring-mvc-basics-4/README.md b/spring-web-modules/spring-mvc-basics-4/README.md index d0bca4a303..211564a363 100644 --- a/spring-web-modules/spring-mvc-basics-4/README.md +++ b/spring-web-modules/spring-mvc-basics-4/README.md @@ -5,7 +5,7 @@ The "REST With Spring" Classes: https://bit.ly/restwithspring ### Relevant Articles: - [Quick Guide to Spring Controllers](https://www.baeldung.com/spring-controllers) -- [Model, ModelMap, and ModelView in Spring MVC](https://www.baeldung.com/spring-mvc-model-model-map-model-view) +- [Model, ModelMap, and ModelAndView in Spring MVC](https://www.baeldung.com/spring-mvc-model-model-map-model-view) - [Spring Web Contexts](https://www.baeldung.com/spring-web-contexts) - [Spring Optional Path variables](https://www.baeldung.com/spring-optional-path-variables) - [JSON Parameters with Spring MVC](https://www.baeldung.com/spring-mvc-send-json-parameters) From 5ab8f0678f06deeca9e494af1e5abcedc958d8a1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Feb 2021 01:46:38 +0800 Subject: [PATCH 347/361] Update README.md --- core-java-modules/core-java-9-new-features/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-9-new-features/README.md b/core-java-modules/core-java-9-new-features/README.md index 5af069c6f0..4045a37d9d 100644 --- a/core-java-modules/core-java-9-new-features/README.md +++ b/core-java-modules/core-java-9-new-features/README.md @@ -4,7 +4,7 @@ This module contains articles about core Java features that have been introduced ### Relevant Articles: -- [Java 9 New Features](https://www.baeldung.com/new-java-9) +- [New Features in Java 9](https://www.baeldung.com/new-java-9) - [Java 9 Variable Handles Demystified](http://www.baeldung.com/java-variable-handles) - [Exploring the New HTTP Client in Java 9 and 11](http://www.baeldung.com/java-9-http-client) - [Multi-Release Jar Files](https://www.baeldung.com/java-multi-release-jar) From d9fcd0de3451076224819b2946207f66729ee723 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Feb 2021 01:49:18 +0800 Subject: [PATCH 348/361] Update README.md --- core-java-modules/core-java-10/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-10/README.md b/core-java-modules/core-java-10/README.md index 38b1db1c05..11c2051816 100644 --- a/core-java-modules/core-java-10/README.md +++ b/core-java-modules/core-java-10/README.md @@ -5,7 +5,7 @@ This module contains articles about Java 10 core features ### Relevant Articles: - [Java 10 LocalVariable Type-Inference](http://www.baeldung.com/java-10-local-variable-type-inference) -- [Guide to Java 10](http://www.baeldung.com/java-10-overview) +- [New Features in Java 10](https://www.baeldung.com/java-10-overview) - [Copy a List to Another List in Java](http://www.baeldung.com/java-copy-list-to-another) - [Deep Dive Into the New Java JIT Compiler – Graal](https://www.baeldung.com/graal-java-jit-compiler) - [Copying Sets in Java](https://www.baeldung.com/java-copy-sets) From 0e93e2f779c2ca47b4ca1f474ec01724e6e50614 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Feb 2021 01:52:55 +0800 Subject: [PATCH 349/361] Update README.md --- core-java-modules/core-java-13/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-13/README.md b/core-java-modules/core-java-13/README.md index 697f89c362..9215139dd4 100644 --- a/core-java-modules/core-java-13/README.md +++ b/core-java-modules/core-java-13/README.md @@ -1,4 +1,4 @@ ### Relevant articles: - [Java Switch Statement](https://www.baeldung.com/java-switch) -- [New Java 13 Features](https://www.baeldung.com/java-13-new-features) +- [New Features in Java 13](https://www.baeldung.com/java-13-new-features) From 25d4cd922284b3db470d761013699f67d4352552 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Feb 2021 01:55:38 +0800 Subject: [PATCH 350/361] Update README.md --- core-java-modules/core-java-12/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core-java-modules/core-java-12/README.md b/core-java-modules/core-java-12/README.md index c28df26c6f..b509be876c 100644 --- a/core-java-modules/core-java-12/README.md +++ b/core-java-modules/core-java-12/README.md @@ -1,5 +1,4 @@ ## Relevant Articles: - - [String API Updates in Java 12](https://www.baeldung.com/java12-string-api) -- [Java 12 New Features](https://www.baeldung.com/java-12-new-features) +- [New Features in Java 12](https://www.baeldung.com/java-12-new-features) From 15d247be80f9563d13f31ed90ce8ffa5835e4186 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Feb 2021 01:59:24 +0800 Subject: [PATCH 351/361] Update README.md --- core-java-modules/core-java-char/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-char/README.md b/core-java-modules/core-java-char/README.md index fd79da15ab..5f33aa6914 100644 --- a/core-java-modules/core-java-char/README.md +++ b/core-java-modules/core-java-char/README.md @@ -3,4 +3,4 @@ This module contains articles about Java Character Class ### Relevant Articles: -- [Character#isAlphabetic vs Character#isLetter](https://www.baeldung.com/java-character-isletter-isalphabetic) +- [Character#isAlphabetic vs. Character#isLetter](https://www.baeldung.com/java-character-isletter-isalphabetic) From 5d2087c7116212cfe9fc6de91b3d5e814e7181df Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Feb 2021 02:04:28 +0800 Subject: [PATCH 352/361] Update README.md --- core-java-modules/core-java-14/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-14/README.md b/core-java-modules/core-java-14/README.md index 004b3587c4..07cdf9859c 100644 --- a/core-java-modules/core-java-14/README.md +++ b/core-java-modules/core-java-14/README.md @@ -10,4 +10,4 @@ This module contains articles about Java 14. - [Helpful NullPointerExceptions in Java 14](https://www.baeldung.com/java-14-nullpointerexception) - [Foreign Memory Access API in Java 14](https://www.baeldung.com/java-foreign-memory-access) - [Java 14 Record Keyword](https://www.baeldung.com/java-record-keyword) -- [Java 14 – New Features](https://www.baeldung.com/java-14-new-features) +- [New Features in Java 14](https://www.baeldung.com/java-14-new-features) From e043ad6d20efa7f574744672c663ad004b139dd9 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Feb 2021 02:19:55 +0800 Subject: [PATCH 353/361] Update README.md --- spring-5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-5/README.md b/spring-5/README.md index 845d602480..2ddd9fa94f 100644 --- a/spring-5/README.md +++ b/spring-5/README.md @@ -12,3 +12,4 @@ This module contains articles about Spring 5 - [Difference between \ vs \](https://www.baeldung.com/spring-contextannotation-contextcomponentscan) - [Finding the Spring Version](https://www.baeldung.com/spring-find-version) - [Spring 5 Testing with @EnabledIf Annotation](https://www.baeldung.com/spring-5-enabledIf) +- [Configuring a Hikari Connection Pool with Spring Boot](https://www.baeldung.com/spring-boot-hikari) From 5ae0cce72e3ab250455b3c4bfdb5dcc033f24d27 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Feb 2021 02:25:06 +0800 Subject: [PATCH 354/361] Update README.md --- spring-boot-modules/spring-boot-springdoc/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-springdoc/README.md b/spring-boot-modules/spring-boot-springdoc/README.md index 2447f30f6b..608e4afa2e 100644 --- a/spring-boot-modules/spring-boot-springdoc/README.md +++ b/spring-boot-modules/spring-boot-springdoc/README.md @@ -2,3 +2,4 @@ - [Documenting a Spring REST API Using OpenAPI 3.0](https://www.baeldung.com/spring-rest-openapi-documentation) - [Spring REST Docs vs OpenAPI](https://www.baeldung.com/spring-rest-docs-vs-openapi) +- [Hiding Endpoints From Swagger Documentation in Spring Boot](https://www.baeldung.com/spring-swagger-hiding-endpoints) From ec93dbe7f2d0f19a9710905e196403c46cf37563 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 10 Feb 2021 02:41:03 +0800 Subject: [PATCH 355/361] Update README.md --- guest/core-kotlin/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guest/core-kotlin/README.md b/guest/core-kotlin/README.md index c211773f27..fad62ebea6 100644 --- a/guest/core-kotlin/README.md +++ b/guest/core-kotlin/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: -- [Kotlin vs Java](https://www.baeldung.com/kotlin/kotlin-vs-java) +- [Kotlin vs Java](https://www.baeldung.com/kotlin/vs-java) From 0315847ad7e93d95590cba85158a153141df2434 Mon Sep 17 00:00:00 2001 From: Mateusz Szablak Date: Wed, 10 Feb 2021 00:40:55 +0100 Subject: [PATCH 356/361] Update PropertiesToHashMapConverter.java --- .../map/propertieshashmap/PropertiesToHashMapConverter.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverter.java b/core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverter.java index 2f333638a9..3472f998f5 100644 --- a/core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverter.java +++ b/core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/propertieshashmap/PropertiesToHashMapConverter.java @@ -27,9 +27,9 @@ public class PropertiesToHashMapConverter { public static HashMap streamConvert(Properties prop) { return prop.entrySet().stream().collect( Collectors.toMap( - e -> String.valueOf(e.getKey()), - e -> String.valueOf(e.getValue()), - (prev, next) -> next, HashMap::new + e -> String.valueOf(e.getKey()), + e -> String.valueOf(e.getValue()), + (prev, next) -> next, HashMap::new )); } From 153f600c627648f5262c6a5ad882124b83d3c21c Mon Sep 17 00:00:00 2001 From: kwoyke Date: Wed, 10 Feb 2021 07:51:44 +0100 Subject: [PATCH 357/361] BAEL-4758: Override autoIndexCreation in MongoConfig (#10474) --- .../src/main/java/com/baeldung/config/MongoConfig.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java b/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java index 90b1268133..a7db26eba5 100644 --- a/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java +++ b/persistence-modules/spring-data-mongodb/src/main/java/com/baeldung/config/MongoConfig.java @@ -68,4 +68,8 @@ public class MongoConfig extends AbstractMongoClientConfiguration { return new MongoTransactionManager(dbFactory); } + @Override + protected boolean autoIndexCreation() { + return true; + } } From 92b4049195720ee321e311dc7f0fca2ec40060f5 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 11 Feb 2021 01:07:33 +0800 Subject: [PATCH 358/361] Update README.md --- core-java-modules/core-java-lang-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-lang-3/README.md b/core-java-modules/core-java-lang-3/README.md index 5279cc23b0..8ed945a56c 100644 --- a/core-java-modules/core-java-lang-3/README.md +++ b/core-java-modules/core-java-lang-3/README.md @@ -11,4 +11,5 @@ This module contains articles about core features in the Java language - [The transient Keyword in Java](https://www.baeldung.com/java-transient-keyword) - [How to Access an Iteration Counter in a For Each Loop](https://www.baeldung.com/java-foreach-counter) - [Comparing Doubles in Java](https://www.baeldung.com/java-comparing-doubles) +- [Guide to Implementing the compareTo Method](https://www.baeldung.com/java-compareto) - [[<-- Prev]](/core-java-modules/core-java-lang-2) From db46684ab9d8d462312637072a0fb2c23b3f6754 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 11 Feb 2021 18:20:25 +0800 Subject: [PATCH 359/361] Update README.md --- stripe/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stripe/README.md b/stripe/README.md index 9e41dcf945..36f0d6e3f3 100644 --- a/stripe/README.md +++ b/stripe/README.md @@ -5,4 +5,4 @@ This module contains articles about Stripe ### Relevant articles - [Introduction to the Stripe API for Java](https://www.baeldung.com/java-stripe-api) - +- [Viewing Contents of a JAR File](https://www.baeldung.com/java-view-jar-contents) From 676bc680f2def5434e9075ac97bd17bc4f134c44 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 11 Feb 2021 19:06:27 +0800 Subject: [PATCH 360/361] Update README.md --- .../spring-session/spring-session-jdbc/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/spring-security-modules/spring-session/spring-session-jdbc/README.md b/spring-security-modules/spring-session/spring-session-jdbc/README.md index a31ee044e8..6af3f53137 100644 --- a/spring-security-modules/spring-session/spring-session-jdbc/README.md +++ b/spring-security-modules/spring-session/spring-session-jdbc/README.md @@ -3,5 +3,3 @@ This module contains articles about Spring Session with JDBC. ### Relevant Articles: - -- [Spring Session with JDBC](https://www.baeldung.com/spring-session-jdbc) From 89eb93a46c195b775e8b817823f9238fc42f1e6e Mon Sep 17 00:00:00 2001 From: Hamid Reza Sharifi Date: Fri, 12 Feb 2021 14:20:52 +0330 Subject: [PATCH 361/361] Bael-4684-Prevent Cross-Site Scripting (XSS) in a Spring application-(new) (#10480) * #bael-4684: add main source code * #bael-4684: add test * #bael-4684: add required dependencies --- .../spring-5-security/pom.xml | 15 + .../java/com/baeldung/xss/Application.java | 14 + .../main/java/com/baeldung/xss/Person.java | 36 ++ .../com/baeldung/xss/PersonController.java | 31 + .../java/com/baeldung/xss/SecurityConf.java | 25 + .../main/java/com/baeldung/xss/XSSFilter.java | 44 ++ .../com/baeldung/xss/XSSRequestWrapper.java | 123 ++++ .../main/java/com/baeldung/xss/XSSUtils.java | 19 + .../src/main/resources/ESAPI.properties | 545 ++++++++++++++++++ .../xss/PersonControllerUnitTest.java | 64 ++ 10 files changed, 916 insertions(+) create mode 100644 spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/Application.java create mode 100644 spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/Person.java create mode 100644 spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/PersonController.java create mode 100644 spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/SecurityConf.java create mode 100644 spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/XSSFilter.java create mode 100644 spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/XSSRequestWrapper.java create mode 100644 spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/XSSUtils.java create mode 100644 spring-security-modules/spring-5-security/src/main/resources/ESAPI.properties create mode 100644 spring-security-modules/spring-5-security/src/test/java/com/baeldung/xss/PersonControllerUnitTest.java diff --git a/spring-security-modules/spring-5-security/pom.xml b/spring-security-modules/spring-5-security/pom.xml index 09de91491c..f50b5ff7a9 100644 --- a/spring-security-modules/spring-5-security/pom.xml +++ b/spring-security-modules/spring-5-security/pom.xml @@ -46,6 +46,21 @@ spring-security-test test
+ + org.owasp.esapi + esapi + 2.2.2.0 + + + org.jsoup + jsoup + 1.13.1 + + + commons-io + commons-io + 2.8.0 + diff --git a/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/Application.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/Application.java new file mode 100644 index 0000000000..b463a7adc3 --- /dev/null +++ b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/Application.java @@ -0,0 +1,14 @@ +package com.baeldung.xss; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; + +@SpringBootApplication +@EnableWebSecurity +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/Person.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/Person.java new file mode 100644 index 0000000000..1e7c02bae8 --- /dev/null +++ b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/Person.java @@ -0,0 +1,36 @@ +package com.baeldung.xss; + +public class Person { + private String firstName; + private String lastName; + private int age; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public String toString() { + return "Person {" + "firstName='" + firstName + '\'' + ", lastName='" + lastName + '\'' + ", age=" + age + '}'; + } +} diff --git a/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/PersonController.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/PersonController.java new file mode 100644 index 0000000000..8486e04e48 --- /dev/null +++ b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/PersonController.java @@ -0,0 +1,31 @@ +package com.baeldung.xss; + +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.Map; + +@RestController +@RequestMapping("/personService") +public class PersonController { + + @PostMapping(value = "/person") + private ResponseEntity savePerson(@RequestHeader Map headers, + @RequestParam String param, @RequestBody Person body) { + ObjectNode response = JsonNodeFactory.instance.objectNode(); + headers.forEach((key, value) -> response.put(key, value)); + response.put("firstName", body.getFirstName()); + response.put("lastName", body.getLastName()); + response.put("age", body.getAge()); + response.put("param", param); + return new ResponseEntity(response.toString(), HttpStatus.OK); + } +} \ No newline at end of file diff --git a/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/SecurityConf.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/SecurityConf.java new file mode 100644 index 0000000000..25d8026e4a --- /dev/null +++ b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/SecurityConf.java @@ -0,0 +1,25 @@ +package com.baeldung.xss; + +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@Configuration +public class SecurityConf extends WebSecurityConfigurerAdapter { + + @Override + public void configure(WebSecurity web) { + // Ignoring here is only for this example. Normally people would apply their own authentication/authorization policies + web.ignoring().antMatchers("/**"); + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .headers() + .xssProtection() + .and() + .contentSecurityPolicy("script-src 'self'"); + } +} diff --git a/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/XSSFilter.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/XSSFilter.java new file mode 100644 index 0000000000..431ed4d120 --- /dev/null +++ b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/XSSFilter.java @@ -0,0 +1,44 @@ +package com.baeldung.xss; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; +import org.springframework.core.Ordered; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; +import javax.servlet.Filter; +import javax.servlet.FilterConfig; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.ServletException; +import javax.servlet.FilterChain; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; + +@Component +@Order(Ordered.HIGHEST_PRECEDENCE) +public class XSSFilter implements Filter { + + @Override + public void init(FilterConfig filterConfig) { + } + + @Override + public void destroy() { + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + + XSSRequestWrapper wrappedRequest = new XSSRequestWrapper((HttpServletRequest) request); + + String body = IOUtils.toString(wrappedRequest.getReader()); + if (!StringUtils.isBlank(body)) { + body = XSSUtils.stripXSS(body); + wrappedRequest.resetInputStream(body.getBytes()); + } + + chain.doFilter(wrappedRequest, response); + } + +} \ No newline at end of file diff --git a/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/XSSRequestWrapper.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/XSSRequestWrapper.java new file mode 100644 index 0000000000..8fe4e20b5c --- /dev/null +++ b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/XSSRequestWrapper.java @@ -0,0 +1,123 @@ +package com.baeldung.xss; + +import org.apache.commons.codec.Charsets; +import org.apache.commons.io.IOUtils; +import javax.servlet.ReadListener; +import javax.servlet.ServletInputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.List; + +import static com.baeldung.xss.XSSUtils.stripXSS; + + +public class XSSRequestWrapper extends HttpServletRequestWrapper { + + private byte[] rawData; + private HttpServletRequest request; + private ResettableServletInputStream servletStream; + + public XSSRequestWrapper(HttpServletRequest request) { + super(request); + this.request = request; + this.servletStream = new ResettableServletInputStream(); + } + + public void resetInputStream(byte[] newRawData) { + rawData = newRawData; + servletStream.stream = new ByteArrayInputStream(newRawData); + } + + @Override + public ServletInputStream getInputStream() throws IOException { + if (rawData == null) { + rawData = IOUtils.toByteArray(this.request.getReader(), Charsets.UTF_8); + servletStream.stream = new ByteArrayInputStream(rawData); + } + return servletStream; + } + + @Override + public BufferedReader getReader() throws IOException { + if (rawData == null) { + rawData = IOUtils.toByteArray(this.request.getReader(), Charsets.UTF_8); + servletStream.stream = new ByteArrayInputStream(rawData); + } + return new BufferedReader(new InputStreamReader(servletStream)); + } + + private class ResettableServletInputStream extends ServletInputStream { + + private InputStream stream; + + @Override + public int read() throws IOException { + return stream.read(); + } + + @Override + public boolean isFinished() { + return false; + } + + @Override + public boolean isReady() { + return false; + } + + @Override + public void setReadListener(ReadListener readListener) { + + } + } + + @Override + public String[] getParameterValues(String parameter) { + String[] values = super.getParameterValues(parameter); + if (values == null) { + return null; + } + int count = values.length; + String[] encodedValues = new String[count]; + for (int i = 0; i < count; i++) { + encodedValues[i] = stripXSS(values[i]); + } + return encodedValues; + } + + @Override + public String getParameter(String parameter) { + String value = super.getParameter(parameter); + return stripXSS(value); + } + + @Override + public String getHeader(String name) { + String value = super.getHeader(name); + return stripXSS(value); + } + + @Override + public Enumeration getHeaders(String name) { + List result = new ArrayList<>(); + Enumeration headers = super.getHeaders(name); + while (headers.hasMoreElements()) { + String header = headers.nextElement(); + String[] tokens = header.split(","); + for (String token : tokens) { + result.add(stripXSS(token)); + } + } + return Collections.enumeration(result); + } + +} diff --git a/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/XSSUtils.java b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/XSSUtils.java new file mode 100644 index 0000000000..51bcba8115 --- /dev/null +++ b/spring-security-modules/spring-5-security/src/main/java/com/baeldung/xss/XSSUtils.java @@ -0,0 +1,19 @@ +package com.baeldung.xss; + +import org.jsoup.Jsoup; +import org.jsoup.safety.Whitelist; +import org.owasp.esapi.ESAPI; + +public class XSSUtils { + + public static String stripXSS(String value) { + if (value == null) { + return null; + } + value = ESAPI.encoder() + .canonicalize(value) + .replaceAll("\0", ""); + return Jsoup.clean(value, Whitelist.none()); + } + +} diff --git a/spring-security-modules/spring-5-security/src/main/resources/ESAPI.properties b/spring-security-modules/spring-5-security/src/main/resources/ESAPI.properties new file mode 100644 index 0000000000..a2746a4dbc --- /dev/null +++ b/spring-security-modules/spring-5-security/src/main/resources/ESAPI.properties @@ -0,0 +1,545 @@ +# +# OWASP Enterprise Security API (ESAPI) Properties file -- PRODUCTION Version +# +# This file is part of the Open Web Application Security Project (OWASP) +# Enterprise Security API (ESAPI) project. For details, please see +# https://owasp.org/www-project-enterprise-security-api/ +# +# Copyright (c) 2008,2009 - The OWASP Foundation +# +# DISCUSS: This may cause a major backwards compatibility issue, etc. but +# from a name space perspective, we probably should have prefaced +# all the property names with ESAPI or at least OWASP. Otherwise +# there could be problems is someone loads this properties file into +# the System properties. We could also put this file into the +# esapi.jar file (perhaps as a ResourceBundle) and then allow an external +# ESAPI properties be defined that would overwrite these defaults. +# That keeps the application's properties relatively simple as usually +# they will only want to override a few properties. If looks like we +# already support multiple override levels of this in the +# DefaultSecurityConfiguration class, but I'm suggesting placing the +# defaults in the esapi.jar itself. That way, if the jar is signed, +# we could detect if those properties had been tampered with. (The +# code to check the jar signatures is pretty simple... maybe 70-90 LOC, +# but off course there is an execution penalty (similar to the way +# that the separate sunjce.jar used to be when a class from it was +# first loaded). Thoughts? +############################################################################### +# +# WARNING: Operating system protection should be used to lock down the .esapi +# resources directory and all the files inside and all the directories all the +# way up to the root directory of the file system. Note that if you are using +# file-based implementations, that some files may need to be read-write as they +# get updated dynamically. +# +#=========================================================================== +# ESAPI Configuration +# +# If true, then print all the ESAPI properties set here when they are loaded. +# If false, they are not printed. Useful to reduce output when running JUnit tests. +# If you need to troubleshoot a properties related problem, turning this on may help. +# This is 'false' in the src/test/resources/.esapi version. It is 'true' by +# default for reasons of backward compatibility with earlier ESAPI versions. +ESAPI.printProperties=true + +# ESAPI is designed to be easily extensible. You can use the reference implementation +# or implement your own providers to take advantage of your enterprise's security +# infrastructure. The functions in ESAPI are referenced using the ESAPI locator, like: +# +# String ciphertext = +# ESAPI.encryptor().encrypt("Secret message"); // Deprecated in 2.0 +# CipherText cipherText = +# ESAPI.encryptor().encrypt(new PlainText("Secret message")); // Preferred +# +# Below you can specify the classname for the provider that you wish to use in your +# application. The only requirement is that it implement the appropriate ESAPI interface. +# This allows you to switch security implementations in the future without rewriting the +# entire application. +# +# ExperimentalAccessController requires ESAPI-AccessControlPolicy.xml in .esapi directory +ESAPI.AccessControl=org.owasp.esapi.reference.DefaultAccessController +# FileBasedAuthenticator requires users.txt file in .esapi directory +ESAPI.Authenticator=org.owasp.esapi.reference.FileBasedAuthenticator +ESAPI.Encoder=org.owasp.esapi.reference.DefaultEncoder +ESAPI.Encryptor=org.owasp.esapi.reference.crypto.JavaEncryptor + +ESAPI.Executor=org.owasp.esapi.reference.DefaultExecutor +ESAPI.HTTPUtilities=org.owasp.esapi.reference.DefaultHTTPUtilities +ESAPI.IntrusionDetector=org.owasp.esapi.reference.DefaultIntrusionDetector +# Log4JFactory Requires log4j.xml or log4j.properties in classpath - http://www.laliluna.de/log4j-tutorial.html +# Note that this is now considered deprecated! +ESAPI.Logger=org.owasp.esapi.logging.slf4j.Slf4JLogFactory +#ESAPI.Logger=org.owasp.esapi.logging.log4j.Log4JLogFactory +#ESAPI.Logger=org.owasp.esapi.logging.java.JavaLogFactory +# To use the new SLF4J logger in ESAPI (see GitHub issue #129), set +# ESAPI.Logger=org.owasp.esapi.logging.slf4j.Slf4JLogFactory +# and do whatever other normal SLF4J configuration that you normally would do for your application. +ESAPI.Randomizer=org.owasp.esapi.reference.DefaultRandomizer +ESAPI.Validator=org.owasp.esapi.reference.DefaultValidator + +#=========================================================================== +# ESAPI Authenticator +# +Authenticator.AllowedLoginAttempts=3 +Authenticator.MaxOldPasswordHashes=13 +Authenticator.UsernameParameterName=username +Authenticator.PasswordParameterName=password +# RememberTokenDuration (in days) +Authenticator.RememberTokenDuration=14 +# Session Timeouts (in minutes) +Authenticator.IdleTimeoutDuration=20 +Authenticator.AbsoluteTimeoutDuration=120 + +#=========================================================================== +# ESAPI Encoder +# +# ESAPI canonicalizes input before validation to prevent bypassing filters with encoded attacks. +# Failure to canonicalize input is a very common mistake when implementing validation schemes. +# Canonicalization is automatic when using the ESAPI Validator, but you can also use the +# following code to canonicalize data. +# +# ESAPI.Encoder().canonicalize( "%22hello world"" ); +# +# Multiple encoding is when a single encoding format is applied multiple times. Allowing +# multiple encoding is strongly discouraged. +Encoder.AllowMultipleEncoding=false + +# Mixed encoding is when multiple different encoding formats are applied, or when +# multiple formats are nested. Allowing multiple encoding is strongly discouraged. +Encoder.AllowMixedEncoding=false + +# The default list of codecs to apply when canonicalizing untrusted data. The list should include the codecs +# for all downstream interpreters or decoders. For example, if the data is likely to end up in a URL, HTML, or +# inside JavaScript, then the list of codecs below is appropriate. The order of the list is not terribly important. +Encoder.DefaultCodecList=HTMLEntityCodec,PercentCodec,JavaScriptCodec + + +#=========================================================================== +# ESAPI Encryption +# +# The ESAPI Encryptor provides basic cryptographic functions with a simplified API. +# To get started, generate a new key using java -classpath esapi.jar org.owasp.esapi.reference.crypto.JavaEncryptor +# There is not currently any support for key rotation, so be careful when changing your key and salt as it +# will invalidate all signed, encrypted, and hashed data. +# +# WARNING: Not all combinations of algorithms and key lengths are supported. +# If you choose to use a key length greater than 128, you MUST download the +# unlimited strength policy files and install in the lib directory of your JRE/JDK. +# See http://java.sun.com/javase/downloads/index.jsp for more information. +# +# ***** IMPORTANT: Do NOT forget to replace these with your own values! ***** +# To calculate these values, you can run: +# java -classpath esapi.jar org.owasp.esapi.reference.crypto.JavaEncryptor +# +#Encryptor.MasterKey= +#Encryptor.MasterSalt= + +# Provides the default JCE provider that ESAPI will "prefer" for its symmetric +# encryption and hashing. (That is it will look to this provider first, but it +# will defer to other providers if the requested algorithm is not implemented +# by this provider.) If left unset, ESAPI will just use your Java VM's current +# preferred JCE provider, which is generally set in the file +# "$JAVA_HOME/jre/lib/security/java.security". +# +# The main intent of this is to allow ESAPI symmetric encryption to be +# used with a FIPS 140-2 compliant crypto-module. For details, see the section +# "Using ESAPI Symmetric Encryption with FIPS 140-2 Cryptographic Modules" in +# the ESAPI 2.0 Symmetric Encryption User Guide, at: +# http://owasp-esapi-java.googlecode.com/svn/trunk/documentation/esapi4java-core-2.0-symmetric-crypto-user-guide.html +# However, this property also allows you to easily use an alternate JCE provider +# such as "Bouncy Castle" without having to make changes to "java.security". +# See Javadoc for SecurityProviderLoader for further details. If you wish to use +# a provider that is not known to SecurityProviderLoader, you may specify the +# fully-qualified class name of the JCE provider class that implements +# java.security.Provider. If the name contains a '.', this is interpreted as +# a fully-qualified class name that implements java.security.Provider. +# +# NOTE: Setting this property has the side-effect of changing it in your application +# as well, so if you are using JCE in your application directly rather than +# through ESAPI (you wouldn't do that, would you? ;-), it will change the +# preferred JCE provider there as well. +# +# Default: Keeps the JCE provider set to whatever JVM sets it to. +Encryptor.PreferredJCEProvider= + +# AES is the most widely used and strongest encryption algorithm. This +# should agree with your Encryptor.CipherTransformation property. +# Warning: This property does not control the default reference implementation for +# ESAPI 2.0 using JavaEncryptor. Also, this property will be dropped +# in the future. +# @deprecated +Encryptor.EncryptionAlgorithm=AES +# For ESAPI Java 2.0 - New encrypt / decrypt methods use this. +Encryptor.CipherTransformation=AES/CBC/PKCS5Padding + +# Applies to ESAPI 2.0 and later only! +# Comma-separated list of cipher modes that provide *BOTH* +# confidentiality *AND* message authenticity. (NIST refers to such cipher +# modes as "combined modes" so that's what we shall call them.) If any of these +# cipher modes are used then no MAC is calculated and stored +# in the CipherText upon encryption. Likewise, if one of these +# cipher modes is used with decryption, no attempt will be made +# to validate the MAC contained in the CipherText object regardless +# of whether it contains one or not. Since the expectation is that +# these cipher modes support support message authenticity already, +# injecting a MAC in the CipherText object would be at best redundant. +# +# Note that as of JDK 1.5, the SunJCE provider does not support *any* +# of these cipher modes. Of these listed, only GCM and CCM are currently +# NIST approved. YMMV for other JCE providers. E.g., Bouncy Castle supports +# GCM and CCM with "NoPadding" mode, but not with "PKCS5Padding" or other +# padding modes. +Encryptor.cipher_modes.combined_modes=GCM,CCM,IAPM,EAX,OCB,CWC + +# Applies to ESAPI 2.0 and later only! +# Additional cipher modes allowed for ESAPI 2.0 encryption. These +# cipher modes are in _addition_ to those specified by the property +# 'Encryptor.cipher_modes.combined_modes'. +# Note: We will add support for streaming modes like CFB & OFB once +# we add support for 'specified' to the property 'Encryptor.ChooseIVMethod' +# (probably in ESAPI 2.1). +# DISCUSS: Better name? +Encryptor.cipher_modes.additional_allowed=CBC + +# Default key size to use for cipher specified by Encryptor.EncryptionAlgorithm. +# Note that this MUST be a valid key size for the algorithm being used +# (as specified by Encryptor.EncryptionAlgorithm). So for example, if AES is used, +# it must be 128, 192, or 256. If DESede is chosen, then it must be either 112 or 168. +# +# Note that 128-bits is almost always sufficient and for AES it appears to be more +# somewhat more resistant to related key attacks than is 256-bit AES.) +# +# Defaults to 128-bits if left blank. +# +# NOTE: If you use a key size > 128-bits, then you MUST have the JCE Unlimited +# Strength Jurisdiction Policy files installed!!! +# +Encryptor.EncryptionKeyLength=128 + +# This is the _minimum_ key size (in bits) that we allow with ANY symmetric +# cipher for doing encryption. (There is no minimum for decryption.) +# +# Generally, if you only use one algorithm, this should be set the same as +# the Encryptor.EncryptionKeyLength property. +Encryptor.MinEncryptionKeyLength=128 + +# Because 2.x uses CBC mode by default, it requires an initialization vector (IV). +# (All cipher modes except ECB require an IV.) There are two choices: we can either +# use a fixed IV known to both parties or allow ESAPI to choose a random IV. While +# the IV does not need to be hidden from adversaries, it is important that the +# adversary not be allowed to choose it. Also, random IVs are generally much more +# secure than fixed IVs. (In fact, it is essential that feed-back cipher modes +# such as CFB and OFB use a different IV for each encryption with a given key so +# in such cases, random IVs are much preferred. By default, ESAPI 2.0 uses random +# IVs. If you wish to use 'fixed' IVs, set 'Encryptor.ChooseIVMethod=fixed' and +# uncomment the Encryptor.fixedIV. +# +# Valid values: random|fixed|specified 'specified' not yet implemented; planned for 2.3 +# 'fixed' is deprecated as of 2.2 +# and will be removed in 2.3. +Encryptor.ChooseIVMethod=random + + +# If you choose to use a fixed IV, then you must place a fixed IV here that +# is known to all others who are sharing your secret key. The format should +# be a hex string that is the same length as the cipher block size for the +# cipher algorithm that you are using. The following is an *example* for AES +# from an AES test vector for AES-128/CBC as described in: +# NIST Special Publication 800-38A (2001 Edition) +# "Recommendation for Block Cipher Modes of Operation". +# (Note that the block size for AES is 16 bytes == 128 bits.) +# +# @Deprecated -- fixed IVs are deprecated as of the 2.2 release and support +# will be removed in the next release (tentatively, 2.3). +# If you MUST use this, at least replace this IV with one +# that your legacy application was using. +Encryptor.fixedIV=0x000102030405060708090a0b0c0d0e0f + +# Whether or not CipherText should use a message authentication code (MAC) with it. +# This prevents an adversary from altering the IV as well as allowing a more +# fool-proof way of determining the decryption failed because of an incorrect +# key being supplied. This refers to the "separate" MAC calculated and stored +# in CipherText, not part of any MAC that is calculated as a result of a +# "combined mode" cipher mode. +# +# If you are using ESAPI with a FIPS 140-2 cryptographic module, you *must* also +# set this property to false. That is because ESAPI takes the master key and +# derives 2 keys from it--a key for the MAC and a key for encryption--and +# because ESAPI is not itself FIPS 140-2 verified such intermediary aterations +# to keys from FIPS approved sources would have the effect of making your FIPS +# approved key generation and thus your FIPS approved JCE provider unapproved! +# More details in +# documentation/esapi4java-core-2.0-readme-crypto-changes.html +# documentation/esapi4java-core-2.0-symmetric-crypto-user-guide.html +# You have been warned. +Encryptor.CipherText.useMAC=true + +# Whether or not the PlainText object may be overwritten and then marked +# eligible for garbage collection. If not set, this is still treated as 'true'. +Encryptor.PlainText.overwrite=true + +# Do not use DES except in a legacy situations. 56-bit is way too small key size. +#Encryptor.EncryptionKeyLength=56 +#Encryptor.MinEncryptionKeyLength=56 +#Encryptor.EncryptionAlgorithm=DES + +# TripleDES is considered strong enough for most purposes. +# Note: There is also a 112-bit version of DESede. Using the 168-bit version +# requires downloading the special jurisdiction policy from Sun. +#Encryptor.EncryptionKeyLength=168 +#Encryptor.MinEncryptionKeyLength=112 +#Encryptor.EncryptionAlgorithm=DESede + +Encryptor.HashAlgorithm=SHA-512 +Encryptor.HashIterations=1024 +Encryptor.DigitalSignatureAlgorithm=SHA1withDSA +Encryptor.DigitalSignatureKeyLength=1024 +Encryptor.RandomAlgorithm=SHA1PRNG +Encryptor.CharacterEncoding=UTF-8 + +# This is the Pseudo Random Function (PRF) that ESAPI's Key Derivation Function +# (KDF) normally uses. Note this is *only* the PRF used for ESAPI's KDF and +# *not* what is used for ESAPI's MAC. (Currently, HmacSHA1 is always used for +# the MAC, mostly to keep the overall size at a minimum.) +# +# Currently supported choices for JDK 1.5 and 1.6 are: +# HmacSHA1 (160 bits), HmacSHA256 (256 bits), HmacSHA384 (384 bits), and +# HmacSHA512 (512 bits). +# Note that HmacMD5 is *not* supported for the PRF used by the KDF even though +# the JDKs support it. See the ESAPI 2.0 Symmetric Encryption User Guide +# further details. +Encryptor.KDF.PRF=HmacSHA256 +#=========================================================================== +# ESAPI HttpUtilties +# +# The HttpUtilities provide basic protections to HTTP requests and responses. Primarily these methods +# protect against malicious data from attackers, such as unprintable characters, escaped characters, +# and other simple attacks. The HttpUtilities also provides utility methods for dealing with cookies, +# headers, and CSRF tokens. +# +# Default file upload location (remember to escape backslashes with \\) +HttpUtilities.UploadDir=C:\\ESAPI\\testUpload +HttpUtilities.UploadTempDir=C:\\temp +# Force flags on cookies, if you use HttpUtilities to set cookies +HttpUtilities.ForceHttpOnlySession=false +HttpUtilities.ForceSecureSession=false +HttpUtilities.ForceHttpOnlyCookies=true +HttpUtilities.ForceSecureCookies=true +# Maximum size of HTTP header key--the validator regex may have additional values. +HttpUtilities.MaxHeaderNameSize=256 +# Maximum size of HTTP header value--the validator regex may have additional values. +HttpUtilities.MaxHeaderValueSize=4096 +# Maximum size of JSESSIONID for the application--the validator regex may have additional values. +HttpUtilities.HTTPJSESSIONIDLENGTH=50 +# Maximum length of a URL (see https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers) +HttpUtilities.URILENGTH=2000 +# Maximum length of a redirect +HttpUtilities.maxRedirectLength=512 +# Maximum length for an http scheme +HttpUtilities.HTTPSCHEMELENGTH=10 +# Maximum length for an http host +HttpUtilities.HTTPHOSTLENGTH=100 +# Maximum length for an http path +HttpUtilities.HTTPPATHLENGTH=150 +#Maximum length for a context path +HttpUtilities.contextPathLength=150 +#Maximum length for an httpServletPath +HttpUtilities.HTTPSERVLETPATHLENGTH=100 +#Maximum length for an http query parameter name +HttpUtilities.httpQueryParamNameLength=100 +#Maximum length for an http query parameter -- old default was 2000, but that's the max length for a URL... +HttpUtilities.httpQueryParamValueLength=500 +# File upload configuration +HttpUtilities.ApprovedUploadExtensions=.pdf,.doc,.docx,.ppt,.pptx,.xls,.xlsx,.rtf,.txt,.jpg,.png +HttpUtilities.MaxUploadFileBytes=500000000 +# Using UTF-8 throughout your stack is highly recommended. That includes your database driver, +# container, and any other technologies you may be using. Failure to do this may expose you +# to Unicode transcoding injection attacks. Use of UTF-8 does not hinder internationalization. +HttpUtilities.ResponseContentType=text/html; charset=UTF-8 +# This is the name of the cookie used to represent the HTTP session +# Typically this will be the default "JSESSIONID" +HttpUtilities.HttpSessionIdName=JSESSIONID +#Sets whether or not we will overwrite http status codes to 200. +HttpUtilities.OverwriteStatusCodes=true +#Sets the application's base character encoding. This is forked from the Java Encryptor property. +HttpUtilities.CharacterEncoding=UTF-8 + +#=========================================================================== +# ESAPI Executor +# CHECKME - This should be made OS independent. Don't use unsafe defaults. +# # Examples only -- do NOT blindly copy! +# For Windows: +# Executor.WorkingDirectory=C:\\Windows\\Temp +# Executor.ApprovedExecutables=C:\\Windows\\System32\\cmd.exe,C:\\Windows\\System32\\runas.exe +# For *nux, MacOS: +# Executor.WorkingDirectory=/tmp +# Executor.ApprovedExecutables=/bin/bash +Executor.WorkingDirectory= +Executor.ApprovedExecutables= + + +#=========================================================================== +# ESAPI Logging +# Set the application name if these logs are combined with other applications +Logger.ApplicationName=ExampleApplication +# If you use an HTML log viewer that does not properly HTML escape log data, you can set LogEncodingRequired to true +Logger.LogEncodingRequired=false +# Determines whether ESAPI should log the application name. This might be clutter in some single-server/single-app environments. +Logger.LogApplicationName=true +# Determines whether ESAPI should log the server IP and port. This might be clutter in some single-server environments. +Logger.LogServerIP=true +# LogFileName, the name of the logging file. Provide a full directory path (e.g., C:\\ESAPI\\ESAPI_logging_file) if you +# want to place it in a specific directory. +Logger.LogFileName=ESAPI_logging_file +# MaxLogFileSize, the max size (in bytes) of a single log file before it cuts over to a new one (default is 10,000,000) +Logger.MaxLogFileSize=10000000 +# Determines whether ESAPI should log the user info. +Logger.UserInfo=true +# Determines whether ESAPI should log the session id and client IP. +Logger.ClientInfo=true + +#=========================================================================== +# ESAPI Intrusion Detection +# +# Each event has a base to which .count, .interval, and .action are added +# The IntrusionException will fire if we receive "count" events within "interval" seconds +# The IntrusionDetector is configurable to take the following actions: log, logout, and disable +# (multiple actions separated by commas are allowed e.g. event.test.actions=log,disable +# +# Custom Events +# Names must start with "event." as the base +# Use IntrusionDetector.addEvent( "test" ) in your code to trigger "event.test" here +# You can also disable intrusion detection completely by changing +# the following parameter to true +# +IntrusionDetector.Disable=false +# +IntrusionDetector.event.test.count=2 +IntrusionDetector.event.test.interval=10 +IntrusionDetector.event.test.actions=disable,log + +# Exception Events +# All EnterpriseSecurityExceptions are registered automatically +# Call IntrusionDetector.getInstance().addException(e) for Exceptions that do not extend EnterpriseSecurityException +# Use the fully qualified classname of the exception as the base + +# any intrusion is an attack +IntrusionDetector.org.owasp.esapi.errors.IntrusionException.count=1 +IntrusionDetector.org.owasp.esapi.errors.IntrusionException.interval=1 +IntrusionDetector.org.owasp.esapi.errors.IntrusionException.actions=log,disable,logout + +# for test purposes +# CHECKME: Shouldn't there be something in the property name itself that designates +# that these are for testing??? +IntrusionDetector.org.owasp.esapi.errors.IntegrityException.count=10 +IntrusionDetector.org.owasp.esapi.errors.IntegrityException.interval=5 +IntrusionDetector.org.owasp.esapi.errors.IntegrityException.actions=log,disable,logout + +# rapid validation errors indicate scans or attacks in progress +# org.owasp.esapi.errors.ValidationException.count=10 +# org.owasp.esapi.errors.ValidationException.interval=10 +# org.owasp.esapi.errors.ValidationException.actions=log,logout + +# sessions jumping between hosts indicates session hijacking +IntrusionDetector.org.owasp.esapi.errors.AuthenticationHostException.count=2 +IntrusionDetector.org.owasp.esapi.errors.AuthenticationHostException.interval=10 +IntrusionDetector.org.owasp.esapi.errors.AuthenticationHostException.actions=log,logout + + +#=========================================================================== +# ESAPI Validation +# +# The ESAPI Validator works on regular expressions with defined names. You can define names +# either here, or you may define application specific patterns in a separate file defined below. +# This allows enterprises to specify both organizational standards as well as application specific +# validation rules. +# +# Use '\p{L}' (without the quotes) within the character class to match +# any Unicode LETTER. You can also use a range, like: \u00C0-\u017F +# You can also use any of the regex flags as documented at +# https://docs.oracle.com/javase/tutorial/essential/regex/pattern.html, e.g. (?u) +# +Validator.ConfigurationFile=validation.properties + +# Validators used by ESAPI +Validator.AccountName=^[a-zA-Z0-9]{3,20}$ +Validator.SystemCommand=^[a-zA-Z\\-\\/]{1,64}$ +Validator.RoleName=^[a-z]{1,20}$ + +#the word TEST below should be changed to your application +#name - only relative URL's are supported +Validator.Redirect=^\\/test.*$ + +# Global HTTP Validation Rules +# Values with Base64 encoded data (e.g. encrypted state) will need at least [a-zA-Z0-9\/+=] +Validator.HTTPScheme=^(http|https)$ +Validator.HTTPServerName=^[a-zA-Z0-9_.\\-]*$ +Validator.HTTPCookieName=^[a-zA-Z0-9\\-_]{1,32}$ +Validator.HTTPCookieValue=^[a-zA-Z0-9\\-\\/+=_ ]*$ +# Note that headerName and Value length is also configured in the HTTPUtilities section +Validator.HTTPHeaderName=^[a-zA-Z0-9\\-_]{1,256}$ +Validator.HTTPHeaderValue=^[a-zA-Z0-9()\\-=\\*\\.\\?;,+\\/:&_ ]*$ +Validator.HTTPServletPath=^[a-zA-Z0-9.\\-\\/_]*$ +Validator.HTTPPath=^[a-zA-Z0-9.\\-_]*$ +Validator.HTTPURL=^.*$ +Validator.HTTPJSESSIONID=^[A-Z0-9]{10,32}$ + + +# Contributed by Fraenku@gmx.ch +# Github Issue 126 https://github.com/ESAPI/esapi-java-legacy/issues/126 +Validator.HTTPParameterName=^[a-zA-Z0-9_\\-]{1,32}$ +Validator.HTTPParameterValue=^[\\p{L}\\p{N}.\\-/+=_ !$*?@]{0,1000}$ +Validator.HTTPContextPath=^/[a-zA-Z0-9.\\-_]*$ +Validator.HTTPQueryString=^([a-zA-Z0-9_\\-]{1,32}=[\\p{L}\\p{N}.\\-/+=_ !$*?@%]*&?)*$ +Validator.HTTPURI=^/([a-zA-Z0-9.\\-_]*/?)*$ + + +# Validation of file related input +Validator.FileName=^[a-zA-Z0-9!@#$%^&{}\\[\\]()_+\\-=,.~'` ]{1,255}$ +Validator.DirectoryName=^[a-zA-Z0-9:/\\\\!@#$%^&{}\\[\\]()_+\\-=,.~'` ]{1,255}$ + +# Validation of dates. Controls whether or not 'lenient' dates are accepted. +# See DataFormat.setLenient(boolean flag) for further details. +Validator.AcceptLenientDates=false + +# ~~~~~ Important Note ~~~~~ +# This is a workaround to make sure that a commit to address GitHub issue #509 +# doesn't accidentally break someone's production code. So essentially what we +# are doing is to reverting back to the previous possibly buggy (by +# documentation intent at least), but, by now, expected legacy behavior. +# Prior to the code changes for issue #509, if invalid / malicious HTML input was +# observed, AntiSamy would simply attempt to sanitize (cleanse) it and it would +# only be logged. However, the code change made ESAPI comply with its +# documentation, which stated that a ValidationException should be thrown in +# such cases. Unfortunately, changing this behavior--especially when no one is +# 100% certain that the documentation was correct--could break existing code +# using ESAPI so after a lot of debate, issue #521 was created to restore the +# previous behavior, but still allow the documented behavior. (We did this +# because it wasn't really causing an security issues since AntiSamy would clean +# it up anyway and we value backward compatibility as long as it doesn't clearly +# present security vulnerabilities.) +# More defaults about this are written up under GitHub issue #521 and +# the pull request it references. Future major releases of ESAPI (e.g., ESAPI 3.x) +# will not support this previous behavior, but it will remain for ESAPI 2.x. +# Set this to 'throw' if you want the originally intended behavior of throwing +# that was fixed via issue #509. Set to 'clean' if you want want the HTML input +# sanitized instead. +# +# Possible values: +# clean -- Use the legacy behavior where unsafe HTML input is logged and the +# sanitized (i.e., clean) input as determined by AntiSamy and your +# AntiSamy rules is returned. This is the default behavior if this +# new property is not found. +# throw -- The new, presumably correct and originally intended behavior where +# a ValidationException is thrown when unsafe HTML input is +# encountered. +# +#Validator.HtmlValidationAction=clean +Validator.HtmlValidationAction=throw + +# With the fix for #310 to enable loading antisamy-esapi.xml from the classpath +# also an enhancement was made to be able to use a different filename for the configuration. +# You don't have to configure the filename here, but in that case the code will keep looking for antisamy-esapi.xml. +# This is the default behaviour of ESAPI. +# +#Validator.HtmlValidationConfigurationFile=antisamy-esapi.xml \ No newline at end of file diff --git a/spring-security-modules/spring-5-security/src/test/java/com/baeldung/xss/PersonControllerUnitTest.java b/spring-security-modules/spring-5-security/src/test/java/com/baeldung/xss/PersonControllerUnitTest.java new file mode 100644 index 0000000000..4e278ebf16 --- /dev/null +++ b/spring-security-modules/spring-5-security/src/test/java/com/baeldung/xss/PersonControllerUnitTest.java @@ -0,0 +1,64 @@ +package com.baeldung.xss; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.http.*; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; +import java.io.IOException; +import static org.assertj.core.api.Assertions.assertThat; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +class PersonControllerUnitTest { + + @LocalServerPort + int randomServerPort; + + @Test + public void givenRequestIsSuspicious_whenRequestIsPost_thenResponseIsClean() + throws IOException { + // given + String createPersonUrl; + RestTemplate restTemplate; + HttpHeaders headers; + UriComponentsBuilder builder; + ObjectMapper objectMapper = new ObjectMapper(); + ObjectNode personJsonObject = JsonNodeFactory.instance.objectNode(); + createPersonUrl = "http://localhost:" + randomServerPort + "/personService/person"; + restTemplate = new RestTemplate(); + headers = new HttpHeaders(); + + // when + personJsonObject.put("id", 1); + personJsonObject.put("firstName", "baeldung "); + personJsonObject.put("lastName", "baeldung click me!"); + + builder = UriComponentsBuilder.fromHttpUrl(createPersonUrl) + .queryParam("param", ""); + headers.add("header_4", "

Your search for 'flowers '"); + HttpEntity request = new HttpEntity<>(personJsonObject.toString(), headers); + + ResponseEntity personResultAsJsonStr = restTemplate.exchange(builder.toUriString(), + HttpMethod.POST, request, String.class); + JsonNode root = objectMapper.readTree(personResultAsJsonStr.getBody()); + + // then + assertThat(root.get("firstName").textValue()).isEqualTo("baeldung "); + assertThat(root.get("lastName").textValue()).isEqualTo("baeldung click me!"); + assertThat(root.get("param").textValue()).isEmpty(); + assertThat(root.get("header_1").textValue()).isEmpty(); + assertThat(root.get("header_2").textValue()).isEmpty(); + assertThat(root.get("header_3").textValue()).isEmpty(); + assertThat(root.get("header_4").textValue()).isEqualTo("Your search for 'flowers '"); + } +}