diff --git a/algorithms-miscellaneous-5/README.md b/algorithms-miscellaneous-5/README.md index 4ef919b33b..87a328e446 100644 --- a/algorithms-miscellaneous-5/README.md +++ b/algorithms-miscellaneous-5/README.md @@ -10,7 +10,6 @@ This module contains articles about algorithms. Some classes of algorithms, e.g. - [Find If Two Numbers Are Relatively Prime in Java](https://www.baeldung.com/java-two-relatively-prime-numbers) - [Knapsack Problem Implementation in Java](https://www.baeldung.com/java-knapsack) - [How to Determine if a Binary Tree is Balanced](https://www.baeldung.com/java-balanced-binary-tree) -- [The Caesar Cipher in Java](https://www.baeldung.com/java-caesar-cipher) - [Overview of Combinatorial Problems in Java](https://www.baeldung.com/java-combinatorial-algorithms) - [Prim’s Algorithm](https://www.baeldung.com/java-prim-algorithm) - [Maximum Subarray Problem](https://www.baeldung.com/java-maximum-subarray) diff --git a/apache-cxf/cxf-aegis/README.md b/apache-cxf/cxf-aegis/README.md deleted file mode 100644 index e055826554..0000000000 --- a/apache-cxf/cxf-aegis/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles - -- [Introduction to Apache CXF Aegis Data Binding](https://www.baeldung.com/aegis-data-binding-in-apache-cxf) diff --git a/apache-fop/README.md b/apache-fop/README.md deleted file mode 100644 index 2adc593026..0000000000 --- a/apache-fop/README.md +++ /dev/null @@ -1,5 +0,0 @@ -## Apache FOP - -This module contains articles about Apache FOP - -### Relevant Articles: diff --git a/apache-olingo/olingo2/README.md b/apache-olingo/olingo2/README.md index b1cb23d822..826cd0133e 100644 --- a/apache-olingo/olingo2/README.md +++ b/apache-olingo/olingo2/README.md @@ -1,4 +1,3 @@ ### Relevant Articles: -- [OData Protocol Guide](https://www.baeldung.com/odata) - [Intro to OData with Olingo](https://www.baeldung.com/olingo) diff --git a/apache-poi/README.md b/apache-poi/README.md index 742220aebc..b562fefc29 100644 --- a/apache-poi/README.md +++ b/apache-poi/README.md @@ -8,4 +8,4 @@ This module contains articles about Apache POI - [Creating a MS PowerPoint Presentation in Java](https://www.baeldung.com/apache-poi-slideshow) - [Merge Cells in Excel Using Apache POI](https://www.baeldung.com/java-apache-poi-merge-cells) - [Get String Value of Excel Cell with Apache POI](https://www.baeldung.com/java-apache-poi-cell-string-value) -- [Read Excel Cell Value Rather Than Formula With Apache POI](https://github.com/eugenp/tutorials/tree/master/apache-poi) +- [Read Excel Cell Value Rather Than Formula With Apache POI](https://www.baeldung.com/apache-poi-read-cell-value-formula) diff --git a/azure/src/main/resources/application.properties b/azure/src/main/resources/application.properties index 32ee873194..1c92245a6f 100644 --- a/azure/src/main/resources/application.properties +++ b/azure/src/main/resources/application.properties @@ -5,7 +5,7 @@ spring.jpa.hibernate.ddl-auto=create logging.file=azure.log logging.level.root=info -spring.datasource.url=jdbc:h2:file:~/test +spring.datasource.url=jdbc:h2:mem:azure-test-db spring.datasource.username=sa spring.datasource.password= diff --git a/cdi/pom.xml b/cdi/pom.xml index 87ad9c111a..32b9c8a360 100644 --- a/cdi/pom.xml +++ b/cdi/pom.xml @@ -26,8 +26,8 @@ org.hamcrest - hamcrest-core - ${org.hamcrest.version} + hamcrest + ${hamcrest.version} test diff --git a/core-java-modules/core-java-8-2/README.md b/core-java-modules/core-java-8-2/README.md index 3d38fbbdbc..961941aac7 100644 --- a/core-java-modules/core-java-8-2/README.md +++ b/core-java-modules/core-java-8-2/README.md @@ -3,7 +3,7 @@ This module contains articles about Java 8 core features ### Relevant Articles: -- [Anonymous Classes in Java](https://www.baeldung.com/java-anonymous-classes) + - [How to Delay Code Execution in Java](https://www.baeldung.com/java-delay-code-execution) - [Run a Java Application from the Command Line](https://www.baeldung.com/java-run-jar-with-arguments) - [Java 8 Stream skip() vs limit()](https://www.baeldung.com/java-stream-skip-vs-limit) diff --git a/core-java-modules/core-java-8/pom.xml b/core-java-modules/core-java-8/pom.xml index 889c30b76e..2a563333ad 100644 --- a/core-java-modules/core-java-8/pom.xml +++ b/core-java-modules/core-java-8/pom.xml @@ -48,25 +48,6 @@ true - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot-maven-plugin.version} - - - - repackage - - - spring-boot - com.baeldung.executable.ExecutableMavenJar - - - - - @@ -74,8 +55,6 @@ 4.1 3.6.1 - - 2.0.4.RELEASE diff --git a/core-java-modules/core-java-arrays-3/README.md b/core-java-modules/core-java-arrays-3/README.md deleted file mode 100644 index 9f2885a2ce..0000000000 --- a/core-java-modules/core-java-arrays-3/README.md +++ /dev/null @@ -1,5 +0,0 @@ -## Core Java Arrays (Part 3) - -This module contains articles about Java arrays - -## Relevant Articles diff --git a/core-java-modules/core-java-arrays/pom.xml b/core-java-modules/core-java-arrays/pom.xml index a70ab2d791..145b711135 100644 --- a/core-java-modules/core-java-arrays/pom.xml +++ b/core-java-modules/core-java-arrays/pom.xml @@ -66,101 +66,7 @@ - - org.apache.maven.plugins - maven-jar-plugin - ${maven-jar-plugin.version} - - - - true - libs/ - com.baeldung.executable.ExecutableMavenJar - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - package - - single - - - ${project.basedir} - - - com.baeldung.executable.ExecutableMavenJar - - - - jar-with-dependencies - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - ${maven-shade-plugin.version} - - - - shade - - - true - - - com.baeldung.executable.ExecutableMavenJar - - - - - - - - - com.jolira - onejar-maven-plugin - ${onejar-maven-plugin.version} - - - - com.baeldung.executable.ExecutableMavenJar - true - ${project.build.finalName}-onejar.${project.packaging} - - - one-jar - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot-maven-plugin.version} - - - - repackage - - - spring-boot - com.baeldung.executable.ExecutableMavenJar - - - - - + org.codehaus.mojo exec-maven-plugin @@ -250,110 +156,6 @@ - - - buildAgentLoader - - - - org.apache.maven.plugins - maven-jar-plugin - - - package - - jar - - - agentLoader - target/classes - - - true - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - com/baeldung/instrumentation/application/AgentLoader.class - com/baeldung/instrumentation/application/Launcher.class - - - - - - - - - - buildApplication - - - - org.apache.maven.plugins - maven-jar-plugin - - - package - - jar - - - application - target/classes - - - true - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - com/baeldung/instrumentation/application/MyAtm.class - com/baeldung/instrumentation/application/MyAtmApplication.class - com/baeldung/instrumentation/application/Launcher.class - - - - - - - - - - buildAgent - - - - org.apache.maven.plugins - maven-jar-plugin - - - package - - jar - - - agent - target/classes - - - true - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - com/baeldung/instrumentation/agent/AtmTransformer.class - com/baeldung/instrumentation/agent/MyInstrumentationAgent.class - - - - - - - - @@ -368,10 +170,6 @@ 3.0.0-M1 - 3.0.2 - 1.4.4 - 3.1.1 - 2.0.3.RELEASE 1.6.0 1.8 1.8 diff --git a/core-java-modules/core-java-lang-operators/README.md b/core-java-modules/core-java-lang-operators/README.md index 3af2c8885b..facbf40fc6 100644 --- a/core-java-modules/core-java-lang-operators/README.md +++ b/core-java-modules/core-java-lang-operators/README.md @@ -11,5 +11,4 @@ This module contains articles about Java operators - [Java Compound Operators](https://www.baeldung.com/java-compound-operators) - [The XOR Operator in Java](https://www.baeldung.com/java-xor-operator) - [Java Bitwise Operators](https://www.baeldung.com/java-bitwise-operators) -- [Bitwise & vs Logical && Operators](https://www.baeldung.com/bitwise-vs-logical-operators/) - +- [Bitwise & vs Logical && Operators](https://www.baeldung.com/java-bitwise-vs-logical-and) diff --git a/core-java-modules/core-java-regex/pom.xml b/core-java-modules/core-java-regex/pom.xml index 129b6039cd..1c55177d70 100644 --- a/core-java-modules/core-java-regex/pom.xml +++ b/core-java-modules/core-java-regex/pom.xml @@ -25,6 +25,12 @@ jmh-generator-annprocess ${jmh-core.version} + + org.assertj + assertj-core + 3.15.0 + test + diff --git a/core-java-modules/core-java-regex/src/main/java/com/baeldung/replacetokens/ReplacingTokens.java b/core-java-modules/core-java-regex/src/main/java/com/baeldung/replacetokens/ReplacingTokens.java new file mode 100644 index 0000000000..a4774ad572 --- /dev/null +++ b/core-java-modules/core-java-regex/src/main/java/com/baeldung/replacetokens/ReplacingTokens.java @@ -0,0 +1,63 @@ +package com.baeldung.replacetokens; + +import java.util.function.Function; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class ReplacingTokens { + public static final Pattern TITLE_CASE_PATTERN = Pattern.compile("(?<=^|[^A-Za-z])([A-Z][a-z]*)(?=[^A-Za-z]|$)"); + + /** + * Iterate over the title case tokens in the input and replace them with lowercase + * @param original the original string + * @return a string with words replaced with their lowercase equivalents + */ + public static String replaceTitleCaseWithLowerCase(String original) { + int lastIndex = 0; + StringBuilder output = new StringBuilder(); + Matcher matcher = TITLE_CASE_PATTERN.matcher(original); + while (matcher.find()) { + output.append(original, lastIndex, matcher.start()) + .append(convert(matcher.group(1))); + + lastIndex = matcher.end(); + } + if (lastIndex < original.length()) { + output.append(original, lastIndex, original.length()); + } + return output.toString(); + } + + /** + * Convert a token found into its desired lowercase + * @param token the token to convert + * @return the converted token + */ + private static String convert(String token) { + return token.toLowerCase(); + } + + /** + * Replace all the tokens in an input using the algorithm provided for each + * @param original original string + * @param tokenPattern the pattern to match with + * @param converter the conversion to apply + * @return the substituted string + */ + public static String replaceTokens(String original, Pattern tokenPattern, + Function converter) { + int lastIndex = 0; + StringBuilder output = new StringBuilder(); + Matcher matcher = tokenPattern.matcher(original); + while (matcher.find()) { + output.append(original, lastIndex, matcher.start()) + .append(converter.apply(matcher)); + + lastIndex = matcher.end(); + } + if (lastIndex < original.length()) { + output.append(original, lastIndex, original.length()); + } + return output.toString(); + } +} diff --git a/core-java-modules/core-java-regex/src/test/java/com/baeldung/replacetokens/ReplacingTokensUnitTest.java b/core-java-modules/core-java-regex/src/test/java/com/baeldung/replacetokens/ReplacingTokensUnitTest.java new file mode 100644 index 0000000000..b42a17f88e --- /dev/null +++ b/core-java-modules/core-java-regex/src/test/java/com/baeldung/replacetokens/ReplacingTokensUnitTest.java @@ -0,0 +1,79 @@ +package com.baeldung.replacetokens; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static com.baeldung.replacetokens.ReplacingTokens.TITLE_CASE_PATTERN; +import static com.baeldung.replacetokens.ReplacingTokens.replaceTokens; +import static org.assertj.core.api.Assertions.assertThat; + +public class ReplacingTokensUnitTest { + private static final String EXAMPLE_INPUT = "First 3 Capital Words! then 10 TLAs, I Found"; + private static final String EXAMPLE_INPUT_PROCESSED = "first 3 capital words! then 10 TLAs, i found"; + + @Test + public void whenFindMatches_thenTitleWordsFound() { + Matcher matcher = TITLE_CASE_PATTERN.matcher(EXAMPLE_INPUT); + List matches = new ArrayList<>(); + while (matcher.find()) { + matches.add(matcher.group(1)); + } + + assertThat(matches) + .containsExactly("First", "Capital", "Words", "I", "Found"); + } + + @Test + public void exploreMatches() { + Matcher matcher = TITLE_CASE_PATTERN.matcher(EXAMPLE_INPUT); + while (matcher.find()) { + System.out.println("Match: " + matcher.group(0)); + System.out.println("Start: " + matcher.start()); + System.out.println("End: " + matcher.end()); + } + } + + @Test + public void whenReplaceTokensWithLowerCase() { + assertThat(ReplacingTokens.replaceTitleCaseWithLowerCase(EXAMPLE_INPUT)) + .isEqualTo(EXAMPLE_INPUT_PROCESSED); + } + + @Test + public void whenReplaceTokensWithLowerCaseUsingGeneralPurpose() { + assertThat(replaceTokens("First 3 Capital Words! then 10 TLAs, I Found", + TITLE_CASE_PATTERN, + match -> match.group(1).toLowerCase())) + .isEqualTo("first 3 capital words! then 10 TLAs, i found"); + } + + @Test + public void escapeRegexCharacters() { + Pattern regexCharacters = Pattern.compile("[<(\\[{\\\\^\\-=$!|\\]})?*+.>]"); + + assertThat(replaceTokens("A regex character like [", + regexCharacters, + match -> "\\" + match.group())) + .isEqualTo("A regex character like \\["); + } + + @Test + public void replacePlaceholders() { + Pattern placeholderPattern = Pattern.compile("\\$\\{(?[A-Za-z0-9-_]+)}"); + + Map placeholderValues = new HashMap<>(); + placeholderValues.put("name", "Bill"); + placeholderValues.put("company", "Baeldung"); + + assertThat(replaceTokens("Hi ${name} at ${company}", + placeholderPattern, + match -> placeholderValues.get(match.group("placeholder")))) + .isEqualTo("Hi Bill at Baeldung"); + } +} diff --git a/core-java-modules/core-java-string-conversions-2/pom.xml b/core-java-modules/core-java-string-conversions-2/pom.xml index 58b00b757a..9f2276b212 100644 --- a/core-java-modules/core-java-string-conversions-2/pom.xml +++ b/core-java-modules/core-java-string-conversions-2/pom.xml @@ -28,8 +28,8 @@ org.hamcrest - hamcrest-library - ${org.hamcrest.version} + hamcrest + ${hamcrest.version} test diff --git a/core-java-modules/core-java-string-conversions/pom.xml b/core-java-modules/core-java-string-conversions/pom.xml index e3d6036e53..7f8fe6468f 100644 --- a/core-java-modules/core-java-string-conversions/pom.xml +++ b/core-java-modules/core-java-string-conversions/pom.xml @@ -44,8 +44,8 @@ org.hamcrest - hamcrest-library - ${org.hamcrest.version} + hamcrest + ${hamcrest.version} test diff --git a/core-java-modules/core-java-string-operations-2/pom.xml b/core-java-modules/core-java-string-operations-2/pom.xml index 7bb687ea2b..b882e499b2 100644 --- a/core-java-modules/core-java-string-operations-2/pom.xml +++ b/core-java-modules/core-java-string-operations-2/pom.xml @@ -48,8 +48,8 @@ org.hamcrest - hamcrest-library - ${org.hamcrest.version} + hamcrest + ${hamcrest.version} test diff --git a/core-java-modules/core-java-sun/pom.xml b/core-java-modules/core-java-sun/pom.xml index c17bb6b8fc..4721eed278 100644 --- a/core-java-modules/core-java-sun/pom.xml +++ b/core-java-modules/core-java-sun/pom.xml @@ -40,20 +40,6 @@ - - org.apache.maven.plugins - maven-jar-plugin - ${maven-jar-plugin.version} - - - - true - libs/ - com.baeldung.executable.ExecutableMavenJar - - - - org.codehaus.mojo exec-maven-plugin @@ -115,7 +101,6 @@ 1.8.0 - 3.0.2 \ No newline at end of file diff --git a/core-java-modules/core-java/README.md b/core-java-modules/core-java/README.md index 033d8032bf..bffb88cafb 100644 --- a/core-java-modules/core-java/README.md +++ b/core-java-modules/core-java/README.md @@ -11,7 +11,7 @@ - [Introduction to Java Serialization](http://www.baeldung.com/java-serialization) - [Guide to UUID in Java](http://www.baeldung.com/java-uuid) - [Creating a Java Compiler Plugin](http://www.baeldung.com/java-build-compiler-plugin) -- [Quick Guide to the Java Stack](http://www.baeldung.com/java-stack) +- [Quick Guide to the Java Stack](https://www.baeldung.com/java-stack) - [Compiling Java *.class Files with javac](http://www.baeldung.com/javac) - [Introduction to Javadoc](http://www.baeldung.com/javadoc) - [Guide to the Externalizable Interface in Java](http://www.baeldung.com/java-externalizable) diff --git a/core-java-modules/core-java/pom.xml b/core-java-modules/core-java/pom.xml index 5f60b43f79..06d0d85b50 100644 --- a/core-java-modules/core-java/pom.xml +++ b/core-java-modules/core-java/pom.xml @@ -90,101 +90,6 @@ - - org.apache.maven.plugins - maven-jar-plugin - ${maven-jar-plugin.version} - - - - true - libs/ - com.baeldung.executable.ExecutableMavenJar - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - package - - single - - - ${project.basedir} - - - com.baeldung.executable.ExecutableMavenJar - - - - jar-with-dependencies - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - ${maven-shade-plugin.version} - - - - shade - - - true - - - com.baeldung.executable.ExecutableMavenJar - - - - - - - - - com.jolira - onejar-maven-plugin - ${onejar-maven-plugin.version} - - - - com.baeldung.executable.ExecutableMavenJar - true - ${project.build.finalName}-onejar.${project.packaging} - - - one-jar - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot-maven-plugin.version} - - - - repackage - - - spring-boot - com.baeldung.executable.ExecutableMavenJar - - - - - org.codehaus.mojo exec-maven-plugin @@ -273,111 +178,6 @@ - - - - buildAgentLoader - - - - org.apache.maven.plugins - maven-jar-plugin - - - package - - jar - - - agentLoader - target/classes - - - true - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - com/baeldung/instrumentation/application/AgentLoader.class - com/baeldung/instrumentation/application/Launcher.class - - - - - - - - - - buildApplication - - - - org.apache.maven.plugins - maven-jar-plugin - - - package - - jar - - - application - target/classes - - - true - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - com/baeldung/instrumentation/application/MyAtm.class - com/baeldung/instrumentation/application/MyAtmApplication.class - com/baeldung/instrumentation/application/Launcher.class - - - - - - - - - - buildAgent - - - - org.apache.maven.plugins - maven-jar-plugin - - - package - - jar - - - agent - target/classes - - - true - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - com/baeldung/instrumentation/agent/AtmTransformer.class - com/baeldung/instrumentation/agent/MyInstrumentationAgent.class - - - - - - - - @@ -392,10 +192,6 @@ 1.1 3.0.0-M1 - 3.0.2 - 1.4.4 - 3.1.1 - 2.0.3.RELEASE 1.6.0 1.8 1.8 diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/stack/StackUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/stack/StackUnitTest.java index 2b04617f36..6a2feff551 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/stack/StackUnitTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/stack/StackUnitTest.java @@ -1,123 +1,153 @@ package com.baeldung.stack; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.*; +import org.junit.Test; import java.util.Arrays; import java.util.List; import java.util.ListIterator; import java.util.Stack; +import java.util.stream.Collectors; -import org.junit.Test; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; public class StackUnitTest { @Test - public void whenStackIsCreated_thenItHasSize0() { - Stack intStack = new Stack(); + public void whenStackIsCreated_thenItHasSizeZero() { + Stack intStack = new Stack<>(); + assertEquals(0, intStack.size()); } @Test - public void givenEmptyStack_whenElementIsPushed_thenStackSizeisIncreased() { - Stack intStack = new Stack(); + public void whenElementIsPushed_thenStackSizeIsIncreased() { + Stack intStack = new Stack<>(); intStack.push(1); + assertEquals(1, intStack.size()); } @Test - public void givenEmptyStack_whenMultipleElementsArePushed_thenStackSizeisIncreased() { - Stack intStack = new Stack(); + public void whenMultipleElementsArePushed_thenStackSizeIsIncreased() { + Stack intStack = new Stack<>(); List intList = Arrays.asList(1, 2, 3, 4, 5, 6, 7); + boolean result = intStack.addAll(intList); + assertTrue(result); assertEquals(7, intList.size()); } @Test public void whenElementIsPoppedFromStack_thenElementIsRemovedAndSizeChanges() { - Stack intStack = new Stack(); + Stack intStack = new Stack<>(); intStack.push(5); - intStack.pop(); + + Integer element = intStack.pop(); + + assertEquals(Integer.valueOf(5), element); assertTrue(intStack.isEmpty()); } @Test public void whenElementIsPeeked_thenElementIsNotRemovedAndSizeDoesNotChange() { - Stack intStack = new Stack(); + Stack intStack = new Stack<>(); intStack.push(5); - intStack.peek(); + + Integer element = intStack.peek(); + + assertEquals(Integer.valueOf(5), element); assertEquals(1, intStack.search(5)); assertEquals(1, intStack.size()); } @Test public void whenElementIsOnStack_thenSearchReturnsItsDistanceFromTheTop() { - Stack intStack = new Stack(); + Stack intStack = new Stack<>(); intStack.push(5); - assertEquals(1, intStack.search(5)); + intStack.push(8); + + assertEquals(2, intStack.search(5)); } @Test public void whenElementIsOnStack_thenIndexOfReturnsItsIndex() { - Stack intStack = new Stack(); + Stack intStack = new Stack<>(); intStack.push(5); + int indexOf = intStack.indexOf(5); + assertEquals(0, indexOf); } @Test public void whenMultipleElementsAreOnStack_thenIndexOfReturnsLastElementIndex() { - Stack intStack = new Stack(); + Stack intStack = new Stack<>(); intStack.push(5); intStack.push(5); intStack.push(5); + int lastIndexOf = intStack.lastIndexOf(5); + assertEquals(2, lastIndexOf); } @Test - public void givenElementOnStack_whenRemoveElementIsInvoked_thenElementIsRemoved() { - Stack intStack = new Stack(); + public void whenRemoveElementIsInvoked_thenElementIsRemoved() { + Stack intStack = new Stack<>(); intStack.push(5); intStack.push(5); + intStack.removeElement(5); + assertEquals(1, intStack.size()); } @Test - public void givenElementOnStack_whenRemoveElementAtIsInvoked_thenElementIsRemoved() { - Stack intStack = new Stack(); + public void whenRemoveElementAtIsInvoked_thenElementIsRemoved() { + Stack intStack = new Stack<>(); intStack.push(5); intStack.push(7); + intStack.removeElementAt(1); + assertEquals(-1, intStack.search(7)); } @Test - public void givenElementsOnStack_whenRemoveAllElementsIsInvoked_thenAllElementsAreRemoved() { - Stack intStack = new Stack(); + public void whenRemoveAllElementsIsInvoked_thenAllElementsAreRemoved() { + Stack intStack = new Stack<>(); intStack.push(5); intStack.push(7); + intStack.removeAllElements(); + assertTrue(intStack.isEmpty()); } @Test public void givenElementsOnStack_whenRemoveAllIsInvoked_thenAllElementsFromCollectionAreRemoved() { - Stack intStack = new Stack(); + Stack intStack = new Stack<>(); List intList = Arrays.asList(1, 2, 3, 4, 5, 6, 7); intStack.addAll(intList); intStack.add(500); + intStack.removeAll(intList); + assertEquals(1, intStack.size()); + assertEquals(1, intStack.search(500)); } @Test - public void givenElementsOnStack_whenRemoveIfIsInvoked_thenAllElementsSatysfyingConditionAreRemoved() { - Stack intStack = new Stack(); + public void whenRemoveIfIsInvoked_thenAllElementsSatysfyingConditionAreRemoved() { + Stack intStack = new Stack<>(); List intList = Arrays.asList(1, 2, 3, 4, 5, 6, 7); intStack.addAll(intList); + intStack.removeIf(element -> element < 6); + assertEquals(2, intStack.size()); } @@ -126,12 +156,28 @@ public class StackUnitTest { Stack intStack = new Stack<>(); List intList = Arrays.asList(1, 2, 3, 4, 5, 6, 7); intStack.addAll(intList); + ListIterator it = intStack.listIterator(); - Stack result = new Stack(); + + Stack result = new Stack<>(); while(it.hasNext()) { result.push(it.next()); } assertThat(result, equalTo(intStack)); } + + @Test + public void whenStackIsFiltered_allElementsNotSatisfyingFilterConditionAreDiscarded() { + Stack intStack = new Stack<>(); + List inputIntList = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 9, 10); + intStack.addAll(inputIntList); + + List filtered = intStack + .stream() + .filter(element -> element <= 3) + .collect(Collectors.toList()); + + assertEquals(3, filtered.size()); + } } diff --git a/core-kotlin-modules/README.md b/core-kotlin-modules/README.md deleted file mode 100644 index 974db9378a..0000000000 --- a/core-kotlin-modules/README.md +++ /dev/null @@ -1,5 +0,0 @@ -## Core Kotlin - -This module contains articles about core Kotlin. - - diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbinarytree/AVLTree.java b/data-structures/src/main/java/com/baeldung/avltree/AVLTree.java similarity index 98% rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbinarytree/AVLTree.java rename to data-structures/src/main/java/com/baeldung/avltree/AVLTree.java index a0575c8be1..ca0cfce7b4 100644 --- a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbinarytree/AVLTree.java +++ b/data-structures/src/main/java/com/baeldung/avltree/AVLTree.java @@ -1,4 +1,4 @@ -package com.baeldung.algorithms.balancedbinarytree; +package com.baeldung.avltree; public class AVLTree { diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbinarytree/AVLTreeUnitTest.java b/data-structures/src/test/java/com/baeldung/avltree/AVLTreeUnitTest.java similarity index 97% rename from algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbinarytree/AVLTreeUnitTest.java rename to data-structures/src/test/java/com/baeldung/avltree/AVLTreeUnitTest.java index ab001b6696..56fc893232 100644 --- a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbinarytree/AVLTreeUnitTest.java +++ b/data-structures/src/test/java/com/baeldung/avltree/AVLTreeUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.algorithms.balancedbinarytree; +package com.baeldung.avltree; import org.junit.Assert; import org.junit.Test; diff --git a/ethereum/pom.xml b/ethereum/pom.xml index 1449d9d95c..8c7e4c8c4c 100644 --- a/ethereum/pom.xml +++ b/ethereum/pom.xml @@ -159,8 +159,8 @@ org.hamcrest - hamcrest-library - ${org.hamcrest.version} + hamcrest + ${hamcrest.version} test diff --git a/gson/src/test/java/com/baeldung/gson/jsoncompare/JsonCompareUnitTest.java b/gson/src/test/java/com/baeldung/gson/jsoncompare/JsonCompareUnitTest.java new file mode 100644 index 0000000000..84989a7411 --- /dev/null +++ b/gson/src/test/java/com/baeldung/gson/jsoncompare/JsonCompareUnitTest.java @@ -0,0 +1,95 @@ +package com.baeldung.gson.jsoncompare; + +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; +import org.junit.Test; +import static org.junit.Assert.*; + +public class JsonCompareUnitTest { + @Test + public void givenJsonStrings_whenCompared_thenNotEqual() { + String string1 = "{\"fullName\": \"Emily Jenkins\", \"age\": 27 }"; + String string2 = "{\"fullName\": \"Emily Jenkins\", \"age\": 27}"; + + assertNotEquals(string1, string2); + } + + @Test + public void givenIdenticalSimpleObjects_whenCompared_thenEqual() { + JsonParser parser = new JsonParser(); + String string1 = "{\"customer\": {\"id\": \"44521\",\"fullName\": \"Emily Jenkins\", \"age\": 27 }}"; + String string2 = "{\"customer\": {\"id\": \"44521\", \"fullName\": \"Emily Jenkins\",\"age\": 27}}"; + + assertTrue(parser.parse(string1) + .isJsonObject()); + assertEquals(parser.parse(string1), parser.parse(string2)); + } + + @Test + public void givenSameObjectsInDifferentOrder_whenCompared_thenEqual() { + JsonParser parser = new JsonParser(); + String string1 = "{\"customer\": {\"id\": \"44521\",\"fullName\": \"Emily Jenkins\", \"age\": 27 }}"; + String string2 = "{\"customer\": {\"id\": \"44521\",\"age\": 27, \"fullName\": \"Emily Jenkins\" }}"; + + JsonElement json1 = parser.parse(string1); + JsonElement json2 = parser.parse(string2); + + assertEquals(json1, json2); + } + + @Test + public void givenIdenticalArrays_whenCompared_thenEqual() { + JsonParser parser = new JsonParser(); + String string1 = "[10, 20, 30]"; + String string2 = "[10, 20, 30]"; + + assertTrue(parser.parse(string1) + .isJsonArray()); + assertEquals(parser.parse(string1), parser.parse(string2)); + } + + @Test + public void givenArraysInDifferentOrder_whenCompared_thenNotEqual() { + JsonParser parser = new JsonParser(); + String string1 = "[20, 10, 30]"; + String string2 = "[10, 20, 30]"; + + assertNotEquals(parser.parse(string1), parser.parse(string2)); + } + + @Test + public void givenIdenticalNestedObjects_whenCompared_thenEqual() { + JsonParser parser = new JsonParser(); + String string1 = "{\"customer\": {\"id\": \"44521\",\"fullName\": \"Emily Jenkins\", \"age\": 27, \"consumption_info\" : {\"fav_product\": \"Coke\", \"last_buy\": \"2012-04-23\"}}}"; + String string2 = "{\"customer\": {\"id\": \"44521\",\"fullName\": \"Emily Jenkins\", \"age\": 27, \"consumption_info\" : {\"last_buy\": \"2012-04-23\", \"fav_product\": \"Coke\"}}}"; + + JsonElement json1 = parser.parse(string1); + JsonElement json2 = parser.parse(string2); + + assertEquals(json1, json2); + } + + @Test + public void givenIdenticalNestedObjectsWithArray_whenCompared_thenEqual() { + JsonParser parser = new JsonParser(); + String string1 = "{\"customer\": {\"id\": \"44521\",\"fullName\": \"Emily Jenkins\", \"age\": 27, \"consumption_info\" : {\"last_buy\": \"2012-04-23\", \"prouducts\": [\"banana\", \"eggs\"]}}}"; + String string2 = "{\"customer\": {\"id\": \"44521\",\"fullName\": \"Emily Jenkins\", \"age\": 27, \"consumption_info\" : {\"last_buy\": \"2012-04-23\", \"prouducts\": [\"banana\", \"eggs\"]}}}"; + + JsonElement json1 = parser.parse(string1); + JsonElement json2 = parser.parse(string2); + + assertEquals(json1, json2); + } + + @Test + public void givenNestedObjectsDifferentArrayOrder_whenCompared_thenNotEqual() { + JsonParser parser = new JsonParser(); + String string1 = "{\"customer\": {\"id\": \"44521\",\"fullName\": \"Emily Jenkins\", \"age\": 27, \"consumption_info\" : {\"last_buy\": \"2012-04-23\", \"prouducts\": [\"banana\", \"eggs\"]}}}"; + String string2 = "{\"customer\": {\"id\": \"44521\",\"fullName\": \"Emily Jenkins\", \"age\": 27, \"consumption_info\" : {\"last_buy\": \"2012-04-23\", \"prouducts\": [\"eggs\", \"banana\"]}}}"; + + JsonElement json1 = parser.parse(string1); + JsonElement json2 = parser.parse(string2); + + assertNotEquals(json1, json2); + } +} diff --git a/java-numbers-2/README.md b/java-numbers-2/README.md index 2d0d5443b1..ba9e14965d 100644 --- a/java-numbers-2/README.md +++ b/java-numbers-2/README.md @@ -13,7 +13,7 @@ This module contains articles about numbers in Java. - [Binary Numbers in Java](https://www.baeldung.com/java-binary-numbers) - [Finding the Least Common Multiple in Java](https://www.baeldung.com/java-least-common-multiple) - [Binary Numbers in Java](https://www.baeldung.com/java-binary-numbers) -- [Generating Random Numbers in a Range in Java](https://www.baeldung.com/java-generating-random-numbers) +- [Generating Random Numbers in a Range in Java](https://www.baeldung.com/java-generating-random-numbers-in-range) - [Listing Numbers Within a Range in Java](https://www.baeldung.com/java-listing-numbers-within-a-range) - [Fibonacci Series in Java](https://www.baeldung.com/java-fibonacci) - More articles: [[<-- prev]](/../java-numbers) diff --git a/libraries/pom.xml b/libraries/pom.xml index b5340d1ebb..af300657b0 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -435,7 +435,23 @@ reflections ${reflections.version} - + + com.uber.nullaway + nullaway + 0.3.0 + + + org.codehaus.plexus + plexus-compiler-javac-errorprone + 2.8 + + + + com.google.errorprone + error_prone_core + 2.1.3 + @@ -552,6 +568,47 @@ + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5 + + javac-with-errorprone + true + 1.8 + 1.8 + true + + + com.uber.nullaway + nullaway + 0.3.0 + + + + + + -XepExcludedPaths:(.*)/test/.*|(.*)/streamex/.* + -XepOpt:NullAway:AnnotatedPackages=com.baeldung.nullaway + + + + + org.codehaus.plexus + plexus-compiler-javac-errorprone + 2.8 + + + + com.google.errorprone + error_prone_core + 2.1.3 + + + + diff --git a/libraries/src/main/java/com/baeldung/nullaway/NullAwayExample.java b/libraries/src/main/java/com/baeldung/nullaway/NullAwayExample.java new file mode 100644 index 0000000000..f3db1d2df9 --- /dev/null +++ b/libraries/src/main/java/com/baeldung/nullaway/NullAwayExample.java @@ -0,0 +1,24 @@ +package com.baeldung.nullaway; + +import com.baeldung.distinct.Person; + +public class NullAwayExample { + + /* + * 1- NullAway will warn about yearsToRetirement method + * 2- Uncomment @Nullable in printAge and NullAway will warn about this method + * 3- Add a standard null check to be NullAway compliant + * 4- Build will be SUCCESS + */ + + static Integer getAge(/*@Nullable*/ Person person) { + return person.getAge(); + } + + Integer yearsToRetirement() { + Person p = null; + // ... p never gets set correctly... + return 65 - getAge(p); + } + +} \ No newline at end of file diff --git a/linux-bash/text/README.md b/linux-bash/text/README.md index e0ee0c1600..de99c1962a 100644 --- a/linux-bash/text/README.md +++ b/linux-bash/text/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: -- [Linux Commands – Remove All Text After X](https://www.baeldung.com/linux/remove-text-after-x-in-file) +- [Linux Commands – Remove All Text After X](https://www.baeldung.com/linux/tr-manipulate-strings) diff --git a/maven-all/compiler-plugin-java-9/README.md b/maven-all/compiler-plugin-java-9/README.md index d0b7b72acc..0e02d56946 100644 --- a/maven-all/compiler-plugin-java-9/README.md +++ b/maven-all/compiler-plugin-java-9/README.md @@ -1,3 +1,3 @@ ### Relevant Articles -- [Maven Compiler Plugin](http://www.baeldung.com/maven-compiler-plugin) \ No newline at end of file +- [Maven Compiler Plugin](https://www.baeldung.com/maven-compiler-plugin) diff --git a/maven-java-11/README.md b/maven-java-11/README.md index fcb6ea3f06..b923518825 100644 --- a/maven-java-11/README.md +++ b/maven-java-11/README.md @@ -4,4 +4,3 @@ This module contains articles about Maven with Java 11+. ### Relevant Articles: -- [Multi-Module Maven Application with Java Modules](https://www.baeldung.com/maven-multi-module-project-java-jpms) diff --git a/muleesb/pom.xml b/muleesb/pom.xml index c8468c1e00..e7c7e50cbe 100644 --- a/muleesb/pom.xml +++ b/muleesb/pom.xml @@ -83,7 +83,7 @@ com.mulesoft.munit mule-munit-support - ${mule.munit.support.version} + ${mule.version} test @@ -106,18 +106,19 @@ - org.mule.tools - muleesb-maven-plugin - ${muleesb-maven-plugin.version} + org.mule.tools.maven + mule-maven-plugin + 2.2.1 + standalone ${mule.version} - /home/abir/AnypointStudio/workspace/variablescopetest deploy + deploy - start + deploy @@ -210,11 +211,9 @@ - 3.8.1 + 3.9.0 1.2 1.3.6 - 3.9.0 - 1.0 1.7 diff --git a/netflix-modules/README.md b/netflix-modules/README.md index 4afea527df..7f7a9656fb 100644 --- a/netflix-modules/README.md +++ b/netflix-modules/README.md @@ -4,4 +4,4 @@ This module contains articles about Netflix. ### Relevant articles -- [Introduction to Netflix Genie](https://github.com/eugenp/tutorials/tree/master/netflix/genie) +- [Introduction to Netflix Genie](https://www.baeldung.com/netflix-genie-intro) diff --git a/oauth2-framework-impl/oauth2-client/README.md b/oauth2-framework-impl/oauth2-client/README.md deleted file mode 100644 index 4bcb9790b1..0000000000 --- a/oauth2-framework-impl/oauth2-client/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: - -- [Implementing The OAuth 2.0 Authorization Framework Using Jakarta EE](https://www.baeldung.com/java-ee-oauth2-implementation) diff --git a/persistence-modules/java-jpa-2/README.md b/persistence-modules/java-jpa-2/README.md index 1c34ef2999..9d46c0d814 100644 --- a/persistence-modules/java-jpa-2/README.md +++ b/persistence-modules/java-jpa-2/README.md @@ -5,7 +5,7 @@ This module contains articles about the Java Persistence API (JPA) in Java. ### Relevant Articles - [JPA Query Parameters Usage](https://www.baeldung.com/jpa-query-parameters) -- [Mapping Entitiy Class Names to SQL Table Names with JPA](https://www.baeldung.com/jpa-entity-table-names) +- [Mapping Entity Class Names to SQL Table Names with JPA](https://www.baeldung.com/jpa-entity-table-names) - [Default Column Values in JPA](https://www.baeldung.com/jpa-default-column-values) - [Types of JPA Queries](https://www.baeldung.com/jpa-queries) - [JPA/Hibernate Projections](https://www.baeldung.com/jpa-hibernate-projections) diff --git a/persistence-modules/spring-data-redis/src/main/java/com/baeldung/spring/data/redis/config/RedisConfig.java b/persistence-modules/spring-data-redis/src/main/java/com/baeldung/spring/data/redis/config/RedisConfig.java index 6fdb3c5bef..fdc279be42 100644 --- a/persistence-modules/spring-data-redis/src/main/java/com/baeldung/spring/data/redis/config/RedisConfig.java +++ b/persistence-modules/spring-data-redis/src/main/java/com/baeldung/spring/data/redis/config/RedisConfig.java @@ -1,13 +1,11 @@ package com.baeldung.spring.data.redis.config; -import com.baeldung.spring.data.redis.queue.MessagePublisher; -import com.baeldung.spring.data.redis.queue.RedisMessagePublisher; -import com.baeldung.spring.data.redis.queue.RedisMessageSubscriber; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.listener.ChannelTopic; import org.springframework.data.redis.listener.RedisMessageListenerContainer; @@ -15,6 +13,10 @@ import org.springframework.data.redis.listener.adapter.MessageListenerAdapter; import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; import org.springframework.data.redis.serializer.GenericToStringSerializer; +import com.baeldung.spring.data.redis.queue.MessagePublisher; +import com.baeldung.spring.data.redis.queue.RedisMessagePublisher; +import com.baeldung.spring.data.redis.queue.RedisMessageSubscriber; + @Configuration @ComponentScan("com.baeldung.spring.data.redis") @EnableRedisRepositories(basePackages = "com.baeldung.spring.data.redis.repo") @@ -33,6 +35,18 @@ public class RedisConfig { template.setValueSerializer(new GenericToStringSerializer(Object.class)); return template; } + + @Bean + public LettuceConnectionFactory lettuceConnectionFactory() { + return new LettuceConnectionFactory(); + } + + @Bean(name = "flushRedisTemplate") + public RedisTemplate flushRedisTemplate() { + RedisTemplate template = new RedisTemplate<>(); + template.setConnectionFactory(lettuceConnectionFactory()); + return template; + } @Bean MessageListenerAdapter messageListener() { diff --git a/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/redis/delete/RedisFlushDatabaseIntegrationTest.java b/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/redis/delete/RedisFlushDatabaseIntegrationTest.java new file mode 100644 index 0000000000..1f56cbb25d --- /dev/null +++ b/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/redis/delete/RedisFlushDatabaseIntegrationTest.java @@ -0,0 +1,92 @@ +package com.baeldung.spring.data.redis.delete; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.io.IOException; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.dao.DataAccessException; +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.core.RedisCallback; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ValueOperations; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.baeldung.spring.data.redis.config.RedisConfig; + +import redis.embedded.RedisServer; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { RedisConfig.class }) +@DirtiesContext(classMode = ClassMode.BEFORE_CLASS) +public class RedisFlushDatabaseIntegrationTest { + + private RedisServer redisServer; + + @Autowired + @Qualifier("flushRedisTemplate") + private RedisTemplate flushRedisTemplate; + + @Before + public void setup() throws IOException { + redisServer = new RedisServer(6390); + redisServer.start(); + } + + @After + public void tearDown() { + redisServer.stop(); + } + + @Test + public void whenFlushDB_thenAllKeysInDatabaseAreCleared() { + + ValueOperations simpleValues = flushRedisTemplate.opsForValue(); + String key = "key"; + String value = "value"; + simpleValues.set(key, value); + assertThat(simpleValues.get(key)).isEqualTo(value); + + flushRedisTemplate.execute(new RedisCallback() { + + @Override + public Void doInRedis(RedisConnection connection) throws DataAccessException { + connection.flushDb(); + return null; + } + }); + + assertThat(simpleValues.get(key)).isNull(); + + } + + @Test + public void whenFlushAll_thenAllKeysInDatabasesAreCleared() { + + ValueOperations simpleValues = flushRedisTemplate.opsForValue(); + String key = "key"; + String value = "value"; + simpleValues.set(key, value); + assertThat(simpleValues.get(key)).isEqualTo(value); + + flushRedisTemplate.execute(new RedisCallback() { + + @Override + public Void doInRedis(RedisConnection connection) throws DataAccessException { + connection.flushAll(); + return null; + } + }); + + assertThat(simpleValues.get(key)).isNull(); + + } +} \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/README.md b/persistence-modules/spring-persistence-simple/README.md index db0d0ce83c..d665433eef 100644 --- a/persistence-modules/spring-persistence-simple/README.md +++ b/persistence-modules/spring-persistence-simple/README.md @@ -6,7 +6,7 @@ ### Relevant Articles: - [A Guide to JPA with Spring](https://www.baeldung.com/the-persistence-layer-with-spring-and-jpa) - [Bootstrapping Hibernate 5 with Spring](http://www.baeldung.com/hibernate-5-spring) -- [The DAO with Spring and Hibernate](http://www.baeldung.com/persistence-layer-with-spring-and-hibernate) +- [The DAO with Spring and Hibernate](https://www.baeldung.com/persistence-layer-with-spring-and-hibernate) - [Simplify the DAO with Spring and Java Generics](https://www.baeldung.com/simplifying-the-data-access-layer-with-spring-and-java-generics) - [Transactions with Spring and JPA](https://www.baeldung.com/transaction-configuration-with-jpa-and-spring) - [Introduction to Spring Data JPA](http://www.baeldung.com/the-persistence-layer-with-spring-data-jpa) diff --git a/pom.xml b/pom.xml index 2cefcc284f..204d884005 100644 --- a/pom.xml +++ b/pom.xml @@ -59,20 +59,14 @@ org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} + hamcrest + ${hamcrest.version} test org.hamcrest hamcrest-all - ${org.hamcrest.version} + ${hamcrest-all.version} test @@ -1334,12 +1328,13 @@ false 4.12 - 1.3 + 2.2 + 1.3 2.21.0 1.7.30 - 1.1.7 + 1.2.3 @@ -1352,7 +1347,6 @@ 2.1.0.1 1.19 1.19 - 1.3 1.6.0 2.21.0 2.5 @@ -1370,7 +1364,7 @@ 1.2.0 5.2.0 0.3.1 - 2.5.1 + 2.5.2 0.0.1 3.8 2.3 diff --git a/spring-5-webflux/src/main/java/com/baeldung/spring/serverconfig/TimeoutController.java b/spring-5-webflux/src/main/java/com/baeldung/spring/serverconfig/TimeoutController.java new file mode 100644 index 0000000000..a4cd6bd6ba --- /dev/null +++ b/spring-5-webflux/src/main/java/com/baeldung/spring/serverconfig/TimeoutController.java @@ -0,0 +1,23 @@ +package com.baeldung.spring.serverconfig; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import reactor.core.publisher.Mono; + +@RestController +@RequestMapping("/timeout") +public class TimeoutController { + + @GetMapping("/{timeout}") + private Mono timeout(@PathVariable int timeout) { + try { + Thread.sleep(timeout * 1000); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + return Mono.just("OK"); + } +} diff --git a/spring-5-webflux/src/test/java/com/baeldung/spring/serverconfig/TimeoutLiveTest.java b/spring-5-webflux/src/test/java/com/baeldung/spring/serverconfig/TimeoutLiveTest.java new file mode 100644 index 0000000000..c53fd4fa80 --- /dev/null +++ b/spring-5-webflux/src/test/java/com/baeldung/spring/serverconfig/TimeoutLiveTest.java @@ -0,0 +1,85 @@ +package com.baeldung.spring.serverconfig; + +import java.util.concurrent.TimeUnit; + +import javax.net.ssl.SSLException; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.http.client.reactive.ReactorClientHttpConnector; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.reactive.server.WebTestClient; + +import io.netty.channel.ChannelOption; +import io.netty.handler.ssl.SslContext; +import io.netty.handler.ssl.SslContextBuilder; +import io.netty.handler.ssl.util.InsecureTrustManagerFactory; +import io.netty.handler.timeout.ReadTimeoutException; +import io.netty.handler.timeout.ReadTimeoutHandler; +import io.netty.handler.timeout.WriteTimeoutHandler; +import reactor.netty.http.client.HttpClient; +import reactor.netty.tcp.TcpClient; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) +@DirtiesContext +public class TimeoutLiveTest { + + private static final String BASE_URL = "https://localhost:8443"; + private static final int TIMEOUT_MILLIS = 2000; + + private WebTestClient webTestClient; + + @Rule + public ExpectedException exception = ExpectedException.none(); + + @Before + public void setup() throws SSLException { + webTestClient = WebTestClient.bindToServer(getConnector()) + .baseUrl(BASE_URL) + .build(); + } + + @Test + public void shouldTimeout() { + exception.expect(ReadTimeoutException.class); + webTestClient.get() + .uri("/timeout/{timeout}", 3) + .exchange(); + } + + @Test + public void shouldNotTimeout() { + WebTestClient.ResponseSpec response = webTestClient.get() + .uri("/timeout/{timeout}", 1) + .exchange(); + response.expectStatus() + .isOk() + .expectBody(String.class) + .isEqualTo("OK"); + } + + private ReactorClientHttpConnector getConnector() throws SSLException { + SslContext sslContext = SslContextBuilder + .forClient() + .trustManager(InsecureTrustManagerFactory.INSTANCE) + .build(); + + TcpClient tcpClient = TcpClient + .create() + .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, TIMEOUT_MILLIS) + .doOnConnected(connection -> { + connection.addHandlerLast(new ReadTimeoutHandler(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)); + connection.addHandlerLast(new WriteTimeoutHandler(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)); + }); + + HttpClient httpClient = HttpClient.from(tcpClient).secure(t -> t.sslContext(sslContext)); + return new ReactorClientHttpConnector(httpClient); + } +} diff --git a/spring-boot-modules/README.md b/spring-boot-modules/README.md deleted file mode 100644 index cd916f48a7..0000000000 --- a/spring-boot-modules/README.md +++ /dev/null @@ -1,3 +0,0 @@ -## Spring Boot Modules - -This module contains various modules of Spring Boot diff --git a/spring-boot-modules/spring-boot-logging-log4j2/pom.xml b/spring-boot-modules/spring-boot-logging-log4j2/pom.xml index 6e709230dd..4422405187 100644 --- a/spring-boot-modules/spring-boot-logging-log4j2/pom.xml +++ b/spring-boot-modules/spring-boot-logging-log4j2/pom.xml @@ -13,6 +13,7 @@ org.springframework.boot spring-boot-starter-parent 2.2.2.RELEASE + diff --git a/spring-boot-modules/spring-boot-properties/pom.xml b/spring-boot-modules/spring-boot-properties/pom.xml index 04879a5052..ec05ec1bdc 100644 --- a/spring-boot-modules/spring-boot-properties/pom.xml +++ b/spring-boot-modules/spring-boot-properties/pom.xml @@ -43,6 +43,12 @@ httpcore ${httpcore.version} + + org.springframework.boot + spring-boot-configuration-processor + ${configuration-processor.version} + true + @@ -121,6 +127,7 @@ 20.0 4.4.11 @ + 2.2.4.RELEASE diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/CustomProperties.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/CustomProperties.java new file mode 100644 index 0000000000..398b7557c4 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/CustomProperties.java @@ -0,0 +1,37 @@ +package com.baeldung.configuration.processor; + +import org.springframework.boot.context.properties.*; +import org.springframework.context.annotation.*; + +@Configuration +@ConfigurationProperties(prefix = "com.baeldung") +public class CustomProperties { + + /** + * The url to connect to. + */ + String url; + + /** + * The time to wait for the connection. + */ + private int timeoutInMilliSeconds = 1000; + + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public int getTimeoutInMilliSeconds() { + return timeoutInMilliSeconds; + } + + public void setTimeoutInMilliSeconds(int timeoutInMilliSeconds) { + this.timeoutInMilliSeconds = timeoutInMilliSeconds; + } + +} diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/DemoApplication.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/DemoApplication.java new file mode 100644 index 0000000000..1a35de86da --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/DemoApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.configuration.processor; + +import org.springframework.boot.*; +import org.springframework.boot.autoconfigure.*; + +@SpringBootApplication +public class DemoApplication { + + public static void main(String[] args) { + SpringApplication.run(DemoApplication.class, args); + } +} diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/PropertyBeanInjection.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/PropertyBeanInjection.java new file mode 100644 index 0000000000..3bcbf41f54 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/PropertyBeanInjection.java @@ -0,0 +1,22 @@ +package com.baeldung.configuration.processor; + +import org.springframework.beans.factory.annotation.*; +import org.springframework.stereotype.*; + +@Component +public class PropertyBeanInjection { + + private final CustomProperties customProperties; + + PropertyBeanInjection(@Autowired CustomProperties customProperties) { + this.customProperties = customProperties; + } + + String getUrl() { + return customProperties.getUrl(); + } + + int getTimeoutInMilliseconds() { + return customProperties.getTimeoutInMilliSeconds(); + } +} diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configuration/processor/PropertyBeanInjectionUnitTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configuration/processor/PropertyBeanInjectionUnitTest.java new file mode 100644 index 0000000000..bdeb6547c3 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configuration/processor/PropertyBeanInjectionUnitTest.java @@ -0,0 +1,24 @@ +package com.baeldung.configuration.processor; + +import org.junit.jupiter.api.*; +import org.junit.runner.*; +import org.springframework.beans.factory.annotation.*; +import org.springframework.boot.test.context.*; +import org.springframework.test.context.*; +import org.springframework.test.context.junit4.*; + +@RunWith(SpringRunner.class) +@TestPropertySource("/configuration-processor.properties") +@SpringBootTest(classes = DemoApplication.class) +class PropertyBeanInjectionUnitTest { + + @Autowired + private PropertyBeanInjection propertyBeanInjection; + + @Test + void checkThatCustomPropertiesHaveTheCorrectValueFromPropertiesFile() { + Assertions.assertEquals("www.abc.test.com", propertyBeanInjection.getUrl()); + Assertions.assertEquals(2000, propertyBeanInjection.getTimeoutInMilliseconds()); + } + +} diff --git a/spring-boot-modules/spring-boot-properties/src/test/resources/configuration-processor.properties b/spring-boot-modules/spring-boot-properties/src/test/resources/configuration-processor.properties new file mode 100644 index 0000000000..00369f2eff --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/test/resources/configuration-processor.properties @@ -0,0 +1,2 @@ +com.baeldung.url=www.abc.test.com +com.baeldung.timeout-in-milli-seconds=2000 diff --git a/spring-boot-modules/spring-boot-runtime/disabling-console-logback/README.md b/spring-boot-modules/spring-boot-runtime/disabling-console-logback/README.md deleted file mode 100644 index 554f051b41..0000000000 --- a/spring-boot-modules/spring-boot-runtime/disabling-console-logback/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: - -- [How to Disable Console Logging in Spring Boot](https://www.baeldung.com/spring-boot-disable-console-logging) diff --git a/spring-boot-modules/spring-boot-springdoc/pom.xml b/spring-boot-modules/spring-boot-springdoc/pom.xml index 9212e56c5a..fd8a9e71ae 100644 --- a/spring-boot-modules/spring-boot-springdoc/pom.xml +++ b/spring-boot-modules/spring-boot-springdoc/pom.xml @@ -17,8 +17,8 @@ - 1.8 + 1.2.32 @@ -26,6 +26,14 @@ org.springframework.boot spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-data-jpa + + + com.h2database + h2 + org.springframework.boot @@ -36,24 +44,13 @@ org.springdoc - springdoc-openapi-core - 1.1.49 - - - io.github.classgraph - classgraph - - + springdoc-openapi-ui + ${springdoc.version} org.springdoc - springdoc-openapi-ui - 1.1.49 - - - io.github.classgraph - classgraph - 4.8.44 + springdoc-openapi-data-rest + ${springdoc.version} diff --git a/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/controller/BookController.java b/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/controller/BookController.java index 4d7d9e3d85..05f8c5a946 100644 --- a/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/controller/BookController.java +++ b/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/controller/BookController.java @@ -6,6 +6,8 @@ import javax.validation.Valid; import javax.validation.constraints.NotNull; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -41,6 +43,11 @@ public class BookController { return repository.getBooks(); } + @GetMapping("/filter") + public Page filterBooks(Pageable pageable) { + return repository.getBooks(pageable); + } + @PutMapping("/{id}") @ResponseStatus(HttpStatus.OK) public Book updateBook(@PathVariable("id") final String id, @RequestBody final Book book) { diff --git a/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/repository/BookRepository.java b/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/repository/BookRepository.java index 4040ba28c2..0e3636d084 100644 --- a/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/repository/BookRepository.java +++ b/spring-boot-modules/spring-boot-springdoc/src/main/java/com/baeldung/springdoc/repository/BookRepository.java @@ -1,13 +1,14 @@ package com.baeldung.springdoc.repository; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; - +import com.baeldung.springdoc.model.Book; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Repository; -import com.baeldung.springdoc.model.Book; +import java.util.*; + +import static java.util.stream.Collectors.toList; @Repository public class BookRepository { @@ -25,4 +26,11 @@ public class BookRepository { public Collection getBooks() { return books.values(); } + + public Page getBooks(Pageable pageable) { + int toSkip = pageable.getPageSize() * pageable.getPageNumber(); + List result = books.values().stream().skip(toSkip).limit(pageable.getPageSize()).collect(toList()); + + return new PageImpl<>(result, pageable, books.size()); + } } diff --git a/spring-boot-modules/spring-boot-springdoc/src/main/resources/application.properties b/spring-boot-modules/spring-boot-springdoc/src/main/resources/application.properties index f03e90feb6..45378e610b 100644 --- a/spring-boot-modules/spring-boot-springdoc/src/main/resources/application.properties +++ b/spring-boot-modules/spring-boot-springdoc/src/main/resources/application.properties @@ -3,3 +3,6 @@ springdoc.swagger-ui.path=/swagger-ui-custom.html # custom path for api docs springdoc.api-docs.path=/api-docs + +# H2 Related Configurations +spring.datasource.url=jdbc:h2:mem:springdoc \ No newline at end of file diff --git a/spring-cloud/spring-cloud-zookeeper/Greeting/pom.xml b/spring-cloud/spring-cloud-zookeeper/Greeting/pom.xml index fd524a1a4a..ac469d8bc4 100644 --- a/spring-cloud/spring-cloud-zookeeper/Greeting/pom.xml +++ b/spring-cloud/spring-cloud-zookeeper/Greeting/pom.xml @@ -65,14 +65,14 @@ org.hamcrest hamcrest-core - ${hamcrest.version} + ${hamcrest-core.version} test 1.2.5.RELEASE - 1.3 + 1.3 - \ No newline at end of file + diff --git a/spring-cloud/spring-cloud-zuul/spring-zuul-ui/pom.xml b/spring-cloud/spring-cloud-zuul/spring-zuul-ui/pom.xml index 09c94663b1..7978d9c77b 100644 --- a/spring-cloud/spring-cloud-zuul/spring-zuul-ui/pom.xml +++ b/spring-cloud/spring-cloud-zuul/spring-zuul-ui/pom.xml @@ -24,12 +24,7 @@ org.hamcrest - hamcrest-core - test - - - org.hamcrest - hamcrest-library + hamcrest test diff --git a/spring-core-2/pom.xml b/spring-core-2/pom.xml index 4d474d8b2c..edbb351bd0 100644 --- a/spring-core-2/pom.xml +++ b/spring-core-2/pom.xml @@ -135,12 +135,7 @@ org.hamcrest - hamcrest-core - test - - - org.hamcrest - hamcrest-library + hamcrest test diff --git a/spring-core-3/static-value-injection/README.md b/spring-core-3/static-value-injection/README.md new file mode 100644 index 0000000000..06dfa29f80 --- /dev/null +++ b/spring-core-3/static-value-injection/README.md @@ -0,0 +1,22 @@ +# Inject a value to a static field + +## How to run +```sh +mvn clean install +mvn spring-boot:run +``` + +## Request + +**GET** +http://localhost:8080/properties + + +## Response +```json +[ + "Inject a value to a static field", + "Inject a value to a static field", + null +] +``` diff --git a/spring-core-3/static-value-injection/pom.xml b/spring-core-3/static-value-injection/pom.xml new file mode 100644 index 0000000000..aa45fde886 --- /dev/null +++ b/spring-core-3/static-value-injection/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.2.4.RELEASE + + + com.baeldung + static.value.injection + 0.0.1-SNAPSHOT + static.value.injection + Demo project for Spring Boot + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/spring-core-3/static-value-injection/src/main/java/com/baeldung/Application.java b/spring-core-3/static-value-injection/src/main/java/com/baeldung/Application.java new file mode 100644 index 0000000000..c1875216b5 --- /dev/null +++ b/spring-core-3/static-value-injection/src/main/java/com/baeldung/Application.java @@ -0,0 +1,13 @@ +package com.baeldung; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/spring-core-3/static-value-injection/src/main/java/com/baeldung/controller/PropertyController.java b/spring-core-3/static-value-injection/src/main/java/com/baeldung/controller/PropertyController.java new file mode 100644 index 0000000000..03a2518117 --- /dev/null +++ b/spring-core-3/static-value-injection/src/main/java/com/baeldung/controller/PropertyController.java @@ -0,0 +1,31 @@ +package com.baeldung.controller; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Arrays; +import java.util.List; + +@RestController +public class PropertyController { + + @Value("${name}") + private String name; + + @Value("${name}") + private static String NAME_NULL; + + private static String NAME_STATIC; + + @Value("${name}") + public void setNameStatic(String name){ + PropertyController.NAME_STATIC = name; + } + + @GetMapping("/properties") + public List getProperties(){ + return Arrays.asList(this.name, NAME_STATIC, NAME_NULL) ; + } +} diff --git a/spring-core-3/static-value-injection/src/main/resources/application.properties b/spring-core-3/static-value-injection/src/main/resources/application.properties new file mode 100644 index 0000000000..828fa9cd2a --- /dev/null +++ b/spring-core-3/static-value-injection/src/main/resources/application.properties @@ -0,0 +1 @@ +name = Inject a value to a static field diff --git a/spring-core-3/static-value-injection/src/test/java/com/baeldung/ApplicationTests.java b/spring-core-3/static-value-injection/src/test/java/com/baeldung/ApplicationTests.java new file mode 100644 index 0000000000..4ad83bc539 --- /dev/null +++ b/spring-core-3/static-value-injection/src/test/java/com/baeldung/ApplicationTests.java @@ -0,0 +1,13 @@ +package com.baeldung; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/spring-rest-query-language/pom.xml b/spring-rest-query-language/pom.xml index 25b149367e..2423528743 100644 --- a/spring-rest-query-language/pom.xml +++ b/spring-rest-query-language/pom.xml @@ -206,15 +206,9 @@ test - - - - - - org.hamcrest - hamcrest-library + hamcrest test diff --git a/spring-rest-simple/pom.xml b/spring-rest-simple/pom.xml index 59f7a94b8d..291053c87f 100644 --- a/spring-rest-simple/pom.xml +++ b/spring-rest-simple/pom.xml @@ -139,12 +139,7 @@ org.hamcrest - hamcrest-core - test - - - org.hamcrest - hamcrest-library + hamcrest test diff --git a/spring-rest-testing/pom.xml b/spring-rest-testing/pom.xml index dcd8b677be..d807459cad 100644 --- a/spring-rest-testing/pom.xml +++ b/spring-rest-testing/pom.xml @@ -177,14 +177,9 @@ test - - - - - org.hamcrest - hamcrest-library + hamcrest test diff --git a/spring-resttemplate/pom.xml b/spring-resttemplate/pom.xml index 138fde3b45..05660f5210 100644 --- a/spring-resttemplate/pom.xml +++ b/spring-resttemplate/pom.xml @@ -130,12 +130,7 @@ org.hamcrest - hamcrest-core - test - - - org.hamcrest - hamcrest-library + hamcrest test diff --git a/spring-scheduling/README.md b/spring-scheduling/README.md index ddc540bafb..bf34fb60de 100644 --- a/spring-scheduling/README.md +++ b/spring-scheduling/README.md @@ -1,7 +1,7 @@ ### Relevant articles: -- [A Guide to the Spring Task Scheduler](http://www.baeldung.com/spring-task-scheduler) +- [A Guide to the Spring Task Scheduler](https://www.baeldung.com/spring-task-scheduler) - [The @Scheduled Annotation in Spring](https://www.baeldung.com/spring-scheduled-tasks) -- [Guide to Spring Retry](http://www.baeldung.com/spring-retry) -- [How To Do @Async in Spring](http://www.baeldung.com/spring-async) +- [Guide to Spring Retry](https://www.baeldung.com/spring-retry) +- [How To Do @Async in Spring](https://www.baeldung.com/spring-async) - [Conditionally Enable Scheduled Jobs in Spring](https://www.baeldung.com/spring-scheduled-enabled-conditionally) diff --git a/spring-security-modules/spring-security-cache-control/pom.xml b/spring-security-modules/spring-security-cache-control/pom.xml index ff96ae78dd..acc37b41ef 100644 --- a/spring-security-modules/spring-security-cache-control/pom.xml +++ b/spring-security-modules/spring-security-cache-control/pom.xml @@ -42,12 +42,8 @@ org.hamcrest - hamcrest-core - test - - - org.hamcrest - hamcrest-library + hamcrest + ${hamcrest.version} test diff --git a/spring-security-modules/spring-security-mvc-boot-1/pom.xml b/spring-security-modules/spring-security-mvc-boot-1/pom.xml index 3eeac80d2c..7dfee200d4 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/pom.xml +++ b/spring-security-modules/spring-security-mvc-boot-1/pom.xml @@ -61,12 +61,7 @@ org.hamcrest - hamcrest-core - test - - - org.hamcrest - hamcrest-library + hamcrest test diff --git a/spring-security-modules/spring-security-mvc-boot-2/pom.xml b/spring-security-modules/spring-security-mvc-boot-2/pom.xml index fca38b9714..565528e070 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/pom.xml +++ b/spring-security-modules/spring-security-mvc-boot-2/pom.xml @@ -61,12 +61,7 @@ org.hamcrest - hamcrest-core - test - - - org.hamcrest - hamcrest-library + hamcrest test diff --git a/spring-security-modules/spring-security-rest-custom/pom.xml b/spring-security-modules/spring-security-rest-custom/pom.xml index d9072ec8a2..b4f0f93bb6 100644 --- a/spring-security-modules/spring-security-rest-custom/pom.xml +++ b/spring-security-modules/spring-security-rest-custom/pom.xml @@ -136,12 +136,7 @@ org.hamcrest - hamcrest-core - test - - - org.hamcrest - hamcrest-library + hamcrest test diff --git a/spring-security-modules/spring-security-rest/README.md b/spring-security-modules/spring-security-rest/README.md index 00bc2a1403..f7e91b85dc 100644 --- a/spring-security-modules/spring-security-rest/README.md +++ b/spring-security-modules/spring-security-rest/README.md @@ -16,3 +16,4 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com - [Intro to Spring Security Expressions](https://www.baeldung.com/spring-security-expressions) - [Spring Security for a REST API](https://www.baeldung.com/securing-a-restful-web-service-with-spring-security) - [Spring Security Expressions - hasRole Example](https://www.baeldung.com/spring-security-expressions-basic) +- [Error Handling for REST with Spring](https://www.baeldung.com/exception-handling-for-rest-with-spring) diff --git a/testing-modules/hamcrest/pom.xml b/testing-modules/hamcrest/pom.xml index cfd5bf5fac..ec9177d8f2 100644 --- a/testing-modules/hamcrest/pom.xml +++ b/testing-modules/hamcrest/pom.xml @@ -18,13 +18,13 @@ org.hamcrest java-hamcrest - ${hamcrest.version} + ${java-hamcrest.version} test - 2.0.0.0 + 2.0.0.0 diff --git a/testing-modules/mockito/pom.xml b/testing-modules/mockito/pom.xml index 0fb11d23ab..aae3981c66 100644 --- a/testing-modules/mockito/pom.xml +++ b/testing-modules/mockito/pom.xml @@ -90,7 +90,6 @@ 2.0.2 - 2.0.0.0 2.1.1 diff --git a/testing-modules/selenium-junit-testng/pom.xml b/testing-modules/selenium-junit-testng/pom.xml index 0616cdaa29..3734bf72c9 100644 --- a/testing-modules/selenium-junit-testng/pom.xml +++ b/testing-modules/selenium-junit-testng/pom.xml @@ -38,7 +38,7 @@ org.hamcrest hamcrest-all - ${org.hamcrest.version} + ${hamcrest-all.version} @@ -71,4 +71,4 @@ 3.4.0 - \ No newline at end of file + diff --git a/testing-modules/spring-testing/pom.xml b/testing-modules/spring-testing/pom.xml index 38e7a0dd46..c5e94f3afc 100644 --- a/testing-modules/spring-testing/pom.xml +++ b/testing-modules/spring-testing/pom.xml @@ -19,7 +19,7 @@ org.hamcrest java-hamcrest - ${hamcrest.version} + ${java-hamcrest.version} @@ -114,7 +114,7 @@ - 2.0.0.0 + 2.0.0.0 3.1.6 5.5.0 1.5.2 diff --git a/testing-modules/testing-libraries/README.md b/testing-modules/testing-libraries/README.md index b5360bd841..b1e1575e63 100644 --- a/testing-modules/testing-libraries/README.md +++ b/testing-modules/testing-libraries/README.md @@ -5,7 +5,6 @@ - [Intro to JaCoCo](http://www.baeldung.com/jacoco) - [Cucumber and Scenario Outline](http://www.baeldung.com/cucumber-scenario-outline) - [Cucumber Java 8 Support](http://www.baeldung.com/cucumber-java-8-support) -- [Introduction to Lambda Behave](http://www.baeldung.com/lambda-behave) - [Introduction to CheckStyle](https://www.baeldung.com/checkstyle-java) - [Introduction to FindBugs](https://www.baeldung.com/intro-to-findbugs) - [Cucumber Data Tables](https://www.baeldung.com/cucumber-data-tables)