diff --git a/.github/ISSUE_TEMPLATE/issue_report.md b/.github/ISSUE_TEMPLATE/issue_report.md new file mode 100644 index 0000000000..725ae12064 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/issue_report.md @@ -0,0 +1,38 @@ +--- +name: Issue Report +about: Report an issue to help us improve +title: '[ISSUE] ' +--- + +**Article and Module Links** +A link to the affected article and the affected module. The link to the module is the one in the "over on GitHub" standard phrase. + +**Describe the Issue** +A clear and concise description of what the issue is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected Behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Environment (please complete the following information):** +- OS: [e.g. Windows] +- Browser [e.g. chrome, safari] +- Version [e.g. 22] + +**Additional Context** +Add any other context about the issue here. + +Note that, unfortunately, we can only help with issues that are specifically and directly related to the article - not with your own, custom application. + +StackOverflow is a great place to ask more general questions. + +That's primarily because we get a large number of questions and - while we do try to go through as much as everything and help wherever we can, we can't really get back to all of them. \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..642f4c6707 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,11 @@ +# Contributing to Baeldung Tutorials +First off, thank you for considering contributing to Baeldung Tutorials. + +## Reporting Issues +Before you submit an issue, please review the guidelines below: + +1. **No Custom Modifications:** If your issue arises from any custom modifications you've made to the code in the repository, we won't be able to assist. We can only help if the issue is reproducible with the untouched codebase from this repo. If you're working with a modified version, consider asking for help on StackOverflow or other relevant forums. +2. **Use a clear and descriptive title** for the issue to identify the problem. +3. **Include a link to the article** you're having issues with. +4. **Describe the exact steps which reproduce the problem** in as many details as possible. +5. **Additional Details:** Offer any other context or descriptions that could be useful. Screenshots, error messages, copy/pasteable snippets, or logs can be immensely helpful. \ No newline at end of file diff --git a/apache-poi-3/pom.xml b/apache-poi-3/pom.xml new file mode 100644 index 0000000000..905db3d58c --- /dev/null +++ b/apache-poi-3/pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + apache-poi-3 + 0.0.1-SNAPSHOT + apache-poi-3 + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + org.apache.poi + poi-ooxml + ${poi.version} + + + org.apache.poi + poi-scratchpad + ${poi.version} + + + + com.github.ozlerhakan + poiji + ${poiji.version} + + + + + org.apache.poi + poi + ${poi.version} + + + + org.apache.poi + poi-ooxml-schemas + 4.1.2 + + + + org.apache.xmlbeans + xmlbeans + 5.1.1 + + + + org.apache.commons + commons-collections4 + 4.4 + + + + org.dhatim + fastexcel + ${fastexcel.version} + + + + org.dhatim + fastexcel-reader + ${fastexcel.version} + + + + net.sourceforge.jexcelapi + jxl + ${jxl.version} + + + + org.apache.logging.log4j + log4j-api + 2.17.1 + + + + org.apache.logging.log4j + log4j-core + 2.17.1 + + + + + 5.2.3 + 4.1.1 + 0.15.7 + 2.6.12 + + + \ No newline at end of file diff --git a/apache-poi-3/src/main/java/com/baeldung/convert/exceldatatolist/FoodInfo.java b/apache-poi-3/src/main/java/com/baeldung/convert/exceldatatolist/FoodInfo.java new file mode 100644 index 0000000000..b8fe4522de --- /dev/null +++ b/apache-poi-3/src/main/java/com/baeldung/convert/exceldatatolist/FoodInfo.java @@ -0,0 +1,54 @@ +package com.baeldung.convert.exceldatatolist; + +import com.poiji.annotation.ExcelCellName; + +public class FoodInfo { + + @ExcelCellName("Category") + private String category; //food category + @ExcelCellName("Name") + private String name; // food name + @ExcelCellName("Measure") + private String measure; + @ExcelCellName("Calories") + private double calories; //amount of calories in kcal/measure + + @Override + public String toString() { + return "FoodInfo{" + "category='" + category + '\'' + ", name='" + name + '\'' + ", measure='" + measure + '\'' + ", calories=" + calories + "} \n"; + } + + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getMeasure() { + return measure; + } + + public void setMeasure(String measure) { + this.measure = measure; + } + + public double getCalories() { + return calories; + } + + public void setCalories(double calories) { + this.calories = calories; + } + +} diff --git a/apache-poi-3/src/main/java/com/baeldung/convert/exceldatatolist/fastexcel/ExcelDataToListOfObjectsFastExcel.java b/apache-poi-3/src/main/java/com/baeldung/convert/exceldatatolist/fastexcel/ExcelDataToListOfObjectsFastExcel.java new file mode 100644 index 0000000000..87d31520e6 --- /dev/null +++ b/apache-poi-3/src/main/java/com/baeldung/convert/exceldatatolist/fastexcel/ExcelDataToListOfObjectsFastExcel.java @@ -0,0 +1,42 @@ +package com.baeldung.convert.exceldatatolist.fastexcel; + +import java.io.FileInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Stream; + +import org.dhatim.fastexcel.reader.ReadableWorkbook; +import org.dhatim.fastexcel.reader.Row; +import org.dhatim.fastexcel.reader.Sheet; + +import com.baeldung.convert.exceldatatolist.FoodInfo; + +public class ExcelDataToListOfObjectsFastExcel { + public static List excelDataToListOfObjets_withFastExcel(String fileLocation)throws IOException, NumberFormatException { + List foodData = new ArrayList(); + + try (FileInputStream file = new FileInputStream(fileLocation); + ReadableWorkbook wb = new ReadableWorkbook(file)) { + Sheet sheet = wb.getFirstSheet(); + for (Row row: + sheet.read() + ) { + if(row.getRowNum() == 1) { + continue; + } + FoodInfo food = new FoodInfo(); + food.setCategory(row.getCellText(0)); + food.setName(row.getCellText(1)); + food.setMeasure(row.getCellText(2)); + food.setCalories(Double.parseDouble(row.getCellText(3))); + + foodData.add(food); + + } + } + + return foodData; + } +} diff --git a/apache-poi-3/src/main/java/com/baeldung/convert/exceldatatolist/jexcelapi/ExcelDataToListOfObjectsJxl.java b/apache-poi-3/src/main/java/com/baeldung/convert/exceldatatolist/jexcelapi/ExcelDataToListOfObjectsJxl.java new file mode 100644 index 0000000000..61ba5e4700 --- /dev/null +++ b/apache-poi-3/src/main/java/com/baeldung/convert/exceldatatolist/jexcelapi/ExcelDataToListOfObjectsJxl.java @@ -0,0 +1,37 @@ +package com.baeldung.convert.exceldatatolist.jexcelapi; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import com.baeldung.convert.exceldatatolist.FoodInfo; + +import jxl.Sheet; +import jxl.Workbook; +import jxl.read.biff.BiffException; + +public class ExcelDataToListOfObjectsJxl { + public static List excelDataToListOfObjets_withJxl(String fileLocation) throws IOException, BiffException { + + List foodData = new ArrayList(); + + Workbook workbook = Workbook.getWorkbook(new File(fileLocation)); + Sheet sheet = workbook.getSheet(0); + + int rows = sheet.getRows(); + + for (int i = 1; i < rows; i++) { + FoodInfo foodInfo = new FoodInfo(); + + foodInfo.setCategory(sheet.getCell(0, i).getContents()); + foodInfo.setName(sheet.getCell(1, i).getContents()); + foodInfo.setMeasure(sheet.getCell(2, i).getContents()); + foodInfo.setCalories(Double.parseDouble(sheet.getCell(3, i).getContents())); + + foodData.add(foodInfo); + + } + return foodData; + } +} diff --git a/apache-poi-3/src/main/java/com/baeldung/convert/exceldatatolist/poi/ExcelDataToListApachePOI.java b/apache-poi-3/src/main/java/com/baeldung/convert/exceldatatolist/poi/ExcelDataToListApachePOI.java new file mode 100644 index 0000000000..8b568b889a --- /dev/null +++ b/apache-poi-3/src/main/java/com/baeldung/convert/exceldatatolist/poi/ExcelDataToListApachePOI.java @@ -0,0 +1,39 @@ +package com.baeldung.convert.exceldatatolist.poi; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.poi.ss.usermodel.DataFormatter; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.baeldung.convert.exceldatatolist.FoodInfo; + +public class ExcelDataToListApachePOI { + public static List excelDataToListOfObjets_withApachePOI(String fileLocation) throws IOException { + FileInputStream file = new FileInputStream(new File(fileLocation)); + Workbook workbook = new XSSFWorkbook(file); + Sheet sheet = workbook.getSheetAt(0); + List foodData = new ArrayList(); + DataFormatter dataFormatter = new DataFormatter(); + for (int n = 1; n < sheet.getPhysicalNumberOfRows(); n++) { + Row row = sheet.getRow(n); + FoodInfo foodInfo = new FoodInfo(); + int i = row.getFirstCellNum(); + + foodInfo.setCategory(dataFormatter.formatCellValue(row.getCell(i))); + foodInfo.setName(dataFormatter.formatCellValue(row.getCell(++i))); + foodInfo.setMeasure(dataFormatter.formatCellValue(row.getCell(++i))); + foodInfo.setCalories(Double.parseDouble(dataFormatter.formatCellValue(row.getCell(++i)))); + + foodData.add(foodInfo); + + } + return foodData; + } +} diff --git a/apache-poi-3/src/main/java/com/baeldung/convert/exceldatatolist/poiji/ExcelDataToListOfObjectsPOIJI.java b/apache-poi-3/src/main/java/com/baeldung/convert/exceldatatolist/poiji/ExcelDataToListOfObjectsPOIJI.java new file mode 100644 index 0000000000..be190d38f7 --- /dev/null +++ b/apache-poi-3/src/main/java/com/baeldung/convert/exceldatatolist/poiji/ExcelDataToListOfObjectsPOIJI.java @@ -0,0 +1,13 @@ +package com.baeldung.convert.exceldatatolist.poiji; + +import java.io.File; +import java.util.List; + +import com.baeldung.convert.exceldatatolist.FoodInfo; +import com.poiji.bind.Poiji; + +public class ExcelDataToListOfObjectsPOIJI { + public static List excelDataToListOfObjets_withPOIJI(String fileLocation){ + return Poiji.fromExcel(new File(fileLocation), FoodInfo.class); + } +} diff --git a/apache-poi-3/src/main/resources/food_info.xls b/apache-poi-3/src/main/resources/food_info.xls new file mode 100644 index 0000000000..1377d8e18d Binary files /dev/null and b/apache-poi-3/src/main/resources/food_info.xls differ diff --git a/apache-poi-3/src/main/resources/food_info.xlsx b/apache-poi-3/src/main/resources/food_info.xlsx new file mode 100644 index 0000000000..c604ff367d Binary files /dev/null and b/apache-poi-3/src/main/resources/food_info.xlsx differ diff --git a/apache-poi-3/src/test/java/com/baeldung/convert/exceldatatolist/ExcelDataToListOfObjectsUnitTest.java b/apache-poi-3/src/test/java/com/baeldung/convert/exceldatatolist/ExcelDataToListOfObjectsUnitTest.java new file mode 100644 index 0000000000..5d65c04b31 --- /dev/null +++ b/apache-poi-3/src/test/java/com/baeldung/convert/exceldatatolist/ExcelDataToListOfObjectsUnitTest.java @@ -0,0 +1,53 @@ +package com.baeldung.convert.exceldatatolist; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.util.List; + +// import org.junit.jupiter.api.Test; +// import static org.junit.jupiter.api.Assertions.*; +import org.junit.Test; + +import com.baeldung.convert.exceldatatolist.fastexcel.ExcelDataToListOfObjectsFastExcel; +import com.baeldung.convert.exceldatatolist.jexcelapi.ExcelDataToListOfObjectsJxl; +import com.baeldung.convert.exceldatatolist.poi.ExcelDataToListApachePOI; +import com.baeldung.convert.exceldatatolist.poiji.ExcelDataToListOfObjectsPOIJI; + +import jxl.read.biff.BiffException; + +public class ExcelDataToListOfObjectsUnitTest { + + @Test + public void whenParsingExcelFileWithPOIJI_thenConvertsToList() throws IOException { + List foodInfoList = ExcelDataToListOfObjectsPOIJI.excelDataToListOfObjets_withPOIJI("src/main/resources/food_info.xlsx"); + + assertEquals("Beverages", foodInfoList.get(0).getCategory()); + assertEquals("Dairy", foodInfoList.get(3).getCategory()); + } + + @Test + public void whenParsingExcelFileWithApachePOI_thenConvertsToList() throws IOException { + List foodInfoList = ExcelDataToListApachePOI.excelDataToListOfObjets_withApachePOI("src/main/resources/food_info.xlsx"); + + assertEquals("Beverages", foodInfoList.get(0).getCategory()); + assertEquals("Dairy", foodInfoList.get(3).getCategory()); + } + + @Test + public void whenParsingExcelFileWithFastExcel_thenConvertsToList() throws IOException { + List foodInfoList = ExcelDataToListOfObjectsFastExcel.excelDataToListOfObjets_withFastExcel("src/main/resources/food_info.xlsx"); + + assertEquals("Beverages", foodInfoList.get(0).getCategory()); + assertEquals("Dairy", foodInfoList.get(3).getCategory()); + } + + @Test + public void whenParsingExcelFileWithJxl_thenConvertsToList() throws IOException, BiffException { + List foodInfoList = ExcelDataToListOfObjectsJxl.excelDataToListOfObjets_withJxl("src/main/resources/food_info.xls"); + + assertEquals("Beverages", foodInfoList.get(0).getCategory()); + assertEquals("Dairy", foodInfoList.get(3).getCategory()); + } + +} diff --git a/apache-poi-3/src/test/java/com/baeldung/poi/excel/expandcolumn/ExpandColumnUnitTest.java b/apache-poi-3/src/test/java/com/baeldung/poi/excel/expandcolumn/ExpandColumnUnitTest.java new file mode 100644 index 0000000000..04d0aef211 --- /dev/null +++ b/apache-poi-3/src/test/java/com/baeldung/poi/excel/expandcolumn/ExpandColumnUnitTest.java @@ -0,0 +1,70 @@ +package com.baeldung.poi.excel.expandcolumn; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.*; + +import java.io.IOException; + +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class ExpandColumnUnitTest { + + private Workbook workbook; + private Sheet sheet; + + @BeforeEach + void prepareSpreadsheet() { + workbook = new XSSFWorkbook(); + sheet = workbook.createSheet(); + + Row headerRow = sheet.createRow(0); + Cell headerCell1 = headerRow.createCell(0); + headerCell1.setCellValue("Full Name"); + Cell headerCell2 = headerRow.createCell(1); + headerCell2.setCellValue("Abbreviation"); + + Row dataRow = sheet.createRow(1); + Cell dataCell1 = dataRow.createCell(0); + dataCell1.setCellValue("Java Virtual Machine"); + Cell dataCell2 = dataRow.createCell(1); + dataCell2.setCellValue("JVM"); + + dataRow = sheet.createRow(2); + dataCell1 = dataRow.createCell(0); + dataCell1.setCellValue("Java Runtime Environment"); + dataCell2 = dataRow.createCell(1); + dataCell2.setCellValue("JRE"); + } + + @Test + void whenSetColumnWidth_thenColumnSetToTheSpecifiedWidth() { + + Row row = sheet.getRow(2); + String cellValue = row.getCell(0).getStringCellValue(); + int targetWidth = cellValue.length() * 256; + + sheet.setColumnWidth(0, targetWidth); + + assertEquals(targetWidth, sheet.getColumnWidth(0)); + } + + @Test + void whenAutoSizeColumn_thenColumnExpands() { + + int originalWidth = sheet.getColumnWidth(0); + + sheet.autoSizeColumn(0); + + assertThat(sheet.getColumnWidth(0)).isGreaterThan(originalWidth); + } + + @AfterEach + void cleanup() throws IOException { + workbook.close(); + } + +} \ No newline at end of file diff --git a/aws-modules/aws-s3/README.md b/aws-modules/aws-s3/README.md index cb039b7c61..9b862c8685 100644 --- a/aws-modules/aws-s3/README.md +++ b/aws-modules/aws-s3/README.md @@ -4,7 +4,7 @@ This module contains articles about Simple Storage Service (S3) on AWS ### Relevant articles -- [AWS S3 with Java](https://www.baeldung.com/aws-s3-java) +- [AWS S3 with Java](https://www.baeldung.com/java-aws-s3) - [Multipart Uploads in Amazon S3 with Java](https://www.baeldung.com/aws-s3-multipart-upload) - [Using the JetS3t Java Client With Amazon S3](https://www.baeldung.com/jets3t-amazon-s3) - [Check if a Specified Key Exists in a Given S3 Bucket Using Java](https://www.baeldung.com/java-aws-s3-check-specified-key-exists) diff --git a/core-java-modules/core-java-16/src/main/java/com/baeldung/value_based_class/Point.java b/core-java-modules/core-java-16/src/main/java/com/baeldung/value_based_class/Point.java new file mode 100644 index 0000000000..13e2238274 --- /dev/null +++ b/core-java-modules/core-java-16/src/main/java/com/baeldung/value_based_class/Point.java @@ -0,0 +1,49 @@ +package com.baeldung.value_based_class; + +import java.util.Objects; + +import jdk.internal.ValueBased; + +/** + * This class is written with the intention that it can serve as an example of + * what a Value-based class could be. + */ + +@ValueBased +public final class Point { + private final int x; + private final int y; + private final int z; + + private static Point ORIGIN = new Point(0, 0, 0); + + private Point(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + public static Point valueOfPoint(int x, int y, int z) { + // returns a cached instance if it is origin, or a new instance + if (isOrigin(x, y, z)) + return ORIGIN; + return new Point(x, y, z); + } + + @Override + public boolean equals(Object other) { + if (other == null || getClass() != other.getClass()) + return false; + Point point = (Point) other; + return x == point.x && y == point.y && z == point.z; + } + + @Override + public int hashCode() { + return Objects.hash(x, y, z); + } + + private static boolean isOrigin(int x, int y, int z) { + return x == 0 && y == 0 && z == 0; + } +} diff --git a/core-java-modules/core-java-16/src/test/java/com/baeldung/value_based_class/ValueBasedClassUnitTest.java b/core-java-modules/core-java-16/src/test/java/com/baeldung/value_based_class/ValueBasedClassUnitTest.java new file mode 100644 index 0000000000..781f368982 --- /dev/null +++ b/core-java-modules/core-java-16/src/test/java/com/baeldung/value_based_class/ValueBasedClassUnitTest.java @@ -0,0 +1,41 @@ +package com.baeldung.value_based_class; + +import org.junit.Assert; +import org.junit.Test; + +public class ValueBasedClassUnitTest { + @Test + public void givenAutoboxedAndPrimitive_whenCompared_thenReturnEquals() { + int primitive_a = 125; + Integer obj_a = 125; // this is autoboxed + Assert.assertSame(primitive_a, obj_a); + } + + @Test + public void givenValueBasedPoint_whenCreated_thenReturnsObjects() { + Point p1 = Point.valueOfPoint(1, 2, 3); + Point p2 = Point.valueOfPoint(2, 3, 4); + + Assert.assertNotEquals(p1, p2); + } + + @Test + public void givenValueBasedPoint_whenCompared_thenReturnEquals() { + Point p1 = Point.valueOfPoint(1, 2, 3); + Point p2 = Point.valueOfPoint(1, 2, 3); + + Assert.assertEquals(p1, p2); + } + + @Test + public void givenValueBasedPoint_whenOrigin_thenReturnCachedInstance() { + Point p1 = Point.valueOfPoint(0, 0, 0); + Point p2 = Point.valueOfPoint(0, 0, 0); + Point p3 = Point.valueOfPoint(1, 2, 3); + + // the following should not be assumed for value-based classes + + Assert.assertTrue(p1 == p2); + Assert.assertFalse(p1 == p3); + } +} diff --git a/core-java-modules/core-java-21/README.md b/core-java-modules/core-java-21/README.md index c63f3b360b..2e7130c906 100644 --- a/core-java-modules/core-java-21/README.md +++ b/core-java-modules/core-java-21/README.md @@ -1 +1,2 @@ -## Relevant Articles \ No newline at end of file +## Relevant Articles +- [Sequenced Collections in Java 21](https://www.baeldung.com/java-21-sequenced-collections) diff --git a/core-java-modules/core-java-21/pom.xml b/core-java-modules/core-java-21/pom.xml index 83b2b1c858..0504f787c6 100644 --- a/core-java-modules/core-java-21/pom.xml +++ b/core-java-modules/core-java-21/pom.xml @@ -12,23 +12,22 @@ 0.0.1-SNAPSHOT - - - - - - - - - - - - - - - - - - - + + + + org.apache.maven.plugins + maven-compiler-plugin + + 21 + 21 + --enable-preview + + + + + + 21 + 21 + UTF-8 + \ No newline at end of file diff --git a/core-java-modules/core-java-21/src/main/java/com/baeldung/stringtemplates/StringCompositionTechniques.java b/core-java-modules/core-java-21/src/main/java/com/baeldung/stringtemplates/StringCompositionTechniques.java new file mode 100644 index 0000000000..7e66144f1c --- /dev/null +++ b/core-java-modules/core-java-21/src/main/java/com/baeldung/stringtemplates/StringCompositionTechniques.java @@ -0,0 +1,37 @@ +package com.baeldung.stringtemplates; + +import java.text.MessageFormat; + +public class StringCompositionTechniques { + String composeUsingPlus(String feelsLike, String temperature, String unit) { + return "Today's weather is " + feelsLike + ", with a temperature of " + temperature + " degrees " + unit; + } + + String composeUsingStringBuffer(String feelsLike, String temperature, String unit) { + return new StringBuffer().append("Today's weather is ") + .append(feelsLike) + .append(", with a temperature of ") + .append(temperature) + .append(" degrees ") + .append(unit) + .toString(); + } + + String composeUsingStringBuilder(String feelsLike, String temperature, String unit) { + return new StringBuilder().append("Today's weather is ") + .append(feelsLike) + .append(", with a temperature of ") + .append(temperature) + .append(" degrees ") + .append(unit) + .toString(); + } + + String composeUsingFormatters(String feelsLike, String temperature, String unit) { + return String.format("Today's weather is %s, with a temperature of %s degrees %s", feelsLike, temperature, unit); + } + + String composeUsingMessageFormatter(String feelsLike, String temperature, String unit) { + return MessageFormat.format("Today''s weather is {0}, with a temperature of {1} degrees {2}", feelsLike, temperature, unit); + } +} diff --git a/core-java-modules/core-java-21/src/main/java/com/baeldung/stringtemplates/StringTemplateExamples.java b/core-java-modules/core-java-21/src/main/java/com/baeldung/stringtemplates/StringTemplateExamples.java new file mode 100644 index 0000000000..0fb18a84e9 --- /dev/null +++ b/core-java-modules/core-java-21/src/main/java/com/baeldung/stringtemplates/StringTemplateExamples.java @@ -0,0 +1,56 @@ +package com.baeldung.stringtemplates; + +import static java.lang.StringTemplate.RAW; +import static java.util.FormatProcessor.FMT; + +public class StringTemplateExamples { + String interpolationUsingSTRProcessor(String feelsLike, String temperature, String unit) { + return STR + . "Today's weather is \{ feelsLike }, with a temperature of \{ temperature } degrees \{ unit }" ; + } + + String interpolationOfJSONBlock(String feelsLike, String temperature, String unit) { + return STR + . """ + { + "feelsLike": "\{ feelsLike }", + "temperature": "\{ temperature }", + "unit": "\{ unit }" + } + """ ; + } + + String interpolationWithExpressions() { + return STR + . "Today's weather is \{ getFeelsLike() }, with a temperature of \{ getTemperature() } degrees \{ getUnit() }" ; + } + + String interpolationWithTemplates() { + StringTemplate str = RAW + . "Today's weather is \{ getFeelsLike() }, with a temperature of \{ getTemperature() } degrees \{ getUnit() }" ; + return STR.process(str); + } + + String interpolationOfJSONBlockWithFMT(String feelsLike, float temperature, String unit) { + return FMT + . """ + { + "feelsLike": "%1s\{ feelsLike }", + "temperature": "%2.2f\{ temperature }", + "unit": "%1s\{ unit }" + } + """ ; + } + + private String getFeelsLike() { + return "pleasant"; + } + + private String getTemperature() { + return "25"; + } + + private String getUnit() { + return "Celsius"; + } +} diff --git a/core-java-modules/core-java-21/src/test/java/com.baeldung.stringtemplates/StringTemplatesUnitTest.java b/core-java-modules/core-java-21/src/test/java/com.baeldung.stringtemplates/StringTemplatesUnitTest.java new file mode 100644 index 0000000000..b9917cab18 --- /dev/null +++ b/core-java-modules/core-java-21/src/test/java/com.baeldung.stringtemplates/StringTemplatesUnitTest.java @@ -0,0 +1,67 @@ +package com.baeldung.stringtemplates; + +import org.junit.Assert; +import org.junit.Test; + +public class StringTemplatesUnitTest { + + @Test + public void whenStringConcat_thenReturnComposedString() { + StringCompositionTechniques stringCompositionTechniques = new StringCompositionTechniques(); + Assert.assertEquals("Today's weather is pleasant, with a temperature of 25 degrees Celsius", stringCompositionTechniques.composeUsingPlus("pleasant", "25", "Celsius")); + } + + @Test + public void whenStringBuffer_thenReturnComposedString() { + StringCompositionTechniques stringCompositionTechniques = new StringCompositionTechniques(); + Assert.assertEquals("Today's weather is pleasant, with a temperature of 25 degrees Celsius", stringCompositionTechniques.composeUsingStringBuffer("pleasant", "25", "Celsius")); + } + + @Test + public void whenStringBuilder_thenReturnComposedString() { + StringCompositionTechniques stringCompositionTechniques = new StringCompositionTechniques(); + Assert.assertEquals("Today's weather is pleasant, with a temperature of 25 degrees Celsius", stringCompositionTechniques.composeUsingStringBuilder("pleasant", "25", "Celsius")); + } + + @Test + public void whenStringFormatter_thenReturnComposedFormattedString() { + StringCompositionTechniques stringCompositionTechniques = new StringCompositionTechniques(); + Assert.assertEquals("Today's weather is pleasant, with a temperature of 25 degrees Celsius", stringCompositionTechniques.composeUsingFormatters("pleasant", "25", "Celsius")); + } + + @Test + public void whenMessageFormatter_thenReturnComposedFormattedString() { + StringCompositionTechniques stringCompositionTechniques = new StringCompositionTechniques(); + Assert.assertEquals("Today's weather is pleasant, with a temperature of 25 degrees Celsius", stringCompositionTechniques.composeUsingMessageFormatter("pleasant", "25", "Celsius")); + } + + @Test + public void whenUsingStringTemplateSTR_thenReturnInterpolatedString() { + StringTemplateExamples templateExamples = new StringTemplateExamples(); + Assert.assertEquals("Today's weather is pleasant, with a temperature of 25 degrees Celsius", templateExamples.interpolationUsingSTRProcessor("pleasant", "25", "Celsius")); + } + + @Test + public void whenUsingMultilineStringTemplateSTR_thenReturnInterpolatedString() { + StringTemplateExamples templateExamples = new StringTemplateExamples(); + Assert.assertEquals("{\n" + " \"feelsLike\": \"pleasant\",\n" + " \"temperature\": \"25\",\n" + " \"unit\": \"Celsius\"\n" + "}\n", templateExamples.interpolationOfJSONBlock("pleasant", "25", "Celsius")); + } + + @Test + public void whenUsingExpressionSTR_thenReturnInterpolatedString() { + StringTemplateExamples templateExamples = new StringTemplateExamples(); + Assert.assertEquals("Today's weather is pleasant, with a temperature of 25 degrees Celsius", templateExamples.interpolationWithExpressions()); + } + + @Test + public void whenUsingExpressionRAW_thenReturnInterpolatedString() { + StringTemplateExamples templateExamples = new StringTemplateExamples(); + Assert.assertEquals("Today's weather is pleasant, with a temperature of 25 degrees Celsius", templateExamples.interpolationWithTemplates()); + } + + @Test + public void whenUsingExpressionFMT_thenReturnInterpolatedString() { + StringTemplateExamples templateExamples = new StringTemplateExamples(); + Assert.assertEquals("{\n" + " \"feelsLike\": \"pleasant\",\n" + " \"temperature\": \"25.86\",\n" + " \"unit\": \"Celsius\"\n" + "}\n", templateExamples.interpolationOfJSONBlockWithFMT("pleasant", 25.8636F, "Celsius")); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-8-datetime-2/README.md b/core-java-modules/core-java-8-datetime-2/README.md index b860ca979d..ac1e1ca81f 100644 --- a/core-java-modules/core-java-8-datetime-2/README.md +++ b/core-java-modules/core-java-8-datetime-2/README.md @@ -5,4 +5,5 @@ - [Parsing Date Strings with Varying Formats](https://www.baeldung.com/java-parsing-dates-many-formats) - [How Many Days Are There in a Particular Month of a Given Year?](https://www.baeldung.com/days-particular-month-given-year) - [Difference Between Instant and LocalDateTime](https://www.baeldung.com/java-instant-vs-localdatetime) +- [Add Minutes to a Time String in Java](https://www.baeldung.com/java-string-time-add-mins) - [[<-- Prev]](/core-java-modules/core-java-datetime-java8-1) diff --git a/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/dateapi/JavaDurationUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/dateapi/JavaDurationUnitTest.java index be43fb609a..d1bd77776a 100644 --- a/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/dateapi/JavaDurationUnitTest.java +++ b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/dateapi/JavaDurationUnitTest.java @@ -3,9 +3,11 @@ package com.baeldung.dateapi; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.time.Duration; import java.time.Instant; +import java.time.LocalDateTime; import java.time.LocalTime; import java.time.temporal.ChronoUnit; @@ -19,7 +21,7 @@ public class JavaDurationUnitTest { LocalTime finalTime = initialTime.plus(Duration.ofSeconds(30)); long seconds = Duration.between(initialTime, finalTime) - .getSeconds(); + .getSeconds(); assertThat(seconds).isEqualTo(30); } @@ -34,6 +36,22 @@ public class JavaDurationUnitTest { assertThat(seconds).isEqualTo(30); } + @Test + public void givenADuration_whenCallingisZeroAndisNegative_thenGetExpectedResult() { + LocalDateTime start = LocalDateTime.parse("2020-01-01T08:00:00"); + LocalDateTime end = LocalDateTime.parse("2020-01-01T12:00:00"); + assertFalse(Duration.between(start, end) + .isNegative()); + assertTrue(Duration.between(end, start) + .isNegative()); + + LocalDateTime theTime = LocalDateTime.parse("2023-09-09T08:00:00"); + assertTrue(Duration.between(theTime, theTime) + .isZero()); + assertFalse(Duration.between(theTime, theTime) + .isNegative()); + } + @Test public void test2() { Instant start = Instant.parse("2017-10-03T10:15:30.00Z"); @@ -53,17 +71,17 @@ public class JavaDurationUnitTest { assertEquals(1, fromMinutes.toHours()); assertEquals(120, duration.plusSeconds(60) - .getSeconds()); + .getSeconds()); assertEquals(30, duration.minusSeconds(30) - .getSeconds()); + .getSeconds()); assertEquals(120, duration.plus(60, ChronoUnit.SECONDS) - .getSeconds()); + .getSeconds()); assertEquals(30, duration.minus(30, ChronoUnit.SECONDS) - .getSeconds()); + .getSeconds()); Duration fromChar1 = Duration.parse("P1DT1H10M10.5S"); Duration fromChar2 = Duration.parse("PT10M"); } -} +} \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-guides/src/main/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicate.java b/core-java-modules/core-java-arrays-guides/src/main/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicate.java new file mode 100644 index 0000000000..e0b249565f --- /dev/null +++ b/core-java-modules/core-java-arrays-guides/src/main/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicate.java @@ -0,0 +1,96 @@ +package com.baeldung.mergeandremoveduplicate; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Stream; + +public class MergeArraysAndRemoveDuplicate { + + public static int[] removeDuplicateOnSortedArray(int[] arr) { + // Initialize a new array to store unique elements + int[] uniqueArray = new int[arr.length]; + uniqueArray[0] = arr[0]; + int uniqueCount = 1; + + // Iterate through the sorted array to remove duplicates + for (int i = 1; i < arr.length; i++) { + if (arr[i] != arr[i - 1]) { + uniqueArray[uniqueCount] = arr[i]; + uniqueCount++; + } + } + int[] truncatedArray = new int[uniqueCount]; + System.arraycopy(uniqueArray, 0, truncatedArray, 0, uniqueCount); + return truncatedArray; + } + + public static int[] mergeAndRemoveDuplicatesUsingStream(int[] arr1, int[] arr2) { + Stream s1 = Arrays.stream(arr1).boxed(); + Stream s2 = Arrays.stream(arr2).boxed(); + return Stream.concat(s1, s2) + .distinct() + .mapToInt(Integer::intValue) + .toArray(); + } + + public static int[] mergeAndRemoveDuplicatesUsingSet(int[] arr1, int[] arr2) { + int[] mergedArr = mergeArrays(arr1, arr2); + Set uniqueInts = new HashSet<>(); + + for (int el : mergedArr) { + uniqueInts.add(el); + } + + return getArrayFromSet(uniqueInts); + } + + private static int[] getArrayFromSet(Set set) { + int[] mergedArrWithoutDuplicated = new int[set.size()]; + int i = 0; + for (Integer el: set) { + mergedArrWithoutDuplicated[i] = el; + i++; + } + return mergedArrWithoutDuplicated; + } + + public static int[] mergeAndRemoveDuplicates(int[] arr1, int[] arr2) { + return removeDuplicate(mergeArrays(arr1, arr2)); + } + + public static int[] mergeAndRemoveDuplicatesOnSortedArray(int[] arr1, int[] arr2) { + return removeDuplicateOnSortedArray(mergeArrays(arr1, arr2)); + } + + private static int[] mergeArrays(int[] arr1, int[] arr2) { + int[] mergedArrays = new int[arr1.length + arr2.length]; + System.arraycopy(arr1, 0, mergedArrays, 0, arr1.length); + System.arraycopy(arr2, 0, mergedArrays, arr1.length, arr2.length); + + return mergedArrays; + } + private static int[] removeDuplicate(int[] arr) { + int[] withoutDuplicates = new int[arr.length]; + int i = 0; + + for(int element : arr) { + if(!isElementPresent(withoutDuplicates, element)) { + withoutDuplicates[i] = element; + i++; + } + } + int[] truncatedArray = new int[i]; + System.arraycopy(withoutDuplicates, 0, truncatedArray, 0, i); + return truncatedArray; + } + + private static boolean isElementPresent(int[] arr, int element) { + for(int el : arr) { + if(el == element) { + return true; + } + } + return false; + } +} diff --git a/core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicateUnitTest.java b/core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicateUnitTest.java new file mode 100644 index 0000000000..5076ef8159 --- /dev/null +++ b/core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/mergeandremoveduplicate/MergeArraysAndRemoveDuplicateUnitTest.java @@ -0,0 +1,74 @@ +package com.baeldung.mergeandremoveduplicate; + +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.stream.Collectors; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; + +public class MergeArraysAndRemoveDuplicateUnitTest { + + private final Logger logger = LoggerFactory.getLogger(MergeArraysAndRemoveDuplicateUnitTest.class); + + private static String getCommaDelimited(int[] arr) { + return Arrays.stream(arr) + .mapToObj(Integer::toString) + .collect(Collectors.joining(", ")); + } + + @Test + public void givenNoLibraryAndUnSortedArrays_whenArr1andArr2_thenMergeAndRemoveDuplicates() { + int[] arr1 = {3, 2, 1, 4, 5, 6, 8, 7, 9}; + int[] arr2 = {8, 9, 10, 11, 12, 13, 15, 14, 15, 14, 16, 17}; + int[] expectedArr = {3, 2, 1, 4, 5, 6, 8, 7, 9, 10, 11, 12, 13, 15, 14, 16, 17}; + + int[] mergedArr = MergeArraysAndRemoveDuplicate.mergeAndRemoveDuplicates(arr1, arr2); + + //merged array maintains the order of the elements in the arrays + assertArrayEquals(expectedArr, mergedArr); + + logger.info(getCommaDelimited(mergedArr)); + } + + @Test + public void givenNoLibraryAndSortedArrays_whenArr1andArr2_thenMergeAndRemoveDuplicates() { + int[] arr1 = {1, 2, 3, 4, 5, 5, 6, 7, 7, 8}; + int[] arr2 = {8, 9, 10, 11, 12, 13, 14, 15, 15, 16, 17}; + int[] expectedArr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + + int[] mergedArr = MergeArraysAndRemoveDuplicate.mergeAndRemoveDuplicatesOnSortedArray(arr1, arr2); + + assertArrayEquals(expectedArr, mergedArr); + + logger.info(getCommaDelimited(mergedArr)); + } + + @Test + public void givenSet_whenArr1andArr2_thenMergeAndRemoveDuplicates() { + int[] arr1 = {3, 2, 1, 4, 5, 6, 8, 7, 9}; + int[] arr2 = {8, 9, 10, 11, 12, 13, 15, 14, 15, 14, 16, 17}; + int[] expectedArr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + + int[] mergedArr = MergeArraysAndRemoveDuplicate.mergeAndRemoveDuplicatesUsingSet(arr1, arr2); + + assertArrayEquals(expectedArr, mergedArr); + + logger.info(getCommaDelimited(mergedArr)); + } + + @Test + public void givenStream_whenArr1andArr2_thenMergeAndRemoveDuplicates() { + int[] arr1 = {3, 2, 1, 4, 5, 6, 8, 7, 9}; + int[] arr2 = {8, 9, 10, 11, 12, 13, 15, 14, 15, 14, 16, 17}; + int[] expectedArr = {3, 2, 1, 4, 5, 6, 8, 7, 9, 10, 11, 12, 13, 15, 14, 16, 17}; + + int[] mergedArr = MergeArraysAndRemoveDuplicate.mergeAndRemoveDuplicatesUsingStream(arr1, arr2); + + assertArrayEquals(expectedArr, mergedArr); + + logger.info(getCommaDelimited(mergedArr)); + } +} diff --git a/core-java-modules/core-java-arrays-operations-advanced-2/pom.xml b/core-java-modules/core-java-arrays-operations-advanced-2/pom.xml new file mode 100644 index 0000000000..53cccb8a73 --- /dev/null +++ b/core-java-modules/core-java-arrays-operations-advanced-2/pom.xml @@ -0,0 +1,46 @@ + + + 4.0.0 + core-java-arrays-operations-advanced-2 + core-java-arrays-operations-advanced-2 + jar + + + core-java-modules + com.baeldung.core-java-modules + 0.0.1-SNAPSHOT + + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + + + + maven-assembly-plugin + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/arraymiddle/MiddleOfArray.java b/core-java-modules/core-java-arrays-operations-advanced-2/src/main/java/com/baeldung/arraymiddle/MiddleOfArray.java similarity index 99% rename from core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/arraymiddle/MiddleOfArray.java rename to core-java-modules/core-java-arrays-operations-advanced-2/src/main/java/com/baeldung/arraymiddle/MiddleOfArray.java index f389893209..bfff003512 100644 --- a/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/arraymiddle/MiddleOfArray.java +++ b/core-java-modules/core-java-arrays-operations-advanced-2/src/main/java/com/baeldung/arraymiddle/MiddleOfArray.java @@ -62,4 +62,4 @@ public class MiddleOfArray { return array[mid]; } } -} +} \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-operations-advanced/src/test/java/com/baeldung/arraymiddle/MiddleOfArrayUnitTest.java b/core-java-modules/core-java-arrays-operations-advanced-2/src/test/java/com/baeldung/arraymiddle/MiddleOfArrayUnitTest.java similarity index 99% rename from core-java-modules/core-java-arrays-operations-advanced/src/test/java/com/baeldung/arraymiddle/MiddleOfArrayUnitTest.java rename to core-java-modules/core-java-arrays-operations-advanced-2/src/test/java/com/baeldung/arraymiddle/MiddleOfArrayUnitTest.java index 706412d83e..64a9796e67 100644 --- a/core-java-modules/core-java-arrays-operations-advanced/src/test/java/com/baeldung/arraymiddle/MiddleOfArrayUnitTest.java +++ b/core-java-modules/core-java-arrays-operations-advanced-2/src/test/java/com/baeldung/arraymiddle/MiddleOfArrayUnitTest.java @@ -86,4 +86,4 @@ public class MiddleOfArrayUnitTest { MiddleOfArray middleOfArray = new MiddleOfArray(); Assert.assertEquals(expectMedian, middleOfArray.medianOfArray(array, 0, 100)); } -} +} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/NonStableSortExample.java b/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/NonStableSortExample.java new file mode 100644 index 0000000000..cd754489a6 --- /dev/null +++ b/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/NonStableSortExample.java @@ -0,0 +1,26 @@ +package com.baeldung.collectionsvsarrays; + +import com.baeldung.collectionsvsarrays.sorting.Quicksort; +import java.util.Comparator; +import java.util.List; + +public class NonStableSortExample { + + + + public static void main(String[] args) { + List tasks = Tasks.supplier.get(); + Quicksort.sort(tasks, Comparator.comparingInt(Task::getPriority)); + System.out.println("After sorting by priority:"); + for (Task task : tasks) { + System.out.println(task); + } + Quicksort.sort(tasks, Comparator.comparing(Task::getDueDate)); + System.out.println("\nAfter sorting by due date:"); + for (Task task : tasks) { + System.out.println(task); + } + } + + +} diff --git a/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/ObjectOverheadBenchmark.java b/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/ObjectOverheadBenchmark.java new file mode 100644 index 0000000000..9a8adff507 --- /dev/null +++ b/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/ObjectOverheadBenchmark.java @@ -0,0 +1,56 @@ +package com.baeldung.collectionsvsarrays; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; +import java.util.stream.Collectors; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.infra.Blackhole; + +@Measurement(iterations = 2, time = 10, timeUnit = TimeUnit.MINUTES) +@Warmup(iterations = 5, time = 10) +@Fork(value = 2) +public class ObjectOverheadBenchmark { + + private static final ThreadLocalRandom RANDOM = ThreadLocalRandom.current(); + + @State(Scope.Benchmark) + public static class Input { + public Supplier> randomNumbers = () -> RANDOM.ints().limit(10000).boxed().collect(Collectors.toList()); + } + + @Benchmark + @BenchmarkMode(Mode.Throughput) + public void sortingPrimitiveArray(Input input, Blackhole blackhole) { + final int[] array = input.randomNumbers.get().stream().mapToInt(Integer::intValue).toArray(); + Arrays.sort(array); + final List result = Arrays.stream(array).boxed().collect(Collectors.toList()); + blackhole.consume(result); + } + + @Benchmark + @BenchmarkMode(Mode.Throughput) + public void sortingObjectArray(Input input, Blackhole blackhole) { + final Integer[] array = input.randomNumbers.get().toArray(new Integer[0]); + Arrays.sort(array); + blackhole.consume(array); + } + + @Benchmark + @BenchmarkMode(Mode.Throughput) + public void sortingObjects(Input input, Blackhole blackhole) { + final List list = input.randomNumbers.get(); + Collections.sort(list); + blackhole.consume(list); + } +} diff --git a/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/PerformanceBenchmark.java b/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/PerformanceBenchmark.java new file mode 100644 index 0000000000..6e645b0fb9 --- /dev/null +++ b/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/PerformanceBenchmark.java @@ -0,0 +1,51 @@ +package com.baeldung.collectionsvsarrays; + +import com.baeldung.collectionsvsarrays.sorting.MergeSort; +import com.baeldung.collectionsvsarrays.sorting.Quicksort; +import java.util.Random; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; +import java.util.stream.IntStream; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.Warmup; + +@Measurement(iterations = 2, time = 10, timeUnit = TimeUnit.MINUTES) +@Warmup(iterations = 5, time = 10) +public class PerformanceBenchmark { + + private static final Random RANDOM = new Random(); + private static final int ARRAY_SIZE = 10000; + private static final int[] randomNumbers = RANDOM.ints(ARRAY_SIZE).toArray(); + private static final int[] sameNumbers = IntStream.generate(() -> 42).limit(ARRAY_SIZE).toArray(); + public static final Supplier randomNumbersSupplier = randomNumbers::clone; + public static final Supplier sameNumbersSupplier = sameNumbers::clone; + + @Benchmark + @BenchmarkMode(Mode.Throughput) + @Fork(value = 1, jvmArgs = {"-Xlog:gc:file=gc-logs-quick-sort-same-number-%t.txt,filesize=900m -Xmx6gb -Xms6gb"}) + public void quickSortSameNumber() { + Quicksort.sort(sameNumbersSupplier.get()); + } + @Benchmark + @BenchmarkMode(Mode.Throughput) + @Fork(value = 1, jvmArgs = {"-Xlog:gc:file=gc-logs-quick-sort-random-number-%t.txt,filesize=900m -Xmx6gb -Xms6gb"}) + public void quickSortRandomNumber() { + Quicksort.sort(randomNumbersSupplier.get()); + } + @Benchmark + @BenchmarkMode(Mode.Throughput) + @Fork(value = 1, jvmArgs = {"-Xlog:gc:file=gc-logs-merge-sort-same-number-%t.txt,filesize=900m -Xmx6gb -Xms6gb"}) + public void mergeSortSameNumber() { + MergeSort.sort(sameNumbersSupplier.get()); + } + @Benchmark + @BenchmarkMode(Mode.Throughput) + @Fork(value = 1, jvmArgs = {"-Xlog:gc:file=gc-logs-merge-sort-random-number-%t.txt,filesize=900m -Xmx6gb -Xms6gb"}) + public void mergeSortRandomNumber() { + MergeSort.sort(randomNumbersSupplier.get()); + } +} diff --git a/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/StableSortExample.java b/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/StableSortExample.java new file mode 100644 index 0000000000..336673bac8 --- /dev/null +++ b/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/StableSortExample.java @@ -0,0 +1,23 @@ +package com.baeldung.collectionsvsarrays; + + +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +public class StableSortExample { + + public static void main(String[] args) { + final List tasks = Tasks.supplier.get(); + Collections.sort(tasks, Comparator.comparingInt(Task::getPriority)); + System.out.println("After sorting by priority:"); + for (Task task : tasks) { + System.out.println(task); + } + Collections.sort(tasks, Comparator.comparing(Task::getDueDate)); + System.out.println("\nAfter sorting by due date:"); + for (Task task : tasks) { + System.out.println(task); + } + } +} diff --git a/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/Task.java b/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/Task.java new file mode 100644 index 0000000000..133c39ccd2 --- /dev/null +++ b/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/Task.java @@ -0,0 +1,30 @@ +package com.baeldung.collectionsvsarrays; + +public class Task { + private final long id; + private final int priority; + private final String dueDate; + + public Task(final long id, int priority, String dueDate) { + this.id = id; + this.priority = priority; + this.dueDate = dueDate; + } + + @Override + public String toString() { + return String.format("Task: #%-2d | Priority: %d | Due Date: %s", getId(), getPriority(), getDueDate()); + } + + public int getPriority() { + return priority; + } + + public String getDueDate() { + return dueDate; + } + + private long getId() { + return id; + } +} diff --git a/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/Tasks.java b/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/Tasks.java new file mode 100644 index 0000000000..fc413f549f --- /dev/null +++ b/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/Tasks.java @@ -0,0 +1,30 @@ +package com.baeldung.collectionsvsarrays; + +import java.util.ArrayList; +import java.util.List; +import java.util.function.Supplier; + +public class Tasks { + + private static final List tasks; + public static final Supplier> supplier; + + static { + tasks = new ArrayList<>(); + tasks.add(new Task(1, 1, "2023-09-01")); + tasks.add(new Task(2, 2, "2023-08-30")); + tasks.add(new Task(3, 1, "2023-08-29")); + tasks.add(new Task(4, 2, "2023-09-02")); + tasks.add(new Task(5, 3, "2023-09-05")); + tasks.add(new Task(6, 1, "2023-09-03")); + tasks.add(new Task(7, 3, "2023-08-28")); + tasks.add(new Task(8, 2, "2023-09-01")); + tasks.add(new Task(9, 1, "2023-08-28")); + tasks.add(new Task(10, 2, "2023-09-04")); + tasks.add(new Task(11, 3, "2023-08-31")); + tasks.add(new Task(12, 1, "2023-08-30")); + tasks.add(new Task(13, 3, "2023-09-02")); + + supplier = () -> new ArrayList<>(tasks); + } +} diff --git a/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/sorting/MergeSort.java b/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/sorting/MergeSort.java new file mode 100644 index 0000000000..6078db50e0 --- /dev/null +++ b/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/sorting/MergeSort.java @@ -0,0 +1,47 @@ +package com.baeldung.collectionsvsarrays.sorting; + +public class MergeSort { + + public static void sort(int[] a) { + sort(a, a.length); + } + public static void sort(int[] a, int n) { + if (n < 2) { + return; + } + int mid = n / 2; + int[] l = new int[mid]; + int[] r = new int[n - mid]; + + for (int i = 0; i < mid; i++) { + l[i] = a[i]; + } + for (int i = mid; i < n; i++) { + r[i - mid] = a[i]; + } + sort(l, mid); + sort(r, n - mid); + + merge(a, l, r, mid, n - mid); + } + private static void merge( + int[] a, int[] l, int[] r, int left, int right) { + + int i = 0, j = 0, k = 0; + while (i < left && j < right) { + if (l[i] <= r[j]) { + a[k++] = l[i++]; + } + else { + a[k++] = r[j++]; + } + } + while (i < left) { + a[k++] = l[i++]; + } + while (j < right) { + a[k++] = r[j++]; + } + } + +} diff --git a/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/sorting/Quicksort.java b/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/sorting/Quicksort.java new file mode 100644 index 0000000000..eab47b901b --- /dev/null +++ b/core-java-modules/core-java-collections-5/src/main/java/com/baeldung/collectionsvsarrays/sorting/Quicksort.java @@ -0,0 +1,72 @@ +package com.baeldung.collectionsvsarrays.sorting; + +import java.util.Comparator; +import java.util.List; + +public class Quicksort { + + public static void sort(int arr[]) { + sort(arr, 0, arr.length - 1); + } + public static void sort(int arr[], int begin, int end) { + if (begin < end) { + int partitionIndex = partition(arr, begin, end); + + sort(arr, begin, partitionIndex-1); + sort(arr, partitionIndex+1, end); + } + } + private static int partition(int arr[], int begin, int end) { + int pivot = arr[end]; + int i = (begin-1); + + for (int j = begin; j < end; j++) { + if (arr[j] <= pivot) { + i++; + + int swapTemp = arr[i]; + arr[i] = arr[j]; + arr[j] = swapTemp; + } + } + + int swapTemp = arr[i+1]; + arr[i+1] = arr[end]; + arr[end] = swapTemp; + + return i+1; + } + + public static void sort(List list, Comparator comparator) { + sort(list, 0, list.size() - 1, comparator); + } + public static void sort(List list, int low, int high, Comparator comparator) { + if (low < high) { + int partitionIndex = partition(list, low, high, comparator); + + sort(list, low, partitionIndex - 1, comparator); + sort(list, partitionIndex + 1, high, comparator); + } + } + + private static int partition(List list, int begin, int end, Comparator comparator) { + T pivot = list.get(end); + int i = (begin-1); + + for (int j = begin; j < end; j++) { + if (comparator.compare(list.get(j), pivot) <= 0) { + i++; + + T swapTemp = list.get(i); + list.set(i, list.get(j)); + list.set(j, swapTemp); + } + } + + T swapTemp = list.get(i+1); + list.set(i+1,list.get(end)); + list.set(end, swapTemp); + + return i+1; + } +} diff --git a/core-java-modules/core-java-collections-conversions-3/README.md b/core-java-modules/core-java-collections-conversions-3/README.md new file mode 100644 index 0000000000..f89cd199ff --- /dev/null +++ b/core-java-modules/core-java-collections-conversions-3/README.md @@ -0,0 +1,5 @@ +## Java Collections Cookbooks and Examples + +This module contains articles about conversions among Collection types in Java. + +### Relevant Articles: diff --git a/core-java-modules/core-java-collections-conversions-3/pom.xml b/core-java-modules/core-java-collections-conversions-3/pom.xml new file mode 100644 index 0000000000..4813d33713 --- /dev/null +++ b/core-java-modules/core-java-collections-conversions-3/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + core-java-collections-conversions-3 + core-java-collections-conversions-3 + jar + + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + + + + core-java-collections-conversions-3 + + + src/main/resources + true + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-collections-conversions-3/src/main/java/com/baeldung/hashmaptoarraylist/HashMapToArrayListConverterUtils.java b/core-java-modules/core-java-collections-conversions-3/src/main/java/com/baeldung/hashmaptoarraylist/HashMapToArrayListConverterUtils.java new file mode 100644 index 0000000000..dd5cc1fe47 --- /dev/null +++ b/core-java-modules/core-java-collections-conversions-3/src/main/java/com/baeldung/hashmaptoarraylist/HashMapToArrayListConverterUtils.java @@ -0,0 +1,66 @@ +package com.baeldung.hashmaptoarraylist; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; + +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Maps.EntryTransformer; + +public class HashMapToArrayListConverterUtils { + + static ArrayList convertUsingConstructor(HashMap hashMap) { + if (hashMap == null) { + return null; + } + return new ArrayList(hashMap.values()); + } + + static ArrayList convertUsingAddAllMethod(HashMap hashMap) { + if (hashMap == null) { + return null; + } + + ArrayList arrayList = new ArrayList(hashMap.size()); + arrayList.addAll(hashMap.values()); + + return arrayList; + } + + static ArrayList convertUsingStreamApi(HashMap hashMap) { + if (hashMap == null) { + return null; + } + + return hashMap.values() + .stream() + .collect(Collectors.toCollection(ArrayList::new)); + } + + static ArrayList convertUsingForLoop(HashMap hashMap) { + if (hashMap == null) { + return null; + } + + ArrayList arrayList = new ArrayList(hashMap.size()); + for (Map.Entry entry : hashMap.entrySet()) { + arrayList.add(entry.getValue()); + } + + return arrayList; + } + + static public ArrayList convertUsingGuava(HashMap hashMap) { + if (hashMap == null) { + return null; + } + + EntryTransformer entryMapTransformer = (key, value) -> value; + + return Lists.newArrayList(Maps.transformEntries(hashMap, entryMapTransformer) + .values()); + } + +} diff --git a/core-java-modules/core-java-collections-conversions-3/src/test/java/com/baeldung/hashmaptoarraylist/HashMapToArrayListConverterUtilsUnitTest.java b/core-java-modules/core-java-collections-conversions-3/src/test/java/com/baeldung/hashmaptoarraylist/HashMapToArrayListConverterUtilsUnitTest.java new file mode 100644 index 0000000000..26a42e77c0 --- /dev/null +++ b/core-java-modules/core-java-collections-conversions-3/src/test/java/com/baeldung/hashmaptoarraylist/HashMapToArrayListConverterUtilsUnitTest.java @@ -0,0 +1,60 @@ +package com.baeldung.hashmaptoarraylist; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsInAnyOrder; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.junit.Before; +import org.junit.Test; + +public class HashMapToArrayListConverterUtilsUnitTest { + + private HashMap hashMap; + + @Before + public void beforeEach() { + hashMap = new HashMap<>(); + hashMap.put(1, "AAA"); + hashMap.put(2, "BBB"); + hashMap.put(3, "CCC"); + hashMap.put(4, "DDD"); + } + + @Test + public void givenAHashMap_whenConvertUsingConstructor_thenReturnArrayList() { + ArrayList myList = HashMapToArrayListConverterUtils.convertUsingConstructor(hashMap); + + assertThat(hashMap.values(), containsInAnyOrder(myList.toArray())); + } + + @Test + public void givenAHashMap_whenConvertUsingAddAllMethod_thenReturnArrayList() { + ArrayList myList = HashMapToArrayListConverterUtils.convertUsingAddAllMethod(hashMap); + + assertThat(hashMap.values(), containsInAnyOrder(myList.toArray())); + } + + @Test + public void givenAHashMap_whenConvertUsingForLoop_thenReturnArrayList() { + ArrayList myList = HashMapToArrayListConverterUtils.convertUsingForLoop(hashMap); + + assertThat(hashMap.values(), containsInAnyOrder(myList.toArray())); + } + + @Test + public void givenAHashMap_whenConvertUsingStreamApi_thenReturnArrayList() { + ArrayList myList = HashMapToArrayListConverterUtils.convertUsingStreamApi(hashMap); + + assertThat(hashMap.values(), containsInAnyOrder(myList.toArray())); + } + + @Test + public void givenAHashMap_whenConvertUsingGuava_thenReturnArrayList() { + ArrayList myList = HashMapToArrayListConverterUtils.convertUsingGuava(hashMap); + + assertThat(hashMap.values(), containsInAnyOrder(myList.toArray())); + } + +} diff --git a/core-java-modules/core-java-collections-maps-5/src/main/java/com/baeldung/map/identity/IdentityHashMapDemonstrator.java b/core-java-modules/core-java-collections-maps-5/src/main/java/com/baeldung/map/identity/IdentityHashMapDemonstrator.java index 3cbe09b93f..3b98423120 100644 --- a/core-java-modules/core-java-collections-maps-5/src/main/java/com/baeldung/map/identity/IdentityHashMapDemonstrator.java +++ b/core-java-modules/core-java-collections-maps-5/src/main/java/com/baeldung/map/identity/IdentityHashMapDemonstrator.java @@ -53,7 +53,7 @@ public class IdentityHashMapDemonstrator { } } - private static class Book { + static class Book { String title; int year; diff --git a/core-java-modules/core-java-collections-maps-5/src/test/java/com/baeldung/map/identity/IdentityHashMapDemonstratorUnitTest.java b/core-java-modules/core-java-collections-maps-5/src/test/java/com/baeldung/map/identity/IdentityHashMapDemonstratorUnitTest.java index cc74ce4dd6..388338c3ab 100644 --- a/core-java-modules/core-java-collections-maps-5/src/test/java/com/baeldung/map/identity/IdentityHashMapDemonstratorUnitTest.java +++ b/core-java-modules/core-java-collections-maps-5/src/test/java/com/baeldung/map/identity/IdentityHashMapDemonstratorUnitTest.java @@ -1,8 +1,11 @@ package com.baeldung.map.identity; +import com.baeldung.map.identity.IdentityHashMapDemonstrator.Book; import org.junit.jupiter.api.Test; import java.util.IdentityHashMap; +import org.junit.jupiter.api.condition.EnabledForJreRange; +import org.junit.jupiter.api.condition.JRE; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -18,4 +21,44 @@ public class IdentityHashMapDemonstratorUnitTest { assertEquals("Fantasy", identityHashMap.get("genre")); assertEquals("Drama", identityHashMap.get(newGenreKey)); } + + @Test + @EnabledForJreRange(max = JRE.JAVA_19) + public void removeEntryComparingValueByEquality() { + Book book = new Book("A Passage to India", 1924); + IdentityHashMap identityHashMap = new IdentityHashMap<>(10); + identityHashMap.put(book, "A great work of fiction"); + identityHashMap.remove(book, new String("A great work of fiction")); + assertEquals(null, identityHashMap.get(book)); + } + + @Test + @EnabledForJreRange(max = JRE.JAVA_19) + public void replaceEntryComparingValueByEquality() { + Book book = new Book("A Passage to India", 1924); + IdentityHashMap identityHashMap = new IdentityHashMap<>(10); + identityHashMap.put(book, "A great work of fiction"); + identityHashMap.replace(book, new String("A great work of fiction"), "One of the greatest books"); + assertEquals("One of the greatest books", identityHashMap.get(book)); + } + + @Test + @EnabledForJreRange(min = JRE.JAVA_20) + public void dontRemoveEntryComparingValueByEquality() { + Book book = new Book("A Passage to India", 1924); + IdentityHashMap identityHashMap = new IdentityHashMap<>(10); + identityHashMap.put(book, "A great work of fiction"); + identityHashMap.remove(book, new String("A great work of fiction")); + assertEquals("A great work of fiction", identityHashMap.get(book)); + } + + @Test + @EnabledForJreRange(min = JRE.JAVA_20) + public void dontReplaceEntryComparingValueByEquality() { + Book book = new Book("A Passage to India", 1924); + IdentityHashMap identityHashMap = new IdentityHashMap<>(10); + identityHashMap.put(book, "A great work of fiction"); + identityHashMap.replace(book, new String("A great work of fiction"), "One of the greatest books"); + assertEquals("A great work of fiction", identityHashMap.get(book)); + } } diff --git a/core-java-modules/core-java-collections-set-2/README.md b/core-java-modules/core-java-collections-set-2/README.md index feeffed1c4..ee41908faf 100644 --- a/core-java-modules/core-java-collections-set-2/README.md +++ b/core-java-modules/core-java-collections-set-2/README.md @@ -5,4 +5,5 @@ - [Sorting a HashSet in Java](https://www.baeldung.com/java-sort-hashset) - [How to Get First Item From a Java Set](https://www.baeldung.com/first-item-set) - [Cartesian Product of Any Number of Sets in Java](https://www.baeldung.com/java-cartesian-product-sets) +- [How to Get Index of an Item in Java Set](https://www.baeldung.com/java-set-element-find-index) - More articles: [[<-- prev]](/core-java-modules/core-java-collections-set) diff --git a/core-java-modules/core-java-concurrency-collections-2/README.md b/core-java-modules/core-java-concurrency-collections-2/README.md index 2d65cf88e7..fdb7af5936 100644 --- a/core-java-modules/core-java-concurrency-collections-2/README.md +++ b/core-java-modules/core-java-concurrency-collections-2/README.md @@ -5,4 +5,5 @@ - [Java Concurrent HashSet Equivalent to ConcurrentHashMap](https://www.baeldung.com/java-concurrent-hashset-concurrenthashmap) - [Reading and Writing With a ConcurrentHashMap](https://www.baeldung.com/concurrenthashmap-reading-and-writing) - [ArrayBlockingQueue vs. LinkedBlockingQueue](https://www.baeldung.com/java-arrayblockingqueue-vs-linkedblockingqueue) +- [Difference Between Hashtable and ConcurrentHashMap in Java](https://www.baeldung.com/java-hashtable-vs-concurrenthashmap) - [[<-- Prev]](/core-java-modules/core-java-concurrency-collections) 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 172882af2c..d5128c522e 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 @@ -96,7 +96,8 @@ public class DateTimeFormatterUnitTest { String newYorkDateTimePattern = "dd.MM.yyyy HH:mm z"; DateTimeFormatter newYorkDateFormatter = DateTimeFormatter.ofPattern(newYorkDateTimePattern); LocalDateTime summerDay = LocalDateTime.of(2016, 7, 31, 14, 15); - Assert.assertEquals("31.07.2016 14:15 EDT", newYorkDateFormatter.format(ZonedDateTime.of(summerDay, ZoneId.of("America/New_York")))); + Assert.assertEquals("31.07.2016 14:15 EDT", + newYorkDateFormatter.format(ZonedDateTime.of(summerDay, ZoneId.of("America/New_York")))); } @Test @@ -121,8 +122,10 @@ public class DateTimeFormatterUnitTest { @Test public void shouldPrintFormattedDateTimeWithPredefined() { Assert.assertEquals("2018-03-09", DateTimeFormatter.ISO_LOCAL_DATE.format(LocalDate.of(2018, 3, 9))); - Assert.assertEquals("2018-03-09-03:00", DateTimeFormatter.ISO_OFFSET_DATE.format(LocalDate.of(2018, 3, 9).atStartOfDay(ZoneId.of("UTC-3")))); - Assert.assertEquals("Fri, 9 Mar 2018 00:00:00 -0300", DateTimeFormatter.RFC_1123_DATE_TIME.format(LocalDate.of(2018, 3, 9).atStartOfDay(ZoneId.of("UTC-3")))); + Assert.assertEquals("2018-03-09-03:00", + DateTimeFormatter.ISO_OFFSET_DATE.format(LocalDate.of(2018, 3, 9).atStartOfDay(ZoneId.of("UTC-3")))); + Assert.assertEquals("Fri, 9 Mar 2018 00:00:00 -0300", + DateTimeFormatter.RFC_1123_DATE_TIME.format(LocalDate.of(2018, 3, 9).atStartOfDay(ZoneId.of("UTC-3")))); } @Test @@ -165,30 +168,62 @@ public class DateTimeFormatterUnitTest { public void shouldPrintFormattedZonedDateTime() { ZonedDateTime zonedDateTime = ZonedDateTime.of(2021, 02, 15, 0, 0, 0, 0, ZoneId.of("Europe/Paris")); String formattedZonedDateTime = DateTimeFormatter.ISO_INSTANT.format(zonedDateTime); - + Assert.assertEquals("2021-02-14T23:00:00Z", formattedZonedDateTime); } - + @Test(expected = UnsupportedTemporalTypeException.class) public void shouldExpectAnExceptionIfInputIsLocalDateTime() { DateTimeFormatter.ISO_INSTANT.format(LocalDate.now()); } - + @Test public void shouldParseZonedDateTime() { DateTimeFormatter formatter = DateTimeFormatter.ISO_INSTANT.withZone(ZoneId.systemDefault()); ZonedDateTime zonedDateTime = ZonedDateTime.parse("2021-10-01T05:06:20Z", formatter); - + Assert.assertEquals("2021-10-01T05:06:20Z", DateTimeFormatter.ISO_INSTANT.format(zonedDateTime)); } - + @Test(expected = DateTimeParseException.class) public void shouldExpectAnExceptionIfTimeZoneIsMissing() { ZonedDateTime zonedDateTime = ZonedDateTime.parse("2021-11-01T05:06:20Z", DateTimeFormatter.ISO_INSTANT); } - + @Test(expected = DateTimeParseException.class) public void shouldExpectAnExceptionIfSecondIsMissing() { ZonedDateTime zonedDateTime = ZonedDateTime.parse("2021-12-02T08:06Z", DateTimeFormatter.ISO_INSTANT); } + + @Test + public void testUSShortFormatting() { + LocalDate date = LocalDate.of(2023, 9, 18); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM dd, yy: EEE").withLocale(Locale.US); + String formattedDate = date.format(formatter); + Assert.assertEquals("Sep 18, 23: Mon", formattedDate); + } + + @Test + public void testUSFullFormatting() { + LocalDate date = LocalDate.of(2023, 9, 18); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM dd, yyyy: EEEE").withLocale(Locale.US); + String formattedDate = date.format(formatter); + Assert.assertEquals("September 18, 2023: Monday", formattedDate); + } + + @Test + public void testKoreanShortFormatting() { + LocalDate date = LocalDate.of(2023, 9, 18); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMM dd, yy: EEE").withLocale(Locale.KOREA); + String formattedDate = date.format(formatter); + Assert.assertEquals("9월 18, 23: 월", formattedDate); + } + + @Test + public void testKoreanFullFormatting() { + LocalDate date = LocalDate.of(2023, 9, 18); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MMMM dd, yyyy: EEEE").withLocale(Locale.KOREA); + String formattedDate = date.format(formatter); + Assert.assertEquals("9월 18, 2023: 월요일", formattedDate); + } } diff --git a/core-java-modules/core-java-io-apis-2/src/main/java/com/baeldung/eofdetections/EOFDetection.java b/core-java-modules/core-java-io-apis-2/src/main/java/com/baeldung/eofdetections/EOFDetection.java new file mode 100644 index 0000000000..c6302a3fc9 --- /dev/null +++ b/core-java-modules/core-java-io-apis-2/src/main/java/com/baeldung/eofdetections/EOFDetection.java @@ -0,0 +1,60 @@ +package com.baeldung.eofdetections; + +import java.io.*; +import java.nio.ByteBuffer; +import java.nio.channels.FileChannel; +import java.nio.charset.StandardCharsets; +import java.util.*; + +public class EOFDetection { + + public String readWithFileInputStream(String pathFile) throws IOException { + try (FileInputStream fis = new FileInputStream(pathFile); + ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + int data; + while ((data = fis.read()) != -1) { + baos.write(data); + } + return baos.toString(); + } + } + + public String readWithBufferedReader(String pathFile) throws IOException { + try (FileInputStream fis = new FileInputStream(pathFile); + InputStreamReader isr = new InputStreamReader(fis); + BufferedReader reader = new BufferedReader(isr)) { + StringBuilder actualContent = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + actualContent.append(line); + } + return actualContent.toString(); + } + } + + public String readWithScanner(String pathFile) throws IOException { + File file = new File(pathFile); + Scanner scanner = new Scanner(file); + StringBuilder actualContent = new StringBuilder(); + while (scanner.hasNext()) { + String line = scanner.nextLine(); + actualContent.append(line); + } + scanner.close(); + return actualContent.toString(); + } + + public String readFileWithFileChannelAndByteBuffer(String pathFile) throws IOException { + try (FileInputStream fis = new FileInputStream(pathFile); + FileChannel channel = fis.getChannel()) { + + ByteBuffer buffer = ByteBuffer.allocate((int) channel.size()); + while (channel.read(buffer) != -1) { + buffer.flip(); + buffer.clear(); + } + return StandardCharsets.UTF_8.decode(buffer).toString(); + } + } +} + diff --git a/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/eofdetections/EOFDetectionUnitTest.java b/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/eofdetections/EOFDetectionUnitTest.java new file mode 100644 index 0000000000..525b242bf9 --- /dev/null +++ b/core-java-modules/core-java-io-apis-2/src/test/java/com/baeldung/eofdetections/EOFDetectionUnitTest.java @@ -0,0 +1,80 @@ +package com.baeldung.eofdetections; + +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; + +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +public class EOFDetectionUnitTest { + + static final String LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum"; + String pathToFile = "sample.txt"; // init sample file path + EOFDetection eofDetection = new EOFDetection(); + @Test + @Order(1) + public void givenDummyText_whenReadWithFileInputStream_returnText() { + try { + String actualText = eofDetection.readWithFileInputStream(pathToFile); + assertEquals(LOREM_IPSUM, actualText); + } catch (IOException e) { + fail(e.getMessage()); + } + } + + @Test + @Order(2) + public void givenDummyText_whenReadFileWithBufferedReader_returnText() { + try { + String actualText = eofDetection.readWithBufferedReader(pathToFile); + assertEquals(LOREM_IPSUM, actualText); + } catch (IOException e) { + fail(e.getMessage()); + } + } + + @Test + @Order(3) + public void givenDummyText_whenReadFileWithScanner_returnText() { + try { + String actualText = eofDetection.readWithScanner(pathToFile); + assertEquals(LOREM_IPSUM, actualText); + } catch (IOException e) { + fail(e.getMessage()); + } + } + + @Test + @Order(4) + public void givenDummyText_whenReadFileWithFileChannelAndByteBuffer_returnText() { + try { + String actualText = eofDetection.readFileWithFileChannelAndByteBuffer(pathToFile); + assertEquals(LOREM_IPSUM, actualText); + } catch (IOException e) { + fail(e.getMessage()); + } + } + @Test + @Order(0) + public void prepareFileForTest() { + File file = new File(pathToFile); + + if (!file.exists()) { + try { + file.createNewFile(); + FileWriter writer = new FileWriter(file); + writer.write(LOREM_IPSUM); + writer.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/core-java-modules/core-java-io/src/test/java/com/baeldung/extension/ExtensionFromMimeTypeUnitTest.java b/core-java-modules/core-java-io/src/test/java/com/baeldung/extension/ExtensionFromMimeTypeUnitTest.java index f8f42861cc..2238cfcafa 100644 --- a/core-java-modules/core-java-io/src/test/java/com/baeldung/extension/ExtensionFromMimeTypeUnitTest.java +++ b/core-java-modules/core-java-io/src/test/java/com/baeldung/extension/ExtensionFromMimeTypeUnitTest.java @@ -14,7 +14,7 @@ import org.apache.tika.mime.MimeTypeException; import org.junit.Test; -import com.j256.simplemagic.ContentInfo; +import com.j256.simplemagic.ContentType; public class ExtensionFromMimeTypeUnitTest { private static final String IMAGE_JPEG_MIME_TYPE = "image/jpeg"; @@ -39,8 +39,7 @@ public class ExtensionFromMimeTypeUnitTest { @Test public void whenUsingMimetypesFileTypeMap_thenGetFileExtension() { List expectedExtensions = Arrays.asList("jpeg", "jpg", "jpe"); - ContentInfo contentInfo = new ContentInfo("", IMAGE_JPEG_MIME_TYPE, "", true); - String[] detectedExtensions = contentInfo.getFileExtensions(); + String[] detectedExtensions = ContentType.fromMimeType(IMAGE_JPEG_MIME_TYPE).getFileExtensions(); assertThat(detectedExtensions).containsExactlyElementsOf(expectedExtensions); } diff --git a/core-java-modules/core-java-lang-oop-inheritance/README.md b/core-java-modules/core-java-lang-oop-inheritance/README.md index 430f88e717..6091b15024 100644 --- a/core-java-modules/core-java-lang-oop-inheritance/README.md +++ b/core-java-modules/core-java-lang-oop-inheritance/README.md @@ -12,4 +12,4 @@ This module contains articles about inheritance in Java - [Guide to Inheritance in Java](https://www.baeldung.com/java-inheritance) - [Object Type Casting in Java](https://www.baeldung.com/java-type-casting) - [Variable and Method Hiding in Java](https://www.baeldung.com/java-variable-method-hiding) -- [Inner Classes Vs. Subclasses in Java](https://www.baeldung.com/java-inner-classes-vs-subclasses) +- [Inner Classes vs. Subclasses in Java](https://www.baeldung.com/java-inner-classes-vs-subclasses) diff --git a/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/EchoIntegrationTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/EchoIntegrationTest.java index 103824b6aa..1e85b9d6dd 100644 --- a/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/EchoIntegrationTest.java +++ b/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/EchoIntegrationTest.java @@ -24,7 +24,7 @@ public class EchoIntegrationTest { Executors.newSingleThreadExecutor() .submit(() -> new EchoServer().start(port)); - Thread.sleep(500); + Thread.sleep(2000); } private EchoClient client = new EchoClient(); diff --git a/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java index 2bded156c5..09f20c970d 100644 --- a/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java +++ b/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/GreetServerIntegrationTest.java @@ -27,7 +27,7 @@ public class GreetServerIntegrationTest { Executors.newSingleThreadExecutor() .submit(() -> new GreetServer().start(port)); - Thread.sleep(500); + Thread.sleep(2000); } @Before diff --git a/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java b/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java index 62e2dd44ae..f08542c1aa 100644 --- a/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java +++ b/core-java-modules/core-java-networking/src/test/java/com/baeldung/socket/SocketEchoMultiIntegrationTest.java @@ -23,7 +23,7 @@ public class SocketEchoMultiIntegrationTest { s.close(); Executors.newSingleThreadExecutor().submit(() -> new EchoMultiServer().start(port)); - Thread.sleep(500); + Thread.sleep(2000); } @Test diff --git a/core-java-modules/core-java-streams-5/README.md b/core-java-modules/core-java-streams-5/README.md index 885949d937..dec4a7a0cb 100644 --- a/core-java-modules/core-java-streams-5/README.md +++ b/core-java-modules/core-java-streams-5/README.md @@ -2,3 +2,4 @@ - [Difference Between parallelStream() and stream().parallel() in Java](https://www.baeldung.com/java-parallelstream-vs-stream-parallel) - [Working With Empty Stream in Java](https://www.baeldung.com/java-empty-stream) - [Aggregate Runtime Exceptions in Java Streams](https://www.baeldung.com/java-streams-aggregate-exceptions) +- [Streams vs. Loops in Java](https://www.baeldung.com/java-streams-vs-loops) 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 7d4adeba92..536175acc2 100644 --- a/core-java-modules/core-java-string-algorithms-3/pom.xml +++ b/core-java-modules/core-java-string-algorithms-3/pom.xml @@ -23,6 +23,11 @@ commons-lang3 ${apache-commons-lang3.version} + + com.vdurmont + emoji-java + ${emoji-java.version} + @@ -52,6 +57,7 @@ 11 1.7 3.12.0 + 5.1.1 \ No newline at end of file diff --git a/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/findemojis/FindEmojisUnitTest.java b/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/findemojis/FindEmojisUnitTest.java new file mode 100644 index 0000000000..3cd5b1ba97 --- /dev/null +++ b/core-java-modules/core-java-string-algorithms-3/src/test/java/com/baeldung/findemojis/FindEmojisUnitTest.java @@ -0,0 +1,33 @@ +package com.baeldung.findemojis; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +import com.vdurmont.emoji.EmojiManager; + +public class FindEmojisUnitTest { + + @Test + public void givenAWord_whenUsingEmojiJava_thenDetectEmoji() { + boolean emoji = EmojiManager.isEmoji("\uD83D\uDC3B"); + assertTrue(emoji); + + boolean notEmoji = EmojiManager.isEmoji("w"); + assertFalse(notEmoji); + } + + @Test + public void givenAWord_whenUsingRegex_thenDetectEmoji() { + String regexPattern = "[\uD800-\uDBFF\uDC00-\uDFFF]+"; + String emojiString = "\uD83D\uDC3B"; + boolean emoji = emojiString.matches(regexPattern); + assertTrue(emoji); + + String notEmojiString = "w"; + boolean notEmoji = notEmojiString.matches(regexPattern); + assertFalse(notEmoji); + } + +} diff --git a/core-java-modules/core-java-string-operations-5/README.md b/core-java-modules/core-java-string-operations-5/README.md index 21ba1bf985..fda7f39654 100644 --- a/core-java-modules/core-java-string-operations-5/README.md +++ b/core-java-modules/core-java-string-operations-5/README.md @@ -10,4 +10,5 @@ - [Guide to Splitting a String by Whitespace in Java](https://www.baeldung.com/java-splitting-a-string-by-whitespace) - [Check if the First Letter of a String Is a Number](https://www.baeldung.com/java-check-if-string-starts-with-number) - [Print “” Quotes Around a String in Java](https://www.baeldung.com/java-string-print-quotes) -- [Remove Punctuation From a String in Java](https://www.baeldung.com/java-remove-punctuation-from-string) \ No newline at end of file +- [Remove Punctuation From a String in Java](https://www.baeldung.com/java-remove-punctuation-from-string) +- [Replacing Single Quote with \’ in Java String](https://www.baeldung.com/java-replacing-single-quote-string) diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 7fbd6cf657..34e5204868 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -65,6 +65,7 @@ core-java-arrays-convert core-java-arrays-operations-basic core-java-arrays-operations-advanced + core-java-arrays-operations-advanced-2 core-java-booleans core-java-char core-java-collections diff --git a/drools/src/main/java/com/baeldung/drools/config/DroolsBeanFactory.java b/drools/src/main/java/com/baeldung/drools/config/DroolsBeanFactory.java index fd2090aecb..386b2ca4a7 100644 --- a/drools/src/main/java/com/baeldung/drools/config/DroolsBeanFactory.java +++ b/drools/src/main/java/com/baeldung/drools/config/DroolsBeanFactory.java @@ -1,8 +1,15 @@ package com.baeldung.drools.config; +import java.util.Arrays; +import java.util.List; + import org.drools.decisiontable.DecisionTableProviderImpl; import org.kie.api.KieServices; -import org.kie.api.builder.*; +import org.kie.api.builder.KieBuilder; +import org.kie.api.builder.KieFileSystem; +import org.kie.api.builder.KieModule; +import org.kie.api.builder.KieRepository; +import org.kie.api.builder.ReleaseId; import org.kie.api.io.Resource; import org.kie.api.runtime.KieContainer; import org.kie.api.runtime.KieSession; @@ -10,35 +17,19 @@ import org.kie.internal.builder.DecisionTableConfiguration; import org.kie.internal.builder.DecisionTableInputType; import org.kie.internal.builder.KnowledgeBuilderFactory; import org.kie.internal.io.ResourceFactory; -import java.util.Arrays; -import java.util.List; public class DroolsBeanFactory { private static final String RULES_PATH = "com/baeldung/drools/rules/"; private KieServices kieServices = KieServices.Factory.get(); - private KieFileSystem getKieFileSystem() { + private KieFileSystem getKieFileSystem() { KieFileSystem kieFileSystem = kieServices.newKieFileSystem(); - List rules = Arrays.asList("BackwardChaining.drl", "SuggestApplicant.drl", "Product_rules.drl.xls"); - for(String rule:rules) { + List rules = Arrays.asList("com/baeldung/drools/rules/BackwardChaining.drl", "com/baeldung/drools/rules/SuggestApplicant.drl", "com/baeldung/drools/rules/Product_rules.drl.xls"); + for (String rule : rules) { kieFileSystem.write(ResourceFactory.newClassPathResource(rule)); } return kieFileSystem; - - } - - public KieContainer getKieContainer() { - getKieRepository(); - - KieBuilder kb = kieServices.newKieBuilder(getKieFileSystem()); - kb.buildAll(); - - KieModule kieModule = kb.getKieModule(); - KieContainer kContainer = kieServices.newKieContainer(kieModule.getReleaseId()); - - return kContainer; - } private void getKieRepository() { @@ -47,20 +38,14 @@ public class DroolsBeanFactory { } public KieSession getKieSession() { - getKieRepository(); - KieFileSystem kieFileSystem = kieServices.newKieFileSystem(); - - kieFileSystem.write(ResourceFactory.newClassPathResource("com/baeldung/drools/rules/BackwardChaining.drl")); - kieFileSystem.write(ResourceFactory.newClassPathResource("com/baeldung/drools/rules/SuggestApplicant.drl")); - kieFileSystem.write(ResourceFactory.newClassPathResource("com/baeldung/drools/rules/Product_rules.drl.xls")); - - KieBuilder kb = kieServices.newKieBuilder(kieFileSystem); + KieBuilder kb = kieServices.newKieBuilder(getKieFileSystem()); kb.buildAll(); - KieModule kieModule = kb.getKieModule(); - KieContainer kContainer = kieServices.newKieContainer(kieModule.getReleaseId()); + KieRepository kieRepository = kieServices.getRepository(); + ReleaseId krDefaultReleaseId = kieRepository.getDefaultReleaseId(); + KieContainer kieContainer = kieServices.newKieContainer(krDefaultReleaseId); - return kContainer.newKieSession(); + return kieContainer.newKieSession(); } public KieSession getKieSession(Resource dt) { diff --git a/gradle-modules/gradle-5/README.md b/gradle-modules/gradle-5/README.md index e37c100534..7871c0e822 100644 --- a/gradle-modules/gradle-5/README.md +++ b/gradle-modules/gradle-5/README.md @@ -2,3 +2,4 @@ - [Run a Java main Method Using Gradle](https://www.baeldung.com/gradle-run-java-main) - [Finding Unused Gradle Dependencies](https://www.baeldung.com/gradle-finding-unused-dependencies) +- [Intro to Gradle Lint Plugin](https://www.baeldung.com/java-gradle-lint-intro) diff --git a/gradle-modules/gradle-5/build.gradle b/gradle-modules/gradle-5/build.gradle index 84cf05bad6..bc3f233f99 100644 --- a/gradle-modules/gradle-5/build.gradle +++ b/gradle-modules/gradle-5/build.gradle @@ -1,14 +1,21 @@ -plugins{ - id "nebula.lint" version "16.9.0" +plugins { + id "nebula.lint" version "18.1.0" } + description = "Gradle 5 root project" allprojects { - apply plugin :"java" - apply plugin :"nebula.lint" + apply plugin: "java" + apply plugin: "nebula.lint" gradleLint { - rules=['unused-dependency'] + rules = [ + // 'unused-dependency', + // 'dependency-parentheses', + // 'undeclared-dependency', + // 'minimum-dependency-version' + ] reportFormat = 'text' + reportOnlyFixableViolations = true } group = "com.baeldung" version = "0.0.1" @@ -16,6 +23,6 @@ allprojects { targetCompatibility = "1.8" repositories { - jcenter() + mavenCentral() } } \ No newline at end of file diff --git a/gradle-modules/gradle-5/gradle-lint-intro.gradle b/gradle-modules/gradle-5/gradle-lint-intro.gradle new file mode 100644 index 0000000000..4b919c21e8 --- /dev/null +++ b/gradle-modules/gradle-5/gradle-lint-intro.gradle @@ -0,0 +1,6 @@ +allprojects { + apply plugin: "nebula.lint" + gradleLint { + rules = ['dependency-parenthesis'] + } +} \ No newline at end of file diff --git a/gradle-modules/gradle-5/gradle-lint-intro/.gitignore b/gradle-modules/gradle-5/gradle-lint-intro/.gitignore new file mode 100644 index 0000000000..84c048a73c --- /dev/null +++ b/gradle-modules/gradle-5/gradle-lint-intro/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/gradle-modules/gradle-5/gradle-lint-intro/build.gradle b/gradle-modules/gradle-5/gradle-lint-intro/build.gradle new file mode 100644 index 0000000000..fab83bfeec --- /dev/null +++ b/gradle-modules/gradle-5/gradle-lint-intro/build.gradle @@ -0,0 +1,15 @@ + +description = "Introduction to Gradle Lint Plugin" + +ext { + awsVersion = '2.20.83' +} + + +dependencies { + implementation platform("software.amazon.awssdk:bom:$awsVersion") + testImplementation('junit:junit:4.13.1') + gradleLint.ignore('unused-dependency', 'dependency-parentheses') { + implementation('software.amazon.awssdk:sts') + } +} diff --git a/gradle-modules/gradle-5/gradle/wrapper/gradle-wrapper.properties b/gradle-modules/gradle-5/gradle/wrapper/gradle-wrapper.properties index 4c46317507..7666e22b54 100644 --- a/gradle-modules/gradle-5/gradle/wrapper/gradle-wrapper.properties +++ b/gradle-modules/gradle-5/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip diff --git a/gradle-modules/gradle-5/lint.gradle b/gradle-modules/gradle-5/lint.gradle new file mode 100644 index 0000000000..7fc8ca780e --- /dev/null +++ b/gradle-modules/gradle-5/lint.gradle @@ -0,0 +1,16 @@ +import com.netflix.nebula.lint.plugin.GradleLintPlugin + +initscript { + repositories { mavenCentral() } + dependencies { + classpath 'com.netflix.nebula:gradle-lint-plugin:18.1.0' + } +} + +allprojects { + apply plugin: GradleLintPlugin + gradleLint { + rules=[] + alwaysRun= false + } +} \ No newline at end of file diff --git a/gradle-modules/gradle-5/settings.gradle b/gradle-modules/gradle-5/settings.gradle index c73af319a3..3173a23d5c 100644 --- a/gradle-modules/gradle-5/settings.gradle +++ b/gradle-modules/gradle-5/settings.gradle @@ -2,4 +2,5 @@ rootProject.name='gradle-5' include 'java-exec' include 'unused-dependencies' include 'source-sets' -include 'cmd-line-args' \ No newline at end of file +include 'cmd-line-args' +include 'gradle-lint-intro' \ No newline at end of file diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index ec02b0f37c..ec63d5c56e 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -101,6 +101,7 @@ spring-data-shardingsphere + spring-hibernate-6 spring-jpa spring-jpa-2 spring-jdbc @@ -114,7 +115,7 @@ java-mongodb questdb neo4j - rethinkdb + scylladb spring-data-cassandra-2 spring-data-jpa-repo-3 diff --git a/persistence-modules/spring-data-cassandra-2/README.md b/persistence-modules/spring-data-cassandra-2/README.md index 3f49d6ae93..0578dcc429 100644 --- a/persistence-modules/spring-data-cassandra-2/README.md +++ b/persistence-modules/spring-data-cassandra-2/README.md @@ -2,3 +2,4 @@ - [Using Test Containers With Spring Data Cassandra](https://www.baeldung.com/spring-data-cassandra-test-containers) - [Cassandra – Object Mapping with DataStax Java Driver](https://www.baeldung.com/cassandra-object-mapping-datastax-java-driver) +- [Query With IN Clause in Spring Data Cassandra](https://www.baeldung.com/spring-cassandra-query-in-clause) diff --git a/persistence-modules/spring-data-couchbase-2/src/test/docker/Dockerfile b/persistence-modules/spring-data-couchbase-2/src/test/docker/Dockerfile new file mode 100644 index 0000000000..1dffcb31f1 --- /dev/null +++ b/persistence-modules/spring-data-couchbase-2/src/test/docker/Dockerfile @@ -0,0 +1,4 @@ +FROM couchbase/server:community-5.0.1 + +COPY configure.sh /configure.sh +CMD ["/configure.sh"] \ No newline at end of file diff --git a/persistence-modules/spring-data-couchbase-2/src/test/docker/configure.sh b/persistence-modules/spring-data-couchbase-2/src/test/docker/configure.sh new file mode 100644 index 0000000000..c2b62dba7c --- /dev/null +++ b/persistence-modules/spring-data-couchbase-2/src/test/docker/configure.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +function retry() { + for i in $(seq 1 10); do + $1 "$2" + if [[ $? == 0 ]]; then + return 0 + fi + sleep 1 + done + return 1 +} + +function bucketCreate(){ + couchbase-cli bucket-create -c localhost -u Administrator -p password \ + --bucket="$1" \ + --bucket-type=couchbase \ + --bucket-ramsize=512 \ + --bucket-replica=1 \ + --wait + if [[ $? != 0 ]]; then + return 1 + fi +} + +function userCreate(){ + createOutput=$(couchbase-cli user-manage -c localhost -u Administrator -p password \ + --set --rbac-username "$1" --rbac-password "$1" \ + --roles admin --auth-domain local) + if [[ $? != 0 ]]; then + echo $createOutput >&2 + return 1 + fi +} + +function clusterUp(){ + # wait for service to come up + until $(curl --output /dev/null --silent --head --fail http://localhost:8091); do + printf '.' + sleep 1 + done + + # initialize cluster + initOutput=$(couchbase-cli cluster-init -c localhost \ + --cluster-username=Administrator \ + --cluster-password=password \ + --cluster-port=8091 \ + --services=data,index,query,fts \ + --cluster-ramsize=1024 \ + --cluster-index-ramsize=256 \ + --cluster-fts-ramsize=256 \ + --index-storage-setting=default) + if [[ $? != 0 ]]; then + echo $initOutput >&2 + return 1 + fi +} + +function main(){ + set -ex + echo "Couchbase UI :8091" + echo "Couchbase logs /opt/couchbase/var/lib/couchbase/logs" + ./entrypoint.sh couchbase-server & + if [[ $? != 0 ]]; then + echo "Couchbase startup failed. Exiting." >&2 + exit 1 + fi + + clusterUp + if [[ $? != 0 ]]; then + echo "Cluster init failed. Exiting." >&2 + exit 1 + fi + + retry userCreate baeldung + if [[ $? != 0 ]]; then + echo "User create failed. Exiting." >&2 + exit 1 + fi + + retry userCreate baeldung2 + if [[ $? != 0 ]]; then + echo "User create failed. Exiting." >&2 + exit 1 + fi + + retry bucketCreate baeldung + if [[ $? != 0 ]]; then + echo "Bucket create failed. Exiting." >&2 + exit 1 + fi + + retry bucketCreate baeldung2 + if [[ $? != 0 ]]; then + echo "Bucket create failed. Exiting." >&2 + exit 1 + fi + + set +ex + + # entrypoint.sh launches the server but since config.sh is pid 1 we keep it + # running so that the docker container does not exit. + wait +} + +main \ No newline at end of file diff --git a/persistence-modules/spring-data-couchbase-2/src/test/docker/dockerbuild.sh b/persistence-modules/spring-data-couchbase-2/src/test/docker/dockerbuild.sh new file mode 100644 index 0000000000..37add165c6 --- /dev/null +++ b/persistence-modules/spring-data-couchbase-2/src/test/docker/dockerbuild.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# setup +set -ex +docker rm couchbase_container -f + +# main +docker build -t couchbase_image . + +# cleanup +set +ex + +# run +docker run -d --name couchbase_container -p 8091-8096:8091-8096 -p 11210-11211:11210-11211 couchbase_image diff --git a/persistence-modules/spring-data-couchbase-2/src/test/java/com/baeldung/SpringContextLiveTest.java b/persistence-modules/spring-data-couchbase-2/src/test/java/com/baeldung/SpringContextLiveTest.java index 553520e6e6..74dccbadd0 100644 --- a/persistence-modules/spring-data-couchbase-2/src/test/java/com/baeldung/SpringContextLiveTest.java +++ b/persistence-modules/spring-data-couchbase-2/src/test/java/com/baeldung/SpringContextLiveTest.java @@ -12,16 +12,10 @@ import org.springframework.test.context.support.DependencyInjectionTestExecution /** * This LiveTest requires: * - * 1- Couchbase instance running (e.g. with `docker run -d --name db -p 8091-8096:8091-8096 -p 11210-11211:11210-11211 couchbase`) - * - * - * 2- Couchbase configured with (we can use the console in localhost:8091): - * - * 2.1- Buckets: named 'baeldung' and 'baeldung2' - * - * 2.2- Security: users 'baeldung' and 'baeldung2'. Note: in newer versions an empty password is not allowed, then we have to change the passwords in the project) - * - * 2.3- Spacial View: Add new spacial view (in Index tab) in document 'campus_spatial', view 'byLocation' with the following function: + * 1- Couchbase 5 instance Running and Configured. + * It's enough to execute the "dockerbuild.sh" script in the test/docker folder. + * + * 2.1- Spacial View: Add new spacial view (in Index tab) in document 'campus_spatial', view 'byLocation' with the following function: * {@code * function (doc) { * if (doc.location && @@ -30,8 +24,9 @@ import org.springframework.test.context.support.DependencyInjectionTestExecution * } * }} * - * 2.4- MapReduce Views: Add new views in document 'campus': - * 2.4.1- view 'all' with function: + * 2.2- MapReduce Views: Add new views in document 'campus': + * + * 2.2.1- view 'all' with function: * {@code * function (doc, meta) { * if(doc._class == "com.baeldung.spring.data.couchbase.model.Campus") { @@ -39,7 +34,7 @@ import org.springframework.test.context.support.DependencyInjectionTestExecution * } * }} * - * 2.4.2- view 'byName' with function: + * 2.2.2- view 'byName' with function: * {@code * function (doc, meta) { * if(doc._class == "com.baeldung.spring.data.couchbase.model.Campus" && diff --git a/persistence-modules/spring-data-couchbase-2/src/test/java/com/baeldung/spring/data/couchbase/CustomTypeKeyCouchbaseConfig.java b/persistence-modules/spring-data-couchbase-2/src/test/java/com/baeldung/spring/data/couchbase/CustomTypeKeyCouchbaseConfig.java deleted file mode 100644 index eacecb4e1e..0000000000 --- a/persistence-modules/spring-data-couchbase-2/src/test/java/com/baeldung/spring/data/couchbase/CustomTypeKeyCouchbaseConfig.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.baeldung.spring.data.couchbase; - -import org.springframework.data.couchbase.core.convert.MappingCouchbaseConverter; - -public class CustomTypeKeyCouchbaseConfig extends MyCouchbaseConfig { - - @Override - public String getConnectionString() { - return NODE_LIST; - } - - @Override - public String getUserName() { - return BUCKET_USERNAME; - } - - @Override - public String getPassword() { - return BUCKET_PASSWORD; - } - - @Override - public String typeKey() { - return MappingCouchbaseConverter.TYPEKEY_SYNCGATEWAY_COMPATIBLE; - } -} diff --git a/persistence-modules/spring-data-couchbase-2/src/test/java/com/baeldung/spring/data/couchbase/ReadYourOwnWritesCouchbaseConfig.java b/persistence-modules/spring-data-couchbase-2/src/test/java/com/baeldung/spring/data/couchbase/ReadYourOwnWritesCouchbaseConfig.java deleted file mode 100644 index 33a6c4f091..0000000000 --- a/persistence-modules/spring-data-couchbase-2/src/test/java/com/baeldung/spring/data/couchbase/ReadYourOwnWritesCouchbaseConfig.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.spring.data.couchbase; - -import com.couchbase.client.java.query.QueryScanConsistency; - -public class ReadYourOwnWritesCouchbaseConfig extends MyCouchbaseConfig { - - @Override - public QueryScanConsistency getDefaultConsistency() { - return QueryScanConsistency.REQUEST_PLUS; - } -} diff --git a/persistence-modules/spring-data-mongodb/pom.xml b/persistence-modules/spring-data-mongodb/pom.xml index 87cf1acaf8..a59fcff3d9 100644 --- a/persistence-modules/spring-data-mongodb/pom.xml +++ b/persistence-modules/spring-data-mongodb/pom.xml @@ -8,31 +8,19 @@ com.baeldung - parent-spring-5 + parent-boot-2 0.0.1-SNAPSHOT - ../../parent-spring-5 + ../../parent-boot-2 - org.springframework.data - spring-data-mongodb - ${org.springframework.data.version} + org.springframework.boot + spring-boot-starter-data-mongodb - org.mongodb - mongodb-driver-sync - ${mongodb-driver.version} - - - org.mongodb - mongodb-driver-reactivestreams - ${mongodb-reactivestreams.version} - - - io.projectreactor - reactor-core - ${projectreactor.version} + org.springframework.boot + spring-boot-starter-data-mongodb-reactive io.projectreactor @@ -40,23 +28,6 @@ ${projectreactor.version} test - - org.springframework - spring-core - ${spring.version} - - - commons-logging - commons-logging - - - - - org.springframework - spring-test - ${spring.version} - test - com.querydsl querydsl-mongodb @@ -103,12 +74,9 @@ - 3.4.7 5.0.0 1.1.3 - 4.1.0 3.5.4 - 4.6.1 4.6.3 diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionTemplateLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionTemplateLiveTest.java index 53b2c7a0e7..a53dfc6663 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionTemplateLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionTemplateLiveTest.java @@ -28,6 +28,7 @@ import com.baeldung.model.User; * * This test requires: * * mongodb instance running on the environment + * Run the src/live-test/resources/live-test-setup.sh * */ @RunWith(SpringJUnit4ClassRunner.class) diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java index d92296beab..adc31ffea2 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java @@ -26,6 +26,7 @@ import com.baeldung.repository.UserRepository; * * This test requires: * * mongodb instance running on the environment + * Run the src/live-test/resources/live-test-setup.sh * */ @RunWith(SpringJUnit4ClassRunner.class) diff --git a/persistence-modules/spring-hibernate-5/README.md b/persistence-modules/spring-hibernate-5/README.md index e2344fd585..ce78e5a0df 100644 --- a/persistence-modules/spring-hibernate-5/README.md +++ b/persistence-modules/spring-hibernate-5/README.md @@ -4,10 +4,7 @@ This module contains articles about Hibernate 5 with Spring. ### Relevant articles -- [Programmatic Transactions in the Spring TestContext Framework](https://www.baeldung.com/spring-test-programmatic-transactions) - [Introduction to Hibernate Search](https://www.baeldung.com/hibernate-search) -- [@DynamicUpdate with Spring Data JPA](https://www.baeldung.com/spring-data-jpa-dynamicupdate) - [Hibernate Second-Level Cache](http://www.baeldung.com/hibernate-second-level-cache) - [Deleting Objects with Hibernate](http://www.baeldung.com/delete-with-hibernate) - [Spring, Hibernate and a JNDI Datasource](http://www.baeldung.com/spring-persistence-jpa-jndi-datasource) -- [Bootstrapping Hibernate 5 with Spring](https://www.baeldung.com/hibernate-5-spring) diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/bootstrap/HibernateXMLConf.java b/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/bootstrap/HibernateXMLConf.java deleted file mode 100644 index b3e979478f..0000000000 --- a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/bootstrap/HibernateXMLConf.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.hibernate.bootstrap; - -import com.google.common.base.Preconditions; -import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; -import org.springframework.context.annotation.PropertySource; -import org.springframework.core.env.Environment; -import org.springframework.orm.hibernate5.HibernateTransactionManager; -import org.springframework.orm.hibernate5.LocalSessionFactoryBean; -import org.springframework.transaction.PlatformTransactionManager; -import org.springframework.transaction.annotation.EnableTransactionManagement; - -import javax.sql.DataSource; -import java.util.Properties; - -@Configuration -@EnableTransactionManagement -@ImportResource({ "classpath:hibernate5Configuration.xml" }) -public class HibernateXMLConf { - -} diff --git a/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/dynamicupdate/DynamicUpdateIntegrationTest.java b/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/dynamicupdate/DynamicUpdateIntegrationTest.java deleted file mode 100644 index fc183d1f19..0000000000 --- a/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/dynamicupdate/DynamicUpdateIntegrationTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.baeldung.hibernate.dynamicupdate; - -import javax.transaction.Transactional; - -import org.junit.FixMethodOrder; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.MethodSorters; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.Commit; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; - -import com.baeldung.hibernate.dynamicupdate.model.Account; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = DynamicUpdateConfig.class, loader = AnnotationConfigContextLoader.class) -@Transactional -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class DynamicUpdateIntegrationTest { - - private static final Integer ACCOUNT_ID = 1; - - @Autowired - private AccountRepository accountRepository; - - @Test - @Commit - public void testA_whenTestAccountIsSaved_thenSuccess() { - Account account = new Account(ACCOUNT_ID, "account1", "regional", true); - accountRepository.save(account); - } - - @Test - @Commit - // Enable Hibernate's debug logging in logback.xml to see the generated SQL statement. - public void testB_whenAccountNameUpdated_thenSuccess() { - Account account = accountRepository.findOne(ACCOUNT_ID); - account.setName("Test Account"); - accountRepository.save(account); - } - -} diff --git a/persistence-modules/spring-hibernate-6/.gitignore b/persistence-modules/spring-hibernate-6/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/persistence-modules/spring-hibernate-6/.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/persistence-modules/spring-hibernate-6/README.md b/persistence-modules/spring-hibernate-6/README.md new file mode 100644 index 0000000000..08fe6216fd --- /dev/null +++ b/persistence-modules/spring-hibernate-6/README.md @@ -0,0 +1,9 @@ +## Hibernate 6 with Spring + +This module contains articles about Hibernate 6 with Spring. + +### Relevant articles + +- [Programmatic Transactions in the Spring TestContext Framework](https://www.baeldung.com/spring-test-programmatic-transactions) +- [@DynamicUpdate with Spring Data JPA](https://www.baeldung.com/spring-data-jpa-dynamicupdate) +- [Bootstrapping Hibernate 5 with Spring](https://www.baeldung.com/hibernate-5-spring) diff --git a/persistence-modules/spring-hibernate-6/pom.xml b/persistence-modules/spring-hibernate-6/pom.xml new file mode 100644 index 0000000000..a13117e68c --- /dev/null +++ b/persistence-modules/spring-hibernate-6/pom.xml @@ -0,0 +1,109 @@ + + + 4.0.0 + spring-hibernate-6 + 0.1-SNAPSHOT + spring-hibernate-6 + + + com.baeldung + persistence-modules + 1.0.0-SNAPSHOT + + + + + + org.springframework + spring-context + ${org.springframework.version} + + + commons-logging + commons-logging + + + + + org.springframework + spring-aspects + ${org.springframework.version} + + + + org.springframework + spring-orm + ${org.springframework.version} + + + org.springframework.data + spring-data-jpa + ${org.springframework.data.version} + + + org.hibernate.orm + hibernate-core + ${hibernate.version} + + + org.apache.tomcat + tomcat-dbcp + ${tomcat-dbcp.version} + + + + + com.google.guava + guava + ${guava.version} + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + test + + + org.springframework + spring-test + ${org.springframework.version} + test + + + org.springframework.security + spring-security-test + ${org.springframework.security.version} + test + + + org.hsqldb + hsqldb + ${hsqldb.version} + + + mysql + mysql-connector-java + ${mysql-connector-java.version} + + + com.h2database + h2 + ${h2.version} + + + + + + 6.0.11 + 3.1.3 + 6.1.3 + + 6.2.8.Final + 8.0.7-dmr + 9.0.80 + + + \ No newline at end of file diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/bootstrap/BarHibernateDAO.java b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/bootstrap/BarHibernateDAO.java similarity index 100% rename from persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/bootstrap/BarHibernateDAO.java rename to persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/bootstrap/BarHibernateDAO.java diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/bootstrap/HibernateConf.java b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/bootstrap/HibernateConf.java similarity index 100% rename from persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/bootstrap/HibernateConf.java rename to persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/bootstrap/HibernateConf.java diff --git a/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/bootstrap/HibernateXMLConf.java b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/bootstrap/HibernateXMLConf.java new file mode 100644 index 0000000000..220c18bccf --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/bootstrap/HibernateXMLConf.java @@ -0,0 +1,12 @@ +package com.baeldung.hibernate.bootstrap; + +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@Configuration +@EnableTransactionManagement +@ImportResource({ "classpath:hibernate6Configuration.xml" }) +public class HibernateXMLConf { + +} diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/bootstrap/model/TestEntity.java b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/bootstrap/model/TestEntity.java similarity index 86% rename from persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/bootstrap/model/TestEntity.java rename to persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/bootstrap/model/TestEntity.java index cae41db831..d260fed7a1 100644 --- a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/bootstrap/model/TestEntity.java +++ b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/bootstrap/model/TestEntity.java @@ -1,7 +1,7 @@ package com.baeldung.hibernate.bootstrap.model; -import javax.persistence.Entity; -import javax.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; @Entity public class TestEntity { diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/dynamicupdate/AccountRepository.java b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/dynamicupdate/AccountRepository.java similarity index 100% rename from persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/dynamicupdate/AccountRepository.java rename to persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/dynamicupdate/AccountRepository.java diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/dynamicupdate/DynamicUpdateConfig.java b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/dynamicupdate/DynamicUpdateConfig.java similarity index 98% rename from persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/dynamicupdate/DynamicUpdateConfig.java rename to persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/dynamicupdate/DynamicUpdateConfig.java index 23e28a9e3b..766295f67a 100644 --- a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/dynamicupdate/DynamicUpdateConfig.java +++ b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/dynamicupdate/DynamicUpdateConfig.java @@ -2,7 +2,7 @@ package com.baeldung.hibernate.dynamicupdate; import java.util.Properties; -import javax.persistence.EntityManagerFactory; +import jakarta.persistence.EntityManagerFactory; import javax.sql.DataSource; import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; diff --git a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/dynamicupdate/model/Account.java b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/dynamicupdate/model/Account.java similarity index 94% rename from persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/dynamicupdate/model/Account.java rename to persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/dynamicupdate/model/Account.java index b3753112fe..808ffe99ee 100644 --- a/persistence-modules/spring-hibernate-5/src/main/java/com/baeldung/hibernate/dynamicupdate/model/Account.java +++ b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/hibernate/dynamicupdate/model/Account.java @@ -2,9 +2,9 @@ package com.baeldung.hibernate.dynamicupdate.model; import java.text.MessageFormat; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; import org.hibernate.annotations.DynamicUpdate; diff --git a/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/dao/IFooDao.java b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/dao/IFooDao.java new file mode 100644 index 0000000000..0935772dbd --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/dao/IFooDao.java @@ -0,0 +1,8 @@ +package com.baeldung.persistence.dao; + +import com.baeldung.persistence.model.Foo; +import com.baeldung.persistence.dao.common.IOperations; + +public interface IFooDao extends IOperations { + // +} diff --git a/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java new file mode 100644 index 0000000000..5a6c76a93a --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/dao/common/AbstractDao.java @@ -0,0 +1,14 @@ +package com.baeldung.persistence.dao.common; + +import java.io.Serializable; + +import com.google.common.base.Preconditions; + +public abstract class AbstractDao implements IOperations { + + protected Class clazz; + + protected final void setClazz(final Class clazzToSet) { + clazz = Preconditions.checkNotNull(clazzToSet); + } +} diff --git a/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java new file mode 100644 index 0000000000..f34866d883 --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/dao/common/AbstractHibernateDao.java @@ -0,0 +1,59 @@ +package com.baeldung.persistence.dao.common; + +import java.io.Serializable; +import java.util.List; + +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.springframework.beans.factory.annotation.Autowired; + +import com.google.common.base.Preconditions; + +@SuppressWarnings("unchecked") +public abstract class AbstractHibernateDao extends AbstractDao implements IOperations { + + @Autowired + protected SessionFactory sessionFactory; + + // API + + @Override + public T findOne(final long id) { + return (T) getCurrentSession().get(clazz, id); + } + + @Override + public List findAll() { + return getCurrentSession().createQuery("from " + clazz.getName()).getResultList(); + } + + @Override + public void create(final T entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().saveOrUpdate(entity); + } + + @Override + public T update(final T entity) { + Preconditions.checkNotNull(entity); + return (T) getCurrentSession().merge(entity); + } + + @Override + public void delete(final T entity) { + Preconditions.checkNotNull(entity); + getCurrentSession().delete(entity); + } + + @Override + public void deleteById(final long entityId) { + final T entity = findOne(entityId); + Preconditions.checkState(entity != null); + delete(entity); + } + + protected Session getCurrentSession() { + return sessionFactory.getCurrentSession(); + } + +} \ No newline at end of file diff --git a/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/dao/common/IOperations.java b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/dao/common/IOperations.java new file mode 100644 index 0000000000..4ef99221ab --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/dao/common/IOperations.java @@ -0,0 +1,20 @@ +package com.baeldung.persistence.dao.common; + +import java.io.Serializable; +import java.util.List; + +public interface IOperations { + + T findOne(final long id); + + List findAll(); + + void create(final T entity); + + T update(final T entity); + + void delete(final T entity); + + void deleteById(final long entityId); + +} diff --git a/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/dao/impl/FooHibernateDao.java b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/dao/impl/FooHibernateDao.java new file mode 100644 index 0000000000..5411073360 --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/dao/impl/FooHibernateDao.java @@ -0,0 +1,19 @@ +package com.baeldung.persistence.dao.impl; + +import com.baeldung.persistence.dao.common.AbstractHibernateDao; +import com.baeldung.persistence.dao.IFooDao; +import com.baeldung.persistence.model.Foo; +import org.springframework.stereotype.Repository; + +@Repository +public class FooHibernateDao extends AbstractHibernateDao implements IFooDao { + + public FooHibernateDao() { + super(); + + setClazz(Foo.class); + } + + // API + +} diff --git a/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/model/Foo.java b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/model/Foo.java new file mode 100644 index 0000000000..c9a541290d --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/persistence/model/Foo.java @@ -0,0 +1,73 @@ +package com.baeldung.persistence.model; + +import jakarta.persistence.*; +import java.io.Serializable; + +@Entity +public class Foo implements Serializable{ + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id") + private long id; + + @Column(name = "name") + private String name; + + public Foo() { + super(); + } + + public Foo(final String name) { + super(); + this.name = name; + } + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final Foo other = (Foo) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + @Override + public String toString() { + final StringBuilder builder = new StringBuilder(); + builder.append("Foo [name=").append(name).append("]"); + return builder.toString(); + } +} diff --git a/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/spring/PersistenceConfig.java b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/spring/PersistenceConfig.java new file mode 100644 index 0000000000..04961c3c49 --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/spring/PersistenceConfig.java @@ -0,0 +1,82 @@ +package com.baeldung.spring; + +import com.baeldung.persistence.dao.IFooDao; +import com.baeldung.persistence.dao.impl.FooHibernateDao; +import com.google.common.base.Preconditions; +import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.env.Environment; +import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; +import org.springframework.orm.hibernate5.HibernateTransactionManager; +import org.springframework.orm.hibernate5.LocalSessionFactoryBean; +import org.springframework.transaction.PlatformTransactionManager; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import javax.sql.DataSource; +import java.util.Properties; + +@Configuration +@EnableTransactionManagement +@PropertySource({ "classpath:persistence-h2.properties" }) +@ComponentScan({ "com.baeldung.persistence" }) +public class PersistenceConfig { + + @Autowired + private Environment env; + + @Bean + public LocalSessionFactoryBean sessionFactory() { + final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); + sessionFactory.setDataSource(myDataSource()); + sessionFactory.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); + sessionFactory.setHibernateProperties(hibernateProperties()); + + return sessionFactory; + } + + @Bean + public DataSource myDataSource() { + final BasicDataSource dataSource = new BasicDataSource(); + dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName"))); + dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url"))); + dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user"))); + dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass"))); + + return dataSource; + } + + @Bean + public PlatformTransactionManager hibernateTransactionManager() { + final HibernateTransactionManager transactionManager = new HibernateTransactionManager(); + transactionManager.setSessionFactory(sessionFactory().getObject()); + return transactionManager; + } + + @Bean + public PersistenceExceptionTranslationPostProcessor exceptionTranslation() { + return new PersistenceExceptionTranslationPostProcessor(); + } + + @Bean + public IFooDao fooHibernateDao() { + return new FooHibernateDao(); + } + + private final Properties hibernateProperties() { + final Properties hibernateProperties = new Properties(); + hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); + hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); + + hibernateProperties.setProperty("hibernate.show_sql", "false"); + + // Envers properties + hibernateProperties.setProperty("org.hibernate.envers.audit_table_suffix", env.getProperty("envers.audit_table_suffix")); + + return hibernateProperties; + } + +} \ No newline at end of file diff --git a/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/spring/PersistenceXmlConfig.java b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/spring/PersistenceXmlConfig.java new file mode 100644 index 0000000000..14caf5c88c --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/main/java/com/baeldung/spring/PersistenceXmlConfig.java @@ -0,0 +1,14 @@ +package com.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@Configuration +@EnableTransactionManagement +@ComponentScan({ "com.baeldung.persistence.dao", "com.baeldung.persistence.service" }) +@ImportResource({ "classpath:hibernate6Config.xml" }) +public class PersistenceXmlConfig { + +} \ No newline at end of file diff --git a/persistence-modules/spring-hibernate-6/src/main/resources/hibernate6Config.xml b/persistence-modules/spring-hibernate-6/src/main/resources/hibernate6Config.xml new file mode 100644 index 0000000000..bbb61cb3e0 --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/main/resources/hibernate6Config.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + ${hibernate.hbm2ddl.auto} + ${hibernate.dialect} + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-hibernate-6/src/main/resources/hibernate6Configuration.xml b/persistence-modules/spring-hibernate-6/src/main/resources/hibernate6Configuration.xml new file mode 100644 index 0000000000..cb6cf0aa5c --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/main/resources/hibernate6Configuration.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + ${hibernate.hbm2ddl.auto} + ${hibernate.dialect} + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-hibernate-6/src/main/resources/logback.xml b/persistence-modules/spring-hibernate-6/src/main/resources/logback.xml new file mode 100644 index 0000000000..ec0dc2469a --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/main/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + web - %date [%thread] %-5level %logger{36} - %message%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/persistence-modules/spring-hibernate-6/src/main/resources/persistence-h2.properties b/persistence-modules/spring-hibernate-6/src/main/resources/persistence-h2.properties new file mode 100644 index 0000000000..2ed7022eab --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/main/resources/persistence-h2.properties @@ -0,0 +1,22 @@ +# jdbc.X +jdbc.driverClassName=org.h2.Driver +jdbc.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 +jdbc.eventGeneratedId=sa +jdbc.user=sa +jdbc.pass= + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.H2Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop +hibernate.cache.use_second_level_cache=true +hibernate.cache.use_query_cache=true +hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory + + +# hibernate.search.X +hibernate.search.default.directory_provider = filesystem +hibernate.search.default.indexBase = /data/index/default + +# envers.X +envers.audit_table_suffix=_audit_log diff --git a/persistence-modules/spring-hibernate-6/src/main/resources/persistence-jndi.properties b/persistence-modules/spring-hibernate-6/src/main/resources/persistence-jndi.properties new file mode 100644 index 0000000000..16d750d7f8 --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/main/resources/persistence-jndi.properties @@ -0,0 +1,8 @@ +# jdbc.X +jdbc.url=java:comp/env/jdbc/BaeldungDatabase + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +hibernate.show_sql=false +#hibernate.hbm2ddl.auto=create +hibernate.hbm2ddl.auto=update \ No newline at end of file diff --git a/persistence-modules/spring-hibernate-6/src/main/resources/persistence-mysql.properties b/persistence-modules/spring-hibernate-6/src/main/resources/persistence-mysql.properties new file mode 100644 index 0000000000..b3cfd31f46 --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/main/resources/persistence-mysql.properties @@ -0,0 +1,13 @@ +# jdbc.X +jdbc.driverClassName=com.mysql.cj.jdbc.Driver +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate5_01?createDatabaseIfNotExist=true +jdbc.eventGeneratedId=tutorialuser +jdbc.pass=tutorialmy5ql + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +hibernate.show_sql=false +hibernate.hbm2ddl.auto=create-drop + +# envers.X +envers.audit_table_suffix=_audit_log diff --git a/persistence-modules/spring-hibernate-6/src/test/java/com/baeldung/SpringContextTest.java b/persistence-modules/spring-hibernate-6/src/test/java/com/baeldung/SpringContextTest.java new file mode 100644 index 0000000000..4ec83cda3e --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/test/java/com/baeldung/SpringContextTest.java @@ -0,0 +1,19 @@ +package com.baeldung; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import com.baeldung.spring.PersistenceConfig; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +public class SpringContextTest { + + @Test + public void whenSpringContextIsBootstrapped_thenNoExceptions() { + + } +} diff --git a/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/bootstrap/HibernateBootstrapIntegrationTest.java b/persistence-modules/spring-hibernate-6/src/test/java/com/baeldung/hibernate/bootstrap/HibernateBootstrapIntegrationTest.java similarity index 79% rename from persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/bootstrap/HibernateBootstrapIntegrationTest.java rename to persistence-modules/spring-hibernate-6/src/test/java/com/baeldung/hibernate/bootstrap/HibernateBootstrapIntegrationTest.java index c41423643a..31522288b6 100644 --- a/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/bootstrap/HibernateBootstrapIntegrationTest.java +++ b/persistence-modules/spring-hibernate-6/src/test/java/com/baeldung/hibernate/bootstrap/HibernateBootstrapIntegrationTest.java @@ -1,33 +1,36 @@ package com.baeldung.hibernate.bootstrap; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import com.baeldung.hibernate.bootstrap.model.TestEntity; + + import org.hibernate.Session; import org.hibernate.SessionFactory; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.annotation.Commit; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.support.AnnotationConfigContextLoader; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.transaction.TestTransaction; import org.springframework.transaction.annotation.Transactional; -import static junit.framework.TestCase.assertFalse; -import static junit.framework.TestCase.assertTrue; -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = { HibernateConf.class }) @Transactional -public class HibernateBootstrapIntegrationTest { +@ContextConfiguration(classes = { HibernateXMLConf.class }) +@ExtendWith(SpringExtension.class) +class HibernateBootstrapIntegrationTest { @Autowired private SessionFactory sessionFactory; @Test - public void whenBootstrapHibernateSession_thenNoException() { + void whenBootstrapHibernateSession_thenNoException() { Session session = sessionFactory.getCurrentSession(); @@ -37,11 +40,11 @@ public class HibernateBootstrapIntegrationTest { TestEntity searchEntity = session.find(TestEntity.class, 1); - Assert.assertNotNull(searchEntity); + assertNotNull(searchEntity); } @Test - public void whenProgrammaticTransactionCommit_thenEntityIsInDatabase() { + void whenProgrammaticTransactionCommit_thenEntityIsInDatabase() { assertTrue(TestTransaction.isActive()); //Save an entity and commit. @@ -53,7 +56,7 @@ public class HibernateBootstrapIntegrationTest { TestEntity searchEntity = session.find(TestEntity.class, 1); - Assert.assertNotNull(searchEntity); + assertTrue(TestTransaction.isFlaggedForRollback()); TestTransaction.flagForCommit(); @@ -72,7 +75,7 @@ public class HibernateBootstrapIntegrationTest { session = sessionFactory.getCurrentSession(); searchEntity = session.find(TestEntity.class, 1); - Assert.assertNotNull(searchEntity); + assertNotNull(searchEntity); session.delete(searchEntity); session.flush(); @@ -88,7 +91,7 @@ public class HibernateBootstrapIntegrationTest { session = sessionFactory.getCurrentSession(); searchEntity = session.find(TestEntity.class, 1); - Assert.assertNotNull(searchEntity); + assertNotNull(searchEntity); session.delete(searchEntity); session.flush(); @@ -108,12 +111,12 @@ public class HibernateBootstrapIntegrationTest { session = sessionFactory.getCurrentSession(); searchEntity = session.find(TestEntity.class, 1); - Assert.assertNull(searchEntity); + assertNull(searchEntity); } @Test @Commit - public void givenTransactionCommitDefault_whenProgrammaticTransactionCommit_thenEntityIsInDatabase() { + void givenTransactionCommitDefault_whenProgrammaticTransactionCommit_thenEntityIsInDatabase() { assertTrue(TestTransaction.isActive()); //Save an entity and commit. @@ -125,7 +128,7 @@ public class HibernateBootstrapIntegrationTest { TestEntity searchEntity = session.find(TestEntity.class, 1); - Assert.assertNotNull(searchEntity); + assertNotNull(searchEntity); assertFalse(TestTransaction.isFlaggedForRollback()); TestTransaction.end(); @@ -143,7 +146,7 @@ public class HibernateBootstrapIntegrationTest { session = sessionFactory.getCurrentSession(); searchEntity = session.find(TestEntity.class, 1); - Assert.assertNotNull(searchEntity); + assertNotNull(searchEntity); session.delete(searchEntity); session.flush(); @@ -160,7 +163,7 @@ public class HibernateBootstrapIntegrationTest { session = sessionFactory.getCurrentSession(); searchEntity = session.find(TestEntity.class, 1); - Assert.assertNotNull(searchEntity); + assertNotNull(searchEntity); session.delete(searchEntity); session.flush(); @@ -179,7 +182,7 @@ public class HibernateBootstrapIntegrationTest { session = sessionFactory.getCurrentSession(); searchEntity = session.find(TestEntity.class, 1); - Assert.assertNull(searchEntity); + assertNull(searchEntity); } } diff --git a/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/bootstrap/HibernateXMLBootstrapIntegrationTest.java b/persistence-modules/spring-hibernate-6/src/test/java/com/baeldung/hibernate/bootstrap/HibernateXMLBootstrapIntegrationTest.java similarity index 65% rename from persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/bootstrap/HibernateXMLBootstrapIntegrationTest.java rename to persistence-modules/spring-hibernate-6/src/test/java/com/baeldung/hibernate/bootstrap/HibernateXMLBootstrapIntegrationTest.java index 5b811ad576..153e6736f1 100644 --- a/persistence-modules/spring-hibernate-5/src/test/java/com/baeldung/hibernate/bootstrap/HibernateXMLBootstrapIntegrationTest.java +++ b/persistence-modules/spring-hibernate-6/src/test/java/com/baeldung/hibernate/bootstrap/HibernateXMLBootstrapIntegrationTest.java @@ -1,26 +1,27 @@ package com.baeldung.hibernate.bootstrap; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import com.baeldung.hibernate.bootstrap.model.TestEntity; import org.hibernate.Session; import org.hibernate.SessionFactory; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.transaction.annotation.Transactional; -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { HibernateXMLConf.class }) @Transactional -public class HibernateXMLBootstrapIntegrationTest { +class HibernateXMLBootstrapIntegrationTest { @Autowired private SessionFactory sessionFactory; @Test - public void whenBootstrapHibernateSession_thenNoException() { + void whenBootstrapHibernateSession_thenNoException() { Session session = sessionFactory.getCurrentSession(); @@ -30,7 +31,7 @@ public class HibernateXMLBootstrapIntegrationTest { TestEntity searchEntity = session.find(TestEntity.class, 1); - Assert.assertNotNull(searchEntity); + assertNotNull(searchEntity); } } diff --git a/persistence-modules/spring-hibernate-6/src/test/java/com/baeldung/hibernate/dynamicupdate/DynamicUpdateIntegrationTest.java b/persistence-modules/spring-hibernate-6/src/test/java/com/baeldung/hibernate/dynamicupdate/DynamicUpdateIntegrationTest.java new file mode 100644 index 0000000000..9a52599842 --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/test/java/com/baeldung/hibernate/dynamicupdate/DynamicUpdateIntegrationTest.java @@ -0,0 +1,52 @@ +package com.baeldung.hibernate.dynamicupdate; + +import java.util.Optional; + +import jakarta.transaction.Transactional; + +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; +import org.junit.jupiter.api.extension.ExtendWith; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.Commit; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import com.baeldung.hibernate.dynamicupdate.model.Account; + +@ExtendWith(SpringExtension.class) +@ContextConfiguration(classes = { DynamicUpdateConfig.class }, loader = AnnotationConfigContextLoader.class) +@Transactional +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +class DynamicUpdateIntegrationTest { + + private static final Integer ACCOUNT_ID = 1; + + @Autowired + private AccountRepository accountRepository; + + @Test + @Commit + @Order(1) + void testA_whenTestAccountIsSaved_thenSuccess() { + Account account = new Account(ACCOUNT_ID, "account1", "regional", true); + accountRepository.save(account); + } + + @Test + @Commit + @Order(2) + // Enable Hibernate's debug logging in logback.xml to see the generated SQL statement. + void testB_whenAccountNameUpdated_thenSuccess() { + Optional account = accountRepository.findById(ACCOUNT_ID); + if(account.isPresent()){ + account.get().setName("Test Account"); + accountRepository.save(account.get()); + } + } + +} diff --git a/persistence-modules/spring-hibernate-6/src/test/java/com/baeldung/persistence/dao/common/HibernateDaoIntegrationTest.java b/persistence-modules/spring-hibernate-6/src/test/java/com/baeldung/persistence/dao/common/HibernateDaoIntegrationTest.java new file mode 100644 index 0000000000..d7069c62c9 --- /dev/null +++ b/persistence-modules/spring-hibernate-6/src/test/java/com/baeldung/persistence/dao/common/HibernateDaoIntegrationTest.java @@ -0,0 +1,46 @@ +package com.baeldung.persistence.dao.common; + +import com.baeldung.persistence.model.Foo; +import com.baeldung.spring.PersistenceConfig; +import org.apache.commons.lang3.RandomStringUtils; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.junit.jupiter.api.AfterEach; +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.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +@ExtendWith(SpringExtension.class) +@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) +class HibernateDaoIntegrationTest { + + @Autowired + private SessionFactory sessionFactory; + + private Session session; + + @BeforeEach + public final void before() { + session = sessionFactory.openSession(); + } + + @AfterEach + public final void after() { + session.close(); + } + + @Test + final void whenContextIsBootstrapped_thenNoExceptions() { + // + } + + @Test + final void whenPersistEntity_thenSuccess() { + session.persist(new Foo(RandomStringUtils.randomAlphabetic(5).toUpperCase())); + } + +} diff --git a/pom.xml b/pom.xml index c65f6ce62d..060f158888 100644 --- a/pom.xml +++ b/pom.xml @@ -816,6 +816,7 @@ apache-olingo apache-poi-2 + apache-poi-3 apache-thrift apache-tika @@ -1089,6 +1090,7 @@ apache-olingo apache-poi-2 + apache-poi-3 apache-thrift apache-tika diff --git a/quarkus-modules/quarkus/pom.xml b/quarkus-modules/quarkus/pom.xml index 99d18579c3..fc3d294beb 100644 --- a/quarkus-modules/quarkus/pom.xml +++ b/quarkus-modules/quarkus/pom.xml @@ -152,11 +152,8 @@ - native-image + image-build - - true - diff --git a/quarkus-modules/quarkus/src/test/java/com/baeldung/quarkus/NativeHelloResourceIT.java b/quarkus-modules/quarkus/src/test/java/com/baeldung/quarkus/NativeHelloResourceIT.java index e6c8a3b8fb..b8567a8609 100644 --- a/quarkus-modules/quarkus/src/test/java/com/baeldung/quarkus/NativeHelloResourceIT.java +++ b/quarkus-modules/quarkus/src/test/java/com/baeldung/quarkus/NativeHelloResourceIT.java @@ -2,9 +2,9 @@ package com.baeldung.quarkus; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.h2.H2DatabaseTestResource; -import io.quarkus.test.junit.NativeImageTest; +import io.quarkus.test.junit.QuarkusIntegrationTest; -@NativeImageTest +@QuarkusIntegrationTest @QuarkusTestResource(H2DatabaseTestResource.class) public class NativeHelloResourceIT extends HelloResourceUnitTest { diff --git a/quarkus-modules/quarkus/src/test/java/com/baeldung/quarkus/NativeLibraryResourceIT.java b/quarkus-modules/quarkus/src/test/java/com/baeldung/quarkus/NativeLibraryResourceIT.java index 0c11fa6fb4..10539d78d7 100644 --- a/quarkus-modules/quarkus/src/test/java/com/baeldung/quarkus/NativeLibraryResourceIT.java +++ b/quarkus-modules/quarkus/src/test/java/com/baeldung/quarkus/NativeLibraryResourceIT.java @@ -2,9 +2,9 @@ package com.baeldung.quarkus; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.h2.H2DatabaseTestResource; -import io.quarkus.test.junit.NativeImageTest; +import io.quarkus.test.junit.QuarkusIntegrationTest; -@NativeImageTest +@QuarkusIntegrationTest @QuarkusTestResource(H2DatabaseTestResource.class) class NativeLibraryResourceIT extends LibraryHttpEndpointIntegrationTest { } diff --git a/spring-aop-2/README.md b/spring-aop-2/README.md index a9694ac236..0aa20d32f0 100644 --- a/spring-aop-2/README.md +++ b/spring-aop-2/README.md @@ -7,4 +7,5 @@ This module contains articles about Spring aspect oriented programming (AOP) - [Spring Performance Logging](https://www.baeldung.com/spring-performance-logging) - [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) -- More articles: [[<-- prev]](/spring-aop) \ No newline at end of file +- [Invoke Spring @Cacheable from Another Method of Same Bean](https://www.baeldung.com/spring-invoke-cacheable-other-method-same-bean) +- More articles: [[<-- prev]](/spring-aop) diff --git a/spring-boot-modules/spring-boot-autoconfiguration/pom.xml b/spring-boot-modules/spring-boot-autoconfiguration/pom.xml index 7a3f9f01e8..7880a033f8 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/pom.xml +++ b/spring-boot-modules/spring-boot-autoconfiguration/pom.xml @@ -10,9 +10,10 @@ This is simple boot application demonstrating a custom auto-configuration - com.baeldung.spring-boot-modules - spring-boot-modules - 1.0.0-SNAPSHOT + com.baeldung + parent-boot-3 + 0.0.1-SNAPSHOT + ../../parent-boot-3 @@ -66,6 +67,13 @@ org.apache.maven.plugins maven-war-plugin + + org.springframework.boot + spring-boot-maven-plugin + + com.baeldung.autoconfiguration.example.AutoconfigurationApplication + + diff --git a/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/MySQLAutoconfiguration.java b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/MySQLAutoconfiguration.java index 295e0d74c9..c470656597 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/MySQLAutoconfiguration.java +++ b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/MySQLAutoconfiguration.java @@ -3,10 +3,10 @@ package com.baeldung.autoconfiguration; import java.util.Arrays; import java.util.Properties; -import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfigureOrder; import org.springframework.boot.autoconfigure.condition.ConditionMessage; import org.springframework.boot.autoconfigure.condition.ConditionMessage.Style; @@ -20,7 +20,6 @@ import org.springframework.boot.autoconfigure.condition.SpringBootCondition; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ConditionContext; import org.springframework.context.annotation.Conditional; -import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.core.Ordered; import org.springframework.core.env.Environment; @@ -31,7 +30,9 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.util.ClassUtils; -@Configuration +import jakarta.persistence.EntityManagerFactory; + +@AutoConfiguration @ConditionalOnClass(DataSource.class) @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) @PropertySource("classpath:mysql.properties") diff --git a/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/annotationprocessor/DatabaseProperties.java b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/annotationprocessor/DatabaseProperties.java index 4fb5b408a2..47f07c808f 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/annotationprocessor/DatabaseProperties.java +++ b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/annotationprocessor/DatabaseProperties.java @@ -1,11 +1,13 @@ package com.baeldung.autoconfiguration.annotationprocessor; -import javax.validation.constraints.Max; -import javax.validation.constraints.Min; + import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; + @Configuration @ConfigurationProperties(prefix = "database") public class DatabaseProperties { diff --git a/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/MyUser.java b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/MyUser.java index 31ce0fd969..26a2e04e2f 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/MyUser.java +++ b/spring-boot-modules/spring-boot-autoconfiguration/src/main/java/com/baeldung/autoconfiguration/example/MyUser.java @@ -1,7 +1,7 @@ package com.baeldung.autoconfiguration.example; -import javax.persistence.Entity; -import javax.persistence.Id; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; @Entity public class MyUser { diff --git a/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring.factories b/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring.factories index 11c775fc6c..e69de29bb2 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring.factories +++ b/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring.factories @@ -1 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.baeldung.autoconfiguration.MySQLAutoconfiguration diff --git a/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000000..ab28361814 --- /dev/null +++ b/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.baeldung.autoconfiguration.MySQLAutoconfiguration diff --git a/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/mysql.properties b/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/mysql.properties index 74f1ee1373..27092f852f 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/mysql.properties +++ b/spring-boot-modules/spring-boot-autoconfiguration/src/main/resources/mysql.properties @@ -1,5 +1,5 @@ usemysql=local -mysql-hibernate.dialect=org.hibernate.dialect.MySQL5Dialect +mysql-hibernate.dialect=org.hibernate.dialect.MySQLDialect mysql-hibernate.show_sql=true mysql-hibernate.hbm2ddl.auto=create-drop \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-aws/pom.xml b/spring-boot-modules/spring-boot-aws/pom.xml index 815766a846..460acae247 100644 --- a/spring-boot-modules/spring-boot-aws/pom.xml +++ b/spring-boot-modules/spring-boot-aws/pom.xml @@ -9,10 +9,11 @@ spring-boot-aws spring-boot-aws + - com.baeldung.spring-boot-modules - spring-boot-modules - 1.0.0-SNAPSHOT + org.springframework.boot + spring-boot-starter-parent + 2.7.11 diff --git a/spring-boot-modules/spring-boot-jasypt/pom.xml b/spring-boot-modules/spring-boot-jasypt/pom.xml index f48cd78595..70bbe35319 100644 --- a/spring-boot-modules/spring-boot-jasypt/pom.xml +++ b/spring-boot-modules/spring-boot-jasypt/pom.xml @@ -27,7 +27,7 @@ com.github.ulisesbocchio - jasypt-spring-boot-starter + jasypt-spring-boot-starter ${jasypt.version} @@ -46,15 +46,7 @@ - - - spring-milestone - Spring Milestone - https://repo.spring.io/milestone - - - - 2.0.0 + 3.0.5 \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/permitallanonymous/SecuredEcommerceApplication.java b/spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/permitallanonymous/SecuredEcommerceApplication.java new file mode 100644 index 0000000000..150fe399d1 --- /dev/null +++ b/spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/permitallanonymous/SecuredEcommerceApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.permitallanonymous; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan("com.baeldung.permitallanonymous.*") +public class SecuredEcommerceApplication { + public static void main(String[] args) { + SpringApplication.run(SecuredEcommerceApplication.class, args); + } +} diff --git a/spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/permitallanonymous/controller/EcommerceController.java b/spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/permitallanonymous/controller/EcommerceController.java new file mode 100644 index 0000000000..8f20baee10 --- /dev/null +++ b/spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/permitallanonymous/controller/EcommerceController.java @@ -0,0 +1,29 @@ +package com.baeldung.permitallanonymous.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class EcommerceController { + + //can be accessed by only logged-in users + @GetMapping("/private/showCart") + public @ResponseBody String showCart() { + return "Show Cart"; + } + + //can we accessed by both anonymous and authenticated users + @GetMapping("/public/showProducts") + public @ResponseBody String listProducts() { + return "List Products"; + } + + //can be access by only anonymous users not by authenticated users + @GetMapping("/public/registerUser") + public @ResponseBody String registerUser() { + return "Register User"; + } + +} + diff --git a/spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/permitallanonymous/filter/AuditInterceptor.java b/spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/permitallanonymous/filter/AuditInterceptor.java new file mode 100644 index 0000000000..c0a5f6972f --- /dev/null +++ b/spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/permitallanonymous/filter/AuditInterceptor.java @@ -0,0 +1,33 @@ +package com.baeldung.permitallanonymous.filter; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.security.authentication.AnonymousAuthenticationToken; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.web.filter.OncePerRequestFilter; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class AuditInterceptor extends OncePerRequestFilter { + private final Logger logger = LoggerFactory.getLogger(AuditInterceptor.class); + + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) + throws ServletException, IOException { + + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + if (authentication instanceof AnonymousAuthenticationToken) { + logger.info("Audit anonymous user"); + } + if (authentication instanceof UsernamePasswordAuthenticationToken) { + logger.info("Audit registered user"); + } + filterChain.doFilter(request, response); + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/permitallanonymous/security/EcommerceWebSecurityConfig.java b/spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/permitallanonymous/security/EcommerceWebSecurityConfig.java new file mode 100644 index 0000000000..566ec49e42 --- /dev/null +++ b/spring-boot-modules/spring-boot-security/src/main/java/com/baeldung/permitallanonymous/security/EcommerceWebSecurityConfig.java @@ -0,0 +1,46 @@ +package com.baeldung.permitallanonymous.security; + +import com.baeldung.permitallanonymous.filter.AuditInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.provisioning.InMemoryUserDetailsManager; +import org.springframework.security.web.SecurityFilterChain; +import org.springframework.security.web.authentication.AnonymousAuthenticationFilter; + +@Configuration +@EnableWebSecurity +public class EcommerceWebSecurityConfig { + @Bean + public InMemoryUserDetailsManager userDetailsService(PasswordEncoder passwordEncoder) { + UserDetails user = User.withUsername("spring") + .password(passwordEncoder.encode("secret")) + .roles("USER") + .build(); + + return new InMemoryUserDetailsManager(user); + } + + @Bean + public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { + http.addFilterAfter(new AuditInterceptor(), AnonymousAuthenticationFilter.class) + .authorizeRequests() + .antMatchers("/private/**").authenticated().and().httpBasic() + .and().authorizeRequests() + .antMatchers("/public/showProducts").permitAll() + .antMatchers("/public/registerUser").anonymous(); + + return http.build(); + } + + @Bean + public BCryptPasswordEncoder passwordEncoder() { + return new BCryptPasswordEncoder(); + } + +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-security/src/test/java/com/baeldung/permitallanonymous/SecureEcommerceApplicationUnitTest.java b/spring-boot-modules/spring-boot-security/src/test/java/com/baeldung/permitallanonymous/SecureEcommerceApplicationUnitTest.java new file mode 100644 index 0000000000..3c73caf1fd --- /dev/null +++ b/spring-boot-modules/spring-boot-security/src/test/java/com/baeldung/permitallanonymous/SecureEcommerceApplicationUnitTest.java @@ -0,0 +1,70 @@ +package com.baeldung.permitallanonymous; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.security.test.context.support.WithAnonymousUser; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.result.MockMvcResultMatchers; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SecuredEcommerceApplication.class) +@AutoConfigureMockMvc +public class SecureEcommerceApplicationUnitTest { + @Autowired + private MockMvc mockMvc; + private static final Logger logger = LoggerFactory.getLogger(SecureEcommerceApplicationUnitTest.class); + + @WithAnonymousUser + @Test + public void givenAnonymousUser_whenAccessToUserRegisterPage_thenAllowAccess() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/public/registerUser")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.content().string("Register User")); + } + + @WithMockUser(username = "spring", password = "secret") + @Test + public void givenAuthenticatedUser_whenAccessToUserRegisterPage_thenDenyAccess() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/public/registerUser")) + .andExpect(MockMvcResultMatchers.status().isForbidden()); + } + + @WithMockUser(username = "spring", password = "secret") + @Test + public void givenAuthenticatedUser_whenAccessToProductLinePage_thenAllowAccess() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/public/showProducts")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.content().string("List Products")); + } + + @WithAnonymousUser + @Test + public void givenAnonymousUser_whenAccessToProductLinePage_thenAllowAccess() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/public/showProducts")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.content().string("List Products")); + } + + @WithMockUser(username = "spring", password = "secret") + @Test + public void givenAuthenticatedUser_whenAccessToCartPage_thenAllowAccess() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/private/showCart")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andExpect(MockMvcResultMatchers.content().string("Show Cart")); + } + + @WithAnonymousUser + @Test + public void givenAnonymousUser_whenAccessToCartPage_thenDenyAccess() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/private/showCart")) + .andExpect(MockMvcResultMatchers.status().isUnauthorized()); + } +} diff --git a/spring-boot-modules/spring-boot-ssl-bundles/README.md b/spring-boot-modules/spring-boot-ssl-bundles/README.md new file mode 100644 index 0000000000..840cc21583 --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/README.md @@ -0,0 +1,2 @@ +## Relevant Articles +- [Securing Spring Boot 3 Applications With SSL Bundles](https://www.baeldung.com/spring-boot-security-ssl-bundles) diff --git a/spring-boot-modules/spring-boot-ssl-bundles/pom.xml b/spring-boot-modules/spring-boot-ssl-bundles/pom.xml new file mode 100644 index 0000000000..056d0308c2 --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.1.3 + + + springbootsslbundles + spring-boot-ssl-bundles + jar + Module for showing usage of SSL Bundles + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.security + spring-security-test + test + + + org.apache.httpcomponents.client5 + httpclient5-fluent + ${apache.client5.version} + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + 5.0.3 + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SSLBundlesApp.java b/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SSLBundlesApp.java new file mode 100644 index 0000000000..f6cfb35d1e --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SSLBundlesApp.java @@ -0,0 +1,19 @@ +package com.baeldung.springbootsslbundles; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.web.client.RestTemplate; +import org.springframework.boot.ssl.SslBundles; + +@SpringBootApplication +public class SSLBundlesApp { + public static void main(String[] args) { + SpringApplication.run(SSLBundlesApp.class, args); + } + @Bean + public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder, SslBundles sslBundles) { + return restTemplateBuilder.setSslBundle(sslBundles.getBundle("secure-service")).build(); + } +} diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SecureRestTemplateConfig.java b/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SecureRestTemplateConfig.java new file mode 100644 index 0000000000..48eda219dd --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SecureRestTemplateConfig.java @@ -0,0 +1,38 @@ +package com.baeldung.springbootsslbundles; + +import org.apache.hc.client5.http.classic.HttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.client5.http.io.HttpClientConnectionManager; +import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; +import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactoryBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ssl.NoSuchSslBundleException; +import org.springframework.boot.ssl.SslBundle; +import org.springframework.boot.ssl.SslBundles; +import org.springframework.context.annotation.Bean; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +import javax.net.ssl.SSLContext; + +@Component +public class SecureRestTemplateConfig { + private final SSLContext sslContext; + + @Autowired + public SecureRestTemplateConfig(SslBundles sslBundles) throws NoSuchSslBundleException { + SslBundle sslBundle = sslBundles.getBundle("secure-service"); + this.sslContext = sslBundle.createSslContext(); + } + + @Bean + public RestTemplate secureRestTemplate() { + final SSLConnectionSocketFactory sslSocketFactory = SSLConnectionSocketFactoryBuilder.create().setSslContext(this.sslContext).build(); + final HttpClientConnectionManager cm = PoolingHttpClientConnectionManagerBuilder.create().setSSLSocketFactory(sslSocketFactory).build(); + HttpClient httpClient = HttpClients.custom().setConnectionManager(cm).evictExpiredConnections().build(); + HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(httpClient); + return new RestTemplate(factory); + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SecureServiceRestApi.java b/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SecureServiceRestApi.java new file mode 100644 index 0000000000..3ed919b957 --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/src/main/java/com/baeldung/springbootsslbundles/SecureServiceRestApi.java @@ -0,0 +1,28 @@ +package com.baeldung.springbootsslbundles; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +@Service +public class SecureServiceRestApi { + private final RestTemplate restTemplate; + + @Autowired + public SecureServiceRestApi(RestTemplate restTemplate) { + this.restTemplate = restTemplate; + } + + public String fetchData(String dataId) { + ResponseEntity response = restTemplate.exchange( + "https://secure-service.com/api/data/{id}", + HttpMethod.GET, + null, + String.class, + dataId + ); + return response.getBody(); + } +} diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/application.yml b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/application.yml new file mode 100644 index 0000000000..1598645805 --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/application.yml @@ -0,0 +1,11 @@ +spring: + ssl: + bundle: + jks: + secure-service: + key: + alias: "secure-service" + keystore: + location: "classpath:keystore.p12" + password: "FooBar" + type: "PKCS12" \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/cert.pem b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/cert.pem new file mode 100644 index 0000000000..82ed122a80 --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/cert.pem @@ -0,0 +1,31 @@ +-----BEGIN CERTIFICATE----- +MIIFazCCA1OgAwIBAgIUCJcVMwyhLy/ln+ENMXbSWcsO0aswDQYJKoZIhvcNAQEL +BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM +GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAeFw0yMzA5MDUxNjAyMzdaFw0yNDA5 +MDQxNjAyMzdaMEUxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEw +HwYDVQQKDBhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQwggIiMA0GCSqGSIb3DQEB +AQUAA4ICDwAwggIKAoICAQDMNn+ZmPfR4FUyG6PVGBB2rOAnIHqFqYMVyDUOtZja +9CxpgbQjHRwwWaUWcYzLPOsvN/tMC8BazAFHSI2KIeNKgjAesv9JTumqgFXdOmw8 +KT7a9C1IQXnCMhlbp9J7c7CLvjAvZvZBghxFLc7xBZo9rWA67QMZoOhXvdMoKv4G +5v9qD1ZqIKlCxJQrdErVUKyZPztlIWNqzPy9BJzFlBea2ArfrASulqJuWGyO09+o +6ABNgUAicp/zfCOeKIe9cni0oZj6Buwk4eVdYESzVohBO52h95KtN17Y/Tw+U8W5 +Szq9tit6Vkupbe8tih7Bkdnj22WeCLVwWdXCp1kJw2kFDJTiC3wQRa6P0OrVpPGx +Z5SmG9eSCz22alA+I521ZG85hmPDt3BleYRYlCtcW7GFT/7zLBEwlN93lY5Os1jj +PRS8o5eIg8UhTbU4QEaZRYcLzaFy0asfKfa4ZF3mH5whh/w07SEEBAKDfQPpiz3T +migd+r9qUnPWeoE8Hi7lA1KzUd4YeM2yNHqXoQiARjHkM4yrX6vVlfT+itVbrpqF +a5J7PjL26w+DsxvRt9Ad5gpOdDzuy5m2V6lphMDjeZoG4OXgBzQQ1YxK1r6wkI4U +ZwRNrb+BxmQebQHnXKEXI7jgS45uoFENwolIHm9Dou5VYGLI0z+/pDReugCcw2lO +/QIDAQABo1MwUTAdBgNVHQ4EFgQUlSkON/OM9HCXeaQ7VWQuiEwY2iAwHwYDVR0j +BBgwFoAUlSkON/OM9HCXeaQ7VWQuiEwY2iAwDwYDVR0TAQH/BAUwAwEB/zANBgkq +hkiG9w0BAQsFAAOCAgEAD+8sPSQR3+A4F9z704OOy1Mo6bvbnIuK9UdN7d4/zh+e +AoloyTFPLPZIldg9hXwCvrKjrfqS5YUKmXIp9tetX7ns13CeDFcqVwZfPnqjzdNN +ad255LEwMjIUm9hSNEV6AQBKW8E+a590SrUamEdkFm4fcUB1LaINwyJjls7C0VB2 +JL50OloaUlv0IMnAPRVp0Adlt9xs69R2B8Q4i297FvHB1PI7VMLYqNnX2+tnvszO +HvWtIqm6foyReDLfC0n87cuEBV7/9304V5vgEj20TR19isd0LffJDD1ujDXvN8dS +uGOB1VLRxAPonr9Iqk358EJ1T22uEcMdKE+sMnCBjw2fYIYRfjhGN+m6U6sb4MrF +zFUI6qB7W7T/5iukiRb4pLQ0OGgKOwYxpZoxcB3Ldjo5x58uKNOTNJ5zEJ8HUofA +BNfty10D3m3DlSyYbf7m1UUM0jj2l83LBGQzhGGUZgCnCsMczLrj64Gvf2iLGmCF +gu5zrxL01dptBkvTsYJwYBA67BBS4FcgYNMGx3m1uPsVUUIguJxufXWYfbub74QV +a1SH1NjO8HR3DLDU+S92tyTKWOUzJ5qOegEsR2cutVRzDuVTsFy7kayuNv/uLRrG +3P2HnUo8PG/nmysReBk6CGycUiDTt55DoPYGoQ5l19xTlkIt7ulNg7yX5pwFMeE= +-----END CERTIFICATE----- diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/key.pem b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/key.pem new file mode 100644 index 0000000000..b4202e9a8e --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/key.pem @@ -0,0 +1,54 @@ +-----BEGIN ENCRYPTED PRIVATE KEY----- +MIIJpDBOBgkqhkiG9w0BBQ0wQTApBgkqhkiG9w0BBQwwHAQIblni8xi+83QCAggA +MAwGCCqGSIb3DQIJBQAwFAYIKoZIhvcNAwcECJSRFMcxzIKiBIIJUEqyZcVQEBL1 +6jkeo5TGxVwolLnCNpEuj8UwLoK5Z2N5oVwSPzD5rMYuPg6OXXWk6zReaaKBkRR2 +vlpkckA4o+aSXfzvEXYGd+rZ3EeIK43zquIBjymlcN++FbEYOtAY1SoQm7FtyvdN +4QW7MOONUJcnN3EgRSRic2CCa0k6NSREfrBWaa+OcYB4C/JEuA2xgkCUw8bCcos6 +mksoF6mZDQearirNankMDR7gLQt9pdK7S55T4sCrFpL072s3k7lV0WtvTE/CQ8Wu +pdBKVPvpvkR1S9n3ajGMWVYBjkRuD0MMn1eGMW6t3mRI8+C15zTp9DjzySJTMzUm +C3l/m9VQBFewuHLziJFylqy7kgxrUUe39FShHYkJZDprZSYE33Lz67o8oHpLkkIh +YccDm2bgqIbKfslbAIXD4BKq0QOUbi681XGRslZ7ZGduwNm3Xly0yuKmstzhnqQu +TLkBWcNeauYA7eeTTwAQq5My/xt+Ls72AwjOjP3kGSNCvmrLBP+4zpJayr+l+OYl +r5G6YNGE3p3QVY/Wn05OWeRE6eVqp1BXvgeLdqNyQXNpPITas0LDeVncexTNilNc +R788Le77m6grpxaX4xKbMKf1dtsRtPf+LvVNAdfVj9lQcEvi3ub0yjKGUhtRuxKi +STvVyJkJM7mV3FsUsYwsJZ2rBXbB2ifz6RCa8BDDwLGqZ54AZcK7OyvS6yRXf2ip +jZ2N09OIoN3WaTXytueqEPmiZ+M8Sirt9YLzNa74BrWsqyazUYMtib1exhp6EVPH +EVh+SlTdwQ//tPZNBx8TCB1s+bOHyzplXZ8JVg+AiuvZtyP20jS6oil2qvOcLR94 +e1hQaIPy6QXFFOTcDnmcTmUnaJKBvPFfqSVg58OeMb3RyQkZWvTkoxiE6PZwh3d1 +hqVzb+l91GDiLbYndGE1QrqBmxbGzM7PKqUr91cWBU8723CqGciWK+bjk4CxWx/F +yHX6nDwDgfuhPe90r7Xrjj9/61/xoaWhg25BZVOgn/e1akDK+8qjHxDhc/anE7xS +DIefhiukPuj/7oaxRIe/pKndztVub3W9EbyvHJArU+H6Ixy4qaulCXymp7Hqo/07 +4dUCVz2AGAIWqC0X6jUO8j2iHuOgbQg/oZFYOl8zn4q1ic1pFp/MJWaaWG9rAXPt +miT34Rv8lvJW9nqKAGuW8uRJ6xqyw8DcpmOMjFamPOZ8H66aOOsVJwTFmg3YlUAh +Cy3ITprdDbLPuX8MLJB7hJxKrqpXpnaY68x1MXAfp3tPkQ41u3Eif8riVY33+XEJ +9OZN8Xwnv+spej8CGmjiNP7WhvyjLJnzsTycXR3BE1TL9IzrKoebdiE1pVUv5tcL +lFCl5eatcxuU03JFQt+DjhcMBuM2AT2dfZ4WyHm2kKbOVTQA5snSFwpLt1ZS2G64 +7XCvx+zLbloqzRZkcKCr7hXgmpWLOECp2Wk98E2iHOHVkMINE5kB+iIXsg2Ii8pN +8UwIDF4VHF/c3hTESFrY3tVIYGauB9hqcBU4NDcZNRuRd6MSx9NZe55xzJ7uR4oV +Et0yNkmluk/EySpMrwLhe6t5I8vQEP9Ug00yobUuRob6rSp2pjkmRm2aPu4q042B +JFqGGwZWTXoa7+THIua9xWQh4Bmz7UZ6oO9rBll5pmoNO8SzaJwF1ZzE9RL2iFQW +px9u+85ee9+a6aQhvZjX0C/XYt0oHeoWpeoLTb97nGlZEv1GouHkjgNKLmcgz0Kd +WugrakcxJolplqfQmPaoPWGMT3ukXauyvSOFrG7eJKrzQSrv2GSqKsvHLgqvtqeL +cDjwESbSHRdGBvEz/L/XJfIba6jOI76GtbWFi9Co872V7SkNWHqOdwcEbb06phxH +1u+ZUy0caU8rLe9exLg1/VLkEDHPy4aSOkkcCkptWG/UwjGOa5HOMPzWDsayDeDT +7bFZlgl11ZZGoRAW+GZkHUCRglLqxKA1lSyK7Pv7cVXe6wniPbfMnyjZQZnRIk+q +UFr7hc2Buw1nISmRF6vx1jdwfA5A/ECNCCCHZ+XQhOO3xcKZeG6FGjr11oHK0H1g +aJve3tkrSYC4nXZfE7Lij5Cx+S1wTfZ8G+fGlSQa2jdsJUfRBy/TXkIorApbzFc1 +P1x05HXzSnMhLUWFYRqLWSVdBQua0w/CYyKEOPZUaFCRa67u1NLH0plA/j7h39ZA +1uTceFbjYQHTAObsNu5z/zaHd+xTc3WN9NFuXQKGxFdgs+duEZk1XZnD3V3DIlbJ +YobwhOiVLelUzBQZBYKEo2LJ71E0oOjIiq0TiCy5YsB9UGl9Un3jn50cKrq7IldF +MQLBl+ixbOLQ0KbVs7K1P7AegQwfgdmvG4jdjFx5Myq77GHgCgmtvngCYJjrF1Vo +OLxrKjk7dZ+Hmy60zPjgYkHyvOdZRUKfIhZrpCM5Al/xKUqhR6rPtr2U7lkHw9zT +gsK6rxXfvmJjIzSFBQzBah8K9rYzk/DScXMQ+3XY7fu6r2LTnfWxCKYhX/2eEoXW +/+t0HsRNoGCLB9g8sDAt2tDbjOsGRIdtfQ28Q56Pi91+IlGE5/n4iJ/bws5F1MXB +amG44iYYNPHUnkr3YsQeCiyh/1GgiLbIi3P6ZVJ5vG1a5oPGNolsABMZ5HZzd/aD +LgZDFjIMDzL5WaP2xhfnTjQsaowpulLE0/7mrc5KnfKxwdlDmLGjLIRsa5fXbL6W +rqezhAkgRrGRhnljMnCgZGpkHMtZN3S0u78/u17FvtlbyDFOev1y9cpvMmp/RAP3 +OXp7Wo3JELz/7aMkmVt6a++j9hxuX0vas6PPCoM0PGlTdWxPo2y96fFuW41j59vh +XY54kI5sBFibuvxLJOr9lXw8EuXJTNiyKuoEoXu2QKNHYSOZi1OPzrJRsKxEwNBh +8TP1G99H/gdlYEI/CPYOGbhWMq1qZyukDHjQaOMdzRIRYawx4GbQE1HeGla5bFSy +n0Gki5ApqQk8b6muUxDXBgPdQKFL6o7KYhAg+8JsGvnByh7qVZl2kmwxjx2bJIcj +o7BBRSYLSWdW3cguXojtgoN2NcFZZON4IEDSBuu/1ESgi2a2W5T9NClK/3ZagPmJ +hX2T2qTTkVjWQ+xM15SD46s4s+5nZX2kGE1DHwtYSKgdHYR9n81po7CuEqVP1n/G +7NNrMLXj3PGrZ2vzKDGSAU1LzLOUrJ4m +-----END ENCRYPTED PRIVATE KEY----- diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/keystore.p12 b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/keystore.p12 new file mode 100644 index 0000000000..f58b355467 Binary files /dev/null and b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/keystore.p12 differ diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/static/index.html b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/static/index.html new file mode 100644 index 0000000000..117910cc89 --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/src/main/resources/static/index.html @@ -0,0 +1,13 @@ + + + + + Spring SSL Bundler Demo Application + + +

