diff --git a/.gitignore b/.gitignore index 78125cc3ee..c54117203f 100644 --- a/.gitignore +++ b/.gitignore @@ -85,3 +85,5 @@ transaction.log *-shell.log apache-cxf/cxf-aegis/baeldung.xml + +libraries-2/*.db \ No newline at end of file diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/jgrapht/GraphImageGenerationUnitTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/jgrapht/GraphImageGenerationUnitTest.java index 3b841d574a..a0d7523f48 100644 --- a/algorithms-miscellaneous-2/src/test/java/com/baeldung/jgrapht/GraphImageGenerationUnitTest.java +++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/jgrapht/GraphImageGenerationUnitTest.java @@ -1,16 +1,21 @@ package com.baeldung.jgrapht; import static org.junit.Assert.assertTrue; + import java.awt.Color; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; + import javax.imageio.ImageIO; + import org.jgrapht.ext.JGraphXAdapter; import org.jgrapht.graph.DefaultDirectedGraph; import org.jgrapht.graph.DefaultEdge; +import org.junit.After; import org.junit.Before; import org.junit.Test; + import com.mxgraph.layout.mxCircleLayout; import com.mxgraph.layout.mxIGraphLayout; import com.mxgraph.util.mxCellRenderer; @@ -20,7 +25,7 @@ public class GraphImageGenerationUnitTest { @Before public void createGraph() throws IOException { - File imgFile = new File("src/test/resources/graph.png"); + File imgFile = new File("src/test/resources/graph1.png"); imgFile.createNewFile(); g = new DefaultDirectedGraph(DefaultEdge.class); String x1 = "x1"; @@ -34,12 +39,18 @@ public class GraphImageGenerationUnitTest { g.addEdge(x3, x1); } + @After + public void cleanup() { + File imgFile = new File("src/test/resources/graph1.png"); + imgFile.deleteOnExit(); + } + @Test public void givenAdaptedGraph_whenWriteBufferedImage_ThenFileShouldExist() throws IOException { JGraphXAdapter graphAdapter = new JGraphXAdapter(g); mxIGraphLayout layout = new mxCircleLayout(graphAdapter); layout.execute(graphAdapter.getDefaultParent()); - File imgFile = new File("src/test/resources/graph.png"); + File imgFile = new File("src/test/resources/graph1.png"); BufferedImage image = mxCellRenderer.createBufferedImage(graphAdapter, null, 2, Color.WHITE, true, null); ImageIO.write(image, "PNG", imgFile); assertTrue(imgFile.exists()); diff --git a/apache-libraries/pom.xml b/apache-libraries/pom.xml index fc655967ed..9f800f1e0b 100644 --- a/apache-libraries/pom.xml +++ b/apache-libraries/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - apache-miscellaneous-1 + apache-libraries 0.0.1-SNAPSHOT apache-libraries diff --git a/aws-app-sync/pom.xml b/aws-app-sync/pom.xml index 4c55d38d77..5ef150de01 100644 --- a/aws-app-sync/pom.xml +++ b/aws-app-sync/pom.xml @@ -13,10 +13,6 @@ ../parent-boot-2 - - 1.8 - - diff --git a/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml b/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml index 8706bd3b53..4d64307558 100644 --- a/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml +++ b/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.example cf-uaa-oauth2-client - uaa-client-webapp + cf-uaa-oauth2-client Demo project for Spring Boot diff --git a/core-java-modules/core-java-8-datetime-2/pom.xml b/core-java-modules/core-java-8-datetime-2/pom.xml index f66a89ca55..0e60941cc7 100644 --- a/core-java-modules/core-java-8-datetime-2/pom.xml +++ b/core-java-modules/core-java-8-datetime-2/pom.xml @@ -6,7 +6,7 @@ 4.0.0 core-java-8-datetime-2 ${project.parent.version} - core-java-8-datetime + core-java-8-datetime-2 jar com.baeldung.core-java-modules diff --git a/core-java-modules/core-java-9-new-features/src/test/java/com/baeldung/java9/currentmethod/CurrentExecutingMethodUnitTest.java b/core-java-modules/core-java-9-new-features/src/test/java/com/baeldung/java9/currentmethod/CurrentExecutingMethodUnitTest.java new file mode 100644 index 0000000000..6a130834e0 --- /dev/null +++ b/core-java-modules/core-java-9-new-features/src/test/java/com/baeldung/java9/currentmethod/CurrentExecutingMethodUnitTest.java @@ -0,0 +1,23 @@ +package com.baeldung.java9.currentmethod; + +import org.junit.Test; + +import java.util.Optional; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class CurrentExecutingMethodUnitTest { + + @Test + public void givenJava9_whenWalkingTheStack_thenFindMethod() { + StackWalker walker = StackWalker.getInstance(); + Optional methodName = walker.walk(frames -> frames + .findFirst() + .map(StackWalker.StackFrame::getMethodName) + ); + + assertTrue(methodName.isPresent()); + assertEquals("givenJava9_whenWalkingTheStack_thenFindMethod", methodName.get()); + } +} diff --git a/core-java-modules/core-java-arrays-operations-basic/pom.xml b/core-java-modules/core-java-arrays-operations-basic/pom.xml index 73588d662a..64856d9b39 100644 --- a/core-java-modules/core-java-arrays-operations-basic/pom.xml +++ b/core-java-modules/core-java-arrays-operations-basic/pom.xml @@ -13,32 +13,6 @@ core-java-arrays-operations-basic jar - - - - org.apache.maven.plugins - maven-shade-plugin - ${shade.plugin.version} - - - package - - shade - - - benchmarks - - - org.openjdk.jmh.Main - - - - - - - - - org.apache.commons @@ -66,6 +40,32 @@ + + + + org.apache.maven.plugins + maven-shade-plugin + ${shade.plugin.version} + + + package + + shade + + + benchmarks + + + org.openjdk.jmh.Main + + + + + + + + + 3.2.0 diff --git a/core-java-modules/core-java-arrays-sorting/pom.xml b/core-java-modules/core-java-arrays-sorting/pom.xml index d5e2beaac4..9b307870a1 100644 --- a/core-java-modules/core-java-arrays-sorting/pom.xml +++ b/core-java-modules/core-java-arrays-sorting/pom.xml @@ -14,32 +14,6 @@ core-java-arrays-sorting jar - - - - org.apache.maven.plugins - maven-shade-plugin - ${shade.plugin.version} - - - package - - shade - - - benchmarks - - - org.openjdk.jmh.Main - - - - - - - - - @@ -74,6 +48,32 @@ + + + + org.apache.maven.plugins + maven-shade-plugin + ${shade.plugin.version} + + + package + + shade + + + benchmarks + + + org.openjdk.jmh.Main + + + + + + + + + 3.2.0 diff --git a/core-java-modules/core-java-concurrency-basic-2/src/main/java/com/baeldung/concurrent/localvariables/LocalAndLambda.java b/core-java-modules/core-java-concurrency-basic-2/src/main/java/com/baeldung/concurrent/localvariables/LocalAndLambda.java new file mode 100644 index 0000000000..d8e0815797 --- /dev/null +++ b/core-java-modules/core-java-concurrency-basic-2/src/main/java/com/baeldung/concurrent/localvariables/LocalAndLambda.java @@ -0,0 +1,10 @@ +package com.baeldung.concurrent.localvariables; + +public class LocalAndLambda { + public static void main(String... args) { + String text = ""; + // Un-commenting the next line will break compilation, because text is no longer effectively final + // text = "675"; + new Thread(() -> System.out.println(text)).start(); + } +} diff --git a/core-java-modules/core-java-concurrency-basic-2/src/main/java/com/baeldung/concurrent/localvariables/LocalVariables.java b/core-java-modules/core-java-concurrency-basic-2/src/main/java/com/baeldung/concurrent/localvariables/LocalVariables.java new file mode 100644 index 0000000000..39cae8da81 --- /dev/null +++ b/core-java-modules/core-java-concurrency-basic-2/src/main/java/com/baeldung/concurrent/localvariables/LocalVariables.java @@ -0,0 +1,20 @@ +package com.baeldung.concurrent.localvariables; + +import java.security.SecureRandom; + +public class LocalVariables implements Runnable { + private int field; + + public static void main(String... args) { + LocalVariables target = new LocalVariables(); + new Thread(target).start(); + new Thread(target).start(); + } + + @Override + public void run() { + field = new SecureRandom().nextInt(); + int local = new SecureRandom().nextInt(); + System.out.println(field + " - " + local); + } +} diff --git a/core-java-modules/core-java-exceptions-2/pom.xml b/core-java-modules/core-java-exceptions-2/pom.xml index a53bf37b77..4497874640 100644 --- a/core-java-modules/core-java-exceptions-2/pom.xml +++ b/core-java-modules/core-java-exceptions-2/pom.xml @@ -33,7 +33,6 @@ http://maven.apache.org - UTF-8 3.10 3.10.0 diff --git a/core-java-modules/core-java-exceptions-2/src/test/java/com/baeldung/exceptionininitializererror/ExceptionInInitializerErrorUnitTest.java b/core-java-modules/core-java-exceptions-2/src/test/java/com/baeldung/exceptionininitializererror/ExceptionInInitializerErrorUnitTest.java new file mode 100644 index 0000000000..352d5ab50e --- /dev/null +++ b/core-java-modules/core-java-exceptions-2/src/test/java/com/baeldung/exceptionininitializererror/ExceptionInInitializerErrorUnitTest.java @@ -0,0 +1,55 @@ +package com.baeldung.exceptionininitializererror; + +import org.junit.Test; + +import java.lang.reflect.Constructor; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class ExceptionInInitializerErrorUnitTest { + + @Test + public void givenStaticVar_whenThrows_thenWrapsItInAnExceptionInInitializerError() { + assertThatThrownBy(StaticVar::new) + .isInstanceOf(ExceptionInInitializerError.class) + .hasCauseInstanceOf(RuntimeException.class); + } + + @Test + public void givenStaticBlock_whenThrows_thenWrapsItInAnExceptionInInitializerError() { + assertThatThrownBy(StaticBlock::new) + .isInstanceOf(ExceptionInInitializerError.class) + .hasCauseInstanceOf(ArithmeticException.class); + } + + private static class CheckedConvention { + + private static Constructor constructor; + + static { + try { + constructor = CheckedConvention.class.getDeclaredConstructor(); + } catch (NoSuchMethodException e) { + throw new ExceptionInInitializerError(e); + } + } + } + + private static class StaticVar { + + private static int state = initializeState(); + + private static int initializeState() { + throw new RuntimeException(); + } + } + + private static class StaticBlock { + + private static int state; + + static { + state = 42 / 0; + } + } +} diff --git a/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/Course.java b/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/Course.java new file mode 100644 index 0000000000..cbe2eed47f --- /dev/null +++ b/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/Course.java @@ -0,0 +1,10 @@ +package com.baeldung.objectsize; + +public class Course { + + private String name; + + public Course(String name) { + this.name = name; + } +} diff --git a/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/InstrumentedSize.java b/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/InstrumentedSize.java new file mode 100644 index 0000000000..54177caf30 --- /dev/null +++ b/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/InstrumentedSize.java @@ -0,0 +1,11 @@ +package com.baeldung.objectsize; + +public class InstrumentedSize { + + public static void main(String[] args) { + String ds = "Data Structures"; + Course course = new Course(ds); + + System.out.println(ObjectSizeCalculator.sizeOf(course)); + } +} diff --git a/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/MANIFEST.MF b/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/MANIFEST.MF new file mode 100644 index 0000000000..5366581b2f --- /dev/null +++ b/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/MANIFEST.MF @@ -0,0 +1 @@ +Premain-Class: com.baeldung.objectsize.ObjectSizeCalculator diff --git a/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/ObjectSizeCalculator.java b/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/ObjectSizeCalculator.java new file mode 100644 index 0000000000..9c1e4c96a0 --- /dev/null +++ b/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/ObjectSizeCalculator.java @@ -0,0 +1,16 @@ +package com.baeldung.objectsize; + +import java.lang.instrument.Instrumentation; + +public class ObjectSizeCalculator { + + private static Instrumentation instrumentation; + + public static void premain(String args, Instrumentation inst) { + instrumentation = inst; + } + + public static long sizeOf(Object o) { + return instrumentation.getObjectSize(o); + } +} diff --git a/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/ObjectSizeUnitTest.java b/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/ObjectSizeUnitTest.java new file mode 100644 index 0000000000..f2ba748d84 --- /dev/null +++ b/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/ObjectSizeUnitTest.java @@ -0,0 +1,40 @@ +package com.baeldung.objectsize; + +import org.junit.Test; +import org.openjdk.jol.info.ClassLayout; +import org.openjdk.jol.info.GraphLayout; +import org.openjdk.jol.vm.VM; + +public class ObjectSizeUnitTest { + + @Test + public void printingTheVMDetails() { + System.out.println(VM.current().details()); + } + + @Test + public void printingTheProfClassLayout() { + System.out.println(ClassLayout.parseClass(Professor.class).toPrintable()); + } + + @Test + public void printingTheCourseClassLayout() { + System.out.println(ClassLayout.parseClass(Course.class).toPrintable()); + } + + @Test + public void printingACourseInstanceLayout() { + String ds = "Data Structures"; + Course course = new Course(ds); + + System.out.println("The shallow size is :" + VM.current().sizeOf(course)); + + System.out.println(ClassLayout.parseInstance(course).toPrintable()); + System.out.println(ClassLayout.parseInstance(ds).toPrintable()); + System.out.println(ClassLayout.parseInstance(ds.toCharArray()).toPrintable()); + + System.out.println(GraphLayout.parseInstance(course).totalSize()); + System.out.println(GraphLayout.parseInstance(course).toFootprint()); + System.out.println(GraphLayout.parseInstance(course).toPrintable()); + } +} diff --git a/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/Professor.java b/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/Professor.java new file mode 100644 index 0000000000..6cd421f273 --- /dev/null +++ b/core-java-modules/core-java-jvm-2/src/test/java/com/baeldung/objectsize/Professor.java @@ -0,0 +1,24 @@ +package com.baeldung.objectsize; + +import java.time.LocalDate; +import java.util.List; + +public class Professor { + + private String name; + private boolean tenured; + private List courses; + private int level; + private LocalDate birthDay; + private double lastEvaluation; + + public Professor(String name, boolean tenured, List courses, + int level, LocalDate birthDay, double lastEvaluation) { + this.name = name; + this.tenured = tenured; + this.courses = courses; + this.level = level; + this.birthDay = birthDay; + this.lastEvaluation = lastEvaluation; + } +} diff --git a/core-java-modules/core-java-lang-2/README.md b/core-java-modules/core-java-lang-2/README.md index 635746251f..c043d29811 100644 --- a/core-java-modules/core-java-lang-2/README.md +++ b/core-java-modules/core-java-lang-2/README.md @@ -13,4 +13,4 @@ This module contains articles about core features in the Java language - [Comparing Long Values in Java](https://www.baeldung.com/java-compare-long-values) - [Comparing Objects in Java](https://www.baeldung.com/java-comparing-objects) - [Casting int to Enum in Java](https://www.baeldung.com/java-cast-int-to-enum) -- [[<-- Prev]](/core-java-modules/core-java-lang) +[[ <-- Prev]](/core-java-modules/core-java-lang)[[Next --> ]](/core-java-modules/core-java-lang-3) diff --git a/core-java-modules/core-java-lang-3/README.md b/core-java-modules/core-java-lang-3/README.md new file mode 100644 index 0000000000..f496b74bfb --- /dev/null +++ b/core-java-modules/core-java-lang-3/README.md @@ -0,0 +1,5 @@ +## Core Java Lang (Part 3) + +This module contains articles about core features in the Java language + +- [[<-- Prev]](/core-java-modules/core-java-lang-2) diff --git a/core-java-modules/core-java-lang-3/pom.xml b/core-java-modules/core-java-lang-3/pom.xml new file mode 100644 index 0000000000..2a2856a80a --- /dev/null +++ b/core-java-modules/core-java-lang-3/pom.xml @@ -0,0 +1,42 @@ + + + 4.0.0 + core-java-lang-3 + 0.1.0-SNAPSHOT + core-java-lang-3 + jar + + + com.baeldung.core-java-modules + core-java-modules + 0.0.1-SNAPSHOT + ../ + + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + core-java-lang-3 + + + src/main/resources + true + + + + + + 3.12.2 + + + diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/IsoscelesTriangle.java b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/isinstancevsisassignablefrom/IsoscelesTriangle.java similarity index 100% rename from core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/IsoscelesTriangle.java rename to core-java-modules/core-java-lang-3/src/main/java/com/baeldung/isinstancevsisassignablefrom/IsoscelesTriangle.java diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/Shape.java b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/isinstancevsisassignablefrom/Shape.java similarity index 100% rename from core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/Shape.java rename to core-java-modules/core-java-lang-3/src/main/java/com/baeldung/isinstancevsisassignablefrom/Shape.java diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/Triangle.java b/core-java-modules/core-java-lang-3/src/main/java/com/baeldung/isinstancevsisassignablefrom/Triangle.java similarity index 100% rename from core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/Triangle.java rename to core-java-modules/core-java-lang-3/src/main/java/com/baeldung/isinstancevsisassignablefrom/Triangle.java diff --git a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/isinstancevsisassignablefrom/IsInstanceIsAssignableFromUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/isinstancevsisassignablefrom/IsInstanceIsAssignableFromUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-2/src/test/java/com/baeldung/isinstancevsisassignablefrom/IsInstanceIsAssignableFromUnitTest.java rename to core-java-modules/core-java-lang-3/src/test/java/com/baeldung/isinstancevsisassignablefrom/IsInstanceIsAssignableFromUnitTest.java diff --git a/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/stringtoboolean/StringToBooleanUnitTest.java b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/stringtoboolean/StringToBooleanUnitTest.java new file mode 100644 index 0000000000..8b10d78fe3 --- /dev/null +++ b/core-java-modules/core-java-lang-3/src/test/java/com/baeldung/stringtoboolean/StringToBooleanUnitTest.java @@ -0,0 +1,30 @@ +package com.baeldung.stringtoboolean; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Test; + +public class StringToBooleanUnitTest { + + @Test + public void givenStringTrue_whenUsingParseBoolean_thenTrue() { + assertThat(Boolean.parseBoolean("true")).isTrue(); + } + + @Test + public void givenStringTrue_whenUsingValueOf_thenTrue() { + assertThat(Boolean.valueOf("true")).isTrue(); + } + + @Test + public void givenStringTrue_whenUsingGetBoolean_thenFalse() { + assertThat(Boolean.getBoolean("true")).isFalse(); + } + + @Test + public void givenSystemProperty_whenUsingGetBoolean_thenTrue() { + System.setProperty("CODING_IS_FUN", "true"); + + assertThat(Boolean.getBoolean("CODING_IS_FUN")).isTrue(); + } +} diff --git a/core-java-modules/core-java-lang/README.md b/core-java-modules/core-java-lang/README.md index 9166b93b7f..963a1e623e 100644 --- a/core-java-modules/core-java-lang/README.md +++ b/core-java-modules/core-java-lang/README.md @@ -13,4 +13,5 @@ This module contains articles about core features in the Java language - [Retrieving a Class Name in Java](https://www.baeldung.com/java-class-name) - [The Java continue and break Keywords](https://www.baeldung.com/java-continue-and-break) - [Infinite Loops in Java](https://www.baeldung.com/infinite-loops-java) -- [[More --> ]](/core-java-modules/core-java-lang-2) + +[[Next --> ]](/core-java-modules/core-java-lang-2) diff --git a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/countmatches/CountMatchesUnitTest.java b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/countmatches/CountMatchesUnitTest.java new file mode 100644 index 0000000000..6427d11dd6 --- /dev/null +++ b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/countmatches/CountMatchesUnitTest.java @@ -0,0 +1,110 @@ +package com.baeldung.regex.countmatches; + +import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.junit.Test; + +/** + * Unit Test intended to count number of matches of a RegEx using Java 8 and 9. + * + * Java 9 is needed to run the commented out tests. + */ +public class CountMatchesUnitTest { + + private static final Pattern EMAIL_ADDRESS_PATTERN = Pattern.compile("([a-z0-9_.-]+)@([a-z0-9_.-]+[a-z])"); + private static final String TEXT_CONTAINING_EMAIL_ADDRESSES = "You can contact me through: writer@baeldung.com, editor@baeldung.com and team@bealdung.com"; + private static final String TEXT_CONTAINING_FIVE_EMAIL_ADDRESSES = "Valid emails are: me@gmail.com, you@baeldung.com, contact@hotmail.com, press@anysite.com and support@bealdung.com"; + private static final String TEXT_CONTAINING_OVERLAP_EMAIL_ADDRESSES = "Try to contact us at team@baeldung.comeditor@baeldung.com, support@baeldung.com."; + + @Test + public void givenContainingEmailString_whenJava8Match_thenCountMacthesFound() { + Matcher countEmailMatcher = EMAIL_ADDRESS_PATTERN.matcher(TEXT_CONTAINING_EMAIL_ADDRESSES); + + int count = 0; + while (countEmailMatcher.find()) { + count++; + } + + assertEquals(3, count); + } + + @Test + public void givenContainingFiveEmailsString_whenJava8Match_thenCountMacthesFound() { + Matcher countFiveEmailsMatcher = EMAIL_ADDRESS_PATTERN.matcher(TEXT_CONTAINING_FIVE_EMAIL_ADDRESSES); + + int count = 0; + while (countFiveEmailsMatcher.find()) { + count++; + } + + assertEquals(5, count); + } + + @Test + public void givenStringWithoutEmails_whenJava8Match_thenCountMacthesNotFound() { + Matcher noEmailMatcher = EMAIL_ADDRESS_PATTERN.matcher("Simple text without emails."); + + int count = 0; + while (noEmailMatcher.find()) { + count++; + } + + assertEquals(0, count); + } + + @Test + public void givenStringWithOverlappingEmails_whenJava8Match_thenCountWrongMatches() { + Matcher countOverlappingEmailsMatcher = EMAIL_ADDRESS_PATTERN.matcher(TEXT_CONTAINING_OVERLAP_EMAIL_ADDRESSES); + + int count = 0; + while (countOverlappingEmailsMatcher.find()) { + count++; + } + + assertNotEquals(3, count); + } + + @Test + public void givenContainingEmailString_whenStartingInJava9Match_thenCountMacthesFound() { + // uncomment to try with Java 9 + // Matcher countEmailMatcher = EMAIL_ADDRESS_PATTERN.matcher(TEXT_CONTAINING_EMAIL_ADDRESSES); + + // long count = countEmailMatcher.results().count(); + + // assertEquals(3, count); + } + + @Test + public void givenContainingFiveEmailsString_whenStartingInJava9Match_thenCountMacthesFound() { + // uncomment to try with Java 9 + // Matcher countFiveEmailsMatcher = EMAIL_ADDRESS_PATTERN.matcher(TEXT_CONTAINING_FIVE_EMAIL_ADDRESSES); + + // long count = countFiveEmailsMatcher.results().count(); + + // assertEquals(5, count); + } + + @Test + public void givenStringWithoutEmails_whenJava9Match_thenCountMacthesNotFound() { + // uncomment to try with Java 9 + // Matcher noEmailMatcher = EMAIL_ADDRESS_PATTERN.matcher("Simple text without emails."); + + // long count = noEmailMatcher.results().count(); + + // assertEquals(0, count); + } + + @Test + public void givenStringWithOverlappingEmails_whenJava9Match_thenCountWrongMatches() { + // uncomment to try with Java 9 + // Matcher countOverlappingEmailsMatcher = EMAIL_ADDRESS_PATTERN.matcher(TEXT_CONTAINING_OVERLAP_EMAIL_ADDRESSES); + + // long count = countOverlappingEmailsMatcher.results().count(); + + // assertNotEquals(3, count); + } +} diff --git a/core-java-modules/core-java-streams/README.md b/core-java-modules/core-java-streams/README.md index 135e136fee..b950325e40 100644 --- a/core-java-modules/core-java-streams/README.md +++ b/core-java-modules/core-java-streams/README.md @@ -9,7 +9,6 @@ This module contains articles about the Stream API in Java. - [Iterable to Stream in Java](https://www.baeldung.com/java-iterable-to-stream) - [How to Iterate Over a Stream With Indices](https://www.baeldung.com/java-stream-indices) - [Stream Ordering in Java](https://www.baeldung.com/java-stream-ordering) -- [Introduction to Protonpack](https://www.baeldung.com/java-protonpack) - [Java Stream Filter with Lambda Expression](https://www.baeldung.com/java-stream-filter-lambda) - [Counting Matches on a Stream Filter](https://www.baeldung.com/java-stream-filter-count) - [Summing Numbers with Java Streams](https://www.baeldung.com/java-stream-sum) diff --git a/core-java-modules/core-java-string-operations-2/README.md b/core-java-modules/core-java-string-operations-2/README.md index cafb3b9017..d66515d372 100644 --- a/core-java-modules/core-java-string-operations-2/README.md +++ b/core-java-modules/core-java-string-operations-2/README.md @@ -10,7 +10,6 @@ This module contains articles about string operations. - [Java String equalsIgnoreCase()](https://www.baeldung.com/java-string-equalsignorecase) - [Case-Insensitive String Matching in Java](https://www.baeldung.com/java-case-insensitive-string-matching) - [L-Trim and R-Trim Alternatives in Java](https://www.baeldung.com/java-trim-alternatives) -- [Java Convert PDF to Base64](https://www.baeldung.com/java-convert-pdf-to-base64) - [Encode a String to UTF-8 in Java](https://www.baeldung.com/java-string-encode-utf-8) - [Guide to Character Encoding](https://www.baeldung.com/java-char-encoding) - [Convert Hex to ASCII in Java](https://www.baeldung.com/java-convert-hex-to-ascii) #remove additional readme file diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 76fed91251..4757ddea72 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -85,6 +85,7 @@ core-java-lambdas core-java-lang core-java-lang-2 + core-java-lang-3 core-java-lang-math core-java-lang-math-2 core-java-lang-oop-constructors @@ -134,18 +135,6 @@ pre-jpms - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - @@ -163,6 +152,18 @@ + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + 2.22.2 5.6.2 diff --git a/ddd/pom.xml b/ddd/pom.xml index 422f9ccd15..9f960502a3 100644 --- a/ddd/pom.xml +++ b/ddd/pom.xml @@ -17,16 +17,6 @@ ../parent-boot-2 - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - @@ -105,6 +95,16 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + 2.22.2 diff --git a/guava-2/README.md b/guava-2/README.md new file mode 100644 index 0000000000..634c17f0eb --- /dev/null +++ b/guava-2/README.md @@ -0,0 +1,7 @@ +## Guava + +This module contains articles a Google Guava + +### Relevant Articles: +- [Introduction to Guava Throwables](https://www.baeldung.com/guava-throwables) +- [Guava CharMatcher](https://www.baeldung.com/guava-string-charmatcher) diff --git a/guava-2/pom.xml b/guava-2/pom.xml new file mode 100644 index 0000000000..b19f59a9b4 --- /dev/null +++ b/guava-2/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + guava-2 + 0.1.0-SNAPSHOT + guava-2 + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + guava + + + src/main/resources + true + + + + + + + 3.6.1 + + + diff --git a/guava-2/src/test/java/com/baeldung/guava/charmatcher/GuavaCharMatcherUnitTest.java b/guava-2/src/test/java/com/baeldung/guava/charmatcher/GuavaCharMatcherUnitTest.java new file mode 100644 index 0000000000..e60777595e --- /dev/null +++ b/guava-2/src/test/java/com/baeldung/guava/charmatcher/GuavaCharMatcherUnitTest.java @@ -0,0 +1,113 @@ +package com.baeldung.guava.charmatcher; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.nio.charset.Charset; +import java.nio.charset.CharsetEncoder; + +import org.junit.Test; + +import com.google.common.base.CharMatcher; +import com.google.common.base.Predicate; + +public class GuavaCharMatcherUnitTest { + + @Test + public void whenRemoveSpecialCharacters_thenRemoved() { + final String input = "H*el.lo,}12"; + final CharMatcher matcher = CharMatcher.javaLetterOrDigit(); + final String result = matcher.retainFrom(input); + + assertEquals("Hello12", result); + } + + @Test + public void whenRemoveNonASCIIChars_thenRemoved() { + final String input = "あhello₤"; + + String result = CharMatcher.ascii().retainFrom(input); + assertEquals("hello", result); + + result = CharMatcher.inRange('0', 'z').retainFrom(input); + assertEquals("hello", result); + } + + @Test + public void whenValidateString_thenValid() { + final String input = "hello"; + + boolean result = CharMatcher.javaLowerCase().matchesAllOf(input); + assertTrue(result); + + result = CharMatcher.is('e').matchesAnyOf(input); + assertTrue(result); + + result = CharMatcher.javaDigit().matchesNoneOf(input); + assertTrue(result); + } + + @Test + public void whenTrimString_thenTrimmed() { + final String input = "---hello,,,"; + + String result = CharMatcher.is('-').trimLeadingFrom(input); + assertEquals("hello,,,", result); + + result = CharMatcher.is(',').trimTrailingFrom(input); + assertEquals("---hello", result); + + result = CharMatcher.anyOf("-,").trimFrom(input); + assertEquals("hello", result); + } + + @Test + public void whenCollapseFromString_thenCollapsed() { + final String input = " hel lo "; + + String result = CharMatcher.is(' ').collapseFrom(input, '-'); + assertEquals("-hel-lo-", result); + + result = CharMatcher.is(' ').trimAndCollapseFrom(input, '-'); + assertEquals("hel-lo", result); + } + + @Test + public void whenReplaceFromString_thenReplaced() { + final String input = "apple-banana."; + + String result = CharMatcher.anyOf("-.").replaceFrom(input, '!'); + assertEquals("apple!banana!", result); + + result = CharMatcher.is('-').replaceFrom(input, " and "); + assertEquals("apple and banana.", result); + } + + @Test + public void whenCountCharInString_thenCorrect() { + final String input = "a, c, z, 1, 2"; + + int result = CharMatcher.is(',').countIn(input); + assertEquals(4, result); + + result = CharMatcher.inRange('a', 'h').countIn(input); + assertEquals(2, result); + } + + @Test + public void whenRemoveCharsNotInCharset_thenRemoved() { + final Charset charset = Charset.forName("cp437"); + final CharsetEncoder encoder = charset.newEncoder(); + + final Predicate inRange = new Predicate() { + @Override + public boolean apply(final Character c) { + return encoder.canEncode(c); + } + }; + + final String result = CharMatcher.forPredicate(inRange).retainFrom("helloは"); + assertEquals("hello", result); + } + +} diff --git a/guava/src/test/java/com/baeldung/guava/ThrowablesUnitTest.java b/guava-2/src/test/java/com/baeldung/guava/throwables/ThrowablesUnitTest.java similarity index 97% rename from guava/src/test/java/com/baeldung/guava/ThrowablesUnitTest.java rename to guava-2/src/test/java/com/baeldung/guava/throwables/ThrowablesUnitTest.java index 7d33b38a0e..c1707f8903 100644 --- a/guava/src/test/java/com/baeldung/guava/ThrowablesUnitTest.java +++ b/guava-2/src/test/java/com/baeldung/guava/throwables/ThrowablesUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.guava; +package com.baeldung.guava.throwables; import com.google.common.base.Throwables; import org.junit.Test; diff --git a/guava-2/src/test/resources/.gitignore b/guava-2/src/test/resources/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/guava-2/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/guava-2/src/test/resources/test.out b/guava-2/src/test/resources/test.out new file mode 100644 index 0000000000..7a79da3803 --- /dev/null +++ b/guava-2/src/test/resources/test.out @@ -0,0 +1 @@ +John Jane Adam Tom \ No newline at end of file diff --git a/guava-2/src/test/resources/test1.in b/guava-2/src/test/resources/test1.in new file mode 100644 index 0000000000..70c379b63f --- /dev/null +++ b/guava-2/src/test/resources/test1.in @@ -0,0 +1 @@ +Hello world \ No newline at end of file diff --git a/guava-2/src/test/resources/test1_1.in b/guava-2/src/test/resources/test1_1.in new file mode 100644 index 0000000000..8318c86b35 --- /dev/null +++ b/guava-2/src/test/resources/test1_1.in @@ -0,0 +1 @@ +Test \ No newline at end of file diff --git a/guava-2/src/test/resources/test2.in b/guava-2/src/test/resources/test2.in new file mode 100644 index 0000000000..622efea9e6 --- /dev/null +++ b/guava-2/src/test/resources/test2.in @@ -0,0 +1,4 @@ +John +Jane +Adam +Tom \ No newline at end of file diff --git a/guava-2/src/test/resources/test_copy.in b/guava-2/src/test/resources/test_copy.in new file mode 100644 index 0000000000..70c379b63f --- /dev/null +++ b/guava-2/src/test/resources/test_copy.in @@ -0,0 +1 @@ +Hello world \ No newline at end of file diff --git a/guava-2/src/test/resources/test_le.txt b/guava-2/src/test/resources/test_le.txt new file mode 100644 index 0000000000..f7cc484bf4 Binary files /dev/null and b/guava-2/src/test/resources/test_le.txt differ diff --git a/guava-collections-map/pom.xml b/guava-collections-map/pom.xml index 06537d26bd..4a95234d5c 100644 --- a/guava-collections-map/pom.xml +++ b/guava-collections-map/pom.xml @@ -14,6 +14,21 @@ ../parent-java + + + org.junit.jupiter + junit-jupiter + ${junit-jupiter.version} + test + + + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} + test + + + guava-collections-map @@ -33,21 +48,6 @@ - - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - - - 5.6.2 diff --git a/guava-collections-set/pom.xml b/guava-collections-set/pom.xml index 49d96965a7..af46400555 100644 --- a/guava-collections-set/pom.xml +++ b/guava-collections-set/pom.xml @@ -13,18 +13,6 @@ ../parent-java - - guava-collections-set - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - - - @@ -47,6 +35,18 @@ + + guava-collections-set + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + 3.6.1 diff --git a/guava-collections/README.md b/guava-collections/README.md index 17cdb91ef5..51731d7db7 100644 --- a/guava-collections/README.md +++ b/guava-collections/README.md @@ -14,4 +14,3 @@ This module contains articles about Google Guava collections - [Guava – Lists](https://www.baeldung.com/guava-lists) - [Guide to Guava MinMaxPriorityQueue and EvictingQueue](https://www.baeldung.com/guava-minmax-priority-queue-and-evicting-queue) - [Guide to Guava Table](https://www.baeldung.com/guava-table) -- [Guava CharMatcher](https://www.baeldung.com/guava-string-charmatcher) diff --git a/guava-collections/pom.xml b/guava-collections/pom.xml index 744eba1a38..238ab60f84 100644 --- a/guava-collections/pom.xml +++ b/guava-collections/pom.xml @@ -15,25 +15,6 @@ ../parent-java - - guava-collections - - - - src/main/resources - true - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - - - @@ -76,6 +57,25 @@ + + guava-collections + + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + 4.1 diff --git a/guava-collections/src/test/java/com/baeldung/guava/joinsplit/GuavaStringUnitTest.java b/guava-collections/src/test/java/com/baeldung/guava/joinsplit/GuavaStringUnitTest.java index 0c480d02a0..d1dd4af3bb 100644 --- a/guava-collections/src/test/java/com/baeldung/guava/joinsplit/GuavaStringUnitTest.java +++ b/guava-collections/src/test/java/com/baeldung/guava/joinsplit/GuavaStringUnitTest.java @@ -4,20 +4,19 @@ import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import java.nio.charset.Charset; -import java.nio.charset.CharsetEncoder; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; -import com.google.common.collect.*; import org.junit.Test; -import com.google.common.base.CharMatcher; import com.google.common.base.Function; import com.google.common.base.Joiner; -import com.google.common.base.Predicate; import com.google.common.base.Splitter; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; public class GuavaStringUnitTest { @@ -113,102 +112,4 @@ public class GuavaStringUnitTest { assertEquals(4, result.size()); assertThat(result, contains("a", "b", "c", "d,e")); } - - @Test - public void whenRemoveSpecialCharacters_thenRemoved() { - final String input = "H*el.lo,}12"; - final CharMatcher matcher = CharMatcher.javaLetterOrDigit(); - final String result = matcher.retainFrom(input); - - assertEquals("Hello12", result); - } - - @Test - public void whenRemoveNonASCIIChars_thenRemoved() { - final String input = "あhello₤"; - - String result = CharMatcher.ascii().retainFrom(input); - assertEquals("hello", result); - - result = CharMatcher.inRange('0', 'z').retainFrom(input); - assertEquals("hello", result); - } - - @Test - public void whenValidateString_thenValid() { - final String input = "hello"; - - boolean result = CharMatcher.javaLowerCase().matchesAllOf(input); - assertTrue(result); - - result = CharMatcher.is('e').matchesAnyOf(input); - assertTrue(result); - - result = CharMatcher.javaDigit().matchesNoneOf(input); - assertTrue(result); - } - - @Test - public void whenTrimString_thenTrimmed() { - final String input = "---hello,,,"; - - String result = CharMatcher.is('-').trimLeadingFrom(input); - assertEquals("hello,,,", result); - - result = CharMatcher.is(',').trimTrailingFrom(input); - assertEquals("---hello", result); - - result = CharMatcher.anyOf("-,").trimFrom(input); - assertEquals("hello", result); - } - - @Test - public void whenCollapseFromString_thenCollapsed() { - final String input = " hel lo "; - - String result = CharMatcher.is(' ').collapseFrom(input, '-'); - assertEquals("-hel-lo-", result); - - result = CharMatcher.is(' ').trimAndCollapseFrom(input, '-'); - assertEquals("hel-lo", result); - } - - @Test - public void whenReplaceFromString_thenReplaced() { - final String input = "apple-banana."; - - String result = CharMatcher.anyOf("-.").replaceFrom(input, '!'); - assertEquals("apple!banana!", result); - - result = CharMatcher.is('-').replaceFrom(input, " and "); - assertEquals("apple and banana.", result); - } - - @Test - public void whenCountCharInString_thenCorrect() { - final String input = "a, c, z, 1, 2"; - - int result = CharMatcher.is(',').countIn(input); - assertEquals(4, result); - - result = CharMatcher.inRange('a', 'h').countIn(input); - assertEquals(2, result); - } - - @Test - public void whenRemoveCharsNotInCharset_thenRemoved() { - final Charset charset = Charset.forName("cp437"); - final CharsetEncoder encoder = charset.newEncoder(); - - final Predicate inRange = new Predicate() { - @Override - public boolean apply(final Character c) { - return encoder.canEncode(c); - } - }; - - final String result = CharMatcher.forPredicate(inRange).retainFrom("helloは"); - assertEquals("hello", result); - } - } diff --git a/guava-io/pom.xml b/guava-io/pom.xml index fd637f2474..e01f76e2e3 100644 --- a/guava-io/pom.xml +++ b/guava-io/pom.xml @@ -16,6 +16,21 @@ ../parent-java + + + org.junit.jupiter + junit-jupiter + ${junit-jupiter.version} + test + + + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} + test + + + guava-io @@ -35,18 +50,4 @@ - - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - - \ No newline at end of file diff --git a/guava-modules/pom.xml b/guava-modules/pom.xml index 4e7282364d..d1a2bbc16e 100644 --- a/guava-modules/pom.xml +++ b/guava-modules/pom.xml @@ -22,16 +22,6 @@ guava-21 - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - - - org.junit.jupiter @@ -46,4 +36,15 @@ test + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + diff --git a/guava/README.md b/guava/README.md index 9c650dbc1d..720aba274d 100644 --- a/guava/README.md +++ b/guava/README.md @@ -12,5 +12,4 @@ This module contains articles a Google Guava - [Guide to Mathematical Utilities in Guava](https://www.baeldung.com/guava-math) - [Bloom Filter in Java using Guava](https://www.baeldung.com/guava-bloom-filter) - [Quick Guide to the Guava RateLimiter](https://www.baeldung.com/guava-rate-limiter) -- [Introduction to Guava Throwables](https://www.baeldung.com/guava-throwables) - [Guava Cache](https://www.baeldung.com/guava-cache) diff --git a/guava/pom.xml b/guava/pom.xml index 881390ae73..2c4ff07c84 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -15,25 +15,6 @@ ../parent-java - - guava - - - - src/main/resources - true - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - - - org.apache.commons @@ -62,6 +43,25 @@ + + guava + + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + 5.6.2 diff --git a/image-processing/pom.xml b/image-processing/pom.xml index 8fe161337c..f2551598d5 100644 --- a/image-processing/pom.xml +++ b/image-processing/pom.xml @@ -60,6 +60,27 @@ tesseract-platform ${tesseract-platform.version} + + org.imgscalr + imgscalr-lib + ${imgscalr-version} + + + net.coobird + thumbnailator + ${thumbnailator-version} + + + com.github.downgoon + marvin + ${marvin-version} + pom + + + com.github.downgoon + MarvinPlugins + ${marvin-version} + @@ -69,6 +90,9 @@ 4.5.1 4.1.0-1.5.2 3.4.2-0 + 4.2 + 0.4.11 + 1.5.5 \ No newline at end of file diff --git a/image-processing/src/main/java/com/baeldung/image/resize/core/Graphics2DExample.java b/image-processing/src/main/java/com/baeldung/image/resize/core/Graphics2DExample.java new file mode 100644 index 0000000000..d52a2dac1b --- /dev/null +++ b/image-processing/src/main/java/com/baeldung/image/resize/core/Graphics2DExample.java @@ -0,0 +1,25 @@ +package com.baeldung.image.resize.core; + +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class Graphics2DExample { + + static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) { + BufferedImage resizedImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB); + Graphics2D graphics2D = resizedImage.createGraphics(); + graphics2D.drawImage(originalImage, 0, 0, targetWidth, targetHeight, null); + graphics2D.dispose(); + return resizedImage; + } + + public static void main(String[] args) throws IOException { + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = resizeImage(originalImage, 200, 200); + ImageIO.write(outputImage, "jpg", new File("src/main/resources/images/sampleImage-resized-graphics2d.jpg")); + } +} diff --git a/image-processing/src/main/java/com/baeldung/image/resize/core/ImageScaledInstanceExample.java b/image-processing/src/main/java/com/baeldung/image/resize/core/ImageScaledInstanceExample.java new file mode 100644 index 0000000000..a6e252f3eb --- /dev/null +++ b/image-processing/src/main/java/com/baeldung/image/resize/core/ImageScaledInstanceExample.java @@ -0,0 +1,24 @@ +package com.baeldung.image.resize.core; + +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +public class ImageScaledInstanceExample { + static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) { + Image resultingImage = originalImage.getScaledInstance(targetWidth, targetHeight, Image.SCALE_DEFAULT); + BufferedImage bufferedImage = new BufferedImage(targetWidth, targetHeight, BufferedImage.TYPE_INT_RGB); + bufferedImage.getGraphics() + .drawImage(resultingImage, 0, 0, null); + return bufferedImage; + } + + public static void main(String[] args) throws IOException { + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = resizeImage(originalImage, 200, 200); + ImageIO.write(outputImage, "jpg", new File("src/main/resources/images/sampleImage-resized-scaledinstance.jpg")); + } +} diff --git a/image-processing/src/main/java/com/baeldung/image/resize/imgscalr/ImgscalrExample.java b/image-processing/src/main/java/com/baeldung/image/resize/imgscalr/ImgscalrExample.java new file mode 100644 index 0000000000..10d4217de6 --- /dev/null +++ b/image-processing/src/main/java/com/baeldung/image/resize/imgscalr/ImgscalrExample.java @@ -0,0 +1,24 @@ +package com.baeldung.image.resize.imgscalr; + +import java.awt.image.BufferedImage; +import java.io.File; + +import javax.imageio.ImageIO; + +import org.imgscalr.Scalr; + +public class ImgscalrExample { + public static BufferedImage simpleResizeImage(BufferedImage originalImage, int targetWidth) { + return Scalr.resize(originalImage, targetWidth); + } + + public static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) { + return Scalr.resize(originalImage, Scalr.Method.AUTOMATIC, Scalr.Mode.AUTOMATIC, targetWidth, targetHeight, Scalr.OP_ANTIALIAS); + } + + public static void main(String[] args) throws Exception { + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = resizeImage(originalImage, 200, 200); + ImageIO.write(outputImage, "jpg", new File("src/main/resources/images/sampleImage-resized-imgscalr.jpg")); + } +} diff --git a/image-processing/src/main/java/com/baeldung/image/resize/marvin/MarvinExample.java b/image-processing/src/main/java/com/baeldung/image/resize/marvin/MarvinExample.java new file mode 100644 index 0000000000..9a7233c4f4 --- /dev/null +++ b/image-processing/src/main/java/com/baeldung/image/resize/marvin/MarvinExample.java @@ -0,0 +1,29 @@ +package com.baeldung.image.resize.marvin; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import org.marvinproject.image.transform.scale.Scale; + +import marvin.image.MarvinImage; + +public class MarvinExample { + static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) { + MarvinImage image = new MarvinImage(originalImage); + Scale scale = new Scale(); + scale.load(); + scale.setAttribute("newWidth", targetWidth); + scale.setAttribute("newHeight", targetHeight); + scale.process(image.clone(), image, null, null, false); + return image.getBufferedImageNoAlpha(); + } + + public static void main(String args[]) throws IOException { + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = resizeImage(originalImage, 200, 200); + ImageIO.write(outputImage, "jpg", new File("src/main/resources/images/sampleImage-resized-marvin.jpg")); + } +} diff --git a/image-processing/src/main/java/com/baeldung/image/resize/thumbnailator/ThumbnailatorExample.java b/image-processing/src/main/java/com/baeldung/image/resize/thumbnailator/ThumbnailatorExample.java new file mode 100644 index 0000000000..2296c1649d --- /dev/null +++ b/image-processing/src/main/java/com/baeldung/image/resize/thumbnailator/ThumbnailatorExample.java @@ -0,0 +1,31 @@ +package com.baeldung.image.resize.thumbnailator; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import net.coobird.thumbnailator.Thumbnails; + +public class ThumbnailatorExample { + static BufferedImage resizeImage(BufferedImage originalImage, int targetWidth, int targetHeight) throws IOException { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + Thumbnails.of(originalImage) + .size(targetWidth, targetHeight) + .outputFormat("JPEG") + .outputQuality(0.90) + .toOutputStream(outputStream); + byte[] data = outputStream.toByteArray(); + ByteArrayInputStream inputStream = new ByteArrayInputStream(data); + return ImageIO.read(inputStream); + } + + public static void main(String[] args) throws Exception { + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = resizeImage(originalImage, 200, 200); + ImageIO.write(outputImage, "jpg", new File("src/main/resources/images/sampleImage-resized-thumbnailator.jpg")); + } +} diff --git a/image-processing/src/test/java/com/baeldung/image/resize/core/Graphics2DExampleUnitTest.java b/image-processing/src/test/java/com/baeldung/image/resize/core/Graphics2DExampleUnitTest.java new file mode 100644 index 0000000000..675a17366d --- /dev/null +++ b/image-processing/src/test/java/com/baeldung/image/resize/core/Graphics2DExampleUnitTest.java @@ -0,0 +1,71 @@ +package com.baeldung.image.resize.core; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import org.junit.Test; + +public class Graphics2DExampleUnitTest { + + @Test(expected = Test.None.class) + public void whenOriginalImageExistsAndTargetSizesAreNotZero_thenImageGeneratedWithoutError() throws IOException { + int targetWidth = 200; + int targetHeight = 200; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = Graphics2DExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertNotNull(outputImage); + } + + @Test(expected = Test.None.class) + public void whenOriginalImageExistsAndTargetSizesAreNotZero_thenOutputImageSizeIsValid() throws IOException { + int targetWidth = 200; + int targetHeight = 200; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + assertNotEquals(originalImage.getWidth(), targetWidth); + assertNotEquals(originalImage.getHeight(), targetHeight); + BufferedImage outputImage = Graphics2DExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertEquals(outputImage.getWidth(), targetWidth); + assertEquals(outputImage.getHeight(), targetHeight); + } + + @Test(expected = Exception.class) + public void whenTargetWidthIsZero_thenErrorIsThrown() throws IOException { + int targetWidth = 0; + int targetHeight = 200; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = Graphics2DExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertNull(outputImage); + } + + @Test(expected = Exception.class) + public void whenTargetHeightIsZero_thenErrorIsThrown() throws IOException { + int targetWidth = 200; + int targetHeight = 0; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = Graphics2DExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertNull(outputImage); + } + + @Test(expected = Test.None.class) + public void whenOriginalImageDoesNotExist_thenErrorIsNotThrownAndImageIsGenerated() throws IOException { + int targetWidth = 200; + int targetHeight = 200; + BufferedImage outputImage = Graphics2DExample.resizeImage(null, targetWidth, targetHeight); + + assertNotNull(outputImage); + assertEquals(outputImage.getWidth(), targetWidth); + assertEquals(outputImage.getHeight(), targetHeight); + } +} diff --git a/image-processing/src/test/java/com/baeldung/image/resize/core/ImageScaledInstanceExampleUnitTest.java b/image-processing/src/test/java/com/baeldung/image/resize/core/ImageScaledInstanceExampleUnitTest.java new file mode 100644 index 0000000000..b0ac5a7787 --- /dev/null +++ b/image-processing/src/test/java/com/baeldung/image/resize/core/ImageScaledInstanceExampleUnitTest.java @@ -0,0 +1,69 @@ +package com.baeldung.image.resize.core; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import org.junit.Test; + +public class ImageScaledInstanceExampleUnitTest { + + @Test(expected = Test.None.class) + public void whenOriginalImageExistsAndTargetSizesAreNotZero_thenImageGeneratedWithoutError() throws IOException { + int targetWidth = 200; + int targetHeight = 200; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = ImageScaledInstanceExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertNotNull(outputImage); + } + + @Test(expected = Test.None.class) + public void whenOriginalImageExistsAndTargetSizesAreNotZero_thenOutputImageSizeIsValid() throws IOException { + int targetWidth = 200; + int targetHeight = 200; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + assertNotEquals(originalImage.getWidth(), targetWidth); + assertNotEquals(originalImage.getHeight(), targetHeight); + BufferedImage outputImage = ImageScaledInstanceExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertEquals(outputImage.getWidth(), targetWidth); + assertEquals(outputImage.getHeight(), targetHeight); + } + + @Test(expected = Exception.class) + public void whenTargetWidthIsZero_thenErrorIsThrown() throws IOException { + int targetWidth = 0; + int targetHeight = 200; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = ImageScaledInstanceExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertNull(outputImage); + } + + @Test(expected = Exception.class) + public void whenTargetHeightIsZero_thenErrorIsThrown() throws IOException { + int targetWidth = 200; + int targetHeight = 0; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = ImageScaledInstanceExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertNull(outputImage); + } + + @Test(expected = Exception.class) + public void whenOriginalImageDoesNotExist_thenErrorIsThrown() throws IOException { + int targetWidth = 200; + int targetHeight = 200; + BufferedImage outputImage = ImageScaledInstanceExample.resizeImage(null, targetWidth, targetHeight); + + assertNull(outputImage); + } +} diff --git a/image-processing/src/test/java/com/baeldung/image/resize/imgscalr/ImgscalrExampleUnitTest.java b/image-processing/src/test/java/com/baeldung/image/resize/imgscalr/ImgscalrExampleUnitTest.java new file mode 100644 index 0000000000..e38850da21 --- /dev/null +++ b/image-processing/src/test/java/com/baeldung/image/resize/imgscalr/ImgscalrExampleUnitTest.java @@ -0,0 +1,69 @@ +package com.baeldung.image.resize.imgscalr; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import org.junit.Test; + +public class ImgscalrExampleUnitTest { + + @Test(expected = Test.None.class) + public void whenOriginalImageExistsAndTargetSizesAreNotZero_thenImageGeneratedWithoutError() throws IOException { + int targetWidth = 200; + int targetHeight = 200; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = ImgscalrExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertNotNull(outputImage); + } + + @Test(expected = Test.None.class) + public void whenOriginalImageExistsAndTargetSizesAreNotZero_thenOutputImageSizeIsValid() throws IOException { + int targetWidth = 200; + int targetHeight = 200; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + assertNotEquals(originalImage.getWidth(), targetWidth); + assertNotEquals(originalImage.getHeight(), targetHeight); + BufferedImage outputImage = ImgscalrExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertEquals(outputImage.getWidth(), targetWidth); + assertEquals(outputImage.getHeight(), targetHeight); + } + + @Test(expected = Test.None.class) + public void whenTargetWidthIsZero_thenImageIsCreated() throws IOException { + int targetWidth = 0; + int targetHeight = 200; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = ImgscalrExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertNotNull(outputImage); + } + + @Test(expected = Test.None.class) + public void whenTargetHeightIsZero_thenImageIsCreated() throws IOException { + int targetWidth = 200; + int targetHeight = 0; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = ImgscalrExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertNotNull(outputImage); + } + + @Test(expected = Exception.class) + public void whenOriginalImageDoesNotExist_thenErrorIsThrown() { + int targetWidth = 200; + int targetHeight = 200; + BufferedImage outputImage = ImgscalrExample.resizeImage(null, targetWidth, targetHeight); + + assertNull(outputImage); + } +} diff --git a/image-processing/src/test/java/com/baeldung/image/resize/marvin/MarvinExampleUnitTest.java b/image-processing/src/test/java/com/baeldung/image/resize/marvin/MarvinExampleUnitTest.java new file mode 100644 index 0000000000..3133a71035 --- /dev/null +++ b/image-processing/src/test/java/com/baeldung/image/resize/marvin/MarvinExampleUnitTest.java @@ -0,0 +1,68 @@ +package com.baeldung.image.resize.marvin; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import org.junit.Test; + +public class MarvinExampleUnitTest { + @Test(expected = Test.None.class) + public void whenOriginalImageExistsAndTargetSizesAreNotZero_thenImageGeneratedWithoutError() throws IOException { + int targetWidth = 200; + int targetHeight = 200; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = MarvinExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertNotNull(outputImage); + } + + @Test(expected = Test.None.class) + public void whenOriginalImageExistsAndTargetSizesAreNotZero_thenOutputImageSizeIsValid() throws IOException { + int targetWidth = 200; + int targetHeight = 200; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + assertNotEquals(originalImage.getWidth(), targetWidth); + assertNotEquals(originalImage.getHeight(), targetHeight); + BufferedImage outputImage = MarvinExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertEquals(outputImage.getWidth(), targetWidth); + assertEquals(outputImage.getHeight(), targetHeight); + } + + @Test(expected = Exception.class) + public void whenTargetWidthIsZero_thenErrorIsThrown() throws IOException { + int targetWidth = 0; + int targetHeight = 200; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = MarvinExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertNull(outputImage); + } + + @Test(expected = Exception.class) + public void whenTargetHeightIsZero_thenErrorIsThrown() throws IOException { + int targetWidth = 200; + int targetHeight = 0; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = MarvinExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertNull(outputImage); + } + + @Test(expected = Exception.class) + public void whenOriginalImageDoesNotExist_thenErrorIsThrown() { + int targetWidth = 200; + int targetHeight = 200; + BufferedImage outputImage = MarvinExample.resizeImage(null, targetWidth, targetHeight); + + assertNull(outputImage); + } +} diff --git a/image-processing/src/test/java/com/baeldung/image/resize/thumbnailator/ThumbnailatorExampleUnitTest.java b/image-processing/src/test/java/com/baeldung/image/resize/thumbnailator/ThumbnailatorExampleUnitTest.java new file mode 100644 index 0000000000..383ac1c7af --- /dev/null +++ b/image-processing/src/test/java/com/baeldung/image/resize/thumbnailator/ThumbnailatorExampleUnitTest.java @@ -0,0 +1,68 @@ +package com.baeldung.image.resize.thumbnailator; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import org.junit.Test; + +public class ThumbnailatorExampleUnitTest { + @Test(expected = Test.None.class) + public void whenOriginalImageExistsAndTargetSizesAreNotZero_thenImageGeneratedWithoutError() throws IOException { + int targetWidth = 200; + int targetHeight = 200; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = ThumbnailatorExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertNotNull(outputImage); + } + + @Test(expected = Test.None.class) + public void whenOriginalImageExistsAndTargetSizesAreNotZero_thenOutputImageSizeIsValid() throws IOException { + int targetWidth = 200; + int targetHeight = 200; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + assertNotEquals(originalImage.getWidth(), targetWidth); + assertNotEquals(originalImage.getHeight(), targetHeight); + BufferedImage outputImage = ThumbnailatorExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertEquals(outputImage.getWidth(), targetWidth); + assertEquals(outputImage.getHeight(), targetHeight); + } + + @Test(expected = Exception.class) + public void whenTargetWidthIsZero_thenErrorIsThrown() throws IOException { + int targetWidth = 0; + int targetHeight = 200; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = ThumbnailatorExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertNull(outputImage); + } + + @Test(expected = Exception.class) + public void whenTargetHeightIsZero_thenErrorIsThrown() throws IOException { + int targetWidth = 200; + int targetHeight = 0; + BufferedImage originalImage = ImageIO.read(new File("src/main/resources/images/sampleImage.jpg")); + BufferedImage outputImage = ThumbnailatorExample.resizeImage(originalImage, targetWidth, targetHeight); + + assertNull(outputImage); + } + + @Test(expected = Exception.class) + public void whenOriginalImageDoesNotExist_thenErrorIsThrown() throws IOException { + int targetWidth = 200; + int targetHeight = 200; + BufferedImage outputImage = ThumbnailatorExample.resizeImage(null, targetWidth, targetHeight); + + assertNull(outputImage); + } +} diff --git a/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/csv/CsvUnitTest.java b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/csv/CsvUnitTest.java index c257cb7dc9..7226eaf27d 100644 --- a/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/csv/CsvUnitTest.java +++ b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/csv/CsvUnitTest.java @@ -7,48 +7,59 @@ import java.io.IOException; import java.nio.charset.Charset; import java.util.List; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; import com.google.common.io.Files; - public class CsvUnitTest { + private File csvFromJson; + private File jsonFromCsv; + private File formattedCsvFromJson; + + @Before + public void setup() { + csvFromJson = new File("src/main/resources/csv/csvFromJson.csv"); + jsonFromCsv = new File("src/main/resources/csv/jsonFromCsv.json"); + formattedCsvFromJson = new File("src/main/resources/csv/formattedCsvFromJson.csv"); + } + + @After + public void cleanup() { + csvFromJson.deleteOnExit(); + jsonFromCsv.deleteOnExit(); + formattedCsvFromJson.deleteOnExit(); + } + @Test public void givenJsonInput_thenWriteCsv() throws JsonParseException, JsonMappingException, IOException { - JsonCsvConverter.JsonToCsv(new File("src/main/resources/csv/orderLines.json"), - new File("src/main/resources/csv/csvFromJson.csv")); - - assertEquals(readFile("src/main/resources/csv/csvFromJson.csv"), - readFile("src/test/resources/csv/expectedCsvFromJson.csv")); + JsonCsvConverter.JsonToCsv(new File("src/main/resources/csv/orderLines.json"), csvFromJson); + + assertEquals(readFile(csvFromJson.getAbsolutePath()), readFile("src/test/resources/csv/expectedCsvFromJson.csv")); } - + @Test public void givenCsvInput_thenWritesJson() throws JsonParseException, JsonMappingException, IOException { - JsonCsvConverter.csvToJson(new File("src/main/resources/csv/orderLines.csv"), - new File("src/main/resources/csv/jsonFromCsv.json")); - - assertEquals(readFile("src/main/resources/csv/jsonFromCsv.json"), - readFile("src/test/resources/csv/expectedJsonFromCsv.json")); - + JsonCsvConverter.csvToJson(new File("src/main/resources/csv/orderLines.csv"), jsonFromCsv); + + assertEquals(readFile(jsonFromCsv.getAbsolutePath()), readFile("src/test/resources/csv/expectedJsonFromCsv.json")); + } - + @Test public void givenJsonInput_thenWriteFormattedCsvOutput() throws JsonParseException, JsonMappingException, IOException { - JsonCsvConverter.JsonToFormattedCsv(new File("src/main/resources/csv/orderLines.json"), - new File("src/main/resources/csv/formattedCsvFromJson.csv")); + JsonCsvConverter.JsonToFormattedCsv(new File("src/main/resources/csv/orderLines.json"), formattedCsvFromJson); + + assertEquals(readFile(formattedCsvFromJson.getAbsolutePath()), readFile("src/test/resources/csv/expectedFormattedCsvFromJson.csv")); - assertEquals(readFile("src/main/resources/csv/formattedCsvFromJson.csv"), - readFile("src/test/resources/csv/expectedFormattedCsvFromJson.csv")); - } - + private List readFile(String filename) throws IOException { return Files.readLines(new File(filename), Charset.forName("utf-8")); } - - -} -; \ No newline at end of file + +}; \ No newline at end of file diff --git a/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/yaml/YamlUnitTest.java b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/yaml/YamlUnitTest.java index 17c487ff26..cfa5afec0d 100644 --- a/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/yaml/YamlUnitTest.java +++ b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/yaml/YamlUnitTest.java @@ -12,6 +12,7 @@ import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; +import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -25,12 +26,19 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature; public class YamlUnitTest { private ObjectMapper mapper; + private File orderOutput; @Before public void setup() { mapper = new ObjectMapper(new YAMLFactory().disable(Feature.WRITE_DOC_START_MARKER)); mapper.findAndRegisterModules(); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + orderOutput = new File("src/test/resources/yaml/orderOutput.yaml"); + } + + @After + public void cleanup() { + orderOutput.deleteOnExit(); } @Test @@ -53,9 +61,9 @@ public class YamlUnitTest { LocalDate.parse("2019-04-18", DateTimeFormatter.ISO_DATE), "Customer, Jane", lines); - mapper.writeValue(new File("src/test/resources/yaml/orderOutput.yaml"), order); + mapper.writeValue(orderOutput, order); - File outputYaml = new File("src/test/resources/yaml/orderOutput.yaml"); + File outputYaml = new File(orderOutput.getAbsolutePath()); assertTrue(outputYaml.exists()); } } diff --git a/jackson-modules/pom.xml b/jackson-modules/pom.xml index 00722510af..70b10e9554 100644 --- a/jackson-modules/pom.xml +++ b/jackson-modules/pom.xml @@ -23,16 +23,6 @@ jackson-exceptions - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - - - com.fasterxml.jackson.core @@ -60,6 +50,16 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + 5.6.2 diff --git a/jackson-simple/pom.xml b/jackson-simple/pom.xml index 1f838bbed0..761dca6afa 100644 --- a/jackson-simple/pom.xml +++ b/jackson-simple/pom.xml @@ -13,25 +13,6 @@ ../parent-java - - jackson-simple - - - - src/main/resources - true - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - - - @@ -61,6 +42,25 @@ + + jackson-simple + + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + 5.6.2 diff --git a/jee-7/pom.xml b/jee-7/pom.xml index a59733fe6e..b0e10c1580 100644 --- a/jee-7/pom.xml +++ b/jee-7/pom.xml @@ -274,10 +274,6 @@ true - - standalone-full.xml - ${project.build.directory}/wildfly-${wildfly.version} - io.undertow @@ -347,15 +343,6 @@ - - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - ${project.build.directory}/wildfly-${wildfly.version} - - - diff --git a/jee-7/src/test/resources/arquillian.xml b/jee-7/src/test/resources/arquillian.xml new file mode 100644 index 0000000000..f4274877fd --- /dev/null +++ b/jee-7/src/test/resources/arquillian.xml @@ -0,0 +1,23 @@ + + + + + target/wildfly-8.2.1.Final + standalone.xml + true + 9990 + -Djboss.http.port=8639 + + + + + + 127.0.0.1 + 9990 + admin + pass + true + + + + \ No newline at end of file diff --git a/libraries-6/README.md b/libraries-6/README.md index 79bb83113e..5f74517ab5 100644 --- a/libraries-6/README.md +++ b/libraries-6/README.md @@ -14,4 +14,5 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Introduction to Functional Java](https://www.baeldung.com/java-functional-library) - [A Guide to the Reflections Library](https://www.baeldung.com/reflections-library) - [Exactly Once Processing in Kafka](https://www.baeldung.com/kafka-exactly-once) +- [Introduction to Protonpack](https://www.baeldung.com/java-protonpack) - More articles [[<-- prev]](/libraries-5) diff --git a/core-java-modules/core-java-streams/src/test/java/com/baeldung/protonpack/ProtonpackUnitTest.java b/libraries-6/src/test/java/com/baeldung/protonpack/ProtonpackUnitTest.java similarity index 99% rename from core-java-modules/core-java-streams/src/test/java/com/baeldung/protonpack/ProtonpackUnitTest.java rename to libraries-6/src/test/java/com/baeldung/protonpack/ProtonpackUnitTest.java index 371ac3a9bb..c28248e52c 100644 --- a/core-java-modules/core-java-streams/src/test/java/com/baeldung/protonpack/ProtonpackUnitTest.java +++ b/libraries-6/src/test/java/com/baeldung/protonpack/ProtonpackUnitTest.java @@ -10,8 +10,6 @@ import org.junit.Test; import java.util.List; import java.util.Optional; import java.util.Set; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; diff --git a/libraries-data-2/pom.xml b/libraries-data-2/pom.xml index be776282e9..93a2f28167 100644 --- a/libraries-data-2/pom.xml +++ b/libraries-data-2/pom.xml @@ -184,6 +184,24 @@ + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + com/baeldung/r/FastRMean.java + + + com/baeldung/r/FastRMeanUnitTest.java + + + + + + 1.5.0 1.6.0 @@ -205,21 +223,4 @@ 2.5.0 - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - com/baeldung/r/FastRMean.java - - - com/baeldung/r/FastRMeanUnitTest.java - - - - - \ No newline at end of file diff --git a/libraries-data-2/src/test/java/com/baeldung/univocity/ParsingServiceUnitTest.java b/libraries-data-2/src/test/java/com/baeldung/univocity/ParsingServiceUnitTest.java index 8cac0bc4b8..c1321ef675 100644 --- a/libraries-data-2/src/test/java/com/baeldung/univocity/ParsingServiceUnitTest.java +++ b/libraries-data-2/src/test/java/com/baeldung/univocity/ParsingServiceUnitTest.java @@ -2,15 +2,26 @@ package com.baeldung.univocity; import static org.junit.Assert.assertEquals; +import java.io.File; import java.util.ArrayList; import java.util.List; +import org.junit.After; import org.junit.Test; import com.baeldung.univocity.model.Product; public class ParsingServiceUnitTest { + @After + public void cleanup() { + File csvFile = new File("src/test/resources/outputProductList.csv"); + csvFile.deleteOnExit(); + + File textFile = new File("src/test/resources/outputProductList.txt"); + textFile.deleteOnExit(); + } + @Test public void givenCsvFile_thenParsedResultsShouldBeReturned() { ParsingService parsingService = new ParsingService(); diff --git a/libraries-testing/src/main/java/com/baeldung/serenity/spring/AdderService.java b/libraries-testing/src/main/java/com/baeldung/serenity/spring/AdderService.java index 756c05bc2c..8e645ccff5 100644 --- a/libraries-testing/src/main/java/com/baeldung/serenity/spring/AdderService.java +++ b/libraries-testing/src/main/java/com/baeldung/serenity/spring/AdderService.java @@ -1,8 +1,10 @@ package com.baeldung.serenity.spring; +import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; @Service +@Scope("prototype") public class AdderService { private int num; diff --git a/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/TransferDemo.java b/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/TransferDemo.java index 259e9a8c5c..0cc9dee2b9 100644 --- a/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/TransferDemo.java +++ b/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/TransferDemo.java @@ -1,19 +1,21 @@ package com.baeldung.mdc; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import org.apache.log4j.Logger; - -import com.baeldung.mdc.log4j.Log4JRunnable; -import com.baeldung.mdc.log4j2.Log4J2Runnable; +import com.baeldung.mdc.pool.MdcAwareThreadPoolExecutor; import com.baeldung.mdc.slf4j.Slf4jRunnable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor.AbortPolicy; + +import static java.util.concurrent.TimeUnit.MINUTES; + public class TransferDemo { public static void main(String[] args) { - ExecutorService executor = Executors.newFixedThreadPool(3); + ExecutorService executor = new MdcAwareThreadPoolExecutor(3, 3, 0, MINUTES, + new LinkedBlockingQueue<>(), Thread::new, new AbortPolicy()); + TransactionFactory transactionFactory = new TransactionFactory(); for (int i = 0; i < 10; i++) { diff --git a/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/pool/MdcAwareThreadPoolExecutor.java b/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/pool/MdcAwareThreadPoolExecutor.java new file mode 100644 index 0000000000..71463fe116 --- /dev/null +++ b/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/pool/MdcAwareThreadPoolExecutor.java @@ -0,0 +1,31 @@ +package com.baeldung.mdc.pool; + +import org.apache.logging.log4j.ThreadContext; +import org.slf4j.MDC; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.RejectedExecutionHandler; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +public class MdcAwareThreadPoolExecutor extends ThreadPoolExecutor { + + public MdcAwareThreadPoolExecutor(int corePoolSize, + int maximumPoolSize, + long keepAliveTime, + TimeUnit unit, + BlockingQueue workQueue, + ThreadFactory threadFactory, + RejectedExecutionHandler handler) { + super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler); + } + + @Override + protected void afterExecute(Runnable r, Throwable t) { + System.out.println("Cleaning the MDC context"); + MDC.clear(); + org.apache.log4j.MDC.clear(); + ThreadContext.clearAll(); + } +} diff --git a/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/slf4j/Slf4jRunnable.java b/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/slf4j/Slf4jRunnable.java index e30a28a3c7..f49640c527 100644 --- a/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/slf4j/Slf4jRunnable.java +++ b/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/slf4j/Slf4jRunnable.java @@ -18,7 +18,7 @@ public class Slf4jRunnable implements Runnable { new Slf4TransferService().transfer(tx.getAmount()); - MDC.clear(); + // MDC.clear(); We don't need this with MdcAwareThreadPoolExecutor } } \ No newline at end of file diff --git a/machine-learning/pom.xml b/machine-learning/pom.xml index 99b7e33579..842e488985 100644 --- a/machine-learning/pom.xml +++ b/machine-learning/pom.xml @@ -6,7 +6,7 @@ 4.0.0 machine-learning 1.0-SNAPSHOT - Supervised Learning + machine-learning jar diff --git a/maven-all/maven-custom-plugin/README.md b/maven-all/maven-custom-plugin/README.md deleted file mode 100644 index 55d147c337..0000000000 --- a/maven-all/maven-custom-plugin/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: - -- [How to Create a Maven Plugin](https://www.baeldung.com/maven-plugin) diff --git a/maven-all/maven/README.md b/maven-all/maven/README.md deleted file mode 100644 index c5f46ca184..0000000000 --- a/maven-all/maven/README.md +++ /dev/null @@ -1,18 +0,0 @@ -## Apache Maven - -This module contains articles about core Apache Maven. Articles about other Maven plugins (such as the Maven WAR Plugin) -have their own dedicated modules. - -### Relevant Articles - -- [Guide to the Core Maven Plugins](https://www.baeldung.com/core-maven-plugins) -- [Maven Resources Plugin](https://www.baeldung.com/maven-resources-plugin) -- [Quick Guide to the Maven Surefire Plugin](https://www.baeldung.com/maven-surefire-plugin) -- [The Maven Failsafe Plugin](https://www.baeldung.com/maven-failsafe-plugin) -- [The Maven Verifier Plugin](https://www.baeldung.com/maven-verifier-plugin) -- [The Maven Clean Plugin](https://www.baeldung.com/maven-clean-plugin) -- [Build a Jar with Maven and Ignore the Test Results](https://www.baeldung.com/maven-ignore-test-results) -- [Maven Project with Multiple Source Directories](https://www.baeldung.com/maven-project-multiple-src-directories) -- [Integration Testing with Maven](https://www.baeldung.com/maven-integration-test) -- [Apache Maven Standard Directory Layout](https://www.baeldung.com/maven-directory-structure) -- [Multi-Module Project with Maven](https://www.baeldung.com/maven-multi-module) diff --git a/maven-all/maven/maven-enforcer/README.md b/maven-all/maven/maven-enforcer/README.md deleted file mode 100644 index 7515647a3d..0000000000 --- a/maven-all/maven/maven-enforcer/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles - -- [Maven Enforcer Plugin](https://www.baeldung.com/maven-enforcer-plugin) \ No newline at end of file diff --git a/maven-all/version-collision/pom.xml b/maven-all/version-collision/pom.xml new file mode 100644 index 0000000000..7bbd17a789 --- /dev/null +++ b/maven-all/version-collision/pom.xml @@ -0,0 +1,54 @@ + + + + maven-all + com.baeldung + 0.0.1-SNAPSHOT + + 4.0.0 + + version-collision + pom + + project-a + project-b + project-collision + + + + + + + com.google.guava + guava + 29.0-jre + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/maven-all/version-collision/project-a/pom.xml b/maven-all/version-collision/project-a/pom.xml new file mode 100644 index 0000000000..1b7af7e963 --- /dev/null +++ b/maven-all/version-collision/project-a/pom.xml @@ -0,0 +1,21 @@ + + + + version-collision + com.baeldung + 0.0.1-SNAPSHOT + + 4.0.0 + + project-a + + + + com.google.guava + guava + 22.0 + + + \ No newline at end of file diff --git a/maven-all/version-collision/project-b/pom.xml b/maven-all/version-collision/project-b/pom.xml new file mode 100644 index 0000000000..0b0f50aeb8 --- /dev/null +++ b/maven-all/version-collision/project-b/pom.xml @@ -0,0 +1,21 @@ + + + + version-collision + com.baeldung + 0.0.1-SNAPSHOT + + 4.0.0 + + project-b + + + + com.google.guava + guava + 29.0-jre + + + \ No newline at end of file diff --git a/maven-all/version-collision/project-collision/pom.xml b/maven-all/version-collision/project-collision/pom.xml new file mode 100644 index 0000000000..3bec0ed54a --- /dev/null +++ b/maven-all/version-collision/project-collision/pom.xml @@ -0,0 +1,34 @@ + + + + version-collision + com.baeldung + 0.0.1-SNAPSHOT + + 4.0.0 + + project-collision + + + + + com.baeldung + project-a + 0.0.1-SNAPSHOT + + + + + + + + + + com.baeldung + project-b + 0.0.1-SNAPSHOT + + + \ No newline at end of file diff --git a/maven-all/version-collision/project-collision/src/test/java/com/baeldung/version/collision/VersionCollisionUnitTest.java b/maven-all/version-collision/project-collision/src/test/java/com/baeldung/version/collision/VersionCollisionUnitTest.java new file mode 100644 index 0000000000..de0b3a7776 --- /dev/null +++ b/maven-all/version-collision/project-collision/src/test/java/com/baeldung/version/collision/VersionCollisionUnitTest.java @@ -0,0 +1,14 @@ +package com.baeldung.version.collision; + +import com.google.common.util.concurrent.Futures; +import org.junit.Test; + +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; + +public class VersionCollisionUnitTest { + @Test + public void whenVersionCollisionDoesNotExist_thenShouldCompile() { + assertThat(Futures.immediateVoidFuture(), notNullValue()); + } +} \ No newline at end of file diff --git a/maven-all/README.md b/maven-modules/README.md similarity index 50% rename from maven-all/README.md rename to maven-modules/README.md index b448be2cd0..1ef664f879 100644 --- a/maven-all/README.md +++ b/maven-modules/README.md @@ -5,4 +5,5 @@ This module contains articles about Apache Maven. Please refer to its submodules ### Relevant Articles - [Apache Maven Tutorial](https://www.baeldung.com/maven) -- [Find Unused Maven Dependencies](https://www.baeldung.com/maven-unused-dependencies) +- [Apache Maven Standard Directory Layout](https://www.baeldung.com/maven-directory-structure) +- [Multi-Module Project with Maven](https://www.baeldung.com/maven-multi-module) diff --git a/maven-all/compiler-plugin-java-9/README.md b/maven-modules/compiler-plugin-java-9/README.md similarity index 100% rename from maven-all/compiler-plugin-java-9/README.md rename to maven-modules/compiler-plugin-java-9/README.md diff --git a/maven-all/compiler-plugin-java-9/pom.xml b/maven-modules/compiler-plugin-java-9/pom.xml similarity index 100% rename from maven-all/compiler-plugin-java-9/pom.xml rename to maven-modules/compiler-plugin-java-9/pom.xml diff --git a/maven-all/compiler-plugin-java-9/src/main/java/com/baeldung/maven/java9/MavenCompilerPlugin.java b/maven-modules/compiler-plugin-java-9/src/main/java/com/baeldung/maven/java9/MavenCompilerPlugin.java similarity index 100% rename from maven-all/compiler-plugin-java-9/src/main/java/com/baeldung/maven/java9/MavenCompilerPlugin.java rename to maven-modules/compiler-plugin-java-9/src/main/java/com/baeldung/maven/java9/MavenCompilerPlugin.java diff --git a/maven-all/compiler-plugin-java-9/src/main/java/module-info.java b/maven-modules/compiler-plugin-java-9/src/main/java/module-info.java similarity index 100% rename from maven-all/compiler-plugin-java-9/src/main/java/module-info.java rename to maven-modules/compiler-plugin-java-9/src/main/java/module-info.java diff --git a/maven-modules/maven-custom-plugin/README.md b/maven-modules/maven-custom-plugin/README.md new file mode 100644 index 0000000000..1889036ce3 --- /dev/null +++ b/maven-modules/maven-custom-plugin/README.md @@ -0,0 +1,7 @@ +## Apache Maven + +This module contains articles about creating a custom plugin in Maven. + +### Relevant Articles + +- [How to Create a Maven Plugin](https://www.baeldung.com/maven-plugin) diff --git a/maven-all/maven-custom-plugin/counter-maven-plugin/pom.xml b/maven-modules/maven-custom-plugin/counter-maven-plugin/pom.xml similarity index 100% rename from maven-all/maven-custom-plugin/counter-maven-plugin/pom.xml rename to maven-modules/maven-custom-plugin/counter-maven-plugin/pom.xml diff --git a/maven-all/maven-custom-plugin/counter-maven-plugin/src/main/java/com/baeldung/maven/plugin/validator/DependencyCounterMojo.java b/maven-modules/maven-custom-plugin/counter-maven-plugin/src/main/java/com/baeldung/maven/plugin/validator/DependencyCounterMojo.java similarity index 100% rename from maven-all/maven-custom-plugin/counter-maven-plugin/src/main/java/com/baeldung/maven/plugin/validator/DependencyCounterMojo.java rename to maven-modules/maven-custom-plugin/counter-maven-plugin/src/main/java/com/baeldung/maven/plugin/validator/DependencyCounterMojo.java diff --git a/maven-modules/maven-custom-plugin/pom.xml b/maven-modules/maven-custom-plugin/pom.xml new file mode 100644 index 0000000000..ad22c735ff --- /dev/null +++ b/maven-modules/maven-custom-plugin/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + maven-custom-plugin + 0.0.1-SNAPSHOT + maven-custom-plugin + pom + + + com.baeldung + maven-modules + 0.0.1-SNAPSHOT + + + + counter-maven-plugin + usage-example + + + \ No newline at end of file diff --git a/maven-all/maven-custom-plugin/usage-example/pom.xml b/maven-modules/maven-custom-plugin/usage-example/pom.xml similarity index 97% rename from maven-all/maven-custom-plugin/usage-example/pom.xml rename to maven-modules/maven-custom-plugin/usage-example/pom.xml index ef6f08a3fb..f512fc104d 100644 --- a/maven-all/maven-custom-plugin/usage-example/pom.xml +++ b/maven-modules/maven-custom-plugin/usage-example/pom.xml @@ -5,7 +5,7 @@ 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 - example + usage-example 0.0.1-SNAPSHOT pom diff --git a/maven-all/maven/.gitignore b/maven-modules/maven-integration-test/.gitignore similarity index 100% rename from maven-all/maven/.gitignore rename to maven-modules/maven-integration-test/.gitignore diff --git a/maven-modules/maven-integration-test/README.md b/maven-modules/maven-integration-test/README.md new file mode 100644 index 0000000000..e73a73e61e --- /dev/null +++ b/maven-modules/maven-integration-test/README.md @@ -0,0 +1,10 @@ +## Apache Maven + +This module contains articles about Integration Testing with Maven and related plugins. + +### Relevant Articles + +- [Integration Testing with Maven](https://www.baeldung.com/maven-integration-test) +- [Build a Jar with Maven and Ignore the Test Results](https://www.baeldung.com/maven-ignore-test-results) +- [Quick Guide to the Maven Surefire Plugin](https://www.baeldung.com/maven-surefire-plugin) +- [The Maven Failsafe Plugin](https://www.baeldung.com/maven-failsafe-plugin) \ No newline at end of file diff --git a/maven-all/maven/pom.xml b/maven-modules/maven-integration-test/pom.xml similarity index 90% rename from maven-all/maven/pom.xml rename to maven-modules/maven-integration-test/pom.xml index 0220cf8dfc..0031230bb1 100644 --- a/maven-all/maven/pom.xml +++ b/maven-modules/maven-integration-test/pom.xml @@ -2,10 +2,9 @@ 4.0.0 - maven + maven-integration-test 0.0.1-SNAPSHOT - maven - pom + maven-integration-test com.baeldung @@ -14,11 +13,6 @@ ../.. - - custom-rule - maven-enforcer - - org.glassfish.jersey.containers @@ -126,20 +120,6 @@ - - maven-verifier-plugin - ${maven.verifier.version} - - input-resources/verifications.xml - - - - - verify - - - - maven-clean-plugin ${maven.clean.version} @@ -156,17 +136,6 @@ build-helper-maven-plugin ${maven.build.helper.version} - - generate-sources - - add-source - - - - src/main/another-src - - - add-integration-test-source generate-test-sources diff --git a/maven-all/maven/src/integration-test/java/com/baeldung/maven/it/RestITCase.java b/maven-modules/maven-integration-test/src/integration-test/java/com/baeldung/maven/it/RestITCase.java similarity index 100% rename from maven-all/maven/src/integration-test/java/com/baeldung/maven/it/RestITCase.java rename to maven-modules/maven-integration-test/src/integration-test/java/com/baeldung/maven/it/RestITCase.java diff --git a/maven-all/maven/src/main/java/com/baeldung/maven/it/EndpointConfig.java b/maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/it/EndpointConfig.java similarity index 100% rename from maven-all/maven/src/main/java/com/baeldung/maven/it/EndpointConfig.java rename to maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/it/EndpointConfig.java diff --git a/maven-all/maven/src/main/java/com/baeldung/maven/it/RestEndpoint.java b/maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/it/RestEndpoint.java similarity index 100% rename from maven-all/maven/src/main/java/com/baeldung/maven/it/RestEndpoint.java rename to maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/it/RestEndpoint.java diff --git a/maven-all/maven/src/main/java/com/baeldung/maven/plugins/Data.java b/maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/plugins/Data.java similarity index 100% rename from maven-all/maven/src/main/java/com/baeldung/maven/plugins/Data.java rename to maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/plugins/Data.java diff --git a/maven-all/maven/src/main/resources/logback.xml b/maven-modules/maven-integration-test/src/main/resources/logback.xml similarity index 100% rename from maven-all/maven/src/main/resources/logback.xml rename to maven-modules/maven-integration-test/src/main/resources/logback.xml diff --git a/maven-all/maven/src/main/webapp/WEB-INF/web.xml b/maven-modules/maven-integration-test/src/main/webapp/WEB-INF/web.xml similarity index 100% rename from maven-all/maven/src/main/webapp/WEB-INF/web.xml rename to maven-modules/maven-integration-test/src/main/webapp/WEB-INF/web.xml diff --git a/maven-all/maven/src/test/java/com/baeldung/maven/it/Integration.java b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/Integration.java similarity index 100% rename from maven-all/maven/src/test/java/com/baeldung/maven/it/Integration.java rename to maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/Integration.java diff --git a/maven-all/maven/src/test/java/com/baeldung/maven/it/RestIT.java b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestIT.java similarity index 100% rename from maven-all/maven/src/test/java/com/baeldung/maven/it/RestIT.java rename to maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestIT.java diff --git a/maven-all/maven/src/test/java/com/baeldung/maven/it/RestIntegrationTest.java b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestIntegrationTest.java similarity index 100% rename from maven-all/maven/src/test/java/com/baeldung/maven/it/RestIntegrationTest.java rename to maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestIntegrationTest.java diff --git a/maven-all/maven/src/test/java/com/baeldung/maven/it/RestJUnitTest.java b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestJUnitTest.java similarity index 100% rename from maven-all/maven/src/test/java/com/baeldung/maven/it/RestJUnitTest.java rename to maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestJUnitTest.java diff --git a/maven-all/maven/src/test/java/com/baeldung/maven/plugins/DataCheck.java b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/plugins/DataCheck.java similarity index 100% rename from maven-all/maven/src/test/java/com/baeldung/maven/plugins/DataCheck.java rename to maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/plugins/DataCheck.java diff --git a/maven-all/maven/src/test/java/com/baeldung/maven/plugins/DataUnitTest.java b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/plugins/DataUnitTest.java similarity index 100% rename from maven-all/maven/src/test/java/com/baeldung/maven/plugins/DataUnitTest.java rename to maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/plugins/DataUnitTest.java diff --git a/maven-all/maven/src/test/java/testfail/TestFail.java b/maven-modules/maven-integration-test/src/test/java/testfail/TestFail.java similarity index 100% rename from maven-all/maven/src/test/java/testfail/TestFail.java rename to maven-modules/maven-integration-test/src/test/java/testfail/TestFail.java diff --git a/maven-modules/maven-multi-source/.gitignore b/maven-modules/maven-multi-source/.gitignore new file mode 100644 index 0000000000..bae0b0d7ce --- /dev/null +++ b/maven-modules/maven-multi-source/.gitignore @@ -0,0 +1,2 @@ +/output-resources +/.idea/ diff --git a/maven-modules/maven-multi-source/README.md b/maven-modules/maven-multi-source/README.md new file mode 100644 index 0000000000..8298332c04 --- /dev/null +++ b/maven-modules/maven-multi-source/README.md @@ -0,0 +1,7 @@ +## Apache Maven - Multiple Source Directories + +This module contains articles about how to use multiple source directories with Maven. + +### Relevant Articles + +- [Maven Project with Multiple Source Directories](https://www.baeldung.com/maven-project-multiple-src-directories) \ No newline at end of file diff --git a/maven-modules/maven-multi-source/pom.xml b/maven-modules/maven-multi-source/pom.xml new file mode 100644 index 0000000000..0c85049df7 --- /dev/null +++ b/maven-modules/maven-multi-source/pom.xml @@ -0,0 +1,92 @@ + + + 4.0.0 + maven-multi-source + 0.0.1-SNAPSHOT + maven-multi-source + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../.. + + + + + + maven-compiler-plugin + ${maven.compiler.version} + + ${java.version} + ${java.version} + + -Xlint:unchecked + + + + + org.codehaus.mojo + build-helper-maven-plugin + ${maven.build.helper.version} + + + generate-sources + + add-source + + + + src/main/another-src + + + + + + + + + + + surefire + + + + maven-surefire-plugin + ${maven.surefire.version} + + + integration-test + + test + + + + none + + + **/*IntegrationTest + + + + + + + + + + + + 3.0.2 + 3.8.0 + 2.22.0 + 2.22.0 + 1.1 + 3.0.0 + 3.0.0 + 9.4.11.v20180605 + 2.27 + + + \ No newline at end of file diff --git a/maven-all/maven/src/main/another-src/com/baeldung/maven/plugins/Foo.java b/maven-modules/maven-multi-source/src/main/another-src/com/baeldung/maven/plugins/Foo.java similarity index 100% rename from maven-all/maven/src/main/another-src/com/baeldung/maven/plugins/Foo.java rename to maven-modules/maven-multi-source/src/main/another-src/com/baeldung/maven/plugins/Foo.java diff --git a/maven-all/maven/src/main/java/com/baeldung/maven/plugins/MultipleSrcFolders.java b/maven-modules/maven-multi-source/src/main/java/com/baeldung/maven/plugins/MultipleSrcFolders.java similarity index 100% rename from maven-all/maven/src/main/java/com/baeldung/maven/plugins/MultipleSrcFolders.java rename to maven-modules/maven-multi-source/src/main/java/com/baeldung/maven/plugins/MultipleSrcFolders.java diff --git a/spring-security-modules/spring-security-cache-control/src/main/resources/logback.xml b/maven-modules/maven-multi-source/src/main/resources/logback.xml similarity index 100% rename from spring-security-modules/spring-security-cache-control/src/main/resources/logback.xml rename to maven-modules/maven-multi-source/src/main/resources/logback.xml diff --git a/maven-modules/maven-plugins/.gitignore b/maven-modules/maven-plugins/.gitignore new file mode 100644 index 0000000000..bae0b0d7ce --- /dev/null +++ b/maven-modules/maven-plugins/.gitignore @@ -0,0 +1,2 @@ +/output-resources +/.idea/ diff --git a/maven-modules/maven-plugins/README.md b/maven-modules/maven-plugins/README.md new file mode 100644 index 0000000000..4210a3bb20 --- /dev/null +++ b/maven-modules/maven-plugins/README.md @@ -0,0 +1,11 @@ +## Apache Maven + +This module contains articles about the core Maven plugins. Other Maven plugins (such as the Maven WAR Plugin) have their own dedicated modules. + +### Relevant Articles + +- [Guide to the Core Maven Plugins](https://www.baeldung.com/core-maven-plugins) +- [Maven Resources Plugin](https://www.baeldung.com/maven-resources-plugin) +- [The Maven Verifier Plugin](https://www.baeldung.com/maven-verifier-plugin) +- [The Maven Clean Plugin](https://www.baeldung.com/maven-clean-plugin) +- [Maven Enforcer Plugin](https://www.baeldung.com/maven-enforcer-plugin) diff --git a/maven-all/maven/custom-rule/pom.xml b/maven-modules/maven-plugins/custom-rule/pom.xml similarity index 69% rename from maven-all/maven/custom-rule/pom.xml rename to maven-modules/maven-plugins/custom-rule/pom.xml index 6ff984cb85..0fb551e71b 100644 --- a/maven-all/maven/custom-rule/pom.xml +++ b/maven-modules/maven-plugins/custom-rule/pom.xml @@ -1,19 +1,18 @@ - + 4.0.0 custom-rule custom-rule com.baeldung - maven + maven-plugins 0.0.1-SNAPSHOT - + org.apache.maven.enforcer enforcer-api @@ -46,19 +45,6 @@ - - - - maven-verifier-plugin - ${maven.verifier.version} - - ../input-resources/verifications.xml - false - - - - - 3.0.0-M2 2.0.9 diff --git a/maven-all/maven/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java b/maven-modules/maven-plugins/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java similarity index 100% rename from maven-all/maven/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java rename to maven-modules/maven-plugins/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java diff --git a/maven-all/maven/input-resources/baeldung.png b/maven-modules/maven-plugins/input-resources/baeldung.png similarity index 100% rename from maven-all/maven/input-resources/baeldung.png rename to maven-modules/maven-plugins/input-resources/baeldung.png diff --git a/maven-all/maven/input-resources/baeldung.txt b/maven-modules/maven-plugins/input-resources/baeldung.txt similarity index 100% rename from maven-all/maven/input-resources/baeldung.txt rename to maven-modules/maven-plugins/input-resources/baeldung.txt diff --git a/maven-all/maven/input-resources/verifications.xml b/maven-modules/maven-plugins/input-resources/verifications.xml similarity index 100% rename from maven-all/maven/input-resources/verifications.xml rename to maven-modules/maven-plugins/input-resources/verifications.xml diff --git a/maven-all/maven/maven-enforcer/pom.xml b/maven-modules/maven-plugins/maven-enforcer/pom.xml similarity index 98% rename from maven-all/maven/maven-enforcer/pom.xml rename to maven-modules/maven-plugins/maven-enforcer/pom.xml index cde37eabd1..01f97a061e 100644 --- a/maven-all/maven/maven-enforcer/pom.xml +++ b/maven-modules/maven-plugins/maven-enforcer/pom.xml @@ -8,7 +8,7 @@ com.baeldung - maven + maven-plugins 0.0.1-SNAPSHOT diff --git a/maven-modules/maven-plugins/pom.xml b/maven-modules/maven-plugins/pom.xml new file mode 100644 index 0000000000..43bcf1f422 --- /dev/null +++ b/maven-modules/maven-plugins/pom.xml @@ -0,0 +1,135 @@ + + + 4.0.0 + maven-plugins + 0.0.1-SNAPSHOT + maven-plugins + pom + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../.. + + + + + + maven-resources-plugin + ${maven.resources.version} + + output-resources + + + input-resources + + *.png + + true + + + + + + maven-compiler-plugin + ${maven.compiler.version} + + ${java.version} + ${java.version} + + -Xlint:unchecked + + + + + maven-verifier-plugin + ${maven.verifier.version} + + input-resources/verifications.xml + + + + + verify + + + + + + maven-clean-plugin + ${maven.clean.version} + + + + output-resources + + + + + + + + + + default + + + + maven-surefire-plugin + ${maven.surefire.version} + + + DataTest.java + + + TestFail.java + DataCheck.java + + true + + + + + + + surefire + + + + maven-surefire-plugin + ${maven.surefire.version} + + + integration-test + + test + + + + none + + + **/*IntegrationTest + + + + + + + + + + + + 3.0.2 + 3.8.0 + 2.22.0 + 2.22.0 + 1.1 + 3.0.0 + 3.0.0 + + + \ No newline at end of file diff --git a/maven-all/profiles/README.md b/maven-modules/maven-profiles/README.md similarity index 100% rename from maven-all/profiles/README.md rename to maven-modules/maven-profiles/README.md diff --git a/maven-all/profiles/pom.xml b/maven-modules/maven-profiles/pom.xml similarity index 97% rename from maven-all/profiles/pom.xml rename to maven-modules/maven-profiles/pom.xml index 4ae6d1ee40..4937bc7c5d 100644 --- a/maven-all/profiles/pom.xml +++ b/maven-modules/maven-profiles/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 - profiles + maven-profiles 0.0.1-SNAPSHOT - profiles + maven-profiles diff --git a/maven-all/maven/proxy/README.md b/maven-modules/maven-proxy/README.md similarity index 100% rename from maven-all/maven/proxy/README.md rename to maven-modules/maven-proxy/README.md diff --git a/maven-all/maven/proxy/settings.xml b/maven-modules/maven-proxy/proxy/settings.xml similarity index 100% rename from maven-all/maven/proxy/settings.xml rename to maven-modules/maven-proxy/proxy/settings.xml diff --git a/maven-all/maven/security/redirect/settings-security.xml b/maven-modules/maven-proxy/security/redirect/settings-security.xml similarity index 100% rename from maven-all/maven/security/redirect/settings-security.xml rename to maven-modules/maven-proxy/security/redirect/settings-security.xml diff --git a/maven-all/maven/security/settings-security.xml b/maven-modules/maven-proxy/security/settings-security.xml similarity index 100% rename from maven-all/maven/security/settings-security.xml rename to maven-modules/maven-proxy/security/settings-security.xml diff --git a/maven-modules/maven-unused-dependencies/README.md b/maven-modules/maven-unused-dependencies/README.md new file mode 100644 index 0000000000..53897e8227 --- /dev/null +++ b/maven-modules/maven-unused-dependencies/README.md @@ -0,0 +1,7 @@ +## Apache Maven + +This module contains articles about Unused Maven Dependencies. + +### Relevant Articles + +- [Find Unused Maven Dependencies](https://www.baeldung.com/maven-unused-dependencies) diff --git a/maven-all/maven-unused-dependencies/pom.xml b/maven-modules/maven-unused-dependencies/pom.xml similarity index 100% rename from maven-all/maven-unused-dependencies/pom.xml rename to maven-modules/maven-unused-dependencies/pom.xml index 825858e481..d98fe83a0e 100644 --- a/maven-all/maven-unused-dependencies/pom.xml +++ b/maven-modules/maven-unused-dependencies/pom.xml @@ -6,13 +6,6 @@ maven-unused-dependencies 0.0.1-SNAPSHOT - - 3.2.2 - 1.7.25 - 3.1.2 - 3.1 - - commons-collections @@ -44,4 +37,11 @@ + + 3.2.2 + 1.7.25 + 3.1.2 + 3.1 + + \ No newline at end of file diff --git a/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java b/maven-modules/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java similarity index 100% rename from maven-all/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java rename to maven-modules/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java diff --git a/maven-all/maven-war-plugin/README.md b/maven-modules/maven-war-plugin/README.md similarity index 100% rename from maven-all/maven-war-plugin/README.md rename to maven-modules/maven-war-plugin/README.md diff --git a/maven-all/maven-war-plugin/pom.xml b/maven-modules/maven-war-plugin/pom.xml similarity index 100% rename from maven-all/maven-war-plugin/pom.xml rename to maven-modules/maven-war-plugin/pom.xml diff --git a/maven-all/pom.xml b/maven-modules/pom.xml similarity index 62% rename from maven-all/pom.xml rename to maven-modules/pom.xml index 3a79a2a686..c4d8c253df 100644 --- a/maven-all/pom.xml +++ b/maven-modules/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - maven-all + maven-modules 0.0.1-SNAPSHOT - maven-all + maven-modules pom @@ -14,12 +14,16 @@ - - maven - maven-custom-plugin/counter-maven-plugin + + maven-custom-plugin + maven-integration-test + maven-multi-source + maven-plugins + maven-unused-dependencies maven-war-plugin - profiles + maven-profiles versions-maven-plugin + version-collision diff --git a/maven-modules/version-collision/child-module/pom.xml b/maven-modules/version-collision/child-module/pom.xml new file mode 100644 index 0000000000..7784bc5953 --- /dev/null +++ b/maven-modules/version-collision/child-module/pom.xml @@ -0,0 +1,21 @@ + + + + version-collision + com.baeldung + 0.0.1-SNAPSHOT + + 4.0.0 + + child-module + + + + org.apache.maven + maven-core + 3.3.9 + + + \ No newline at end of file diff --git a/maven-modules/version-collision/pom.xml b/maven-modules/version-collision/pom.xml new file mode 100644 index 0000000000..9a38fd0edb --- /dev/null +++ b/maven-modules/version-collision/pom.xml @@ -0,0 +1,44 @@ + + + + maven-all + com.baeldung + 0.0.1-SNAPSHOT + + 4.0.0 + + version-collision + pom + + + child-module + + + + + org.apache.commons + commons-configuration2 + 2.7 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/maven-all/versions-maven-plugin/README.md b/maven-modules/versions-maven-plugin/README.md similarity index 100% rename from maven-all/versions-maven-plugin/README.md rename to maven-modules/versions-maven-plugin/README.md diff --git a/maven-all/versions-maven-plugin/original/pom.xml b/maven-modules/versions-maven-plugin/original/pom.xml similarity index 100% rename from maven-all/versions-maven-plugin/original/pom.xml rename to maven-modules/versions-maven-plugin/original/pom.xml diff --git a/maven-all/versions-maven-plugin/pom.xml b/maven-modules/versions-maven-plugin/pom.xml similarity index 100% rename from maven-all/versions-maven-plugin/pom.xml rename to maven-modules/versions-maven-plugin/pom.xml diff --git a/maven-all/versions-maven-plugin/run-the-demo.sh b/maven-modules/versions-maven-plugin/run-the-demo.sh similarity index 100% rename from maven-all/versions-maven-plugin/run-the-demo.sh rename to maven-modules/versions-maven-plugin/run-the-demo.sh diff --git a/patterns/cqrs-es/pom.xml b/patterns/cqrs-es/pom.xml index 67665a2d32..0829e35f34 100644 --- a/patterns/cqrs-es/pom.xml +++ b/patterns/cqrs-es/pom.xml @@ -1,21 +1,17 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 cqrs-es 1.0-SNAPSHOT cqrs-es + com.baeldung patterns 1.0.0-SNAPSHOT - - 1.8 - 1.8 - 4.13 - 1.18.12 - + org.projectlombok @@ -29,4 +25,12 @@ test + + + 1.8 + 1.8 + 4.13 + 1.18.12 + + \ No newline at end of file diff --git a/pdf/README.md b/pdf/README.md index b904b101fb..bed468ad24 100644 --- a/pdf/README.md +++ b/pdf/README.md @@ -6,3 +6,4 @@ This module contains articles about PDF files. - [PDF Conversions in Java](https://www.baeldung.com/pdf-conversions-java) - [Creating PDF Files in Java](https://www.baeldung.com/java-pdf-creation) - [Generating PDF Files Using Thymeleaf](https://www.baeldung.com/thymeleaf-generate-pdf) +- [Java Convert PDF to Base64](https://www.baeldung.com/java-convert-pdf-to-base64) diff --git a/core-java-modules/core-java-string-operations-2/src/test/java/com/baeldung/pdf/base64/EncodeDecodeUnitTest.java b/pdf/src/test/java/com/baeldung/pdf/base64/EncodeDecodeUnitTest.java similarity index 94% rename from core-java-modules/core-java-string-operations-2/src/test/java/com/baeldung/pdf/base64/EncodeDecodeUnitTest.java rename to pdf/src/test/java/com/baeldung/pdf/base64/EncodeDecodeUnitTest.java index 0df6f58136..db76f9a0c8 100644 --- a/core-java-modules/core-java-string-operations-2/src/test/java/com/baeldung/pdf/base64/EncodeDecodeUnitTest.java +++ b/pdf/src/test/java/com/baeldung/pdf/base64/EncodeDecodeUnitTest.java @@ -1,8 +1,7 @@ package com.baeldung.pdf.base64; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; +import org.junit.BeforeClass; +import org.junit.Test; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -11,8 +10,7 @@ import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.Paths; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.junit.Assert.*; public class EncodeDecodeUnitTest { diff --git a/core-java-modules/core-java-string-operations-2/src/test/resources/input.pdf b/pdf/src/test/resources/input.pdf similarity index 100% rename from core-java-modules/core-java-string-operations-2/src/test/resources/input.pdf rename to pdf/src/test/resources/input.pdf diff --git a/core-java-modules/core-java-string-operations-2/src/test/resources/output.pdf b/pdf/src/test/resources/output.pdf similarity index 100% rename from core-java-modules/core-java-string-operations-2/src/test/resources/output.pdf rename to pdf/src/test/resources/output.pdf diff --git a/performance-tests/pom.xml b/performance-tests/pom.xml index c8cebd8a11..0dc38e56a4 100644 --- a/performance-tests/pom.xml +++ b/performance-tests/pom.xml @@ -65,44 +65,6 @@ - - UTF-8 - - - 1.21 - 1.5.2 - 5.5.1 - 1.0.2 - 1.2.0.Final - 1.1.0 - 1.6.0.1 - 1.8 - 1.2.0.Final - 1.21 - 1.21 - 3.7.0 - - - 1.8 - - - benchmarks - 3.1 - 2.2 - 2.5.1 - 2.4 - 2.9.1 - 2.6 - 3.3 - 2.2.1 - 2.17 - @@ -201,4 +163,40 @@ + + + 1.21 + 1.5.2 + 5.5.1 + 1.0.2 + 1.2.0.Final + 1.1.0 + 1.6.0.1 + 1.2.0.Final + 1.21 + 1.21 + 3.7.0 + + + 1.8 + + + benchmarks + 3.1 + 2.2 + 2.5.1 + 2.4 + 2.9.1 + 2.6 + 3.3 + 2.2.1 + 2.17 + + diff --git a/persistence-modules/hibernate-exceptions/pom.xml b/persistence-modules/hibernate-exceptions/pom.xml index e5217e83bd..f7eee22960 100644 --- a/persistence-modules/hibernate-exceptions/pom.xml +++ b/persistence-modules/hibernate-exceptions/pom.xml @@ -33,7 +33,6 @@ 2.4.0 2.3.0 - 5.3.7.Final diff --git a/persistence-modules/hibernate-libraries/pom.xml b/persistence-modules/hibernate-libraries/pom.xml index ea2dda7e88..808c47133c 100644 --- a/persistence-modules/hibernate-libraries/pom.xml +++ b/persistence-modules/hibernate-libraries/pom.xml @@ -171,7 +171,6 @@ 2.9.7 5.4.14.Final 2.10.3 - 1.8 3.27.0-GA 2.3.1 2.0.0 diff --git a/persistence-modules/hibernate-queries/pom.xml b/persistence-modules/hibernate-queries/pom.xml index a439ded9df..06f7f42088 100644 --- a/persistence-modules/hibernate-queries/pom.xml +++ b/persistence-modules/hibernate-queries/pom.xml @@ -71,7 +71,6 @@ - 5.3.7.Final 6.0.6 2.2.3 3.8.0 diff --git a/persistence-modules/persistence-libraries/pom.xml b/persistence-modules/persistence-libraries/pom.xml index a72654f2aa..42f3a33a40 100644 --- a/persistence-modules/persistence-libraries/pom.xml +++ b/persistence-modules/persistence-libraries/pom.xml @@ -4,7 +4,7 @@ 4.0.0 persistence-libraries 1.0-SNAPSHOT - java-sql2o + persistence-libraries com.baeldung diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index efef4f2015..f1154f203b 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -78,4 +78,8 @@ spring-persistence-simple-2 + + + 5.2.17.Final + diff --git a/persistence-modules/r2dbc/pom.xml b/persistence-modules/r2dbc/pom.xml index d0f53ba37c..2da81cba06 100644 --- a/persistence-modules/r2dbc/pom.xml +++ b/persistence-modules/r2dbc/pom.xml @@ -62,7 +62,6 @@ - 1.8 0.8.1.RELEASE 1.4.200 diff --git a/persistence-modules/sirix/pom.xml b/persistence-modules/sirix/pom.xml index 0f114966f7..67de507cca 100644 --- a/persistence-modules/sirix/pom.xml +++ b/persistence-modules/sirix/pom.xml @@ -6,7 +6,7 @@ io.sirix sirix 1.0-SNAPSHOT - core-api-tutorial + sirix jar http://maven.apache.org diff --git a/persistence-modules/spring-boot-persistence-2/pom.xml b/persistence-modules/spring-boot-persistence-2/pom.xml index f36d8fc43f..e90d61fda3 100644 --- a/persistence-modules/spring-boot-persistence-2/pom.xml +++ b/persistence-modules/spring-boot-persistence-2/pom.xml @@ -6,7 +6,7 @@ com.baeldung.boot.persistence spring-boot-persistence-2 0.0.1-SNAPSHOT - spring-boot-jdbi + spring-boot-persistence-2 Sample SpringBoot JDBI Project diff --git a/persistence-modules/spring-boot-persistence/pom.xml b/persistence-modules/spring-boot-persistence/pom.xml index cc26ff58d5..9e44a7b9c1 100644 --- a/persistence-modules/spring-boot-persistence/pom.xml +++ b/persistence-modules/spring-boot-persistence/pom.xml @@ -74,7 +74,6 @@ - UTF-8 2.23.0 2.0.1.Final diff --git a/persistence-modules/spring-data-geode/pom.xml b/persistence-modules/spring-data-geode/pom.xml index 557d09376a..07aa65463c 100644 --- a/persistence-modules/spring-data-geode/pom.xml +++ b/persistence-modules/spring-data-geode/pom.xml @@ -85,7 +85,6 @@ 2.1.9.RELEASE - UTF-8 com.baeldung.springdatageode.app.ClientCacheApp 1.1.1.RELEASE 2.1.9.RELEASE diff --git a/persistence-modules/spring-data-jpa-5/pom.xml b/persistence-modules/spring-data-jpa-5/pom.xml index f09c83ab11..db58a16062 100644 --- a/persistence-modules/spring-data-jpa-5/pom.xml +++ b/persistence-modules/spring-data-jpa-5/pom.xml @@ -71,7 +71,6 @@ 2.1.9.RELEASE - UTF-8 com.baeldung.springdatageode.app.ClientCacheApp 1.1.1.RELEASE 2.1.9.RELEASE diff --git a/persistence-modules/spring-jpa/pom.xml b/persistence-modules/spring-jpa/pom.xml index ef05269c92..410ed592b0 100644 --- a/persistence-modules/spring-jpa/pom.xml +++ b/persistence-modules/spring-jpa/pom.xml @@ -133,8 +133,6 @@ 5.1.5.RELEASE 3.21.0-GA - - 5.2.17.Final 6.0.6 2.1.5.RELEASE diff --git a/pom.xml b/pom.xml index 2882155117..1db715147a 100644 --- a/pom.xml +++ b/pom.xml @@ -416,6 +416,7 @@ grpc gson guava + guava-2 guava-collections guava-collections-map guava-collections-set @@ -509,7 +510,7 @@ machine-learning mapstruct - maven-all + maven-modules maven-archetype maven-polyglot @@ -1020,7 +1021,7 @@ machine-learning mapstruct - maven-all + maven-modules maven-archetype maven-polyglot diff --git a/spf4j/spf4j-aspects-app/pom.xml b/spf4j/spf4j-aspects-app/pom.xml index db6a18f26a..24a419233e 100644 --- a/spf4j/spf4j-aspects-app/pom.xml +++ b/spf4j/spf4j-aspects-app/pom.xml @@ -81,7 +81,6 @@ - UTF-8 8.6.10 1.7.21 3.8.0 diff --git a/spf4j/spf4j-core-app/pom.xml b/spf4j/spf4j-core-app/pom.xml index 48cbf4a1c9..280a59e0d9 100644 --- a/spf4j/spf4j-core-app/pom.xml +++ b/spf4j/spf4j-core-app/pom.xml @@ -81,7 +81,6 @@ - UTF-8 8.6.10 1.7.21 3.8.0 diff --git a/spring-5-reactive-oauth/pom.xml b/spring-5-reactive-oauth/pom.xml index e286e821b2..e9882a6d32 100644 --- a/spring-5-reactive-oauth/pom.xml +++ b/spring-5-reactive-oauth/pom.xml @@ -65,8 +65,6 @@ - UTF-8 - UTF-8 2.1.0.RELEASE diff --git a/spring-5-webflux/pom.xml b/spring-5-webflux/pom.xml index 22f429da2a..292e4d7ad9 100644 --- a/spring-5-webflux/pom.xml +++ b/spring-5-webflux/pom.xml @@ -64,7 +64,4 @@ - - 2.2.0.RELEASE - diff --git a/spring-activiti/pom.xml b/spring-activiti/pom.xml index eef4d37ff8..4803827b45 100644 --- a/spring-activiti/pom.xml +++ b/spring-activiti/pom.xml @@ -56,8 +56,6 @@ - UTF-8 - UTF-8 6.0.0 diff --git a/spring-aop/pom.xml b/spring-aop/pom.xml index 69de2d66fd..74b6f48b46 100644 --- a/spring-aop/pom.xml +++ b/spring-aop/pom.xml @@ -18,6 +18,11 @@ org.springframework.boot spring-boot-starter-aop + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/spring-aop/src/test/java/com/baeldung/undeclared/SomeCheckedException.java b/spring-aop/src/test/java/com/baeldung/undeclared/SomeCheckedException.java new file mode 100644 index 0000000000..bbb28681fa --- /dev/null +++ b/spring-aop/src/test/java/com/baeldung/undeclared/SomeCheckedException.java @@ -0,0 +1,7 @@ +package com.baeldung.undeclared; + +public class SomeCheckedException extends Exception { + public SomeCheckedException(String message) { + super(message); + } +} diff --git a/spring-aop/src/test/java/com/baeldung/undeclared/ThrowUndeclared.java b/spring-aop/src/test/java/com/baeldung/undeclared/ThrowUndeclared.java new file mode 100644 index 0000000000..dd6436e722 --- /dev/null +++ b/spring-aop/src/test/java/com/baeldung/undeclared/ThrowUndeclared.java @@ -0,0 +1,11 @@ +package com.baeldung.undeclared; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface ThrowUndeclared { +} diff --git a/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredApplication.java b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredApplication.java new file mode 100644 index 0000000000..37a0ec89b5 --- /dev/null +++ b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.undeclared; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class UndeclaredApplication { + + public static void main(String[] args) { + SpringApplication.run(UndeclaredApplication.class, args); + } +} diff --git a/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredAspect.java b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredAspect.java new file mode 100644 index 0000000000..076fdff66c --- /dev/null +++ b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredAspect.java @@ -0,0 +1,16 @@ +package com.baeldung.undeclared; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; + +@Aspect +@Component +public class UndeclaredAspect { + + @Around("@annotation(undeclared)") + public Object advise(ProceedingJoinPoint pjp, ThrowUndeclared undeclared) throws Throwable { + throw new SomeCheckedException("AOP Checked Exception"); + } +} diff --git a/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredService.java b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredService.java new file mode 100644 index 0000000000..6cc16c1ceb --- /dev/null +++ b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredService.java @@ -0,0 +1,10 @@ +package com.baeldung.undeclared; + +import org.springframework.stereotype.Service; + +@Service +public class UndeclaredService { + + @ThrowUndeclared + public void doSomething() {} +} diff --git a/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredThrowableExceptionIntegrationTest.java b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredThrowableExceptionIntegrationTest.java new file mode 100644 index 0000000000..e64a45d418 --- /dev/null +++ b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredThrowableExceptionIntegrationTest.java @@ -0,0 +1,25 @@ +package com.baeldung.undeclared; + +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 java.lang.reflect.UndeclaredThrowableException; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = UndeclaredApplication.class) +public class UndeclaredThrowableExceptionIntegrationTest { + + @Autowired private UndeclaredService service; + + @Test + public void givenAnAspect_whenCallingAdvisedMethod_thenShouldWrapTheException() { + assertThatThrownBy(service::doSomething) + .isInstanceOf(UndeclaredThrowableException.class) + .hasCauseInstanceOf(SomeCheckedException.class); + } +} diff --git a/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredThrowableExceptionUnitTest.java b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredThrowableExceptionUnitTest.java new file mode 100644 index 0000000000..464239d12d --- /dev/null +++ b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredThrowableExceptionUnitTest.java @@ -0,0 +1,48 @@ +package com.baeldung.undeclared; + +import org.junit.Test; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.lang.reflect.UndeclaredThrowableException; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class UndeclaredThrowableExceptionUnitTest { + + @Test + @SuppressWarnings("unchecked") + public void givenAProxy_whenProxyUndeclaredThrowsCheckedException_thenShouldBeWrapped() { + ClassLoader classLoader = getClass().getClassLoader(); + InvocationHandler invocationHandler = new ExceptionalInvocationHandler(); + List proxy = (List) Proxy.newProxyInstance(classLoader, new Class[] { List.class }, invocationHandler); + + assertThatThrownBy(proxy::size) + .isInstanceOf(UndeclaredThrowableException.class) + .hasCauseInstanceOf(SomeCheckedException.class); + } + + @Test + @SuppressWarnings("unchecked") + public void givenAProxy_whenProxyThrowsUncheckedException_thenShouldBeThrownAsIs() { + ClassLoader classLoader = getClass().getClassLoader(); + InvocationHandler invocationHandler = new ExceptionalInvocationHandler(); + List proxy = (List) Proxy.newProxyInstance(classLoader, new Class[] { List.class }, invocationHandler); + + assertThatThrownBy(proxy::isEmpty).isInstanceOf(RuntimeException.class); + } + + private static class ExceptionalInvocationHandler implements InvocationHandler { + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + if ("size".equals(method.getName())) { + throw new SomeCheckedException("Always fails"); + } + + throw new RuntimeException(); + } + } +} diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 50059fe383..84f1f0e86c 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -6,9 +6,10 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - spring-boot-modules pom + spring-boot-modules + com.baeldung parent-boot-2 @@ -48,6 +49,7 @@ spring-boot-kotlin spring-boot-mvc spring-boot-mvc-2 + spring-boot-mvc-3 spring-boot-mvc-birt spring-boot-nashorn spring-boot-parent @@ -63,6 +65,37 @@ spring-boot-actuator + + + + + org.junit + junit-bom + ${junit-jupiter.version} + pom + import + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + + org.junit.jupiter + junit-jupiter + + + org.junit.vintage + junit-vintage-engine + + + @@ -75,5 +108,6 @@ 5.6.2 + 2.6 diff --git a/spring-boot-modules/spring-boot-admin/pom.xml b/spring-boot-modules/spring-boot-admin/pom.xml index f7dc98770a..6109081723 100644 --- a/spring-boot-modules/spring-boot-admin/pom.xml +++ b/spring-boot-modules/spring-boot-admin/pom.xml @@ -2,21 +2,22 @@ 4.0.0 - spring-boot-admin - 0.0.1-SNAPSHOT - spring-boot-admin - pom - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-admin + 0.0.1-SNAPSHOT + pom + + spring-boot-admin + spring-boot-admin-server spring-boot-admin-client - diff --git a/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml index 8bb8c7bac3..eb40bfe8ea 100644 --- a/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml +++ b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml @@ -2,18 +2,21 @@ 4.0.0 - spring-boot-admin-client - 0.0.1-SNAPSHOT - spring-boot-admin-client - jar - Spring Boot Admin Client - com.baeldung + com.baeldung.spring-boot-modules spring-boot-admin 0.0.1-SNAPSHOT + ../ + spring-boot-admin-client + 0.0.1-SNAPSHOT + jar + + spring-boot-admin-client + Spring Boot Admin Client + org.springframework.boot @@ -61,5 +64,4 @@ 2.2.2 2.0.4.RELEASE - diff --git a/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml index 118b270812..4c1dcdef6b 100644 --- a/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml +++ b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml @@ -2,18 +2,21 @@ 4.0.0 - spring-boot-admin-server - 0.0.1-SNAPSHOT - spring-boot-admin-server - Spring Boot Admin Server - jar - com.baeldung + com.baeldung.spring-boot-modules spring-boot-admin 0.0.1-SNAPSHOT + ../ + spring-boot-admin-server + 0.0.1-SNAPSHOT + jar + + spring-boot-admin-server + Spring Boot Admin Server + org.springframework.boot @@ -84,5 +87,4 @@ 1.5.7 2.0.4.RELEASE - diff --git a/spring-boot-modules/spring-boot-angular/pom.xml b/spring-boot-modules/spring-boot-angular/pom.xml index e8082656ad..4b3ac27834 100644 --- a/spring-boot-modules/spring-boot-angular/pom.xml +++ b/spring-boot-modules/spring-boot-angular/pom.xml @@ -2,18 +2,20 @@ 4.0.0 + + + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + + com.baeldung.springbootangular spring-boot-angular 1.0 - spring-boot-angular jar - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 - + spring-boot-angular diff --git a/spring-boot-modules/spring-boot-annotations/pom.xml b/spring-boot-modules/spring-boot-annotations/pom.xml index da2c46ca92..799692d51b 100644 --- a/spring-boot-modules/spring-boot-annotations/pom.xml +++ b/spring-boot-modules/spring-boot-annotations/pom.xml @@ -2,17 +2,19 @@ 4.0.0 - spring-boot-annotations - spring-boot-annotations - war - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-annotations + war + + spring-boot-annotations + org.aspectj diff --git a/spring-boot-modules/spring-boot-artifacts/pom.xml b/spring-boot-modules/spring-boot-artifacts/pom.xml index de9f6ab635..2704b71bd6 100644 --- a/spring-boot-modules/spring-boot-artifacts/pom.xml +++ b/spring-boot-modules/spring-boot-artifacts/pom.xml @@ -2,20 +2,21 @@ 4.0.0 - spring-boot-artifacts - spring-boot-artifacts - war - Demo project for Spring Boot - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ - + spring-boot-artifacts + war + spring-boot-artifacts + Demo project for Spring Boot + + org.springframework.boot spring-boot-starter-web diff --git a/spring-boot-modules/spring-boot-autoconfiguration/pom.xml b/spring-boot-modules/spring-boot-autoconfiguration/pom.xml index 34db784176..5709d1d796 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/pom.xml +++ b/spring-boot-modules/spring-boot-autoconfiguration/pom.xml @@ -2,19 +2,21 @@ 4.0.0 - spring-boot-autoconfiguration - 0.0.1-SNAPSHOT - spring-boot-autoconfiguration - war - This is simple boot application demonstrating a custom auto-configuration - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-autoconfiguration + 0.0.1-SNAPSHOT + war + + spring-boot-autoconfiguration + This is simple boot application demonstrating a custom auto-configuration + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-basic-customization/pom.xml b/spring-boot-modules/spring-boot-basic-customization/pom.xml index 7c2c89def4..fc34994a85 100644 --- a/spring-boot-modules/spring-boot-basic-customization/pom.xml +++ b/spring-boot-modules/spring-boot-basic-customization/pom.xml @@ -3,18 +3,20 @@ 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-boot-basic-customization - spring-boot-basic-customization - jar - Module For Spring Boot Basic Customization - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-basic-customization + jar + + spring-boot-basic-customization + Module For Spring Boot Basic Customization + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-bootstrap/pom.xml b/spring-boot-modules/spring-boot-bootstrap/pom.xml index 1dc75c7e61..6a1be7a2c8 100644 --- a/spring-boot-modules/spring-boot-bootstrap/pom.xml +++ b/spring-boot-modules/spring-boot-bootstrap/pom.xml @@ -2,18 +2,20 @@ 4.0.0 - spring-boot-bootstrap - spring-boot-bootstrap - jar - Demo project for Spring Boot - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-bootstrap + jar + + spring-boot-bootstrap + Demo project for Spring Boot + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-ci-cd/pom.xml b/spring-boot-modules/spring-boot-ci-cd/pom.xml index 25e45d56f3..61a2e299fb 100644 --- a/spring-boot-modules/spring-boot-ci-cd/pom.xml +++ b/spring-boot-modules/spring-boot-ci-cd/pom.xml @@ -3,18 +3,20 @@ 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-boot-ci-cd - 0.0.1-SNAPSHOT - spring-boot-ci-cd - jar - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-ci-cd + 0.0.1-SNAPSHOT + jar + + spring-boot-ci-cd + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-client/pom.xml b/spring-boot-modules/spring-boot-client/pom.xml index 40a8690953..a7737be106 100644 --- a/spring-boot-modules/spring-boot-client/pom.xml +++ b/spring-boot-modules/spring-boot-client/pom.xml @@ -2,40 +2,22 @@ 4.0.0 - spring-boot-client - 0.0.1-SNAPSHOT - spring-boot-client - war - This is simple boot client application for Spring boot actuator test - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-client + 0.0.1-SNAPSHOT + war + + spring-boot-client + This is simple boot client application for Spring boot actuator test + - - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - - - org.junit.platform - junit-platform-launcher - ${junit-platform.version} - test - org.springframework.boot spring-boot-starter-web diff --git a/spring-boot-modules/spring-boot-config-jpa-error/pom.xml b/spring-boot-modules/spring-boot-config-jpa-error/pom.xml index f578957a1a..d236a581d8 100644 --- a/spring-boot-modules/spring-boot-config-jpa-error/pom.xml +++ b/spring-boot-modules/spring-boot-config-jpa-error/pom.xml @@ -2,18 +2,19 @@ 4.0.0 + + + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + + com.baeldung.spring-boot-config-jpa-error spring-boot-config-jpa-error 0.0.1-SNAPSHOT pom - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2/pom.xml - - data-jpa-library data-jpa-application diff --git a/spring-boot-modules/spring-boot-crud/pom.xml b/spring-boot-modules/spring-boot-crud/pom.xml index 676d522f84..8ba7bab171 100644 --- a/spring-boot-modules/spring-boot-crud/pom.xml +++ b/spring-boot-modules/spring-boot-crud/pom.xml @@ -3,16 +3,18 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 - spring-boot-crud - spring-boot-crud - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-crud + + spring-boot-crud + org.springframework.boot @@ -79,8 +81,4 @@ - - UTF-8 - - diff --git a/spring-boot-modules/spring-boot-ctx-fluent/pom.xml b/spring-boot-modules/spring-boot-ctx-fluent/pom.xml index 872e15d307..cfbc6ffac0 100644 --- a/spring-boot-modules/spring-boot-ctx-fluent/pom.xml +++ b/spring-boot-modules/spring-boot-ctx-fluent/pom.xml @@ -2,18 +2,20 @@ 4.0.0 - spring-boot-ctx-fluent - 0.0.1-SNAPSHOT - spring-boot-ctx-fluent - jar - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-ctx-fluent + 0.0.1-SNAPSHOT + jar + + spring-boot-ctx-fluent + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml index 8d328b88be..6291756d21 100644 --- a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml @@ -7,10 +7,10 @@ greeter-spring-boot-sample-app - com.baeldung - parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-custom-starter 0.0.1-SNAPSHOT - ../../../parent-boot-2 + ../ diff --git a/spring-boot-modules/spring-boot-custom-starter/pom.xml b/spring-boot-modules/spring-boot-custom-starter/pom.xml index 1a13e2ba9b..17f9fdc2cc 100644 --- a/spring-boot-modules/spring-boot-custom-starter/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/pom.xml @@ -2,17 +2,20 @@ 4.0.0 - spring-boot-custom-starter - 0.0.1-SNAPSHOT - spring-boot-custom-starter - pom com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT + ../ + spring-boot-custom-starter + 0.0.1-SNAPSHOT + pom + + spring-boot-custom-starter + greeter-library greeter-spring-boot-autoconfigure @@ -20,5 +23,4 @@ greeter-spring-boot-sample-app parent-multi-module - \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-data/pom.xml b/spring-boot-modules/spring-boot-data/pom.xml index f25b4ee472..fe64b07379 100644 --- a/spring-boot-modules/spring-boot-data/pom.xml +++ b/spring-boot-modules/spring-boot-data/pom.xml @@ -2,18 +2,20 @@ 4.0.0 - spring-boot-data - spring-boot-data - war - Spring Boot Data Module - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-data + war + + spring-boot-data + Spring Boot Data Module + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-deployment/pom.xml b/spring-boot-modules/spring-boot-deployment/pom.xml index b3fc3eabd1..6b5e75bd62 100644 --- a/spring-boot-modules/spring-boot-deployment/pom.xml +++ b/spring-boot-modules/spring-boot-deployment/pom.xml @@ -8,14 +8,13 @@ Demo project for Spring Boot - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ - org.springframework.boot spring-boot-starter-web diff --git a/spring-boot-modules/spring-boot-di/pom.xml b/spring-boot-modules/spring-boot-di/pom.xml index b24e4a9037..87a0ad2937 100644 --- a/spring-boot-modules/spring-boot-di/pom.xml +++ b/spring-boot-modules/spring-boot-di/pom.xml @@ -3,18 +3,20 @@ 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-boot-di - spring-boot-di - jar - Module For Spring Boot DI - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-di + jar + + spring-boot-di + Module For Spring Boot DI + org.aspectj diff --git a/spring-boot-modules/spring-boot-environment/pom.xml b/spring-boot-modules/spring-boot-environment/pom.xml index 138c59847d..694e17fd72 100644 --- a/spring-boot-modules/spring-boot-environment/pom.xml +++ b/spring-boot-modules/spring-boot-environment/pom.xml @@ -2,20 +2,21 @@ 4.0.0 - spring-boot-environment - spring-boot-environment - war - Demo project for Spring Boot - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ - + spring-boot-environment + war + spring-boot-environment + Demo project for Spring Boot + + org.springframework.boot spring-boot-starter-web diff --git a/spring-boot-modules/spring-boot-exceptions/pom.xml b/spring-boot-modules/spring-boot-exceptions/pom.xml index 6ef7e66770..4b9d787b61 100644 --- a/spring-boot-modules/spring-boot-exceptions/pom.xml +++ b/spring-boot-modules/spring-boot-exceptions/pom.xml @@ -2,18 +2,20 @@ 4.0.0 - spring-boot-exceptions - spring-boot-exceptions - jar - Demo project for working with Spring Boot exceptions - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-exceptions + jar + + spring-boot-exceptions + Demo project for working with Spring Boot exceptions + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-flowable/pom.xml b/spring-boot-modules/spring-boot-flowable/pom.xml index 7d9fb97cba..f1121ea6a0 100644 --- a/spring-boot-modules/spring-boot-flowable/pom.xml +++ b/spring-boot-modules/spring-boot-flowable/pom.xml @@ -3,18 +3,20 @@ 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-boot-flowable - spring-boot-flowable - war - Spring Boot Flowable Module - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-flowable + war + + spring-boot-flowable + Spring Boot Flowable Module + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-jasypt/pom.xml b/spring-boot-modules/spring-boot-jasypt/pom.xml index e63a02729f..2f0c8a27b4 100644 --- a/spring-boot-modules/spring-boot-jasypt/pom.xml +++ b/spring-boot-modules/spring-boot-jasypt/pom.xml @@ -2,19 +2,21 @@ 4.0.0 - com.example.jasypt - spring-boot-jasypt - spring-boot-jasypt - jar - Demo project for Spring Boot - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + com.example.jasypt + spring-boot-jasypt + jar + + spring-boot-jasypt + Demo project for Spring Boot + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-keycloak/pom.xml b/spring-boot-modules/spring-boot-keycloak/pom.xml index 68d4ec4b8f..6208fbe305 100644 --- a/spring-boot-modules/spring-boot-keycloak/pom.xml +++ b/spring-boot-modules/spring-boot-keycloak/pom.xml @@ -2,19 +2,21 @@ 4.0.0 + + + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + + com.baeldung.keycloak spring-boot-keycloak 0.0.1 - spring-boot-keycloak jar - This is a simple application demonstrating integration between Keycloak and Spring Boot. - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 - + spring-boot-keycloak + This is a simple application demonstrating integration between Keycloak and Spring Boot. diff --git a/spring-boot-modules/spring-boot-libraries/pom.xml b/spring-boot-modules/spring-boot-libraries/pom.xml index 189eb4cf1a..05ab59aab7 100644 --- a/spring-boot-modules/spring-boot-libraries/pom.xml +++ b/spring-boot-modules/spring-boot-libraries/pom.xml @@ -9,10 +9,10 @@ This is simple boot application for Spring boot actuator test - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ diff --git a/spring-boot-modules/spring-boot-mvc-2/pom.xml b/spring-boot-modules/spring-boot-mvc-2/pom.xml index 45202d1e4c..73a75f020c 100644 --- a/spring-boot-modules/spring-boot-mvc-2/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-2/pom.xml @@ -3,18 +3,20 @@ 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-boot-mvc-2 - spring-boot-mvc-2 - jar - Module For Spring Boot MVC Web Fn - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-mvc-2 + jar + + spring-boot-mvc-2 + Module For Spring Boot MVC Web Fn + org.springframework.boot @@ -99,8 +101,7 @@ 3.0.0-SNAPSHOT com.baeldung.swagger2boot.SpringBootSwaggerApplication - 2.2.6.RELEASE - 1.4.11.1 + 1.4.11.1 \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc-3/pom.xml b/spring-boot-modules/spring-boot-mvc-3/pom.xml index 64e8a99c6c..71b7383ef4 100644 --- a/spring-boot-modules/spring-boot-mvc-3/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-3/pom.xml @@ -3,18 +3,20 @@ 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-boot-mvc-3 - spring-boot-mvc-3 - jar - Module For Spring Boot MVC Web - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-mvc-3 + jar + + spring-boot-mvc-3 + Module For Spring Boot MVC Web + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-mvc-birt/pom.xml b/spring-boot-modules/spring-boot-mvc-birt/pom.xml index 0e8e231a84..0ab744bb26 100644 --- a/spring-boot-modules/spring-boot-mvc-birt/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-birt/pom.xml @@ -3,19 +3,21 @@ 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-boot-mvc-birt - 0.0.1-SNAPSHOT - spring-boot-mvc-birt - jar - Module For Spring Boot Integration with BIRT - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-mvc-birt + 0.0.1-SNAPSHOT + jar + + spring-boot-mvc-birt + Module For Spring Boot Integration with BIRT + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-mvc/pom.xml b/spring-boot-modules/spring-boot-mvc/pom.xml index 019d29285c..fd6f1b0a8a 100644 --- a/spring-boot-modules/spring-boot-mvc/pom.xml +++ b/spring-boot-modules/spring-boot-mvc/pom.xml @@ -3,18 +3,20 @@ 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-boot-mvc - spring-boot-mvc - jar - Module For Spring Boot MVC - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ - + + spring-boot-mvc + jar + + spring-boot-mvc + Module For Spring Boot MVC + diff --git a/spring-boot-modules/spring-boot-nashorn/pom.xml b/spring-boot-modules/spring-boot-nashorn/pom.xml index c60997005d..ca0b726a47 100644 --- a/spring-boot-modules/spring-boot-nashorn/pom.xml +++ b/spring-boot-modules/spring-boot-nashorn/pom.xml @@ -3,18 +3,20 @@ 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 + + + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + + com.baeldung.nashorn spring-boot-nashorn 1.0 - spring-boot-nashorn jar - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 - + spring-boot-nashorn diff --git a/spring-boot-modules/spring-boot-parent/pom.xml b/spring-boot-modules/spring-boot-parent/pom.xml index cf0a6702ea..ebd3cd5d36 100644 --- a/spring-boot-modules/spring-boot-parent/pom.xml +++ b/spring-boot-modules/spring-boot-parent/pom.xml @@ -3,21 +3,23 @@ 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-boot-parent - 1.0.0-SNAPSHOT - spring-boot-parent - pom - spring-boot-parent com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT + ../ + spring-boot-parent + 1.0.0-SNAPSHOT + pom + + spring-boot-parent + spring-boot-parent + spring-boot-with-starter-parent spring-boot-with-custom-parent - diff --git a/spring-boot-modules/spring-boot-parent/spring-boot-with-custom-parent/pom.xml b/spring-boot-modules/spring-boot-parent/spring-boot-with-custom-parent/pom.xml index d08384e34c..5f5d3a9f6a 100644 --- a/spring-boot-modules/spring-boot-parent/spring-boot-with-custom-parent/pom.xml +++ b/spring-boot-modules/spring-boot-parent/spring-boot-with-custom-parent/pom.xml @@ -3,17 +3,19 @@ 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-boot-with-custom-parent - 1.0.0-SNAPSHOT - spring-boot-with-custom-parent - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-parent + 1.0.0-SNAPSHOT + ../ + spring-boot-with-custom-parent + 1.0.0-SNAPSHOT + + spring-boot-with-custom-parent + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-parent/spring-boot-with-starter-parent/pom.xml b/spring-boot-modules/spring-boot-parent/spring-boot-with-starter-parent/pom.xml index 331a85ec5b..7413492d7f 100644 --- a/spring-boot-modules/spring-boot-parent/spring-boot-with-starter-parent/pom.xml +++ b/spring-boot-modules/spring-boot-parent/spring-boot-with-starter-parent/pom.xml @@ -3,17 +3,19 @@ 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 + + + com.baeldung.spring-boot-modules + spring-boot-parent + 1.0.0-SNAPSHOT + ../ + + com.baeldung spring-boot-with-starter-parent 1.0.0-SNAPSHOT - spring-boot-with-starter-parent - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../../parent-boot-2 - + spring-boot-with-starter-parent diff --git a/spring-boot-modules/spring-boot-performance/pom.xml b/spring-boot-modules/spring-boot-performance/pom.xml index 1f3eafd96c..053f68eea3 100644 --- a/spring-boot-modules/spring-boot-performance/pom.xml +++ b/spring-boot-modules/spring-boot-performance/pom.xml @@ -2,18 +2,20 @@ 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-boot-performance - spring-boot-performance - war - This is a simple Spring Boot application taking advantage of the latest Spring Boot improvements/features. Current version: 2.2 - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-performance + war + + spring-boot-performance + This is a simple Spring Boot application taking advantage of the latest Spring Boot improvements/features. Current version: 2.2 + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-properties-2/pom.xml b/spring-boot-modules/spring-boot-properties-2/pom.xml index bd2a35b19d..e777b8f318 100644 --- a/spring-boot-modules/spring-boot-properties-2/pom.xml +++ b/spring-boot-modules/spring-boot-properties-2/pom.xml @@ -2,19 +2,21 @@ 4.0.0 - spring-boot-properties-2 - spring-boot-properties-2 - jar - Spring Boot Properties Module - 0.0.1-SNAPSHOT - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-properties-2 + jar + 0.0.1-SNAPSHOT + + spring-boot-properties-2 + Spring Boot Properties Module + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-properties/pom.xml b/spring-boot-modules/spring-boot-properties/pom.xml index 98d328bd19..a5594ee2de 100644 --- a/spring-boot-modules/spring-boot-properties/pom.xml +++ b/spring-boot-modules/spring-boot-properties/pom.xml @@ -2,19 +2,21 @@ 4.0.0 - spring-boot-properties - spring-boot-properties - jar - Spring Boot Properties Module - 0.0.1-SNAPSHOT - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-properties + jar + 0.0.1-SNAPSHOT + + spring-boot-properties + Spring Boot Properties Module + commons-configuration diff --git a/spring-boot-modules/spring-boot-runtime/disabling-console-jul/pom.xml b/spring-boot-modules/spring-boot-runtime/disabling-console-jul/pom.xml index 2f1c9c2add..77629ffdd1 100644 --- a/spring-boot-modules/spring-boot-runtime/disabling-console-jul/pom.xml +++ b/spring-boot-modules/spring-boot-runtime/disabling-console-jul/pom.xml @@ -7,9 +7,10 @@ - com.baeldung + com.baeldung.spring-boot-modules spring-boot-runtime - 0.0.1-SNAPSHOT + 1.0.0-SNAPSHOT + ../ diff --git a/spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/pom.xml b/spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/pom.xml index 35f54999ec..fd57eccbbf 100644 --- a/spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/pom.xml +++ b/spring-boot-modules/spring-boot-runtime/disabling-console-log4j2/pom.xml @@ -7,9 +7,10 @@ - com.baeldung + com.baeldung.spring-boot-modules spring-boot-runtime - 0.0.1-SNAPSHOT + 1.0.0-SNAPSHOT + ../ diff --git a/spring-boot-modules/spring-boot-runtime/disabling-console-logback/pom.xml b/spring-boot-modules/spring-boot-runtime/disabling-console-logback/pom.xml index c96dfb6a2f..8cb0e24bb7 100644 --- a/spring-boot-modules/spring-boot-runtime/disabling-console-logback/pom.xml +++ b/spring-boot-modules/spring-boot-runtime/disabling-console-logback/pom.xml @@ -7,9 +7,10 @@ disabling-console-logback - com.baeldung + com.baeldung.spring-boot-modules spring-boot-runtime - 0.0.1-SNAPSHOT + 1.0.0-SNAPSHOT + ../ diff --git a/spring-boot-modules/spring-boot-runtime/pom.xml b/spring-boot-modules/spring-boot-runtime/pom.xml index 8c85735d8e..d3966beb65 100644 --- a/spring-boot-modules/spring-boot-runtime/pom.xml +++ b/spring-boot-modules/spring-boot-runtime/pom.xml @@ -2,18 +2,20 @@ 4.0.0 - spring-boot-runtime - spring-boot-runtime - pom - Demo project for Spring Boot - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-runtime + pom + + spring-boot-runtime + Demo project for Spring Boot + disabling-console-jul disabling-console-log4j2 @@ -170,7 +172,6 @@ 2.0.2.RELEASE 4.5.8 2.1.6 - 2.6 diff --git a/spring-boot-modules/spring-boot-security/pom.xml b/spring-boot-modules/spring-boot-security/pom.xml index b9f28b68c4..33b7cbfd74 100644 --- a/spring-boot-modules/spring-boot-security/pom.xml +++ b/spring-boot-modules/spring-boot-security/pom.xml @@ -2,18 +2,20 @@ 4.0.0 - spring-boot-security - spring-boot-security - Spring Boot Security Auto-Configuration - jar - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-security + jar + + spring-boot-security + Spring Boot Security Auto-Configuration + org.springframework.boot @@ -84,9 +86,7 @@ com.baeldung.springbootsecurity.basic_auth.SpringBootSecurityApplication - 2.6 2.4.0.RELEASE - 2.6 2.2.2.RELEASE diff --git a/spring-boot-modules/spring-boot-springdoc/pom.xml b/spring-boot-modules/spring-boot-springdoc/pom.xml index 4bede8c796..3e8d5175f7 100644 --- a/spring-boot-modules/spring-boot-springdoc/pom.xml +++ b/spring-boot-modules/spring-boot-springdoc/pom.xml @@ -4,19 +4,21 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - spring-boot-springdoc - 0.0.1-SNAPSHOT - spring-boot-springdoc - jar - Project for Springdoc integration - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-springdoc + 0.0.1-SNAPSHOT + jar + + spring-boot-springdoc + Project for Springdoc integration + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-testing/pom.xml b/spring-boot-modules/spring-boot-testing/pom.xml index 8353f9de61..a3b176af88 100644 --- a/spring-boot-modules/spring-boot-testing/pom.xml +++ b/spring-boot-modules/spring-boot-testing/pom.xml @@ -3,18 +3,20 @@ 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-boot-testing - spring-boot-testing - war - This is simple boot application for demonstrating testing features. - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-testing + war + + spring-boot-testing + This is simple boot application for demonstrating testing features. + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-vue/pom.xml b/spring-boot-modules/spring-boot-vue/pom.xml index 0a6307e46b..9973246115 100644 --- a/spring-boot-modules/spring-boot-vue/pom.xml +++ b/spring-boot-modules/spring-boot-vue/pom.xml @@ -2,19 +2,21 @@ 4.0.0 - spring-boot-vue - 0.0.1-SNAPSHOT - spring-boot-vue - jar - Demo project for Spring Boot Vue project - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-vue + 0.0.1-SNAPSHOT + jar + + spring-boot-vue + Demo project for Spring Boot Vue project + org.springframework.boot @@ -43,9 +45,4 @@ - - UTF-8 - UTF-8 - - diff --git a/spring-boot-modules/spring-boot/pom.xml b/spring-boot-modules/spring-boot/pom.xml index e0ff9ae2f9..e1299a6a16 100644 --- a/spring-boot-modules/spring-boot/pom.xml +++ b/spring-boot-modules/spring-boot/pom.xml @@ -3,40 +3,22 @@ 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-boot - spring-boot - war - This is simple boot application for Spring boot actuator test - 0.0.1-SNAPSHOT - parent-boot-2 - com.baeldung - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot + 0.0.1-SNAPSHOT + war + + spring-boot + This is simple boot application for Spring boot actuator test + - - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - - - org.junit.platform - junit-platform-launcher - ${junit-platform.version} - test - org.springframework.boot spring-boot-starter-thymeleaf diff --git a/spring-cloud-data-flow/spring-cloud-data-flow-etl/customer-mongodb-sink/pom.xml b/spring-cloud-data-flow/spring-cloud-data-flow-etl/customer-mongodb-sink/pom.xml index 43772505a4..f4557335d6 100644 --- a/spring-cloud-data-flow/spring-cloud-data-flow-etl/customer-mongodb-sink/pom.xml +++ b/spring-cloud-data-flow/spring-cloud-data-flow-etl/customer-mongodb-sink/pom.xml @@ -60,8 +60,6 @@ - UTF-8 - UTF-8 Hoxton.SR4 diff --git a/spring-cloud-data-flow/spring-cloud-data-flow-etl/customer-transform/pom.xml b/spring-cloud-data-flow/spring-cloud-data-flow-etl/customer-transform/pom.xml index f0d18a1c4f..81f194c772 100644 --- a/spring-cloud-data-flow/spring-cloud-data-flow-etl/customer-transform/pom.xml +++ b/spring-cloud-data-flow/spring-cloud-data-flow-etl/customer-transform/pom.xml @@ -52,8 +52,6 @@ - UTF-8 - UTF-8 Hoxton.SR4 diff --git a/spring-cloud/spring-cloud-bootstrap/README.md b/spring-cloud/spring-cloud-bootstrap/README.md index 01998ccf51..223c21b762 100644 --- a/spring-cloud/spring-cloud-bootstrap/README.md +++ b/spring-cloud/spring-cloud-bootstrap/README.md @@ -11,6 +11,7 @@ This module contains articles about bootstrapping Spring Cloud applications ### Running the Project +- First, you need a redis server running on the default port - To run the project: - copy the appliction-config folder to c:\Users\{username}\ on Windows or /home/{username}/ on *nix. Then open a git bash terminal in application-config and run: - git init diff --git a/spring-cloud/spring-cloud-bootstrap/customer-service/pom.xml b/spring-cloud/spring-cloud-bootstrap/customer-service/pom.xml index 3e33e27c6c..8fcf4adadb 100644 --- a/spring-cloud/spring-cloud-bootstrap/customer-service/pom.xml +++ b/spring-cloud/spring-cloud-bootstrap/customer-service/pom.xml @@ -16,13 +16,6 @@ ../../../parent-boot-2 - - 1.8 - 1.8 - 1.8 - UTF-8 - - org.springframework.boot @@ -81,4 +74,9 @@ + + + 1.8 + 1.8 + diff --git a/spring-cloud/spring-cloud-bootstrap/order-service/pom.xml b/spring-cloud/spring-cloud-bootstrap/order-service/pom.xml index 8f3c9ceaff..a1c6c1c39f 100644 --- a/spring-cloud/spring-cloud-bootstrap/order-service/pom.xml +++ b/spring-cloud/spring-cloud-bootstrap/order-service/pom.xml @@ -21,16 +21,6 @@ order-server - - 1.8 - 2.6 - 0.0.2 - 1.8 - 1.8 - UTF-8 - com.baeldung.orderservice.OrderApplication - - @@ -120,4 +110,13 @@ + + + 1.8 + 2.6 + 0.0.2 + 1.8 + 1.8 + com.baeldung.orderservice.OrderApplication + diff --git a/spring-cloud/spring-cloud-bootstrap/pom.xml b/spring-cloud/spring-cloud-bootstrap/pom.xml index ed9b148564..eb1a55c2a9 100644 --- a/spring-cloud/spring-cloud-bootstrap/pom.xml +++ b/spring-cloud/spring-cloud-bootstrap/pom.xml @@ -22,7 +22,6 @@ zipkin customer-service order-service - shared-dto - \ No newline at end of file + diff --git a/spring-cloud/spring-cloud-bootstrap/shared-dto/pom.xml b/spring-cloud/spring-cloud-bootstrap/shared-dto/pom.xml deleted file mode 100644 index 59dde717b5..0000000000 --- a/spring-cloud/spring-cloud-bootstrap/shared-dto/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - 4.0.0 - com.baeldung - shared-dto - 1.0.0-SNAPSHOT - shared-dto - - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../../parent-boot-2 - - - - - UTF-8 - 1.8 - 1.8 - 0.0.2 - - - - - org.qunix - structure-maven-plugin - ${structure-maven.version} - - - org.projectlombok - lombok - true - - - - - - - - org.qunix - structure-maven-plugin - ${structure-maven.version} - false - - - compile - - files - - - - - - - - diff --git a/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/deliverydto/CustomerDTO.java b/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/deliverydto/CustomerDTO.java deleted file mode 100644 index aa6b3ceac8..0000000000 --- a/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/deliverydto/CustomerDTO.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.deliverydto; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@AllArgsConstructor -public class CustomerDTO { - private String firstName; - private String lastName; - private String homeAddress; - private String contactNumber; - // constructor, getters, setters -} diff --git a/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/shared/CustomerDTO.java b/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/shared/CustomerDTO.java deleted file mode 100644 index 905773609d..0000000000 --- a/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/shared/CustomerDTO.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.shared; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@AllArgsConstructor -public class CustomerDTO { - private String firstName; - private String lastName; - private String cardNumber; - // constructor, getters, setters -} diff --git a/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/shared/OrderDTO.java b/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/shared/OrderDTO.java deleted file mode 100644 index 0640b84291..0000000000 --- a/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/shared/OrderDTO.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.shared; - - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@AllArgsConstructor -public class OrderDTO { - - private int customerId; - private String itemId; - -} diff --git a/spring-cloud/spring-cloud-circuit-breaker/pom.xml b/spring-cloud/spring-cloud-circuit-breaker/pom.xml index ae44fa8199..680d835c19 100644 --- a/spring-cloud/spring-cloud-circuit-breaker/pom.xml +++ b/spring-cloud/spring-cloud-circuit-breaker/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-cloud-circuit-breaker - spring-cloud-gateway + spring-cloud-circuit-breaker jar diff --git a/spring-cloud/spring-cloud-contract/pom.xml b/spring-cloud/spring-cloud-contract/pom.xml index 2f868980db..f26f1d7e3b 100644 --- a/spring-cloud/spring-cloud-contract/pom.xml +++ b/spring-cloud/spring-cloud-contract/pom.xml @@ -53,8 +53,6 @@ - UTF-8 - UTF-8 2.1.1.RELEASE 2.1.4.RELEASE diff --git a/spring-cloud/spring-cloud-functions/pom.xml b/spring-cloud/spring-cloud-functions/pom.xml index 03510d0504..4654d70dd7 100644 --- a/spring-cloud/spring-cloud-functions/pom.xml +++ b/spring-cloud/spring-cloud-functions/pom.xml @@ -82,8 +82,6 @@ - UTF-8 - UTF-8 1.0.1.RELEASE 2.0.2 1.1.0 diff --git a/spring-cloud/spring-cloud-open-service-broker/pom.xml b/spring-cloud/spring-cloud-open-service-broker/pom.xml index 7acd302dc1..42e90402e5 100644 --- a/spring-cloud/spring-cloud-open-service-broker/pom.xml +++ b/spring-cloud/spring-cloud-open-service-broker/pom.xml @@ -13,12 +13,6 @@ 1.0.0-SNAPSHOT - - 3.1.1.RELEASE - 2.2.7.RELEASE - 3.3.5.RELEASE - - org.springframework.cloud @@ -38,4 +32,10 @@ + + 3.1.1.RELEASE + 2.2.7.RELEASE + 3.3.5.RELEASE + + diff --git a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/main/resources/application.yml b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/main/resources/application.yml index 3199f38dce..29d2360793 100644 --- a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/main/resources/application.yml +++ b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/main/resources/application.yml @@ -9,7 +9,7 @@ weather-service: ribbon: eureka: enabled: false - listOfServers: http://localhost:8081, http://localhost:8082 + listOfServers: http://localhost:8021, http://localhost:8022 ServerListRefreshInterval: 5000 MaxAutoRetries: 3 MaxAutoRetriesNextServer: 1 diff --git a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetryFailureIntegrationTest.java b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetryFailureIntegrationTest.java index 0e72bdbb86..0f0a1c4255 100644 --- a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetryFailureIntegrationTest.java +++ b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetryFailureIntegrationTest.java @@ -24,8 +24,8 @@ public class RibbonRetryFailureIntegrationTest { @BeforeAll public static void setup() { - weatherServiceInstance1 = startApp(8081); - weatherServiceInstance2 = startApp(8082); + weatherServiceInstance1 = startApp(8021); + weatherServiceInstance2 = startApp(8022); } @AfterAll diff --git a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetrySuccessIntegrationTest.java b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetrySuccessIntegrationTest.java index 2055159117..6fdad0f2a9 100644 --- a/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetrySuccessIntegrationTest.java +++ b/spring-cloud/spring-cloud-ribbon-retry/ribbon-client-service/src/test/java/com/baeldung/spring/cloud/ribbon/retry/RibbonRetrySuccessIntegrationTest.java @@ -25,8 +25,8 @@ public class RibbonRetrySuccessIntegrationTest { @BeforeAll public static void setup() { - weatherServiceInstance1 = startApp(8081); - weatherServiceInstance2 = startApp(8082); + weatherServiceInstance1 = startApp(8021); + weatherServiceInstance2 = startApp(8022); } private static ConfigurableApplicationContext startApp(int port) { diff --git a/spring-cloud/spring-cloud-vault/pom.xml b/spring-cloud/spring-cloud-vault/pom.xml index dbdbcb2c50..a5a29d9024 100644 --- a/spring-cloud/spring-cloud-vault/pom.xml +++ b/spring-cloud/spring-cloud-vault/pom.xml @@ -78,8 +78,6 @@ - UTF-8 - UTF-8 Greenwich.RELEASE diff --git a/spring-cloud/spring-cloud-zuul/pom.xml b/spring-cloud/spring-cloud-zuul/pom.xml index e0a63ae00b..140a1337b3 100644 --- a/spring-cloud/spring-cloud-zuul/pom.xml +++ b/spring-cloud/spring-cloud-zuul/pom.xml @@ -72,8 +72,6 @@ - UTF-8 - UTF-8 Hoxton.RELEASE 2.2.2.RELEASE diff --git a/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/pom.xml b/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/pom.xml index 34f0e6b7ae..fd6d18fc09 100644 --- a/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/pom.xml +++ b/spring-cloud/spring-cloud-zuul/spring-zuul-rate-limiting/pom.xml @@ -48,8 +48,6 @@ - UTF-8 - UTF-8 Finchley.SR1 2.0.6.RELEASE 2.2.0.RELEASE diff --git a/spring-data-rest/pom.xml b/spring-data-rest/pom.xml index bb592c08d5..741d146fbf 100644 --- a/spring-data-rest/pom.xml +++ b/spring-data-rest/pom.xml @@ -88,7 +88,6 @@ - UTF-8 com.baeldung.books.SpringDataRestApplication 1.0 diff --git a/spring-ejb/ejb-beans/pom.xml b/spring-ejb/ejb-beans/pom.xml index c9edfc21f8..299de584ef 100644 --- a/spring-ejb/ejb-beans/pom.xml +++ b/spring-ejb/ejb-beans/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.baeldung.singletonsession ejb-beans - spring-ejb-beans + ejb-beans com.baeldung.spring.ejb @@ -31,7 +31,6 @@ javaee-api provided - org.apache.openejb tomee-embedded @@ -81,6 +80,62 @@ + + wildfly-managed-arquillian + + true + + + + org.wildfly + wildfly-arquillian-container-managed + ${wildfly.version} + test + + + + + + + maven-dependency-plugin + ${maven-dependency-plugin.version} + + ${maven.test.skip} + + + + unpack + process-test-classes + + unpack + + + + + org.wildfly + wildfly-dist + ${wildfly.version} + zip + false + ${project.build.directory} + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + always + + + + + arquillian-glassfish-embedded @@ -117,12 +172,15 @@ 1.7.5 3.1.2 1.0.0.CR4 + 8.2.1.Final 3.2 5.2.3.RELEASE 5.10.2 5.13.1 2.21.0 1.8.5 + 2.8 + 8.2.1.Final diff --git a/spring-ejb/ejb-beans/src/test/java/com/baeldung/ejb/stateless/StatelessEJBIntegrationTest.java b/spring-ejb/ejb-beans/src/test/java/com/baeldung/ejb/stateless/StatelessEJBIntegrationTest.java index a970ef90ae..f74d62c36a 100644 --- a/spring-ejb/ejb-beans/src/test/java/com/baeldung/ejb/stateless/StatelessEJBIntegrationTest.java +++ b/spring-ejb/ejb-beans/src/test/java/com/baeldung/ejb/stateless/StatelessEJBIntegrationTest.java @@ -6,6 +6,7 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; @@ -17,6 +18,7 @@ import javax.inject.Inject; @RunWith(Arquillian.class) +@Ignore("Will be fixed in BAEL-4422") public class StatelessEJBIntegrationTest { @Inject diff --git a/spring-ejb/ejb-beans/src/test/resources/arquillian.xml b/spring-ejb/ejb-beans/src/test/resources/arquillian.xml new file mode 100644 index 0000000000..3316f41f7c --- /dev/null +++ b/spring-ejb/ejb-beans/src/test/resources/arquillian.xml @@ -0,0 +1,23 @@ + + + + + target/wildfly-8.2.1.Final + standalone.xml + true + 9990 + -Djboss.http.port=8734 + + + + + + 127.0.0.1 + 9990 + admin + pass + true + + + + \ No newline at end of file diff --git a/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/setup/test/EJBSetupIntegrationTest.java b/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/setup/test/EJBSetupLiveTest.java similarity index 69% rename from spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/setup/test/EJBSetupIntegrationTest.java rename to spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/setup/test/EJBSetupLiveTest.java index c04a649d26..e85d2f155a 100644 --- a/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/setup/test/EJBSetupIntegrationTest.java +++ b/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/setup/test/EJBSetupLiveTest.java @@ -6,7 +6,12 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class EJBSetupIntegrationTest { +/** + * This Live Test requires: + * * run the `spring-ejb-remote` module with the following command: `mvn clean package cargo:run -Pwildfly-standalone` + * + */ +public class EJBSetupLiveTest { @Test public void EJBClientTest() { diff --git a/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/wildfly/TextApplicationIntegrationTest.java b/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/wildfly/TextApplicationLiveTest.java similarity index 74% rename from spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/wildfly/TextApplicationIntegrationTest.java rename to spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/wildfly/TextApplicationLiveTest.java index 8dff116ca1..616811eae6 100644 --- a/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/wildfly/TextApplicationIntegrationTest.java +++ b/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/wildfly/TextApplicationLiveTest.java @@ -8,7 +8,12 @@ import java.io.ByteArrayOutputStream; import java.io.PrintStream; import static org.junit.Assert.*; -public class TextApplicationIntegrationTest { +/** + * This Live Test requires: + * * run the `spring-ejb-remote` module with the following command: `mvn clean package cargo:run -Pwildfly-standalone` + * + */ +public class TextApplicationLiveTest { private static ByteArrayOutputStream outContent; @@ -26,6 +31,6 @@ public class TextApplicationIntegrationTest { @Test public void givenInputString_whenCompareTtoStringPrintedToConsole_thenSuccessful() throws NamingException { TextApplication.main(new String[]{}); - assertEquals("SAMPLE TEXT", outContent.toString()); + assertTrue(outContent.toString().contains("SAMPLE TEXT")); } } \ No newline at end of file diff --git a/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/springejbclient/SpringEjbClientApplicationIntegrationTest.java b/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/springejbclient/SpringEjbClientApplicationIntegrationTest.java deleted file mode 100644 index 89c88fe5a5..0000000000 --- a/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/springejbclient/SpringEjbClientApplicationIntegrationTest.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.springejbclient; - -import org.junit.Test; - -public class SpringEjbClientApplicationIntegrationTest { - - @Test - public void contextLoads() { - } - -} diff --git a/spring-integration/pom.xml b/spring-integration/pom.xml index a985f55d89..11b2803095 100644 --- a/spring-integration/pom.xml +++ b/spring-integration/pom.xml @@ -117,7 +117,6 @@ - UTF-8 5.0.13.RELEASE 1.1.4.RELEASE 1.4.7 diff --git a/spring-mvc-crash/pom.xml b/spring-mvc-crash/pom.xml index d23e18361b..8a902d4937 100644 --- a/spring-mvc-crash/pom.xml +++ b/spring-mvc-crash/pom.xml @@ -5,7 +5,7 @@ 4.0.0 spring-mvc-crash 0.1-SNAPSHOT - spring-mvc-xml + spring-mvc-crash war diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerRealIntegrationTest.java b/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerRealIntegrationTest.java new file mode 100644 index 0000000000..05c6313e76 --- /dev/null +++ b/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerRealIntegrationTest.java @@ -0,0 +1,34 @@ +package com.baeldung.web.controller; + +import io.restassured.RestAssured; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import static io.restassured.RestAssured.given; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = RANDOM_PORT) +@TestPropertySource(properties = {"spring.main.allow-bean-definition-overriding=true", "server.servlet.context-path=/"}) +public class GreetControllerRealIntegrationTest { + + @LocalServerPort + private int port; + + @Before + public void setUp() { + RestAssured.port = port; + } + + @Test + public void givenGreetURI_whenSendingReq_thenVerifyResponse() { + given().get("/greet") + .then() + .statusCode(200); + } +} diff --git a/spring-remoting/remoting-jms/remoting-jms-client/pom.xml b/spring-remoting/remoting-jms/remoting-jms-client/pom.xml index d8b9701600..2f3f993b2e 100644 --- a/spring-remoting/remoting-jms/remoting-jms-client/pom.xml +++ b/spring-remoting/remoting-jms/remoting-jms-client/pom.xml @@ -30,8 +30,4 @@ - - UTF-8 - - \ No newline at end of file diff --git a/spring-remoting/remoting-jms/remoting-jms-server/pom.xml b/spring-remoting/remoting-jms/remoting-jms-server/pom.xml index 5d6d63219d..53d95edcd7 100644 --- a/spring-remoting/remoting-jms/remoting-jms-server/pom.xml +++ b/spring-remoting/remoting-jms/remoting-jms-server/pom.xml @@ -30,8 +30,4 @@ - - UTF-8 - - \ No newline at end of file diff --git a/spring-remoting/remoting-rmi/remoting-rmi-server/pom.xml b/spring-remoting/remoting-rmi/remoting-rmi-server/pom.xml index 94bdccd093..cb5eaa1031 100644 --- a/spring-remoting/remoting-rmi/remoting-rmi-server/pom.xml +++ b/spring-remoting/remoting-rmi/remoting-rmi-server/pom.xml @@ -30,8 +30,4 @@ - - UTF-8 - - \ No newline at end of file diff --git a/spring-resttemplate-2/pom.xml b/spring-resttemplate-2/pom.xml index 1a594fd21e..b1d6f60c53 100644 --- a/spring-resttemplate-2/pom.xml +++ b/spring-resttemplate-2/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - spring-resttemplate + spring-resttemplate-2 0.1-SNAPSHOT spring-resttemplate-2 war diff --git a/spring-roo/pom.xml b/spring-roo/pom.xml index 448574ed19..a3680ade70 100644 --- a/spring-roo/pom.xml +++ b/spring-roo/pom.xml @@ -605,11 +605,9 @@ 2.0.0.RELEASE 8 - UTF-8 1.8 1.5.4 2.1.7.RELEASE - 1.8 1.2.0.RELEASE 1.1.2 3.0.0.RELEASE diff --git a/spring-security-modules/pom.xml b/spring-security-modules/pom.xml index e78b7fe80c..472c6b6e0d 100644 --- a/spring-security-modules/pom.xml +++ b/spring-security-modules/pom.xml @@ -17,9 +17,8 @@ spring-security-acl spring-security-auth0 spring-security-angular/server - spring-security-cache-control + spring-security-config spring-security-core - spring-security-cors spring-security-mvc spring-security-mvc-boot-1 spring-security-mvc-boot-2 diff --git a/spring-security-modules/spring-security-cache-control/README.md b/spring-security-modules/spring-security-config/cache-control/README.md similarity index 100% rename from spring-security-modules/spring-security-cache-control/README.md rename to spring-security-modules/spring-security-config/cache-control/README.md diff --git a/spring-security-modules/spring-security-cache-control/pom.xml b/spring-security-modules/spring-security-config/cache-control/pom.xml similarity index 88% rename from spring-security-modules/spring-security-cache-control/pom.xml rename to spring-security-modules/spring-security-config/cache-control/pom.xml index 743b3c291d..753307493d 100644 --- a/spring-security-modules/spring-security-cache-control/pom.xml +++ b/spring-security-modules/spring-security-config/cache-control/pom.xml @@ -2,15 +2,15 @@ 4.0.0 - spring-security-cache-control + cache-control 1.0-SNAPSHOT - spring-security-cache-control + cache-control com.baeldung parent-boot-2 0.0.1-SNAPSHOT - ../../parent-boot-2 + ../../../parent-boot-2 diff --git a/spring-security-modules/spring-security-cache-control/src/main/java/com/baeldung/cachecontrol/AppRunner.java b/spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/AppRunner.java similarity index 100% rename from spring-security-modules/spring-security-cache-control/src/main/java/com/baeldung/cachecontrol/AppRunner.java rename to spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/AppRunner.java diff --git a/spring-security-modules/spring-security-cache-control/src/main/java/com/baeldung/cachecontrol/ResourceEndpoint.java b/spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/ResourceEndpoint.java similarity index 100% rename from spring-security-modules/spring-security-cache-control/src/main/java/com/baeldung/cachecontrol/ResourceEndpoint.java rename to spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/ResourceEndpoint.java diff --git a/spring-security-modules/spring-security-cache-control/src/main/java/com/baeldung/cachecontrol/config/SpringSecurityConfig.java b/spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/config/SpringSecurityConfig.java similarity index 100% rename from spring-security-modules/spring-security-cache-control/src/main/java/com/baeldung/cachecontrol/config/SpringSecurityConfig.java rename to spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/config/SpringSecurityConfig.java diff --git a/spring-security-modules/spring-security-cache-control/src/main/java/com/baeldung/cachecontrol/model/TimestampDto.java b/spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/model/TimestampDto.java similarity index 100% rename from spring-security-modules/spring-security-cache-control/src/main/java/com/baeldung/cachecontrol/model/TimestampDto.java rename to spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/model/TimestampDto.java diff --git a/spring-security-modules/spring-security-cache-control/src/main/java/com/baeldung/cachecontrol/model/UserDto.java b/spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/model/UserDto.java similarity index 100% rename from spring-security-modules/spring-security-cache-control/src/main/java/com/baeldung/cachecontrol/model/UserDto.java rename to spring-security-modules/spring-security-config/cache-control/src/main/java/com/baeldung/cachecontrol/model/UserDto.java diff --git a/spring-security-modules/spring-security-config/cache-control/src/main/resources/logback.xml b/spring-security-modules/spring-security-config/cache-control/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/spring-security-modules/spring-security-config/cache-control/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-security-modules/spring-security-cache-control/src/test/java/com/baeldung/SpringContextTest.java b/spring-security-modules/spring-security-config/cache-control/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-security-modules/spring-security-cache-control/src/test/java/com/baeldung/SpringContextTest.java rename to spring-security-modules/spring-security-config/cache-control/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-security-modules/spring-security-cache-control/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java b/spring-security-modules/spring-security-config/cache-control/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java similarity index 100% rename from spring-security-modules/spring-security-cache-control/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java rename to spring-security-modules/spring-security-config/cache-control/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java diff --git a/spring-security-modules/spring-security-cors/README.md b/spring-security-modules/spring-security-config/cors/README.md similarity index 100% rename from spring-security-modules/spring-security-cors/README.md rename to spring-security-modules/spring-security-config/cors/README.md diff --git a/spring-security-modules/spring-security-cors/pom.xml b/spring-security-modules/spring-security-config/cors/pom.xml similarity index 87% rename from spring-security-modules/spring-security-cors/pom.xml rename to spring-security-modules/spring-security-config/cors/pom.xml index 2acb99368f..19ca7f5ccc 100644 --- a/spring-security-modules/spring-security-cors/pom.xml +++ b/spring-security-modules/spring-security-config/cors/pom.xml @@ -2,8 +2,8 @@ 4.0.0 - spring-security-cors - spring-security-cors + cors + cors jar Spring Security CORS @@ -56,9 +56,4 @@ - - UTF-8 - UTF-8 - - diff --git a/spring-security-modules/spring-security-cors/src/main/java/com/baeldung/springbootsecuritycors/basicauth/SpringBootSecurityApplication.java b/spring-security-modules/spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors/basicauth/SpringBootSecurityApplication.java similarity index 100% rename from spring-security-modules/spring-security-cors/src/main/java/com/baeldung/springbootsecuritycors/basicauth/SpringBootSecurityApplication.java rename to spring-security-modules/spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors/basicauth/SpringBootSecurityApplication.java diff --git a/spring-security-modules/spring-security-cors/src/main/java/com/baeldung/springbootsecuritycors/basicauth/config/WebSecurityConfig.java b/spring-security-modules/spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors/basicauth/config/WebSecurityConfig.java similarity index 100% rename from spring-security-modules/spring-security-cors/src/main/java/com/baeldung/springbootsecuritycors/basicauth/config/WebSecurityConfig.java rename to spring-security-modules/spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors/basicauth/config/WebSecurityConfig.java diff --git a/spring-security-modules/spring-security-cors/src/main/java/com/baeldung/springbootsecuritycors/controller/ResourceController.java b/spring-security-modules/spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors/controller/ResourceController.java similarity index 100% rename from spring-security-modules/spring-security-cors/src/main/java/com/baeldung/springbootsecuritycors/controller/ResourceController.java rename to spring-security-modules/spring-security-config/cors/src/main/java/com/baeldung/springbootsecuritycors/controller/ResourceController.java diff --git a/spring-security-modules/spring-security-cors/src/test/java/com/baeldung/springbootsecuritycors/ResourceControllerUnitTest.java b/spring-security-modules/spring-security-config/cors/src/test/java/com/baeldung/springbootsecuritycors/ResourceControllerUnitTest.java similarity index 100% rename from spring-security-modules/spring-security-cors/src/test/java/com/baeldung/springbootsecuritycors/ResourceControllerUnitTest.java rename to spring-security-modules/spring-security-config/cors/src/test/java/com/baeldung/springbootsecuritycors/ResourceControllerUnitTest.java diff --git a/spring-security-modules/spring-security-config/pom.xml b/spring-security-modules/spring-security-config/pom.xml new file mode 100644 index 0000000000..b3796d1cc6 --- /dev/null +++ b/spring-security-modules/spring-security-config/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + spring-security-config + 0.0.1-SNAPSHOT + spring-security-conf + pom + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + cache-control + cors + + + diff --git a/spring-security-modules/spring-security-kotlin-dsl/pom.xml b/spring-security-modules/spring-security-kotlin-dsl/pom.xml index 2c53d19c2c..24e99decfb 100644 --- a/spring-security-modules/spring-security-kotlin-dsl/pom.xml +++ b/spring-security-modules/spring-security-kotlin-dsl/pom.xml @@ -15,11 +15,6 @@ spring-security-kotlin-dsl Spring Security Kotlin DSL - - 11 - 1.3.72 - - org.springframework.boot @@ -83,4 +78,10 @@ + + + 11 + 1.3.72 + + diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageFilter.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageFilter.java new file mode 100644 index 0000000000..3c6d076756 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageFilter.java @@ -0,0 +1,43 @@ +package com.baeldung.loginredirect; + +import org.apache.http.HttpStatus; +import org.springframework.security.authentication.AnonymousAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.web.filter.GenericFilterBean; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +class LoginPageFilter extends GenericFilterBean { + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + HttpServletRequest servletRequest = (HttpServletRequest) request; + HttpServletResponse servletResponse = (HttpServletResponse) response; + + if (isAuthenticated() && "/loginUser".equals(servletRequest.getRequestURI())) { + + String encodedRedirectURL = ((HttpServletResponse) response).encodeRedirectURL( + servletRequest.getContextPath() + "/userMainPage"); + + servletResponse.setStatus(HttpStatus.SC_TEMPORARY_REDIRECT); + servletResponse.setHeader("Location", encodedRedirectURL); + } + + chain.doFilter(servletRequest, servletResponse); + } + + private boolean isAuthenticated() { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + if (authentication == null || AnonymousAuthenticationToken.class.isAssignableFrom(authentication.getClass())) { + return false; + } + return authentication.isAuthenticated(); + } +} \ No newline at end of file diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageInterceptor.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageInterceptor.java new file mode 100644 index 0000000000..aa93201f37 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageInterceptor.java @@ -0,0 +1,39 @@ +package com.baeldung.loginredirect; + +import org.apache.http.HttpStatus; +import org.springframework.security.authentication.AnonymousAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; +import org.springframework.web.util.UrlPathHelper; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +class LoginPageInterceptor extends HandlerInterceptorAdapter { + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { + + UrlPathHelper urlPathHelper = new UrlPathHelper(); + if ("/loginUser".equals(urlPathHelper.getLookupPathForRequest(request)) && isAuthenticated()) { + + String encodedRedirectURL = response.encodeRedirectURL( + request.getContextPath() + "/userMainPage"); + response.setStatus(HttpStatus.SC_TEMPORARY_REDIRECT); + response.setHeader("Location", encodedRedirectURL); + + return false; + } else { + return true; + } + } + + private boolean isAuthenticated() { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + if (authentication == null || AnonymousAuthenticationToken.class.isAssignableFrom(authentication.getClass())) { + return false; + } + return authentication.isAuthenticated(); + } +} diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectApplication.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectApplication.java new file mode 100644 index 0000000000..1e44240449 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.loginredirect; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ImportResource; + +@SpringBootApplication +@ImportResource({"classpath*:spring-security-login-redirect.xml"}) +class LoginRedirectApplication { + public static void main(String[] args) { + SpringApplication.run(LoginRedirectApplication.class, args); + } +} \ No newline at end of file diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectMvcConfig.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectMvcConfig.java new file mode 100644 index 0000000000..ca2ddcb020 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectMvcConfig.java @@ -0,0 +1,14 @@ +package com.baeldung.loginredirect; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +class LoginRedirectMvcConfig implements WebMvcConfigurer { + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(new LoginPageInterceptor()); + } +} \ No newline at end of file diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectSecurityConfig.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectSecurityConfig.java new file mode 100644 index 0000000000..8bd3200608 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectSecurityConfig.java @@ -0,0 +1,43 @@ +package com.baeldung.loginredirect; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; + +@Configuration +@EnableWebSecurity +class LoginRedirectSecurityConfig extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + auth.inMemoryAuthentication().withUser("user").password(encoder().encode("user")).roles("USER"); + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + + http + .addFilterAfter(new LoginPageFilter(), UsernamePasswordAuthenticationFilter.class) + + .authorizeRequests() + .antMatchers("/loginUser").permitAll() + .antMatchers("/user*").hasRole("USER") + + .and().formLogin().loginPage("/loginUser").loginProcessingUrl("/user_login") + .failureUrl("/loginUser?error=loginError").defaultSuccessUrl("/userMainPage").permitAll() + + .and().logout().logoutUrl("/user_logout").logoutSuccessUrl("/loginUser").deleteCookies("JSESSIONID") + .and().csrf().disable(); + } + + @Bean + public static PasswordEncoder encoder() { + return new BCryptPasswordEncoder(); + } +} diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/UsersController.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/UsersController.java new file mode 100644 index 0000000000..308495d2ab --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/UsersController.java @@ -0,0 +1,32 @@ +package com.baeldung.loginredirect; + +import org.springframework.security.authentication.AnonymousAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +class UsersController { + + @GetMapping("/userMainPage") + public String getUserPage() { + return "userMainPage"; + } + + @GetMapping("/loginUser") + public String getUserLoginPage() { + if (isAuthenticated()) { + return "redirect:userMainPage"; + } + return "loginUser"; + } + + private boolean isAuthenticated() { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + if (authentication == null || AnonymousAuthenticationToken.class.isAssignableFrom(authentication.getClass())) { + return false; + } + return authentication.isAuthenticated(); + } +} diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/spring-security-login-redirect.xml b/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/spring-security-login-redirect.xml new file mode 100644 index 0000000000..e711abce1f --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/spring-security-login-redirect.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/templates/userMainPage.html b/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/templates/userMainPage.html new file mode 100644 index 0000000000..501d019790 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/templates/userMainPage.html @@ -0,0 +1,10 @@ + + + + +Baeldung Login Redirect + + +Welcome user! Logout + + \ No newline at end of file diff --git a/spring-security-modules/spring-security-mvc/pom.xml b/spring-security-modules/spring-security-mvc/pom.xml index 517aa83270..d97825975f 100644 --- a/spring-security-modules/spring-security-mvc/pom.xml +++ b/spring-security-modules/spring-security-mvc/pom.xml @@ -89,11 +89,6 @@ - - 5.2.2.RELEASE - 4.0.1 - - @@ -108,4 +103,9 @@ + + 5.2.2.RELEASE + 4.0.1 + + diff --git a/spring-security-modules/spring-security-rest/src/main/resources/webSecurityConfig.xml b/spring-security-modules/spring-security-rest/src/main/resources/webSecurityConfig.xml index 2c0a0bc774..b20151b8f4 100644 --- a/spring-security-modules/spring-security-rest/src/main/resources/webSecurityConfig.xml +++ b/spring-security-modules/spring-security-rest/src/main/resources/webSecurityConfig.xml @@ -33,6 +33,8 @@ class="com.baeldung.security.MySavedRequestAwareAuthenticationSuccessHandler" /> + diff --git a/spring-security-modules/spring-security-sso/spring-security-sso-kerberos/pom.xml b/spring-security-modules/spring-security-sso/spring-security-sso-kerberos/pom.xml index 0864ead1c4..a67cc4af83 100644 --- a/spring-security-modules/spring-security-sso/spring-security-sso-kerberos/pom.xml +++ b/spring-security-modules/spring-security-sso/spring-security-sso-kerberos/pom.xml @@ -11,31 +11,6 @@ 1.0.0-SNAPSHOT - - - - ${basedir}/src/main/resources - true - - **/* - - - - - - org.apache.maven.plugins - maven-resources-plugin - 2.7 - - - @ - - false - - - - - org.springframework.boot @@ -92,4 +67,29 @@ + + + + ${basedir}/src/main/resources + true + + **/* + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.7 + + + @ + + false + + + + + \ No newline at end of file diff --git a/spring-swagger-codegen/spring-openapi-generator-api-client/pom.xml b/spring-swagger-codegen/spring-openapi-generator-api-client/pom.xml index cc70a9f654..7c6de543ae 100644 --- a/spring-swagger-codegen/spring-openapi-generator-api-client/pom.xml +++ b/spring-swagger-codegen/spring-openapi-generator-api-client/pom.xml @@ -31,6 +31,97 @@ + + + sign-artifacts + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + + + + + + + io.swagger + swagger-annotations + ${swagger-annotations-version} + + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + + + org.springframework + spring-web + ${spring-web-version} + + + + + com.fasterxml.jackson.core + jackson-core + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson-databind-version} + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + ${jackson-version} + + + org.openapitools + jackson-databind-nullable + ${jackson-databind-nullable-version} + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson-version} + + + com.github.joschi.jackson + jackson-datatype-threetenbp + ${jackson-threetenbp-version} + + + + + junit + junit + ${junit-version} + test + + + @@ -170,98 +261,7 @@ - - - sign-artifacts - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - - - - - - - - - io.swagger - swagger-annotations - ${swagger-annotations-version} - - - - - com.google.code.findbugs - jsr305 - 3.0.2 - - - - - org.springframework - spring-web - ${spring-web-version} - - - - - com.fasterxml.jackson.core - jackson-core - ${jackson-version} - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson-version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson-databind-version} - - - com.fasterxml.jackson.jaxrs - jackson-jaxrs-json-provider - ${jackson-version} - - - org.openapitools - jackson-databind-nullable - ${jackson-databind-nullable-version} - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - ${jackson-version} - - - com.github.joschi.jackson - jackson-datatype-threetenbp - ${jackson-threetenbp-version} - - - - - junit - junit - ${junit-version} - test - - - UTF-8 1.5.22 4.3.9.RELEASE 2.10.1 diff --git a/spring-vault/pom.xml b/spring-vault/pom.xml index 40967e2894..a39c5575a9 100644 --- a/spring-vault/pom.xml +++ b/spring-vault/pom.xml @@ -38,7 +38,6 @@ - UTF-8 2.1.1.RELEASE diff --git a/testing-modules/easymock/pom.xml b/testing-modules/easymock/pom.xml index 4146ae6df4..98458b724d 100644 --- a/testing-modules/easymock/pom.xml +++ b/testing-modules/easymock/pom.xml @@ -23,7 +23,6 @@ - UTF-8 4.0.2 diff --git a/testing-modules/junit-5/pom.xml b/testing-modules/junit-5/pom.xml index 33fd0bbce8..831fa97e12 100644 --- a/testing-modules/junit-5/pom.xml +++ b/testing-modules/junit-5/pom.xml @@ -138,7 +138,7 @@ 1.4.2 5.4.2 2.8.2 - 2.0.0-RC.1 + 2.0.0 2.22.0 1.6.0 5.0.1.RELEASE diff --git a/testing-modules/parallel-tests-junit/math-test-functions/pom.xml b/testing-modules/parallel-tests-junit/math-test-functions/pom.xml index ba645d00ff..fb12803333 100644 --- a/testing-modules/parallel-tests-junit/math-test-functions/pom.xml +++ b/testing-modules/parallel-tests-junit/math-test-functions/pom.xml @@ -45,8 +45,4 @@ - - UTF-8 - - diff --git a/testing-modules/parallel-tests-junit/string-test-functions/pom.xml b/testing-modules/parallel-tests-junit/string-test-functions/pom.xml index 984dd64ce4..313d82c23f 100644 --- a/testing-modules/parallel-tests-junit/string-test-functions/pom.xml +++ b/testing-modules/parallel-tests-junit/string-test-functions/pom.xml @@ -37,8 +37,4 @@ - - UTF-8 - - diff --git a/twitter4j/pom.xml b/twitter4j/pom.xml index 0c36e72892..e2579bf73e 100644 --- a/twitter4j/pom.xml +++ b/twitter4j/pom.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 twitter4j - twitter4J + twitter4j jar diff --git a/vaadin/pom.xml b/vaadin/pom.xml index f8f709cef7..4814e70ae3 100644 --- a/vaadin/pom.xml +++ b/vaadin/pom.xml @@ -182,7 +182,6 @@ 8.8.5 8.8.5 9.3.9.v20160517 - UTF-8 1.8 1.8 local diff --git a/webrtc/pom.xml b/webrtc/pom.xml index 6dc98afb1c..f302ae97a2 100644 --- a/webrtc/pom.xml +++ b/webrtc/pom.xml @@ -22,10 +22,6 @@ - - 1.8 - - @@ -35,4 +31,8 @@ + + 1.8 + +