Spring SSL Bundler Demo Application

+

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

+ + diff --git a/spring-boot-modules/spring-boot-ssl-bundles/src/test/java/com/baeldung/springbootsslbundles/SSLBundleApplicationTests.java b/spring-boot-modules/spring-boot-ssl-bundles/src/test/java/com/baeldung/springbootsslbundles/SSLBundleApplicationTests.java new file mode 100644 index 0000000000..876641c8b5 --- /dev/null +++ b/spring-boot-modules/spring-boot-ssl-bundles/src/test/java/com/baeldung/springbootsslbundles/SSLBundleApplicationTests.java @@ -0,0 +1,12 @@ +package com.baeldung.springbootsslbundles; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class SSLBundleApplicationTests { + @Test + void contextLoads() { + + } +} diff --git a/spring-cloud-modules/spring-cloud-kubernetes/kubernetes-guide/travel-agency-service/mongo-deployment.yaml b/spring-cloud-modules/spring-cloud-kubernetes/kubernetes-guide/travel-agency-service/mongo-deployment.yaml index 3d40581578..77a5efa13c 100644 --- a/spring-cloud-modules/spring-cloud-kubernetes/kubernetes-guide/travel-agency-service/mongo-deployment.yaml +++ b/spring-cloud-modules/spring-cloud-kubernetes/kubernetes-guide/travel-agency-service/mongo-deployment.yaml @@ -14,22 +14,24 @@ spec: selector: service: mongo --- -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: mongo spec: replicas: 1 + selector: + matchLabels: + name: mongodb-service template: metadata: labels: service: mongo - name: mongodb-service + name: mongodb-service spec: containers: - args: - mongod - - --smallfiles image: mongo:latest name: mongo env: diff --git a/spring-cloud-modules/spring-cloud-task/springcloudtaskbatch/src/main/resources/application.yml b/spring-cloud-modules/spring-cloud-task/springcloudtaskbatch/src/main/resources/application.yml index 71275793ec..b7cd3e7726 100644 --- a/spring-cloud-modules/spring-cloud-task/springcloudtaskbatch/src/main/resources/application.yml +++ b/spring-cloud-modules/spring-cloud-task/springcloudtaskbatch/src/main/resources/application.yml @@ -19,8 +19,4 @@ spring: hibernate: dialect: org.hibernate.dialect.MySQL5Dialect batch: - initialize-schema: always -maven: - remoteRepositories: - springRepo: - url: https://repo.spring.io/libs-snapshot \ No newline at end of file + initialize-schema: always \ No newline at end of file diff --git a/spring-cloud-modules/spring-cloud-task/springcloudtasksink/src/main/resources/application.properties b/spring-cloud-modules/spring-cloud-task/springcloudtasksink/src/main/resources/application.properties index 1660dc8516..e69de29bb2 100644 --- a/spring-cloud-modules/spring-cloud-task/springcloudtasksink/src/main/resources/application.properties +++ b/spring-cloud-modules/spring-cloud-task/springcloudtasksink/src/main/resources/application.properties @@ -1 +0,0 @@ -maven.remoteRepositories.springRepo.url=https://repo.spring.io/libs-snapshot \ No newline at end of file diff --git a/spring-reactive-modules/pom.xml b/spring-reactive-modules/pom.xml index e75682da78..efae864b46 100644 --- a/spring-reactive-modules/pom.xml +++ b/spring-reactive-modules/pom.xml @@ -17,17 +17,18 @@ - spring-5-data-reactive - spring-5-data-reactive-2 - spring-5-reactive - spring-5-reactive-2 - spring-5-reactive-3 - spring-5-reactive-client - spring-5-reactive-client-2 - spring-5-reactive-filters - spring-5-reactive-oauth - spring-5-reactive-security + spring-reactive-data + spring-reactive-data-2 spring-reactive + spring-reactive-2 + spring-reactive-3 + spring-reactive-client + spring-reactive-client-2 + spring-reactive-filters + spring-reactive-oauth + spring-reactive-security + spring-data-couchbase + spring-reactive-webflux spring-reactive-exceptions spring-reactor spring-webflux-amqp diff --git a/spring-reactive-modules/spring-5-reactive/README.md b/spring-reactive-modules/spring-5-reactive/README.md deleted file mode 100644 index f3148fe696..0000000000 --- a/spring-reactive-modules/spring-5-reactive/README.md +++ /dev/null @@ -1,14 +0,0 @@ -## Spring 5 Reactive Project - -This module contains articles about reactive Spring 5 - -### The Course -The "REST With Spring" Classes: https://bit.ly/restwithspring - -### Relevant Articles - -- [Exploring the Spring 5 WebFlux URL Matching](https://www.baeldung.com/spring-5-mvc-url-matching) -- [Reactive WebSockets with Spring 5](https://www.baeldung.com/spring-5-reactive-websockets) -- [How to Set a Header on a Response with Spring 5](https://www.baeldung.com/spring-response-header) -- [A Guide to Spring Session Reactive Support: WebSession](https://www.baeldung.com/spring-session-reactive) -- More articles: [[next -->]](../spring-5-reactive-2) diff --git a/spring-reactive-modules/spring-5-reactive/pom.xml b/spring-reactive-modules/spring-5-reactive/pom.xml deleted file mode 100644 index 212281b6f9..0000000000 --- a/spring-reactive-modules/spring-5-reactive/pom.xml +++ /dev/null @@ -1,165 +0,0 @@ - - - 4.0.0 - spring-5-reactive - 0.0.1-SNAPSHOT - spring-5-reactive - jar - spring 5 sample project about new features - - - com.baeldung.spring.reactive - spring-reactive-modules - 1.0.0-SNAPSHOT - - - - - org.springframework.boot - spring-boot-starter-validation - - - org.springframework.boot - spring-boot-starter-tomcat - - - org.springframework.boot - spring-boot-starter-integration - - - org.springframework.boot - spring-boot-starter-websocket - - - javax.json.bind - javax.json.bind-api - - - org.projectlombok - lombok - compile - - - org.apache.geronimo.specs - geronimo-json_1.1_spec - ${geronimo-json_1.1_spec.version} - - - org.apache.johnzon - johnzon-jsonb - - - - org.apache.commons - commons-lang3 - - - - org.springframework.boot - spring-boot-devtools - runtime - - - org.springframework - spring-test - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.security - spring-security-test - test - - - io.projectreactor - reactor-test - test - - - - org.springframework.boot - spring-boot-starter-webflux - - - org.springframework.boot - spring-boot-starter-data-redis - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.session - spring-session-core - - - org.springframework.session - spring-session-data-redis - - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - test - - - io.reactivex.rxjava2 - rxjava - - - org.apache.httpcomponents - httpclient - - - io.netty - netty-all - - - - - - - maven-resources-plugin - 3.0.1 - - - copy-resources - validate - - copy-resources - - - - - src/main/assets - true - - - ${basedir}/target/classes/assets - - - - - - org.springframework.boot - spring-boot-maven-plugin - - com.baeldung.reactive.Spring5ReactiveApplication - JAR - - - - - - - 1.1.3 - 1.0 - 1.0 - - - \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-data-reactive/README.md b/spring-reactive-modules/spring-data-couchbase/README.md similarity index 62% rename from spring-reactive-modules/spring-5-data-reactive/README.md rename to spring-reactive-modules/spring-data-couchbase/README.md index ecb6d01267..e38ef10562 100644 --- a/spring-reactive-modules/spring-5-data-reactive/README.md +++ b/spring-reactive-modules/spring-data-couchbase/README.md @@ -1,10 +1,9 @@ ## Spring Data Reactive Project -This module contains articles about reactive Spring 5 Data +This module contains articles about reactive Spring Data Couchbase ### The Course The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles -- [A Quick Look at R2DBC with Spring Data](https://www.baeldung.com/spring-data-r2dbc) - [Spring Data Reactive Repositories with Couchbase](https://www.baeldung.com/spring-data-reactive-couchbase) diff --git a/spring-reactive-modules/spring-5-data-reactive/pom.xml b/spring-reactive-modules/spring-data-couchbase/pom.xml similarity index 83% rename from spring-reactive-modules/spring-5-data-reactive/pom.xml rename to spring-reactive-modules/spring-data-couchbase/pom.xml index e4d3aeeddd..d7b36f97fa 100644 --- a/spring-reactive-modules/spring-5-data-reactive/pom.xml +++ b/spring-reactive-modules/spring-data-couchbase/pom.xml @@ -1,10 +1,10 @@ + 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 - spring-5-data-reactive - spring-5-data-reactive + spring-data-couchbase + spring-data-couchbase jar @@ -62,29 +62,11 @@ spring-boot-starter-test test
- - org.springframework.boot - spring-boot-starter-webflux - org.springframework spring-tx ${spring-tx.version} - - org.springframework.data - spring-data-r2dbc - ${spring-data-r2dbc.version} - - - io.r2dbc - r2dbc-h2 - ${r2dbc-h2.version} - - - com.h2database - h2 - org.apache.httpcomponents httpclient @@ -152,8 +134,6 @@ 5.2.2.RELEASE - 1.0.0.RELEASE - 0.8.1.RELEASE 4.5.2 1.5.23 3.3.1.RELEASE diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/ReactiveCouchbaseApplication.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/ReactiveCouchbaseApplication.java similarity index 99% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/ReactiveCouchbaseApplication.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/ReactiveCouchbaseApplication.java index 4e5bf9d5dc..0ca7c9a8d1 100644 --- a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/ReactiveCouchbaseApplication.java +++ b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/ReactiveCouchbaseApplication.java @@ -10,4 +10,4 @@ public class ReactiveCouchbaseApplication { public static void main(String[] args) { SpringApplication.run(ReactiveCouchbaseApplication.class, args); } -} +} \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/CouchbaseProperties.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/CouchbaseProperties.java similarity index 99% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/CouchbaseProperties.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/CouchbaseProperties.java index 81f19eebd6..cc9540eecb 100644 --- a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/CouchbaseProperties.java +++ b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/CouchbaseProperties.java @@ -40,4 +40,4 @@ public class CouchbaseProperties { public int getPort() { return port; } -} +} \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/N1QLReactiveCouchbaseConfiguration.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/N1QLReactiveCouchbaseConfiguration.java similarity index 99% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/N1QLReactiveCouchbaseConfiguration.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/N1QLReactiveCouchbaseConfiguration.java index 059bd36cae..7ba12db2c6 100644 --- a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/N1QLReactiveCouchbaseConfiguration.java +++ b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/N1QLReactiveCouchbaseConfiguration.java @@ -12,4 +12,4 @@ public class N1QLReactiveCouchbaseConfiguration extends ReactiveCouchbaseConfigu public N1QLReactiveCouchbaseConfiguration(CouchbaseProperties couchbaseProperties) { super(couchbaseProperties); } -} +} \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/ReactiveCouchbaseConfiguration.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/ReactiveCouchbaseConfiguration.java similarity index 99% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/ReactiveCouchbaseConfiguration.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/ReactiveCouchbaseConfiguration.java index a51b19ee22..1816082f7c 100644 --- a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/ReactiveCouchbaseConfiguration.java +++ b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/ReactiveCouchbaseConfiguration.java @@ -45,4 +45,4 @@ public abstract class ReactiveCouchbaseConfiguration extends AbstractReactiveCou public IndexManager couchbaseIndexManager() { return new IndexManager(true, true, false); } -} +} \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/ViewReactiveCouchbaseConfiguration.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/ViewReactiveCouchbaseConfiguration.java similarity index 99% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/ViewReactiveCouchbaseConfiguration.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/ViewReactiveCouchbaseConfiguration.java index 9b4d9b0319..578a03ae19 100644 --- a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/configuration/ViewReactiveCouchbaseConfiguration.java +++ b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/configuration/ViewReactiveCouchbaseConfiguration.java @@ -10,4 +10,4 @@ public class ViewReactiveCouchbaseConfiguration extends ReactiveCouchbaseConfigu public ViewReactiveCouchbaseConfiguration(CouchbaseProperties couchbaseProperties) { super(couchbaseProperties); } -} +} \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/Person.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/Person.java similarity index 99% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/Person.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/Person.java index 285de34df8..5a1b1eec18 100644 --- a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/Person.java +++ b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/Person.java @@ -40,4 +40,4 @@ public class Person { public int hashCode() { return Objects.hash(id, firstName); } -} +} \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepository.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepository.java similarity index 99% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepository.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepository.java index 6f73a77ceb..e78316e218 100644 --- a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepository.java +++ b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepository.java @@ -13,4 +13,4 @@ import java.util.UUID; public interface N1QLPersonRepository extends ReactiveCrudRepository { Flux findAllByFirstName(final String firstName); -} +} \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepository.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepository.java similarity index 99% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepository.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepository.java index 57dd149425..1225ed914a 100644 --- a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepository.java +++ b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepository.java @@ -10,4 +10,4 @@ import java.util.UUID; @Repository @N1qlPrimaryIndexed public interface N1QLSortingPersonRepository extends ReactiveSortingRepository { -} +} \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepository.java b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepository.java similarity index 99% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepository.java rename to spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepository.java index 06c47c2393..4b3f0a7f1c 100644 --- a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepository.java +++ b/spring-reactive-modules/spring-data-couchbase/src/main/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepository.java @@ -17,4 +17,4 @@ public interface ViewPersonRepository extends ReactiveCrudRepository findByFirstName(String firstName); -} +} \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/resources/couchbase.properties b/spring-reactive-modules/spring-data-couchbase/src/main/resources/couchbase.properties similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/main/resources/couchbase.properties rename to spring-reactive-modules/spring-data-couchbase/src/main/resources/couchbase.properties diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/resources/logback.xml b/spring-reactive-modules/spring-data-couchbase/src/main/resources/logback.xml similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/main/resources/logback.xml rename to spring-reactive-modules/spring-data-couchbase/src/main/resources/logback.xml diff --git a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/CouchbaseMockConfiguration.java b/spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/CouchbaseMockConfiguration.java similarity index 99% rename from spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/CouchbaseMockConfiguration.java rename to spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/CouchbaseMockConfiguration.java index 2a09fce4b0..082ad5061b 100644 --- a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/CouchbaseMockConfiguration.java +++ b/spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/CouchbaseMockConfiguration.java @@ -1,16 +1,18 @@ package com.baeldung.couchbase.domain.repository; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.util.Collections; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; + +import org.springframework.boot.test.context.TestConfiguration; + import com.baeldung.couchbase.configuration.CouchbaseProperties; import com.couchbase.mock.Bucket; import com.couchbase.mock.BucketConfiguration; import com.couchbase.mock.CouchbaseMock; -import org.springframework.boot.test.context.TestConfiguration; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.Collections; @TestConfiguration public class CouchbaseMockConfiguration { diff --git a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepositoryLiveTest.java b/spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepositoryLiveTest.java similarity index 96% rename from spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepositoryLiveTest.java rename to spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepositoryLiveTest.java index c8dbbf429e..51bca948c0 100644 --- a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepositoryLiveTest.java +++ b/spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLPersonRepositoryLiveTest.java @@ -1,16 +1,19 @@ package com.baeldung.couchbase.domain.repository.n1ql; -import com.baeldung.couchbase.domain.Person; +import java.util.UUID; + 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 com.baeldung.couchbase.domain.Person; +import com.baeldung.couchbase.domain.repository.n1ql.N1QLPersonRepository; + import reactor.core.publisher.Flux; import reactor.test.StepVerifier; -import java.util.UUID; - @RunWith(SpringRunner.class) @SpringBootTest(properties = {"spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration"}) public class N1QLPersonRepositoryLiveTest { diff --git a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepositoryLiveTest.java b/spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepositoryLiveTest.java similarity index 96% rename from spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepositoryLiveTest.java rename to spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepositoryLiveTest.java index 8c6ce137f1..dbc353a94b 100644 --- a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepositoryLiveTest.java +++ b/spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/n1ql/N1QLSortingPersonRepositoryLiveTest.java @@ -1,17 +1,20 @@ package com.baeldung.couchbase.domain.repository.n1ql; -import com.baeldung.couchbase.domain.Person; +import java.util.UUID; + import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.data.domain.Sort; import org.springframework.test.context.junit4.SpringRunner; + +import com.baeldung.couchbase.domain.Person; +import com.baeldung.couchbase.domain.repository.n1ql.N1QLSortingPersonRepository; + import reactor.core.publisher.Flux; import reactor.test.StepVerifier; -import java.util.UUID; - @RunWith(SpringRunner.class) @SpringBootTest(properties = {"spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration"}) public class N1QLSortingPersonRepositoryLiveTest { diff --git a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepositoryIntegrationTest.java b/spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepositoryIntegrationTest.java similarity index 97% rename from spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepositoryIntegrationTest.java rename to spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepositoryIntegrationTest.java index 15688e1b80..038d4dec31 100644 --- a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepositoryIntegrationTest.java +++ b/spring-reactive-modules/spring-data-couchbase/src/test/java/com/baeldung/couchbase/domain/repository/view/ViewPersonRepositoryIntegrationTest.java @@ -1,21 +1,22 @@ package com.baeldung.couchbase.domain.repository.view; +import java.util.UUID; + +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 com.baeldung.couchbase.configuration.CouchbaseProperties; import com.baeldung.couchbase.configuration.ViewReactiveCouchbaseConfiguration; import com.baeldung.couchbase.domain.Person; import com.baeldung.couchbase.domain.repository.CouchbaseMockConfiguration; -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.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; + import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; -import java.util.UUID; - @RunWith(SpringRunner.class) @SpringBootTest(properties = { "spring.couchbase.port=10010", "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration,org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration" }, classes = { CouchbaseMockConfiguration.class, ViewReactiveCouchbaseConfiguration.class, CouchbaseProperties.class }) diff --git a/spring-reactive-modules/spring-5-reactive-2/.gitignore b/spring-reactive-modules/spring-reactive-2/.gitignore similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/.gitignore rename to spring-reactive-modules/spring-reactive-2/.gitignore diff --git a/spring-reactive-modules/spring-5-reactive-2/README.md b/spring-reactive-modules/spring-reactive-2/README.md similarity index 91% rename from spring-reactive-modules/spring-5-reactive-2/README.md rename to spring-reactive-modules/spring-reactive-2/README.md index 1cd3bf46c6..a5df5187bf 100644 --- a/spring-reactive-modules/spring-5-reactive-2/README.md +++ b/spring-reactive-modules/spring-reactive-2/README.md @@ -1,6 +1,6 @@ ## Spring 5 Reactive Project -This module contains articles about reactive Spring 5. +This module contains articles about reactive Spring Boot. - [Validation for Functional Endpoints in Spring 5](https://www.baeldung.com/spring-functional-endpoints-validation) - [Testing Reactive Streams Using StepVerifier and TestPublisher](https://www.baeldung.com/reactive-streams-step-verifier-test-publisher) diff --git a/spring-reactive-modules/spring-5-reactive-2/pom.xml b/spring-reactive-modules/spring-reactive-2/pom.xml similarity index 98% rename from spring-reactive-modules/spring-5-reactive-2/pom.xml rename to spring-reactive-modules/spring-reactive-2/pom.xml index 41c434fb92..ba40f3b48a 100644 --- a/spring-reactive-modules/spring-5-reactive-2/pom.xml +++ b/spring-reactive-modules/spring-reactive-2/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - spring-5-reactive-2 + spring-reactive-2 0.0.1-SNAPSHOT spring-5-reactive-2 jar diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/reactive/serversentevents/consumer/ConsumerSSEApplication.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/reactive/serversentevents/consumer/ConsumerSSEApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/reactive/serversentevents/consumer/ConsumerSSEApplication.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/reactive/serversentevents/consumer/ConsumerSSEApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/reactive/serversentevents/consumer/controller/ClientController.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/reactive/serversentevents/consumer/controller/ClientController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/reactive/serversentevents/consumer/controller/ClientController.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/reactive/serversentevents/consumer/controller/ClientController.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/reactive/serversentevents/server/ServerSSEApplication.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/reactive/serversentevents/server/ServerSSEApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/reactive/serversentevents/server/ServerSSEApplication.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/reactive/serversentevents/server/ServerSSEApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/reactive/serversentevents/server/controllers/ServerController.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/reactive/serversentevents/server/controllers/ServerController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/reactive/serversentevents/server/controllers/ServerController.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/reactive/serversentevents/server/controllers/ServerController.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/staticcontent/StaticContentApplication.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/staticcontent/StaticContentApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/staticcontent/StaticContentApplication.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/staticcontent/StaticContentApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/staticcontent/StaticContentConfig.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/staticcontent/StaticContentConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/staticcontent/StaticContentConfig.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/staticcontent/StaticContentConfig.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/FunctionalValidationsApplication.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/FunctionalValidationsApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/FunctionalValidationsApplication.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/FunctionalValidationsApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/AbstractValidationHandler.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/AbstractValidationHandler.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/AbstractValidationHandler.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/AbstractValidationHandler.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/FunctionalHandler.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/FunctionalHandler.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/FunctionalHandler.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/FunctionalHandler.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/AnnotatedRequestEntityValidationHandler.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/AnnotatedRequestEntityValidationHandler.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/AnnotatedRequestEntityValidationHandler.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/AnnotatedRequestEntityValidationHandler.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/CustomRequestEntityValidationHandler.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/CustomRequestEntityValidationHandler.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/CustomRequestEntityValidationHandler.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/CustomRequestEntityValidationHandler.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/OtherEntityValidationHandler.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/OtherEntityValidationHandler.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/OtherEntityValidationHandler.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/handlers/impl/OtherEntityValidationHandler.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/model/AnnotatedRequestEntity.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/model/AnnotatedRequestEntity.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/model/AnnotatedRequestEntity.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/model/AnnotatedRequestEntity.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/model/CustomRequestEntity.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/model/CustomRequestEntity.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/model/CustomRequestEntity.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/model/CustomRequestEntity.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/model/OtherEntity.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/model/OtherEntity.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/model/OtherEntity.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/model/OtherEntity.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/routers/ValidationsRouters.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/routers/ValidationsRouters.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/routers/ValidationsRouters.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/routers/ValidationsRouters.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/validators/CustomRequestEntityValidator.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/validators/CustomRequestEntityValidator.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/validators/CustomRequestEntityValidator.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/validators/CustomRequestEntityValidator.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/validators/OtherEntityValidator.java b/spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/validators/OtherEntityValidator.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/java/com/baeldung/validations/functional/validators/OtherEntityValidator.java rename to spring-reactive-modules/spring-reactive-2/src/main/java/com/baeldung/validations/functional/validators/OtherEntityValidator.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/main/resources/application-assets-custom-location.properties b/spring-reactive-modules/spring-reactive-2/src/main/resources/application-assets-custom-location.properties similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/main/resources/application-assets-custom-location.properties rename to spring-reactive-modules/spring-reactive-2/src/main/resources/application-assets-custom-location.properties diff --git a/spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/backpressure/BackpressureUnitTest.java b/spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/backpressure/BackpressureUnitTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/backpressure/BackpressureUnitTest.java rename to spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/backpressure/BackpressureUnitTest.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/reactive/serversentsevents/ServiceSentEventLiveTest.java b/spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/reactive/serversentsevents/ServiceSentEventLiveTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/reactive/serversentsevents/ServiceSentEventLiveTest.java rename to spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/reactive/serversentsevents/ServiceSentEventLiveTest.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/staticcontent/StaticContentCustomLocationIntegrationTest.java b/spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/staticcontent/StaticContentCustomLocationIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/staticcontent/StaticContentCustomLocationIntegrationTest.java rename to spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/staticcontent/StaticContentCustomLocationIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/staticcontent/StaticContentDefaultLocationIntegrationTest.java b/spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/staticcontent/StaticContentDefaultLocationIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/staticcontent/StaticContentDefaultLocationIntegrationTest.java rename to spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/staticcontent/StaticContentDefaultLocationIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/stepverifier/PostExecutionUnitTest.java b/spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/stepverifier/PostExecutionUnitTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/stepverifier/PostExecutionUnitTest.java rename to spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/stepverifier/PostExecutionUnitTest.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/stepverifier/StepByStepUnitTest.java b/spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/stepverifier/StepByStepUnitTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/stepverifier/StepByStepUnitTest.java rename to spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/stepverifier/StepByStepUnitTest.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/stepverifier/TestingTestPublisherUnitTest.java b/spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/stepverifier/TestingTestPublisherUnitTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/stepverifier/TestingTestPublisherUnitTest.java rename to spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/stepverifier/TestingTestPublisherUnitTest.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/stepverifier/TimeBasedUnitTest.java b/spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/stepverifier/TimeBasedUnitTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/stepverifier/TimeBasedUnitTest.java rename to spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/stepverifier/TimeBasedUnitTest.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/validations/functional/FunctionalEndpointValidationsLiveTest.java b/spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/validations/functional/FunctionalEndpointValidationsLiveTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/test/java/com/baeldung/validations/functional/FunctionalEndpointValidationsLiveTest.java rename to spring-reactive-modules/spring-reactive-2/src/test/java/com/baeldung/validations/functional/FunctionalEndpointValidationsLiveTest.java diff --git a/spring-reactive-modules/spring-5-reactive-2/src/test/resources/assets/index.html b/spring-reactive-modules/spring-reactive-2/src/test/resources/assets/index.html similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/test/resources/assets/index.html rename to spring-reactive-modules/spring-reactive-2/src/test/resources/assets/index.html diff --git a/spring-reactive-modules/spring-5-reactive-2/src/test/resources/img/example-image.png b/spring-reactive-modules/spring-reactive-2/src/test/resources/img/example-image.png similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/test/resources/img/example-image.png rename to spring-reactive-modules/spring-reactive-2/src/test/resources/img/example-image.png diff --git a/spring-reactive-modules/spring-5-reactive-2/src/test/resources/logback-test.xml b/spring-reactive-modules/spring-reactive-2/src/test/resources/logback-test.xml similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/test/resources/logback-test.xml rename to spring-reactive-modules/spring-reactive-2/src/test/resources/logback-test.xml diff --git a/spring-reactive-modules/spring-5-reactive-2/src/test/resources/public/index.html b/spring-reactive-modules/spring-reactive-2/src/test/resources/public/index.html similarity index 100% rename from spring-reactive-modules/spring-5-reactive-2/src/test/resources/public/index.html rename to spring-reactive-modules/spring-reactive-2/src/test/resources/public/index.html diff --git a/spring-reactive-modules/spring-5-reactive-3/.gitignore b/spring-reactive-modules/spring-reactive-3/.gitignore similarity index 100% rename from spring-reactive-modules/spring-5-reactive-3/.gitignore rename to spring-reactive-modules/spring-reactive-3/.gitignore diff --git a/spring-reactive-modules/spring-5-reactive-3/README.md b/spring-reactive-modules/spring-reactive-3/README.md similarity index 72% rename from spring-reactive-modules/spring-5-reactive-3/README.md rename to spring-reactive-modules/spring-reactive-3/README.md index 38036f929b..640a60d63d 100644 --- a/spring-reactive-modules/spring-5-reactive-3/README.md +++ b/spring-reactive-modules/spring-reactive-3/README.md @@ -1,9 +1,8 @@ ## Spring 5 Reactive Project -This module contains articles about reactive Spring 5. +This module contains articles about reactive Spring Boot. - [Logging a Reactive Sequence](https://www.baeldung.com/spring-reactive-sequence-logging) - [Reading Flux Into a Single InputStream Using Spring Reactive WebClient](https://www.baeldung.com/spring-reactive-read-flux-into-inputstream) -- [Spring Boot FeignClient vs. WebClient](https://www.baeldung.com/spring-boot-feignclient-vs-webclient) - [Cancel an Ongoing Flux in Spring WebFlux](https://www.baeldung.com/spring-webflux-cancel-flux) - More articles: [[<-- prev]](../spring-5-reactive-2) diff --git a/spring-reactive-modules/spring-5-reactive-3/pom.xml b/spring-reactive-modules/spring-reactive-3/pom.xml similarity index 98% rename from spring-reactive-modules/spring-5-reactive-3/pom.xml rename to spring-reactive-modules/spring-reactive-3/pom.xml index d33b63e921..7672fa29f3 100644 --- a/spring-reactive-modules/spring-5-reactive-3/pom.xml +++ b/spring-reactive-modules/spring-reactive-3/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - spring-5-reactive-3 + spring-reactive-3 0.0.1-SNAPSHOT spring-5-reactive-3 jar diff --git a/spring-reactive-modules/spring-5-reactive-3/src/main/java/com/baeldung/databuffer/DataBufferToInputStream.java b/spring-reactive-modules/spring-reactive-3/src/main/java/com/baeldung/databuffer/DataBufferToInputStream.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-3/src/main/java/com/baeldung/databuffer/DataBufferToInputStream.java rename to spring-reactive-modules/spring-reactive-3/src/main/java/com/baeldung/databuffer/DataBufferToInputStream.java diff --git a/spring-reactive-modules/spring-5-reactive-3/src/main/java/com/baeldung/webflux/logging/WebFluxLoggingExample.java b/spring-reactive-modules/spring-reactive-3/src/main/java/com/baeldung/webflux/logging/WebFluxLoggingExample.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-3/src/main/java/com/baeldung/webflux/logging/WebFluxLoggingExample.java rename to spring-reactive-modules/spring-reactive-3/src/main/java/com/baeldung/webflux/logging/WebFluxLoggingExample.java diff --git a/spring-reactive-modules/spring-5-reactive-3/src/main/resources/application.properties b/spring-reactive-modules/spring-reactive-3/src/main/resources/application.properties similarity index 100% rename from spring-reactive-modules/spring-5-reactive-3/src/main/resources/application.properties rename to spring-reactive-modules/spring-reactive-3/src/main/resources/application.properties diff --git a/spring-reactive-modules/spring-5-reactive-3/src/test/java/com/baeldung/cancelflux/CancelFluxUnitTest.java b/spring-reactive-modules/spring-reactive-3/src/test/java/com/baeldung/cancelflux/CancelFluxUnitTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-3/src/test/java/com/baeldung/cancelflux/CancelFluxUnitTest.java rename to spring-reactive-modules/spring-reactive-3/src/test/java/com/baeldung/cancelflux/CancelFluxUnitTest.java diff --git a/spring-reactive-modules/spring-5-reactive-3/src/test/java/com/baeldung/databuffer/DataBufferToInputStreamUnitTest.java b/spring-reactive-modules/spring-reactive-3/src/test/java/com/baeldung/databuffer/DataBufferToInputStreamUnitTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-3/src/test/java/com/baeldung/databuffer/DataBufferToInputStreamUnitTest.java rename to spring-reactive-modules/spring-reactive-3/src/test/java/com/baeldung/databuffer/DataBufferToInputStreamUnitTest.java diff --git a/spring-reactive-modules/spring-5-reactive-3/src/test/resources/logback-test.xml b/spring-reactive-modules/spring-reactive-3/src/test/resources/logback-test.xml similarity index 100% rename from spring-reactive-modules/spring-5-reactive-3/src/test/resources/logback-test.xml rename to spring-reactive-modules/spring-reactive-3/src/test/resources/logback-test.xml diff --git a/spring-reactive-modules/spring-5-reactive-3/src/test/resources/user-response.json b/spring-reactive-modules/spring-reactive-3/src/test/resources/user-response.json similarity index 100% rename from spring-reactive-modules/spring-5-reactive-3/src/test/resources/user-response.json rename to spring-reactive-modules/spring-reactive-3/src/test/resources/user-response.json diff --git a/spring-reactive-modules/spring-5-reactive-client-2/README.md b/spring-reactive-modules/spring-reactive-client-2/README.md similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/README.md rename to spring-reactive-modules/spring-reactive-client-2/README.md diff --git a/spring-reactive-modules/spring-5-reactive-client-2/pom.xml b/spring-reactive-modules/spring-reactive-client-2/pom.xml similarity index 94% rename from spring-reactive-modules/spring-5-reactive-client-2/pom.xml rename to spring-reactive-modules/spring-reactive-client-2/pom.xml index e86134badc..5d5f3ebc2e 100644 --- a/spring-reactive-modules/spring-5-reactive-client-2/pom.xml +++ b/spring-reactive-modules/spring-reactive-client-2/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"> 4.0.0 - spring-5-reactive-client-2 - spring-5-reactive-client-2 + spring-reactive-client-2 + spring-reactive-client-2 jar - spring 5 sample project about new features + spring boot sample project about new features com.baeldung.spring.reactive @@ -93,10 +93,6 @@ org.apache.maven.plugins maven-compiler-plugin - - 1.8 - 1.8 - diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/LimitRequestsApp.java b/spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/LimitRequestsApp.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/LimitRequestsApp.java rename to spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/LimitRequestsApp.java diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/DelayElements.java b/spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/DelayElements.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/DelayElements.java rename to spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/DelayElements.java diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/GuavaRateLimit.java b/spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/GuavaRateLimit.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/GuavaRateLimit.java rename to spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/GuavaRateLimit.java diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/LimitConcurrency.java b/spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/LimitConcurrency.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/LimitConcurrency.java rename to spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/LimitConcurrency.java diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/Resilience4jRateLimit.java b/spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/Resilience4jRateLimit.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/Resilience4jRateLimit.java rename to spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/Resilience4jRateLimit.java diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/ZipWithInterval.java b/spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/ZipWithInterval.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/ZipWithInterval.java rename to spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/ZipWithInterval.java diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/utils/Client.java b/spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/utils/Client.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/utils/Client.java rename to spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/utils/Client.java diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/utils/RandomConsumer.java b/spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/utils/RandomConsumer.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/utils/RandomConsumer.java rename to spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/client/utils/RandomConsumer.java diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/server/Concurrency.java b/spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/server/Concurrency.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/server/Concurrency.java rename to spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/server/Concurrency.java diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/server/RandomController.java b/spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/server/RandomController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/limitrequests/server/RandomController.java rename to spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/limitrequests/server/RandomController.java diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/streamlargefile/StreamLargeFileApp.java b/spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/streamlargefile/StreamLargeFileApp.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/streamlargefile/StreamLargeFileApp.java rename to spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/streamlargefile/StreamLargeFileApp.java diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/streamlargefile/client/LargeFileDownloadWebClient.java b/spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/streamlargefile/client/LargeFileDownloadWebClient.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/streamlargefile/client/LargeFileDownloadWebClient.java rename to spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/streamlargefile/client/LargeFileDownloadWebClient.java diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/streamlargefile/client/LimitedFileDownloadWebClient.java b/spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/streamlargefile/client/LimitedFileDownloadWebClient.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/streamlargefile/client/LimitedFileDownloadWebClient.java rename to spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/streamlargefile/client/LimitedFileDownloadWebClient.java diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/streamlargefile/server/LargeFileController.java b/spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/streamlargefile/server/LargeFileController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/java/com/baeldung/streamlargefile/server/LargeFileController.java rename to spring-reactive-modules/spring-reactive-client-2/src/main/java/com/baeldung/streamlargefile/server/LargeFileController.java diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/resources/application.properties b/spring-reactive-modules/spring-reactive-client-2/src/main/resources/application.properties similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/resources/application.properties rename to spring-reactive-modules/spring-reactive-client-2/src/main/resources/application.properties diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/resources/logback.xml b/spring-reactive-modules/spring-reactive-client-2/src/main/resources/logback.xml similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/resources/logback.xml rename to spring-reactive-modules/spring-reactive-client-2/src/main/resources/logback.xml diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/resources/streamlargefile/generate-sample-files.sh b/spring-reactive-modules/spring-reactive-client-2/src/main/resources/streamlargefile/generate-sample-files.sh old mode 100755 new mode 100644 similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/resources/streamlargefile/generate-sample-files.sh rename to spring-reactive-modules/spring-reactive-client-2/src/main/resources/streamlargefile/generate-sample-files.sh diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/main/resources/streamlargefile/run.sh b/spring-reactive-modules/spring-reactive-client-2/src/main/resources/streamlargefile/run.sh old mode 100755 new mode 100644 similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/main/resources/streamlargefile/run.sh rename to spring-reactive-modules/spring-reactive-client-2/src/main/resources/streamlargefile/run.sh diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/test/java/com/baeldung/limitrequests/RandomControllerLiveTest.java b/spring-reactive-modules/spring-reactive-client-2/src/test/java/com/baeldung/limitrequests/RandomControllerLiveTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/test/java/com/baeldung/limitrequests/RandomControllerLiveTest.java rename to spring-reactive-modules/spring-reactive-client-2/src/test/java/com/baeldung/limitrequests/RandomControllerLiveTest.java diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/test/java/com/baeldung/streamlargefile/LargeFileControllerLiveTest.java b/spring-reactive-modules/spring-reactive-client-2/src/test/java/com/baeldung/streamlargefile/LargeFileControllerLiveTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/test/java/com/baeldung/streamlargefile/LargeFileControllerLiveTest.java rename to spring-reactive-modules/spring-reactive-client-2/src/test/java/com/baeldung/streamlargefile/LargeFileControllerLiveTest.java diff --git a/spring-reactive-modules/spring-5-reactive-client-2/src/test/resources/logback-test.xml b/spring-reactive-modules/spring-reactive-client-2/src/test/resources/logback-test.xml similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client-2/src/test/resources/logback-test.xml rename to spring-reactive-modules/spring-reactive-client-2/src/test/resources/logback-test.xml diff --git a/spring-reactive-modules/spring-5-reactive-client/.gitignore b/spring-reactive-modules/spring-reactive-client/.gitignore similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/.gitignore rename to spring-reactive-modules/spring-reactive-client/.gitignore diff --git a/spring-reactive-modules/spring-5-reactive-client/README.md b/spring-reactive-modules/spring-reactive-client/README.md similarity index 89% rename from spring-reactive-modules/spring-5-reactive-client/README.md rename to spring-reactive-modules/spring-reactive-client/README.md index f1793070b3..fc67a4f16e 100644 --- a/spring-reactive-modules/spring-5-reactive-client/README.md +++ b/spring-reactive-modules/spring-reactive-client/README.md @@ -9,8 +9,8 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Logging Spring WebClient Calls](https://www.baeldung.com/spring-log-webclient-calls) - [Simultaneous Spring WebClient Calls](https://www.baeldung.com/spring-webclient-simultaneous-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) - [Upload a File with WebClient](https://www.baeldung.com/spring-webclient-upload-file) - [How to Get Response Body When Testing the Status Code in WebFlux WebClient](https://www.baeldung.com/spring-webclient-get-response-body) +- [Spring Boot FeignClient vs. WebClient](https://www.baeldung.com/spring-boot-feignclient-vs-webclient) - More articles: [[next -->]](../spring-5-reactive-client-2) diff --git a/spring-reactive-modules/spring-5-reactive-client/pom.xml b/spring-reactive-modules/spring-reactive-client/pom.xml similarity index 93% rename from spring-reactive-modules/spring-5-reactive-client/pom.xml rename to spring-reactive-modules/spring-reactive-client/pom.xml index a0e5f7794e..94134e5271 100644 --- a/spring-reactive-modules/spring-5-reactive-client/pom.xml +++ b/spring-reactive-modules/spring-reactive-client/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"> 4.0.0 - spring-5-reactive-client - spring-5-reactive-client + spring-reactive-client + spring-reactive-client jar - spring 5 sample project about new features + spring boot sample project about new features com.baeldung.spring.reactive @@ -32,8 +32,9 @@ spring-boot-starter-webflux - org.springframework.boot - spring-boot-starter-security + org.springframework.cloud + spring-cloud-starter-openfeign + ${spring-cloud-starter-openfeign.version} org.projectreactor @@ -176,13 +177,12 @@ 1.0.1.RELEASE - 1.1.3 - 1.0 1.0 1.1.6 4.0.1 3.5.3 2.26.0 + 3.1.4 \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/controller/UploadController.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/controller/UploadController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/controller/UploadController.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/controller/UploadController.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/enums/Role.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/enums/Role.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/enums/Role.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/enums/Role.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/exception/ServiceException.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/exception/ServiceException.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/exception/ServiceException.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/exception/ServiceException.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/model/Employee.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/model/Employee.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/model/Employee.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/model/Employee.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/model/Foo.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/model/Foo.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/model/Foo.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/model/Foo.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/service/EmployeeService.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/service/EmployeeService.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/service/EmployeeService.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/service/EmployeeService.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/service/ReactiveUploadService.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/service/ReactiveUploadService.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/service/ReactiveUploadService.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/service/ReactiveUploadService.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Client.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Client.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Client.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Client.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Item.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Item.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Item.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/Item.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/User.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/User.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/User.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/User.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/UserWithItem.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/UserWithItem.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/UserWithItem.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/reactive/webclient/simultaneous/UserWithItem.java diff --git a/spring-reactive-modules/spring-5-reactive-3/src/main/java/com/baeldung/webclient/Product.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/Product.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-3/src/main/java/com/baeldung/webclient/Product.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/Product.java diff --git a/spring-reactive-modules/spring-5-reactive-3/src/main/java/com/baeldung/webclient/ProductsFeignClient.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/ProductsFeignClient.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-3/src/main/java/com/baeldung/webclient/ProductsFeignClient.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/ProductsFeignClient.java diff --git a/spring-reactive-modules/spring-5-reactive-3/src/main/java/com/baeldung/webclient/ProductsSlowServiceController.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/ProductsSlowServiceController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-3/src/main/java/com/baeldung/webclient/ProductsSlowServiceController.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/ProductsSlowServiceController.java diff --git a/spring-reactive-modules/spring-5-reactive-3/src/main/java/com/baeldung/webclient/WebClientApplication.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/WebClientApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-3/src/main/java/com/baeldung/webclient/WebClientApplication.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/WebClientApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-3/src/main/java/com/baeldung/webclient/WebController.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/WebController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-3/src/main/java/com/baeldung/webclient/WebController.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/WebController.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerService.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerService.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerService.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerService.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerServiceImpl.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerServiceImpl.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerServiceImpl.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/json/ReaderConsumerServiceImpl.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Book.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/json/model/Book.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Book.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/json/model/Book.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Reader.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/json/model/Reader.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/json/model/Reader.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/json/model/Reader.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/WebClientStatusCodeHandler.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/status/WebClientStatusCodeHandler.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/WebClientStatusCodeHandler.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/status/WebClientStatusCodeHandler.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/CustomBadRequestException.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/status/exception/CustomBadRequestException.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/CustomBadRequestException.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/status/exception/CustomBadRequestException.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/CustomServerErrorException.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/status/exception/CustomServerErrorException.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/status/exception/CustomServerErrorException.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/status/exception/CustomServerErrorException.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/timeout/WebClientTimeoutProvider.java b/spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/timeout/WebClientTimeoutProvider.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/timeout/WebClientTimeoutProvider.java rename to spring-reactive-modules/spring-reactive-client/src/main/java/com/baeldung/webclient/timeout/WebClientTimeoutProvider.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/resources/application.properties b/spring-reactive-modules/spring-reactive-client/src/main/resources/application.properties similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/resources/application.properties rename to spring-reactive-modules/spring-reactive-client/src/main/resources/application.properties diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/resources/logback.xml b/spring-reactive-modules/spring-reactive-client/src/main/resources/logback.xml similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/resources/logback.xml rename to spring-reactive-modules/spring-reactive-client/src/main/resources/logback.xml diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/webapp/WEB-INF/web.xml b/spring-reactive-modules/spring-reactive-client/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/main/webapp/WEB-INF/web.xml rename to spring-reactive-modules/spring-reactive-client/src/main/webapp/WEB-INF/web.xml diff --git a/spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/SpringContextTest.java b/spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/SpringContextTest.java rename to spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/ReactiveIntegrationTest.java b/spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/ReactiveIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/ReactiveIntegrationTest.java rename to spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/ReactiveIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/Spring5ReactiveTestApplication.java b/spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/Spring5ReactiveTestApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/Spring5ReactiveTestApplication.java rename to spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/Spring5ReactiveTestApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/logging/WebClientLoggingIntegrationTest.java b/spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/logging/WebClientLoggingIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/logging/WebClientLoggingIntegrationTest.java rename to spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/logging/WebClientLoggingIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/logging/filters/LogFilters.java b/spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/logging/filters/LogFilters.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/logging/filters/LogFilters.java rename to spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/logging/filters/LogFilters.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/logging/jetty/RequestLogEnhancer.java b/spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/logging/jetty/RequestLogEnhancer.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/logging/jetty/RequestLogEnhancer.java rename to spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/logging/jetty/RequestLogEnhancer.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/service/EmployeeServiceIntegrationTest.java b/spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/service/EmployeeServiceIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/service/EmployeeServiceIntegrationTest.java rename to spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/service/EmployeeServiceIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/service/EmployeeServiceUnitTest.java b/spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/service/EmployeeServiceUnitTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/service/EmployeeServiceUnitTest.java rename to spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/service/EmployeeServiceUnitTest.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/service/ReactiveUploadServiceUnitTest.java b/spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/service/ReactiveUploadServiceUnitTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/service/ReactiveUploadServiceUnitTest.java rename to spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/service/ReactiveUploadServiceUnitTest.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/webclient/simultaneous/ClientIntegrationTest.java b/spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/webclient/simultaneous/ClientIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/reactive/webclient/simultaneous/ClientIntegrationTest.java rename to spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/reactive/webclient/simultaneous/ClientIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/webclient/WebClientStatusCodeHandlerIntegrationTest.java b/spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/webclient/WebClientStatusCodeHandlerIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/webclient/WebClientStatusCodeHandlerIntegrationTest.java rename to spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/webclient/WebClientStatusCodeHandlerIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive-3/src/test/java/com/baeldung/webclient/WebControllerIntegrationTest.java b/spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/webclient/WebControllerIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-3/src/test/java/com/baeldung/webclient/WebControllerIntegrationTest.java rename to spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/webclient/WebControllerIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/ReaderConsumerServiceImplUnitTest.java b/spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/webclient/json/ReaderConsumerServiceImplUnitTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/webclient/json/ReaderConsumerServiceImplUnitTest.java rename to spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/webclient/json/ReaderConsumerServiceImplUnitTest.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/webclient/timeout/WebClientTimeoutIntegrationTest.java b/spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/webclient/timeout/WebClientTimeoutIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/webclient/timeout/WebClientTimeoutIntegrationTest.java rename to spring-reactive-modules/spring-reactive-client/src/test/java/com/baeldung/webclient/timeout/WebClientTimeoutIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/test/resources/logback-test.xml b/spring-reactive-modules/spring-reactive-client/src/test/resources/logback-test.xml similarity index 100% rename from spring-reactive-modules/spring-5-reactive-client/src/test/resources/logback-test.xml rename to spring-reactive-modules/spring-reactive-client/src/test/resources/logback-test.xml diff --git a/spring-reactive-modules/spring-5-data-reactive-2/README.md b/spring-reactive-modules/spring-reactive-data-2/README.md similarity index 80% rename from spring-reactive-modules/spring-5-data-reactive-2/README.md rename to spring-reactive-modules/spring-reactive-data-2/README.md index ffc664b8af..c13171cbc6 100644 --- a/spring-reactive-modules/spring-5-data-reactive-2/README.md +++ b/spring-reactive-modules/spring-reactive-data-2/README.md @@ -1,6 +1,6 @@ ## Spring Data Reactive Project -This module contains articles about reactive Spring 5 Data +This module contains articles about reactive Spring Boot Data ### The Course diff --git a/spring-reactive-modules/spring-5-data-reactive-2/pom.xml b/spring-reactive-modules/spring-reactive-data-2/pom.xml similarity index 85% rename from spring-reactive-modules/spring-5-data-reactive-2/pom.xml rename to spring-reactive-modules/spring-reactive-data-2/pom.xml index 3d88e672eb..64ce278973 100644 --- a/spring-reactive-modules/spring-5-data-reactive-2/pom.xml +++ b/spring-reactive-modules/spring-reactive-data-2/pom.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - spring-5-data-reactive-2 - spring-5-data-reactive-2 + spring-reactive-data-2 + spring-reactive-data-2 jar @@ -14,8 +14,6 @@ - 8 - 8 UTF-8 @@ -56,11 +54,6 @@ lombok true - - org.springframework.boot - spring-boot-starter-test - test - io.projectreactor reactor-test diff --git a/spring-reactive-modules/spring-5-data-reactive-2/src/main/java/com/baeldung/pagination/PaginationApplication.java b/spring-reactive-modules/spring-reactive-data-2/src/main/java/com/baeldung/pagination/PaginationApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive-2/src/main/java/com/baeldung/pagination/PaginationApplication.java rename to spring-reactive-modules/spring-reactive-data-2/src/main/java/com/baeldung/pagination/PaginationApplication.java diff --git a/spring-reactive-modules/spring-5-data-reactive-2/src/main/java/com/baeldung/pagination/config/CustomWebMvcConfigurationSupport.java b/spring-reactive-modules/spring-reactive-data-2/src/main/java/com/baeldung/pagination/config/CustomWebMvcConfigurationSupport.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive-2/src/main/java/com/baeldung/pagination/config/CustomWebMvcConfigurationSupport.java rename to spring-reactive-modules/spring-reactive-data-2/src/main/java/com/baeldung/pagination/config/CustomWebMvcConfigurationSupport.java diff --git a/spring-reactive-modules/spring-5-data-reactive-2/src/main/java/com/baeldung/pagination/config/DatabaseConfig.java b/spring-reactive-modules/spring-reactive-data-2/src/main/java/com/baeldung/pagination/config/DatabaseConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive-2/src/main/java/com/baeldung/pagination/config/DatabaseConfig.java rename to spring-reactive-modules/spring-reactive-data-2/src/main/java/com/baeldung/pagination/config/DatabaseConfig.java diff --git a/spring-reactive-modules/spring-5-data-reactive-2/src/main/java/com/baeldung/pagination/controller/ProductPaginationController.java b/spring-reactive-modules/spring-reactive-data-2/src/main/java/com/baeldung/pagination/controller/ProductPaginationController.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive-2/src/main/java/com/baeldung/pagination/controller/ProductPaginationController.java rename to spring-reactive-modules/spring-reactive-data-2/src/main/java/com/baeldung/pagination/controller/ProductPaginationController.java diff --git a/spring-reactive-modules/spring-5-data-reactive-2/src/main/java/com/baeldung/pagination/model/Product.java b/spring-reactive-modules/spring-reactive-data-2/src/main/java/com/baeldung/pagination/model/Product.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive-2/src/main/java/com/baeldung/pagination/model/Product.java rename to spring-reactive-modules/spring-reactive-data-2/src/main/java/com/baeldung/pagination/model/Product.java diff --git a/spring-reactive-modules/spring-5-data-reactive-2/src/main/java/com/baeldung/pagination/repository/ProductRepository.java b/spring-reactive-modules/spring-reactive-data-2/src/main/java/com/baeldung/pagination/repository/ProductRepository.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive-2/src/main/java/com/baeldung/pagination/repository/ProductRepository.java rename to spring-reactive-modules/spring-reactive-data-2/src/main/java/com/baeldung/pagination/repository/ProductRepository.java diff --git a/spring-reactive-modules/spring-5-data-reactive-2/src/main/resources/application.properties b/spring-reactive-modules/spring-reactive-data-2/src/main/resources/application.properties similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive-2/src/main/resources/application.properties rename to spring-reactive-modules/spring-reactive-data-2/src/main/resources/application.properties diff --git a/spring-reactive-modules/spring-5-data-reactive-2/src/main/resources/init.sql b/spring-reactive-modules/spring-reactive-data-2/src/main/resources/init.sql similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive-2/src/main/resources/init.sql rename to spring-reactive-modules/spring-reactive-data-2/src/main/resources/init.sql diff --git a/spring-reactive-modules/spring-5-data-reactive-2/src/test/java/com/baeldung/pagination/controller/ProductPaginationControllerIntegrationTest.java b/spring-reactive-modules/spring-reactive-data-2/src/test/java/com/baeldung/pagination/controller/ProductPaginationControllerIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive-2/src/test/java/com/baeldung/pagination/controller/ProductPaginationControllerIntegrationTest.java rename to spring-reactive-modules/spring-reactive-data-2/src/test/java/com/baeldung/pagination/controller/ProductPaginationControllerIntegrationTest.java diff --git a/spring-reactive-modules/spring-reactive-data/README.md b/spring-reactive-modules/spring-reactive-data/README.md new file mode 100644 index 0000000000..cafd0c502f --- /dev/null +++ b/spring-reactive-modules/spring-reactive-data/README.md @@ -0,0 +1,9 @@ +## Spring Data Reactive Project + +This module contains articles about reactive Spring Boot Data + +### The Course +The "REST With Spring" Classes: http://bit.ly/restwithspring + +### Relevant Articles +- [A Quick Look at R2DBC with Spring Data](https://www.baeldung.com/spring-data-r2dbc) \ No newline at end of file diff --git a/spring-reactive-modules/spring-reactive-data/pom.xml b/spring-reactive-modules/spring-reactive-data/pom.xml new file mode 100644 index 0000000000..91c4dca6e8 --- /dev/null +++ b/spring-reactive-modules/spring-reactive-data/pom.xml @@ -0,0 +1,74 @@ + + + 4.0.0 + spring-reactive-data + spring-reactive-data + jar + + + com.baeldung.spring.reactive + spring-reactive-modules + 1.0.0-SNAPSHOT + + + + + + org.apache.logging.log4j + log4j-bom + ${log4j2.version} + import + pom + + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.projectlombok + lombok + + + io.projectreactor + reactor-test + test + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-starter-webflux + + + org.springframework.data + spring-data-r2dbc + + + io.r2dbc + r2dbc-h2 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + 2.17.1 + + + \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/R2dbcApplication.java b/spring-reactive-modules/spring-reactive-data/src/main/java/com/baeldung/r2dbc/R2dbcApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/R2dbcApplication.java rename to spring-reactive-modules/spring-reactive-data/src/main/java/com/baeldung/r2dbc/R2dbcApplication.java diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/configuration/R2DBCConfiguration.java b/spring-reactive-modules/spring-reactive-data/src/main/java/com/baeldung/r2dbc/configuration/R2DBCConfiguration.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/configuration/R2DBCConfiguration.java rename to spring-reactive-modules/spring-reactive-data/src/main/java/com/baeldung/r2dbc/configuration/R2DBCConfiguration.java diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/model/Player.java b/spring-reactive-modules/spring-reactive-data/src/main/java/com/baeldung/r2dbc/model/Player.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/model/Player.java rename to spring-reactive-modules/spring-reactive-data/src/main/java/com/baeldung/r2dbc/model/Player.java diff --git a/spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/repository/PlayerRepository.java b/spring-reactive-modules/spring-reactive-data/src/main/java/com/baeldung/r2dbc/repository/PlayerRepository.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/repository/PlayerRepository.java rename to spring-reactive-modules/spring-reactive-data/src/main/java/com/baeldung/r2dbc/repository/PlayerRepository.java diff --git a/spring-reactive-modules/spring-5-reactive-filters/src/main/resources/logback.xml b/spring-reactive-modules/spring-reactive-data/src/main/resources/logback.xml similarity index 100% rename from spring-reactive-modules/spring-5-reactive-filters/src/main/resources/logback.xml rename to spring-reactive-modules/spring-reactive-data/src/main/resources/logback.xml diff --git a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/SpringContextTest.java b/spring-reactive-modules/spring-reactive-data/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/SpringContextTest.java rename to spring-reactive-modules/spring-reactive-data/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java b/spring-reactive-modules/spring-reactive-data/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java similarity index 93% rename from spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java rename to spring-reactive-modules/spring-reactive-data/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java index 1af570587e..b5e859ae2f 100644 --- a/spring-reactive-modules/spring-5-data-reactive/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java +++ b/spring-reactive-modules/spring-reactive-data/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java @@ -1,6 +1,7 @@ package com.baeldung.r2dbc; +import com.baeldung.r2dbc.configuration.R2DBCConfiguration; import com.baeldung.r2dbc.model.Player; import com.baeldung.r2dbc.repository.PlayerRepository; import io.r2dbc.h2.H2ConnectionFactory; @@ -9,7 +10,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.r2dbc.core.DatabaseClient; +import org.springframework.r2dbc.core.DatabaseClient; import org.springframework.test.context.junit4.SpringRunner; import reactor.core.publisher.Flux; import reactor.core.publisher.Hooks; @@ -20,7 +21,7 @@ import java.util.Arrays; import java.util.List; @RunWith(SpringRunner.class) -@SpringBootTest +@SpringBootTest(classes = R2DBCConfiguration.class) public class R2dbcApplicationIntegrationTest { @@ -43,7 +44,7 @@ public class R2dbcApplicationIntegrationTest { "DROP TABLE IF EXISTS player;", "CREATE table player (id INT AUTO_INCREMENT NOT NULL, name VARCHAR2, age INT NOT NULL);"); - statements.forEach(it -> client.execute(it) // + statements.forEach(it -> client.sql(it) // .fetch() // .rowsUpdated() // .as(StepVerifier::create) // diff --git a/spring-reactive-modules/spring-reactive-exceptions/README.md b/spring-reactive-modules/spring-reactive-exceptions/README.md index fc1a31b26f..f7e2c8cae0 100644 --- a/spring-reactive-modules/spring-reactive-exceptions/README.md +++ b/spring-reactive-modules/spring-reactive-exceptions/README.md @@ -1,3 +1,4 @@ ## Relevant Articles - [How to Resolve Spring Webflux DataBufferLimitException](https://www.baeldung.com/spring-webflux-databufferlimitexception) - [Custom WebFlux Exceptions in Spring Boot 3](https://www.baeldung.com/spring-boot-custom-webflux-exceptions) +- [Handling Errors in Spring WebFlux](https://www.baeldung.com/spring-webflux-errors) \ No newline at end of file diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/ErrorHandlingApplication.java b/spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/ErrorHandlingApplication.java similarity index 93% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/ErrorHandlingApplication.java rename to spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/ErrorHandlingApplication.java index 50579d8721..c34f86febd 100644 --- a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/ErrorHandlingApplication.java +++ b/spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/ErrorHandlingApplication.java @@ -1,4 +1,4 @@ -package com.baeldung.reactive.errorhandling; +package com.baeldung.spring.reactive.errorhandling; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorAttributes.java b/spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/GlobalErrorAttributes.java similarity index 93% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorAttributes.java rename to spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/GlobalErrorAttributes.java index 3458a175e4..9dce1b3e5b 100644 --- a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorAttributes.java +++ b/spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/GlobalErrorAttributes.java @@ -1,4 +1,6 @@ -package com.baeldung.reactive.errorhandling; +package com.baeldung.spring.reactive.errorhandling; + +import java.util.Map; import org.springframework.boot.web.error.ErrorAttributeOptions; import org.springframework.boot.web.reactive.error.DefaultErrorAttributes; @@ -6,8 +8,6 @@ import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.server.ServerRequest; -import java.util.Map; - @Component public class GlobalErrorAttributes extends DefaultErrorAttributes { diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorWebExceptionHandler.java b/spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/GlobalErrorWebExceptionHandler.java similarity index 92% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorWebExceptionHandler.java rename to spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/GlobalErrorWebExceptionHandler.java index 24583308cd..bfd3bba2a1 100644 --- a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/GlobalErrorWebExceptionHandler.java +++ b/spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/GlobalErrorWebExceptionHandler.java @@ -1,4 +1,6 @@ -package com.baeldung.reactive.errorhandling; +package com.baeldung.spring.reactive.errorhandling; + +import java.util.Map; import org.springframework.boot.autoconfigure.web.WebProperties; import org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler; @@ -16,15 +18,15 @@ 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; -import java.util.Map; +import reactor.core.publisher.Mono; @Component @Order(-2) public class GlobalErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler { - public GlobalErrorWebExceptionHandler(GlobalErrorAttributes g, ApplicationContext applicationContext, + public GlobalErrorWebExceptionHandler( + GlobalErrorAttributes g, ApplicationContext applicationContext, ServerCodecConfigurer serverCodecConfigurer) { super(g, new WebProperties.Resources(), applicationContext); super.setMessageWriters(serverCodecConfigurer.getWriters()); diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/Handler.java b/spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/Handler.java similarity index 97% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/Handler.java rename to spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/Handler.java index d49d9b4be2..2956cc1686 100644 --- a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/Handler.java +++ b/spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/Handler.java @@ -1,10 +1,11 @@ -package com.baeldung.reactive.errorhandling; +package com.baeldung.spring.reactive.errorhandling; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.server.ServerRequest; import org.springframework.web.reactive.function.server.ServerResponse; + import reactor.core.publisher.Mono; @Component diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/NameRequiredException.java b/spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/NameRequiredException.java similarity index 85% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/NameRequiredException.java rename to spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/NameRequiredException.java index bdc7771b80..1926d6416a 100644 --- a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/NameRequiredException.java +++ b/spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/NameRequiredException.java @@ -1,4 +1,4 @@ -package com.baeldung.reactive.errorhandling; +package com.baeldung.spring.reactive.errorhandling; import org.springframework.http.HttpStatus; import org.springframework.web.server.ResponseStatusException; diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/Router.java b/spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/Router.java similarity index 96% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/Router.java rename to spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/Router.java index 5f130ec035..c65b645f09 100644 --- a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/errorhandling/Router.java +++ b/spring-reactive-modules/spring-reactive-exceptions/src/main/java/com/baeldung/spring/reactive/errorhandling/Router.java @@ -1,4 +1,8 @@ -package com.baeldung.reactive.errorhandling; +package com.baeldung.spring.reactive.errorhandling; + +import static org.springframework.http.MediaType.TEXT_PLAIN; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Component; @@ -6,10 +10,6 @@ import org.springframework.web.reactive.function.server.RouterFunction; import org.springframework.web.reactive.function.server.RouterFunctions; import org.springframework.web.reactive.function.server.ServerResponse; -import static org.springframework.http.MediaType.TEXT_PLAIN; -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; - @Component public class Router { diff --git a/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java b/spring-reactive-modules/spring-reactive-exceptions/src/test/java/com/baeldung/spring/reactive/errorhandling/ErrorHandlingIntegrationTest.java similarity index 98% rename from spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java rename to spring-reactive-modules/spring-reactive-exceptions/src/test/java/com/baeldung/spring/reactive/errorhandling/ErrorHandlingIntegrationTest.java index 0068379d61..972eefa5ac 100644 --- a/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java +++ b/spring-reactive-modules/spring-reactive-exceptions/src/test/java/com/baeldung/spring/reactive/errorhandling/ErrorHandlingIntegrationTest.java @@ -1,4 +1,4 @@ -package com.baeldung.reactive.errorhandling; +package com.baeldung.spring.reactive.errorhandling; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-reactive-modules/spring-5-reactive-filters/.gitignore b/spring-reactive-modules/spring-reactive-filters/.gitignore similarity index 100% rename from spring-reactive-modules/spring-5-reactive-filters/.gitignore rename to spring-reactive-modules/spring-reactive-filters/.gitignore diff --git a/spring-reactive-modules/spring-5-reactive-filters/README.md b/spring-reactive-modules/spring-reactive-filters/README.md similarity index 76% rename from spring-reactive-modules/spring-5-reactive-filters/README.md rename to spring-reactive-modules/spring-reactive-filters/README.md index 815ca35442..9d73eae9ee 100644 --- a/spring-reactive-modules/spring-5-reactive-filters/README.md +++ b/spring-reactive-modules/spring-reactive-filters/README.md @@ -8,3 +8,4 @@ The "REST With Spring" Classes: https://bit.ly/restwithspring ### Relevant Articles - [Spring WebFlux Filters](https://www.baeldung.com/spring-webflux-filters) +- [Spring WebClient Filters](https://www.baeldung.com/spring-webclient-filters) diff --git a/spring-reactive-modules/spring-5-reactive-filters/pom.xml b/spring-reactive-modules/spring-reactive-filters/pom.xml similarity index 81% rename from spring-reactive-modules/spring-5-reactive-filters/pom.xml rename to spring-reactive-modules/spring-reactive-filters/pom.xml index c9503d631a..67f7a11cb4 100644 --- a/spring-reactive-modules/spring-5-reactive-filters/pom.xml +++ b/spring-reactive-modules/spring-reactive-filters/pom.xml @@ -3,11 +3,11 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - spring-5-reactive-filters + spring-reactive-filters 0.0.1-SNAPSHOT - spring-5-reactive-filters + spring-reactive-filters jar - spring 5 sample project about new features + spring boot sample project about new features com.baeldung.spring.reactive @@ -49,6 +49,12 @@ netty-all test + + com.github.tomakehurst + wiremock-standalone + ${wiremock-standalone.version} + test +
@@ -65,4 +71,8 @@ + + 2.26.0 + + \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-reactive-filters/src/main/java/com/baeldung/reactive/Spring5ReactiveFiltersApplication.java b/spring-reactive-modules/spring-reactive-filters/src/main/java/com/baeldung/reactive/Spring5ReactiveFiltersApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-filters/src/main/java/com/baeldung/reactive/Spring5ReactiveFiltersApplication.java rename to spring-reactive-modules/spring-reactive-filters/src/main/java/com/baeldung/reactive/Spring5ReactiveFiltersApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-filters/src/main/java/com/baeldung/reactive/filters/ExampleHandlerFilterFunction.java b/spring-reactive-modules/spring-reactive-filters/src/main/java/com/baeldung/reactive/filters/ExampleHandlerFilterFunction.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-filters/src/main/java/com/baeldung/reactive/filters/ExampleHandlerFilterFunction.java rename to spring-reactive-modules/spring-reactive-filters/src/main/java/com/baeldung/reactive/filters/ExampleHandlerFilterFunction.java diff --git a/spring-reactive-modules/spring-5-reactive-filters/src/main/java/com/baeldung/reactive/filters/ExampleWebFilter.java b/spring-reactive-modules/spring-reactive-filters/src/main/java/com/baeldung/reactive/filters/ExampleWebFilter.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-filters/src/main/java/com/baeldung/reactive/filters/ExampleWebFilter.java rename to spring-reactive-modules/spring-reactive-filters/src/main/java/com/baeldung/reactive/filters/ExampleWebFilter.java diff --git a/spring-reactive-modules/spring-5-reactive-filters/src/main/java/com/baeldung/reactive/filters/PlayerHandler.java b/spring-reactive-modules/spring-reactive-filters/src/main/java/com/baeldung/reactive/filters/PlayerHandler.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-filters/src/main/java/com/baeldung/reactive/filters/PlayerHandler.java rename to spring-reactive-modules/spring-reactive-filters/src/main/java/com/baeldung/reactive/filters/PlayerHandler.java diff --git a/spring-reactive-modules/spring-5-reactive-filters/src/main/java/com/baeldung/reactive/filters/PlayerRouter.java b/spring-reactive-modules/spring-reactive-filters/src/main/java/com/baeldung/reactive/filters/PlayerRouter.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-filters/src/main/java/com/baeldung/reactive/filters/PlayerRouter.java rename to spring-reactive-modules/spring-reactive-filters/src/main/java/com/baeldung/reactive/filters/PlayerRouter.java diff --git a/spring-reactive-modules/spring-5-reactive-filters/src/main/java/com/baeldung/reactive/filters/UserController.java b/spring-reactive-modules/spring-reactive-filters/src/main/java/com/baeldung/reactive/filters/UserController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-filters/src/main/java/com/baeldung/reactive/filters/UserController.java rename to spring-reactive-modules/spring-reactive-filters/src/main/java/com/baeldung/reactive/filters/UserController.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/filter/WebClientFilters.java b/spring-reactive-modules/spring-reactive-filters/src/main/java/com/baeldung/reactive/filters/WebClientFilters.java similarity index 98% rename from spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/filter/WebClientFilters.java rename to spring-reactive-modules/spring-reactive-filters/src/main/java/com/baeldung/reactive/filters/WebClientFilters.java index c98caf67b4..34fff3c4cb 100644 --- a/spring-reactive-modules/spring-5-reactive-client/src/main/java/com/baeldung/webclient/filter/WebClientFilters.java +++ b/spring-reactive-modules/spring-reactive-filters/src/main/java/com/baeldung/reactive/filters/WebClientFilters.java @@ -1,4 +1,4 @@ -package com.baeldung.webclient.filter; +package com.baeldung.reactive.filters; import java.io.PrintStream; import java.net.URI; diff --git a/spring-reactive-modules/spring-5-reactive-filters/src/main/resources/application.properties b/spring-reactive-modules/spring-reactive-filters/src/main/resources/application.properties similarity index 100% rename from spring-reactive-modules/spring-5-reactive-filters/src/main/resources/application.properties rename to spring-reactive-modules/spring-reactive-filters/src/main/resources/application.properties diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/resources/logback.xml b/spring-reactive-modules/spring-reactive-filters/src/main/resources/logback.xml similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/resources/logback.xml rename to spring-reactive-modules/spring-reactive-filters/src/main/resources/logback.xml diff --git a/spring-reactive-modules/spring-5-reactive-filters/src/test/java/com/baeldung/SpringContextTest.java b/spring-reactive-modules/spring-reactive-filters/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-filters/src/test/java/com/baeldung/SpringContextTest.java rename to spring-reactive-modules/spring-reactive-filters/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/webclient/filter/FilteredWebClientUnitTest.java b/spring-reactive-modules/spring-reactive-filters/src/test/java/com/baeldung/reactive/filters/FilteredWebClientUnitTest.java similarity index 95% rename from spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/webclient/filter/FilteredWebClientUnitTest.java rename to spring-reactive-modules/spring-reactive-filters/src/test/java/com/baeldung/reactive/filters/FilteredWebClientUnitTest.java index 675cd03d10..1350db0752 100644 --- a/spring-reactive-modules/spring-5-reactive-client/src/test/java/com/baeldung/webclient/filter/FilteredWebClientUnitTest.java +++ b/spring-reactive-modules/spring-reactive-filters/src/test/java/com/baeldung/reactive/filters/FilteredWebClientUnitTest.java @@ -1,8 +1,8 @@ -package com.baeldung.webclient.filter; +package com.baeldung.reactive.filters; -import static com.baeldung.webclient.filter.WebClientFilters.countingFilter; -import static com.baeldung.webclient.filter.WebClientFilters.loggingFilter; -import static com.baeldung.webclient.filter.WebClientFilters.urlModifyingFilter; +import static com.baeldung.reactive.filters.WebClientFilters.countingFilter; +import static com.baeldung.reactive.filters.WebClientFilters.loggingFilter; +import static com.baeldung.reactive.filters.WebClientFilters.urlModifyingFilter; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.containing; import static com.github.tomakehurst.wiremock.client.WireMock.get; diff --git a/spring-reactive-modules/spring-5-reactive-filters/src/test/java/com/baeldung/reactive/filters/PlayerHandlerIntegrationTest.java b/spring-reactive-modules/spring-reactive-filters/src/test/java/com/baeldung/reactive/filters/PlayerHandlerIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-filters/src/test/java/com/baeldung/reactive/filters/PlayerHandlerIntegrationTest.java rename to spring-reactive-modules/spring-reactive-filters/src/test/java/com/baeldung/reactive/filters/PlayerHandlerIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive-filters/src/test/java/com/baeldung/reactive/filters/UserControllerIntegrationTest.java b/spring-reactive-modules/spring-reactive-filters/src/test/java/com/baeldung/reactive/filters/UserControllerIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-filters/src/test/java/com/baeldung/reactive/filters/UserControllerIntegrationTest.java rename to spring-reactive-modules/spring-reactive-filters/src/test/java/com/baeldung/reactive/filters/UserControllerIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/README.md b/spring-reactive-modules/spring-reactive-oauth/README.md similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/README.md rename to spring-reactive-modules/spring-reactive-oauth/README.md diff --git a/spring-reactive-modules/spring-5-reactive-oauth/pom.xml b/spring-reactive-modules/spring-reactive-oauth/pom.xml similarity index 96% rename from spring-reactive-modules/spring-5-reactive-oauth/pom.xml rename to spring-reactive-modules/spring-reactive-oauth/pom.xml index 9c237607ba..9d2dbf6126 100644 --- a/spring-reactive-modules/spring-5-reactive-oauth/pom.xml +++ b/spring-reactive-modules/spring-reactive-oauth/pom.xml @@ -4,9 +4,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.baeldung.reactive.oauth - spring-5-reactive-oauth + spring-reactive-oauth 1.0.0-SNAPSHOT - spring-5-reactive-oauth + spring-reactive-oauth jar WebFlux and Spring Security OAuth diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/SecurityConfig.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/SecurityConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/SecurityConfig.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/SecurityConfig.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/Spring5ReactiveOauthApplication.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/Spring5ReactiveOauthApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/Spring5ReactiveOauthApplication.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/Spring5ReactiveOauthApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/web/MainController.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/web/MainController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/web/MainController.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/web/MainController.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/web/dto/Foo.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/web/dto/Foo.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/web/dto/Foo.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/reactive/oauth/web/dto/Foo.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/OauthClientApplication.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/OauthClientApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/OauthClientApplication.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/OauthClientApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/configuration/WebClientConfig.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/configuration/WebClientConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/configuration/WebClientConfig.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/configuration/WebClientConfig.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/configuration/WebSecurityConfig.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/configuration/WebSecurityConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/configuration/WebSecurityConfig.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/configuration/WebSecurityConfig.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/web/ClientRestController.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/web/ClientRestController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/web/ClientRestController.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodeclient/web/ClientRestController.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/OauthClientLoginApplication.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/OauthClientLoginApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/OauthClientLoginApplication.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/OauthClientLoginApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/configuration/WebClientConfig.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/configuration/WebClientConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/configuration/WebClientConfig.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/configuration/WebClientConfig.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/configuration/WebSecurityConfig.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/configuration/WebSecurityConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/configuration/WebSecurityConfig.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/configuration/WebSecurityConfig.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/web/ClientRestController.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/web/ClientRestController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/web/ClientRestController.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/authorizationcodelogin/web/ClientRestController.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/ClientCredentialsOauthApplication.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/ClientCredentialsOauthApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/ClientCredentialsOauthApplication.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/ClientCredentialsOauthApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/configuration/WebClientConfig.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/configuration/WebClientConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/configuration/WebClientConfig.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/configuration/WebClientConfig.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/service/WebClientChonJob.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/service/WebClientChonJob.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/service/WebClientChonJob.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/clientcredentials/service/WebClientChonJob.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/ManualRequestApplication.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/ManualRequestApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/ManualRequestApplication.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/ManualRequestApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/configure/WebClientConfig.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/configure/WebClientConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/configure/WebClientConfig.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/configure/WebClientConfig.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/configure/WebSecurityConfig.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/configure/WebSecurityConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/configure/WebSecurityConfig.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/configure/WebSecurityConfig.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/web/ManualOauthRequestController.java b/spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/web/ManualOauthRequestController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/web/ManualOauthRequestController.java rename to spring-reactive-modules/spring-reactive-oauth/src/main/java/com/baeldung/webclient/manualrequest/web/ManualOauthRequestController.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/resources/application.yml b/spring-reactive-modules/spring-reactive-oauth/src/main/resources/application.yml similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/resources/application.yml rename to spring-reactive-modules/spring-reactive-oauth/src/main/resources/application.yml diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/resources/default-application.yml b/spring-reactive-modules/spring-reactive-oauth/src/main/resources/default-application.yml similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/resources/default-application.yml rename to spring-reactive-modules/spring-reactive-oauth/src/main/resources/default-application.yml diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-client-application.properties b/spring-reactive-modules/spring-reactive-oauth/src/main/resources/webclient-auth-code-client-application.properties similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-client-application.properties rename to spring-reactive-modules/spring-reactive-oauth/src/main/resources/webclient-auth-code-client-application.properties diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-login-application.properties b/spring-reactive-modules/spring-reactive-oauth/src/main/resources/webclient-auth-code-login-application.properties similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/resources/webclient-auth-code-login-application.properties rename to spring-reactive-modules/spring-reactive-oauth/src/main/resources/webclient-auth-code-login-application.properties diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/resources/webclient-client-credentials-oauth-application.properties b/spring-reactive-modules/spring-reactive-oauth/src/main/resources/webclient-client-credentials-oauth-application.properties similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/resources/webclient-client-credentials-oauth-application.properties rename to spring-reactive-modules/spring-reactive-oauth/src/main/resources/webclient-client-credentials-oauth-application.properties diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/main/resources/webclient-manual-request-oauth-application.properties b/spring-reactive-modules/spring-reactive-oauth/src/main/resources/webclient-manual-request-oauth-application.properties similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/main/resources/webclient-manual-request-oauth-application.properties rename to spring-reactive-modules/spring-reactive-oauth/src/main/resources/webclient-manual-request-oauth-application.properties diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/test/java/com/baeldung/reactive/oauth/Spring5ReactiveOauthIntegrationTest.java b/spring-reactive-modules/spring-reactive-oauth/src/test/java/com/baeldung/reactive/oauth/Spring5ReactiveOauthIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/test/java/com/baeldung/reactive/oauth/Spring5ReactiveOauthIntegrationTest.java rename to spring-reactive-modules/spring-reactive-oauth/src/test/java/com/baeldung/reactive/oauth/Spring5ReactiveOauthIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/clientcredentials/OAuth2ClientCredentialsLiveTest.java b/spring-reactive-modules/spring-reactive-oauth/src/test/java/com/baeldung/webclient/clientcredentials/OAuth2ClientCredentialsLiveTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/clientcredentials/OAuth2ClientCredentialsLiveTest.java rename to spring-reactive-modules/spring-reactive-oauth/src/test/java/com/baeldung/webclient/clientcredentials/OAuth2ClientCredentialsLiveTest.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/manualrequest/OAuth2ManualRequestLiveTest.java b/spring-reactive-modules/spring-reactive-oauth/src/test/java/com/baeldung/webclient/manualrequest/OAuth2ManualRequestLiveTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/manualrequest/OAuth2ManualRequestLiveTest.java rename to spring-reactive-modules/spring-reactive-oauth/src/test/java/com/baeldung/webclient/manualrequest/OAuth2ManualRequestLiveTest.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/utils/ListAppender.java b/spring-reactive-modules/spring-reactive-oauth/src/test/java/com/baeldung/webclient/utils/ListAppender.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/test/java/com/baeldung/webclient/utils/ListAppender.java rename to spring-reactive-modules/spring-reactive-oauth/src/test/java/com/baeldung/webclient/utils/ListAppender.java diff --git a/spring-reactive-modules/spring-5-reactive-oauth/src/test/resources/logback-test.xml b/spring-reactive-modules/spring-reactive-oauth/src/test/resources/logback-test.xml similarity index 100% rename from spring-reactive-modules/spring-5-reactive-oauth/src/test/resources/logback-test.xml rename to spring-reactive-modules/spring-reactive-oauth/src/test/resources/logback-test.xml diff --git a/spring-reactive-modules/spring-5-reactive-security/.gitignore b/spring-reactive-modules/spring-reactive-security/.gitignore similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/.gitignore rename to spring-reactive-modules/spring-reactive-security/.gitignore diff --git a/spring-reactive-modules/spring-5-reactive-security/README.md b/spring-reactive-modules/spring-reactive-security/README.md similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/README.md rename to spring-reactive-modules/spring-reactive-security/README.md diff --git a/spring-reactive-modules/spring-5-reactive-security/pom.xml b/spring-reactive-modules/spring-reactive-security/pom.xml similarity index 93% rename from spring-reactive-modules/spring-5-reactive-security/pom.xml rename to spring-reactive-modules/spring-reactive-security/pom.xml index e455940d83..8ed976c572 100644 --- a/spring-reactive-modules/spring-5-reactive-security/pom.xml +++ b/spring-reactive-modules/spring-reactive-security/pom.xml @@ -3,11 +3,11 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - spring-5-reactive-security + spring-reactive-security 0.0.1-SNAPSHOT - spring-5-reactive-security + spring-reactive-security jar - spring 5 security sample project about new features + spring boot security sample project about new features com.baeldung.spring.reactive @@ -66,10 +66,6 @@ spring-boot-devtools runtime - - org.springframework - spring-test - org.springframework.boot spring-boot-starter-test diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/DownstreamServiceHealthIndicator.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/actuator/DownstreamServiceHealthIndicator.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/DownstreamServiceHealthIndicator.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/actuator/DownstreamServiceHealthIndicator.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/FeaturesEndpoint.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/actuator/FeaturesEndpoint.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/FeaturesEndpoint.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/actuator/FeaturesEndpoint.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/InfoWebEndpointExtension.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/actuator/InfoWebEndpointExtension.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/InfoWebEndpointExtension.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/actuator/InfoWebEndpointExtension.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/Spring5ReactiveApplication.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/actuator/Spring5ReactiveApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/Spring5ReactiveApplication.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/actuator/Spring5ReactiveApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/WebSecurityConfig.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/actuator/WebSecurityConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/WebSecurityConfig.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/actuator/WebSecurityConfig.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/AuthResolverApplication.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/authresolver/AuthResolverApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/AuthResolverApplication.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/authresolver/AuthResolverApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/AuthResolverController.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/authresolver/AuthResolverController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/AuthResolverController.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/authresolver/AuthResolverController.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/CustomWebSecurityConfig.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/authresolver/CustomWebSecurityConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/authresolver/CustomWebSecurityConfig.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/authresolver/CustomWebSecurityConfig.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/annotated/CorsOnAnnotatedElementsApplication.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/annotated/CorsOnAnnotatedElementsApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/annotated/CorsOnAnnotatedElementsApplication.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/annotated/CorsOnAnnotatedElementsApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/annotated/controllers/CorsOnClassController.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/annotated/controllers/CorsOnClassController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/annotated/controllers/CorsOnClassController.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/annotated/controllers/CorsOnClassController.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/annotated/controllers/CorsOnMethodsController.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/annotated/controllers/CorsOnMethodsController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/annotated/controllers/CorsOnMethodsController.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/annotated/controllers/CorsOnMethodsController.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/global/CorsGlobalConfigApplication.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/global/CorsGlobalConfigApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/global/CorsGlobalConfigApplication.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/global/CorsGlobalConfigApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/global/config/CorsGlobalConfiguration.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/global/config/CorsGlobalConfiguration.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/global/config/CorsGlobalConfiguration.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/global/config/CorsGlobalConfiguration.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/global/controllers/FurtherCorsConfigsController.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/global/controllers/FurtherCorsConfigsController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/global/controllers/FurtherCorsConfigsController.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/global/controllers/FurtherCorsConfigsController.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/global/controllers/RegularRestController.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/global/controllers/RegularRestController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/global/controllers/RegularRestController.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/global/controllers/RegularRestController.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/global/functional/handlers/CorsGlobalFunctionalHandler.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/global/functional/handlers/CorsGlobalFunctionalHandler.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/global/functional/handlers/CorsGlobalFunctionalHandler.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/global/functional/handlers/CorsGlobalFunctionalHandler.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/global/functional/routers/CorsRouterFunctions.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/global/functional/routers/CorsRouterFunctions.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/global/functional/routers/CorsRouterFunctions.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/global/functional/routers/CorsRouterFunctions.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/CorsWebFilterApplication.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/CorsWebFilterApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/CorsWebFilterApplication.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/CorsWebFilterApplication.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/config/CorsWebFilterConfig.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/config/CorsWebFilterConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/config/CorsWebFilterConfig.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/config/CorsWebFilterConfig.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/controllers/FurtherCorsConfigsController.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/controllers/FurtherCorsConfigsController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/controllers/FurtherCorsConfigsController.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/controllers/FurtherCorsConfigsController.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/controllers/RegularRestController.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/controllers/RegularRestController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/controllers/RegularRestController.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/controllers/RegularRestController.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/functional/handlers/CorsWithWebFilterHandler.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/functional/handlers/CorsWithWebFilterHandler.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/functional/handlers/CorsWithWebFilterHandler.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/functional/handlers/CorsWithWebFilterHandler.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/functional/routers/CorsWithWebFilterRouterFunctions.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/functional/routers/CorsWithWebFilterRouterFunctions.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/functional/routers/CorsWithWebFilterRouterFunctions.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/reactive/cors/webfilter/functional/routers/CorsWithWebFilterRouterFunctions.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/webflux/Employee.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/webflux/Employee.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/webflux/Employee.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/webflux/Employee.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/webflux/EmployeeConfig.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/webflux/EmployeeConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/webflux/EmployeeConfig.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/webflux/EmployeeConfig.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/webflux/EmployeeCreationEvent.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/webflux/EmployeeCreationEvent.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/webflux/EmployeeCreationEvent.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/webflux/EmployeeCreationEvent.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/webflux/EmployeeWebSecurityConfig.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/webflux/EmployeeWebSecurityConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/webflux/EmployeeWebSecurityConfig.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/webflux/EmployeeWebSecurityConfig.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/webflux/EmployeeWebSocketClient.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/webflux/EmployeeWebSocketClient.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/webflux/EmployeeWebSocketClient.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/webflux/EmployeeWebSocketClient.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/webflux/EmployeeWebSocketHandler.java b/spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/webflux/EmployeeWebSocketHandler.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/java/com/baeldung/webflux/EmployeeWebSocketHandler.java rename to spring-reactive-modules/spring-reactive-security/src/main/java/com/baeldung/webflux/EmployeeWebSocketHandler.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/resources/application.properties b/spring-reactive-modules/spring-reactive-security/src/main/resources/application.properties similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/resources/application.properties rename to spring-reactive-modules/spring-reactive-security/src/main/resources/application.properties diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/resources/files/hello.txt b/spring-reactive-modules/spring-reactive-security/src/main/resources/files/hello.txt similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/resources/files/hello.txt rename to spring-reactive-modules/spring-reactive-security/src/main/resources/files/hello.txt diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/resources/files/test/test.txt b/spring-reactive-modules/spring-reactive-security/src/main/resources/files/test/test.txt similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/resources/files/test/test.txt rename to spring-reactive-modules/spring-reactive-security/src/main/resources/files/test/test.txt diff --git a/spring-reactive-modules/spring-5-reactive/src/main/resources/logback.xml b/spring-reactive-modules/spring-reactive-security/src/main/resources/logback.xml similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/resources/logback.xml rename to spring-reactive-modules/spring-reactive-security/src/main/resources/logback.xml diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/resources/static/client-websocket.html b/spring-reactive-modules/spring-reactive-security/src/main/resources/static/client-websocket.html similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/resources/static/client-websocket.html rename to spring-reactive-modules/spring-reactive-security/src/main/resources/static/client-websocket.html diff --git a/spring-reactive-modules/spring-5-reactive-security/src/main/webapp/WEB-INF/web.xml b/spring-reactive-modules/spring-reactive-security/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/main/webapp/WEB-INF/web.xml rename to spring-reactive-modules/spring-reactive-security/src/main/webapp/WEB-INF/web.xml diff --git a/spring-reactive-modules/spring-5-reactive-security/src/test/java/com/baeldung/SpringContextTest.java b/spring-reactive-modules/spring-reactive-security/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/test/java/com/baeldung/SpringContextTest.java rename to spring-reactive-modules/spring-reactive-security/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/test/java/com/baeldung/reactive/actuator/ActuatorInfoIntegrationTest.java b/spring-reactive-modules/spring-reactive-security/src/test/java/com/baeldung/reactive/actuator/ActuatorInfoIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/test/java/com/baeldung/reactive/actuator/ActuatorInfoIntegrationTest.java rename to spring-reactive-modules/spring-reactive-security/src/test/java/com/baeldung/reactive/actuator/ActuatorInfoIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/test/java/com/baeldung/reactive/authresolver/AuthResolverIntegrationTest.java b/spring-reactive-modules/spring-reactive-security/src/test/java/com/baeldung/reactive/authresolver/AuthResolverIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/test/java/com/baeldung/reactive/authresolver/AuthResolverIntegrationTest.java rename to spring-reactive-modules/spring-reactive-security/src/test/java/com/baeldung/reactive/authresolver/AuthResolverIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/test/java/com/baeldung/reactive/cors/CorsOnAnnotatedElementsLiveTest.java b/spring-reactive-modules/spring-reactive-security/src/test/java/com/baeldung/reactive/cors/CorsOnAnnotatedElementsLiveTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/test/java/com/baeldung/reactive/cors/CorsOnAnnotatedElementsLiveTest.java rename to spring-reactive-modules/spring-reactive-security/src/test/java/com/baeldung/reactive/cors/CorsOnAnnotatedElementsLiveTest.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/test/java/com/baeldung/reactive/cors/CorsOnGlobalConfigLiveTest.java b/spring-reactive-modules/spring-reactive-security/src/test/java/com/baeldung/reactive/cors/CorsOnGlobalConfigLiveTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/test/java/com/baeldung/reactive/cors/CorsOnGlobalConfigLiveTest.java rename to spring-reactive-modules/spring-reactive-security/src/test/java/com/baeldung/reactive/cors/CorsOnGlobalConfigLiveTest.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/test/java/com/baeldung/reactive/cors/CorsOnWebFilterLiveTest.java b/spring-reactive-modules/spring-reactive-security/src/test/java/com/baeldung/reactive/cors/CorsOnWebFilterLiveTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/test/java/com/baeldung/reactive/cors/CorsOnWebFilterLiveTest.java rename to spring-reactive-modules/spring-reactive-security/src/test/java/com/baeldung/reactive/cors/CorsOnWebFilterLiveTest.java diff --git a/spring-reactive-modules/spring-5-reactive-security/src/test/resources/baeldung-weekly.png b/spring-reactive-modules/spring-reactive-security/src/test/resources/baeldung-weekly.png similarity index 100% rename from spring-reactive-modules/spring-5-reactive-security/src/test/resources/baeldung-weekly.png rename to spring-reactive-modules/spring-reactive-security/src/test/resources/baeldung-weekly.png diff --git a/spring-reactive-modules/spring-reactive-webflux/README.md b/spring-reactive-modules/spring-reactive-webflux/README.md new file mode 100644 index 0000000000..d2b63b2186 --- /dev/null +++ b/spring-reactive-modules/spring-reactive-webflux/README.md @@ -0,0 +1,23 @@ +### Spring Reactive Articles that are also part of the e-book + +This module contains articles about Spring Reactive that are also part of an Ebook. + +## Spring Reactive + +This module contains articles describing reactive processing in Spring. + +## Relevant articles: + +- [Intro To Reactor Core](https://www.baeldung.com/reactor-core) +- [Debugging Reactive Streams in Java](https://www.baeldung.com/spring-debugging-reactive-streams) +- [Guide to Spring 5 WebFlux](https://www.baeldung.com/spring-webflux) +- [Introduction to the Functional Web Framework in Spring 5](https://www.baeldung.com/spring-5-functional-web) +- [Spring 5 WebClient](https://www.baeldung.com/spring-5-webclient) +- [Spring WebClient vs. RestTemplate](https://www.baeldung.com/spring-webclient-resttemplate) +- [Spring WebClient Requests with Parameters](https://www.baeldung.com/webflux-webclient-parameters) +- [Spring Security 5 for Reactive Applications](https://www.baeldung.com/spring-security-5-reactive) +- [Concurrency in Spring WebFlux](https://www.baeldung.com/spring-webflux-concurrency) + +### NOTE: + +Since this is a module tied to an e-book, it should **not** be moved or used to store the code for any further article. diff --git a/spring-reactive-modules/spring-reactive-webflux/pom.xml b/spring-reactive-modules/spring-reactive-webflux/pom.xml new file mode 100644 index 0000000000..cecaeff20c --- /dev/null +++ b/spring-reactive-modules/spring-reactive-webflux/pom.xml @@ -0,0 +1,112 @@ + + + 4.0.0 + spring-reactive-webflux + + + com.baeldung + parent-boot-3 + 0.0.1-SNAPSHOT + ../../parent-boot-3 + + + + + org.springframework.boot + spring-boot-starter-webflux + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.boot + spring-boot-starter-security + + + io.reactivex.rxjava2 + rxjava + ${rxjava.version} + + + io.projectreactor.kafka + reactor-kafka + ${reactor-kafka.version} + + + org.springframework.boot + spring-boot-starter-data-mongodb-reactive + + + org.springframework.security + spring-security-test + test + + + io.projectreactor + reactor-test + ${reactor.version} + test + + + org.projectlombok + lombok + + + + + + integration-lite-first + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${project.basedir}/src/test/resources/logback-test.xml + + + + + + + + integration-lite-second + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${project.basedir}/src/test/resources/logback-test.xml + + + + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + + + 3.4.16 + 1.3.10 + 2.2.21 + + + \ No newline at end of file diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/concurrency/Application.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/concurrency/Application.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/concurrency/Application.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/concurrency/Application.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/concurrency/Controller.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/concurrency/Controller.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/concurrency/Controller.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/concurrency/Controller.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/concurrency/Person.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/concurrency/Person.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/concurrency/Person.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/concurrency/Person.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/concurrency/PersonRepository.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/concurrency/PersonRepository.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/concurrency/PersonRepository.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/concurrency/PersonRepository.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/ConsumerDebuggingApplication.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/ConsumerDebuggingApplication.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/ConsumerDebuggingApplication.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/ConsumerDebuggingApplication.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/controllers/ReactiveConfigsToggleRestController.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/controllers/ReactiveConfigsToggleRestController.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/controllers/ReactiveConfigsToggleRestController.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/controllers/ReactiveConfigsToggleRestController.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/cronjobs/CronJobs.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/cronjobs/CronJobs.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/cronjobs/CronJobs.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/cronjobs/CronJobs.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/model/Foo.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/model/Foo.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/model/Foo.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/model/Foo.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/model/FooDto.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/model/FooDto.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/model/FooDto.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/model/FooDto.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/service/FooNameHelper.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/service/FooNameHelper.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/service/FooNameHelper.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/service/FooNameHelper.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/service/FooQuantityHelper.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/service/FooQuantityHelper.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/service/FooQuantityHelper.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/service/FooQuantityHelper.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/service/FooReporter.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/service/FooReporter.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/service/FooReporter.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/service/FooReporter.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/service/FooService.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/service/FooService.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/consumer/service/FooService.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/consumer/service/FooService.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/server/ServerDebuggingApplication.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/server/ServerDebuggingApplication.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/server/ServerDebuggingApplication.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/server/ServerDebuggingApplication.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/server/handlers/ServerHandler.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/server/handlers/ServerHandler.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/server/handlers/ServerHandler.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/server/handlers/ServerHandler.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/server/model/Foo.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/server/model/Foo.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/server/model/Foo.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/server/model/Foo.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/server/routers/ServerRouter.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/server/routers/ServerRouter.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/debugging/server/routers/ServerRouter.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/debugging/server/routers/ServerRouter.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/security/GreetingController.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/security/GreetingController.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/security/GreetingController.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/security/GreetingController.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/security/GreetingService.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/security/GreetingService.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/security/GreetingService.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/security/GreetingService.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/security/SecurityConfig.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/security/SecurityConfig.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/security/SecurityConfig.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/security/SecurityConfig.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/security/SpringSecurity6Application.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/security/SpringSecurity6Application.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/security/SpringSecurity6Application.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/security/SpringSecurity6Application.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webclient/Foo.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webclient/Foo.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webclient/Foo.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webclient/Foo.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webclient/Tweet.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webclient/Tweet.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webclient/Tweet.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webclient/Tweet.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webclient/TweetsSlowServiceController.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webclient/TweetsSlowServiceController.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webclient/TweetsSlowServiceController.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webclient/TweetsSlowServiceController.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webclient/WebClientApplication.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webclient/WebClientApplication.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webclient/WebClientApplication.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webclient/WebClientApplication.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webclient/WebClientController.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webclient/WebClientController.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webclient/WebClientController.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webclient/WebClientController.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webclient/WebController.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webclient/WebController.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webclient/WebController.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webclient/WebController.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webclientrequests/SpringWebClientRequestsApp.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webclientrequests/SpringWebClientRequestsApp.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webclientrequests/SpringWebClientRequestsApp.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webclientrequests/SpringWebClientRequestsApp.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webflux/Employee.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webflux/Employee.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webflux/Employee.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webflux/Employee.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webflux/EmployeeRepository.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webflux/EmployeeRepository.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webflux/EmployeeRepository.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webflux/EmployeeRepository.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webflux/annotation/EmployeeController.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webflux/annotation/EmployeeController.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webflux/annotation/EmployeeController.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webflux/annotation/EmployeeController.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webflux/annotation/EmployeeSpringApplication.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webflux/annotation/EmployeeSpringApplication.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webflux/annotation/EmployeeSpringApplication.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webflux/annotation/EmployeeSpringApplication.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webflux/annotation/EmployeeWebClient.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webflux/annotation/EmployeeWebClient.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webflux/annotation/EmployeeWebClient.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webflux/annotation/EmployeeWebClient.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webflux/annotation/EmployeeWebSecurityConfig.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webflux/annotation/EmployeeWebSecurityConfig.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webflux/annotation/EmployeeWebSecurityConfig.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webflux/annotation/EmployeeWebSecurityConfig.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webflux/functional/EmployeeFunctionalConfig.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webflux/functional/EmployeeFunctionalConfig.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webflux/functional/EmployeeFunctionalConfig.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webflux/functional/EmployeeFunctionalConfig.java diff --git a/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webflux/functional/EmployeeSpringFunctionalApplication.java b/spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webflux/functional/EmployeeSpringFunctionalApplication.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/webflux/functional/EmployeeSpringFunctionalApplication.java rename to spring-reactive-modules/spring-reactive-webflux/src/main/java/com/baeldung/reactive/webflux/functional/EmployeeSpringFunctionalApplication.java diff --git a/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/debugging/consumer/ConsumerFooServiceIntegrationTest.java b/spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/debugging/consumer/ConsumerFooServiceIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/debugging/consumer/ConsumerFooServiceIntegrationTest.java rename to spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/debugging/consumer/ConsumerFooServiceIntegrationTest.java diff --git a/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/debugging/consumer/ConsumerFooServiceLiveTest.java b/spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/debugging/consumer/ConsumerFooServiceLiveTest.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/debugging/consumer/ConsumerFooServiceLiveTest.java rename to spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/debugging/consumer/ConsumerFooServiceLiveTest.java diff --git a/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/debugging/consumer/utils/ListAppender.java b/spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/debugging/consumer/utils/ListAppender.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/debugging/consumer/utils/ListAppender.java rename to spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/debugging/consumer/utils/ListAppender.java diff --git a/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/introduction/ReactorIntegrationTest.java b/spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/introduction/ReactorIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/introduction/ReactorIntegrationTest.java rename to spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/introduction/ReactorIntegrationTest.java diff --git a/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/security/SecurityIntegrationTest.java b/spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/security/SecurityIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/security/SecurityIntegrationTest.java rename to spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/security/SecurityIntegrationTest.java diff --git a/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/webclient/SpringContextTest.java b/spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/webclient/SpringContextTest.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/webclient/SpringContextTest.java rename to spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/webclient/SpringContextTest.java diff --git a/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebClientIntegrationTest.java b/spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/webclient/WebClientIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebClientIntegrationTest.java rename to spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/webclient/WebClientIntegrationTest.java diff --git a/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebControllerIntegrationTest.java b/spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/webclient/WebControllerIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebControllerIntegrationTest.java rename to spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/webclient/WebControllerIntegrationTest.java diff --git a/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebTestClientIntegrationTest.java b/spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/webclient/WebTestClientIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/webclient/WebTestClientIntegrationTest.java rename to spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/webclient/WebTestClientIntegrationTest.java diff --git a/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/webclientrequests/WebClientRequestsWithParametersUnitTest.java b/spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/webclientrequests/WebClientRequestsWithParametersUnitTest.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/webclientrequests/WebClientRequestsWithParametersUnitTest.java rename to spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/webclientrequests/WebClientRequestsWithParametersUnitTest.java diff --git a/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/webflux/annotation/EmployeeControllerIntegrationTest.java b/spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/webflux/annotation/EmployeeControllerIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/webflux/annotation/EmployeeControllerIntegrationTest.java rename to spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/webflux/annotation/EmployeeControllerIntegrationTest.java diff --git a/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/webflux/functional/EmployeeSpringFunctionalIntegrationTest.java b/spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/webflux/functional/EmployeeSpringFunctionalIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/webflux/functional/EmployeeSpringFunctionalIntegrationTest.java rename to spring-reactive-modules/spring-reactive-webflux/src/test/java/com/baeldung/reactive/webflux/functional/EmployeeSpringFunctionalIntegrationTest.java diff --git a/spring-reactive-modules/spring-reactive/src/test/resources/logback-test.xml b/spring-reactive-modules/spring-reactive-webflux/src/test/resources/logback-test.xml similarity index 100% rename from spring-reactive-modules/spring-reactive/src/test/resources/logback-test.xml rename to spring-reactive-modules/spring-reactive-webflux/src/test/resources/logback-test.xml diff --git a/spring-reactive-modules/spring-5-reactive/.gitignore b/spring-reactive-modules/spring-reactive/.gitignore similarity index 100% rename from spring-reactive-modules/spring-5-reactive/.gitignore rename to spring-reactive-modules/spring-reactive/.gitignore diff --git a/spring-reactive-modules/spring-reactive/README.md b/spring-reactive-modules/spring-reactive/README.md index 7dfc7b2952..f3148fe696 100644 --- a/spring-reactive-modules/spring-reactive/README.md +++ b/spring-reactive-modules/spring-reactive/README.md @@ -1,24 +1,14 @@ -### Spring Reactive Articles that are also part of the e-book +## Spring 5 Reactive Project -This module contains articles about Spring Reactive that are also part of an Ebook. +This module contains articles about reactive Spring 5 -## Spring Reactive +### The Course +The "REST With Spring" Classes: https://bit.ly/restwithspring -This module contains articles describing reactive processing in Spring. +### Relevant Articles -## Relevant articles: - -- [Intro To Reactor Core](https://www.baeldung.com/reactor-core) -- [Debugging Reactive Streams in Java](https://www.baeldung.com/spring-debugging-reactive-streams) -- [Guide to Spring 5 WebFlux](https://www.baeldung.com/spring-webflux) -- [Introduction to the Functional Web Framework in Spring 5](https://www.baeldung.com/spring-5-functional-web) -- [Spring 5 WebClient](https://www.baeldung.com/spring-5-webclient) -- [Spring WebClient vs. RestTemplate](https://www.baeldung.com/spring-webclient-resttemplate) -- [Spring WebClient Requests with Parameters](https://www.baeldung.com/webflux-webclient-parameters) -- [Handling Errors in Spring WebFlux](https://www.baeldung.com/spring-webflux-errors) -- [Spring Security 5 for Reactive Applications](https://www.baeldung.com/spring-security-5-reactive) -- [Concurrency in Spring WebFlux](https://www.baeldung.com/spring-webflux-concurrency) - -### NOTE: - -Since this is a module tied to an e-book, it should **not** be moved or used to store the code for any further article. +- [Exploring the Spring 5 WebFlux URL Matching](https://www.baeldung.com/spring-5-mvc-url-matching) +- [Reactive WebSockets with Spring 5](https://www.baeldung.com/spring-5-reactive-websockets) +- [How to Set a Header on a Response with Spring 5](https://www.baeldung.com/spring-response-header) +- [A Guide to Spring Session Reactive Support: WebSession](https://www.baeldung.com/spring-session-reactive) +- More articles: [[next -->]](../spring-5-reactive-2) diff --git a/spring-reactive-modules/spring-reactive/pom.xml b/spring-reactive-modules/spring-reactive/pom.xml index f19809e302..f843e04c7b 100644 --- a/spring-reactive-modules/spring-reactive/pom.xml +++ b/spring-reactive-modules/spring-reactive/pom.xml @@ -4,40 +4,71 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-reactive + 0.0.1-SNAPSHOT + spring-5-reactive + jar + spring 5 sample project about new features - com.baeldung - parent-boot-3 - 0.0.1-SNAPSHOT - ../../parent-boot-3 + com.baeldung.spring.reactive + spring-reactive-modules + 1.0.0-SNAPSHOT - - org.springframework.boot - spring-boot-starter-webflux - org.springframework.boot spring-boot-starter-validation org.springframework.boot - spring-boot-starter-security - - - io.reactivex.rxjava2 - rxjava - ${rxjava.version} - - - io.projectreactor.kafka - reactor-kafka - ${reactor-kafka.version} + spring-boot-starter-tomcat org.springframework.boot - spring-boot-starter-data-mongodb-reactive + spring-boot-starter-integration + + + org.springframework.boot + spring-boot-starter-websocket + + + javax.json.bind + javax.json.bind-api + + + org.projectlombok + lombok + compile + + + org.apache.geronimo.specs + geronimo-json_1.1_spec + ${geronimo-json_1.1_spec.version} + + + org.apache.johnzon + johnzon-jsonb + + + + org.apache.commons + commons-lang3 + + + + org.springframework.boot + spring-boot-devtools + runtime + + + org.springframework + spring-test + + + org.springframework.boot + spring-boot-starter-test + test org.springframework.security @@ -47,66 +78,88 @@ io.projectreactor reactor-test - ${reactor.version} + test + + + + org.springframework.boot + spring-boot-starter-webflux + + + org.springframework.boot + spring-boot-starter-data-redis + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.session + spring-session-core + + + org.springframework.session + spring-session-data-redis + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} test - org.projectlombok - lombok + io.reactivex.rxjava2 + rxjava + + + org.apache.httpcomponents + httpclient + + + io.netty + netty-all - - - integration-lite-first - - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${project.basedir}/src/test/resources/logback-test.xml - - - - - - - - integration-lite-second - - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${project.basedir}/src/test/resources/logback-test.xml - - - - - - - - + + maven-resources-plugin + 3.0.1 + + + copy-resources + validate + + copy-resources + + + + + src/main/assets + true + + + ${basedir}/target/classes/assets + + + + org.springframework.boot spring-boot-maven-plugin - true + com.baeldung.reactive.Spring5ReactiveApplication + JAR - 3.4.16 - 1.3.10 - 2.2.21 + 1.1.3 + 1.0 + 1.0 \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-reactive/src/main/assets/index.html b/spring-reactive-modules/spring-reactive/src/main/assets/index.html similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/assets/index.html rename to spring-reactive-modules/spring-reactive/src/main/assets/index.html diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/functional/Actor.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/functional/Actor.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/functional/Actor.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/functional/Actor.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/functional/FormHandler.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/functional/FormHandler.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/functional/FormHandler.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/functional/FormHandler.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/functional/FunctionalSpringBootApplication.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/functional/FunctionalSpringBootApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/functional/FunctionalSpringBootApplication.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/functional/FunctionalSpringBootApplication.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/functional/FunctionalWebApplication.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/functional/FunctionalWebApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/functional/FunctionalWebApplication.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/functional/FunctionalWebApplication.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/functional/IndexRewriteFilter.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/functional/IndexRewriteFilter.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/functional/IndexRewriteFilter.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/functional/IndexRewriteFilter.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/functional/RootServlet.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/functional/RootServlet.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/functional/RootServlet.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/functional/RootServlet.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/Spring5ReactiveApplication.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/Spring5ReactiveApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/Spring5ReactiveApplication.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/Spring5ReactiveApplication.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/controller/FooReactiveController.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/controller/FooReactiveController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/controller/FooReactiveController.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/controller/FooReactiveController.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/controller/PathPatternController.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/controller/PathPatternController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/controller/PathPatternController.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/controller/PathPatternController.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/model/Foo.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/model/Foo.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/model/Foo.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/model/Foo.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/responseheaders/controllers/ResponseHeaderController.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/responseheaders/controllers/ResponseHeaderController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/responseheaders/controllers/ResponseHeaderController.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/responseheaders/controllers/ResponseHeaderController.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/responseheaders/filter/AddResponseHeaderWebFilter.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/responseheaders/filter/AddResponseHeaderWebFilter.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/responseheaders/filter/AddResponseHeaderWebFilter.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/responseheaders/filter/AddResponseHeaderWebFilter.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/responseheaders/functional/handlers/ResponseHeaderHandler.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/responseheaders/functional/handlers/ResponseHeaderHandler.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/responseheaders/functional/handlers/ResponseHeaderHandler.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/responseheaders/functional/handlers/ResponseHeaderHandler.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/responseheaders/functional/routers/ResponseHeadersRouterFunctions.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/responseheaders/functional/routers/ResponseHeadersRouterFunctions.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/responseheaders/functional/routers/ResponseHeadersRouterFunctions.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/responseheaders/functional/routers/ResponseHeadersRouterFunctions.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/Actor.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/urlmatch/Actor.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/Actor.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/urlmatch/Actor.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/ExploreSpring5URLPatternUsingRouterFunctions.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/urlmatch/ExploreSpring5URLPatternUsingRouterFunctions.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/ExploreSpring5URLPatternUsingRouterFunctions.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/urlmatch/ExploreSpring5URLPatternUsingRouterFunctions.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/FormHandler.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/urlmatch/FormHandler.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/FormHandler.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/urlmatch/FormHandler.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/FunctionalWebApplication.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/urlmatch/FunctionalWebApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/FunctionalWebApplication.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/urlmatch/FunctionalWebApplication.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/IndexRewriteFilter.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/urlmatch/IndexRewriteFilter.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/urlmatch/IndexRewriteFilter.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/urlmatch/IndexRewriteFilter.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/util/CpuUtils.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/util/CpuUtils.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/reactive/util/CpuUtils.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/reactive/util/CpuUtils.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websession/Application.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websession/Application.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websession/Application.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websession/Application.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websession/configuration/RedisConfig.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websession/configuration/RedisConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websession/configuration/RedisConfig.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websession/configuration/RedisConfig.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websession/configuration/SessionConfig.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websession/configuration/SessionConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websession/configuration/SessionConfig.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websession/configuration/SessionConfig.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websession/configuration/WebFluxConfig.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websession/configuration/WebFluxConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websession/configuration/WebFluxConfig.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websession/configuration/WebFluxConfig.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websession/configuration/WebFluxSecurityConfig.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websession/configuration/WebFluxSecurityConfig.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websession/configuration/WebFluxSecurityConfig.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websession/configuration/WebFluxSecurityConfig.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websession/controller/SessionController.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websession/controller/SessionController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websession/controller/SessionController.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websession/controller/SessionController.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websession/transfer/CustomResponse.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websession/transfer/CustomResponse.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websession/transfer/CustomResponse.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websession/transfer/CustomResponse.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websocket/Event.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websocket/Event.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websocket/Event.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websocket/Event.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websocket/ReactiveJavaClientWebSocket.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websocket/ReactiveJavaClientWebSocket.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websocket/ReactiveJavaClientWebSocket.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websocket/ReactiveJavaClientWebSocket.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websocket/ReactiveWebSocketApplication.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websocket/ReactiveWebSocketApplication.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websocket/ReactiveWebSocketApplication.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websocket/ReactiveWebSocketApplication.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websocket/ReactiveWebSocketConfiguration.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websocket/ReactiveWebSocketConfiguration.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websocket/ReactiveWebSocketConfiguration.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websocket/ReactiveWebSocketConfiguration.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websocket/ReactiveWebSocketHandler.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websocket/ReactiveWebSocketHandler.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websocket/ReactiveWebSocketHandler.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websocket/ReactiveWebSocketHandler.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websocket/WebSocketController.java b/spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websocket/WebSocketController.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/java/com/baeldung/websocket/WebSocketController.java rename to spring-reactive-modules/spring-reactive/src/main/java/com/baeldung/websocket/WebSocketController.java diff --git a/spring-reactive-modules/spring-5-reactive/src/main/resources/application.properties b/spring-reactive-modules/spring-reactive/src/main/resources/application.properties similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/resources/application.properties rename to spring-reactive-modules/spring-reactive/src/main/resources/application.properties diff --git a/spring-reactive-modules/spring-5-reactive/src/main/resources/files/hello.txt b/spring-reactive-modules/spring-reactive/src/main/resources/files/hello.txt similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/resources/files/hello.txt rename to spring-reactive-modules/spring-reactive/src/main/resources/files/hello.txt diff --git a/spring-reactive-modules/spring-5-reactive/src/main/resources/files/test/test.txt b/spring-reactive-modules/spring-reactive/src/main/resources/files/test/test.txt similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/resources/files/test/test.txt rename to spring-reactive-modules/spring-reactive/src/main/resources/files/test/test.txt diff --git a/spring-reactive-modules/spring-reactive/src/main/resources/logback.xml b/spring-reactive-modules/spring-reactive/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/spring-reactive-modules/spring-reactive/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/spring-reactive-modules/spring-5-reactive/src/main/resources/resources/test/test.txt b/spring-reactive-modules/spring-reactive/src/main/resources/resources/test/test.txt similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/resources/resources/test/test.txt rename to spring-reactive-modules/spring-reactive/src/main/resources/resources/test/test.txt diff --git a/spring-reactive-modules/spring-5-reactive/src/main/resources/static/client-websocket.html b/spring-reactive-modules/spring-reactive/src/main/resources/static/client-websocket.html similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/resources/static/client-websocket.html rename to spring-reactive-modules/spring-reactive/src/main/resources/static/client-websocket.html diff --git a/spring-reactive-modules/spring-5-reactive/src/main/webapp/WEB-INF/web.xml b/spring-reactive-modules/spring-reactive/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/main/webapp/WEB-INF/web.xml rename to spring-reactive-modules/spring-reactive/src/main/webapp/WEB-INF/web.xml diff --git a/spring-reactive-modules/spring-5-reactive/src/test/java/com/baeldung/SpringContextTest.java b/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/test/java/com/baeldung/SpringContextTest.java rename to spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-reactive-modules/spring-5-reactive/src/test/java/com/baeldung/functional/FunctionalWebApplicationIntegrationTest.java b/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/functional/FunctionalWebApplicationIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/test/java/com/baeldung/functional/FunctionalWebApplicationIntegrationTest.java rename to spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/functional/FunctionalWebApplicationIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive/src/test/java/com/baeldung/reactive/FluxUnitTest.java b/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/FluxUnitTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/test/java/com/baeldung/reactive/FluxUnitTest.java rename to spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/FluxUnitTest.java diff --git a/spring-reactive-modules/spring-5-reactive/src/test/java/com/baeldung/reactive/responseheaders/ResponseHeaderLiveTest.java b/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/responseheaders/ResponseHeaderLiveTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/test/java/com/baeldung/reactive/responseheaders/ResponseHeaderLiveTest.java rename to spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/responseheaders/ResponseHeaderLiveTest.java diff --git a/spring-reactive-modules/spring-5-reactive/src/test/java/com/baeldung/reactive/urlmatch/ExploreSpring5URLPatternUsingRouterFunctionsIntegrationTest.java b/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/urlmatch/ExploreSpring5URLPatternUsingRouterFunctionsIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/test/java/com/baeldung/reactive/urlmatch/ExploreSpring5URLPatternUsingRouterFunctionsIntegrationTest.java rename to spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/urlmatch/ExploreSpring5URLPatternUsingRouterFunctionsIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive/src/test/java/com/baeldung/reactive/urlmatch/PathPatternsUsingHandlerMethodIntegrationTest.java b/spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/urlmatch/PathPatternsUsingHandlerMethodIntegrationTest.java similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/test/java/com/baeldung/reactive/urlmatch/PathPatternsUsingHandlerMethodIntegrationTest.java rename to spring-reactive-modules/spring-reactive/src/test/java/com/baeldung/reactive/urlmatch/PathPatternsUsingHandlerMethodIntegrationTest.java diff --git a/spring-reactive-modules/spring-5-reactive/src/test/resources/baeldung-weekly.png b/spring-reactive-modules/spring-reactive/src/test/resources/baeldung-weekly.png similarity index 100% rename from spring-reactive-modules/spring-5-reactive/src/test/resources/baeldung-weekly.png rename to spring-reactive-modules/spring-reactive/src/test/resources/baeldung-weekly.png diff --git a/spring-reactive-modules/spring-reactor/pom.xml b/spring-reactive-modules/spring-reactor/pom.xml index 22eaa898bd..c2635765f0 100644 --- a/spring-reactive-modules/spring-reactor/pom.xml +++ b/spring-reactive-modules/spring-reactor/pom.xml @@ -37,7 +37,6 @@
- 2.0.2.RELEASE 2.0.8.RELEASE diff --git a/spring-vault/README.md b/spring-vault/README.md index 9e1d14ba6b..22fb0a7ff2 100644 --- a/spring-vault/README.md +++ b/spring-vault/README.md @@ -5,3 +5,4 @@ This module contains articles about Spring Vault ### Relevant Articles: - [Spring Vault](https://www.baeldung.com/spring-vault) +- [Secure Kubernetes Secrets with Vault](https://www.baeldung.com/spring-vault-kubernetes-secrets) diff --git a/testing-modules/junit-5-basics-2/README.md b/testing-modules/junit-5-basics-2/README.md index f5e2558332..0e0faedb4b 100644 --- a/testing-modules/junit-5-basics-2/README.md +++ b/testing-modules/junit-5-basics-2/README.md @@ -1,2 +1,2 @@ ### Relevant Articles: -- [Test Main Method with JUnit](http://www.baeldung.com/junit-5) +- [Test Main Method with JUnit](https://www.baeldung.com/junit-test-main-method) diff --git a/testing-modules/mockito-2/README.md b/testing-modules/mockito-2/README.md index 82c97305f6..b60885c6d5 100644 --- a/testing-modules/mockito-2/README.md +++ b/testing-modules/mockito-2/README.md @@ -7,3 +7,4 @@ This module contains articles about Mockito - [Resolving Mockito Exception: Wanted But Not Invoked](https://www.baeldung.com/mockito-exception-wanted-but-not-invoked) - [Matching Null With Mockito](https://www.baeldung.com/mockito-match-null) - [Mock Same Method with Different Parameters](https://www.baeldung.com/java-mock-same-method-other-parameters) +- [How to Mock Constructors for Unit Testing using Mockito](https://www.baeldung.com/java-mockito-constructors-unit-testing) diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/construction/CoffeeMachine.java b/testing-modules/mockito-2/src/main/java/com/baeldung/construction/CoffeeMachine.java new file mode 100644 index 0000000000..5cf1d4eecb --- /dev/null +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/construction/CoffeeMachine.java @@ -0,0 +1,23 @@ +package com.baeldung.construction; + +public class CoffeeMachine { + + private Grinder grinder; + private WaterTank tank; + + public CoffeeMachine() { + this.grinder = new Grinder(); + this.tank = new WaterTank(); + } + + public CoffeeMachine(int mils) { + this.grinder = new Grinder(); + this.tank = new WaterTank(mils); + } + + public String makeCoffee() { + String type = this.tank.isEspresso() ? "Espresso" : "Americano"; + return String.format("Finished making a delicious %s made with %s beans", type, this.grinder.getBeans()); + } + +} diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/construction/Fruit.java b/testing-modules/mockito-2/src/main/java/com/baeldung/construction/Fruit.java new file mode 100644 index 0000000000..c63f28d25f --- /dev/null +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/construction/Fruit.java @@ -0,0 +1,12 @@ +package com.baeldung.construction; + +public class Fruit { + + public String getName() { + return "Apple"; + } + + public String getColour() { + return "Red"; + } +} diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/construction/Grinder.java b/testing-modules/mockito-2/src/main/java/com/baeldung/construction/Grinder.java new file mode 100644 index 0000000000..e62b690bb2 --- /dev/null +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/construction/Grinder.java @@ -0,0 +1,19 @@ +package com.baeldung.construction; + +public class Grinder { + + private String beans; + + public Grinder() { + this.beans = "Guatemalan"; + } + + public String getBeans() { + return beans; + } + + public void setBeans(String beans) { + this.beans = beans; + } + +} \ No newline at end of file diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/construction/WaterTank.java b/testing-modules/mockito-2/src/main/java/com/baeldung/construction/WaterTank.java new file mode 100644 index 0000000000..bf744930a0 --- /dev/null +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/construction/WaterTank.java @@ -0,0 +1,27 @@ +package com.baeldung.construction; + +public class WaterTank { + + private int mils; + + public WaterTank() { + this.mils = 25; + } + + public WaterTank(int mils) { + this.mils = mils; + } + + public int getMils() { + return mils; + } + + public void setMils(int mils) { + this.mils = mils; + } + + public boolean isEspresso() { + return getMils() < 50; + } + +} diff --git a/testing-modules/mockito-2/src/test/java/com/baeldung/construction/CoffeeMachineUnitTest.java b/testing-modules/mockito-2/src/test/java/com/baeldung/construction/CoffeeMachineUnitTest.java new file mode 100644 index 0000000000..7b93ad9db6 --- /dev/null +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/construction/CoffeeMachineUnitTest.java @@ -0,0 +1,56 @@ +package com.baeldung.construction; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.mockConstruction; +import static org.mockito.Mockito.when; + +import org.junit.jupiter.api.Test; +import org.mockito.MockedConstruction; + +class CoffeeMachineUnitTest { + + @Test + void givenNoMockedContructor_whenCoffeeMade_thenRealDependencyReturned() { + CoffeeMachine machine = new CoffeeMachine(); + assertEquals("Finished making a delicious Espresso made with Guatemalan beans", machine.makeCoffee()); + } + + @Test + void givenMockedContructor_whenCoffeeMade_thenMockDependencyReturned() { + try (MockedConstruction mockTank = mockConstruction(WaterTank.class); MockedConstruction mockGrinder = mockConstruction(Grinder.class)) { + + CoffeeMachine machine = new CoffeeMachine(); + + WaterTank tank = mockTank.constructed() + .get(0); + Grinder grinder = mockGrinder.constructed() + .get(0); + + when(tank.isEspresso()).thenReturn(false); + when(grinder.getBeans()).thenReturn("Peruvian"); + + assertEquals("Finished making a delicious Americano made with Peruvian beans", machine.makeCoffee()); + } + + } + + @Test + void givenMockedContructorWithArgument_whenCoffeeMade_thenMockDependencyReturned() { + try (MockedConstruction mockTank = mockConstruction(WaterTank.class, (mock, context) -> { + int mils = (int) context.arguments().get(0); + when(mock.getMils()).thenReturn(mils); + }); + MockedConstruction mockGrinder = mockConstruction(Grinder.class)) { + + CoffeeMachine machine = new CoffeeMachine(100); + + Grinder grinder = mockGrinder.constructed() + .get(0); + + when(grinder.getBeans()).thenReturn("Kenyan"); + assertEquals("Finished making a delicious Americano made with Kenyan beans", machine.makeCoffee()); + } + + } + +} diff --git a/testing-modules/mockito-2/src/test/java/com/baeldung/construction/FruitUnitTest.java b/testing-modules/mockito-2/src/test/java/com/baeldung/construction/FruitUnitTest.java new file mode 100644 index 0000000000..c7baa1cc7d --- /dev/null +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/construction/FruitUnitTest.java @@ -0,0 +1,50 @@ +package com.baeldung.construction; + +import org.junit.jupiter.api.Test; +import org.mockito.Answers; +import org.mockito.MockedConstruction; + +import static org.mockito.Mockito.when; +import static org.mockito.Mockito.withSettings; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.List; + +import static org.mockito.Mockito.mockConstruction; + +class FruitUnitTest { + + @Test + void givenMockedContructor_whenFruitCreated_thenMockIsReturned() { + assertEquals("Apple", new Fruit().getName()); + assertEquals("Red", new Fruit().getColour()); + + try (MockedConstruction mock = mockConstruction(Fruit.class)) { + + Fruit fruit = new Fruit(); + when(fruit.getName()).thenReturn("Banana"); + when(fruit.getColour()).thenReturn("Yellow"); + + assertEquals("Banana", fruit.getName()); + assertEquals("Yellow", fruit.getColour()); + + List constructed = mock.constructed(); + assertEquals(1, constructed.size()); + } + } + + @Test + void givenMockedContructorWithNewDefaultAnswer_whenFruitCreated_thenRealMethodInvoked() { + try (MockedConstruction mock = mockConstruction(Fruit.class, withSettings().defaultAnswer(Answers.CALLS_REAL_METHODS))) { + + Fruit fruit = new Fruit(); + + assertEquals("Apple", fruit.getName()); + assertEquals("Red", fruit.getColour()); + + List constructed = mock.constructed(); + assertEquals(1, constructed.size()); + } + } + +} diff --git a/testing-modules/testing-assertions/README.md b/testing-modules/testing-assertions/README.md index 37de3d4929..8f94277791 100644 --- a/testing-modules/testing-assertions/README.md +++ b/testing-modules/testing-assertions/README.md @@ -5,3 +5,4 @@ - [Assert That a Java Optional Has a Certain Value](https://www.baeldung.com/java-optional-assert-value) - [Assert That an Object Is From a Specific Type](https://www.baeldung.com/java-assert-object-of-type) - [Asserting Equality on Two Classes Without an equals() Method](https://www.baeldung.com/java-assert-equality-no-equals) +- [Assert Regex Matches in JUnit](https://www.baeldung.com/junit-assert-regex-matches)