From 6762557f1ec4e0731aa8291d02b8e93ce91b966a Mon Sep 17 00:00:00 2001 From: fejera Date: Sun, 17 Nov 2019 15:04:03 +0100 Subject: [PATCH 001/503] added live-all profile to root pom --- pom.xml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pom.xml b/pom.xml index bc4c38f386..63561cb65e 100644 --- a/pom.xml +++ b/pom.xml @@ -1671,6 +1671,39 @@ + + + live-all + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + **/SpringContextTest.java + **/*UnitTest.java + **/*IntegrationTest.java + **/*IntTest.java + **/*LongRunningUnitTest.java + **/*ManualTest.java + **/*JdbcTest.java + + + **/*LiveTest.java + + + + + + + + + + + + From ae8ef36227de957b2696acf94bb782941dcefe1a Mon Sep 17 00:00:00 2001 From: fejera Date: Sun, 17 Nov 2019 15:05:58 +0100 Subject: [PATCH 002/503] added live-test resources --- persistence-modules/spring-data-mongodb/live-test.sh | 11 +++++++++++ .../spring-data-mongodb/live-test/Dockerfile | 8 ++++++++ .../spring-data-mongodb/live-test/init-session.js | 1 + 3 files changed, 20 insertions(+) create mode 100755 persistence-modules/spring-data-mongodb/live-test.sh create mode 100644 persistence-modules/spring-data-mongodb/live-test/Dockerfile create mode 100644 persistence-modules/spring-data-mongodb/live-test/init-session.js diff --git a/persistence-modules/spring-data-mongodb/live-test.sh b/persistence-modules/spring-data-mongodb/live-test.sh new file mode 100755 index 0000000000..bb513a90bb --- /dev/null +++ b/persistence-modules/spring-data-mongodb/live-test.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +docker image build -t spring-data-mongodb:live-test live-test/ + +docker run -p 27017:27017 --name spring-data-mongodb-live-test -it spring-data-mongodb:live-test +#wait + +mvn clean compile test -P live-all + +docker stop spring-data-mongodb-live-test +docker rm spring-data-mongodb-live-test diff --git a/persistence-modules/spring-data-mongodb/live-test/Dockerfile b/persistence-modules/spring-data-mongodb/live-test/Dockerfile new file mode 100644 index 0000000000..9e3634feb0 --- /dev/null +++ b/persistence-modules/spring-data-mongodb/live-test/Dockerfile @@ -0,0 +1,8 @@ +FROM mongo:4.2.1 + +COPY init-session.js /docker-entrypoint-initdb.d/ + +EXPOSE 27017 + +HEALTHCHECK --interval=5s --timeout=3s --start-period=10s CMD mongo db.stats() +CMD ["mongod", "--replSet", "rs0"] diff --git a/persistence-modules/spring-data-mongodb/live-test/init-session.js b/persistence-modules/spring-data-mongodb/live-test/init-session.js new file mode 100644 index 0000000000..2e968884cc --- /dev/null +++ b/persistence-modules/spring-data-mongodb/live-test/init-session.js @@ -0,0 +1 @@ +rs.initiate(); From 23fb4ae451fef29cb5a81d486542e32cb4d5b979 Mon Sep 17 00:00:00 2001 From: fejera Date: Sun, 24 Nov 2019 12:42:59 +0100 Subject: [PATCH 003/503] cleaned up and documented live testing script usage --- persistence-modules/spring-data-mongodb/LIVE-TEST.md | 9 +++++++++ .../spring-data-mongodb/live-test-setup.sh | 5 +++++ .../spring-data-mongodb/live-test-teardown.sh | 4 ++++ persistence-modules/spring-data-mongodb/live-test.sh | 8 -------- 4 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 persistence-modules/spring-data-mongodb/LIVE-TEST.md create mode 100644 persistence-modules/spring-data-mongodb/live-test-setup.sh create mode 100644 persistence-modules/spring-data-mongodb/live-test-teardown.sh diff --git a/persistence-modules/spring-data-mongodb/LIVE-TEST.md b/persistence-modules/spring-data-mongodb/LIVE-TEST.md new file mode 100644 index 0000000000..9da1ea249e --- /dev/null +++ b/persistence-modules/spring-data-mongodb/LIVE-TEST.md @@ -0,0 +1,9 @@ +========= + +## Spring Data MongoDB Live Testing + + +There are 3 scripts to simplify running live tests: +1. `live-test-setup.sh` builds a docker image with the necessary setup and runs it. The environment is ready, when the log stops - it takes approximately 30 seconds. +2. `live-test.sh` runs the live tests (but no other tests). +3. `live-test-setup.sh` stops and removes the docker image. diff --git a/persistence-modules/spring-data-mongodb/live-test-setup.sh b/persistence-modules/spring-data-mongodb/live-test-setup.sh new file mode 100644 index 0000000000..37e6c48dbd --- /dev/null +++ b/persistence-modules/spring-data-mongodb/live-test-setup.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +docker image build -t spring-data-mongodb:live-test live-test/ + +docker run -p 27017:27017 --name spring-data-mongodb-live-test spring-data-mongodb:live-test diff --git a/persistence-modules/spring-data-mongodb/live-test-teardown.sh b/persistence-modules/spring-data-mongodb/live-test-teardown.sh new file mode 100644 index 0000000000..a29163bc7a --- /dev/null +++ b/persistence-modules/spring-data-mongodb/live-test-teardown.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker stop spring-data-mongodb-live-test +docker rm spring-data-mongodb-live-test diff --git a/persistence-modules/spring-data-mongodb/live-test.sh b/persistence-modules/spring-data-mongodb/live-test.sh index bb513a90bb..5a079bdac8 100755 --- a/persistence-modules/spring-data-mongodb/live-test.sh +++ b/persistence-modules/spring-data-mongodb/live-test.sh @@ -1,11 +1,3 @@ #!/bin/bash -docker image build -t spring-data-mongodb:live-test live-test/ - -docker run -p 27017:27017 --name spring-data-mongodb-live-test -it spring-data-mongodb:live-test -#wait - mvn clean compile test -P live-all - -docker stop spring-data-mongodb-live-test -docker rm spring-data-mongodb-live-test From 1afd7a40e20ba55edd147e2f95c873f46c3b8539 Mon Sep 17 00:00:00 2001 From: fejera Date: Mon, 2 Dec 2019 10:18:42 +0100 Subject: [PATCH 004/503] moved live test resources to src/live-test/resources --- persistence-modules/spring-data-mongodb/live-test-setup.sh | 2 +- .../{live-test => src/live-test/resources}/Dockerfile | 0 .../{live-test => src/live-test/resources}/init-session.js | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename persistence-modules/spring-data-mongodb/{live-test => src/live-test/resources}/Dockerfile (100%) rename persistence-modules/spring-data-mongodb/{live-test => src/live-test/resources}/init-session.js (100%) diff --git a/persistence-modules/spring-data-mongodb/live-test-setup.sh b/persistence-modules/spring-data-mongodb/live-test-setup.sh index 37e6c48dbd..e8e0437083 100644 --- a/persistence-modules/spring-data-mongodb/live-test-setup.sh +++ b/persistence-modules/spring-data-mongodb/live-test-setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -docker image build -t spring-data-mongodb:live-test live-test/ +docker image build -t spring-data-mongodb:live-test src/live-test/resources/ docker run -p 27017:27017 --name spring-data-mongodb-live-test spring-data-mongodb:live-test diff --git a/persistence-modules/spring-data-mongodb/live-test/Dockerfile b/persistence-modules/spring-data-mongodb/src/live-test/resources/Dockerfile similarity index 100% rename from persistence-modules/spring-data-mongodb/live-test/Dockerfile rename to persistence-modules/spring-data-mongodb/src/live-test/resources/Dockerfile diff --git a/persistence-modules/spring-data-mongodb/live-test/init-session.js b/persistence-modules/spring-data-mongodb/src/live-test/resources/init-session.js similarity index 100% rename from persistence-modules/spring-data-mongodb/live-test/init-session.js rename to persistence-modules/spring-data-mongodb/src/live-test/resources/init-session.js From 421d15b1324cde53a91abc359d5a88ab93b99a1a Mon Sep 17 00:00:00 2001 From: mrsoto Date: Sat, 14 Dec 2019 22:03:27 -0300 Subject: [PATCH 005/503] Cleanup and function references --- .../convertlisttomap/ConvertListToMapService.java | 3 ++- .../CollectionToArrayListUnitTest.java | 12 ++++++------ .../ConvertIteratorToListServiceUnitTest.java | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/java-collections-conversions/src/main/java/com/baeldung/convertlisttomap/ConvertListToMapService.java b/java-collections-conversions/src/main/java/com/baeldung/convertlisttomap/ConvertListToMapService.java index 6527d35742..57579e948f 100644 --- a/java-collections-conversions/src/main/java/com/baeldung/convertlisttomap/ConvertListToMapService.java +++ b/java-collections-conversions/src/main/java/com/baeldung/convertlisttomap/ConvertListToMapService.java @@ -6,6 +6,7 @@ import org.apache.commons.collections4.MapUtils; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Function; import java.util.stream.Collectors; public class ConvertListToMapService { @@ -21,7 +22,7 @@ public class ConvertListToMapService { } public Map convertListAfterJava8(List list) { - Map map = list.stream().collect(Collectors.toMap(Animal::getId, animal -> animal)); + Map map = list.stream().collect(Collectors.toMap(Animal::getId, Function.identity())); return map; } diff --git a/java-collections-conversions/src/test/java/com/baeldung/convertcollectiontoarraylist/CollectionToArrayListUnitTest.java b/java-collections-conversions/src/test/java/com/baeldung/convertcollectiontoarraylist/CollectionToArrayListUnitTest.java index ad2ab2a756..15960c300d 100644 --- a/java-collections-conversions/src/test/java/com/baeldung/convertcollectiontoarraylist/CollectionToArrayListUnitTest.java +++ b/java-collections-conversions/src/test/java/com/baeldung/convertcollectiontoarraylist/CollectionToArrayListUnitTest.java @@ -53,14 +53,14 @@ public class CollectionToArrayListUnitTest { verifyShallowCopy(srcCollection, newList); } - + /** * Section 5. Deep Copy */ @Test public void whenUsingDeepCopy_thenVerifyDeepCopy() { ArrayList newList = srcCollection.stream() - .map(foo -> foo.deepCopy()) + .map(Foo::deepCopy) .collect(toCollection(ArrayList::new)); verifyDeepCopy(srcCollection, newList); @@ -83,13 +83,13 @@ public class CollectionToArrayListUnitTest { * @param a * @param b */ - private void verifyShallowCopy(Collection a, Collection b) { + private void verifyShallowCopy(Collection a, Collection b) { assertEquals("Collections have different lengths", a.size(), b.size()); Iterator iterA = a.iterator(); Iterator iterB = b.iterator(); while (iterA.hasNext()) { // use '==' to test instance identity - assertTrue("Foo instances differ!", iterA.next() == iterB.next()); + assertSame("Foo instances differ!", iterA.next(), iterB.next()); } } @@ -98,7 +98,7 @@ public class CollectionToArrayListUnitTest { * @param a * @param b */ - private void verifyDeepCopy(Collection a, Collection b) { + private void verifyDeepCopy(Collection a, Collection b) { assertEquals("Collections have different lengths", a.size(), b.size()); Iterator iterA = a.iterator(); Iterator iterB = b.iterator(); @@ -106,7 +106,7 @@ public class CollectionToArrayListUnitTest { Foo nextA = iterA.next(); Foo nextB = iterB.next(); // should not be same instance - assertFalse("Foo instances are the same!", nextA == nextB); + assertNotSame("Foo instances are the same!", nextA, nextB); // but should have same content assertFalse("Foo instances have different content!", fooDiff(nextA, nextB)); } diff --git a/java-collections-conversions/src/test/java/com/baeldung/convertiteratortolist/ConvertIteratorToListServiceUnitTest.java b/java-collections-conversions/src/test/java/com/baeldung/convertiteratortolist/ConvertIteratorToListServiceUnitTest.java index 4d6cba7d27..7d94f88d21 100644 --- a/java-collections-conversions/src/test/java/com/baeldung/convertiteratortolist/ConvertIteratorToListServiceUnitTest.java +++ b/java-collections-conversions/src/test/java/com/baeldung/convertiteratortolist/ConvertIteratorToListServiceUnitTest.java @@ -23,7 +23,7 @@ public class ConvertIteratorToListServiceUnitTest { Iterator iterator; @Before - public void setUp() throws Exception { + public void setUp() { iterator = Arrays.asList(1, 2, 3) .iterator(); } @@ -31,7 +31,7 @@ public class ConvertIteratorToListServiceUnitTest { @Test public void givenAnIterator_whenConvertIteratorToListUsingWhileLoop_thenReturnAList() { - List actualList = new ArrayList(); + List actualList = new ArrayList<>(); // Convert Iterator to List using while loop dsf while (iterator.hasNext()) { @@ -44,7 +44,7 @@ public class ConvertIteratorToListServiceUnitTest { @Test public void givenAnIterator_whenConvertIteratorToListAfterJava8_thenReturnAList() { - List actualList = new ArrayList(); + List actualList = new ArrayList<>(); // Convert Iterator to List using Java 8 iterator.forEachRemaining(actualList::add); From 84c71c639906885edb1b343d7425a872081cc55c Mon Sep 17 00:00:00 2001 From: cxmshine <13724591964@163.com> Date: Thu, 9 Jan 2020 23:45:10 +0800 Subject: [PATCH 006/503] update AddressMapper.java --- .../main/java/com/baeldung/mybatis/mapper/AddressMapper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mybatis/src/main/java/com/baeldung/mybatis/mapper/AddressMapper.java b/mybatis/src/main/java/com/baeldung/mybatis/mapper/AddressMapper.java index e96a4837db..c79ef667bd 100644 --- a/mybatis/src/main/java/com/baeldung/mybatis/mapper/AddressMapper.java +++ b/mybatis/src/main/java/com/baeldung/mybatis/mapper/AddressMapper.java @@ -14,8 +14,8 @@ public interface AddressMapper { @Results(value = { @Result(property = "addressId", column = "addressId"), @Result(property = "streetAddress", column = "streetAddress"), @Result(property = "person", column = "personId", javaType = Person.class, one = @One(select = "getPerson")) }) - Address getAddresses(Integer addressID); + Address getAddresses(Integer addressId); @Select("SELECT personId FROM address WHERE addressId = #{addressId})") - Person getPerson(Integer personId); + Person getPerson(Integer addressId); } From eb4e462b36f2e486e7b51865ea6e9a62c161d928 Mon Sep 17 00:00:00 2001 From: crist Date: Tue, 4 Feb 2020 18:20:00 +0200 Subject: [PATCH 007/503] [BAEL-3750] Breaking YAML Strings Over Multiple Lines --- yaml/README.md | 7 ++ yaml/pom.xml | 29 ++++++ .../multiline/MultiLineStringsUnitTest.java | 90 +++++++++++++++++++ .../src/test/resources/multi-line/folded.yaml | 4 + .../test/resources/multi-line/folded2.yaml | 9 ++ .../resources/multi-line/folded_keep.yaml | 6 ++ .../resources/multi-line/folded_strip.yaml | 7 ++ .../test/resources/multi-line/literal.yaml | 4 + .../test/resources/multi-line/literal2.yaml | 10 +++ .../resources/multi-line/literal_keep.yaml | 5 ++ .../resources/multi-line/literal_strip.yaml | 5 ++ .../multi-line/plain_double_quotes.yaml | 1 + .../multi-line/plain_single_quotes.yaml | 3 + 13 files changed, 180 insertions(+) create mode 100644 yaml/README.md create mode 100644 yaml/pom.xml create mode 100644 yaml/src/test/java/com/baeldung/multiline/MultiLineStringsUnitTest.java create mode 100644 yaml/src/test/resources/multi-line/folded.yaml create mode 100644 yaml/src/test/resources/multi-line/folded2.yaml create mode 100644 yaml/src/test/resources/multi-line/folded_keep.yaml create mode 100644 yaml/src/test/resources/multi-line/folded_strip.yaml create mode 100644 yaml/src/test/resources/multi-line/literal.yaml create mode 100644 yaml/src/test/resources/multi-line/literal2.yaml create mode 100644 yaml/src/test/resources/multi-line/literal_keep.yaml create mode 100644 yaml/src/test/resources/multi-line/literal_strip.yaml create mode 100644 yaml/src/test/resources/multi-line/plain_double_quotes.yaml create mode 100644 yaml/src/test/resources/multi-line/plain_single_quotes.yaml diff --git a/yaml/README.md b/yaml/README.md new file mode 100644 index 0000000000..ebf403eb57 --- /dev/null +++ b/yaml/README.md @@ -0,0 +1,7 @@ +## YAML + +This module contains articles about YAML + +### Relevant articles + + diff --git a/yaml/pom.xml b/yaml/pom.xml new file mode 100644 index 0000000000..c801505c6a --- /dev/null +++ b/yaml/pom.xml @@ -0,0 +1,29 @@ + + + + 4.0.0 + yaml + 1.0-SNAPSHOT + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + org.yaml + snakeyaml + 1.21 + + + + + 1.8 + 1.21 + + + \ No newline at end of file diff --git a/yaml/src/test/java/com/baeldung/multiline/MultiLineStringsUnitTest.java b/yaml/src/test/java/com/baeldung/multiline/MultiLineStringsUnitTest.java new file mode 100644 index 0000000000..c97faa355a --- /dev/null +++ b/yaml/src/test/java/com/baeldung/multiline/MultiLineStringsUnitTest.java @@ -0,0 +1,90 @@ +package com.baeldung.multiline; + +import org.junit.Before; +import org.junit.Test; +import org.yaml.snakeyaml.Yaml; + +import java.io.File; +import java.io.InputStream; +import java.util.Map; + +import static org.junit.Assert.assertEquals; + +public class MultiLineStringsUnitTest { + + private Yaml yaml; + + @Before + public void setup() { + yaml = new Yaml(); + } + + @Test + public void whenLiteral_ThenLineBreaksArePresent() { + String key = parseYamlKey("literal.yaml"); + assertEquals("Line1\nLine2\nLine3", key); + } + + @Test + public void whenLiteral_ThenEndingBreaksAreReducedToOne() { + String key = parseYamlKey("literal2.yaml"); + assertEquals("\n\nLine1\n\nLine2\n\nLine3\n", key); + } + + @Test + public void whenFolded_ThenLineBreaksAreReplaced() { + String key = parseYamlKey("folded.yaml"); + assertEquals("Line1 Line2 Line3", key); + } + + @Test + public void whenFolded_ThenEmptyLinesAreReducedToOne() { + String key = parseYamlKey("folded2.yaml"); + assertEquals("Line1\nLine2\n\nLine3\n", key); + } + + @Test + public void whenLiteralKeep_ThenLastEmptyLinesArePresent() { + String key = parseYamlKey("literal_keep.yaml"); + assertEquals("Line1\nLine2\nLine3\n\n", key); + } + + @Test + public void whenLiteralStrip_ThenLastEmptyLinesAreRemoved() { + String key = parseYamlKey("literal_strip.yaml"); + assertEquals("Line1\nLine2\nLine3", key); + } + + @Test + public void whenFoldedKeep_ThenLastEmptyLinesArePresent() { + String key = parseYamlKey("folded_keep.yaml"); + assertEquals("Line1 Line2 Line3\n\n\n", key); + } + + @Test + public void whenFoldedStrip_ThenLastEmptyLinesAreRemoved() { + String key = parseYamlKey("folded_strip.yaml"); + assertEquals("Line1 Line2 Line3", key); + } + + @Test + public void whenDoubleQuotes_ThenExplicitBreaksArePreserved() { + String key = parseYamlKey("plain_double_quotes.yaml"); + assertEquals("Line1\nLine2\nLine3", key); + } + + @Test + public void whenSingleQuotes_ThenExplicitBreaksAreIgnored() { + String key = parseYamlKey("plain_single_quotes.yaml"); + assertEquals("Line1\\nLine2\nLine3", key); + } + + private String parseYamlKey(String fileName) { + InputStream inputStream = this.getClass() + .getClassLoader() + .getResourceAsStream("multi-line" + File.separator + fileName); + Map parsed = yaml.load(inputStream); + return parsed.get("key"); + } + +} diff --git a/yaml/src/test/resources/multi-line/folded.yaml b/yaml/src/test/resources/multi-line/folded.yaml new file mode 100644 index 0000000000..c5fa743a08 --- /dev/null +++ b/yaml/src/test/resources/multi-line/folded.yaml @@ -0,0 +1,4 @@ +key: > + Line1 + Line2 + Line3 \ No newline at end of file diff --git a/yaml/src/test/resources/multi-line/folded2.yaml b/yaml/src/test/resources/multi-line/folded2.yaml new file mode 100644 index 0000000000..a7f244994a --- /dev/null +++ b/yaml/src/test/resources/multi-line/folded2.yaml @@ -0,0 +1,9 @@ +key: > + Line1 + + Line2 + + + Line3 + + diff --git a/yaml/src/test/resources/multi-line/folded_keep.yaml b/yaml/src/test/resources/multi-line/folded_keep.yaml new file mode 100644 index 0000000000..555291fd26 --- /dev/null +++ b/yaml/src/test/resources/multi-line/folded_keep.yaml @@ -0,0 +1,6 @@ +key: >+ + Line1 + Line2 + Line3 + + diff --git a/yaml/src/test/resources/multi-line/folded_strip.yaml b/yaml/src/test/resources/multi-line/folded_strip.yaml new file mode 100644 index 0000000000..0a3a246dc2 --- /dev/null +++ b/yaml/src/test/resources/multi-line/folded_strip.yaml @@ -0,0 +1,7 @@ +key: >- + Line1 + Line2 + Line3 + + + diff --git a/yaml/src/test/resources/multi-line/literal.yaml b/yaml/src/test/resources/multi-line/literal.yaml new file mode 100644 index 0000000000..7e02501a33 --- /dev/null +++ b/yaml/src/test/resources/multi-line/literal.yaml @@ -0,0 +1,4 @@ +key: | + Line1 + Line2 + Line3 \ No newline at end of file diff --git a/yaml/src/test/resources/multi-line/literal2.yaml b/yaml/src/test/resources/multi-line/literal2.yaml new file mode 100644 index 0000000000..7c7fed0163 --- /dev/null +++ b/yaml/src/test/resources/multi-line/literal2.yaml @@ -0,0 +1,10 @@ +key: | + + + Line1 + + Line2 + + Line3 + + diff --git a/yaml/src/test/resources/multi-line/literal_keep.yaml b/yaml/src/test/resources/multi-line/literal_keep.yaml new file mode 100644 index 0000000000..37f22684dd --- /dev/null +++ b/yaml/src/test/resources/multi-line/literal_keep.yaml @@ -0,0 +1,5 @@ +key: |+ + Line1 + Line2 + Line3 + diff --git a/yaml/src/test/resources/multi-line/literal_strip.yaml b/yaml/src/test/resources/multi-line/literal_strip.yaml new file mode 100644 index 0000000000..0791e13d5d --- /dev/null +++ b/yaml/src/test/resources/multi-line/literal_strip.yaml @@ -0,0 +1,5 @@ +key: |- + Line1 + Line2 + Line3 + diff --git a/yaml/src/test/resources/multi-line/plain_double_quotes.yaml b/yaml/src/test/resources/multi-line/plain_double_quotes.yaml new file mode 100644 index 0000000000..ccab040a27 --- /dev/null +++ b/yaml/src/test/resources/multi-line/plain_double_quotes.yaml @@ -0,0 +1 @@ +key: "Line1\nLine2\nLine3" \ No newline at end of file diff --git a/yaml/src/test/resources/multi-line/plain_single_quotes.yaml b/yaml/src/test/resources/multi-line/plain_single_quotes.yaml new file mode 100644 index 0000000000..acbf35a462 --- /dev/null +++ b/yaml/src/test/resources/multi-line/plain_single_quotes.yaml @@ -0,0 +1,3 @@ +key: 'Line1\nLine2 + + Line3' \ No newline at end of file From a1d246f2e1c6849abd0bdca347f910d3ee9f183b Mon Sep 17 00:00:00 2001 From: crist Date: Tue, 4 Feb 2020 18:22:20 +0200 Subject: [PATCH 008/503] Added yamo module to appropriate profiles --- pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pom.xml b/pom.xml index 2a0ae0d8d8..379c741648 100644 --- a/pom.xml +++ b/pom.xml @@ -781,6 +781,7 @@ wildfly xml xstream + yaml @@ -1304,6 +1305,7 @@ wildfly xml xstream + yaml From e2de2a78d19dd74eb4f66b212693644c5448bbf5 Mon Sep 17 00:00:00 2001 From: crist Date: Thu, 6 Feb 2020 02:32:40 +0200 Subject: [PATCH 009/503] Article improvements --- .../multiline/MultiLineStringsUnitTest.java | 26 +++++++++---------- .../test/resources/multi-line/folded2.yaml | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/yaml/src/test/java/com/baeldung/multiline/MultiLineStringsUnitTest.java b/yaml/src/test/java/com/baeldung/multiline/MultiLineStringsUnitTest.java index c97faa355a..a99de63a47 100644 --- a/yaml/src/test/java/com/baeldung/multiline/MultiLineStringsUnitTest.java +++ b/yaml/src/test/java/com/baeldung/multiline/MultiLineStringsUnitTest.java @@ -21,70 +21,70 @@ public class MultiLineStringsUnitTest { @Test public void whenLiteral_ThenLineBreaksArePresent() { - String key = parseYamlKey("literal.yaml"); + String key = parseYamlKey("literal.yaml", "key"); assertEquals("Line1\nLine2\nLine3", key); } @Test public void whenLiteral_ThenEndingBreaksAreReducedToOne() { - String key = parseYamlKey("literal2.yaml"); + String key = parseYamlKey("literal2.yaml", "key"); assertEquals("\n\nLine1\n\nLine2\n\nLine3\n", key); } @Test public void whenFolded_ThenLineBreaksAreReplaced() { - String key = parseYamlKey("folded.yaml"); + String key = parseYamlKey("folded.yaml", "key"); assertEquals("Line1 Line2 Line3", key); } @Test public void whenFolded_ThenEmptyLinesAreReducedToOne() { - String key = parseYamlKey("folded2.yaml"); - assertEquals("Line1\nLine2\n\nLine3\n", key); + String key = parseYamlKey("folded2.yaml", "key"); + assertEquals("Line1 Line2\n\nLine3\n", key); } @Test public void whenLiteralKeep_ThenLastEmptyLinesArePresent() { - String key = parseYamlKey("literal_keep.yaml"); + String key = parseYamlKey("literal_keep.yaml", "key"); assertEquals("Line1\nLine2\nLine3\n\n", key); } @Test public void whenLiteralStrip_ThenLastEmptyLinesAreRemoved() { - String key = parseYamlKey("literal_strip.yaml"); + String key = parseYamlKey("literal_strip.yaml", "key"); assertEquals("Line1\nLine2\nLine3", key); } @Test public void whenFoldedKeep_ThenLastEmptyLinesArePresent() { - String key = parseYamlKey("folded_keep.yaml"); + String key = parseYamlKey("folded_keep.yaml", "key"); assertEquals("Line1 Line2 Line3\n\n\n", key); } @Test public void whenFoldedStrip_ThenLastEmptyLinesAreRemoved() { - String key = parseYamlKey("folded_strip.yaml"); + String key = parseYamlKey("folded_strip.yaml", "key"); assertEquals("Line1 Line2 Line3", key); } @Test public void whenDoubleQuotes_ThenExplicitBreaksArePreserved() { - String key = parseYamlKey("plain_double_quotes.yaml"); + String key = parseYamlKey("plain_double_quotes.yaml", "key"); assertEquals("Line1\nLine2\nLine3", key); } @Test public void whenSingleQuotes_ThenExplicitBreaksAreIgnored() { - String key = parseYamlKey("plain_single_quotes.yaml"); + String key = parseYamlKey("plain_single_quotes.yaml", "key"); assertEquals("Line1\\nLine2\nLine3", key); } - private String parseYamlKey(String fileName) { + String parseYamlKey(String fileName, String key) { InputStream inputStream = this.getClass() .getClassLoader() .getResourceAsStream("multi-line" + File.separator + fileName); Map parsed = yaml.load(inputStream); - return parsed.get("key"); + return parsed.get(key); } } diff --git a/yaml/src/test/resources/multi-line/folded2.yaml b/yaml/src/test/resources/multi-line/folded2.yaml index a7f244994a..5c55ef62f2 100644 --- a/yaml/src/test/resources/multi-line/folded2.yaml +++ b/yaml/src/test/resources/multi-line/folded2.yaml @@ -1,9 +1,9 @@ key: > Line1 - Line2 Line3 +... \ No newline at end of file From 845f66ee2e21265beedbc78eaeaeaf1a02e90cf3 Mon Sep 17 00:00:00 2001 From: crist Date: Thu, 6 Feb 2020 02:37:44 +0200 Subject: [PATCH 010/503] Fix --- yaml/src/test/resources/multi-line/folded2.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/yaml/src/test/resources/multi-line/folded2.yaml b/yaml/src/test/resources/multi-line/folded2.yaml index 5c55ef62f2..735abf9b2f 100644 --- a/yaml/src/test/resources/multi-line/folded2.yaml +++ b/yaml/src/test/resources/multi-line/folded2.yaml @@ -6,4 +6,3 @@ key: > Line3 -... \ No newline at end of file From 2b51ce0ebcfda726fc43dbf3439a216cf209a483 Mon Sep 17 00:00:00 2001 From: crist Date: Mon, 10 Feb 2020 15:26:56 +0200 Subject: [PATCH 011/503] [BAEL-3750] Moved multi line yaml files from the yaml module to the libraries-data-io folder --- .../snakeyaml/MultiLineStringsUnitTest.java | 90 +++++++++++++++++++ .../test/resources/yaml/multiline/folded.yaml | 4 + .../resources/yaml/multiline/folded2.yaml | 8 ++ .../resources/yaml/multiline/folded_keep.yaml | 6 ++ .../yaml/multiline/folded_strip.yaml | 7 ++ .../resources/yaml/multiline/literal.yaml | 4 + .../resources/yaml/multiline/literal2.yaml | 10 +++ .../yaml/multiline/literal_keep.yaml | 5 ++ .../yaml/multiline/literal_strip.yaml | 5 ++ .../yaml/multiline/plain_double_quotes.yaml | 1 + .../yaml/multiline/plain_single_quotes.yaml | 3 + 11 files changed, 143 insertions(+) create mode 100644 libraries-data-io/src/test/java/com/baeldung/libraries/snakeyaml/MultiLineStringsUnitTest.java create mode 100644 libraries-data-io/src/test/resources/yaml/multiline/folded.yaml create mode 100644 libraries-data-io/src/test/resources/yaml/multiline/folded2.yaml create mode 100644 libraries-data-io/src/test/resources/yaml/multiline/folded_keep.yaml create mode 100644 libraries-data-io/src/test/resources/yaml/multiline/folded_strip.yaml create mode 100644 libraries-data-io/src/test/resources/yaml/multiline/literal.yaml create mode 100644 libraries-data-io/src/test/resources/yaml/multiline/literal2.yaml create mode 100644 libraries-data-io/src/test/resources/yaml/multiline/literal_keep.yaml create mode 100644 libraries-data-io/src/test/resources/yaml/multiline/literal_strip.yaml create mode 100644 libraries-data-io/src/test/resources/yaml/multiline/plain_double_quotes.yaml create mode 100644 libraries-data-io/src/test/resources/yaml/multiline/plain_single_quotes.yaml diff --git a/libraries-data-io/src/test/java/com/baeldung/libraries/snakeyaml/MultiLineStringsUnitTest.java b/libraries-data-io/src/test/java/com/baeldung/libraries/snakeyaml/MultiLineStringsUnitTest.java new file mode 100644 index 0000000000..836ac86339 --- /dev/null +++ b/libraries-data-io/src/test/java/com/baeldung/libraries/snakeyaml/MultiLineStringsUnitTest.java @@ -0,0 +1,90 @@ +package com.baeldung.libraries.snakeyaml; + +import org.junit.Before; +import org.junit.Test; +import org.yaml.snakeyaml.Yaml; + +import java.io.File; +import java.io.InputStream; +import java.util.Map; + +import static org.junit.Assert.assertEquals; + +public class MultiLineStringsUnitTest { + + private Yaml yaml; + + @Before + public void setup() { + yaml = new Yaml(); + } + + @Test + public void whenLiteral_ThenLineBreaksArePresent() { + String key = parseYamlKey("literal.yaml", "key"); + assertEquals("Line1\nLine2\nLine3", key); + } + + @Test + public void whenLiteral_ThenEndingBreaksAreReducedToOne() { + String key = parseYamlKey("literal2.yaml", "key"); + assertEquals("\n\nLine1\n\nLine2\n\nLine3\n", key); + } + + @Test + public void whenFolded_ThenLineBreaksAreReplaced() { + String key = parseYamlKey("folded.yaml", "key"); + assertEquals("Line1 Line2 Line3", key); + } + + @Test + public void whenFolded_ThenEmptyLinesAreReducedToOne() { + String key = parseYamlKey("folded2.yaml", "key"); + assertEquals("Line1 Line2\n\nLine3\n", key); + } + + @Test + public void whenLiteralKeep_ThenLastEmptyLinesArePresent() { + String key = parseYamlKey("literal_keep.yaml", "key"); + assertEquals("Line1\nLine2\nLine3\n\n", key); + } + + @Test + public void whenLiteralStrip_ThenLastEmptyLinesAreRemoved() { + String key = parseYamlKey("literal_strip.yaml", "key"); + assertEquals("Line1\nLine2\nLine3", key); + } + + @Test + public void whenFoldedKeep_ThenLastEmptyLinesArePresent() { + String key = parseYamlKey("folded_keep.yaml", "key"); + assertEquals("Line1 Line2 Line3\n\n\n", key); + } + + @Test + public void whenFoldedStrip_ThenLastEmptyLinesAreRemoved() { + String key = parseYamlKey("folded_strip.yaml", "key"); + assertEquals("Line1 Line2 Line3", key); + } + + @Test + public void whenDoubleQuotes_ThenExplicitBreaksArePreserved() { + String key = parseYamlKey("plain_double_quotes.yaml", "key"); + assertEquals("Line1\nLine2\nLine3", key); + } + + @Test + public void whenSingleQuotes_ThenExplicitBreaksAreIgnored() { + String key = parseYamlKey("plain_single_quotes.yaml", "key"); + assertEquals("Line1\\nLine2\nLine3", key); + } + + String parseYamlKey(String fileName, String key) { + InputStream inputStream = this.getClass() + .getClassLoader() + .getResourceAsStream("yaml" + File.separator + "multiline" + File.separator + fileName); + Map parsed = yaml.load(inputStream); + return parsed.get(key); + } + +} diff --git a/libraries-data-io/src/test/resources/yaml/multiline/folded.yaml b/libraries-data-io/src/test/resources/yaml/multiline/folded.yaml new file mode 100644 index 0000000000..c5fa743a08 --- /dev/null +++ b/libraries-data-io/src/test/resources/yaml/multiline/folded.yaml @@ -0,0 +1,4 @@ +key: > + Line1 + Line2 + Line3 \ No newline at end of file diff --git a/libraries-data-io/src/test/resources/yaml/multiline/folded2.yaml b/libraries-data-io/src/test/resources/yaml/multiline/folded2.yaml new file mode 100644 index 0000000000..735abf9b2f --- /dev/null +++ b/libraries-data-io/src/test/resources/yaml/multiline/folded2.yaml @@ -0,0 +1,8 @@ +key: > + Line1 + Line2 + + + Line3 + + diff --git a/libraries-data-io/src/test/resources/yaml/multiline/folded_keep.yaml b/libraries-data-io/src/test/resources/yaml/multiline/folded_keep.yaml new file mode 100644 index 0000000000..555291fd26 --- /dev/null +++ b/libraries-data-io/src/test/resources/yaml/multiline/folded_keep.yaml @@ -0,0 +1,6 @@ +key: >+ + Line1 + Line2 + Line3 + + diff --git a/libraries-data-io/src/test/resources/yaml/multiline/folded_strip.yaml b/libraries-data-io/src/test/resources/yaml/multiline/folded_strip.yaml new file mode 100644 index 0000000000..0a3a246dc2 --- /dev/null +++ b/libraries-data-io/src/test/resources/yaml/multiline/folded_strip.yaml @@ -0,0 +1,7 @@ +key: >- + Line1 + Line2 + Line3 + + + diff --git a/libraries-data-io/src/test/resources/yaml/multiline/literal.yaml b/libraries-data-io/src/test/resources/yaml/multiline/literal.yaml new file mode 100644 index 0000000000..7e02501a33 --- /dev/null +++ b/libraries-data-io/src/test/resources/yaml/multiline/literal.yaml @@ -0,0 +1,4 @@ +key: | + Line1 + Line2 + Line3 \ No newline at end of file diff --git a/libraries-data-io/src/test/resources/yaml/multiline/literal2.yaml b/libraries-data-io/src/test/resources/yaml/multiline/literal2.yaml new file mode 100644 index 0000000000..7c7fed0163 --- /dev/null +++ b/libraries-data-io/src/test/resources/yaml/multiline/literal2.yaml @@ -0,0 +1,10 @@ +key: | + + + Line1 + + Line2 + + Line3 + + diff --git a/libraries-data-io/src/test/resources/yaml/multiline/literal_keep.yaml b/libraries-data-io/src/test/resources/yaml/multiline/literal_keep.yaml new file mode 100644 index 0000000000..37f22684dd --- /dev/null +++ b/libraries-data-io/src/test/resources/yaml/multiline/literal_keep.yaml @@ -0,0 +1,5 @@ +key: |+ + Line1 + Line2 + Line3 + diff --git a/libraries-data-io/src/test/resources/yaml/multiline/literal_strip.yaml b/libraries-data-io/src/test/resources/yaml/multiline/literal_strip.yaml new file mode 100644 index 0000000000..0791e13d5d --- /dev/null +++ b/libraries-data-io/src/test/resources/yaml/multiline/literal_strip.yaml @@ -0,0 +1,5 @@ +key: |- + Line1 + Line2 + Line3 + diff --git a/libraries-data-io/src/test/resources/yaml/multiline/plain_double_quotes.yaml b/libraries-data-io/src/test/resources/yaml/multiline/plain_double_quotes.yaml new file mode 100644 index 0000000000..ccab040a27 --- /dev/null +++ b/libraries-data-io/src/test/resources/yaml/multiline/plain_double_quotes.yaml @@ -0,0 +1 @@ +key: "Line1\nLine2\nLine3" \ No newline at end of file diff --git a/libraries-data-io/src/test/resources/yaml/multiline/plain_single_quotes.yaml b/libraries-data-io/src/test/resources/yaml/multiline/plain_single_quotes.yaml new file mode 100644 index 0000000000..acbf35a462 --- /dev/null +++ b/libraries-data-io/src/test/resources/yaml/multiline/plain_single_quotes.yaml @@ -0,0 +1,3 @@ +key: 'Line1\nLine2 + + Line3' \ No newline at end of file From 7feb9bfb1ec7e9502d482fef57867439f831f6b4 Mon Sep 17 00:00:00 2001 From: crist Date: Mon, 10 Feb 2020 15:29:53 +0200 Subject: [PATCH 012/503] [BAEL-3750] deleted the yaml module --- pom.xml | 2 - yaml/README.md | 7 -- yaml/pom.xml | 29 ------ .../multiline/MultiLineStringsUnitTest.java | 90 ------------------- .../src/test/resources/multi-line/folded.yaml | 4 - .../test/resources/multi-line/folded2.yaml | 8 -- .../resources/multi-line/folded_keep.yaml | 6 -- .../resources/multi-line/folded_strip.yaml | 7 -- .../test/resources/multi-line/literal.yaml | 4 - .../test/resources/multi-line/literal2.yaml | 10 --- .../resources/multi-line/literal_keep.yaml | 5 -- .../resources/multi-line/literal_strip.yaml | 5 -- .../multi-line/plain_double_quotes.yaml | 1 - .../multi-line/plain_single_quotes.yaml | 3 - 14 files changed, 181 deletions(-) delete mode 100644 yaml/README.md delete mode 100644 yaml/pom.xml delete mode 100644 yaml/src/test/java/com/baeldung/multiline/MultiLineStringsUnitTest.java delete mode 100644 yaml/src/test/resources/multi-line/folded.yaml delete mode 100644 yaml/src/test/resources/multi-line/folded2.yaml delete mode 100644 yaml/src/test/resources/multi-line/folded_keep.yaml delete mode 100644 yaml/src/test/resources/multi-line/folded_strip.yaml delete mode 100644 yaml/src/test/resources/multi-line/literal.yaml delete mode 100644 yaml/src/test/resources/multi-line/literal2.yaml delete mode 100644 yaml/src/test/resources/multi-line/literal_keep.yaml delete mode 100644 yaml/src/test/resources/multi-line/literal_strip.yaml delete mode 100644 yaml/src/test/resources/multi-line/plain_double_quotes.yaml delete mode 100644 yaml/src/test/resources/multi-line/plain_single_quotes.yaml diff --git a/pom.xml b/pom.xml index b0d3f2297d..0c9896cf35 100644 --- a/pom.xml +++ b/pom.xml @@ -782,7 +782,6 @@ wildfly xml xstream - yaml @@ -1307,7 +1306,6 @@ wildfly xml xstream - yaml diff --git a/yaml/README.md b/yaml/README.md deleted file mode 100644 index ebf403eb57..0000000000 --- a/yaml/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## YAML - -This module contains articles about YAML - -### Relevant articles - - diff --git a/yaml/pom.xml b/yaml/pom.xml deleted file mode 100644 index c801505c6a..0000000000 --- a/yaml/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - 4.0.0 - yaml - 1.0-SNAPSHOT - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - - - - - org.yaml - snakeyaml - 1.21 - - - - - 1.8 - 1.21 - - - \ No newline at end of file diff --git a/yaml/src/test/java/com/baeldung/multiline/MultiLineStringsUnitTest.java b/yaml/src/test/java/com/baeldung/multiline/MultiLineStringsUnitTest.java deleted file mode 100644 index a99de63a47..0000000000 --- a/yaml/src/test/java/com/baeldung/multiline/MultiLineStringsUnitTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.baeldung.multiline; - -import org.junit.Before; -import org.junit.Test; -import org.yaml.snakeyaml.Yaml; - -import java.io.File; -import java.io.InputStream; -import java.util.Map; - -import static org.junit.Assert.assertEquals; - -public class MultiLineStringsUnitTest { - - private Yaml yaml; - - @Before - public void setup() { - yaml = new Yaml(); - } - - @Test - public void whenLiteral_ThenLineBreaksArePresent() { - String key = parseYamlKey("literal.yaml", "key"); - assertEquals("Line1\nLine2\nLine3", key); - } - - @Test - public void whenLiteral_ThenEndingBreaksAreReducedToOne() { - String key = parseYamlKey("literal2.yaml", "key"); - assertEquals("\n\nLine1\n\nLine2\n\nLine3\n", key); - } - - @Test - public void whenFolded_ThenLineBreaksAreReplaced() { - String key = parseYamlKey("folded.yaml", "key"); - assertEquals("Line1 Line2 Line3", key); - } - - @Test - public void whenFolded_ThenEmptyLinesAreReducedToOne() { - String key = parseYamlKey("folded2.yaml", "key"); - assertEquals("Line1 Line2\n\nLine3\n", key); - } - - @Test - public void whenLiteralKeep_ThenLastEmptyLinesArePresent() { - String key = parseYamlKey("literal_keep.yaml", "key"); - assertEquals("Line1\nLine2\nLine3\n\n", key); - } - - @Test - public void whenLiteralStrip_ThenLastEmptyLinesAreRemoved() { - String key = parseYamlKey("literal_strip.yaml", "key"); - assertEquals("Line1\nLine2\nLine3", key); - } - - @Test - public void whenFoldedKeep_ThenLastEmptyLinesArePresent() { - String key = parseYamlKey("folded_keep.yaml", "key"); - assertEquals("Line1 Line2 Line3\n\n\n", key); - } - - @Test - public void whenFoldedStrip_ThenLastEmptyLinesAreRemoved() { - String key = parseYamlKey("folded_strip.yaml", "key"); - assertEquals("Line1 Line2 Line3", key); - } - - @Test - public void whenDoubleQuotes_ThenExplicitBreaksArePreserved() { - String key = parseYamlKey("plain_double_quotes.yaml", "key"); - assertEquals("Line1\nLine2\nLine3", key); - } - - @Test - public void whenSingleQuotes_ThenExplicitBreaksAreIgnored() { - String key = parseYamlKey("plain_single_quotes.yaml", "key"); - assertEquals("Line1\\nLine2\nLine3", key); - } - - String parseYamlKey(String fileName, String key) { - InputStream inputStream = this.getClass() - .getClassLoader() - .getResourceAsStream("multi-line" + File.separator + fileName); - Map parsed = yaml.load(inputStream); - return parsed.get(key); - } - -} diff --git a/yaml/src/test/resources/multi-line/folded.yaml b/yaml/src/test/resources/multi-line/folded.yaml deleted file mode 100644 index c5fa743a08..0000000000 --- a/yaml/src/test/resources/multi-line/folded.yaml +++ /dev/null @@ -1,4 +0,0 @@ -key: > - Line1 - Line2 - Line3 \ No newline at end of file diff --git a/yaml/src/test/resources/multi-line/folded2.yaml b/yaml/src/test/resources/multi-line/folded2.yaml deleted file mode 100644 index 735abf9b2f..0000000000 --- a/yaml/src/test/resources/multi-line/folded2.yaml +++ /dev/null @@ -1,8 +0,0 @@ -key: > - Line1 - Line2 - - - Line3 - - diff --git a/yaml/src/test/resources/multi-line/folded_keep.yaml b/yaml/src/test/resources/multi-line/folded_keep.yaml deleted file mode 100644 index 555291fd26..0000000000 --- a/yaml/src/test/resources/multi-line/folded_keep.yaml +++ /dev/null @@ -1,6 +0,0 @@ -key: >+ - Line1 - Line2 - Line3 - - diff --git a/yaml/src/test/resources/multi-line/folded_strip.yaml b/yaml/src/test/resources/multi-line/folded_strip.yaml deleted file mode 100644 index 0a3a246dc2..0000000000 --- a/yaml/src/test/resources/multi-line/folded_strip.yaml +++ /dev/null @@ -1,7 +0,0 @@ -key: >- - Line1 - Line2 - Line3 - - - diff --git a/yaml/src/test/resources/multi-line/literal.yaml b/yaml/src/test/resources/multi-line/literal.yaml deleted file mode 100644 index 7e02501a33..0000000000 --- a/yaml/src/test/resources/multi-line/literal.yaml +++ /dev/null @@ -1,4 +0,0 @@ -key: | - Line1 - Line2 - Line3 \ No newline at end of file diff --git a/yaml/src/test/resources/multi-line/literal2.yaml b/yaml/src/test/resources/multi-line/literal2.yaml deleted file mode 100644 index 7c7fed0163..0000000000 --- a/yaml/src/test/resources/multi-line/literal2.yaml +++ /dev/null @@ -1,10 +0,0 @@ -key: | - - - Line1 - - Line2 - - Line3 - - diff --git a/yaml/src/test/resources/multi-line/literal_keep.yaml b/yaml/src/test/resources/multi-line/literal_keep.yaml deleted file mode 100644 index 37f22684dd..0000000000 --- a/yaml/src/test/resources/multi-line/literal_keep.yaml +++ /dev/null @@ -1,5 +0,0 @@ -key: |+ - Line1 - Line2 - Line3 - diff --git a/yaml/src/test/resources/multi-line/literal_strip.yaml b/yaml/src/test/resources/multi-line/literal_strip.yaml deleted file mode 100644 index 0791e13d5d..0000000000 --- a/yaml/src/test/resources/multi-line/literal_strip.yaml +++ /dev/null @@ -1,5 +0,0 @@ -key: |- - Line1 - Line2 - Line3 - diff --git a/yaml/src/test/resources/multi-line/plain_double_quotes.yaml b/yaml/src/test/resources/multi-line/plain_double_quotes.yaml deleted file mode 100644 index ccab040a27..0000000000 --- a/yaml/src/test/resources/multi-line/plain_double_quotes.yaml +++ /dev/null @@ -1 +0,0 @@ -key: "Line1\nLine2\nLine3" \ No newline at end of file diff --git a/yaml/src/test/resources/multi-line/plain_single_quotes.yaml b/yaml/src/test/resources/multi-line/plain_single_quotes.yaml deleted file mode 100644 index acbf35a462..0000000000 --- a/yaml/src/test/resources/multi-line/plain_single_quotes.yaml +++ /dev/null @@ -1,3 +0,0 @@ -key: 'Line1\nLine2 - - Line3' \ No newline at end of file From 91da58e880b411d0a99000d555359c41d5af59f2 Mon Sep 17 00:00:00 2001 From: ajay74984 <51405689+ajay74984@users.noreply.github.com> Date: Wed, 12 Feb 2020 16:06:47 +0100 Subject: [PATCH 013/503] initial commit of Hexagonal Architecture --- spring-boot-modules/pom.xml | 1 + .../spring-boot-hexagonal/README.md | 4 + .../spring-boot-hexagonal/pom.xml | 76 +++++++++++++++++++ .../main/java/com/baeldung/Application.java | 13 ++++ .../adapter/DocumentRepositoryImpl.java | 24 ++++++ .../baeldung/adapter/DocumentRestAdapter.java | 24 ++++++ .../java/com/baeldung/domain/Document.java | 13 ++++ .../java/com/baeldung/port/DocumentRepo.java | 11 +++ .../com/baeldung/port/DocumentService.java | 11 +++ .../port/impl/DocumentServiceImpl.java | 24 ++++++ .../src/main/resources/application.properties | 1 + .../java/com/baeldung/ApplicationTests.java | 16 ++++ 12 files changed, 218 insertions(+) create mode 100644 spring-boot-modules/spring-boot-hexagonal/README.md create mode 100644 spring-boot-modules/spring-boot-hexagonal/pom.xml create mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java create mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java create mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java create mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java create mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentRepo.java create mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentService.java create mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/impl/DocumentServiceImpl.java create mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/resources/application.properties create mode 100644 spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationTests.java diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 234c52f638..3a503bf837 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -49,6 +49,7 @@ spring-boot-springdoc spring-boot-testing spring-boot-vue + spring-boot-hexagonal diff --git a/spring-boot-modules/spring-boot-hexagonal/README.md b/spring-boot-modules/spring-boot-hexagonal/README.md new file mode 100644 index 0000000000..44728b185e --- /dev/null +++ b/spring-boot-modules/spring-boot-hexagonal/README.md @@ -0,0 +1,4 @@ +## HEXAGONAL Architecture + +This module contains articles about Hexagonal Architecture implemented via Spring Boot. + diff --git a/spring-boot-modules/spring-boot-hexagonal/pom.xml b/spring-boot-modules/spring-boot-hexagonal/pom.xml new file mode 100644 index 0000000000..4d6109d24f --- /dev/null +++ b/spring-boot-modules/spring-boot-hexagonal/pom.xml @@ -0,0 +1,76 @@ + + + 4.0.0 + spring-boot-hexagonal + spring-boot-hexagonal + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-test + + + + org.projectlombok + lombok + 1.18.12 + + + + + + spring-boot-hexagonal + + + src/main/resources + true + + + + + org.springframework.boot + spring-boot-maven-plugin + + exec + + + + org.apache.maven.plugins + maven-assembly-plugin + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + + + + UTF-8 + + + diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java new file mode 100644 index 0000000000..17be2b0d79 --- /dev/null +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java @@ -0,0 +1,13 @@ +package com.ajay.documentservice; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class DocumentserviceApplication { + + public static void main(String[] args) { + SpringApplication.run(DocumentserviceApplication.class, args); + } + +} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java new file mode 100644 index 0000000000..e22ccb5cbf --- /dev/null +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java @@ -0,0 +1,24 @@ +package com.ajay.documentservice.adapter; + +import com.ajay.documentservice.domain.Document; +import com.ajay.documentservice.port.DocumentRepo; +import org.springframework.stereotype.Repository; + +import java.util.HashMap; +import java.util.Map; + +@Repository +public class DocumentRepositoryImpl implements DocumentRepo { + + private Map documentMap = new HashMap<>(); + + @Override + public void storeDocument(Document document) { + documentMap.put(document.getId(), document); + } + + @Override + public Document findDocumentById(String id) { + return documentMap.get(id); + } +} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java new file mode 100644 index 0000000000..2a3cffb0e8 --- /dev/null +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java @@ -0,0 +1,24 @@ +package com.ajay.documentservice.adapter; + +import com.ajay.documentservice.domain.Document; +import com.ajay.documentservice.port.DocumentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/doc") +public class DocumentRestAdapter { + @Autowired + private DocumentService documentService; + + @PostMapping + public void createDocument(@RequestBody Document document) { + documentService.createDocument(document); + } + + @GetMapping("/{id}") + public Document findById(@PathVariable String id) { + return documentService.findById(id); + } + +} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java new file mode 100644 index 0000000000..14ab4900e2 --- /dev/null +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java @@ -0,0 +1,13 @@ +package com.ajay.documentservice.domain; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +@Data +@AllArgsConstructor +@Builder +public class Document { + private String id; + private String data; +} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentRepo.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentRepo.java new file mode 100644 index 0000000000..2e18dd92ee --- /dev/null +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentRepo.java @@ -0,0 +1,11 @@ +package com.ajay.documentservice.port; + + +import com.ajay.documentservice.domain.Document; + +public interface DocumentRepo { + void storeDocument(Document document); + + Document findDocumentById(String id); +} + diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentService.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentService.java new file mode 100644 index 0000000000..6ed9edaf2c --- /dev/null +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentService.java @@ -0,0 +1,11 @@ +package com.ajay.documentservice.port; + +import com.ajay.documentservice.domain.Document; + +public interface DocumentService { + + void createDocument(Document document); + + Document findById(String id); + +} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/impl/DocumentServiceImpl.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/impl/DocumentServiceImpl.java new file mode 100644 index 0000000000..2549ca834c --- /dev/null +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/impl/DocumentServiceImpl.java @@ -0,0 +1,24 @@ +package com.ajay.documentservice.port.impl; + +import com.ajay.documentservice.domain.Document; +import com.ajay.documentservice.port.DocumentRepo; +import com.ajay.documentservice.port.DocumentService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class DocumentServiceImpl implements DocumentService { + + @Autowired + private DocumentRepo documentRepo; + + @Override + public void createDocument(Document document) { + documentRepo.storeDocument(document); + } + + @Override + public Document findById(String id) { + return documentRepo.findDocumentById(id); + } +} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/resources/application.properties b/spring-boot-modules/spring-boot-hexagonal/src/main/resources/application.properties new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationTests.java b/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationTests.java new file mode 100644 index 0000000000..ce3b754df3 --- /dev/null +++ b/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationTests.java @@ -0,0 +1,16 @@ +package com.ajay.documentservice.documentservice; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@SpringBootTest +@RunWith(SpringRunner.class) +class ApplicationTests { + + @Test + public void contextLoads() { + } + +} From 563b6b7a89896bc643a22d227b4318529360a67a Mon Sep 17 00:00:00 2001 From: ajay74984 <51405689+ajay74984@users.noreply.github.com> Date: Wed, 12 Feb 2020 16:10:36 +0100 Subject: [PATCH 014/503] updated package name --- .../src/main/java/com/baeldung/Application.java | 2 +- .../main/java/com/baeldung/adapter/DocumentRepositoryImpl.java | 2 +- .../src/main/java/com/baeldung/adapter/DocumentRestAdapter.java | 2 +- .../src/main/java/com/baeldung/domain/Document.java | 2 +- .../src/main/java/com/baeldung/port/DocumentRepo.java | 2 +- .../src/main/java/com/baeldung/port/DocumentService.java | 2 +- .../main/java/com/baeldung/port/impl/DocumentServiceImpl.java | 2 +- .../src/test/java/com/baeldung/ApplicationTests.java | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java index 17be2b0d79..5e4bcc0435 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java @@ -1,4 +1,4 @@ -package com.ajay.documentservice; +package com.baeldung; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java index e22ccb5cbf..eabdaa63b8 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java @@ -1,4 +1,4 @@ -package com.ajay.documentservice.adapter; +package com.baeldung.adapter; import com.ajay.documentservice.domain.Document; import com.ajay.documentservice.port.DocumentRepo; diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java index 2a3cffb0e8..d8c89d5c6e 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java @@ -1,4 +1,4 @@ -package com.ajay.documentservice.adapter; +package com.baeldung.adapter; import com.ajay.documentservice.domain.Document; import com.ajay.documentservice.port.DocumentService; diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java index 14ab4900e2..77c1079cdc 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java @@ -1,4 +1,4 @@ -package com.ajay.documentservice.domain; +package com.baeldung.domain; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentRepo.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentRepo.java index 2e18dd92ee..d5591f9aa4 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentRepo.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentRepo.java @@ -1,4 +1,4 @@ -package com.ajay.documentservice.port; +package com.baeldung.port; import com.ajay.documentservice.domain.Document; diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentService.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentService.java index 6ed9edaf2c..5df49efa88 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentService.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentService.java @@ -1,4 +1,4 @@ -package com.ajay.documentservice.port; +package com.baeldung.port; import com.ajay.documentservice.domain.Document; diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/impl/DocumentServiceImpl.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/impl/DocumentServiceImpl.java index 2549ca834c..a2942b2d59 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/impl/DocumentServiceImpl.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/impl/DocumentServiceImpl.java @@ -1,4 +1,4 @@ -package com.ajay.documentservice.port.impl; +package com.baeldung.port.impl; import com.ajay.documentservice.domain.Document; import com.ajay.documentservice.port.DocumentRepo; diff --git a/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationTests.java b/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationTests.java index ce3b754df3..f531a9fba0 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationTests.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationTests.java @@ -1,4 +1,4 @@ -package com.ajay.documentservice.documentservice; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; From 7feb7bf9d8d22dfc015b969eda13e5c76e3e6426 Mon Sep 17 00:00:00 2001 From: ajay74984 <51405689+ajay74984@users.noreply.github.com> Date: Wed, 12 Feb 2020 17:15:44 +0100 Subject: [PATCH 015/503] renamed packages. --- .../spring-boot-hexagonal/pom.xml | 6 ----- .../main/java/com/baeldung/Application.java | 4 ++-- .../adapter/DocumentRepositoryImpl.java | 5 +++-- .../baeldung/adapter/DocumentRestAdapter.java | 6 +++-- .../java/com/baeldung/domain/Document.java | 22 +++++++++++++------ .../java/com/baeldung/port/DocumentRepo.java | 3 +-- .../com/baeldung/port/DocumentService.java | 2 +- .../port/impl/DocumentServiceImpl.java | 7 +++--- ...ionTests.java => ApplicationUnitTest.java} | 2 +- 9 files changed, 31 insertions(+), 26 deletions(-) rename spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/{ApplicationTests.java => ApplicationUnitTest.java} (91%) diff --git a/spring-boot-modules/spring-boot-hexagonal/pom.xml b/spring-boot-modules/spring-boot-hexagonal/pom.xml index 4d6109d24f..54d61fa806 100644 --- a/spring-boot-modules/spring-boot-hexagonal/pom.xml +++ b/spring-boot-modules/spring-boot-hexagonal/pom.xml @@ -24,12 +24,6 @@ spring-boot-starter-test - - org.projectlombok - lombok - 1.18.12 - - diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java index 5e4bcc0435..a898f9cf05 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java @@ -4,10 +4,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class DocumentserviceApplication { +public class Application { public static void main(String[] args) { - SpringApplication.run(DocumentserviceApplication.class, args); + SpringApplication.run(Application.class, args); } } diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java index eabdaa63b8..1248133665 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java @@ -1,9 +1,10 @@ package com.baeldung.adapter; -import com.ajay.documentservice.domain.Document; -import com.ajay.documentservice.port.DocumentRepo; import org.springframework.stereotype.Repository; +import com.baeldung.domain.Document; +import com.baeldung.port.DocumentRepo; + import java.util.HashMap; import java.util.Map; diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java index d8c89d5c6e..e7fa5d0b42 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java @@ -1,10 +1,12 @@ package com.baeldung.adapter; -import com.ajay.documentservice.domain.Document; -import com.ajay.documentservice.port.DocumentService; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import com.baeldung.domain.Document; +import com.baeldung.port.DocumentService; + @RestController @RequestMapping("/doc") public class DocumentRestAdapter { diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java index 77c1079cdc..58381d536d 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java @@ -1,13 +1,21 @@ package com.baeldung.domain; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; - -@Data -@AllArgsConstructor -@Builder public class Document { private String id; private String data; + + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getData() { + return data; + } + public void setData(String data) { + this.data = data; + } + + } diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentRepo.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentRepo.java index d5591f9aa4..96dba3d954 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentRepo.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentRepo.java @@ -1,7 +1,6 @@ package com.baeldung.port; - -import com.ajay.documentservice.domain.Document; +import com.baeldung.domain.Document; public interface DocumentRepo { void storeDocument(Document document); diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentService.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentService.java index 5df49efa88..5d5bfb2035 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentService.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentService.java @@ -1,6 +1,6 @@ package com.baeldung.port; -import com.ajay.documentservice.domain.Document; +import com.baeldung.domain.Document; public interface DocumentService { diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/impl/DocumentServiceImpl.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/impl/DocumentServiceImpl.java index a2942b2d59..1b50e1efe2 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/impl/DocumentServiceImpl.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/impl/DocumentServiceImpl.java @@ -1,11 +1,12 @@ package com.baeldung.port.impl; -import com.ajay.documentservice.domain.Document; -import com.ajay.documentservice.port.DocumentRepo; -import com.ajay.documentservice.port.DocumentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.baeldung.domain.Document; +import com.baeldung.port.DocumentRepo; +import com.baeldung.port.DocumentService; + @Service public class DocumentServiceImpl implements DocumentService { diff --git a/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationTests.java b/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationUnitTest.java similarity index 91% rename from spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationTests.java rename to spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationUnitTest.java index f531a9fba0..f7592c0cc8 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationTests.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationUnitTest.java @@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringRunner; @SpringBootTest @RunWith(SpringRunner.class) -class ApplicationTests { +class ApplicationUnitTest { @Test public void contextLoads() { From d868eda952f0698e0568dfbab26134a06f47c001 Mon Sep 17 00:00:00 2001 From: ajay74984 <51405689+ajay74984@users.noreply.github.com> Date: Sat, 15 Feb 2020 09:32:50 +0100 Subject: [PATCH 016/503] reformatted as per standard formatter and incorporated review comments. --- .../spring-boot-hexagonal/pom.xml | 102 ++++++++---------- .../main/java/com/baeldung/Application.java | 10 +- .../adapter/DocumentRepositoryImpl.java | 26 ++--- .../baeldung/adapter/DocumentRestAdapter.java | 29 +++-- .../java/com/baeldung/domain/Document.java | 36 ++++--- .../baeldung/domain/port/DocumentRepo.java | 9 ++ .../baeldung/domain/port/DocumentService.java | 11 ++ .../domain/port/impl/DocumentServiceImpl.java | 25 +++++ .../java/com/baeldung/port/DocumentRepo.java | 10 -- .../com/baeldung/port/DocumentService.java | 11 -- .../port/impl/DocumentServiceImpl.java | 25 ----- .../com/baeldung/ApplicationUnitTest.java | 10 +- 12 files changed, 143 insertions(+), 161 deletions(-) create mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/DocumentRepo.java create mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/DocumentService.java create mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/impl/DocumentServiceImpl.java delete mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentRepo.java delete mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentService.java delete mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/impl/DocumentServiceImpl.java diff --git a/spring-boot-modules/spring-boot-hexagonal/pom.xml b/spring-boot-modules/spring-boot-hexagonal/pom.xml index 54d61fa806..c4ff36c2cf 100644 --- a/spring-boot-modules/spring-boot-hexagonal/pom.xml +++ b/spring-boot-modules/spring-boot-hexagonal/pom.xml @@ -1,70 +1,52 @@ - 4.0.0 - spring-boot-hexagonal - spring-boot-hexagonal + 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-hexagonal + spring-boot-hexagonal - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 - + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + - - - org.springframework.boot - spring-boot-starter-web - + + + org.springframework.boot + spring-boot-starter-web + - - org.springframework.boot - spring-boot-starter-test - + + org.springframework.boot + spring-boot-starter-test + - + - - spring-boot-hexagonal - - - src/main/resources - true - - - - - org.springframework.boot - spring-boot-maven-plugin - - exec - - - - org.apache.maven.plugins - maven-assembly-plugin - - - jar-with-dependencies - - - - - make-assembly - package - - single - - - - - - + + spring-boot-hexagonal + + + src/main/resources + true + + + + + org.springframework.boot + spring-boot-maven-plugin + + exec + + + + - - UTF-8 - + + UTF-8 + diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java index a898f9cf05..37dbe7dab8 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java @@ -5,9 +5,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + } diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java index 1248133665..32414442ef 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java @@ -3,23 +3,23 @@ package com.baeldung.adapter; import org.springframework.stereotype.Repository; import com.baeldung.domain.Document; -import com.baeldung.port.DocumentRepo; +import com.baeldung.domain.port.DocumentRepo; import java.util.HashMap; import java.util.Map; @Repository public class DocumentRepositoryImpl implements DocumentRepo { - - private Map documentMap = new HashMap<>(); - - @Override - public void storeDocument(Document document) { - documentMap.put(document.getId(), document); - } - - @Override - public Document findDocumentById(String id) { - return documentMap.get(id); - } + + private Map documentMap = new HashMap<>(); + + @Override + public void storeDocument(Document document) { + documentMap.put(document.getId(), document); + } + + @Override + public Document findDocumentById(String id) { + return documentMap.get(id); + } } diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java index e7fa5d0b42..985a5257c0 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java @@ -1,26 +1,25 @@ package com.baeldung.adapter; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import com.baeldung.domain.Document; -import com.baeldung.port.DocumentService; +import com.baeldung.domain.port.DocumentService; @RestController @RequestMapping("/doc") public class DocumentRestAdapter { - @Autowired - private DocumentService documentService; - - @PostMapping - public void createDocument(@RequestBody Document document) { - documentService.createDocument(document); - } - - @GetMapping("/{id}") - public Document findById(@PathVariable String id) { - return documentService.findById(id); - } - + @Autowired + private DocumentService documentService; + + @PostMapping + public void createDocument(@RequestBody Document document) { + documentService.createDocument(document); + } + + @GetMapping("/{id}") + public Document findById(@PathVariable String id) { + return documentService.findById(id); + } + } diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java index 58381d536d..24d0a95071 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java @@ -1,21 +1,23 @@ package com.baeldung.domain; public class Document { - private String id; - private String data; - - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - public String getData() { - return data; - } - public void setData(String data) { - this.data = data; - } - - + private String id; + private String data; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } + } diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/DocumentRepo.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/DocumentRepo.java new file mode 100644 index 0000000000..001e3251e4 --- /dev/null +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/DocumentRepo.java @@ -0,0 +1,9 @@ +package com.baeldung.domain.port; + +import com.baeldung.domain.Document; + +public interface DocumentRepo { + void storeDocument(Document document); + + Document findDocumentById(String id); +} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/DocumentService.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/DocumentService.java new file mode 100644 index 0000000000..009c26c01f --- /dev/null +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/DocumentService.java @@ -0,0 +1,11 @@ +package com.baeldung.domain.port; + +import com.baeldung.domain.Document; + +public interface DocumentService { + + void createDocument(Document document); + + Document findById(String id); + +} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/impl/DocumentServiceImpl.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/impl/DocumentServiceImpl.java new file mode 100644 index 0000000000..f5c351406e --- /dev/null +++ b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/impl/DocumentServiceImpl.java @@ -0,0 +1,25 @@ +package com.baeldung.domain.port.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.baeldung.domain.Document; +import com.baeldung.domain.port.DocumentRepo; +import com.baeldung.domain.port.DocumentService; + +@Service +public class DocumentServiceImpl implements DocumentService { + + @Autowired + private DocumentRepo documentRepo; + + @Override + public void createDocument(Document document) { + documentRepo.storeDocument(document); + } + + @Override + public Document findById(String id) { + return documentRepo.findDocumentById(id); + } +} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentRepo.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentRepo.java deleted file mode 100644 index 96dba3d954..0000000000 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentRepo.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.baeldung.port; - -import com.baeldung.domain.Document; - -public interface DocumentRepo { - void storeDocument(Document document); - - Document findDocumentById(String id); -} - diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentService.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentService.java deleted file mode 100644 index 5d5bfb2035..0000000000 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/DocumentService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.port; - -import com.baeldung.domain.Document; - -public interface DocumentService { - - void createDocument(Document document); - - Document findById(String id); - -} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/impl/DocumentServiceImpl.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/impl/DocumentServiceImpl.java deleted file mode 100644 index 1b50e1efe2..0000000000 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/port/impl/DocumentServiceImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.port.impl; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.baeldung.domain.Document; -import com.baeldung.port.DocumentRepo; -import com.baeldung.port.DocumentService; - -@Service -public class DocumentServiceImpl implements DocumentService { - - @Autowired - private DocumentRepo documentRepo; - - @Override - public void createDocument(Document document) { - documentRepo.storeDocument(document); - } - - @Override - public Document findById(String id) { - return documentRepo.findDocumentById(id); - } -} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationUnitTest.java b/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationUnitTest.java index f7592c0cc8..2ce9b1cf24 100644 --- a/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationUnitTest.java +++ b/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationUnitTest.java @@ -8,9 +8,9 @@ import org.springframework.test.context.junit4.SpringRunner; @SpringBootTest @RunWith(SpringRunner.class) class ApplicationUnitTest { - - @Test - public void contextLoads() { - } - + + @Test + public void contextLoads() { + } + } From 523ad7f7767fa6f17f7e468e19ec78e7e5860518 Mon Sep 17 00:00:00 2001 From: ajay74984 <51405689+ajay74984@users.noreply.github.com> Date: Sat, 7 Mar 2020 15:21:12 +0100 Subject: [PATCH 017/503] java abstract number class --- .../AbstractNumberUnitTest.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 java-numbers-3/src/test/java/com/baeldung/abstractnumber/AbstractNumberUnitTest.java diff --git a/java-numbers-3/src/test/java/com/baeldung/abstractnumber/AbstractNumberUnitTest.java b/java-numbers-3/src/test/java/com/baeldung/abstractnumber/AbstractNumberUnitTest.java new file mode 100644 index 0000000000..521f2d37a6 --- /dev/null +++ b/java-numbers-3/src/test/java/com/baeldung/abstractnumber/AbstractNumberUnitTest.java @@ -0,0 +1,52 @@ +package com.baeldung.abstractnumber; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +public class AbstractNumberUnitTest { + + private final static double DOUBLE_VALUE = 9999.999; + private final static float FLOAT_VALUE = 101.99F; + private final static long LONG_VALUE = 1000L; + private final static int INTEGER_VALUE = 100; + private final static short SHORT_VALUE = 127; + private final static byte BYTE_VALUE = 120; + + @Test + public void givenDoubleValue_whenShortValueUsed_thenShortValueReturned() { + Double doubleValue = Double.valueOf(DOUBLE_VALUE); + assertEquals(9999, doubleValue.shortValue()); + } + + @Test + public void givenFloatValue_whenByteValueUsed_thenByteValueReturned() { + Float floatValue = Float.valueOf(FLOAT_VALUE); + assertEquals(101, floatValue.byteValue()); + } + + @Test + public void givenLongValue_whenInitValueUsed_thenInitValueReturned() { + Long longValue = Long.valueOf(LONG_VALUE); + assertEquals(1000, longValue.intValue()); + } + + @Test + public void givenIntegerValue_whenLongValueUsed_thenLongValueReturned() { + Integer integerValue = Integer.valueOf(INTEGER_VALUE); + assertEquals(100, integerValue.longValue()); + } + + @Test + public void givenShortValue_whenFloatValueUsed_thenFloatValueReturned() { + Short shortValue = Short.valueOf(SHORT_VALUE); + assertEquals(127.0F, shortValue.floatValue(), 0); + } + + @Test + public void givenByteValue_whenDoubleValueUsed_thenDoubleValueReturned() { + Byte byteValue = Byte.valueOf(BYTE_VALUE); + assertEquals(120.0, byteValue.doubleValue(), 0); + } + +} From aab469525e014c4a9916bffad20c52dbf0922bc3 Mon Sep 17 00:00:00 2001 From: kkaravitis Date: Sun, 8 Mar 2020 19:58:47 +0200 Subject: [PATCH 018/503] kkaravitis@gmail.com hexagonal architecture in java --- .../hexagonal-architecture-example/pom.xml | 34 ++++++++++++++ .../adapters/inbound/CommandLineAdapter.java | 46 +++++++++++++++++++ .../adapters/outbound/CocktailRepository.java | 23 ++++++++++ .../example/application/domain/Cocktail.java | 21 +++++++++ .../application/ports/in/AddCocktailPort.java | 24 ++++++++++ .../ports/in/GetCocktailsPort.java | 9 ++++ .../service/AddCocktailService.java | 19 ++++++++ .../service/GetCocktailsService.java | 20 ++++++++ .../infrastructure/CocktailsMenuApp.java | 43 +++++++++++++++++ .../application/AddCocktailUnitTest.java | 42 +++++++++++++++++ .../application/GetCocktailsUnitTest.java | 41 +++++++++++++++++ patterns/pom.xml | 1 + 12 files changed, 323 insertions(+) create mode 100644 patterns/hexagonal-architecture-example/pom.xml create mode 100644 patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/adapters/inbound/CommandLineAdapter.java create mode 100644 patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/adapters/outbound/CocktailRepository.java create mode 100644 patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/domain/Cocktail.java create mode 100644 patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/ports/in/AddCocktailPort.java create mode 100644 patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/ports/in/GetCocktailsPort.java create mode 100644 patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/service/AddCocktailService.java create mode 100644 patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/service/GetCocktailsService.java create mode 100644 patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/infrastructure/CocktailsMenuApp.java create mode 100644 patterns/hexagonal-architecture-example/src/test/java/com/baeldung/hexagonal/architecture/example/application/AddCocktailUnitTest.java create mode 100644 patterns/hexagonal-architecture-example/src/test/java/com/baeldung/hexagonal/architecture/example/application/GetCocktailsUnitTest.java diff --git a/patterns/hexagonal-architecture-example/pom.xml b/patterns/hexagonal-architecture-example/pom.xml new file mode 100644 index 0000000000..e5439bf8f7 --- /dev/null +++ b/patterns/hexagonal-architecture-example/pom.xml @@ -0,0 +1,34 @@ + + 4.0.0 + hexagonal-architecture-example + 1.0 + jar + + com.baeldung + patterns + 1.0.0-SNAPSHOT + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + + true + lib/ + com.baeldung.hexagonal.architecture.example.infrastructure.CocktailsMenuApp + + + + + + + + \ No newline at end of file diff --git a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/adapters/inbound/CommandLineAdapter.java b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/adapters/inbound/CommandLineAdapter.java new file mode 100644 index 0000000000..4f85639009 --- /dev/null +++ b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/adapters/inbound/CommandLineAdapter.java @@ -0,0 +1,46 @@ +package com.baeldung.hexagonal.architecture.example.adapters.inbound; + +import java.util.List; +import java.util.Scanner; + +import com.baeldung.hexagonal.architecture.example.application.domain.Cocktail; +import com.baeldung.hexagonal.architecture.example.application.ports.in.AddCocktailPort; +import com.baeldung.hexagonal.architecture.example.application.ports.in.AddCocktailPort.AddCocktailCommand; +import com.baeldung.hexagonal.architecture.example.application.ports.in.GetCocktailsPort; + +public class CommandLineAdapter { + private AddCocktailPort addCocktailPort; + private GetCocktailsPort listCocktailsPort; + private Scanner scanner; + + public CommandLineAdapter(Scanner scanner, AddCocktailPort addCocktailPort, GetCocktailsPort listCocktailsPort) { + this.addCocktailPort = addCocktailPort; + this.listCocktailsPort = listCocktailsPort; + this.scanner = scanner; + } + + public void addCocktail() { + try { + System.out.println("Enter the name of the cocktail"); + scanner.nextLine(); + String name = scanner.nextLine(); + System.out.println("Enter the price of the cocktail"); + double price = scanner.nextDouble(); + scanner.nextLine(); + AddCocktailCommand command = new AddCocktailCommand(name, price); + addCocktailPort.addCocktail(command); + } catch (Exception exception) { + System.out.println("Error during adding a new Cocktail"); + } + } + + public void listCocktails() { + List cocktailList = listCocktailsPort.getCocktails(); + System.out.println("Cocktails menu: \n"); + cocktailList.stream() + .forEach(cocktail -> { + System.out.println(cocktail.getName() + "\n" + + "price: " + cocktail.getPrice() + " $ " + "\n"); + }); + } +} diff --git a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/adapters/outbound/CocktailRepository.java b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/adapters/outbound/CocktailRepository.java new file mode 100644 index 0000000000..8b8e4d1d54 --- /dev/null +++ b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/adapters/outbound/CocktailRepository.java @@ -0,0 +1,23 @@ +package com.baeldung.hexagonal.architecture.example.adapters.outbound; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.baeldung.hexagonal.architecture.example.application.domain.Cocktail; +import com.baeldung.hexagonal.architecture.example.application.ports.out.FetchCocktailsPort; +import com.baeldung.hexagonal.architecture.example.application.ports.out.SaveCocktailPort; + +public class CocktailRepository implements FetchCocktailsPort, SaveCocktailPort { + + private Map store = new HashMap<>(); + + public List fetchCocktails() { + return new ArrayList<>(store.values()); + } + + public void saveCocktail(Cocktail cocktail) { + store.put(cocktail.getName(), cocktail); + } +} diff --git a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/domain/Cocktail.java b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/domain/Cocktail.java new file mode 100644 index 0000000000..878d667bf6 --- /dev/null +++ b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/domain/Cocktail.java @@ -0,0 +1,21 @@ +package com.baeldung.hexagonal.architecture.example.application.domain; + +public class Cocktail { + + private String name; + + private double price; + + public Cocktail(String name, double price) { + this.name = name; + this.price = price; + } + + public String getName() { + return name; + } + + public double getPrice() { + return price; + } +} diff --git a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/ports/in/AddCocktailPort.java b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/ports/in/AddCocktailPort.java new file mode 100644 index 0000000000..49138a2b34 --- /dev/null +++ b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/ports/in/AddCocktailPort.java @@ -0,0 +1,24 @@ +package com.baeldung.hexagonal.architecture.example.application.ports.in; + +public interface AddCocktailPort { + + void addCocktail(AddCocktailCommand command); + + class AddCocktailCommand { + private String name; + private double price; + + public AddCocktailCommand(String name, double price) { + this.name = name; + this.price = price; + } + + public String getName() { + return name; + } + + public double getPrice() { + return price; + } + } +} diff --git a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/ports/in/GetCocktailsPort.java b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/ports/in/GetCocktailsPort.java new file mode 100644 index 0000000000..1d46bbd722 --- /dev/null +++ b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/ports/in/GetCocktailsPort.java @@ -0,0 +1,9 @@ +package com.baeldung.hexagonal.architecture.example.application.ports.in; + +import java.util.List; + +import com.baeldung.hexagonal.architecture.example.application.domain.Cocktail; + +public interface GetCocktailsPort { + List getCocktails(); +} diff --git a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/service/AddCocktailService.java b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/service/AddCocktailService.java new file mode 100644 index 0000000000..81855853e8 --- /dev/null +++ b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/service/AddCocktailService.java @@ -0,0 +1,19 @@ +package com.baeldung.hexagonal.architecture.example.application.service; + +import com.baeldung.hexagonal.architecture.example.application.domain.Cocktail; +import com.baeldung.hexagonal.architecture.example.application.ports.in.AddCocktailPort; +import com.baeldung.hexagonal.architecture.example.application.ports.out.SaveCocktailPort; + +public class AddCocktailService implements AddCocktailPort { + private SaveCocktailPort saveCocktailPort; + + public AddCocktailService(SaveCocktailPort saveCocktailPort) { + this.saveCocktailPort = saveCocktailPort; + } + + @Override + public void addCocktail(AddCocktailCommand command) { + Cocktail cocktail = new Cocktail(command.getName(), command.getPrice()); + saveCocktailPort.saveCocktail(cocktail); + } +} diff --git a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/service/GetCocktailsService.java b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/service/GetCocktailsService.java new file mode 100644 index 0000000000..a1459f2372 --- /dev/null +++ b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/service/GetCocktailsService.java @@ -0,0 +1,20 @@ +package com.baeldung.hexagonal.architecture.example.application.service; + +import java.util.List; + +import com.baeldung.hexagonal.architecture.example.application.domain.Cocktail; +import com.baeldung.hexagonal.architecture.example.application.ports.in.GetCocktailsPort; +import com.baeldung.hexagonal.architecture.example.application.ports.out.FetchCocktailsPort; + +public class GetCocktailsService implements GetCocktailsPort { + private FetchCocktailsPort fetchCocktailsPort; + + public GetCocktailsService(FetchCocktailsPort fetchCocktailsPort) { + this.fetchCocktailsPort = fetchCocktailsPort; + } + + @Override + public List getCocktails() { + return fetchCocktailsPort.fetchCocktails(); + } +} diff --git a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/infrastructure/CocktailsMenuApp.java b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/infrastructure/CocktailsMenuApp.java new file mode 100644 index 0000000000..a808d1f85e --- /dev/null +++ b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/infrastructure/CocktailsMenuApp.java @@ -0,0 +1,43 @@ +package com.baeldung.hexagonal.architecture.example.infrastructure; + +import java.util.Scanner; + +import com.baeldung.hexagonal.architecture.example.adapters.inbound.CommandLineAdapter; +import com.baeldung.hexagonal.architecture.example.adapters.outbound.CocktailRepository; +import com.baeldung.hexagonal.architecture.example.application.service.AddCocktailService; +import com.baeldung.hexagonal.architecture.example.application.service.GetCocktailsService; + +public class CocktailsMenuApp { + private static final String ADD = "add"; + private static final String LIST = "list"; + private static final String EXIT = "exit"; + private static final String HELP_TEXT = "Enter command \n" + + ADD + " - add a new Cocktail to the menu \n" + + LIST + " - list cocktails \n" + + EXIT + " - exit \n"; + private static Scanner SCANNER = new Scanner(System.in); + + public static void main(String[] args) { + CocktailRepository cocktailRepository = new CocktailRepository(); + AddCocktailService addCocktailService = new AddCocktailService(cocktailRepository); + GetCocktailsService getCocktailsMenuService = new GetCocktailsService(cocktailRepository); + CommandLineAdapter commandLineAdapter = new CommandLineAdapter(SCANNER, addCocktailService, getCocktailsMenuService); + runWith(commandLineAdapter); + } + + public static void runWith(CommandLineAdapter adapter) { + String command = null; + while (!EXIT.equalsIgnoreCase(command)) { + System.out.println(HELP_TEXT); + command = SCANNER.next(); + switch (command.toLowerCase()) { + case ADD: + adapter.addCocktail(); + break; + case LIST: + adapter.listCocktails(); + break; + } + } + } +} diff --git a/patterns/hexagonal-architecture-example/src/test/java/com/baeldung/hexagonal/architecture/example/application/AddCocktailUnitTest.java b/patterns/hexagonal-architecture-example/src/test/java/com/baeldung/hexagonal/architecture/example/application/AddCocktailUnitTest.java new file mode 100644 index 0000000000..bff8550464 --- /dev/null +++ b/patterns/hexagonal-architecture-example/src/test/java/com/baeldung/hexagonal/architecture/example/application/AddCocktailUnitTest.java @@ -0,0 +1,42 @@ +package com.baeldung.hexagonal.architecture.example.application; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Mockito; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import com.baeldung.hexagonal.architecture.example.application.domain.Cocktail; +import com.baeldung.hexagonal.architecture.example.application.ports.in.AddCocktailPort.AddCocktailCommand; +import com.baeldung.hexagonal.architecture.example.application.ports.out.SaveCocktailPort; +import com.baeldung.hexagonal.architecture.example.application.service.AddCocktailService; + +class AddCocktailUnitTest { + + SaveCocktailPort saveCocktailPort; + AddCocktailService addCocktailService; + + @BeforeEach + void setup() { + saveCocktailPort = mock(SaveCocktailPort.class); + addCocktailService = new AddCocktailService(saveCocktailPort); + } + + @Test + void whenAddingACocktail_thenTheCocktailIsSaved() { + AddCocktailCommand command = mock(AddCocktailCommand.class); + when(command.getName()).thenReturn("mockito"); + when(command.getPrice()).thenReturn(9.50); + ArgumentCaptor captor = ArgumentCaptor.forClass(Cocktail.class); + + addCocktailService.addCocktail(command); + + Mockito.verify(saveCocktailPort).saveCocktail(captor.capture()); + Cocktail cocktailThatSaved = captor.getValue(); + assertEquals(command.getName(), cocktailThatSaved.getName()); + assertEquals(command.getPrice(), cocktailThatSaved.getPrice()); + } + +} diff --git a/patterns/hexagonal-architecture-example/src/test/java/com/baeldung/hexagonal/architecture/example/application/GetCocktailsUnitTest.java b/patterns/hexagonal-architecture-example/src/test/java/com/baeldung/hexagonal/architecture/example/application/GetCocktailsUnitTest.java new file mode 100644 index 0000000000..5933f71895 --- /dev/null +++ b/patterns/hexagonal-architecture-example/src/test/java/com/baeldung/hexagonal/architecture/example/application/GetCocktailsUnitTest.java @@ -0,0 +1,41 @@ +package com.baeldung.hexagonal.architecture.example.application; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.List; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import com.baeldung.hexagonal.architecture.example.application.domain.Cocktail; +import com.baeldung.hexagonal.architecture.example.application.ports.out.FetchCocktailsPort; +import com.baeldung.hexagonal.architecture.example.application.service.GetCocktailsService; + +class GetCocktailsUnitTest { + + FetchCocktailsPort fetchCocktailsPort; + GetCocktailsService getCocktailsService; + + @BeforeEach + void setup() { + fetchCocktailsPort = mock(FetchCocktailsPort.class); + getCocktailsService = new GetCocktailsService(fetchCocktailsPort); + } + + @Test + void whenGettingCocktails_thenCocktailsFetchedFromPortAndReturned() { + Cocktail cocktail = mock(Cocktail.class); + when(cocktail.getName()).thenReturn("zombie"); + when(cocktail.getPrice()).thenReturn(12.00); + when(fetchCocktailsPort.fetchCocktails()).thenReturn(List.of(cocktail)); + + List cocktails = getCocktailsService.getCocktails(); + + assertEquals(1, cocktails.size()); + assertEquals(cocktail.getName(), cocktails.get(0).getName()); + assertEquals(cocktail.getPrice(), cocktails.get(0).getPrice()); + } + +} diff --git a/patterns/pom.xml b/patterns/pom.xml index 4c17055231..7631d8bbb0 100644 --- a/patterns/pom.xml +++ b/patterns/pom.xml @@ -24,6 +24,7 @@ front-controller intercepting-filter solid + hexagonal-architecture-example From 9860318a485ac6705f4457f2d49d4460df331975 Mon Sep 17 00:00:00 2001 From: ramkumarvenkat Date: Tue, 10 Mar 2020 16:35:00 +0530 Subject: [PATCH 019/503] Guava MapMaker --- .../guava/mapmaker/GuavaMapMakerUnitTest.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java diff --git a/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java b/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java new file mode 100644 index 0000000000..36c0cd8493 --- /dev/null +++ b/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java @@ -0,0 +1,50 @@ +package com.baeldung.guava.mapmaker; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertEquals; + +import com.google.common.collect.MapMaker; +import org.junit.Test; + +import java.util.concurrent.ConcurrentMap; + +public class GuavaMapMakerUnitTest { + @Test + public void whenMakeMap_thenCreated() { + ConcurrentMap m = new MapMaker() + .makeMap(); + assertNotNull(m); + } + + @Test + public void whenMakeMapWithWeakKeys_thenCreated() { + ConcurrentMap m = new MapMaker() + .weakKeys() + .makeMap(); + assertNotNull(m); + } + + @Test + public void whenMakeMapWithWeakValues_thenCreated() { + ConcurrentMap m = new MapMaker() + .weakValues() + .makeMap(); + assertNotNull(m); + } + + @Test + public void whenMakeMapWithInitialCapacity_thenCreated() { + ConcurrentMap m = new MapMaker() + .initialCapacity(10) + .makeMap(); + assertNotNull(m); + } + + @Test + public void whenMakeMapWithConcurrencyLevel_thenCreated() { + ConcurrentMap m = new MapMaker() + .concurrencyLevel(10) + .makeMap(); + assertNotNull(m); + } +} From 79433c0396ed3a147fecf0aa3d531486ba5b00c8 Mon Sep 17 00:00:00 2001 From: ramkumarvenkat Date: Thu, 12 Mar 2020 07:35:47 +0530 Subject: [PATCH 020/503] Fixed comments --- .../guava/mapmaker/GuavaMapMakerUnitTest.java | 49 +++++++------------ 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java b/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java index 36c0cd8493..d9a5fc6cd8 100644 --- a/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java +++ b/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java @@ -1,50 +1,35 @@ package com.baeldung.guava.mapmaker; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertEquals; - import com.google.common.collect.MapMaker; import org.junit.Test; import java.util.concurrent.ConcurrentMap; +import static org.junit.Assert.assertNotNull; + public class GuavaMapMakerUnitTest { - @Test - public void whenMakeMap_thenCreated() { - ConcurrentMap m = new MapMaker() - .makeMap(); - assertNotNull(m); + @Test public void whenMakeMap_thenCreated() { + ConcurrentMap concurrentMap = new MapMaker().makeMap(); + assertNotNull(concurrentMap); } - @Test - public void whenMakeMapWithWeakKeys_thenCreated() { - ConcurrentMap m = new MapMaker() - .weakKeys() - .makeMap(); - assertNotNull(m); + @Test public void whenMakeMapWithWeakKeys_thenCreated() { + ConcurrentMap concurrentMap = new MapMaker().weakKeys().makeMap(); + assertNotNull(concurrentMap); } - @Test - public void whenMakeMapWithWeakValues_thenCreated() { - ConcurrentMap m = new MapMaker() - .weakValues() - .makeMap(); - assertNotNull(m); + @Test public void whenMakeMapWithWeakValues_thenCreated() { + ConcurrentMap concurrentMap = new MapMaker().weakValues().makeMap(); + assertNotNull(concurrentMap); } - @Test - public void whenMakeMapWithInitialCapacity_thenCreated() { - ConcurrentMap m = new MapMaker() - .initialCapacity(10) - .makeMap(); - assertNotNull(m); + @Test public void whenMakeMapWithInitialCapacity_thenCreated() { + ConcurrentMap concurrentMap = new MapMaker().initialCapacity(10).makeMap(); + assertNotNull(concurrentMap); } - @Test - public void whenMakeMapWithConcurrencyLevel_thenCreated() { - ConcurrentMap m = new MapMaker() - .concurrencyLevel(10) - .makeMap(); - assertNotNull(m); + @Test public void whenMakeMapWithConcurrencyLevel_thenCreated() { + ConcurrentMap concurrentMap = new MapMaker().concurrencyLevel(10).makeMap(); + assertNotNull(concurrentMap); } } From 20ef5cc79928cbc51ed4ff1e4a2f35047c03ee18 Mon Sep 17 00:00:00 2001 From: ajay74984 <51405689+ajay74984@users.noreply.github.com> Date: Sat, 14 Mar 2020 11:52:42 +0100 Subject: [PATCH 021/503] added new section --- java-numbers-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/java-numbers-3/README.md b/java-numbers-3/README.md index 08e8dae8ef..a331a979ad 100644 --- a/java-numbers-3/README.md +++ b/java-numbers-3/README.md @@ -2,3 +2,4 @@ - [Generating Random Numbers](https://www.baeldung.com/java-generating-random-numbers) - [Convert Double to Long in Java](https://www.baeldung.com/java-convert-double-long) +- [Guide to the Java Number Class](http://inprogress.baeldung.com/?p=180694&preview=true) From 6c78ed9be0dc47684cfb9716b50f405304148258 Mon Sep 17 00:00:00 2001 From: ajay74984 <51405689+ajay74984@users.noreply.github.com> Date: Sat, 14 Mar 2020 12:25:31 +0100 Subject: [PATCH 022/503] REmoved files --- .../spring-boot-hexagonal/README.md | 4 -- .../spring-boot-hexagonal/pom.xml | 52 ------------------- .../main/java/com/baeldung/Application.java | 13 ----- .../adapter/DocumentRepositoryImpl.java | 25 --------- .../baeldung/adapter/DocumentRestAdapter.java | 25 --------- .../java/com/baeldung/domain/Document.java | 23 -------- .../baeldung/domain/port/DocumentRepo.java | 9 ---- .../baeldung/domain/port/DocumentService.java | 11 ---- .../domain/port/impl/DocumentServiceImpl.java | 25 --------- .../src/main/resources/application.properties | 1 - .../com/baeldung/ApplicationUnitTest.java | 16 ------ 11 files changed, 204 deletions(-) delete mode 100644 spring-boot-modules/spring-boot-hexagonal/README.md delete mode 100644 spring-boot-modules/spring-boot-hexagonal/pom.xml delete mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java delete mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java delete mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java delete mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java delete mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/DocumentRepo.java delete mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/DocumentService.java delete mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/impl/DocumentServiceImpl.java delete mode 100644 spring-boot-modules/spring-boot-hexagonal/src/main/resources/application.properties delete mode 100644 spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationUnitTest.java diff --git a/spring-boot-modules/spring-boot-hexagonal/README.md b/spring-boot-modules/spring-boot-hexagonal/README.md deleted file mode 100644 index 44728b185e..0000000000 --- a/spring-boot-modules/spring-boot-hexagonal/README.md +++ /dev/null @@ -1,4 +0,0 @@ -## HEXAGONAL Architecture - -This module contains articles about Hexagonal Architecture implemented via Spring Boot. - diff --git a/spring-boot-modules/spring-boot-hexagonal/pom.xml b/spring-boot-modules/spring-boot-hexagonal/pom.xml deleted file mode 100644 index c4ff36c2cf..0000000000 --- a/spring-boot-modules/spring-boot-hexagonal/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - 4.0.0 - spring-boot-hexagonal - spring-boot-hexagonal - - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 - - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-test - - - - - - spring-boot-hexagonal - - - src/main/resources - true - - - - - org.springframework.boot - spring-boot-maven-plugin - - exec - - - - - - - UTF-8 - - - diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java deleted file mode 100644 index 37dbe7dab8..0000000000 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/Application.java +++ /dev/null @@ -1,13 +0,0 @@ -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-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java deleted file mode 100644 index 32414442ef..0000000000 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRepositoryImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.adapter; - -import org.springframework.stereotype.Repository; - -import com.baeldung.domain.Document; -import com.baeldung.domain.port.DocumentRepo; - -import java.util.HashMap; -import java.util.Map; - -@Repository -public class DocumentRepositoryImpl implements DocumentRepo { - - private Map documentMap = new HashMap<>(); - - @Override - public void storeDocument(Document document) { - documentMap.put(document.getId(), document); - } - - @Override - public Document findDocumentById(String id) { - return documentMap.get(id); - } -} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java deleted file mode 100644 index 985a5257c0..0000000000 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/adapter/DocumentRestAdapter.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.adapter; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import com.baeldung.domain.Document; -import com.baeldung.domain.port.DocumentService; - -@RestController -@RequestMapping("/doc") -public class DocumentRestAdapter { - @Autowired - private DocumentService documentService; - - @PostMapping - public void createDocument(@RequestBody Document document) { - documentService.createDocument(document); - } - - @GetMapping("/{id}") - public Document findById(@PathVariable String id) { - return documentService.findById(id); - } - -} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java deleted file mode 100644 index 24d0a95071..0000000000 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/Document.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.baeldung.domain; - -public class Document { - private String id; - private String data; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getData() { - return data; - } - - public void setData(String data) { - this.data = data; - } - -} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/DocumentRepo.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/DocumentRepo.java deleted file mode 100644 index 001e3251e4..0000000000 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/DocumentRepo.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.domain.port; - -import com.baeldung.domain.Document; - -public interface DocumentRepo { - void storeDocument(Document document); - - Document findDocumentById(String id); -} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/DocumentService.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/DocumentService.java deleted file mode 100644 index 009c26c01f..0000000000 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/DocumentService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.domain.port; - -import com.baeldung.domain.Document; - -public interface DocumentService { - - void createDocument(Document document); - - Document findById(String id); - -} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/impl/DocumentServiceImpl.java b/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/impl/DocumentServiceImpl.java deleted file mode 100644 index f5c351406e..0000000000 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/java/com/baeldung/domain/port/impl/DocumentServiceImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.domain.port.impl; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.baeldung.domain.Document; -import com.baeldung.domain.port.DocumentRepo; -import com.baeldung.domain.port.DocumentService; - -@Service -public class DocumentServiceImpl implements DocumentService { - - @Autowired - private DocumentRepo documentRepo; - - @Override - public void createDocument(Document document) { - documentRepo.storeDocument(document); - } - - @Override - public Document findById(String id) { - return documentRepo.findDocumentById(id); - } -} diff --git a/spring-boot-modules/spring-boot-hexagonal/src/main/resources/application.properties b/spring-boot-modules/spring-boot-hexagonal/src/main/resources/application.properties deleted file mode 100644 index 8b13789179..0000000000 --- a/spring-boot-modules/spring-boot-hexagonal/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationUnitTest.java b/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationUnitTest.java deleted file mode 100644 index 2ce9b1cf24..0000000000 --- a/spring-boot-modules/spring-boot-hexagonal/src/test/java/com/baeldung/ApplicationUnitTest.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@SpringBootTest -@RunWith(SpringRunner.class) -class ApplicationUnitTest { - - @Test - public void contextLoads() { - } - -} From 2fca6d60de37440c3e632c61f796134c410dd99d Mon Sep 17 00:00:00 2001 From: ajay74984 <51405689+ajay74984@users.noreply.github.com> Date: Sat, 14 Mar 2020 12:29:22 +0100 Subject: [PATCH 023/503] cleanup --- spring-boot-modules/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 16541408a4..c8d153d4bb 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -53,7 +53,6 @@ spring-boot-springdoc spring-boot-testing spring-boot-vue - spring-boot-hexagonal From 2c0cf3e2e02de86f36e65212248f8625657c8c28 Mon Sep 17 00:00:00 2001 From: mike b Date: Sun, 15 Mar 2020 14:14:46 -0400 Subject: [PATCH 024/503] [BAEL-3646] Conditional Flow in Spring Batch --- .../ConditionalFlowApplication.java | 18 ++++ .../conditionalflow/NumberInfoDecider.java | 19 +++++ .../config/NumberInfoConfig.java | 85 +++++++++++++++++++ .../conditionalflow/model/NumberInfo.java | 47 ++++++++++ .../conditionalflow/step/NotifierTasklet.java | 14 +++ .../step/NumberInfoClassifier.java | 31 +++++++ .../step/NumberInfoClassifierWithDecider.java | 15 ++++ .../step/NumberInfoGenerator.java | 23 +++++ .../step/NumberInfoProcessor.java | 17 ++++ .../step/PrependingStdoutWriter.java | 30 +++++++ .../model/NumberInfoUnitTest.java | 44 ++++++++++ .../step/NumberInfoClassifierUnitTest.java | 17 ++++ .../step/NumberInfoGeneratorUnitTest.java | 20 +++++ 13 files changed, 380 insertions(+) create mode 100644 spring-batch/src/main/java/org/baeldung/conditionalflow/ConditionalFlowApplication.java create mode 100644 spring-batch/src/main/java/org/baeldung/conditionalflow/NumberInfoDecider.java create mode 100644 spring-batch/src/main/java/org/baeldung/conditionalflow/config/NumberInfoConfig.java create mode 100644 spring-batch/src/main/java/org/baeldung/conditionalflow/model/NumberInfo.java create mode 100644 spring-batch/src/main/java/org/baeldung/conditionalflow/step/NotifierTasklet.java create mode 100644 spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifier.java create mode 100644 spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifierWithDecider.java create mode 100644 spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoGenerator.java create mode 100644 spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoProcessor.java create mode 100644 spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java create mode 100644 spring-batch/src/test/java/org/baeldung/conditionalflow/model/NumberInfoUnitTest.java create mode 100644 spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoClassifierUnitTest.java create mode 100644 spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoGeneratorUnitTest.java diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/ConditionalFlowApplication.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/ConditionalFlowApplication.java new file mode 100644 index 0000000000..8b6c841b6e --- /dev/null +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/ConditionalFlowApplication.java @@ -0,0 +1,18 @@ +package org.baeldung.conditionalflow; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ConditionalFlowApplication implements CommandLineRunner { + + public static void main(String[] args) { + SpringApplication.run(ConditionalFlowApplication.class, args); + } + + @Override + public void run(String... args) throws Exception { + System.out.println("Running and exiting"); + } +} diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/NumberInfoDecider.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/NumberInfoDecider.java new file mode 100644 index 0000000000..017980f1a4 --- /dev/null +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/NumberInfoDecider.java @@ -0,0 +1,19 @@ +package org.baeldung.conditionalflow; + +import org.springframework.batch.core.ExitStatus; +import org.springframework.batch.core.JobExecution; +import org.springframework.batch.core.StepExecution; +import org.springframework.batch.core.job.flow.FlowExecutionStatus; +import org.springframework.batch.core.job.flow.JobExecutionDecider; + +public class NumberInfoDecider implements JobExecutionDecider { + + @Override + public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { + if(jobExecution.getExitStatus().equals("UNKNOWN")) { + return new FlowExecutionStatus("NOTIFY"); + } else { + return null; + } + } +} diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/config/NumberInfoConfig.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/config/NumberInfoConfig.java new file mode 100644 index 0000000000..fd28c2291f --- /dev/null +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/config/NumberInfoConfig.java @@ -0,0 +1,85 @@ +package org.baeldung.conditionalflow.config; + +import org.baeldung.conditionalflow.NumberInfoDecider; +import org.baeldung.conditionalflow.model.NumberInfo; +import org.baeldung.conditionalflow.step.*; +import org.springframework.batch.core.Job; +import org.springframework.batch.core.Step; +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; +import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@EnableBatchProcessing +public class NumberInfoConfig { + + @Bean + @Qualifier("NotificationStep") + public Step notificationStep(StepBuilderFactory sbf) { + return sbf.get("Billing step").tasklet(new NotifierTasklet()).build(); + } + + public Step numberGeneratorStep(StepBuilderFactory sbf, int[] values, String prepend) { + return sbf.get("Number generator") + .chunk(1) + .reader(new NumberInfoGenerator(values)) + .processor(new NumberInfoClassifier()) + .writer(new PrependingStdoutWriter<>(prepend)) + .build(); + } + + public Step numberGeneratorStepDecider(StepBuilderFactory sbf, int[] values, String prepend) { + return sbf.get("Number generator") + .chunk(1) + .reader(new NumberInfoGenerator(values)) + .processor(new NumberInfoClassifierWithDecider()) + .writer(new PrependingStdoutWriter<>(prepend)) + .build(); + } + + @Bean + public Job numberGeneratorNonNotifierJob(JobBuilderFactory jobBuilderFactory, + StepBuilderFactory stepBuilderFactory, + @Qualifier("NotificationStep") Step notificationStep + ) { + int[] nonNotifierData = {-1, -2, -3}; + Step step = numberGeneratorStep(stepBuilderFactory, nonNotifierData, "First Dataset Processor"); + return jobBuilderFactory.get("Number generator - first dataset") + .start(step) + .on("NOTIFY").to(notificationStep) + .from(step).on("*").stop() + .end() + .build(); + } + + @Bean + public Job numberGeneratorNotifierJob(JobBuilderFactory jobBuilderFactory, + StepBuilderFactory stepBuilderFactory, + @Qualifier("NotificationStep") Step notificationStep + ) { + int[] billableData = {11, -2, -3}; + Step dataProviderStep = numberGeneratorStep(stepBuilderFactory, billableData, "Second Dataset Processor"); + return jobBuilderFactory.get("Number generator - second dataset") + .start(dataProviderStep) + .on("NOTIFY").to(notificationStep) + .end() + .build(); + } + + @Bean + public Job numberGeneratorNotifierJobWithDecider(JobBuilderFactory jobBuilderFactory, + StepBuilderFactory stepBuilderFactory, + @Qualifier("NotificationStep") Step notificationStep + ) { + int[] billableData = {11, -2, -3}; + Step dataProviderStep = numberGeneratorStepDecider(stepBuilderFactory, billableData, "Third Dataset Processor"); + return jobBuilderFactory.get("Number generator - third dataset") + .start(dataProviderStep) + .next(new NumberInfoDecider()).on("NOTIFY").to(notificationStep) + .end() + .build(); + } +} diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/model/NumberInfo.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/model/NumberInfo.java new file mode 100644 index 0000000000..81bd67d2a1 --- /dev/null +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/model/NumberInfo.java @@ -0,0 +1,47 @@ +package org.baeldung.conditionalflow.model; + +import java.util.Objects; + +public class NumberInfo { + private int number; + + public static NumberInfo from(int number){ + return new NumberInfo(number); + } + + public NumberInfo(int number) { + this.number = number; + } + + public boolean isPositive() { + return number > 0; + } + + public boolean isEven() { + return number % 2 == 0; + } + + public int getNumber() { + return number; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + NumberInfo that = (NumberInfo) o; + return number == that.number; + } + + @Override + public int hashCode() { + return Objects.hash(number); + } + + @Override + public String toString() { + return "NumberInfo{" + + "number=" + number + + '}'; + } +} \ No newline at end of file diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NotifierTasklet.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NotifierTasklet.java new file mode 100644 index 0000000000..6a88edcbbe --- /dev/null +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NotifierTasklet.java @@ -0,0 +1,14 @@ +package org.baeldung.conditionalflow.step; + +import org.springframework.batch.core.StepContribution; +import org.springframework.batch.core.scope.context.ChunkContext; +import org.springframework.batch.core.step.tasklet.Tasklet; +import org.springframework.batch.repeat.RepeatStatus; + +public class NotifierTasklet implements Tasklet { + @Override + public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception { + System.err.println("[" + chunkContext.getStepContext().getJobName() + "] contains interesting data!!"); + return RepeatStatus.FINISHED; + } +} diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifier.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifier.java new file mode 100644 index 0000000000..95b1e4d155 --- /dev/null +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifier.java @@ -0,0 +1,31 @@ +package org.baeldung.conditionalflow.step; + +import org.baeldung.conditionalflow.model.NumberInfo; +import org.springframework.batch.core.ExitStatus; +import org.springframework.batch.core.StepExecution; +import org.springframework.batch.core.annotation.BeforeStep; +import org.springframework.batch.core.listener.ItemListenerSupport; +import org.springframework.batch.item.ItemProcessor; + +public class NumberInfoClassifier extends ItemListenerSupport + implements ItemProcessor { + private StepExecution stepExecution; + + @BeforeStep + public void beforeStep(StepExecution stepExecution) { + this.stepExecution = stepExecution; + } + + @Override + public void afterProcess(NumberInfo item, Integer result) { + super.afterProcess(item, result); + if (item.isPositive()) { + stepExecution.setExitStatus(new ExitStatus("NOTIFY")); + } + } + + @Override + public Integer process(NumberInfo numberInfo) throws Exception { + return Integer.valueOf(numberInfo.getNumber()); + } +} diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifierWithDecider.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifierWithDecider.java new file mode 100644 index 0000000000..0ba7fde279 --- /dev/null +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifierWithDecider.java @@ -0,0 +1,15 @@ +package org.baeldung.conditionalflow.step; + +import org.baeldung.conditionalflow.model.NumberInfo; +import org.springframework.batch.core.StepExecution; +import org.springframework.batch.item.ItemProcessor; + +public class NumberInfoClassifierWithDecider + implements ItemProcessor { + private StepExecution stepExecution; + + @Override + public Integer process(NumberInfo numberInfo) throws Exception { + return Integer.valueOf(numberInfo.getNumber()); + } +} diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoGenerator.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoGenerator.java new file mode 100644 index 0000000000..35f6c39778 --- /dev/null +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoGenerator.java @@ -0,0 +1,23 @@ +package org.baeldung.conditionalflow.step; + +import org.baeldung.conditionalflow.model.NumberInfo; +import org.springframework.batch.item.ItemReader; + +public class NumberInfoGenerator implements ItemReader { + private int[] values; + private int counter; + + public NumberInfoGenerator(int[] values){ + this.values = values; + counter = 0; + } + + @Override + public NumberInfo read() { + if(counter == values.length){ + return null; + } else { + return new NumberInfo(values[counter++]); + } + } +} diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoProcessor.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoProcessor.java new file mode 100644 index 0000000000..fe566221de --- /dev/null +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoProcessor.java @@ -0,0 +1,17 @@ +package org.baeldung.conditionalflow.step; + +import org.baeldung.conditionalflow.model.NumberInfo; +import org.springframework.batch.core.ExitStatus; +import org.springframework.batch.core.StepExecution; +import org.springframework.batch.core.annotation.BeforeStep; +import org.springframework.batch.core.listener.ItemListenerSupport; +import org.springframework.batch.item.ItemProcessor; + +public class NumberInfoProcessor implements ItemProcessor { + private StepExecution stepExecution; + + @Override + public Integer process(NumberInfo numberInfo) throws Exception { + return Integer.valueOf(numberInfo.getNumber()); + } +} diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java new file mode 100644 index 0000000000..8b8959d249 --- /dev/null +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java @@ -0,0 +1,30 @@ +package org.baeldung.conditionalflow.step; + +import org.springframework.batch.item.ItemWriter; + +import java.io.OutputStream; +import java.util.List; + +public class PrependingStdoutWriter implements ItemWriter { + private String prependText; + private OutputStream writeTo; + + private PrependingStdoutWriter() { + } + + public PrependingStdoutWriter(String prependText, OutputStream os){ + this.prependText = prependText; + this.writeTo = os; + } + + public PrependingStdoutWriter(String prependText) { + this(prependText, System.out); + } + + @Override + public void write(List list) throws Exception { + for (T listItem : list) { + System.out.println(prependText + " " + listItem.toString()); + } + } +} diff --git a/spring-batch/src/test/java/org/baeldung/conditionalflow/model/NumberInfoUnitTest.java b/spring-batch/src/test/java/org/baeldung/conditionalflow/model/NumberInfoUnitTest.java new file mode 100644 index 0000000000..cf3d361412 --- /dev/null +++ b/spring-batch/src/test/java/org/baeldung/conditionalflow/model/NumberInfoUnitTest.java @@ -0,0 +1,44 @@ +package org.baeldung.conditionalflow.model; + +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import static org.junit.jupiter.api.Assertions.*; + +@RunWith(SpringJUnit4ClassRunner.class) +class NumberInfoUnitTest { + + @Test + void isPositive() { + assertTrue(NumberInfo.from(1).isPositive()); + assertTrue(NumberInfo.from(11).isPositive()); + assertFalse(NumberInfo.from(0).isPositive()); + assertFalse(NumberInfo.from(-1).isPositive()); + assertFalse(NumberInfo.from(-10).isPositive()); + } + + @Test + void isEven() { + assertTrue(NumberInfo.from(0).isEven()); + assertTrue(NumberInfo.from(-2).isEven()); + assertTrue(NumberInfo.from(2).isEven()); + assertTrue(NumberInfo.from(-22).isEven()); + assertTrue(NumberInfo.from(22).isEven()); + + assertFalse(NumberInfo.from(1).isEven()); + assertFalse(NumberInfo.from(-1).isEven()); + + assertFalse(NumberInfo.from(13).isEven()); + assertFalse(NumberInfo.from(-13).isEven()); + assertFalse(NumberInfo.from(31).isEven()); + assertFalse(NumberInfo.from(-51).isEven()); + } + + @Test + void getNumber() { + for(int i = -100 ; i < 100 ; i++){ + assertEquals(i, NumberInfo.from(i).getNumber()); + } + } +} \ No newline at end of file diff --git a/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoClassifierUnitTest.java b/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoClassifierUnitTest.java new file mode 100644 index 0000000000..c195740caa --- /dev/null +++ b/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoClassifierUnitTest.java @@ -0,0 +1,17 @@ +package org.baeldung.conditionalflow.step; + +import org.baeldung.conditionalflow.model.NumberInfo; +import org.baeldung.conditionalflow.step.NumberInfoClassifier; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class NumberInfoClassifierUnitTest { + + @Test + void process() throws Exception { + NumberInfoClassifier nic = new NumberInfoClassifier(); + assertEquals(Integer.valueOf(4), nic.process(NumberInfo.from(4))); + assertEquals(Integer.valueOf(-4), nic.process(NumberInfo.from(-4))); + } +} \ No newline at end of file diff --git a/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoGeneratorUnitTest.java b/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoGeneratorUnitTest.java new file mode 100644 index 0000000000..3fc240bcbf --- /dev/null +++ b/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoGeneratorUnitTest.java @@ -0,0 +1,20 @@ +package org.baeldung.conditionalflow.step; + +import org.baeldung.conditionalflow.model.NumberInfo; +import org.junit.jupiter.api.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +public class NumberInfoGeneratorUnitTest { + @Test + public void testGenerateNumbers() { + int[] numbers = new int[]{1, -2, 4, -10}; + NumberInfoGenerator numberGenerator = new NumberInfoGenerator(numbers); + assertEquals(new NumberInfo(numbers[0]), numberGenerator.read()); + assertEquals(new NumberInfo(numbers[1]), numberGenerator.read()); + assertEquals(new NumberInfo(numbers[2]), numberGenerator.read()); + assertEquals(new NumberInfo(numbers[3]), numberGenerator.read()); + assertNull(numberGenerator.read()); + } +} \ No newline at end of file From d3b351e27f4e21857ffa92d8acb5f5a5efba86eb Mon Sep 17 00:00:00 2001 From: ramkumarvenkat Date: Mon, 16 Mar 2020 08:30:23 +0530 Subject: [PATCH 025/503] fix formatting --- .../guava/mapmaker/GuavaMapMakerUnitTest.java | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java b/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java index d9a5fc6cd8..8da459f22e 100644 --- a/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java +++ b/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java @@ -8,28 +8,33 @@ import java.util.concurrent.ConcurrentMap; import static org.junit.Assert.assertNotNull; public class GuavaMapMakerUnitTest { - @Test public void whenMakeMap_thenCreated() { - ConcurrentMap concurrentMap = new MapMaker().makeMap(); - assertNotNull(concurrentMap); - } + @Test + public void whenMakeMap_thenCreated() { + ConcurrentMap concurrentMap = new MapMaker().makeMap(); + assertNotNull(concurrentMap); + } - @Test public void whenMakeMapWithWeakKeys_thenCreated() { - ConcurrentMap concurrentMap = new MapMaker().weakKeys().makeMap(); - assertNotNull(concurrentMap); - } + @Test + public void whenMakeMapWithWeakKeys_thenCreated() { + ConcurrentMap concurrentMap = new MapMaker().weakKeys().makeMap(); + assertNotNull(concurrentMap); + } - @Test public void whenMakeMapWithWeakValues_thenCreated() { - ConcurrentMap concurrentMap = new MapMaker().weakValues().makeMap(); - assertNotNull(concurrentMap); - } + @Test + public void whenMakeMapWithWeakValues_thenCreated() { + ConcurrentMap concurrentMap = new MapMaker().weakValues().makeMap(); + assertNotNull(concurrentMap); + } - @Test public void whenMakeMapWithInitialCapacity_thenCreated() { - ConcurrentMap concurrentMap = new MapMaker().initialCapacity(10).makeMap(); - assertNotNull(concurrentMap); - } + @Test + public void whenMakeMapWithInitialCapacity_thenCreated() { + ConcurrentMap concurrentMap = new MapMaker().initialCapacity(10).makeMap(); + assertNotNull(concurrentMap); + } - @Test public void whenMakeMapWithConcurrencyLevel_thenCreated() { - ConcurrentMap concurrentMap = new MapMaker().concurrencyLevel(10).makeMap(); - assertNotNull(concurrentMap); - } + @Test + public void whenMakeMapWithConcurrencyLevel_thenCreated() { + ConcurrentMap concurrentMap = new MapMaker().concurrencyLevel(10).makeMap(); + assertNotNull(concurrentMap); + } } From 0a5fbbe0e7626062cf5810970b07e65c1472bcbe Mon Sep 17 00:00:00 2001 From: Greg Martin Date: Mon, 16 Mar 2020 16:55:14 -0400 Subject: [PATCH 026/503] Moved NullAwayExample.java to libraries-3. Updated the libraries-3 README --- libraries-3/README.md | 1 + .../src/main/java/com/baeldung/nullaway/NullAwayExample.java | 0 2 files changed, 1 insertion(+) rename {libraries => libraries-3}/src/main/java/com/baeldung/nullaway/NullAwayExample.java (100%) diff --git a/libraries-3/README.md b/libraries-3/README.md index 404045e6b1..2692d606f3 100644 --- a/libraries-3/README.md +++ b/libraries-3/README.md @@ -12,3 +12,4 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Guide to the Cactoos Library](https://www.baeldung.com/java-cactoos) - [Parsing Command-Line Parameters with Airline](https://www.baeldung.com/java-airline) - [Introduction to cache2k](https://www.baeldung.com/java-cache2k) +- [Using NullAway to Avoid NullPointerExceptions](https://www.baeldung.com/java-nullaway) diff --git a/libraries/src/main/java/com/baeldung/nullaway/NullAwayExample.java b/libraries-3/src/main/java/com/baeldung/nullaway/NullAwayExample.java similarity index 100% rename from libraries/src/main/java/com/baeldung/nullaway/NullAwayExample.java rename to libraries-3/src/main/java/com/baeldung/nullaway/NullAwayExample.java From f55a86f19f742f20ff139095c7d24994953f2399 Mon Sep 17 00:00:00 2001 From: kkaravitis Date: Tue, 17 Mar 2020 15:55:04 +0200 Subject: [PATCH 027/503] Removed evaluation article code --- .../hexagonal-architecture-example/pom.xml | 34 -------------- .../adapters/inbound/CommandLineAdapter.java | 46 ------------------- .../adapters/outbound/CocktailRepository.java | 23 ---------- .../example/application/domain/Cocktail.java | 21 --------- .../application/ports/in/AddCocktailPort.java | 24 ---------- .../ports/in/GetCocktailsPort.java | 9 ---- .../service/AddCocktailService.java | 19 -------- .../service/GetCocktailsService.java | 20 -------- .../infrastructure/CocktailsMenuApp.java | 43 ----------------- .../application/AddCocktailUnitTest.java | 42 ----------------- .../application/GetCocktailsUnitTest.java | 41 ----------------- 11 files changed, 322 deletions(-) delete mode 100644 patterns/hexagonal-architecture-example/pom.xml delete mode 100644 patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/adapters/inbound/CommandLineAdapter.java delete mode 100644 patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/adapters/outbound/CocktailRepository.java delete mode 100644 patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/domain/Cocktail.java delete mode 100644 patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/ports/in/AddCocktailPort.java delete mode 100644 patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/ports/in/GetCocktailsPort.java delete mode 100644 patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/service/AddCocktailService.java delete mode 100644 patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/service/GetCocktailsService.java delete mode 100644 patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/infrastructure/CocktailsMenuApp.java delete mode 100644 patterns/hexagonal-architecture-example/src/test/java/com/baeldung/hexagonal/architecture/example/application/AddCocktailUnitTest.java delete mode 100644 patterns/hexagonal-architecture-example/src/test/java/com/baeldung/hexagonal/architecture/example/application/GetCocktailsUnitTest.java diff --git a/patterns/hexagonal-architecture-example/pom.xml b/patterns/hexagonal-architecture-example/pom.xml deleted file mode 100644 index e5439bf8f7..0000000000 --- a/patterns/hexagonal-architecture-example/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ - - 4.0.0 - hexagonal-architecture-example - 1.0 - jar - - com.baeldung - patterns - 1.0.0-SNAPSHOT - - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.2.0 - - - - true - lib/ - com.baeldung.hexagonal.architecture.example.infrastructure.CocktailsMenuApp - - - - - - - - \ No newline at end of file diff --git a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/adapters/inbound/CommandLineAdapter.java b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/adapters/inbound/CommandLineAdapter.java deleted file mode 100644 index 4f85639009..0000000000 --- a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/adapters/inbound/CommandLineAdapter.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.baeldung.hexagonal.architecture.example.adapters.inbound; - -import java.util.List; -import java.util.Scanner; - -import com.baeldung.hexagonal.architecture.example.application.domain.Cocktail; -import com.baeldung.hexagonal.architecture.example.application.ports.in.AddCocktailPort; -import com.baeldung.hexagonal.architecture.example.application.ports.in.AddCocktailPort.AddCocktailCommand; -import com.baeldung.hexagonal.architecture.example.application.ports.in.GetCocktailsPort; - -public class CommandLineAdapter { - private AddCocktailPort addCocktailPort; - private GetCocktailsPort listCocktailsPort; - private Scanner scanner; - - public CommandLineAdapter(Scanner scanner, AddCocktailPort addCocktailPort, GetCocktailsPort listCocktailsPort) { - this.addCocktailPort = addCocktailPort; - this.listCocktailsPort = listCocktailsPort; - this.scanner = scanner; - } - - public void addCocktail() { - try { - System.out.println("Enter the name of the cocktail"); - scanner.nextLine(); - String name = scanner.nextLine(); - System.out.println("Enter the price of the cocktail"); - double price = scanner.nextDouble(); - scanner.nextLine(); - AddCocktailCommand command = new AddCocktailCommand(name, price); - addCocktailPort.addCocktail(command); - } catch (Exception exception) { - System.out.println("Error during adding a new Cocktail"); - } - } - - public void listCocktails() { - List cocktailList = listCocktailsPort.getCocktails(); - System.out.println("Cocktails menu: \n"); - cocktailList.stream() - .forEach(cocktail -> { - System.out.println(cocktail.getName() + "\n" + - "price: " + cocktail.getPrice() + " $ " + "\n"); - }); - } -} diff --git a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/adapters/outbound/CocktailRepository.java b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/adapters/outbound/CocktailRepository.java deleted file mode 100644 index 8b8e4d1d54..0000000000 --- a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/adapters/outbound/CocktailRepository.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.baeldung.hexagonal.architecture.example.adapters.outbound; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.baeldung.hexagonal.architecture.example.application.domain.Cocktail; -import com.baeldung.hexagonal.architecture.example.application.ports.out.FetchCocktailsPort; -import com.baeldung.hexagonal.architecture.example.application.ports.out.SaveCocktailPort; - -public class CocktailRepository implements FetchCocktailsPort, SaveCocktailPort { - - private Map store = new HashMap<>(); - - public List fetchCocktails() { - return new ArrayList<>(store.values()); - } - - public void saveCocktail(Cocktail cocktail) { - store.put(cocktail.getName(), cocktail); - } -} diff --git a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/domain/Cocktail.java b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/domain/Cocktail.java deleted file mode 100644 index 878d667bf6..0000000000 --- a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/domain/Cocktail.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.hexagonal.architecture.example.application.domain; - -public class Cocktail { - - private String name; - - private double price; - - public Cocktail(String name, double price) { - this.name = name; - this.price = price; - } - - public String getName() { - return name; - } - - public double getPrice() { - return price; - } -} diff --git a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/ports/in/AddCocktailPort.java b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/ports/in/AddCocktailPort.java deleted file mode 100644 index 49138a2b34..0000000000 --- a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/ports/in/AddCocktailPort.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.hexagonal.architecture.example.application.ports.in; - -public interface AddCocktailPort { - - void addCocktail(AddCocktailCommand command); - - class AddCocktailCommand { - private String name; - private double price; - - public AddCocktailCommand(String name, double price) { - this.name = name; - this.price = price; - } - - public String getName() { - return name; - } - - public double getPrice() { - return price; - } - } -} diff --git a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/ports/in/GetCocktailsPort.java b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/ports/in/GetCocktailsPort.java deleted file mode 100644 index 1d46bbd722..0000000000 --- a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/ports/in/GetCocktailsPort.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.hexagonal.architecture.example.application.ports.in; - -import java.util.List; - -import com.baeldung.hexagonal.architecture.example.application.domain.Cocktail; - -public interface GetCocktailsPort { - List getCocktails(); -} diff --git a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/service/AddCocktailService.java b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/service/AddCocktailService.java deleted file mode 100644 index 81855853e8..0000000000 --- a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/service/AddCocktailService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.hexagonal.architecture.example.application.service; - -import com.baeldung.hexagonal.architecture.example.application.domain.Cocktail; -import com.baeldung.hexagonal.architecture.example.application.ports.in.AddCocktailPort; -import com.baeldung.hexagonal.architecture.example.application.ports.out.SaveCocktailPort; - -public class AddCocktailService implements AddCocktailPort { - private SaveCocktailPort saveCocktailPort; - - public AddCocktailService(SaveCocktailPort saveCocktailPort) { - this.saveCocktailPort = saveCocktailPort; - } - - @Override - public void addCocktail(AddCocktailCommand command) { - Cocktail cocktail = new Cocktail(command.getName(), command.getPrice()); - saveCocktailPort.saveCocktail(cocktail); - } -} diff --git a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/service/GetCocktailsService.java b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/service/GetCocktailsService.java deleted file mode 100644 index a1459f2372..0000000000 --- a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/application/service/GetCocktailsService.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.hexagonal.architecture.example.application.service; - -import java.util.List; - -import com.baeldung.hexagonal.architecture.example.application.domain.Cocktail; -import com.baeldung.hexagonal.architecture.example.application.ports.in.GetCocktailsPort; -import com.baeldung.hexagonal.architecture.example.application.ports.out.FetchCocktailsPort; - -public class GetCocktailsService implements GetCocktailsPort { - private FetchCocktailsPort fetchCocktailsPort; - - public GetCocktailsService(FetchCocktailsPort fetchCocktailsPort) { - this.fetchCocktailsPort = fetchCocktailsPort; - } - - @Override - public List getCocktails() { - return fetchCocktailsPort.fetchCocktails(); - } -} diff --git a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/infrastructure/CocktailsMenuApp.java b/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/infrastructure/CocktailsMenuApp.java deleted file mode 100644 index a808d1f85e..0000000000 --- a/patterns/hexagonal-architecture-example/src/main/java/com/baeldung/hexagonal/architecture/example/infrastructure/CocktailsMenuApp.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.baeldung.hexagonal.architecture.example.infrastructure; - -import java.util.Scanner; - -import com.baeldung.hexagonal.architecture.example.adapters.inbound.CommandLineAdapter; -import com.baeldung.hexagonal.architecture.example.adapters.outbound.CocktailRepository; -import com.baeldung.hexagonal.architecture.example.application.service.AddCocktailService; -import com.baeldung.hexagonal.architecture.example.application.service.GetCocktailsService; - -public class CocktailsMenuApp { - private static final String ADD = "add"; - private static final String LIST = "list"; - private static final String EXIT = "exit"; - private static final String HELP_TEXT = "Enter command \n" + - ADD + " - add a new Cocktail to the menu \n" + - LIST + " - list cocktails \n" + - EXIT + " - exit \n"; - private static Scanner SCANNER = new Scanner(System.in); - - public static void main(String[] args) { - CocktailRepository cocktailRepository = new CocktailRepository(); - AddCocktailService addCocktailService = new AddCocktailService(cocktailRepository); - GetCocktailsService getCocktailsMenuService = new GetCocktailsService(cocktailRepository); - CommandLineAdapter commandLineAdapter = new CommandLineAdapter(SCANNER, addCocktailService, getCocktailsMenuService); - runWith(commandLineAdapter); - } - - public static void runWith(CommandLineAdapter adapter) { - String command = null; - while (!EXIT.equalsIgnoreCase(command)) { - System.out.println(HELP_TEXT); - command = SCANNER.next(); - switch (command.toLowerCase()) { - case ADD: - adapter.addCocktail(); - break; - case LIST: - adapter.listCocktails(); - break; - } - } - } -} diff --git a/patterns/hexagonal-architecture-example/src/test/java/com/baeldung/hexagonal/architecture/example/application/AddCocktailUnitTest.java b/patterns/hexagonal-architecture-example/src/test/java/com/baeldung/hexagonal/architecture/example/application/AddCocktailUnitTest.java deleted file mode 100644 index bff8550464..0000000000 --- a/patterns/hexagonal-architecture-example/src/test/java/com/baeldung/hexagonal/architecture/example/application/AddCocktailUnitTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.baeldung.hexagonal.architecture.example.application; -import static org.junit.jupiter.api.Assertions.assertEquals; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.baeldung.hexagonal.architecture.example.application.domain.Cocktail; -import com.baeldung.hexagonal.architecture.example.application.ports.in.AddCocktailPort.AddCocktailCommand; -import com.baeldung.hexagonal.architecture.example.application.ports.out.SaveCocktailPort; -import com.baeldung.hexagonal.architecture.example.application.service.AddCocktailService; - -class AddCocktailUnitTest { - - SaveCocktailPort saveCocktailPort; - AddCocktailService addCocktailService; - - @BeforeEach - void setup() { - saveCocktailPort = mock(SaveCocktailPort.class); - addCocktailService = new AddCocktailService(saveCocktailPort); - } - - @Test - void whenAddingACocktail_thenTheCocktailIsSaved() { - AddCocktailCommand command = mock(AddCocktailCommand.class); - when(command.getName()).thenReturn("mockito"); - when(command.getPrice()).thenReturn(9.50); - ArgumentCaptor captor = ArgumentCaptor.forClass(Cocktail.class); - - addCocktailService.addCocktail(command); - - Mockito.verify(saveCocktailPort).saveCocktail(captor.capture()); - Cocktail cocktailThatSaved = captor.getValue(); - assertEquals(command.getName(), cocktailThatSaved.getName()); - assertEquals(command.getPrice(), cocktailThatSaved.getPrice()); - } - -} diff --git a/patterns/hexagonal-architecture-example/src/test/java/com/baeldung/hexagonal/architecture/example/application/GetCocktailsUnitTest.java b/patterns/hexagonal-architecture-example/src/test/java/com/baeldung/hexagonal/architecture/example/application/GetCocktailsUnitTest.java deleted file mode 100644 index 5933f71895..0000000000 --- a/patterns/hexagonal-architecture-example/src/test/java/com/baeldung/hexagonal/architecture/example/application/GetCocktailsUnitTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.baeldung.hexagonal.architecture.example.application; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.List; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import com.baeldung.hexagonal.architecture.example.application.domain.Cocktail; -import com.baeldung.hexagonal.architecture.example.application.ports.out.FetchCocktailsPort; -import com.baeldung.hexagonal.architecture.example.application.service.GetCocktailsService; - -class GetCocktailsUnitTest { - - FetchCocktailsPort fetchCocktailsPort; - GetCocktailsService getCocktailsService; - - @BeforeEach - void setup() { - fetchCocktailsPort = mock(FetchCocktailsPort.class); - getCocktailsService = new GetCocktailsService(fetchCocktailsPort); - } - - @Test - void whenGettingCocktails_thenCocktailsFetchedFromPortAndReturned() { - Cocktail cocktail = mock(Cocktail.class); - when(cocktail.getName()).thenReturn("zombie"); - when(cocktail.getPrice()).thenReturn(12.00); - when(fetchCocktailsPort.fetchCocktails()).thenReturn(List.of(cocktail)); - - List cocktails = getCocktailsService.getCocktails(); - - assertEquals(1, cocktails.size()); - assertEquals(cocktail.getName(), cocktails.get(0).getName()); - assertEquals(cocktail.getPrice(), cocktails.get(0).getPrice()); - } - -} From 9b5b41a1c6c66d9695e24a497b7b37970f5fae73 Mon Sep 17 00:00:00 2001 From: kkaravitis Date: Tue, 17 Mar 2020 15:57:00 +0200 Subject: [PATCH 028/503] Removed evaluation article code --- patterns/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/patterns/pom.xml b/patterns/pom.xml index 7631d8bbb0..4c17055231 100644 --- a/patterns/pom.xml +++ b/patterns/pom.xml @@ -24,7 +24,6 @@ front-controller intercepting-filter solid - hexagonal-architecture-example From 159370411205f46ecbe50ad765c9efb586c1d65d Mon Sep 17 00:00:00 2001 From: Greg Martin Date: Tue, 17 Mar 2020 09:58:23 -0400 Subject: [PATCH 029/503] Added dependencies and plugins for NullAway example --- libraries-3/pom.xml | 57 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/libraries-3/pom.xml b/libraries-3/pom.xml index a438d423e2..dbe6dd194f 100644 --- a/libraries-3/pom.xml +++ b/libraries-3/pom.xml @@ -104,6 +104,23 @@ velocity-engine-core ${velocity-engine-core.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 + @@ -139,6 +156,46 @@ ${aspectjweaver.version} + + + + 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 + + From e58683f48b092fc1cf9f28a0dd86050edc0dca32 Mon Sep 17 00:00:00 2001 From: mike b Date: Tue, 17 Mar 2020 10:06:34 -0400 Subject: [PATCH 030/503] [BAEL-3646] Addressing PR comments --- spring-batch/repository.sqlite | Bin 49152 -> 73728 bytes .../ConditionalFlowApplication.java | 5 +- .../conditionalflow/NumberInfoDecider.java | 18 +++- .../config/NumberInfoConfig.java | 86 ++++++++++-------- .../conditionalflow/model/NumberInfo.java | 18 ++-- .../conditionalflow/step/NotifierTasklet.java | 3 +- .../step/NumberInfoClassifier.java | 9 +- .../step/NumberInfoClassifierWithDecider.java | 8 +- .../step/NumberInfoGenerator.java | 4 +- .../step/NumberInfoProcessor.java | 17 ---- .../step/PrependingStdoutWriter.java | 9 +- .../DeciderJobIntegrationTest.java | 56 ++++++++++++ .../model/NumberInfoUnitTest.java | 77 +++++++++++----- .../step/NumberInfoClassifierUnitTest.java | 9 +- .../step/NumberInfoGeneratorUnitTest.java | 8 +- spring-batch/xml/retryOutput.xml | 2 +- 16 files changed, 208 insertions(+), 121 deletions(-) delete mode 100644 spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoProcessor.java create mode 100644 spring-batch/src/test/java/org/baeldung/conditionalflow/DeciderJobIntegrationTest.java diff --git a/spring-batch/repository.sqlite b/spring-batch/repository.sqlite index 4456ef63cc28948e07a545a72ec1b63366e9057b..9d260fa2d1eed9ab00ea099508119d8e44235d87 100644 GIT binary patch literal 73728 zcmeHQTWlLwdY<7$7h4MBWH+ko79J?hio!~>oZ(e8vRj%O*^DVtA*tBfG*CywLx~Z^ z;SPtE)5Si->$X7q)FuV`)YpA)Q51dZLkqNvw&|h|?Mol_ae=l#7gz+@Z6ErdGsEEw zIlL&byRrS#=4f~>|2gM7*Z*?PslHuonnY;m#+hmgaqeY~=egey1dih`a~$^yeES~_ zUPApJ@RxVJk9h?eB7d+P`HZ_9Y;Z3XU;5L?pD(>}>0tg3=F*}62)!5l7jVW8BJi9e z@c#1r%Gw(L;j5;4)FQWXwfvpKx5~E;tIFG+AItfQlB+2~EqAM^2p%sXDipSbLaCmgZM(-sC@A8%j*MujKb@g>uQ8tjBq2 zOa?rGX3xsy%kwL5zR7>M?#fEFrtBSh=vn0)b-(PBnbA-)=jKu2()>z3&p*EE$_=fB zL1yx0!1sP_0Q`v8C7(R`(tvDv-Cea;D%XV4ezEAT#tor*r(CHW+F20Z$yM@qa+Ro@ zjK$W4ehdhuR0_Fb;oHi#6Et5e-x4+iO>cKiLv6NAC*{L@?f&7;T{^sz=5bp%B_9aU z;cTr725At3v^COowK=EgJ`vU*y}dZUqA2|1H(Xc_)r|*Cf4@Z^H2p&YoI@V}pLjY+ z`vU6tTD_~V?SrT{Ow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pn zIjY~3$;@){#QtnPCPpR(uwi^B82C;AmF~l#v=|ucKN$FbK-?a{F2u&j!XU^{U5juE SREis6DA0NQe_+BaAiDrUiJ;X0 diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/ConditionalFlowApplication.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/ConditionalFlowApplication.java index 8b6c841b6e..c977d6ecab 100644 --- a/spring-batch/src/main/java/org/baeldung/conditionalflow/ConditionalFlowApplication.java +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/ConditionalFlowApplication.java @@ -1,11 +1,14 @@ package org.baeldung.conditionalflow; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class ConditionalFlowApplication implements CommandLineRunner { + private static Logger logger = LoggerFactory.getLogger(ConditionalFlowApplication.class); public static void main(String[] args) { SpringApplication.run(ConditionalFlowApplication.class, args); @@ -13,6 +16,6 @@ public class ConditionalFlowApplication implements CommandLineRunner { @Override public void run(String... args) throws Exception { - System.out.println("Running and exiting"); + logger.info("Running conditional flow application..."); } } diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/NumberInfoDecider.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/NumberInfoDecider.java index 017980f1a4..701011b4d3 100644 --- a/spring-batch/src/main/java/org/baeldung/conditionalflow/NumberInfoDecider.java +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/NumberInfoDecider.java @@ -1,6 +1,5 @@ package org.baeldung.conditionalflow; -import org.springframework.batch.core.ExitStatus; import org.springframework.batch.core.JobExecution; import org.springframework.batch.core.StepExecution; import org.springframework.batch.core.job.flow.FlowExecutionStatus; @@ -8,12 +7,23 @@ import org.springframework.batch.core.job.flow.JobExecutionDecider; public class NumberInfoDecider implements JobExecutionDecider { + public static final String NOTIFY = "NOTIFY"; + public static final String QUIET = "QUIET"; + + /** + * Method that determines notification status of job + * @return true if notifications should be sent. + */ + private boolean shouldNotify() { + return true; + } + @Override public FlowExecutionStatus decide(JobExecution jobExecution, StepExecution stepExecution) { - if(jobExecution.getExitStatus().equals("UNKNOWN")) { - return new FlowExecutionStatus("NOTIFY"); + if (shouldNotify()) { + return new FlowExecutionStatus(NOTIFY); } else { - return null; + return new FlowExecutionStatus(QUIET); } } } diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/config/NumberInfoConfig.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/config/NumberInfoConfig.java index fd28c2291f..906a6e1d28 100644 --- a/spring-batch/src/main/java/org/baeldung/conditionalflow/config/NumberInfoConfig.java +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/config/NumberInfoConfig.java @@ -11,6 +11,9 @@ import org.springframework.batch.core.configuration.annotation.StepBuilderFactor import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; + +import static org.baeldung.conditionalflow.NumberInfoDecider.NOTIFY; @Configuration @EnableBatchProcessing @@ -19,67 +22,70 @@ public class NumberInfoConfig { @Bean @Qualifier("NotificationStep") public Step notificationStep(StepBuilderFactory sbf) { - return sbf.get("Billing step").tasklet(new NotifierTasklet()).build(); + return sbf.get("Notify step") + .tasklet(new NotifierTasklet()) + .build(); } public Step numberGeneratorStep(StepBuilderFactory sbf, int[] values, String prepend) { return sbf.get("Number generator") - .chunk(1) - .reader(new NumberInfoGenerator(values)) - .processor(new NumberInfoClassifier()) - .writer(new PrependingStdoutWriter<>(prepend)) - .build(); + . chunk(1) + .reader(new NumberInfoGenerator(values)) + .processor(new NumberInfoClassifier()) + .writer(new PrependingStdoutWriter<>(prepend)) + .build(); } public Step numberGeneratorStepDecider(StepBuilderFactory sbf, int[] values, String prepend) { - return sbf.get("Number generator") - .chunk(1) - .reader(new NumberInfoGenerator(values)) - .processor(new NumberInfoClassifierWithDecider()) - .writer(new PrependingStdoutWriter<>(prepend)) - .build(); + return sbf.get("Number generator decider") + . chunk(1) + .reader(new NumberInfoGenerator(values)) + .processor(new NumberInfoClassifierWithDecider()) + .writer(new PrependingStdoutWriter<>(prepend)) + .build(); } @Bean - public Job numberGeneratorNonNotifierJob(JobBuilderFactory jobBuilderFactory, - StepBuilderFactory stepBuilderFactory, - @Qualifier("NotificationStep") Step notificationStep - ) { - int[] nonNotifierData = {-1, -2, -3}; + @Qualifier("first_job") + public Job numberGeneratorNonNotifierJob(JobBuilderFactory jobBuilderFactory, StepBuilderFactory stepBuilderFactory, @Qualifier("NotificationStep") Step notificationStep) { + int[] nonNotifierData = { -1, -2, -3 }; Step step = numberGeneratorStep(stepBuilderFactory, nonNotifierData, "First Dataset Processor"); return jobBuilderFactory.get("Number generator - first dataset") - .start(step) - .on("NOTIFY").to(notificationStep) - .from(step).on("*").stop() - .end() - .build(); + .start(step) + .on(NOTIFY) + .to(notificationStep) + .from(step) + .on("*") + .stop() + .end() + .build(); } @Bean - public Job numberGeneratorNotifierJob(JobBuilderFactory jobBuilderFactory, - StepBuilderFactory stepBuilderFactory, - @Qualifier("NotificationStep") Step notificationStep - ) { - int[] billableData = {11, -2, -3}; + @Qualifier("second_job") + public Job numberGeneratorNotifierJob(JobBuilderFactory jobBuilderFactory, StepBuilderFactory stepBuilderFactory, @Qualifier("NotificationStep") Step notificationStep) { + int[] billableData = { 11, -2, -3 }; Step dataProviderStep = numberGeneratorStep(stepBuilderFactory, billableData, "Second Dataset Processor"); return jobBuilderFactory.get("Number generator - second dataset") - .start(dataProviderStep) - .on("NOTIFY").to(notificationStep) - .end() - .build(); + .start(dataProviderStep) + .on(NOTIFY) + .to(notificationStep) + .end() + .build(); } @Bean - public Job numberGeneratorNotifierJobWithDecider(JobBuilderFactory jobBuilderFactory, - StepBuilderFactory stepBuilderFactory, - @Qualifier("NotificationStep") Step notificationStep - ) { - int[] billableData = {11, -2, -3}; + @Qualifier("third_job") + @Primary + public Job numberGeneratorNotifierJobWithDecider(JobBuilderFactory jobBuilderFactory, StepBuilderFactory stepBuilderFactory, @Qualifier("NotificationStep") Step notificationStep) { + int[] billableData = { 11, -2, -3 }; Step dataProviderStep = numberGeneratorStepDecider(stepBuilderFactory, billableData, "Third Dataset Processor"); return jobBuilderFactory.get("Number generator - third dataset") - .start(dataProviderStep) - .next(new NumberInfoDecider()).on("NOTIFY").to(notificationStep) - .end() - .build(); + .start(dataProviderStep) + .next(new NumberInfoDecider()) + .on(NOTIFY) + .to(notificationStep) + .end() + .build(); } } diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/model/NumberInfo.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/model/NumberInfo.java index 81bd67d2a1..4134974386 100644 --- a/spring-batch/src/main/java/org/baeldung/conditionalflow/model/NumberInfo.java +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/model/NumberInfo.java @@ -5,14 +5,14 @@ import java.util.Objects; public class NumberInfo { private int number; - public static NumberInfo from(int number){ - return new NumberInfo(number); - } - public NumberInfo(int number) { this.number = number; } + public static NumberInfo from(int number) { + return new NumberInfo(number); + } + public boolean isPositive() { return number > 0; } @@ -27,8 +27,10 @@ public class NumberInfo { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; NumberInfo that = (NumberInfo) o; return number == that.number; } @@ -40,8 +42,6 @@ public class NumberInfo { @Override public String toString() { - return "NumberInfo{" + - "number=" + number + - '}'; + return "NumberInfo{" + "number=" + number + '}'; } } \ No newline at end of file diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NotifierTasklet.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NotifierTasklet.java index 6a88edcbbe..0d1db66fe9 100644 --- a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NotifierTasklet.java +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NotifierTasklet.java @@ -8,7 +8,8 @@ import org.springframework.batch.repeat.RepeatStatus; public class NotifierTasklet implements Tasklet { @Override public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception { - System.err.println("[" + chunkContext.getStepContext().getJobName() + "] contains interesting data!!"); + System.err.println("[" + chunkContext.getStepContext() + .getJobName() + "] contains interesting data!!"); return RepeatStatus.FINISHED; } } diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifier.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifier.java index 95b1e4d155..e9bc852d56 100644 --- a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifier.java +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifier.java @@ -7,20 +7,23 @@ import org.springframework.batch.core.annotation.BeforeStep; import org.springframework.batch.core.listener.ItemListenerSupport; import org.springframework.batch.item.ItemProcessor; -public class NumberInfoClassifier extends ItemListenerSupport - implements ItemProcessor { +import static org.baeldung.conditionalflow.NumberInfoDecider.NOTIFY; +import static org.baeldung.conditionalflow.NumberInfoDecider.QUIET; + +public class NumberInfoClassifier extends ItemListenerSupport implements ItemProcessor { private StepExecution stepExecution; @BeforeStep public void beforeStep(StepExecution stepExecution) { this.stepExecution = stepExecution; + this.stepExecution.setExitStatus(new ExitStatus(QUIET)); } @Override public void afterProcess(NumberInfo item, Integer result) { super.afterProcess(item, result); if (item.isPositive()) { - stepExecution.setExitStatus(new ExitStatus("NOTIFY")); + stepExecution.setExitStatus(new ExitStatus(NOTIFY)); } } diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifierWithDecider.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifierWithDecider.java index 0ba7fde279..ab6e33aec1 100644 --- a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifierWithDecider.java +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifierWithDecider.java @@ -1,15 +1,17 @@ package org.baeldung.conditionalflow.step; import org.baeldung.conditionalflow.model.NumberInfo; +import org.springframework.batch.core.ExitStatus; import org.springframework.batch.core.StepExecution; +import org.springframework.batch.core.annotation.BeforeStep; +import org.springframework.batch.core.listener.ItemListenerSupport; import org.springframework.batch.item.ItemProcessor; -public class NumberInfoClassifierWithDecider - implements ItemProcessor { - private StepExecution stepExecution; +public class NumberInfoClassifierWithDecider extends ItemListenerSupport implements ItemProcessor { @Override public Integer process(NumberInfo numberInfo) throws Exception { return Integer.valueOf(numberInfo.getNumber()); } + } diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoGenerator.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoGenerator.java index 35f6c39778..606ebf6204 100644 --- a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoGenerator.java +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoGenerator.java @@ -7,14 +7,14 @@ public class NumberInfoGenerator implements ItemReader { private int[] values; private int counter; - public NumberInfoGenerator(int[] values){ + public NumberInfoGenerator(int[] values) { this.values = values; counter = 0; } @Override public NumberInfo read() { - if(counter == values.length){ + if (counter == values.length) { return null; } else { return new NumberInfo(values[counter++]); diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoProcessor.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoProcessor.java deleted file mode 100644 index fe566221de..0000000000 --- a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoProcessor.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.baeldung.conditionalflow.step; - -import org.baeldung.conditionalflow.model.NumberInfo; -import org.springframework.batch.core.ExitStatus; -import org.springframework.batch.core.StepExecution; -import org.springframework.batch.core.annotation.BeforeStep; -import org.springframework.batch.core.listener.ItemListenerSupport; -import org.springframework.batch.item.ItemProcessor; - -public class NumberInfoProcessor implements ItemProcessor { - private StepExecution stepExecution; - - @Override - public Integer process(NumberInfo numberInfo) throws Exception { - return Integer.valueOf(numberInfo.getNumber()); - } -} diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java index 8b8959d249..283b43f267 100644 --- a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java @@ -1,18 +1,15 @@ package org.baeldung.conditionalflow.step; -import org.springframework.batch.item.ItemWriter; - import java.io.OutputStream; import java.util.List; +import org.springframework.batch.item.ItemWriter; + public class PrependingStdoutWriter implements ItemWriter { private String prependText; private OutputStream writeTo; - private PrependingStdoutWriter() { - } - - public PrependingStdoutWriter(String prependText, OutputStream os){ + public PrependingStdoutWriter(String prependText, OutputStream os) { this.prependText = prependText; this.writeTo = os; } diff --git a/spring-batch/src/test/java/org/baeldung/conditionalflow/DeciderJobIntegrationTest.java b/spring-batch/src/test/java/org/baeldung/conditionalflow/DeciderJobIntegrationTest.java new file mode 100644 index 0000000000..8669264848 --- /dev/null +++ b/spring-batch/src/test/java/org/baeldung/conditionalflow/DeciderJobIntegrationTest.java @@ -0,0 +1,56 @@ +package org.baeldung.conditionalflow; + +import org.baeldung.conditionalflow.config.NumberInfoConfig; +import org.junit.After; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.batch.core.ExitStatus; +import org.springframework.batch.core.JobExecution; +import org.springframework.batch.core.StepExecution; +import org.springframework.batch.test.AssertFile; +import org.springframework.batch.test.JobLauncherTestUtils; +import org.springframework.batch.test.JobRepositoryTestUtils; +import org.springframework.batch.test.context.SpringBatchTest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestExecutionListeners; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; +import org.springframework.test.context.support.DirtiesContextTestExecutionListener; + +import java.util.Collection; +import java.util.Iterator; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +@RunWith(SpringRunner.class) +@SpringBatchTest +@EnableAutoConfiguration +@ContextConfiguration(classes = { NumberInfoConfig.class }) +@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class }) +@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS) +public class DeciderJobIntegrationTest { + @Autowired + private JobLauncherTestUtils jobLauncherTestUtils; + + @Test + public void whenNumberGeneratorDecider_thenNotifyStepRuns() throws Exception { + JobExecution jobExecution = jobLauncherTestUtils.launchJob(); + Collection actualStepExecutions = jobExecution.getStepExecutions(); + ExitStatus actualJobExitStatus = jobExecution.getExitStatus(); + + assertEquals(actualJobExitStatus.getExitCode().toString(), "COMPLETED"); + assertEquals(actualStepExecutions.size(), 2); + boolean notifyStepDidRun = false; + Iterator iterator = actualStepExecutions.iterator(); + while(iterator.hasNext() && !notifyStepDidRun){ + if(iterator.next().getStepName().equals("Notify step")){ + notifyStepDidRun = true; + } + } + assertTrue(notifyStepDidRun); + } +} diff --git a/spring-batch/src/test/java/org/baeldung/conditionalflow/model/NumberInfoUnitTest.java b/spring-batch/src/test/java/org/baeldung/conditionalflow/model/NumberInfoUnitTest.java index cf3d361412..26cd286409 100644 --- a/spring-batch/src/test/java/org/baeldung/conditionalflow/model/NumberInfoUnitTest.java +++ b/spring-batch/src/test/java/org/baeldung/conditionalflow/model/NumberInfoUnitTest.java @@ -1,44 +1,71 @@ package org.baeldung.conditionalflow.model; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import static org.junit.jupiter.api.Assertions.*; - @RunWith(SpringJUnit4ClassRunner.class) class NumberInfoUnitTest { @Test - void isPositive() { - assertTrue(NumberInfo.from(1).isPositive()); - assertTrue(NumberInfo.from(11).isPositive()); - assertFalse(NumberInfo.from(0).isPositive()); - assertFalse(NumberInfo.from(-1).isPositive()); - assertFalse(NumberInfo.from(-10).isPositive()); + void whenPositive_isPositive() { + assertTrue(NumberInfo.from(1) + .isPositive()); + assertTrue(NumberInfo.from(11) + .isPositive()); + assertFalse(NumberInfo.from(0) + .isPositive()); } @Test - void isEven() { - assertTrue(NumberInfo.from(0).isEven()); - assertTrue(NumberInfo.from(-2).isEven()); - assertTrue(NumberInfo.from(2).isEven()); - assertTrue(NumberInfo.from(-22).isEven()); - assertTrue(NumberInfo.from(22).isEven()); - - assertFalse(NumberInfo.from(1).isEven()); - assertFalse(NumberInfo.from(-1).isEven()); - - assertFalse(NumberInfo.from(13).isEven()); - assertFalse(NumberInfo.from(-13).isEven()); - assertFalse(NumberInfo.from(31).isEven()); - assertFalse(NumberInfo.from(-51).isEven()); + void whenNegative_isPositive_isFalse() { + assertFalse(NumberInfo.from(-1) + .isPositive()); + assertFalse(NumberInfo.from(-10) + .isPositive()); } @Test - void getNumber() { - for(int i = -100 ; i < 100 ; i++){ - assertEquals(i, NumberInfo.from(i).getNumber()); + void whenEven_isEven() { + assertTrue(NumberInfo.from(0) + .isEven()); + assertTrue(NumberInfo.from(-2) + .isEven()); + assertTrue(NumberInfo.from(2) + .isEven()); + assertTrue(NumberInfo.from(-22) + .isEven()); + assertTrue(NumberInfo.from(22) + .isEven()); + } + + @Test + void whenOdd_isEven_isFalse() { + + assertFalse(NumberInfo.from(1) + .isEven()); + assertFalse(NumberInfo.from(-1) + .isEven()); + + assertFalse(NumberInfo.from(13) + .isEven()); + assertFalse(NumberInfo.from(-13) + .isEven()); + assertFalse(NumberInfo.from(31) + .isEven()); + assertFalse(NumberInfo.from(-51) + .isEven()); + } + + @Test + void testStatic_fromMethod_equals_getNumber() { + for (int i = -100; i < 100; i++) { + assertEquals(i, NumberInfo.from(i) + .getNumber()); } } } \ No newline at end of file diff --git a/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoClassifierUnitTest.java b/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoClassifierUnitTest.java index c195740caa..9b490799db 100644 --- a/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoClassifierUnitTest.java +++ b/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoClassifierUnitTest.java @@ -1,15 +1,14 @@ package org.baeldung.conditionalflow.step; -import org.baeldung.conditionalflow.model.NumberInfo; -import org.baeldung.conditionalflow.step.NumberInfoClassifier; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.*; +import org.baeldung.conditionalflow.model.NumberInfo; +import org.junit.jupiter.api.Test; class NumberInfoClassifierUnitTest { @Test - void process() throws Exception { + void process_convertsToInteger() throws Exception { NumberInfoClassifier nic = new NumberInfoClassifier(); assertEquals(Integer.valueOf(4), nic.process(NumberInfo.from(4))); assertEquals(Integer.valueOf(-4), nic.process(NumberInfo.from(-4))); diff --git a/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoGeneratorUnitTest.java b/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoGeneratorUnitTest.java index 3fc240bcbf..7794003959 100644 --- a/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoGeneratorUnitTest.java +++ b/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoGeneratorUnitTest.java @@ -1,14 +1,14 @@ package org.baeldung.conditionalflow.step; -import org.baeldung.conditionalflow.model.NumberInfo; -import org.junit.jupiter.api.Test; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; +import org.baeldung.conditionalflow.model.NumberInfo; +import org.junit.jupiter.api.Test; + public class NumberInfoGeneratorUnitTest { @Test - public void testGenerateNumbers() { + public void testGenerateNumbers_correctOrderAndValue() { int[] numbers = new int[]{1, -2, 4, -10}; NumberInfoGenerator numberGenerator = new NumberInfoGenerator(numbers); assertEquals(new NumberInfo(numbers[0]), numberGenerator.read()); diff --git a/spring-batch/xml/retryOutput.xml b/spring-batch/xml/retryOutput.xml index d30f2c4a32..c5dec44f16 100644 --- a/spring-batch/xml/retryOutput.xml +++ b/spring-batch/xml/retryOutput.xml @@ -1 +1 @@ -1010000.04302222015-10-31 00:00:001234sammy1012321.04302222015-12-03 00:00:009999john \ No newline at end of file + \ No newline at end of file From 5861ebd6337f574226da2fcadb878401d9da4635 Mon Sep 17 00:00:00 2001 From: Greg Date: Tue, 17 Mar 2020 10:47:54 -0400 Subject: [PATCH 031/503] Update pom.xml --- libraries-3/pom.xml | 86 ++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/libraries-3/pom.xml b/libraries-3/pom.xml index dbe6dd194f..fe007dfc4d 100644 --- a/libraries-3/pom.xml +++ b/libraries-3/pom.xml @@ -104,23 +104,23 @@ velocity-engine-core ${velocity-engine-core.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 - + + 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 + @@ -158,32 +158,32 @@ - - 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.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 From 97885bd06ef5134b7bae19d57f76a7933ef532b7 Mon Sep 17 00:00:00 2001 From: piuserre Date: Wed, 18 Mar 2020 16:27:58 +0100 Subject: [PATCH 032/503] fix launch run command --- spring-jenkins-pipeline/scripted-pipeline-unix-nonunix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-jenkins-pipeline/scripted-pipeline-unix-nonunix b/spring-jenkins-pipeline/scripted-pipeline-unix-nonunix index b76bb8a81a..871fee4ccb 100644 --- a/spring-jenkins-pipeline/scripted-pipeline-unix-nonunix +++ b/spring-jenkins-pipeline/scripted-pipeline-unix-nonunix @@ -72,7 +72,7 @@ node { if (isUnix()) { sh 'nohup ./mvnw spring-boot:run -Dserver.port=8989 &' } else { - bat 'start ./mvnw.cmd spring-boot:run -Dserver.port=8989' + bat 'start mvnw.cmd spring-boot:run -Dserver.port=8989' } } } From f95c25d461a4abdb3e303404e7e8f965990d0c02 Mon Sep 17 00:00:00 2001 From: Greg Martin Date: Wed, 18 Mar 2020 16:01:52 -0400 Subject: [PATCH 033/503] Added com.baeldung.distinct.Person to libraries-3 --- .../java/com/baeldung/distinct/Person.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 libraries-3/src/main/java/com/baeldung/distinct/Person.java diff --git a/libraries-3/src/main/java/com/baeldung/distinct/Person.java b/libraries-3/src/main/java/com/baeldung/distinct/Person.java new file mode 100644 index 0000000000..8a2a5f7a45 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/distinct/Person.java @@ -0,0 +1,65 @@ +package com.baeldung.distinct; + +public class Person { + int age; + String name; + String email; + + public Person(int age, String name, String email) { + super(); + this.age = age; + this.name = name; + this.email = email; + } + + public int getAge() { + return age; + } + + public String getName() { + return name; + } + + public String getEmail() { + return email; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Person [age="); + builder.append(age); + builder.append(", name="); + builder.append(name); + builder.append(", email="); + builder.append(email); + builder.append("]"); + return builder.toString(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((email == null) ? 0 : email.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Person other = (Person) obj; + if (email == null) { + if (other.email != null) + return false; + } else if (!email.equals(other.email)) + return false; + return true; + } + +} From 4cd3cc23361cc1d9f70a4179a8050c8cb7b49bf6 Mon Sep 17 00:00:00 2001 From: Greg Martin Date: Thu, 19 Mar 2020 07:04:24 -0400 Subject: [PATCH 034/503] Updated error_prone_core version to 2.3.4. --- libraries-3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries-3/pom.xml b/libraries-3/pom.xml index fe007dfc4d..5c373b88dc 100644 --- a/libraries-3/pom.xml +++ b/libraries-3/pom.xml @@ -193,7 +193,7 @@ com.google.errorprone error_prone_core - 2.1.3 + 2.3.4 From d16ed66dcc3e7e03ad7f5a225f25d5b4f606b6bf Mon Sep 17 00:00:00 2001 From: Greg Martin Date: Thu, 19 Mar 2020 09:18:23 -0400 Subject: [PATCH 035/503] Updated pom to tell errorprone to excluude the jcabi directory. --- libraries-3/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries-3/pom.xml b/libraries-3/pom.xml index 5c373b88dc..8e0a93c982 100644 --- a/libraries-3/pom.xml +++ b/libraries-3/pom.xml @@ -178,7 +178,7 @@ - -XepExcludedPaths:(.*)/test/.*|(.*)/streamex/.* + -XepExcludedPaths:(.*)/test/.*|(.*)/streamex/.*|(.*)/jcabi/.* -XepOpt:NullAway:AnnotatedPackages=com.baeldung.nullaway From d23c8aa41de79a1b06854821e30afc8d0cee8f7d Mon Sep 17 00:00:00 2001 From: kkaravitis Date: Thu, 19 Mar 2020 22:28:55 +0200 Subject: [PATCH 036/503] [BAEL-3913] Initial commit for prevent commandline application runner execution during JUnit test article --- .../spring-boot-testing/README.md | 1 + .../ApplicationCommandLineRunnerApp.java | 11 +++++ .../ApplicationRunnerTaskExecutor.java | 26 +++++++++++ .../execution/CommandLineTaskExecutor.java | 25 +++++++++++ .../runner/execution/TaskService.java | 14 ++++++ .../LoadSpringContextIntegrationTest.java | 44 +++++++++++++++++++ .../RunApplicationIntegrationTest.java | 26 +++++++++++ ...icationWithTestProfileIntegrationTest.java | 33 ++++++++++++++ ...tionWithTestPropertiesIntegrationTest.java | 34 ++++++++++++++ 9 files changed, 214 insertions(+) create mode 100644 spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/ApplicationCommandLineRunnerApp.java create mode 100644 spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/ApplicationRunnerTaskExecutor.java create mode 100644 spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/CommandLineTaskExecutor.java create mode 100644 spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/TaskService.java create mode 100644 spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestProfileIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestPropertiesIntegrationTest.java diff --git a/spring-boot-modules/spring-boot-testing/README.md b/spring-boot-modules/spring-boot-testing/README.md index 0b2533e6bc..b033826541 100644 --- a/spring-boot-modules/spring-boot-testing/README.md +++ b/spring-boot-modules/spring-boot-testing/README.md @@ -12,3 +12,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Exclude Auto-Configuration Classes in Spring Boot Tests](https://www.baeldung.com/spring-boot-exclude-auto-configuration-test) - [Setting the Log Level in Spring Boot when Testing](https://www.baeldung.com/spring-boot-testing-log-level) - [Embedded Redis Server with Spring Boot Test](https://www.baeldung.com/spring-embedded-redis) +- [Prevent ApplicationRunner or CommandLineRunner Beans From Executing During Junit Testing]() diff --git a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/ApplicationCommandLineRunnerApp.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/ApplicationCommandLineRunnerApp.java new file mode 100644 index 0000000000..76e18dfd2f --- /dev/null +++ b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/ApplicationCommandLineRunnerApp.java @@ -0,0 +1,11 @@ +package com.baeldung.prevent.commandline.application.runner.execution; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ApplicationCommandLineRunnerApp { + public static void main(String[] args) { + SpringApplication.run(ApplicationCommandLineRunnerApp.class, args); + } +} diff --git a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/ApplicationRunnerTaskExecutor.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/ApplicationRunnerTaskExecutor.java new file mode 100644 index 0000000000..98d4654d25 --- /dev/null +++ b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/ApplicationRunnerTaskExecutor.java @@ -0,0 +1,26 @@ +package com.baeldung.prevent.commandline.application.runner.execution; + +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Component; + +@Profile("!test") +@ConditionalOnProperty(prefix = "application.runner", + value = "enabled", + havingValue = "true", + matchIfMissing = true) +@Component +public class ApplicationRunnerTaskExecutor implements ApplicationRunner { + private TaskService taskService; + + public ApplicationRunnerTaskExecutor(TaskService taskService) { + this.taskService = taskService; + } + + @Override + public void run(ApplicationArguments args) throws Exception { + taskService.execute("application runner task"); + } +} diff --git a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/CommandLineTaskExecutor.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/CommandLineTaskExecutor.java new file mode 100644 index 0000000000..4a77d78429 --- /dev/null +++ b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/CommandLineTaskExecutor.java @@ -0,0 +1,25 @@ +package com.baeldung.prevent.commandline.application.runner.execution; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Component; + +@Profile("!test") +@ConditionalOnProperty(prefix = "command.line.runner", + value = "enabled", + havingValue = "true", + matchIfMissing = true) +@Component +public class CommandLineTaskExecutor implements CommandLineRunner { + private TaskService taskService; + + public CommandLineTaskExecutor(TaskService taskService) { + this.taskService = taskService; + } + + @Override + public void run(String... args) throws Exception { + taskService.execute("command line runner task"); + } +} diff --git a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/TaskService.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/TaskService.java new file mode 100644 index 0000000000..dac437e72d --- /dev/null +++ b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/TaskService.java @@ -0,0 +1,14 @@ +package com.baeldung.prevent.commandline.application.runner.execution; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +@Service +public class TaskService { + private static Logger logger = LoggerFactory.getLogger(TaskService.class); + + public void execute(String task) { + logger.info("do " + task); + } +} diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java new file mode 100644 index 0000000000..911b16615d --- /dev/null +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java @@ -0,0 +1,44 @@ +package com.baeldung.prevent.commandline.application.runner.execution; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springframework.boot.ApplicationRunner; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer; +import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit.jupiter.SpringExtension; + +import com.baeldung.prevent.commandline.application.runner.execution.ApplicationCommandLineRunnerApp; +import com.baeldung.prevent.commandline.application.runner.execution.TaskService; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +@ExtendWith(SpringExtension.class) +@ContextConfiguration(classes = {ApplicationCommandLineRunnerApp.class}, + initializers = ConfigFileApplicationContextInitializer.class) +public class LoadSpringContextIntegrationTest { + @SpyBean + TaskService taskService; + + @SpyBean + CommandLineRunner commandLineRunner; + + @SpyBean + ApplicationRunner applicationRunner; + + @Test + void whenContextLoads_thenAllBeansAreLoadedButCommandLineAndApplicationRunnerAreNotExecuted() + throws Exception { + assertNotNull(taskService); + assertNotNull(commandLineRunner); + assertNotNull(applicationRunner); + + verify(taskService, times(0)).execute(any()); + verify(commandLineRunner, times(0)).run(any()); + verify(applicationRunner, times(0)).run(any()); + } +} diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationIntegrationTest.java new file mode 100644 index 0000000000..d732bc5260 --- /dev/null +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationIntegrationTest.java @@ -0,0 +1,26 @@ +package com.baeldung.prevent.commandline.application.runner.execution; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.SpyBean; + +import com.baeldung.prevent.commandline.application.runner.execution.ApplicationRunnerTaskExecutor; +import com.baeldung.prevent.commandline.application.runner.execution.CommandLineTaskExecutor; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +@SpringBootTest +class RunApplicationIntegrationTest { + @SpyBean + ApplicationRunnerTaskExecutor applicationRunnerTaskExecutor; + @SpyBean + CommandLineTaskExecutor commandLineTaskExecutor; + + @Test + void whenContextLoads_thenTheCommandLineAndApplicationRunnerAreExecuted() throws Exception { + verify(applicationRunnerTaskExecutor, times(1)).run(any()); + verify(commandLineTaskExecutor, times(1)).run(any()); + } +} diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestProfileIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestProfileIntegrationTest.java new file mode 100644 index 0000000000..b5e09077c6 --- /dev/null +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestProfileIntegrationTest.java @@ -0,0 +1,33 @@ +package com.baeldung.prevent.commandline.application.runner.execution; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; +import org.springframework.test.context.ActiveProfiles; + +import com.baeldung.prevent.commandline.application.runner.execution.ApplicationRunnerTaskExecutor; +import com.baeldung.prevent.commandline.application.runner.execution.CommandLineTaskExecutor; +import com.baeldung.prevent.commandline.application.runner.execution.TaskService; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +@ActiveProfiles("test") +@SpringBootTest +class RunApplicationWithTestProfileIntegrationTest { + @Autowired + private ApplicationContext context; + + @Test + void whenContextLoads_thenTheCommandLineAndApplicationRunnerAreNotLoaded() { + assertNotNull(context.getBean(TaskService.class)); + assertThrows(NoSuchBeanDefinitionException.class, + () -> context.getBean(CommandLineTaskExecutor.class), + "CommandLineRunner should not be loaded during this integration test"); + assertThrows(NoSuchBeanDefinitionException.class, + () -> context.getBean(ApplicationRunnerTaskExecutor.class), + "ApplicationRunner should not be loaded during this integration test"); + } +} diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestPropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestPropertiesIntegrationTest.java new file mode 100644 index 0000000000..9ab8baec14 --- /dev/null +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestPropertiesIntegrationTest.java @@ -0,0 +1,34 @@ +package com.baeldung.prevent.commandline.application.runner.execution; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; + +import com.baeldung.prevent.commandline.application.runner.execution.ApplicationRunnerTaskExecutor; +import com.baeldung.prevent.commandline.application.runner.execution.CommandLineTaskExecutor; +import com.baeldung.prevent.commandline.application.runner.execution.TaskService; + +@SpringBootTest( + properties = { + "command.line.runner.enabled=false", + "application.runner.enabled=false" + }) +class RunApplicationWithTestPropertiesIntegrationTest { + @Autowired + private ApplicationContext context; + + @Test + void whenContextLoads_thenTheCommandLineAndApplicationRunnerAreNotLoaded() { + assertNotNull(context.getBean(TaskService.class)); + assertThrows(NoSuchBeanDefinitionException.class, + () -> context.getBean(CommandLineTaskExecutor.class), + "CommandLineRunner should not be loaded during this integration test"); + assertThrows(NoSuchBeanDefinitionException.class, + () -> context.getBean(ApplicationRunnerTaskExecutor.class), + "ApplicationRunner should not be loaded during this integration test"); + } +} From f953196ddfeecbe61b285a4f6d702cb86119fcab Mon Sep 17 00:00:00 2001 From: mike b Date: Thu, 19 Mar 2020 20:15:52 -0400 Subject: [PATCH 037/503] [BAEL-3646] Fixing tests per review comments --- .../step/NumberInfoClassifier.java | 3 ++- .../step/NumberInfoClassifierWithDecider.java | 1 - .../DeciderJobIntegrationTest.java | 16 ++++++++-------- .../model/NumberInfoUnitTest.java | 10 +++++----- .../step/NumberInfoClassifierUnitTest.java | 2 +- .../step/NumberInfoGeneratorUnitTest.java | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifier.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifier.java index e9bc852d56..fdb28263e7 100644 --- a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifier.java +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifier.java @@ -10,7 +10,8 @@ import org.springframework.batch.item.ItemProcessor; import static org.baeldung.conditionalflow.NumberInfoDecider.NOTIFY; import static org.baeldung.conditionalflow.NumberInfoDecider.QUIET; -public class NumberInfoClassifier extends ItemListenerSupport implements ItemProcessor { +public class NumberInfoClassifier extends ItemListenerSupport + implements ItemProcessor { private StepExecution stepExecution; @BeforeStep diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifierWithDecider.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifierWithDecider.java index ab6e33aec1..b9d251c02d 100644 --- a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifierWithDecider.java +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifierWithDecider.java @@ -13,5 +13,4 @@ public class NumberInfoClassifierWithDecider extends ItemListenerSupport actualStepExecutions = jobExecution.getStepExecutions(); ExitStatus actualJobExitStatus = jobExecution.getExitStatus(); - assertEquals(actualJobExitStatus.getExitCode().toString(), "COMPLETED"); - assertEquals(actualStepExecutions.size(), 2); + assertEquals("COMPLETED", actualJobExitStatus.getExitCode() + .toString()); + assertEquals(2, actualStepExecutions.size()); boolean notifyStepDidRun = false; Iterator iterator = actualStepExecutions.iterator(); - while(iterator.hasNext() && !notifyStepDidRun){ - if(iterator.next().getStepName().equals("Notify step")){ + while (iterator.hasNext() && !notifyStepDidRun) { + if (iterator.next() + .getStepName() + .equals("Notify step")) { notifyStepDidRun = true; } } diff --git a/spring-batch/src/test/java/org/baeldung/conditionalflow/model/NumberInfoUnitTest.java b/spring-batch/src/test/java/org/baeldung/conditionalflow/model/NumberInfoUnitTest.java index 26cd286409..dc396b38da 100644 --- a/spring-batch/src/test/java/org/baeldung/conditionalflow/model/NumberInfoUnitTest.java +++ b/spring-batch/src/test/java/org/baeldung/conditionalflow/model/NumberInfoUnitTest.java @@ -12,7 +12,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; class NumberInfoUnitTest { @Test - void whenPositive_isPositive() { + void givenPositive_whenFrom_isPositive() { assertTrue(NumberInfo.from(1) .isPositive()); assertTrue(NumberInfo.from(11) @@ -22,7 +22,7 @@ class NumberInfoUnitTest { } @Test - void whenNegative_isPositive_isFalse() { + void givenNegative_whenFrom_isNegative() { assertFalse(NumberInfo.from(-1) .isPositive()); assertFalse(NumberInfo.from(-10) @@ -30,7 +30,7 @@ class NumberInfoUnitTest { } @Test - void whenEven_isEven() { + void givenEven_whenFrom_isEven() { assertTrue(NumberInfo.from(0) .isEven()); assertTrue(NumberInfo.from(-2) @@ -44,7 +44,7 @@ class NumberInfoUnitTest { } @Test - void whenOdd_isEven_isFalse() { + void givenOdd_whenFrom_isOdd() { assertFalse(NumberInfo.from(1) .isEven()); @@ -62,7 +62,7 @@ class NumberInfoUnitTest { } @Test - void testStatic_fromMethod_equals_getNumber() { + void giveGeneratedInt_whenFrom_isNumberFromGenerator() { for (int i = -100; i < 100; i++) { assertEquals(i, NumberInfo.from(i) .getNumber()); diff --git a/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoClassifierUnitTest.java b/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoClassifierUnitTest.java index 9b490799db..cea0626168 100644 --- a/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoClassifierUnitTest.java +++ b/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoClassifierUnitTest.java @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test; class NumberInfoClassifierUnitTest { @Test - void process_convertsToInteger() throws Exception { + void givenNumberInfo_whenProcess_thenConvertsToInteger() throws Exception { NumberInfoClassifier nic = new NumberInfoClassifier(); assertEquals(Integer.valueOf(4), nic.process(NumberInfo.from(4))); assertEquals(Integer.valueOf(-4), nic.process(NumberInfo.from(-4))); diff --git a/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoGeneratorUnitTest.java b/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoGeneratorUnitTest.java index 7794003959..62fe35add6 100644 --- a/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoGeneratorUnitTest.java +++ b/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoGeneratorUnitTest.java @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test; public class NumberInfoGeneratorUnitTest { @Test - public void testGenerateNumbers_correctOrderAndValue() { + public void givenArray_whenGenerator_correctOrderAndValue() { int[] numbers = new int[]{1, -2, 4, -10}; NumberInfoGenerator numberGenerator = new NumberInfoGenerator(numbers); assertEquals(new NumberInfo(numbers[0]), numberGenerator.read()); From d3b35f9f0cfb9ef49366f3b7f9db10f891fb0f6d Mon Sep 17 00:00:00 2001 From: Eduard Ardeleanu Date: Fri, 20 Mar 2020 17:28:47 +0200 Subject: [PATCH 038/503] BAEL-3853: Helpful NPE in Java 14 --- .../HelpfulNullPointerException.java | 56 +++++++++++++++++++ .../HelpfulNullPointerExceptionUnitTest.java | 37 ++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 core-java-modules/core-java-14/src/main/java/com/baeldung/java14/helpfulnullpointerexceptions/HelpfulNullPointerException.java create mode 100644 core-java-modules/core-java-14/src/test/java/com/baeldung/java14/helpfulnullpointerexceptions/HelpfulNullPointerExceptionUnitTest.java diff --git a/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/helpfulnullpointerexceptions/HelpfulNullPointerException.java b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/helpfulnullpointerexceptions/HelpfulNullPointerException.java new file mode 100644 index 0000000000..ef5dbb754c --- /dev/null +++ b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/helpfulnullpointerexceptions/HelpfulNullPointerException.java @@ -0,0 +1,56 @@ +package com.baeldung.java14.helpfulnullpointerexceptions; + +public class HelpfulNullPointerException { + + public static void main(String[] args) { + Employee employee = null; + employee.getName(); + } + + public String getEmployeeEmailAddress(Employee employee) { + String emailAddress = employee.getPersonalDetails().getEmailAddress().toLowerCase(); + return emailAddress; + } + + static class Employee { + String name; + PersonalDetails personalDetails; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public PersonalDetails getPersonalDetails() { + return personalDetails; + } + + public void setPersonalDetails(PersonalDetails personalDetails) { + this.personalDetails = personalDetails; + } + } + + static class PersonalDetails { + String emailAddress; + String phone; + + public String getEmailAddress() { + return emailAddress; + } + + public void setEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + } +} diff --git a/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/helpfulnullpointerexceptions/HelpfulNullPointerExceptionUnitTest.java b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/helpfulnullpointerexceptions/HelpfulNullPointerExceptionUnitTest.java new file mode 100644 index 0000000000..fae331bb92 --- /dev/null +++ b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/helpfulnullpointerexceptions/HelpfulNullPointerExceptionUnitTest.java @@ -0,0 +1,37 @@ +package com.baeldung.java14.helpfulnullpointerexceptions; + +import org.junit.Test; + +import static com.baeldung.java14.helpfulnullpointerexceptions.HelpfulNullPointerException.Employee; +import static com.baeldung.java14.helpfulnullpointerexceptions.HelpfulNullPointerException.PersonalDetails; +import static org.assertj.core.api.Assertions.assertThat; + +public class HelpfulNullPointerExceptionUnitTest { + + @Test (expected = NullPointerException.class) + public void givenAnEmptyPersonalDetails_whenEmailAddressIsAccessed_thenThrowNPE() { + var helpfulNPE = new HelpfulNullPointerException(); + + var employee = new Employee(); + employee.setName("Eduard"); + employee.setPersonalDetails(new PersonalDetails()); + helpfulNPE.getEmployeeEmailAddress(employee); + } + + @Test + public void givenCompletePersonalDetails_whenEmailAddressIsAccessed_thenSuccess() { + var helpfulNPE = new HelpfulNullPointerException(); + var emailAddress = "eduard@gmx.com"; + + var employee = new Employee(); + employee.setName("Eduard"); + + var personalDetails = new PersonalDetails(); + personalDetails.setEmailAddress(emailAddress.toUpperCase()); + personalDetails.setPhone("1234"); + employee.setPersonalDetails(personalDetails); + + assertThat(helpfulNPE.getEmployeeEmailAddress(employee)).isEqualTo(emailAddress); + } + +} From 63bfa3706ad5739d42959458ec5fc51258154871 Mon Sep 17 00:00:00 2001 From: ajay74984 <51405689+ajay74984@users.noreply.github.com> Date: Sat, 21 Mar 2020 11:17:11 +0100 Subject: [PATCH 039/503] revert changes --- java-numbers-3/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/java-numbers-3/README.md b/java-numbers-3/README.md index a331a979ad..08e8dae8ef 100644 --- a/java-numbers-3/README.md +++ b/java-numbers-3/README.md @@ -2,4 +2,3 @@ - [Generating Random Numbers](https://www.baeldung.com/java-generating-random-numbers) - [Convert Double to Long in Java](https://www.baeldung.com/java-convert-double-long) -- [Guide to the Java Number Class](http://inprogress.baeldung.com/?p=180694&preview=true) From adf1ee9b0db6593d6480f350a6448994e193da89 Mon Sep 17 00:00:00 2001 From: kkaravitis Date: Sun, 22 Mar 2020 22:06:44 +0200 Subject: [PATCH 040/503] [BAEL-3913] Fixed broken lines format and reduced the test method names length --- .../ApplicationRunnerTaskExecutor.java | 9 ++++---- .../execution/CommandLineTaskExecutor.java | 9 ++++---- .../LoadSpringContextIntegrationTest.java | 7 +++--- .../RunApplicationIntegrationTest.java | 2 +- ...icationWithTestProfileIntegrationTest.java | 14 ++++++------ ...tionWithTestPropertiesIntegrationTest.java | 22 +++++++++---------- 6 files changed, 31 insertions(+), 32 deletions(-) diff --git a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/ApplicationRunnerTaskExecutor.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/ApplicationRunnerTaskExecutor.java index 98d4654d25..3bf08491bf 100644 --- a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/ApplicationRunnerTaskExecutor.java +++ b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/ApplicationRunnerTaskExecutor.java @@ -7,10 +7,11 @@ import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; @Profile("!test") -@ConditionalOnProperty(prefix = "application.runner", - value = "enabled", - havingValue = "true", - matchIfMissing = true) +@ConditionalOnProperty( + prefix = "application.runner", + value = "enabled", + havingValue = "true", + matchIfMissing = true) @Component public class ApplicationRunnerTaskExecutor implements ApplicationRunner { private TaskService taskService; diff --git a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/CommandLineTaskExecutor.java b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/CommandLineTaskExecutor.java index 4a77d78429..38fd3b9c0a 100644 --- a/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/CommandLineTaskExecutor.java +++ b/spring-boot-modules/spring-boot-testing/src/main/java/com/baeldung/prevent/commandline/application/runner/execution/CommandLineTaskExecutor.java @@ -6,10 +6,11 @@ import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; @Profile("!test") -@ConditionalOnProperty(prefix = "command.line.runner", - value = "enabled", - havingValue = "true", - matchIfMissing = true) +@ConditionalOnProperty( + prefix = "command.line.runner", + value = "enabled", + havingValue = "true", + matchIfMissing = true) @Component public class CommandLineTaskExecutor implements CommandLineRunner { private TaskService taskService; diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java index 911b16615d..c3922536b1 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java @@ -18,8 +18,8 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @ExtendWith(SpringExtension.class) -@ContextConfiguration(classes = {ApplicationCommandLineRunnerApp.class}, - initializers = ConfigFileApplicationContextInitializer.class) +@ContextConfiguration(classes = { ApplicationCommandLineRunnerApp.class }, + initializers = ConfigFileApplicationContextInitializer.class) public class LoadSpringContextIntegrationTest { @SpyBean TaskService taskService; @@ -31,8 +31,7 @@ public class LoadSpringContextIntegrationTest { ApplicationRunner applicationRunner; @Test - void whenContextLoads_thenAllBeansAreLoadedButCommandLineAndApplicationRunnerAreNotExecuted() - throws Exception { + void whenContextLoads_thenRunnersDoNotRun() throws Exception { assertNotNull(taskService); assertNotNull(commandLineRunner); assertNotNull(applicationRunner); diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationIntegrationTest.java index d732bc5260..26a7339f1d 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationIntegrationTest.java @@ -19,7 +19,7 @@ class RunApplicationIntegrationTest { CommandLineTaskExecutor commandLineTaskExecutor; @Test - void whenContextLoads_thenTheCommandLineAndApplicationRunnerAreExecuted() throws Exception { + void whenContextLoads_thenRunnersRun() throws Exception { verify(applicationRunnerTaskExecutor, times(1)).run(any()); verify(commandLineTaskExecutor, times(1)).run(any()); } diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestProfileIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestProfileIntegrationTest.java index b5e09077c6..333cd2ab91 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestProfileIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestProfileIntegrationTest.java @@ -21,13 +21,13 @@ class RunApplicationWithTestProfileIntegrationTest { private ApplicationContext context; @Test - void whenContextLoads_thenTheCommandLineAndApplicationRunnerAreNotLoaded() { + void whenContextLoads_thenRunnersAreNotLoaded() { assertNotNull(context.getBean(TaskService.class)); - assertThrows(NoSuchBeanDefinitionException.class, - () -> context.getBean(CommandLineTaskExecutor.class), - "CommandLineRunner should not be loaded during this integration test"); - assertThrows(NoSuchBeanDefinitionException.class, - () -> context.getBean(ApplicationRunnerTaskExecutor.class), - "ApplicationRunner should not be loaded during this integration test"); + assertThrows(NoSuchBeanDefinitionException.class, + () -> context.getBean(CommandLineTaskExecutor.class), + "CommandLineRunner should not be loaded during this integration test"); + assertThrows(NoSuchBeanDefinitionException.class, + () -> context.getBean(ApplicationRunnerTaskExecutor.class), + "ApplicationRunner should not be loaded during this integration test"); } } diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestPropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestPropertiesIntegrationTest.java index 9ab8baec14..264a06a41e 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestPropertiesIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/RunApplicationWithTestPropertiesIntegrationTest.java @@ -12,23 +12,21 @@ import com.baeldung.prevent.commandline.application.runner.execution.Application import com.baeldung.prevent.commandline.application.runner.execution.CommandLineTaskExecutor; import com.baeldung.prevent.commandline.application.runner.execution.TaskService; -@SpringBootTest( - properties = { - "command.line.runner.enabled=false", - "application.runner.enabled=false" - }) +@SpringBootTest(properties = { + "command.line.runner.enabled=false", + "application.runner.enabled=false" }) class RunApplicationWithTestPropertiesIntegrationTest { @Autowired private ApplicationContext context; @Test - void whenContextLoads_thenTheCommandLineAndApplicationRunnerAreNotLoaded() { + void whenContextLoads_thenRunnersAreNotLoaded() { assertNotNull(context.getBean(TaskService.class)); - assertThrows(NoSuchBeanDefinitionException.class, - () -> context.getBean(CommandLineTaskExecutor.class), - "CommandLineRunner should not be loaded during this integration test"); - assertThrows(NoSuchBeanDefinitionException.class, - () -> context.getBean(ApplicationRunnerTaskExecutor.class), - "ApplicationRunner should not be loaded during this integration test"); + assertThrows(NoSuchBeanDefinitionException.class, + () -> context.getBean(CommandLineTaskExecutor.class), + "CommandLineRunner should not be loaded during this integration test"); + assertThrows(NoSuchBeanDefinitionException.class, + () -> context.getBean(ApplicationRunnerTaskExecutor.class), + "ApplicationRunner should not be loaded during this integration test"); } } From a3d7eb0bf3ab5ce0a101c97a75ae213dccb73f62 Mon Sep 17 00:00:00 2001 From: kkaravitis Date: Sun, 22 Mar 2020 23:55:33 +0200 Subject: [PATCH 041/503] [BAEL-3913] Fixed broken lines format --- .../runner/execution/LoadSpringContextIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java index c3922536b1..6698094550 100644 --- a/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java +++ b/spring-boot-modules/spring-boot-testing/src/test/java/com/baeldung/prevent/commandline/application/runner/execution/LoadSpringContextIntegrationTest.java @@ -19,7 +19,7 @@ import static org.mockito.Mockito.verify; @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = { ApplicationCommandLineRunnerApp.class }, - initializers = ConfigFileApplicationContextInitializer.class) + initializers = ConfigFileApplicationContextInitializer.class) public class LoadSpringContextIntegrationTest { @SpyBean TaskService taskService; From 51ad7ac4138ba728dde7f3d41cbbb14a88e448fb Mon Sep 17 00:00:00 2001 From: mike b Date: Tue, 24 Mar 2020 10:36:56 -0400 Subject: [PATCH 042/503] [BAEL-3646] addressing pr issues --- .../conditionalflow/step/NumberInfoClassifierWithDecider.java | 3 --- .../baeldung/conditionalflow/step/PrependingStdoutWriter.java | 4 +--- .../conditionalflow/step/NumberInfoGeneratorUnitTest.java | 3 ++- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifierWithDecider.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifierWithDecider.java index b9d251c02d..4a8b7f1963 100644 --- a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifierWithDecider.java +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/NumberInfoClassifierWithDecider.java @@ -1,9 +1,6 @@ package org.baeldung.conditionalflow.step; import org.baeldung.conditionalflow.model.NumberInfo; -import org.springframework.batch.core.ExitStatus; -import org.springframework.batch.core.StepExecution; -import org.springframework.batch.core.annotation.BeforeStep; import org.springframework.batch.core.listener.ItemListenerSupport; import org.springframework.batch.item.ItemProcessor; diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java index 283b43f267..c6f77df2ba 100644 --- a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java @@ -7,11 +7,9 @@ import org.springframework.batch.item.ItemWriter; public class PrependingStdoutWriter implements ItemWriter { private String prependText; - private OutputStream writeTo; - public PrependingStdoutWriter(String prependText, OutputStream os) { + public PrependingStdoutWriter(String prependText) { this.prependText = prependText; - this.writeTo = os; } public PrependingStdoutWriter(String prependText) { diff --git a/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoGeneratorUnitTest.java b/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoGeneratorUnitTest.java index 62fe35add6..90fd884674 100644 --- a/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoGeneratorUnitTest.java +++ b/spring-batch/src/test/java/org/baeldung/conditionalflow/step/NumberInfoGeneratorUnitTest.java @@ -7,9 +7,10 @@ import org.baeldung.conditionalflow.model.NumberInfo; import org.junit.jupiter.api.Test; public class NumberInfoGeneratorUnitTest { + @Test public void givenArray_whenGenerator_correctOrderAndValue() { - int[] numbers = new int[]{1, -2, 4, -10}; + int[] numbers = new int[] { 1, -2, 4, -10 }; NumberInfoGenerator numberGenerator = new NumberInfoGenerator(numbers); assertEquals(new NumberInfo(numbers[0]), numberGenerator.read()); assertEquals(new NumberInfo(numbers[1]), numberGenerator.read()); From a7cb075f7d8cb308d6ced810233abbd485efe9f6 Mon Sep 17 00:00:00 2001 From: mike b Date: Tue, 24 Mar 2020 19:57:00 -0400 Subject: [PATCH 043/503] [BAEL-3646] Addressing broken PR --- .../conditionalflow/step/PrependingStdoutWriter.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java index c6f77df2ba..913c0885a9 100644 --- a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java @@ -12,12 +12,8 @@ public class PrependingStdoutWriter implements ItemWriter { this.prependText = prependText; } - public PrependingStdoutWriter(String prependText) { - this(prependText, System.out); - } - @Override - public void write(List list) throws Exception { + public void write(List list) { for (T listItem : list) { System.out.println(prependText + " " + listItem.toString()); } From c4ba08d9e5026059a3d070aafcf904a579cb86fe Mon Sep 17 00:00:00 2001 From: mike b Date: Tue, 24 Mar 2020 20:02:23 -0400 Subject: [PATCH 044/503] [BAEL-3646] remove unused import --- .../baeldung/conditionalflow/step/PrependingStdoutWriter.java | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java index 913c0885a9..9ffea1e798 100644 --- a/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java +++ b/spring-batch/src/main/java/org/baeldung/conditionalflow/step/PrependingStdoutWriter.java @@ -1,6 +1,5 @@ package org.baeldung.conditionalflow.step; -import java.io.OutputStream; import java.util.List; import org.springframework.batch.item.ItemWriter; From 9d11370afcda84ac9f07b9872f86f674e1767302 Mon Sep 17 00:00:00 2001 From: mike b Date: Wed, 25 Mar 2020 20:23:05 -0400 Subject: [PATCH 045/503] [bael-3646] trying to resolve merge conflict. --- spring-batch/repository.sqlite | Bin 73728 -> 73728 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/spring-batch/repository.sqlite b/spring-batch/repository.sqlite index 9d260fa2d1eed9ab00ea099508119d8e44235d87..2b549352ec8073708bd085fd414ed93d189c7511 100644 GIT binary patch delta 3276 zcmeHJUu;uV7{BNC-fPQRZd;t#GH8itU0~b2xA$M8MA_EC*xF7g!HwwX{l`k(TBI8f z(`+%~gBrHwJoEuH@kJg?jIP5MA0!f=L>$BiBhlc4kw;9-LX?Q-oOZPulF6HKG`ZjX zecwIj~+l4j?0LD$8& zA=s9n#T8Xm6q=>n9jTLre5sV5IM$sjn`8TnhV4kQWJsbWNseJEdQLV(*%1F2^lTlgnLRKO5wK=U1u${}~p(n+$ZXe10_tN=OzCX7?P(CVLO1 z2hy3t>6#6mqJ0zqEX#&M=UZ8drm=nbdm?`#Ylh%2$pY}fz(6~^+sDE;`vx0YmY`1f z!u~e+&R(HOvsul6kjm&f)IJ4S6VmEYc^eb67N@41!N8oLMT=*sb@2pU83 zL}41sX)FT+AvpU|idc8UxmTVfw#VUU>M%wVyJ6|oCkV3Z`lsnALMIAOL%xU+zS+^t zPJ$u{a_Q$Z;H7{E@e+yn5G~mF^(2vBV7dHdPbM`qm_&RMfJ(t%{Vj8b_o%vta#vGz zxG>t*S<_TGKKvN%0in$?x7*Fr2eSwI(|eB>js9Ly(dF7AMU>$6(Jf)3shX}0v*=Ws z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l@)r_W+)rkfd?Zjj%shXL zGt{{yL%)(6mFG&}smVP3YBL`$*G5LVToAcVfG@`(QRLw7qoH)j??^95O0-|mzD21W zh+f;&p<2EaYT|CR(+5$0k;OVfxjzZu4+E&h+9?rLJBMt$I#ijq2P>147Os6GqVJ#2 zRl-x1H*G6ySHdMY3m?Sn)D9QT@&&8V1DVOx{(J`guM4DRc#*=Y<=nEb_K_FSQlh03 z1ixt@>Q&_X6wOHubnWi0rw4-v{u_g|Juq~BUH|#M0LbB>c6cBFrhbE&OawKijYgLtrObCFz3v4sza$h z)TGA9)y3Y&yXCy(^r0w|_2mJOfmU3ZvYPJJZ`~2-kc|H8kc^Svf9UbUv73DzY=TX! N#YFV(6CayBe*?Yuegpsj From b7ea20cf99e620a8085777a204fed81487792639 Mon Sep 17 00:00:00 2001 From: patkorek Date: Thu, 26 Mar 2020 12:02:03 +0100 Subject: [PATCH 046/503] Postman Collection to test GraphQL endpoints --- ...GraphQL collection.postman_collection.json | 169 ++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 spring-boot-modules/spring-boot/src/test/resources/GraphQL collection.postman_collection.json diff --git a/spring-boot-modules/spring-boot/src/test/resources/GraphQL collection.postman_collection.json b/spring-boot-modules/spring-boot/src/test/resources/GraphQL collection.postman_collection.json new file mode 100644 index 0000000000..7fcaa2c76d --- /dev/null +++ b/spring-boot-modules/spring-boot/src/test/resources/GraphQL collection.postman_collection.json @@ -0,0 +1,169 @@ +{ + "info": { + "_postman_id": "910d9690-f629-4491-bbbd-adb30982a386", + "name": "GraphQL collection", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "mutations", + "item": [ + { + "name": "writePost", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation writePost ($title: String!, $text: String!, $category: String) {\n writePost (title: $title, text: $text, category: $category) {\n id\n title\n text\n category\n }\n}", + "variables": "{\n \"title\": \"\",\n \"text\": \"\",\n \"category\": \"\"\n}" + }, + "options": { + "graphql": {} + } + }, + "url": { + "raw": "http://localhost:9090/springbootapp/graphql", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "springbootapp", + "graphql" + ] + } + }, + "response": [] + } + ], + "protocolProfileBehavior": {} + }, + { + "name": "queries", + "item": [ + { + "name": "get recent posts", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n recentPosts(count: 10, offset: 0) {\r\n id\r\n title\r\n category\r\n text\r\n author {\r\n id\r\n name\r\n thumbnail\r\n }\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "http://localhost:9090/springbootapp/graphql", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "springbootapp", + "graphql" + ] + } + }, + "response": [] + }, + { + "name": "recentPosts - variables", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "query recentPosts ($count: Int, $offset: Int) {\n recentPosts (count: $count, offset: $offset) {\n id\n title\n text\n category\n }\n}", + "variables": "{\n \"count\": 1,\n \"offset\": 0\n}" + }, + "options": { + "graphql": {} + } + }, + "url": { + "raw": "http://localhost:9090/springbootapp/graphql", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "springbootapp", + "graphql" + ] + } + }, + "response": [] + }, + { + "name": "get recent posts - raw", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/graphql", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "query {\r\n recentPosts(count: 10, offset: 0) {\r\n id\r\n title\r\n category\r\n author {\r\n id\r\n name\r\n thumbnail\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "http://localhost:9090/springbootapp/graphql", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "springbootapp", + "graphql" + ] + } + }, + "response": [] + } + ], + "protocolProfileBehavior": {} + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "b54f267b-c450-4f2d-8105-2f23bab4c922", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "00b575be-03d4-4b29-b137-733ead139638", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "id": "20a274e5-6d51-40d6-81cb-af9eb115b21b", + "key": "url", + "value": "", + "type": "string" + } + ], + "protocolProfileBehavior": {} +} \ No newline at end of file From 23153cf01c005f2033518054cb08cb7cddb78007 Mon Sep 17 00:00:00 2001 From: mthomas Date: Sat, 28 Mar 2020 04:58:57 -0500 Subject: [PATCH 047/503] BAEL-3860 - Add model class and test for AtomicStampedReference --- .../concurrent/atomic/SafeAccount.java | 34 +++++++++++++++++++ .../atomic/ThreadSafeAccountTest.java | 21 ++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeAccount.java create mode 100644 core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeAccountTest.java diff --git a/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeAccount.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeAccount.java new file mode 100644 index 0000000000..febfd481c3 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeAccount.java @@ -0,0 +1,34 @@ +package com.baeldung.concurrent.atomic; + +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicStampedReference; + +public class SafeAccount { + + AtomicInteger stamp = new AtomicInteger(0); + AtomicStampedReference balance = new AtomicStampedReference<>(0, 0); + + public int getBalance() { + return this.balance.get(new int[1]); + } + + public int getStamp() { + int[] stamps = new int[1]; + this.balance.get(stamps); + return stamps[0]; + } + + public boolean deposit(int funds) { + int[] stamps = new int[1]; + int current = this.balance.get(stamps); + int newStamp = this.stamp.incrementAndGet(); + return this.balance.compareAndSet(current, current + funds, stamps[0], newStamp); + } + + public boolean withdrawal(int funds) { + int[] stamps = new int[1]; + int current = this.balance.get(stamps); + int newStamp = this.stamp.incrementAndGet(); + return this.balance.compareAndSet(current, current - funds, stamps[0], newStamp); + } +} diff --git a/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeAccountTest.java b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeAccountTest.java new file mode 100644 index 0000000000..b9a5fe7773 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeAccountTest.java @@ -0,0 +1,21 @@ +package com.baeldung.concurrent.atomic; + +import org.junit.Assert; +import org.junit.Test; + +public class ThreadSafeAccountTest { + + @Test + public void givenMultiThread_whenSafeAccountSetBalance() throws InterruptedException { + SafeAccount account = new SafeAccount(); + Thread t = new Thread(() -> { + while (!account.withdrawal(100)) + Thread.yield(); + }); + t.start(); + Assert.assertTrue(account.deposit(100)); + t.join(1_000); + Assert.assertFalse(t.isAlive()); + Assert.assertSame(0, account.getBalance()); + } +} From e189686b4a55267a1a0b369ef0f170576b2a0eb7 Mon Sep 17 00:00:00 2001 From: naXa! Date: Sun, 17 Mar 2019 22:24:10 +0300 Subject: [PATCH 048/503] [BAEL-2749] create new module `dbunit`; add DbUnit tests: `OldSchoolDbUnitTest` + `PrepAndExpectedDbUnitTest` + relevant data --- dbunit/README.md | 6 + dbunit/docs/db_schema.png | Bin 0 -> 17099 bytes dbunit/pom.xml | 35 ++++++ .../main/java/com/baeldung/dbunit/.gitkeep | 0 dbunit/src/main/resources/logback.xml | 13 ++ .../baeldung/dbunit/OldSchoolDbUnitTest.java | 111 ++++++++++++++++++ .../dbunit/PrepAndExpectedDbUnitTest.java | 103 ++++++++++++++++ dbunit/src/test/resources/data.xml | 11 ++ dbunit/src/test/resources/items.xml | 9 ++ .../src/test/resources/items_exp_delete.xml | 8 ++ .../src/test/resources/items_exp_rename.xml | 9 ++ dbunit/src/test/resources/schema.sql | 28 +++++ dbunit/src/test/resources/users.xml | 7 ++ .../src/test/resources/users_exp_delete.xml | 6 + .../src/test/resources/users_exp_rename.xml | 7 ++ 15 files changed, 353 insertions(+) create mode 100644 dbunit/README.md create mode 100644 dbunit/docs/db_schema.png create mode 100644 dbunit/pom.xml create mode 100644 dbunit/src/main/java/com/baeldung/dbunit/.gitkeep create mode 100644 dbunit/src/main/resources/logback.xml create mode 100644 dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java create mode 100644 dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java create mode 100644 dbunit/src/test/resources/data.xml create mode 100644 dbunit/src/test/resources/items.xml create mode 100644 dbunit/src/test/resources/items_exp_delete.xml create mode 100644 dbunit/src/test/resources/items_exp_rename.xml create mode 100644 dbunit/src/test/resources/schema.sql create mode 100644 dbunit/src/test/resources/users.xml create mode 100644 dbunit/src/test/resources/users_exp_delete.xml create mode 100644 dbunit/src/test/resources/users_exp_rename.xml diff --git a/dbunit/README.md b/dbunit/README.md new file mode 100644 index 0000000000..383bd6fb7e --- /dev/null +++ b/dbunit/README.md @@ -0,0 +1,6 @@ +### Database schema + +![db schema](docs/db_schema.png) + +### Relevant Articles: +- [Introduction To DBUnit](https://www.baeldung.com/dbunit) diff --git a/dbunit/docs/db_schema.png b/dbunit/docs/db_schema.png new file mode 100644 index 0000000000000000000000000000000000000000..d9185bacd2c624c8e05aea87bf542cfdfd7f1604 GIT binary patch literal 17099 zcmch91VJ!}GI}RUv>+r(2*N1QqxWuf5_R<6d+(z6 z-!1Yy&%5`2fBT$$UFV!XTv)U2wZ3buZ~d&#JpnIY$Y5iTVIUzPVav%%svsfVi2;60 z(eDB+822AMMnVz~my;BG<)XV4zoAOL7CX9s?c%i38RO6$T#=SwZAPC=hhk8vhx^8Q z*#LRjxRBks5RbaoFYa^Wn-AE&AA=r-3LTBMOb=R@GsRgBsavVYrG>w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8>HNYi8#qU@Bz+cpZcQAOK#N%*CBa>jf!6(*!lF}KVjSh=3 zQw!;w2r;Y=Bu9wlBxC!<3p!@Ey>H|888U3p_;S&9QtNeL*=N_cmV88Z) + 4.0.0 + dbunit + 1.0 + dbunit + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + org.dbunit + dbunit + ${dbunit.version} + test + + + + com.h2database + h2 + 1.4.197 + test + + + + + + 2.6.0 + + + diff --git a/dbunit/src/main/java/com/baeldung/dbunit/.gitkeep b/dbunit/src/main/java/com/baeldung/dbunit/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/dbunit/src/main/resources/logback.xml b/dbunit/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/dbunit/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/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java new file mode 100644 index 0000000000..a703863614 --- /dev/null +++ b/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java @@ -0,0 +1,111 @@ +package com.baeldung.dbunit; + +import org.dbunit.Assertion; +import org.dbunit.IDatabaseTester; +import org.dbunit.JdbcDatabaseTester; +import org.dbunit.dataset.IDataSet; +import org.dbunit.dataset.ITable; +import org.dbunit.dataset.xml.FlatXmlDataSet; +import org.dbunit.operation.DatabaseOperation; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.InputStream; +import java.sql.Connection; +import java.sql.ResultSet; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class OldSchoolDbUnitTest { + private static final String JDBC_DRIVER = org.h2.Driver.class.getName(); + private static final String JDBC_URL = "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;init=runscript from 'classpath:schema.sql'"; + private static final String USER = "sa"; + private static final String PASSWORD = ""; + + private static IDatabaseTester tester = null; + + @BeforeClass + public static void setUp() throws Exception { + tester = initDatabaseTester(); + } + + private static IDatabaseTester initDatabaseTester() throws Exception { + final JdbcDatabaseTester tester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER, PASSWORD); + tester.setDataSet(initDataSet()); + tester.setSetUpOperation(DatabaseOperation.REFRESH); + tester.setTearDownOperation(DatabaseOperation.NONE); + return tester; + } + + private static IDataSet initDataSet() throws Exception { + final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("data.xml"); + return new FlatXmlDataSet(is); + } + + @Before + public void setup() throws Exception { + tester.onSetup(); + } + + @After + public void tearDown() throws Exception { + tester.onTearDown(); + } + + @Test + public void testSelect() throws Exception { + // Arrange + final Connection connection = tester.getConnection().getConnection(); + + // Act + final ResultSet rs = connection.createStatement().executeQuery("select * from iTEMS where id = 1"); + + // Assert + assertTrue(rs.next()); + assertEquals("Grey T-Shirt", rs.getString("title")); + } + + @Test + public void testDelete() throws Exception { + // Arrange + final Connection connection = tester.getConnection().getConnection(); + + final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_delete.xml"); + ITable expectedTable = (new FlatXmlDataSet(is)).getTable("items"); + //expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedTable, new String[]{"produced"}); + + // Act + connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); + + // Assert + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); + //actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); + + Assertion.assertEquals(expectedTable, actualTable); + } + + @Test + public void testUpdate() throws Exception { + // Arrange + final Connection connection = tester.getConnection().getConnection(); + + final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_rename.xml"); + ITable expectedTable = (new FlatXmlDataSet(is)).getTable("items"); + //expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedTable, new String[]{"produced"}); + + // Act + connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); + + // Assert + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); + //actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); + + Assertion.assertEquals(expectedTable, actualTable); + } + +} diff --git a/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java new file mode 100644 index 0000000000..c3882d5eab --- /dev/null +++ b/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java @@ -0,0 +1,103 @@ +package com.baeldung.dbunit; + +import org.dbunit.*; +import org.dbunit.dataset.IDataSet; +import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; +import org.dbunit.operation.DatabaseOperation; +import org.dbunit.util.fileloader.DataFileLoader; +import org.dbunit.util.fileloader.FlatXmlDataFileLoader; +import org.junit.Test; + +import java.io.InputStream; +import java.sql.Connection; +import java.sql.ResultSet; + +public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { + private static final String JDBC_DRIVER = org.h2.Driver.class.getName(); + private static final String JDBC_URL = "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;init=runscript from 'classpath:schema.sql'"; + private static final String USER = "sa"; + private static final String PASSWORD = ""; + + @Override + public void setUp() throws Exception { + setDatabaseTester(initDatabaseTester()); + setDataFileLoader(initDataFileLoader()); + super.setUp(); + } + + private IDatabaseTester initDatabaseTester() throws Exception { + final JdbcDatabaseTester tester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER, PASSWORD); + tester.setDataSet(initDataSet()); + tester.setSetUpOperation(DatabaseOperation.REFRESH); + return tester; + } + + private IDataSet initDataSet() throws Exception { + final InputStream is = getClass().getClassLoader().getResourceAsStream("data.xml"); + return new FlatXmlDataSetBuilder().build(is); + } + + private DataFileLoader initDataFileLoader() { + return new FlatXmlDataFileLoader(); + } + + @Test + public void testSelect() throws Exception { + // Arrange + final Connection connection = getConnection().getConnection(); + final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("USERS", new String[]{})}; + final String[] prepDataFiles = {"/users.xml"}; + final String[] expectedDataFiles = {"/users.xml"}; + final PrepAndExpectedTestCaseSteps testSteps = () -> { + // invoke the method being tested here; for the sake of simplicity we use JDBC API directly in this example + final ResultSet rs = connection.createStatement().executeQuery("select * from USERS where id = 1"); + + // either place assertions here + //assertTrue(rs.next()); + //assertEquals("Xavier", rs.getString("last_name")); + + return rs; + }; + + // Act + final ResultSet rs = (ResultSet) super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); + + // or place assertions at the end + assertTrue(rs.next()); + assertEquals("Xavier", rs.getString("last_name")); + } + + @Test + public void testUpdate() throws Exception { + // Arrange + final Connection connection = getConnection().getConnection(); + final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("USERS", new String[]{})}; // define tables to verify + final String[] prepDataFiles = {"/users.xml"}; // define prep files + final String[] expectedDataFiles = {"/users_exp_rename.xml"}; // define expected files + final PrepAndExpectedTestCaseSteps testSteps = () -> { + // invoke the method being tested here; for the sake of simplicity we use JDBC API directly in this example + return connection.createStatement().executeUpdate("update USERS set first_name = 'new name' where id = 1"); + // after this method exits, dbUnit will: + // * verify configured tables + // * cleanup tables as configured + }; + + // Act + super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); + } + + @Test + public void testDelete() throws Exception { + // Arrange + final Connection connection = getConnection().getConnection(); + final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("USERS", new String[]{})}; + final String[] prepDataFiles = {"/users.xml"}; + final String[] expectedDataFiles = {"/users_exp_delete.xml"}; + final PrepAndExpectedTestCaseSteps testSteps = + () -> connection.createStatement().executeUpdate("delete from USERS where id = 2"); + + // Act + super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); + } + +} diff --git a/dbunit/src/test/resources/data.xml b/dbunit/src/test/resources/data.xml new file mode 100644 index 0000000000..e4498513e0 --- /dev/null +++ b/dbunit/src/test/resources/data.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/dbunit/src/test/resources/items.xml b/dbunit/src/test/resources/items.xml new file mode 100644 index 0000000000..04a975d7ee --- /dev/null +++ b/dbunit/src/test/resources/items.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/dbunit/src/test/resources/items_exp_delete.xml b/dbunit/src/test/resources/items_exp_delete.xml new file mode 100644 index 0000000000..1aaeff59ca --- /dev/null +++ b/dbunit/src/test/resources/items_exp_delete.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/dbunit/src/test/resources/items_exp_rename.xml b/dbunit/src/test/resources/items_exp_rename.xml new file mode 100644 index 0000000000..237280e758 --- /dev/null +++ b/dbunit/src/test/resources/items_exp_rename.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/dbunit/src/test/resources/schema.sql b/dbunit/src/test/resources/schema.sql new file mode 100644 index 0000000000..9b5018985a --- /dev/null +++ b/dbunit/src/test/resources/schema.sql @@ -0,0 +1,28 @@ +CREATE TABLE IF NOT EXISTS USERS +( + `id` int AUTO_INCREMENT NOT NULL, + `first_name` varchar(100) NOT NULL, + `last_name` varchar(100) NOT NULL, + PRIMARY KEY (`id`) +); + +CREATE TABLE IF NOT EXISTS ITEMS +( + `id` int AUTO_INCREMENT NOT NULL, + `title` varchar(100) NOT NULL, + `produced` date, + `price` float, + PRIMARY KEY (`id`) +); + +CREATE TABLE IF NOT EXISTS PURCHASES +( + `id` int NOT NULL AUTO_INCREMENT, + `id_user` int NOT NULL, + `id_item` int NOT NULL, + `total_price` float NOT NULL, + `quantity` int(11) NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_user`) REFERENCES USERS (`id`) ON DELETE CASCADE, + FOREIGN KEY (`id_item`) REFERENCES ITEMS (`id`) ON DELETE CASCADE ON UPDATE CASCADE +); diff --git a/dbunit/src/test/resources/users.xml b/dbunit/src/test/resources/users.xml new file mode 100644 index 0000000000..cebadf2e67 --- /dev/null +++ b/dbunit/src/test/resources/users.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/dbunit/src/test/resources/users_exp_delete.xml b/dbunit/src/test/resources/users_exp_delete.xml new file mode 100644 index 0000000000..8b72ceef89 --- /dev/null +++ b/dbunit/src/test/resources/users_exp_delete.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/dbunit/src/test/resources/users_exp_rename.xml b/dbunit/src/test/resources/users_exp_rename.xml new file mode 100644 index 0000000000..9bc1254967 --- /dev/null +++ b/dbunit/src/test/resources/users_exp_rename.xml @@ -0,0 +1,7 @@ + + + + + + + From 6194165f0d1c57ef5d6b5f1111d96107beee735c Mon Sep 17 00:00:00 2001 From: naXa! Date: Mon, 25 Mar 2019 01:37:05 +0300 Subject: [PATCH 049/503] [BAEL-2749] add `SampleDbUnitTest` (extending `DBTestCase`) --- .../com/baeldung/dbunit/SampleDbUnitTest.java | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 dbunit/src/test/java/com/baeldung/dbunit/SampleDbUnitTest.java diff --git a/dbunit/src/test/java/com/baeldung/dbunit/SampleDbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/SampleDbUnitTest.java new file mode 100644 index 0000000000..cfe4fd4e11 --- /dev/null +++ b/dbunit/src/test/java/com/baeldung/dbunit/SampleDbUnitTest.java @@ -0,0 +1,96 @@ +package com.baeldung.dbunit; + +import org.dbunit.Assertion; +import org.dbunit.DBTestCase; +import org.dbunit.PropertiesBasedJdbcDatabaseTester; +import org.dbunit.dataset.IDataSet; +import org.dbunit.dataset.ITable; +import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; +import org.dbunit.operation.DatabaseOperation; +import org.junit.Test; + +import java.io.InputStream; +import java.sql.Connection; +import java.sql.ResultSet; + +public class SampleDbUnitTest extends DBTestCase { + private static final String JDBC_DRIVER = org.h2.Driver.class.getName(); + private static final String JDBC_URL = "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;init=runscript from 'classpath:schema.sql'"; + private static final String USER = "sa"; + private static final String PASSWORD = ""; + + public SampleDbUnitTest(String name) { + super(name); + System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS, JDBC_DRIVER); + System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL, JDBC_URL); + System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME, USER); + System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD, PASSWORD); + // System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_SCHEMA, ""); + } + + @Override + protected IDataSet getDataSet() throws Exception { + final InputStream is = SampleDbUnitTest.class.getClassLoader().getResourceAsStream("data.xml"); + return new FlatXmlDataSetBuilder().build(is); + } + + @Override + protected DatabaseOperation getSetUpOperation() { + return DatabaseOperation.REFRESH; + } + + @Override + protected DatabaseOperation getTearDownOperation() { + return DatabaseOperation.NONE; + } + + @Test + public void testSelect() throws Exception { + // Arrange + final Connection connection = getConnection().getConnection(); + + // Act + final ResultSet rs = connection.createStatement().executeQuery("select * from iTEMS where id = 1"); + + // Assert + assertTrue(rs.next()); + assertEquals("Grey T-Shirt", rs.getString("title")); + } + + @Test + public void testDelete() throws Exception { + // Arrange + final Connection connection = getConnection().getConnection(); + + final InputStream is = SampleDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_delete.xml"); + ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("items"); + + // Act + connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); + + // Assert + final IDataSet databaseDataSet = getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); + + Assertion.assertEquals(expectedTable, actualTable); + } + + @Test + public void testUpdate() throws Exception { + // Arrange + final Connection connection = getConnection().getConnection(); + + final InputStream is = SampleDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_rename.xml"); + ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("items"); + + // Act + connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); + + // Assert + final IDataSet databaseDataSet = getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); + + Assertion.assertEquals(expectedTable, actualTable); + } + +} From 71fecd658963941c694f0528e981b2f88441999d Mon Sep 17 00:00:00 2001 From: Philippe Date: Sun, 29 Mar 2020 11:49:46 -0300 Subject: [PATCH 050/503] [BAEL-3793][BAEL-3935] Code snippets --- terraform/best-practices/README.md | 10 +++ .../best-practices/ec2-simple/.gitignore | 4 ++ terraform/best-practices/ec2-simple/SETUP.md | 23 +++++++ terraform/best-practices/ec2-simple/main.tf | 33 +++++++++ .../best-practices/ec2-simple/providers.tf | 6 ++ .../best-practices/ec2-simple/variables.tf | 15 ++++ terraform/best-practices/k8s-basic/.gitignore | 4 ++ terraform/best-practices/k8s-basic/SETUP.md | 15 ++++ terraform/best-practices/k8s-basic/main.tf | 12 ++++ .../best-practices/k8s-basic/providers.tf | 6 ++ .../best-practices/k8s-basic/variables.tf | 9 +++ .../best-practices/k8s-modules/.gitignore | 4 ++ terraform/best-practices/k8s-modules/SETUP.md | 21 ++++++ terraform/best-practices/k8s-modules/main.tf | 27 ++++++++ .../k8s-modules/modules/SvcCustomer/main.tf | 68 ++++++++++++++++++ .../modules/SvcCustomer/outputs.tf | 3 + .../modules/SvcCustomer/variables.tf | 5 ++ .../k8s-modules/modules/SvcFeedback/main.tf | 69 +++++++++++++++++++ .../modules/SvcFeedback/outputs.tf | 3 + .../modules/SvcFeedback/variables.tf | 5 ++ .../ingress/www.petshop.com.br/main.tf | 41 +++++++++++ .../ingress/www.petshop.com.br/outputs.tf | 5 ++ .../ingress/www.petshop.com.br/variables.tf | 20 ++++++ .../best-practices/k8s-modules/provider.tf | 13 ++++ terraform/hello-terraform/.gitignore | 6 ++ terraform/hello-terraform/main.tf | 7 ++ 26 files changed, 434 insertions(+) create mode 100644 terraform/best-practices/README.md create mode 100644 terraform/best-practices/ec2-simple/.gitignore create mode 100644 terraform/best-practices/ec2-simple/SETUP.md create mode 100644 terraform/best-practices/ec2-simple/main.tf create mode 100644 terraform/best-practices/ec2-simple/providers.tf create mode 100644 terraform/best-practices/ec2-simple/variables.tf create mode 100644 terraform/best-practices/k8s-basic/.gitignore create mode 100644 terraform/best-practices/k8s-basic/SETUP.md create mode 100644 terraform/best-practices/k8s-basic/main.tf create mode 100644 terraform/best-practices/k8s-basic/providers.tf create mode 100644 terraform/best-practices/k8s-basic/variables.tf create mode 100644 terraform/best-practices/k8s-modules/.gitignore create mode 100644 terraform/best-practices/k8s-modules/SETUP.md create mode 100644 terraform/best-practices/k8s-modules/main.tf create mode 100644 terraform/best-practices/k8s-modules/modules/SvcCustomer/main.tf create mode 100644 terraform/best-practices/k8s-modules/modules/SvcCustomer/outputs.tf create mode 100644 terraform/best-practices/k8s-modules/modules/SvcCustomer/variables.tf create mode 100644 terraform/best-practices/k8s-modules/modules/SvcFeedback/main.tf create mode 100644 terraform/best-practices/k8s-modules/modules/SvcFeedback/outputs.tf create mode 100644 terraform/best-practices/k8s-modules/modules/SvcFeedback/variables.tf create mode 100644 terraform/best-practices/k8s-modules/modules/ingress/www.petshop.com.br/main.tf create mode 100644 terraform/best-practices/k8s-modules/modules/ingress/www.petshop.com.br/outputs.tf create mode 100644 terraform/best-practices/k8s-modules/modules/ingress/www.petshop.com.br/variables.tf create mode 100644 terraform/best-practices/k8s-modules/provider.tf create mode 100644 terraform/hello-terraform/.gitignore create mode 100644 terraform/hello-terraform/main.tf diff --git a/terraform/best-practices/README.md b/terraform/best-practices/README.md new file mode 100644 index 0000000000..fd488b1afb --- /dev/null +++ b/terraform/best-practices/README.md @@ -0,0 +1,10 @@ +# Terraform Sample Code + +This folder contains Terraform project samples that illustrates topics covered in the +"Best practices when using Terraform" article. Setup instructions are available in each sample's folder. + +List of available samples: + + * k8s-basic: "Hello world" project that just connects to a Kubernetes cluster and create a new namespace. + * ec2-basic: "Hello world" project that creates a single EC2 instance + * k8s-modules: A more elaborate sample that creates a simple set of services in a Kubernetes cluster diff --git a/terraform/best-practices/ec2-simple/.gitignore b/terraform/best-practices/ec2-simple/.gitignore new file mode 100644 index 0000000000..a70da3ca16 --- /dev/null +++ b/terraform/best-practices/ec2-simple/.gitignore @@ -0,0 +1,4 @@ +*.tfvars +*.tfstate +*.tfstate.backup +.terraform diff --git a/terraform/best-practices/ec2-simple/SETUP.md b/terraform/best-practices/ec2-simple/SETUP.md new file mode 100644 index 0000000000..3f906b6933 --- /dev/null +++ b/terraform/best-practices/ec2-simple/SETUP.md @@ -0,0 +1,23 @@ +# EC2 Basic Sample + +This Terraform sample project creates a single EC2 instance in the configured region. + +IMPORTANT NOTICE: In order to run this sample you must have an active AWS Account. As you probably know, creating resources on AWS +may result in additional charges in your bill. We recommend creating a test account to run this test as you can then use AWS's free tier +to play around. When finished, ALWAYS REMEMBER TO DESTROY YOUR RESOURCES !!! + +# Setup instructions + +1. Make sure you have a working AWS environment. Use a simple command such as _aws ec2 describe-instances_ and check its output. + If you get a list of existing EC2 instances, you're good to go. Otherwise, please refer to AWS documentation in order to setup your CLI. +2. Download the Terraform package for your environment from Hashicorp's site. Unzip it and put the _terraform_ binary somewhere + in the OS's PATH. +3. Open a command prompt and _cd_ into this folder +4. Run the following commands: +''' + $ terraform init + $ terraform apply -auto-approve +''' +5. Wait until Terraform create all resources and run _aws ec2 describe-instances_. The output should list the newly creates EC2 instance +6. Run _terraform destroy_ to remove the previously creates namespace. + diff --git a/terraform/best-practices/ec2-simple/main.tf b/terraform/best-practices/ec2-simple/main.tf new file mode 100644 index 0000000000..57fb9d1757 --- /dev/null +++ b/terraform/best-practices/ec2-simple/main.tf @@ -0,0 +1,33 @@ +# +# Resource definitions +# + +data "aws_ami" "apache" { + filter { + name = "name" + values = [var.ami_name] + } + + filter { + name = "virtualization-type" + values = ["hvm"] + } + + owners = [var.ami_owner] + + most_recent = true +} + +resource "aws_instance" "web" { + ami = data.aws_ami.apache.id + instance_type = "t2.micro" + subnet_id = aws_subnet.frontend.id +} +resource "aws_subnet" "frontend" { + vpc_id = aws_vpc.apps.id + cidr_block = "10.0.1.0/24" +} + +resource "aws_vpc" "apps" { + cidr_block = "10.0.0.0/16" +} diff --git a/terraform/best-practices/ec2-simple/providers.tf b/terraform/best-practices/ec2-simple/providers.tf new file mode 100644 index 0000000000..fa5826b067 --- /dev/null +++ b/terraform/best-practices/ec2-simple/providers.tf @@ -0,0 +1,6 @@ +# +# Providers definitions +# +provider "aws" { + version = "~> 2.53" +} \ No newline at end of file diff --git a/terraform/best-practices/ec2-simple/variables.tf b/terraform/best-practices/ec2-simple/variables.tf new file mode 100644 index 0000000000..2a7fddcd33 --- /dev/null +++ b/terraform/best-practices/ec2-simple/variables.tf @@ -0,0 +1,15 @@ +# +# Variables +# + +variable "ami_name" { + type = string + description = "AMI name to use for our EC2 instance. Defaults to Ubuntu 18.04 (Bionic)" + default = "ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-*" +} + +variable "ami_owner" { + type = string + description = "AMI Owner ID to use for our EC2 instance. Defaults to 099720109477 (Canonical)" + default = "099720109477" +} \ No newline at end of file diff --git a/terraform/best-practices/k8s-basic/.gitignore b/terraform/best-practices/k8s-basic/.gitignore new file mode 100644 index 0000000000..a70da3ca16 --- /dev/null +++ b/terraform/best-practices/k8s-basic/.gitignore @@ -0,0 +1,4 @@ +*.tfvars +*.tfstate +*.tfstate.backup +.terraform diff --git a/terraform/best-practices/k8s-basic/SETUP.md b/terraform/best-practices/k8s-basic/SETUP.md new file mode 100644 index 0000000000..479bb75274 --- /dev/null +++ b/terraform/best-practices/k8s-basic/SETUP.md @@ -0,0 +1,15 @@ +# Setup instructions + +1. Mak sure you have a working Kubernetes environment. Use a simple command such as _kubectl get nodes_ and check its output. + If you get a list of nodes that contains at least one _ready_ module, you're good to go +2. Download the Terraform package for your environment from Hashicorp's site. Unzip it and put the _terraform_ binary somewhere + in the OS's PATH. +3. Open a command prompt and _cd_ into this folder +4. Run the following commands: +''' + $ terraform init + $ terraform apply -auto-approve +''' +5. Wait until Terraform create all resources and run _kubectl get namespaces_. The output should now have a new "hello-terraform" namespace. +6. Run _terraform destroy_ to remove the previously creates namespace. + diff --git a/terraform/best-practices/k8s-basic/main.tf b/terraform/best-practices/k8s-basic/main.tf new file mode 100644 index 0000000000..5eb3749930 --- /dev/null +++ b/terraform/best-practices/k8s-basic/main.tf @@ -0,0 +1,12 @@ +# +# Resource definitions +# + +resource "kubernetes_namespace" "hello" { + metadata { + labels = { + terraform = "true" + } + name = var.namespace_name + } +} \ No newline at end of file diff --git a/terraform/best-practices/k8s-basic/providers.tf b/terraform/best-practices/k8s-basic/providers.tf new file mode 100644 index 0000000000..385f857a11 --- /dev/null +++ b/terraform/best-practices/k8s-basic/providers.tf @@ -0,0 +1,6 @@ +# +# Providers definitions +# +provider "kubernetes" { + version = "~> 1.11" +} \ No newline at end of file diff --git a/terraform/best-practices/k8s-basic/variables.tf b/terraform/best-practices/k8s-basic/variables.tf new file mode 100644 index 0000000000..b9217079bf --- /dev/null +++ b/terraform/best-practices/k8s-basic/variables.tf @@ -0,0 +1,9 @@ +# +# Variables +# + +variable "namespace_name" { + type = string + description = "Name to use for the created namespace" + default = "hello-terraform" +} \ No newline at end of file diff --git a/terraform/best-practices/k8s-modules/.gitignore b/terraform/best-practices/k8s-modules/.gitignore new file mode 100644 index 0000000000..a70da3ca16 --- /dev/null +++ b/terraform/best-practices/k8s-modules/.gitignore @@ -0,0 +1,4 @@ +*.tfvars +*.tfstate +*.tfstate.backup +.terraform diff --git a/terraform/best-practices/k8s-modules/SETUP.md b/terraform/best-practices/k8s-modules/SETUP.md new file mode 100644 index 0000000000..b7e4c2764d --- /dev/null +++ b/terraform/best-practices/k8s-modules/SETUP.md @@ -0,0 +1,21 @@ +# Kubernetes multimodule sample + +This sample deploys two services behind a Kubernetes ingress. + +# Setup instructions + +1. Mak sure you have a working Kubernetes environment. Use a simple command such as _kubectl get nodes_ and check its output. + If you get a list of nodes that contains at least one _ready_ module, you're good to go +2. Download the Terraform package for your environment from Hashicorp's site. Unzip it and put the _terraform_ binary somewhere + in the OS's PATH. +3. Open a command prompt and _cd_ into this folder +4. Run the following commands: +''' + $ terraform init + $ terraform apply -auto-approve +''' +5. Wait until Terraform create all resources and run _kubectl get services_. The output should now have a few services. +6. Run _terraform destroy_ to remove the previously creates namespace. + + + diff --git a/terraform/best-practices/k8s-modules/main.tf b/terraform/best-practices/k8s-modules/main.tf new file mode 100644 index 0000000000..86426b33db --- /dev/null +++ b/terraform/best-practices/k8s-modules/main.tf @@ -0,0 +1,27 @@ +/* + * Top-level definitions + */ + +//================================================================== Ingress + +module "ingress_www_petshop_com_br" { + source = "./modules/ingress/www.petshop.com.br" + ingress_host = "www.petshop.com.br" +} + +//================================================================== Deployments + +module "SvcCustomer" { + source = "./modules/SvcCustomer" +} + +module "SvcFeedback" { + source = "./modules/SvcFeedback" +} + + + + + + + diff --git a/terraform/best-practices/k8s-modules/modules/SvcCustomer/main.tf b/terraform/best-practices/k8s-modules/modules/SvcCustomer/main.tf new file mode 100644 index 0000000000..1ca0c91545 --- /dev/null +++ b/terraform/best-practices/k8s-modules/modules/SvcCustomer/main.tf @@ -0,0 +1,68 @@ +/* + * SvcCustomer deployment resources + */ + +resource "kubernetes_deployment" "SvcCustomer" { + + metadata { + name = "svccustomer" + labels = { + app = "SvcCustomer" + } + } + + spec { + replicas = 1 + + selector { + match_labels = { + app = "SvcCustomer" + } + } + + template { + metadata { + labels = { + app = "SvcCustomer" + } + } + + spec { + image_pull_secrets { + name = "docker-config" + } + + + container { + image = "inanimate/echo-server" + name = "svccustomer-httpd" + env { + name = "PORT" + value = "80" + } + } + } + } + } +} + +resource "kubernetes_service" "SvcCustomer" { + metadata { + name = "svccustomer" + } + + spec { + + selector = { + app = "SvcCustomer" + } + + session_affinity = "ClientIP" + port { + port = 80 + } + + //type = "LoadBalancer" + } + } + \ No newline at end of file diff --git a/terraform/best-practices/k8s-modules/modules/SvcCustomer/outputs.tf b/terraform/best-practices/k8s-modules/modules/SvcCustomer/outputs.tf new file mode 100644 index 0000000000..8a37fdf375 --- /dev/null +++ b/terraform/best-practices/k8s-modules/modules/SvcCustomer/outputs.tf @@ -0,0 +1,3 @@ +/* + * SvcCustomer output values + */ diff --git a/terraform/best-practices/k8s-modules/modules/SvcCustomer/variables.tf b/terraform/best-practices/k8s-modules/modules/SvcCustomer/variables.tf new file mode 100644 index 0000000000..3dfcfcd264 --- /dev/null +++ b/terraform/best-practices/k8s-modules/modules/SvcCustomer/variables.tf @@ -0,0 +1,5 @@ +/* + * SvcCustomer deployment variables + */ + + \ No newline at end of file diff --git a/terraform/best-practices/k8s-modules/modules/SvcFeedback/main.tf b/terraform/best-practices/k8s-modules/modules/SvcFeedback/main.tf new file mode 100644 index 0000000000..0f84c9163e --- /dev/null +++ b/terraform/best-practices/k8s-modules/modules/SvcFeedback/main.tf @@ -0,0 +1,69 @@ +/* + * SvcFeedback deployment resources + */ + +resource "kubernetes_deployment" "SvcFeedback" { + + metadata { + name = "svcfeedback" + labels = { + app = "SvcFeedback" + } + } + + spec { + replicas = 1 + + selector { + match_labels = { + app = "SvcFeedback" + } + } + + template { + metadata { + labels = { + app = "SvcFeedback" + } + } + + spec { + image_pull_secrets { + name = "docker-config" + } + + + container { + image = "inanimate/echo-server" + name = "svcfeedback-httpd" + env { + name = "PORT" + value = "80" + } + } + + } + } + } +} + +resource "kubernetes_service" "SvcFeedback" { + metadata { + name = "svcfeedback" + } + + spec { + + selector = { + app = "SvcFeedback" + } + + session_affinity = "ClientIP" + port { + port = 80 + } + + //type = "LoadBalancer" + } + } + \ No newline at end of file diff --git a/terraform/best-practices/k8s-modules/modules/SvcFeedback/outputs.tf b/terraform/best-practices/k8s-modules/modules/SvcFeedback/outputs.tf new file mode 100644 index 0000000000..e08c17d4b4 --- /dev/null +++ b/terraform/best-practices/k8s-modules/modules/SvcFeedback/outputs.tf @@ -0,0 +1,3 @@ +/* + * SvcFeedback output values + */ diff --git a/terraform/best-practices/k8s-modules/modules/SvcFeedback/variables.tf b/terraform/best-practices/k8s-modules/modules/SvcFeedback/variables.tf new file mode 100644 index 0000000000..d8076d41a4 --- /dev/null +++ b/terraform/best-practices/k8s-modules/modules/SvcFeedback/variables.tf @@ -0,0 +1,5 @@ +/* + * SvcFeedback deployment variables + */ + + \ No newline at end of file diff --git a/terraform/best-practices/k8s-modules/modules/ingress/www.petshop.com.br/main.tf b/terraform/best-practices/k8s-modules/modules/ingress/www.petshop.com.br/main.tf new file mode 100644 index 0000000000..0dbda48981 --- /dev/null +++ b/terraform/best-practices/k8s-modules/modules/ingress/www.petshop.com.br/main.tf @@ -0,0 +1,41 @@ +/* + * Kubernetes Ingress module + */ +locals { + iname = var.ingress_name == "" ? join("-",["ingress",sha1(uuid())]) : var.ingress_name +} + +resource "kubernetes_ingress" "ingress" { + metadata { + name = local.iname + annotations = map( + "nginx.ingress.kubernetes.io/rewrite-target","/" + ) + } + spec { + rule { + http { + path { + backend { + service_name = "svccustomer" + service_port = 80 + } + path = "/customers" + } + path { + backend { + service_name = "svcfeedback" + service_port = 80 + } + path = "/feedback" + } + } + } +/* + tls { + secret_name = "tls-secret" + } +*/ + } +} + diff --git a/terraform/best-practices/k8s-modules/modules/ingress/www.petshop.com.br/outputs.tf b/terraform/best-practices/k8s-modules/modules/ingress/www.petshop.com.br/outputs.tf new file mode 100644 index 0000000000..e604417b05 --- /dev/null +++ b/terraform/best-practices/k8s-modules/modules/ingress/www.petshop.com.br/outputs.tf @@ -0,0 +1,5 @@ +/* + * Output variables + */ + + diff --git a/terraform/best-practices/k8s-modules/modules/ingress/www.petshop.com.br/variables.tf b/terraform/best-practices/k8s-modules/modules/ingress/www.petshop.com.br/variables.tf new file mode 100644 index 0000000000..9b06128ec5 --- /dev/null +++ b/terraform/best-practices/k8s-modules/modules/ingress/www.petshop.com.br/variables.tf @@ -0,0 +1,20 @@ +/* + * Kubernetes Ingress module + */ + + +variable "ingress_name" { + type = string + description = "Ingress name. Defaults to a random name." + default = "" +} + +variable "ingress_host" { + type = string + description = "Ingress hostname" + default = "www.petshop.com.br" +} + + + + diff --git a/terraform/best-practices/k8s-modules/provider.tf b/terraform/best-practices/k8s-modules/provider.tf new file mode 100644 index 0000000000..bb90d66ecf --- /dev/null +++ b/terraform/best-practices/k8s-modules/provider.tf @@ -0,0 +1,13 @@ +# +# Provider configurations +# This file will *NOT* be overwriten upon regeneration, so it's safe +# to add your own customizations +# + +provider "kubernetes" { + version = "~> 1.10" +} + +provider "random" { + version = "~> 2.2" +} \ No newline at end of file diff --git a/terraform/hello-terraform/.gitignore b/terraform/hello-terraform/.gitignore new file mode 100644 index 0000000000..452502c50f --- /dev/null +++ b/terraform/hello-terraform/.gitignore @@ -0,0 +1,6 @@ +*.tfvars +*.tfstate +*.tfstate.backup +.terraform +hello.txt + diff --git a/terraform/hello-terraform/main.tf b/terraform/hello-terraform/main.tf new file mode 100644 index 0000000000..d6a726fa36 --- /dev/null +++ b/terraform/hello-terraform/main.tf @@ -0,0 +1,7 @@ +provider "local" { + version = "~> 1.4" +} +resource "local_file" "hello" { + content = "Hello, Terraform" + filename = "hello.txt" +} From 4382852a1731d9d06f838219ec176ddf89c04d3d Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Sun, 29 Mar 2020 19:00:40 +0200 Subject: [PATCH 051/503] JAVA-43: Upgrade spring-security-modules to Spring Boot 2 --- spring-security-modules/spring-security-acl/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-security-modules/spring-security-acl/pom.xml b/spring-security-modules/spring-security-acl/pom.xml index 3c613f9d92..5c04aaa9ca 100644 --- a/spring-security-modules/spring-security-acl/pom.xml +++ b/spring-security-modules/spring-security-acl/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../../parent-boot-1 + ../../parent-boot-2 From 35bbf9c8845c7c6091afdefb5fb49e8f54035f1c Mon Sep 17 00:00:00 2001 From: Ali Dehghani Date: Mon, 30 Mar 2020 01:29:02 +0430 Subject: [PATCH 052/503] Borrowing one Example from JCIP --- .../volatilekeyword/TaskRunner.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/volatilekeyword/TaskRunner.java diff --git a/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/volatilekeyword/TaskRunner.java b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/volatilekeyword/TaskRunner.java new file mode 100644 index 0000000000..f0493d4911 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/volatilekeyword/TaskRunner.java @@ -0,0 +1,25 @@ +package com.baeldung.concurrent.volatilekeyword; + +public class TaskRunner { + + private static int number; + private volatile static boolean ready; + + private static class Reader extends Thread { + + @Override + public void run() { + while (!ready) { + Thread.yield(); + } + + System.out.println(number); + } + } + + public static void main(String[] args) { + new Reader().start(); + number = 42; + ready = true; + } +} From ee95317ad9dd8af56a885bcac40b9b11d04dca56 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Sun, 29 Mar 2020 23:54:31 +0200 Subject: [PATCH 053/503] JAVA-42: Upgrade spring-security-ldap to Spring Boot 2 --- .../spring-security-ldap/pom.xml | 8 +++++-- .../com/baeldung/SampleLDAPApplication.java | 13 +----------- .../{security => config}/SecurityConfig.java | 21 +++++++++++++++---- .../java/com/baeldung/config/WebConfig.java | 16 ++++++++++++++ .../src/main/resources/application.properties | 1 + .../src/main/resources/webSecurityConfig.xml | 1 + 6 files changed, 42 insertions(+), 18 deletions(-) rename spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/{security => config}/SecurityConfig.java (53%) create mode 100644 spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/config/WebConfig.java create mode 100644 spring-security-modules/spring-security-ldap/src/main/resources/application.properties diff --git a/spring-security-modules/spring-security-ldap/pom.xml b/spring-security-modules/spring-security-ldap/pom.xml index f5e8856648..baed682186 100644 --- a/spring-security-modules/spring-security-ldap/pom.xml +++ b/spring-security-modules/spring-security-ldap/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../../parent-boot-1 + ../../parent-boot-2 @@ -21,6 +21,10 @@ org.springframework.boot spring-boot-starter-security + + org.springframework.boot + spring-boot-starter-web + org.springframework.boot spring-boot-starter-thymeleaf diff --git a/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/SampleLDAPApplication.java b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/SampleLDAPApplication.java index ec585f2387..2d619cccfa 100644 --- a/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/SampleLDAPApplication.java +++ b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/SampleLDAPApplication.java @@ -2,7 +2,7 @@ package com.baeldung; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.web.support.SpringBootServletInitializer; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.annotation.Bean; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @@ -19,15 +19,4 @@ public class SampleLDAPApplication extends SpringBootServletInitializer { SpringApplication.run(SampleLDAPApplication.class, args); } - @Bean - public WebMvcConfigurerAdapter adapter() { - return new WebMvcConfigurerAdapter() { - @Override - public void addViewControllers(ViewControllerRegistry registry) { - registry.addViewController("/login") - .setViewName("login"); - } - }; - } - } \ No newline at end of file diff --git a/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/security/SecurityConfig.java b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/config/SecurityConfig.java similarity index 53% rename from spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/security/SecurityConfig.java rename to spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/config/SecurityConfig.java index a00cb02459..69f90d9de9 100644 --- a/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/security/SecurityConfig.java +++ b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/config/SecurityConfig.java @@ -1,4 +1,4 @@ -package com.baeldung.security; +package com.baeldung.config; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; @@ -14,13 +14,26 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.ldapAuthentication().userSearchBase("ou=people").userSearchFilter("(uid={0})").groupSearchBase("ou=groups").groupSearchFilter("(member={0})").contextSource().root("dc=baeldung,dc=com").ldif("classpath:users.ldif"); + auth.ldapAuthentication() + .userSearchBase("ou=people") + .userSearchFilter("(uid={0})") + .groupSearchBase("ou=groups") + .groupSearchFilter("(member={0})") + .contextSource() + .root("dc=baeldung,dc=com") + .ldif("classpath:users.ldif"); } @Override protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests().antMatchers("/", "/home").permitAll().anyRequest().authenticated(); - http.formLogin().loginPage("/login").permitAll().and().logout().logoutSuccessUrl("/"); + http + .authorizeRequests() + .antMatchers("/", "/home", "/css/**") + .permitAll() + .anyRequest() + .authenticated() + .and().formLogin().loginPage("/login").permitAll() + .and().logout().logoutSuccessUrl("/"); } } diff --git a/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/config/WebConfig.java b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/config/WebConfig.java new file mode 100644 index 0000000000..9809be1844 --- /dev/null +++ b/spring-security-modules/spring-security-ldap/src/main/java/com/baeldung/config/WebConfig.java @@ -0,0 +1,16 @@ +package com.baeldung.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class WebConfig implements WebMvcConfigurer { + + @Override + public void addViewControllers(ViewControllerRegistry registry) { + registry.addViewController("/login") + .setViewName("login"); + } +} diff --git a/spring-security-modules/spring-security-ldap/src/main/resources/application.properties b/spring-security-modules/spring-security-ldap/src/main/resources/application.properties new file mode 100644 index 0000000000..3d0221bb7b --- /dev/null +++ b/spring-security-modules/spring-security-ldap/src/main/resources/application.properties @@ -0,0 +1 @@ +management.health.ldap.enabled=false \ No newline at end of file diff --git a/spring-security-modules/spring-security-ldap/src/main/resources/webSecurityConfig.xml b/spring-security-modules/spring-security-ldap/src/main/resources/webSecurityConfig.xml index c13f65de5e..adfd603e54 100644 --- a/spring-security-modules/spring-security-ldap/src/main/resources/webSecurityConfig.xml +++ b/spring-security-modules/spring-security-ldap/src/main/resources/webSecurityConfig.xml @@ -10,6 +10,7 @@ + From 3f83ed67d3511a057bbf5b0db8e56f214ffd88a7 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Mon, 30 Mar 2020 23:27:11 +0200 Subject: [PATCH 054/503] JAVA-42: Upgrade spring-security-kerberos to Spring Boot 2 --- spring-security-modules/spring-security-kerberos/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-security-modules/spring-security-kerberos/pom.xml b/spring-security-modules/spring-security-kerberos/pom.xml index 6846bdf063..51a48a78c6 100644 --- a/spring-security-modules/spring-security-kerberos/pom.xml +++ b/spring-security-modules/spring-security-kerberos/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../../parent-boot-1 + ../../parent-boot-2 From 3f2d436db4e93cf57428c75758376b8e2d17b3c2 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Mon, 30 Mar 2020 23:45:37 +0200 Subject: [PATCH 055/503] JAVA-42: Upgrade spring-security-cache-control to Spring Boot 2 --- .../spring-security-cache-control/pom.xml | 38 +++---------------- .../ResourceEndpointIntegrationTest.java | 2 +- 2 files changed, 7 insertions(+), 33 deletions(-) diff --git a/spring-security-modules/spring-security-cache-control/pom.xml b/spring-security-modules/spring-security-cache-control/pom.xml index acc37b41ef..743b3c291d 100644 --- a/spring-security-modules/spring-security-cache-control/pom.xml +++ b/spring-security-modules/spring-security-cache-control/pom.xml @@ -8,9 +8,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../../parent-boot-1 + ../../parent-boot-2 @@ -23,41 +23,15 @@ spring-boot-starter-web - org.springframework.security - spring-security-core - - - org.springframework.security - spring-security-config - - - org.springframework.security - spring-security-web - - - javax.servlet - javax.servlet-api - ${javax.servlet-api.version} + org.springframework.boot + spring-boot-starter-security - org.hamcrest - hamcrest - ${hamcrest.version} + org.springframework.boot + spring-boot-starter-test test - - - org.mockito - mockito-core - test - - - - org.springframework - spring-test - - \ No newline at end of file diff --git a/spring-security-modules/spring-security-cache-control/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java b/spring-security-modules/spring-security-cache-control/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java index d6a1a97773..d4d24a4986 100644 --- a/spring-security-modules/spring-security-cache-control/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java +++ b/spring-security-modules/spring-security-cache-control/src/test/java/com/baeldung/cachecontrol/ResourceEndpointIntegrationTest.java @@ -4,8 +4,8 @@ import static io.restassured.RestAssured.given; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.boot.context.embedded.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.test.context.junit4.SpringRunner; import io.restassured.http.ContentType; From 405831d3da839c12ca73562112653842ee83ef44 Mon Sep 17 00:00:00 2001 From: patkorek Date: Tue, 31 Mar 2020 07:36:44 +0200 Subject: [PATCH 056/503] changed tabs to spaces --- ...GraphQL collection.postman_collection.json | 334 +++++++++--------- 1 file changed, 167 insertions(+), 167 deletions(-) diff --git a/spring-boot-modules/spring-boot/src/test/resources/GraphQL collection.postman_collection.json b/spring-boot-modules/spring-boot/src/test/resources/GraphQL collection.postman_collection.json index 7fcaa2c76d..f19bc1febb 100644 --- a/spring-boot-modules/spring-boot/src/test/resources/GraphQL collection.postman_collection.json +++ b/spring-boot-modules/spring-boot/src/test/resources/GraphQL collection.postman_collection.json @@ -1,169 +1,169 @@ { - "info": { - "_postman_id": "910d9690-f629-4491-bbbd-adb30982a386", - "name": "GraphQL collection", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, - "item": [ - { - "name": "mutations", - "item": [ - { - "name": "writePost", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "graphql", - "graphql": { - "query": "mutation writePost ($title: String!, $text: String!, $category: String) {\n writePost (title: $title, text: $text, category: $category) {\n id\n title\n text\n category\n }\n}", - "variables": "{\n \"title\": \"\",\n \"text\": \"\",\n \"category\": \"\"\n}" - }, - "options": { - "graphql": {} - } - }, - "url": { - "raw": "http://localhost:9090/springbootapp/graphql", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "9090", - "path": [ - "springbootapp", - "graphql" - ] - } - }, - "response": [] - } - ], - "protocolProfileBehavior": {} - }, - { - "name": "queries", - "item": [ - { - "name": "get recent posts", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "graphql", - "graphql": { - "query": "{\r\n recentPosts(count: 10, offset: 0) {\r\n id\r\n title\r\n category\r\n text\r\n author {\r\n id\r\n name\r\n thumbnail\r\n }\r\n }\r\n}", - "variables": "" - } - }, - "url": { - "raw": "http://localhost:9090/springbootapp/graphql", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "9090", - "path": [ - "springbootapp", - "graphql" - ] - } - }, - "response": [] - }, - { - "name": "recentPosts - variables", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "graphql", - "graphql": { - "query": "query recentPosts ($count: Int, $offset: Int) {\n recentPosts (count: $count, offset: $offset) {\n id\n title\n text\n category\n }\n}", - "variables": "{\n \"count\": 1,\n \"offset\": 0\n}" - }, - "options": { - "graphql": {} - } - }, - "url": { - "raw": "http://localhost:9090/springbootapp/graphql", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "9090", - "path": [ - "springbootapp", - "graphql" - ] - } - }, - "response": [] - }, - { - "name": "get recent posts - raw", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/graphql", - "type": "text" - } - ], - "body": { - "mode": "raw", - "raw": "query {\r\n recentPosts(count: 10, offset: 0) {\r\n id\r\n title\r\n category\r\n author {\r\n id\r\n name\r\n thumbnail\r\n }\r\n }\r\n}" - }, - "url": { - "raw": "http://localhost:9090/springbootapp/graphql", - "protocol": "http", - "host": [ - "localhost" - ], - "port": "9090", - "path": [ - "springbootapp", - "graphql" - ] - } - }, - "response": [] - } - ], - "protocolProfileBehavior": {} - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "id": "b54f267b-c450-4f2d-8105-2f23bab4c922", - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "id": "00b575be-03d4-4b29-b137-733ead139638", - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ], - "variable": [ - { - "id": "20a274e5-6d51-40d6-81cb-af9eb115b21b", - "key": "url", - "value": "", - "type": "string" - } - ], - "protocolProfileBehavior": {} + "info": { + "_postman_id": "910d9690-f629-4491-bbbd-adb30982a386", + "name": "GraphQL collection", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "mutations", + "item": [ + { + "name": "writePost", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "mutation writePost ($title: String!, $text: String!, $category: String) {\n writePost (title: $title, text: $text, category: $category) {\n id\n title\n text\n category\n }\n}", + "variables": "{\n \"title\": \"\",\n \"text\": \"\",\n \"category\": \"\"\n}" + }, + "options": { + "graphql": {} + } + }, + "url": { + "raw": "http://localhost:9090/springbootapp/graphql", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "springbootapp", + "graphql" + ] + } + }, + "response": [] + } + ], + "protocolProfileBehavior": {} + }, + { + "name": "queries", + "item": [ + { + "name": "get recent posts", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "{\r\n recentPosts(count: 10, offset: 0) {\r\n id\r\n title\r\n category\r\n text\r\n author {\r\n id\r\n name\r\n thumbnail\r\n }\r\n }\r\n}", + "variables": "" + } + }, + "url": { + "raw": "http://localhost:9090/springbootapp/graphql", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "springbootapp", + "graphql" + ] + } + }, + "response": [] + }, + { + "name": "recentPosts - variables", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "graphql", + "graphql": { + "query": "query recentPosts ($count: Int, $offset: Int) {\n recentPosts (count: $count, offset: $offset) {\n id\n title\n text\n category\n }\n}", + "variables": "{\n \"count\": 1,\n \"offset\": 0\n}" + }, + "options": { + "graphql": {} + } + }, + "url": { + "raw": "http://localhost:9090/springbootapp/graphql", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "springbootapp", + "graphql" + ] + } + }, + "response": [] + }, + { + "name": "get recent posts - raw", + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/graphql", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "query {\r\n recentPosts(count: 10, offset: 0) {\r\n id\r\n title\r\n category\r\n author {\r\n id\r\n name\r\n thumbnail\r\n }\r\n }\r\n}" + }, + "url": { + "raw": "http://localhost:9090/springbootapp/graphql", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "9090", + "path": [ + "springbootapp", + "graphql" + ] + } + }, + "response": [] + } + ], + "protocolProfileBehavior": {} + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "b54f267b-c450-4f2d-8105-2f23bab4c922", + "type": "text/javascript", + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "00b575be-03d4-4b29-b137-733ead139638", + "type": "text/javascript", + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "id": "20a274e5-6d51-40d6-81cb-af9eb115b21b", + "key": "url", + "value": "", + "type": "string" + } + ], + "protocolProfileBehavior": {} } \ No newline at end of file From a0478a7832e003ac3748ae5b574504b12e64dc1a Mon Sep 17 00:00:00 2001 From: ramkumarvenkat Date: Tue, 31 Mar 2020 12:09:13 +0530 Subject: [PATCH 057/503] Fix code after article changes --- .../com/baeldung/guava/entity/Profile.java | 20 ++++++++ .../com/baeldung/guava/entity/Session.java | 13 ++++++ .../java/com/baeldung/guava/entity/User.java | 20 ++++++++ .../guava/mapmaker/GuavaMapMakerUnitTest.java | 46 +++++++++++++------ 4 files changed, 84 insertions(+), 15 deletions(-) create mode 100644 guava-collections-map/src/main/java/com/baeldung/guava/entity/Profile.java create mode 100644 guava-collections-map/src/main/java/com/baeldung/guava/entity/Session.java create mode 100644 guava-collections-map/src/main/java/com/baeldung/guava/entity/User.java diff --git a/guava-collections-map/src/main/java/com/baeldung/guava/entity/Profile.java b/guava-collections-map/src/main/java/com/baeldung/guava/entity/Profile.java new file mode 100644 index 0000000000..17a6502f39 --- /dev/null +++ b/guava-collections-map/src/main/java/com/baeldung/guava/entity/Profile.java @@ -0,0 +1,20 @@ +package com.baeldung.guava.entity; + +public class Profile { + private long id; + private String type; + + public Profile(long id, String type) { + this.id = id; + this.type = type; + } + + public long getId() { + return id; + } + + public String getName() { + return type; + } + +} diff --git a/guava-collections-map/src/main/java/com/baeldung/guava/entity/Session.java b/guava-collections-map/src/main/java/com/baeldung/guava/entity/Session.java new file mode 100644 index 0000000000..b834c23df1 --- /dev/null +++ b/guava-collections-map/src/main/java/com/baeldung/guava/entity/Session.java @@ -0,0 +1,13 @@ +package com.baeldung.guava.entity; + +public class Session { + private long id; + + public Session(long id) { + this.id = id; + } + + public long getId() { + return id; + } +} diff --git a/guava-collections-map/src/main/java/com/baeldung/guava/entity/User.java b/guava-collections-map/src/main/java/com/baeldung/guava/entity/User.java new file mode 100644 index 0000000000..613045ec23 --- /dev/null +++ b/guava-collections-map/src/main/java/com/baeldung/guava/entity/User.java @@ -0,0 +1,20 @@ +package com.baeldung.guava.entity; + +public class User { + private long id; + private String name; + + public User(long id, String name) { + this.id = id; + this.name = name; + } + + public long getId() { + return id; + } + + public String getName() { + return name; + } + +} diff --git a/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java b/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java index 8da459f22e..e2bc1349c6 100644 --- a/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java +++ b/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java @@ -1,40 +1,56 @@ package com.baeldung.guava.mapmaker; +import com.baeldung.guava.entity.Profile; +import com.baeldung.guava.entity.Session; +import com.baeldung.guava.entity.User; import com.google.common.collect.MapMaker; +import org.junit.Assert; import org.junit.Test; import java.util.concurrent.ConcurrentMap; +import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertNotNull; public class GuavaMapMakerUnitTest { @Test - public void whenMakeMap_thenCreated() { - ConcurrentMap concurrentMap = new MapMaker().makeMap(); - assertNotNull(concurrentMap); + public void whenCreateCaches_thenCreated() { + ConcurrentMap sessionCache = new MapMaker().makeMap(); + assertNotNull(sessionCache); + + ConcurrentMap profileCache = new MapMaker().makeMap(); + assertNotNull(profileCache); + + User userA = new User(1, "UserA"); + + sessionCache.put(userA, new Session(100)); + Assert.assertThat(sessionCache.size(), equalTo(1)); + + profileCache.put(userA, new Profile(1000, "Personal")); + Assert.assertThat(profileCache.size(), equalTo(1)); } @Test - public void whenMakeMapWithWeakKeys_thenCreated() { - ConcurrentMap concurrentMap = new MapMaker().weakKeys().makeMap(); - assertNotNull(concurrentMap); + public void whenCreateCacheWithInitialCapacity_thenCreated() { + ConcurrentMap profileCache = new MapMaker().initialCapacity(100).makeMap(); + assertNotNull(profileCache); } @Test - public void whenMakeMapWithWeakValues_thenCreated() { - ConcurrentMap concurrentMap = new MapMaker().weakValues().makeMap(); - assertNotNull(concurrentMap); + public void whenCreateCacheWithConcurrencyLevel_thenCreated() { + ConcurrentMap sessionCache = new MapMaker().concurrencyLevel(10).makeMap(); + assertNotNull(sessionCache); } @Test - public void whenMakeMapWithInitialCapacity_thenCreated() { - ConcurrentMap concurrentMap = new MapMaker().initialCapacity(10).makeMap(); - assertNotNull(concurrentMap); + public void whenCreateCacheWithWeakKeys_thenCreated() { + ConcurrentMap sessionCache = new MapMaker().weakKeys().makeMap(); + assertNotNull(sessionCache); } @Test - public void whenMakeMapWithConcurrencyLevel_thenCreated() { - ConcurrentMap concurrentMap = new MapMaker().concurrencyLevel(10).makeMap(); - assertNotNull(concurrentMap); + public void whenCreateCacheWithWeakValues_thenCreated() { + ConcurrentMap profileCache = new MapMaker().weakValues().makeMap(); + assertNotNull(profileCache); } } From 6534bddb6c73cae5ba2614fbc509535ae46babae Mon Sep 17 00:00:00 2001 From: mthomas Date: Tue, 31 Mar 2020 04:43:06 -0500 Subject: [PATCH 058/503] Move code to core-java-modules/core-java-concurrency-advanced-3Add Add missing 'Unit' in test name --- .../com/baeldung/atomicstampedreference}/SafeAccount.java | 6 +++--- .../atomicstampedreference/ThreadSafeAccountUnitTest.java} | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) rename core-java-modules/{core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic => core-java-concurrency-advanced-3/src/main/java/com/baeldung/atomicstampedreference}/SafeAccount.java (82%) rename core-java-modules/{core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeAccountTest.java => core-java-concurrency-advanced-3/src/test/java/com/baeldung/atomicstampedreference/ThreadSafeAccountUnitTest.java} (70%) diff --git a/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeAccount.java b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/atomicstampedreference/SafeAccount.java similarity index 82% rename from core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeAccount.java rename to core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/atomicstampedreference/SafeAccount.java index febfd481c3..fe41429e22 100644 --- a/core-java-modules/core-java-concurrency-advanced/src/main/java/com/baeldung/concurrent/atomic/SafeAccount.java +++ b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/atomicstampedreference/SafeAccount.java @@ -1,12 +1,12 @@ -package com.baeldung.concurrent.atomic; +package com.baeldung.atomicstampedreference; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicStampedReference; public class SafeAccount { - AtomicInteger stamp = new AtomicInteger(0); - AtomicStampedReference balance = new AtomicStampedReference<>(0, 0); + private AtomicInteger stamp = new AtomicInteger(0); + private AtomicStampedReference balance = new AtomicStampedReference<>(0, 0); public int getBalance() { return this.balance.get(new int[1]); diff --git a/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeAccountTest.java b/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/atomicstampedreference/ThreadSafeAccountUnitTest.java similarity index 70% rename from core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeAccountTest.java rename to core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/atomicstampedreference/ThreadSafeAccountUnitTest.java index b9a5fe7773..bd33d5b4ec 100644 --- a/core-java-modules/core-java-concurrency-advanced/src/test/java/com/baeldung/concurrent/atomic/ThreadSafeAccountTest.java +++ b/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/atomicstampedreference/ThreadSafeAccountUnitTest.java @@ -1,12 +1,12 @@ -package com.baeldung.concurrent.atomic; +package com.baeldung.atomicstampedreference; import org.junit.Assert; import org.junit.Test; -public class ThreadSafeAccountTest { +public class ThreadSafeAccountUnitTest { @Test - public void givenMultiThread_whenSafeAccountSetBalance() throws InterruptedException { + public void givenMultiThread_whenSafeAccount_thenSetBalance() throws InterruptedException { SafeAccount account = new SafeAccount(); Thread t = new Thread(() -> { while (!account.withdrawal(100)) From aaffd9614fc1675ab05f992eec62c90be5aef76f Mon Sep 17 00:00:00 2001 From: naXa! Date: Mon, 25 Mar 2019 02:00:03 +0300 Subject: [PATCH 059/503] [BAEL-2749] add dbunit module to parent pom --- pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pom.xml b/pom.xml index 04a2ce054c..734e2c8ab9 100644 --- a/pom.xml +++ b/pom.xml @@ -601,6 +601,8 @@ + dbunit + parent-boot-1 parent-boot-2 parent-spring-4 @@ -1288,6 +1290,8 @@ + dbunit + parent-boot-1 parent-boot-2 parent-spring-4 From a65c5bf202c3326514e7d6c1408bd9e445c06fd9 Mon Sep 17 00:00:00 2001 From: Joao Esperancinha Date: Sun, 29 Mar 2020 11:37:19 +0200 Subject: [PATCH 060/503] [BAEL-2749] Introduces Assertj and uses builder pattern --- dbunit/pom.xml | 36 ++++++++++++++++--- .../baeldung/dbunit/OldSchoolDbUnitTest.java | 8 +++-- .../dbunit/PrepAndExpectedDbUnitTest.java | 12 +++++-- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/dbunit/pom.xml b/dbunit/pom.xml index b77b15f2d4..ab0befcf4c 100644 --- a/dbunit/pom.xml +++ b/dbunit/pom.xml @@ -3,6 +3,16 @@ 4.0.0 dbunit 1.0 + + 1.4.200 + + 1.8 + 1.8 + 3.8.1 + + 3.14.0 + 2.6.0 + dbunit @@ -22,14 +32,30 @@ com.h2database h2 - 1.4.197 + ${h2.version} + test + + + + org.assertj + assertj-core + ${assertj-core.version} test - - - 2.6.0 - + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven-compiler-plugin.source} + ${maven-compiler-plugin.target} + + + + diff --git a/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java index a703863614..2a2f25971b 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java @@ -6,6 +6,7 @@ import org.dbunit.JdbcDatabaseTester; import org.dbunit.dataset.IDataSet; import org.dbunit.dataset.ITable; import org.dbunit.dataset.xml.FlatXmlDataSet; +import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; import org.dbunit.operation.DatabaseOperation; import org.junit.After; import org.junit.Before; @@ -16,6 +17,7 @@ import java.io.InputStream; import java.sql.Connection; import java.sql.ResultSet; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -74,7 +76,7 @@ public class OldSchoolDbUnitTest { final Connection connection = tester.getConnection().getConnection(); final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_delete.xml"); - ITable expectedTable = (new FlatXmlDataSet(is)).getTable("items"); + ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); //expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedTable, new String[]{"produced"}); // Act @@ -94,7 +96,7 @@ public class OldSchoolDbUnitTest { final Connection connection = tester.getConnection().getConnection(); final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_rename.xml"); - ITable expectedTable = (new FlatXmlDataSet(is)).getTable("items"); + ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); //expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedTable, new String[]{"produced"}); // Act @@ -105,7 +107,7 @@ public class OldSchoolDbUnitTest { ITable actualTable = databaseDataSet.getTable("items"); //actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); - Assertion.assertEquals(expectedTable, actualTable); + assertThat(actualTable).isEqualTo(actualTable); } } diff --git a/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java index c3882d5eab..c322cf0ae3 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java @@ -1,6 +1,10 @@ package com.baeldung.dbunit; -import org.dbunit.*; +import org.dbunit.DefaultPrepAndExpectedTestCase; +import org.dbunit.IDatabaseTester; +import org.dbunit.JdbcDatabaseTester; +import org.dbunit.PrepAndExpectedTestCaseSteps; +import org.dbunit.VerifyTableDefinition; import org.dbunit.dataset.IDataSet; import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; import org.dbunit.operation.DatabaseOperation; @@ -12,6 +16,8 @@ import java.io.InputStream; import java.sql.Connection; import java.sql.ResultSet; +import static org.assertj.core.api.Assertions.assertThat; + public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { private static final String JDBC_DRIVER = org.h2.Driver.class.getName(); private static final String JDBC_URL = "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;init=runscript from 'classpath:schema.sql'"; @@ -63,8 +69,8 @@ public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { final ResultSet rs = (ResultSet) super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); // or place assertions at the end - assertTrue(rs.next()); - assertEquals("Xavier", rs.getString("last_name")); + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("last_name")).isEqualTo("Xavier"); } @Test From 71ba591868ed0f200f16c17a3d116cf6c32a559b Mon Sep 17 00:00:00 2001 From: Joao Esperancinha Date: Sun, 29 Mar 2020 18:16:45 +0200 Subject: [PATCH 061/503] [BAEL-2749] Select and Delete for OldSchool --- dbunit/pom.xml | 1 + .../baeldung/dbunit/OldSchoolDbUnitTest.java | 39 +++++++++++-------- .../items_exp_delete_no_produced.xml | 8 ++++ 3 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 dbunit/src/test/resources/items_exp_delete_no_produced.xml diff --git a/dbunit/pom.xml b/dbunit/pom.xml index ab0befcf4c..7ca53cd3be 100644 --- a/dbunit/pom.xml +++ b/dbunit/pom.xml @@ -13,6 +13,7 @@ 3.14.0 2.6.0 + dbunit diff --git a/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java index 2a2f25971b..e64b49263a 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java @@ -5,7 +5,7 @@ import org.dbunit.IDatabaseTester; import org.dbunit.JdbcDatabaseTester; import org.dbunit.dataset.IDataSet; import org.dbunit.dataset.ITable; -import org.dbunit.dataset.xml.FlatXmlDataSet; +import org.dbunit.dataset.filter.DefaultColumnFilter; import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; import org.dbunit.operation.DatabaseOperation; import org.junit.After; @@ -18,8 +18,7 @@ import java.sql.Connection; import java.sql.ResultSet; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.dbunit.Assertion.assertEquals; public class OldSchoolDbUnitTest { private static final String JDBC_DRIVER = org.h2.Driver.class.getName(); @@ -44,7 +43,7 @@ public class OldSchoolDbUnitTest { private static IDataSet initDataSet() throws Exception { final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("data.xml"); - return new FlatXmlDataSet(is); + return new FlatXmlDataSetBuilder().build(is); } @Before @@ -59,35 +58,43 @@ public class OldSchoolDbUnitTest { @Test public void testSelect() throws Exception { - // Arrange final Connection connection = tester.getConnection().getConnection(); - // Act final ResultSet rs = connection.createStatement().executeQuery("select * from iTEMS where id = 1"); - // Assert - assertTrue(rs.next()); - assertEquals("Grey T-Shirt", rs.getString("title")); + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); } @Test public void testDelete() throws Exception { - // Arrange final Connection connection = tester.getConnection().getConnection(); final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_delete.xml"); ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); - //expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedTable, new String[]{"produced"}); - // Act connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); - // Assert final IDataSet databaseDataSet = tester.getConnection().createDataSet(); ITable actualTable = databaseDataSet.getTable("items"); - //actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); - Assertion.assertEquals(expectedTable, actualTable); + assertEquals(expectedTable, actualTable); + } + + @Test + public void testDeleteWithExcludedColumns() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + + final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_delete_no_produced.xml"); + ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); + + connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); + actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); + + assertEquals(expectedTable, actualTable); } @Test @@ -107,7 +114,7 @@ public class OldSchoolDbUnitTest { ITable actualTable = databaseDataSet.getTable("items"); //actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); - assertThat(actualTable).isEqualTo(actualTable); + assertEquals(expectedTable, actualTable); } } diff --git a/dbunit/src/test/resources/items_exp_delete_no_produced.xml b/dbunit/src/test/resources/items_exp_delete_no_produced.xml new file mode 100644 index 0000000000..c9b182a1b2 --- /dev/null +++ b/dbunit/src/test/resources/items_exp_delete_no_produced.xml @@ -0,0 +1,8 @@ + + + + + + + + From e4f4f7110b33f753a50b5f56443b8dff8ab014b5 Mon Sep 17 00:00:00 2001 From: Joao Esperancinha Date: Sun, 29 Mar 2020 21:47:00 +0200 Subject: [PATCH 062/503] [BAEL-2749] Code refactoring --- dbunit/src/main/resources/logback.xml | 2 +- .../baeldung/dbunit/ConnectionSettings.java | 8 ++++ .../baeldung/dbunit/OldSchoolDbUnitTest.java | 32 ++++++++----- .../dbunit/PrepAndExpectedDbUnitTest.java | 48 +++++++------------ .../com/baeldung/dbunit/SampleDbUnitTest.java | 23 ++++----- dbunit/src/test/resources/data.xml | 12 ++--- .../src/test/resources/items_exp_delete.xml | 8 ++-- .../items_exp_delete_no_produced.xml | 8 ++-- .../src/test/resources/items_exp_rename.xml | 10 ++-- .../items_exp_rename_no_produced.xml | 9 ++++ dbunit/src/test/resources/schema.sql | 34 ++++++------- dbunit/src/test/resources/users.xml | 6 +-- .../src/test/resources/users_exp_delete.xml | 4 +- .../src/test/resources/users_exp_rename.xml | 6 +-- 14 files changed, 108 insertions(+), 102 deletions(-) create mode 100644 dbunit/src/test/java/com/baeldung/dbunit/ConnectionSettings.java create mode 100644 dbunit/src/test/resources/items_exp_rename_no_produced.xml diff --git a/dbunit/src/main/resources/logback.xml b/dbunit/src/main/resources/logback.xml index 7d900d8ea8..26beb6d5b4 100644 --- a/dbunit/src/main/resources/logback.xml +++ b/dbunit/src/main/resources/logback.xml @@ -8,6 +8,6 @@ - + \ No newline at end of file diff --git a/dbunit/src/test/java/com/baeldung/dbunit/ConnectionSettings.java b/dbunit/src/test/java/com/baeldung/dbunit/ConnectionSettings.java new file mode 100644 index 0000000000..e842022292 --- /dev/null +++ b/dbunit/src/test/java/com/baeldung/dbunit/ConnectionSettings.java @@ -0,0 +1,8 @@ +package com.baeldung.dbunit; + +public class ConnectionSettings { + public static final String JDBC_DRIVER = org.h2.Driver.class.getName(); + public static final String JDBC_URL = "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;init=runscript from 'classpath:schema.sql'"; + public static final String USER = "sa"; + public static final String PASSWORD = ""; +} diff --git a/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java index e64b49263a..0b63184951 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java @@ -1,6 +1,5 @@ package com.baeldung.dbunit; -import org.dbunit.Assertion; import org.dbunit.IDatabaseTester; import org.dbunit.JdbcDatabaseTester; import org.dbunit.dataset.IDataSet; @@ -17,14 +16,14 @@ import java.io.InputStream; import java.sql.Connection; import java.sql.ResultSet; +import static com.baeldung.dbunit.ConnectionSettings.JDBC_DRIVER; +import static com.baeldung.dbunit.ConnectionSettings.JDBC_URL; +import static com.baeldung.dbunit.ConnectionSettings.PASSWORD; +import static com.baeldung.dbunit.ConnectionSettings.USER; import static org.assertj.core.api.Assertions.assertThat; import static org.dbunit.Assertion.assertEquals; public class OldSchoolDbUnitTest { - private static final String JDBC_DRIVER = org.h2.Driver.class.getName(); - private static final String JDBC_URL = "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;init=runscript from 'classpath:schema.sql'"; - private static final String USER = "sa"; - private static final String PASSWORD = ""; private static IDatabaseTester tester = null; @@ -99,20 +98,31 @@ public class OldSchoolDbUnitTest { @Test public void testUpdate() throws Exception { - // Arrange final Connection connection = tester.getConnection().getConnection(); final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_rename.xml"); - ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); - //expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedTable, new String[]{"produced"}); + final ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); - // Act connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); - // Assert final IDataSet databaseDataSet = tester.getConnection().createDataSet(); ITable actualTable = databaseDataSet.getTable("items"); - //actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); + + assertEquals(expectedTable, actualTable); + } + + @Test + public void testUpdateWithExcludedColumns() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + + final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_rename_no_produced.xml"); + ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); + + connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); + actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); assertEquals(expectedTable, actualTable); } diff --git a/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java index c322cf0ae3..bb70136de2 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java @@ -16,13 +16,13 @@ import java.io.InputStream; import java.sql.Connection; import java.sql.ResultSet; +import static com.baeldung.dbunit.ConnectionSettings.JDBC_DRIVER; +import static com.baeldung.dbunit.ConnectionSettings.JDBC_URL; +import static com.baeldung.dbunit.ConnectionSettings.PASSWORD; +import static com.baeldung.dbunit.ConnectionSettings.USER; import static org.assertj.core.api.Assertions.assertThat; public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { - private static final String JDBC_DRIVER = org.h2.Driver.class.getName(); - private static final String JDBC_URL = "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;init=runscript from 'classpath:schema.sql'"; - private static final String USER = "sa"; - private static final String PASSWORD = ""; @Override public void setUp() throws Exception { @@ -49,60 +49,46 @@ public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { @Test public void testSelect() throws Exception { - // Arrange final Connection connection = getConnection().getConnection(); final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("USERS", new String[]{})}; final String[] prepDataFiles = {"/users.xml"}; final String[] expectedDataFiles = {"/users.xml"}; - final PrepAndExpectedTestCaseSteps testSteps = () -> { - // invoke the method being tested here; for the sake of simplicity we use JDBC API directly in this example - final ResultSet rs = connection.createStatement().executeQuery("select * from USERS where id = 1"); + final PrepAndExpectedTestCaseSteps testSteps = + () -> connection + .createStatement() + .executeQuery("select * from USERS where id = 1"); - // either place assertions here - //assertTrue(rs.next()); - //assertEquals("Xavier", rs.getString("last_name")); - - return rs; - }; - - // Act final ResultSet rs = (ResultSet) super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); - // or place assertions at the end assertThat(rs.next()).isTrue(); assertThat(rs.getString("last_name")).isEqualTo("Xavier"); } @Test public void testUpdate() throws Exception { - // Arrange final Connection connection = getConnection().getConnection(); final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("USERS", new String[]{})}; // define tables to verify - final String[] prepDataFiles = {"/users.xml"}; // define prep files - final String[] expectedDataFiles = {"/users_exp_rename.xml"}; // define expected files - final PrepAndExpectedTestCaseSteps testSteps = () -> { - // invoke the method being tested here; for the sake of simplicity we use JDBC API directly in this example - return connection.createStatement().executeUpdate("update USERS set first_name = 'new name' where id = 1"); - // after this method exits, dbUnit will: - // * verify configured tables - // * cleanup tables as configured - }; + final String[] prepDataFiles = {"/users.xml"}; + final String[] expectedDataFiles = {"/users_exp_rename.xml"}; + final PrepAndExpectedTestCaseSteps testSteps = + () -> connection + .createStatement() + .executeUpdate("update USERS set first_name = 'new name' where id = 1"); - // Act super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); } @Test public void testDelete() throws Exception { - // Arrange final Connection connection = getConnection().getConnection(); final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("USERS", new String[]{})}; final String[] prepDataFiles = {"/users.xml"}; final String[] expectedDataFiles = {"/users_exp_delete.xml"}; final PrepAndExpectedTestCaseSteps testSteps = - () -> connection.createStatement().executeUpdate("delete from USERS where id = 2"); + () -> connection + .createStatement() + .executeUpdate("delete from USERS where id = 2"); - // Act super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); } diff --git a/dbunit/src/test/java/com/baeldung/dbunit/SampleDbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/SampleDbUnitTest.java index cfe4fd4e11..f7970754e7 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/SampleDbUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/SampleDbUnitTest.java @@ -13,11 +13,13 @@ import java.io.InputStream; import java.sql.Connection; import java.sql.ResultSet; +import static com.baeldung.dbunit.ConnectionSettings.JDBC_DRIVER; +import static com.baeldung.dbunit.ConnectionSettings.JDBC_URL; +import static com.baeldung.dbunit.ConnectionSettings.PASSWORD; +import static com.baeldung.dbunit.ConnectionSettings.USER; +import static org.assertj.core.api.Assertions.assertThat; + public class SampleDbUnitTest extends DBTestCase { - private static final String JDBC_DRIVER = org.h2.Driver.class.getName(); - private static final String JDBC_URL = "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;init=runscript from 'classpath:schema.sql'"; - private static final String USER = "sa"; - private static final String PASSWORD = ""; public SampleDbUnitTest(String name) { super(name); @@ -46,29 +48,23 @@ public class SampleDbUnitTest extends DBTestCase { @Test public void testSelect() throws Exception { - // Arrange final Connection connection = getConnection().getConnection(); - // Act final ResultSet rs = connection.createStatement().executeQuery("select * from iTEMS where id = 1"); - // Assert - assertTrue(rs.next()); - assertEquals("Grey T-Shirt", rs.getString("title")); + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); } @Test public void testDelete() throws Exception { - // Arrange final Connection connection = getConnection().getConnection(); final InputStream is = SampleDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_delete.xml"); ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("items"); - // Act connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); - // Assert final IDataSet databaseDataSet = getConnection().createDataSet(); ITable actualTable = databaseDataSet.getTable("items"); @@ -77,16 +73,13 @@ public class SampleDbUnitTest extends DBTestCase { @Test public void testUpdate() throws Exception { - // Arrange final Connection connection = getConnection().getConnection(); final InputStream is = SampleDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_rename.xml"); ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("items"); - // Act connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); - // Assert final IDataSet databaseDataSet = getConnection().createDataSet(); ITable actualTable = databaseDataSet.getTable("items"); diff --git a/dbunit/src/test/resources/data.xml b/dbunit/src/test/resources/data.xml index e4498513e0..ac413cfd23 100644 --- a/dbunit/src/test/resources/data.xml +++ b/dbunit/src/test/resources/data.xml @@ -1,11 +1,11 @@ - + - - - - - + + + + + diff --git a/dbunit/src/test/resources/items_exp_delete.xml b/dbunit/src/test/resources/items_exp_delete.xml index 1aaeff59ca..09b78da493 100644 --- a/dbunit/src/test/resources/items_exp_delete.xml +++ b/dbunit/src/test/resources/items_exp_delete.xml @@ -1,8 +1,8 @@ - - - - + + + + diff --git a/dbunit/src/test/resources/items_exp_delete_no_produced.xml b/dbunit/src/test/resources/items_exp_delete_no_produced.xml index c9b182a1b2..dd76e8c6ce 100644 --- a/dbunit/src/test/resources/items_exp_delete_no_produced.xml +++ b/dbunit/src/test/resources/items_exp_delete_no_produced.xml @@ -1,8 +1,8 @@ - - - - + + + + diff --git a/dbunit/src/test/resources/items_exp_rename.xml b/dbunit/src/test/resources/items_exp_rename.xml index 237280e758..830d83499f 100644 --- a/dbunit/src/test/resources/items_exp_rename.xml +++ b/dbunit/src/test/resources/items_exp_rename.xml @@ -1,9 +1,9 @@ - - - - - + + + + + diff --git a/dbunit/src/test/resources/items_exp_rename_no_produced.xml b/dbunit/src/test/resources/items_exp_rename_no_produced.xml new file mode 100644 index 0000000000..991c4726a0 --- /dev/null +++ b/dbunit/src/test/resources/items_exp_rename_no_produced.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/dbunit/src/test/resources/schema.sql b/dbunit/src/test/resources/schema.sql index 9b5018985a..dc4738ca76 100644 --- a/dbunit/src/test/resources/schema.sql +++ b/dbunit/src/test/resources/schema.sql @@ -1,28 +1,28 @@ CREATE TABLE IF NOT EXISTS USERS ( - `id` int AUTO_INCREMENT NOT NULL, - `first_name` varchar(100) NOT NULL, - `last_name` varchar(100) NOT NULL, - PRIMARY KEY (`id`) + `id` int AUTO_INCREMENT NOT NULL, + `first_name` varchar(100) NOT NULL, + `last_name` varchar(100) NOT NULL, + PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS ITEMS ( - `id` int AUTO_INCREMENT NOT NULL, - `title` varchar(100) NOT NULL, - `produced` date, - `price` float, - PRIMARY KEY (`id`) + `id` int AUTO_INCREMENT NOT NULL, + `title` varchar(100) NOT NULL, + `produced` date, + `price` float, + PRIMARY KEY (`id`) ); CREATE TABLE IF NOT EXISTS PURCHASES ( - `id` int NOT NULL AUTO_INCREMENT, - `id_user` int NOT NULL, - `id_item` int NOT NULL, - `total_price` float NOT NULL, - `quantity` int(11) NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_user`) REFERENCES USERS (`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_item`) REFERENCES ITEMS (`id`) ON DELETE CASCADE ON UPDATE CASCADE + `id` int NOT NULL AUTO_INCREMENT, + `id_user` int NOT NULL, + `id_item` int NOT NULL, + `total_price` float NOT NULL, + `quantity` int(11) NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_user`) REFERENCES USERS (`id`) ON DELETE CASCADE, + FOREIGN KEY (`id_item`) REFERENCES ITEMS (`id`) ON DELETE CASCADE ON UPDATE CASCADE ); diff --git a/dbunit/src/test/resources/users.xml b/dbunit/src/test/resources/users.xml index cebadf2e67..d8ff78024e 100644 --- a/dbunit/src/test/resources/users.xml +++ b/dbunit/src/test/resources/users.xml @@ -1,7 +1,7 @@ - - - + + + diff --git a/dbunit/src/test/resources/users_exp_delete.xml b/dbunit/src/test/resources/users_exp_delete.xml index 8b72ceef89..c4ea6e64e5 100644 --- a/dbunit/src/test/resources/users_exp_delete.xml +++ b/dbunit/src/test/resources/users_exp_delete.xml @@ -1,6 +1,6 @@ - - + + diff --git a/dbunit/src/test/resources/users_exp_rename.xml b/dbunit/src/test/resources/users_exp_rename.xml index 9bc1254967..c187e1ebe5 100644 --- a/dbunit/src/test/resources/users_exp_rename.xml +++ b/dbunit/src/test/resources/users_exp_rename.xml @@ -1,7 +1,7 @@ - - - + + + From d5d1cc7d580b1749b9f29df644ea34cbddeee8ac Mon Sep 17 00:00:00 2001 From: Joao Esperancinha Date: Tue, 31 Mar 2020 12:02:24 +0200 Subject: [PATCH 063/503] [BAEL-2749] Adds DataSourceBaseDBTestCase --- .../baeldung/dbunit/DataSourceDBUnitTest.java | 46 +++++++++++++++++++ ...{SampleDbUnitTest.java => DbUnitTest.java} | 12 ++--- 2 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java rename dbunit/src/test/java/com/baeldung/dbunit/{SampleDbUnitTest.java => DbUnitTest.java} (85%) diff --git a/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java new file mode 100644 index 0000000000..154d93e0af --- /dev/null +++ b/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java @@ -0,0 +1,46 @@ +package com.baeldung.dbunit; + +import org.dbunit.DataSourceBasedDBTestCase; +import org.dbunit.dataset.IDataSet; +import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; +import org.h2.jdbcx.JdbcDataSource; +import org.junit.Test; + +import javax.sql.DataSource; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; + +import static org.assertj.core.api.Assertions.assertThat; + +public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { + @Override + protected DataSource getDataSource() { + JdbcDataSource dataSource = new JdbcDataSource(); + dataSource.setURL( + "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;init=runscript from 'classpath:schema.sql'"); + dataSource.setUser("sa"); + dataSource.setPassword("sa"); + return dataSource; + } + + @Override + protected IDataSet getDataSet() throws Exception { + return new FlatXmlDataSetBuilder().build(getClass() + .getClassLoader() + .getResourceAsStream("data.xml")); + } + + @Test + public void testSimpleDataSet() throws SQLException { + final Connection connection = getDataSource() + .getConnection(); + + final ResultSet rs = connection + .createStatement() + .executeQuery("select * from iTEMS where id = 1"); + + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); + } +} diff --git a/dbunit/src/test/java/com/baeldung/dbunit/SampleDbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java similarity index 85% rename from dbunit/src/test/java/com/baeldung/dbunit/SampleDbUnitTest.java rename to dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java index f7970754e7..8d6a94279a 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/SampleDbUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java @@ -19,9 +19,9 @@ import static com.baeldung.dbunit.ConnectionSettings.PASSWORD; import static com.baeldung.dbunit.ConnectionSettings.USER; import static org.assertj.core.api.Assertions.assertThat; -public class SampleDbUnitTest extends DBTestCase { +public class DbUnitTest extends DBTestCase { - public SampleDbUnitTest(String name) { + public DbUnitTest(String name) { super(name); System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS, JDBC_DRIVER); System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL, JDBC_URL); @@ -32,7 +32,7 @@ public class SampleDbUnitTest extends DBTestCase { @Override protected IDataSet getDataSet() throws Exception { - final InputStream is = SampleDbUnitTest.class.getClassLoader().getResourceAsStream("data.xml"); + final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("data.xml"); return new FlatXmlDataSetBuilder().build(is); } @@ -53,14 +53,14 @@ public class SampleDbUnitTest extends DBTestCase { final ResultSet rs = connection.createStatement().executeQuery("select * from iTEMS where id = 1"); assertThat(rs.next()).isTrue(); - assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); + assertThat(rs.getString( "title")).isEqualTo("Grey T-Shirt"); } @Test public void testDelete() throws Exception { final Connection connection = getConnection().getConnection(); - final InputStream is = SampleDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_delete.xml"); + final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_delete.xml"); ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("items"); connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); @@ -75,7 +75,7 @@ public class SampleDbUnitTest extends DBTestCase { public void testUpdate() throws Exception { final Connection connection = getConnection().getConnection(); - final InputStream is = SampleDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_rename.xml"); + final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_rename.xml"); ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("items"); connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); From ef19d83db5f48290978f5c4e9e3c738a53e6087c Mon Sep 17 00:00:00 2001 From: Joao Esperancinha Date: Tue, 31 Mar 2020 12:38:39 +0200 Subject: [PATCH 064/503] [BAEL-2749] USERS table name changed to CLIENTS --- .../baeldung/dbunit/DataSourceDBUnitTest.java | 18 +++++++++++++++--- .../java/com/baeldung/dbunit/DbUnitTest.java | 1 - .../dbunit/PrepAndExpectedDbUnitTest.java | 12 ++++++------ dbunit/src/test/resources/data.xml | 2 +- dbunit/src/test/resources/schema.sql | 4 ++-- dbunit/src/test/resources/users.xml | 6 +++--- dbunit/src/test/resources/users_exp_delete.xml | 4 ++-- dbunit/src/test/resources/users_exp_rename.xml | 6 +++--- 8 files changed, 32 insertions(+), 21 deletions(-) diff --git a/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java index 154d93e0af..c8045394c4 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java @@ -1,7 +1,9 @@ package com.baeldung.dbunit; +import org.dbunit.Assertion; import org.dbunit.DataSourceBasedDBTestCase; import org.dbunit.dataset.IDataSet; +import org.dbunit.dataset.ITable; import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; import org.h2.jdbcx.JdbcDataSource; import org.junit.Test; @@ -11,16 +13,17 @@ import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; +import static com.baeldung.dbunit.ConnectionSettings.JDBC_URL; import static org.assertj.core.api.Assertions.assertThat; public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { + @Override protected DataSource getDataSource() { JdbcDataSource dataSource = new JdbcDataSource(); - dataSource.setURL( - "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;init=runscript from 'classpath:schema.sql'"); + dataSource.setURL(JDBC_URL); dataSource.setUser("sa"); - dataSource.setPassword("sa"); + dataSource.setPassword(""); return dataSource; } @@ -43,4 +46,13 @@ public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { assertThat(rs.next()).isTrue(); assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); } + + @Test + public void testEmptySchema() throws Exception { + IDataSet expectedDataSet = getDataSet(); + ITable expectedTable = expectedDataSet.getTable("CLIENTS"); + IDataSet databaseDataSet = getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("CLIENTS"); + Assertion.assertEquals(expectedTable, actualTable); + } } diff --git a/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java index 8d6a94279a..479ea3dd51 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java @@ -27,7 +27,6 @@ public class DbUnitTest extends DBTestCase { System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL, JDBC_URL); System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME, USER); System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD, PASSWORD); - // System.setProperty( PropertiesBasedJdbcDatabaseTester.DBUNIT_SCHEMA, ""); } @Override diff --git a/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java index bb70136de2..2c7e5de508 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java @@ -50,13 +50,13 @@ public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { @Test public void testSelect() throws Exception { final Connection connection = getConnection().getConnection(); - final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("USERS", new String[]{})}; + final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("CLIENTS", new String[]{})}; final String[] prepDataFiles = {"/users.xml"}; final String[] expectedDataFiles = {"/users.xml"}; final PrepAndExpectedTestCaseSteps testSteps = () -> connection .createStatement() - .executeQuery("select * from USERS where id = 1"); + .executeQuery("select * from CLIENTS where id = 1"); final ResultSet rs = (ResultSet) super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); @@ -67,13 +67,13 @@ public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { @Test public void testUpdate() throws Exception { final Connection connection = getConnection().getConnection(); - final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("USERS", new String[]{})}; // define tables to verify + final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("CLIENTS", new String[]{})}; // define tables to verify final String[] prepDataFiles = {"/users.xml"}; final String[] expectedDataFiles = {"/users_exp_rename.xml"}; final PrepAndExpectedTestCaseSteps testSteps = () -> connection .createStatement() - .executeUpdate("update USERS set first_name = 'new name' where id = 1"); + .executeUpdate("update CLIENTS set first_name = 'new name' where id = 1"); super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); } @@ -81,13 +81,13 @@ public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { @Test public void testDelete() throws Exception { final Connection connection = getConnection().getConnection(); - final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("USERS", new String[]{})}; + final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("CLIENTS", new String[]{})}; final String[] prepDataFiles = {"/users.xml"}; final String[] expectedDataFiles = {"/users_exp_delete.xml"}; final PrepAndExpectedTestCaseSteps testSteps = () -> connection .createStatement() - .executeUpdate("delete from USERS where id = 2"); + .executeUpdate("delete from CLIENTS where id = 2"); super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); } diff --git a/dbunit/src/test/resources/data.xml b/dbunit/src/test/resources/data.xml index ac413cfd23..4230073fc6 100644 --- a/dbunit/src/test/resources/data.xml +++ b/dbunit/src/test/resources/data.xml @@ -1,7 +1,7 @@ - + diff --git a/dbunit/src/test/resources/schema.sql b/dbunit/src/test/resources/schema.sql index dc4738ca76..c2a8d2d630 100644 --- a/dbunit/src/test/resources/schema.sql +++ b/dbunit/src/test/resources/schema.sql @@ -1,4 +1,4 @@ -CREATE TABLE IF NOT EXISTS USERS +CREATE TABLE IF NOT EXISTS CLIENTS ( `id` int AUTO_INCREMENT NOT NULL, `first_name` varchar(100) NOT NULL, @@ -23,6 +23,6 @@ CREATE TABLE IF NOT EXISTS PURCHASES `total_price` float NOT NULL, `quantity` int(11) NOT NULL, PRIMARY KEY (`id`), - FOREIGN KEY (`id_user`) REFERENCES USERS (`id`) ON DELETE CASCADE, + FOREIGN KEY (`id_user`) REFERENCES CLIENTS (`id`) ON DELETE CASCADE, FOREIGN KEY (`id_item`) REFERENCES ITEMS (`id`) ON DELETE CASCADE ON UPDATE CASCADE ); diff --git a/dbunit/src/test/resources/users.xml b/dbunit/src/test/resources/users.xml index d8ff78024e..9c14435362 100644 --- a/dbunit/src/test/resources/users.xml +++ b/dbunit/src/test/resources/users.xml @@ -1,7 +1,7 @@ - - - + + + diff --git a/dbunit/src/test/resources/users_exp_delete.xml b/dbunit/src/test/resources/users_exp_delete.xml index c4ea6e64e5..3780c00c4c 100644 --- a/dbunit/src/test/resources/users_exp_delete.xml +++ b/dbunit/src/test/resources/users_exp_delete.xml @@ -1,6 +1,6 @@ - - + + diff --git a/dbunit/src/test/resources/users_exp_rename.xml b/dbunit/src/test/resources/users_exp_rename.xml index c187e1ebe5..a576cc9e80 100644 --- a/dbunit/src/test/resources/users_exp_rename.xml +++ b/dbunit/src/test/resources/users_exp_rename.xml @@ -1,7 +1,7 @@ - - - + + + From 07947ce4d62daae7bc147fe7b4ac106b070b4d0e Mon Sep 17 00:00:00 2001 From: Joao Esperancinha Date: Tue, 31 Mar 2020 13:31:11 +0200 Subject: [PATCH 065/503] [BAEL-2749] Insertion test with ignore cols --- .../baeldung/dbunit/DataSourceDBUnitTest.java | 18 ++++++++++++++++++ dbunit/src/test/resources/expected-user.xml | 5 +++++ 2 files changed, 23 insertions(+) create mode 100644 dbunit/src/test/resources/expected-user.xml diff --git a/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java index c8045394c4..d30305ecf2 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java @@ -55,4 +55,22 @@ public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { ITable actualTable = databaseDataSet.getTable("CLIENTS"); Assertion.assertEquals(expectedTable, actualTable); } + + + @Test + public void testAssertByQuery() throws Exception { + IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(getClass() + .getClassLoader() + .getResourceAsStream("expected-user.xml")); + ITable expectedTable = expectedDataSet.getTable("CLIENTS"); + Connection conn = getDataSource().getConnection(); + conn.createStatement() + .executeUpdate( + "INSERT INTO CLIENTS (first_name, last_name) VALUES ('John', 'Jansen')"); + ITable actualData = getConnection() + .createQueryTable( + "result_name", + "SELECT * FROM CLIENTS WHERE id='2'"); + Assertion.assertEqualsIgnoreCols(expectedTable, actualData, new String[]{"id"}); + } } diff --git a/dbunit/src/test/resources/expected-user.xml b/dbunit/src/test/resources/expected-user.xml new file mode 100644 index 0000000000..379db13601 --- /dev/null +++ b/dbunit/src/test/resources/expected-user.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file From 906d72859f67d1d9d9016d6b689805286d4c2675 Mon Sep 17 00:00:00 2001 From: Joao Esperancinha Date: Tue, 31 Mar 2020 17:51:04 +0200 Subject: [PATCH 066/503] [BAEL-2749] Test Code Completion --- .../baeldung/dbunit/DataSourceDBUnitTest.java | 49 ++++++++++++++++++- .../java/com/baeldung/dbunit/DbUnitTest.java | 2 +- .../baeldung/dbunit/OldSchoolDbUnitTest.java | 19 ++++++- dbunit/src/test/resources/data.xml | 2 - .../expected-ignoring-registered_at.xml | 9 ++++ .../resources/expected-multiple-failures.xml | 9 ++++ dbunit/src/test/resources/expected-user.xml | 3 +- dbunit/src/test/resources/items.xml | 1 - .../src/test/resources/items_exp_delete.xml | 1 - .../items_exp_delete_no_produced.xml | 1 - .../src/test/resources/items_exp_rename.xml | 1 - .../items_exp_rename_no_produced.xml | 1 - dbunit/src/test/resources/users.xml | 1 - .../src/test/resources/users_exp_delete.xml | 1 - .../src/test/resources/users_exp_rename.xml | 1 - 15 files changed, 85 insertions(+), 16 deletions(-) create mode 100644 dbunit/src/test/resources/expected-ignoring-registered_at.xml create mode 100644 dbunit/src/test/resources/expected-multiple-failures.xml diff --git a/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java index d30305ecf2..7482f38535 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java @@ -2,10 +2,15 @@ package com.baeldung.dbunit; import org.dbunit.Assertion; import org.dbunit.DataSourceBasedDBTestCase; +import org.dbunit.assertion.DiffCollectingFailureHandler; +import org.dbunit.assertion.Difference; import org.dbunit.dataset.IDataSet; import org.dbunit.dataset.ITable; import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; +import org.dbunit.operation.DatabaseOperation; import org.h2.jdbcx.JdbcDataSource; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import javax.sql.DataSource; @@ -14,6 +19,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import static com.baeldung.dbunit.ConnectionSettings.JDBC_URL; +import static java.util.stream.Collectors.joining; import static org.assertj.core.api.Assertions.assertThat; public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { @@ -34,6 +40,27 @@ public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { .getResourceAsStream("data.xml")); } + @Override + protected DatabaseOperation getSetUpOperation() { + return DatabaseOperation.REFRESH; + } + + @Override + protected DatabaseOperation getTearDownOperation() { + return DatabaseOperation.DELETE_ALL; + } + + @Before + public void setUp() throws Exception { + super.setUp(); + } + + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + @Test public void testSimpleDataSet() throws SQLException { final Connection connection = getDataSource() @@ -56,7 +83,6 @@ public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { Assertion.assertEquals(expectedTable, actualTable); } - @Test public void testAssertByQuery() throws Exception { IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(getClass() @@ -70,7 +96,26 @@ public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { ITable actualData = getConnection() .createQueryTable( "result_name", - "SELECT * FROM CLIENTS WHERE id='2'"); + "SELECT * FROM CLIENTS WHERE last_name='Jansen'"); Assertion.assertEqualsIgnoreCols(expectedTable, actualData, new String[]{"id"}); } + + @Test(expected = AssertionError.class) + public void testMultipleFailures() throws Exception { + IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(getClass().getClassLoader().getResourceAsStream("expected-multiple-failures.xml")); + ITable expectedTable = expectedDataSet.getTable("ITEMS"); + Connection conn = getDataSource().getConnection(); + conn.createStatement().executeUpdate("INSERT INTO ITEMS (title, price) VALUES ('Battery', '1000000')"); + ITable actualData = getConnection().createDataSet().getTable("ITEMS"); + DiffCollectingFailureHandler collectingHandler = new DiffCollectingFailureHandler(); + Assertion.assertEquals(expectedTable, actualData, collectingHandler); + if (!collectingHandler.getDiffList().isEmpty()) { + String message = (String) collectingHandler.getDiffList().stream().map(d -> formatDifference((Difference) d)).collect(joining("\n")); +// throw new AssertionError(message); + } + } + + private static String formatDifference(Difference diff) { + return "expected value in " + diff.getExpectedTable().getTableMetaData().getTableName() + "." + diff.getColumnName() + " row " + diff.getRowIndex() + ":" + diff.getExpectedValue() + ", but was: " + diff.getActualValue(); + } } diff --git a/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java index 479ea3dd51..1dee5afb28 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java @@ -42,7 +42,7 @@ public class DbUnitTest extends DBTestCase { @Override protected DatabaseOperation getTearDownOperation() { - return DatabaseOperation.NONE; + return DatabaseOperation.DELETE_ALL; } @Test diff --git a/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java index 0b63184951..3b46feb304 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java @@ -1,5 +1,6 @@ package com.baeldung.dbunit; +import org.dbunit.Assertion; import org.dbunit.IDatabaseTester; import org.dbunit.JdbcDatabaseTester; import org.dbunit.dataset.IDataSet; @@ -36,7 +37,7 @@ public class OldSchoolDbUnitTest { final JdbcDatabaseTester tester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER, PASSWORD); tester.setDataSet(initDataSet()); tester.setSetUpOperation(DatabaseOperation.REFRESH); - tester.setTearDownOperation(DatabaseOperation.NONE); + tester.setTearDownOperation(DatabaseOperation.DELETE_ALL); return tester; } @@ -65,6 +66,22 @@ public class OldSchoolDbUnitTest { assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); } + @Test + public void testIgnoringProduced() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + final String[] excludedColumns = {"id", "produced"}; + final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(getClass().getClassLoader() + .getResourceAsStream("expected-ignoring-registered_at.xml")); + final ITable expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedDataSet.getTable("ITEMS"), excludedColumns); + + connection.createStatement().executeUpdate("INSERT INTO ITEMS (title, price, produced) VALUES('Necklace', 199.99, now())"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + final ITable actualTable = DefaultColumnFilter.excludedColumnsTable(databaseDataSet.getTable("ITEMS"), excludedColumns); + + Assertion.assertEquals(expectedTable, actualTable); + } + @Test public void testDelete() throws Exception { final Connection connection = tester.getConnection().getConnection(); diff --git a/dbunit/src/test/resources/data.xml b/dbunit/src/test/resources/data.xml index 4230073fc6..290cc36890 100644 --- a/dbunit/src/test/resources/data.xml +++ b/dbunit/src/test/resources/data.xml @@ -1,8 +1,6 @@ - - diff --git a/dbunit/src/test/resources/expected-ignoring-registered_at.xml b/dbunit/src/test/resources/expected-ignoring-registered_at.xml new file mode 100644 index 0000000000..ea57b6a961 --- /dev/null +++ b/dbunit/src/test/resources/expected-ignoring-registered_at.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/dbunit/src/test/resources/expected-multiple-failures.xml b/dbunit/src/test/resources/expected-multiple-failures.xml new file mode 100644 index 0000000000..ea57b6a961 --- /dev/null +++ b/dbunit/src/test/resources/expected-multiple-failures.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/dbunit/src/test/resources/expected-user.xml b/dbunit/src/test/resources/expected-user.xml index 379db13601..631dd84210 100644 --- a/dbunit/src/test/resources/expected-user.xml +++ b/dbunit/src/test/resources/expected-user.xml @@ -1,5 +1,4 @@ - - + \ No newline at end of file diff --git a/dbunit/src/test/resources/items.xml b/dbunit/src/test/resources/items.xml index 04a975d7ee..d13e93bbe0 100644 --- a/dbunit/src/test/resources/items.xml +++ b/dbunit/src/test/resources/items.xml @@ -1,5 +1,4 @@ - diff --git a/dbunit/src/test/resources/items_exp_delete.xml b/dbunit/src/test/resources/items_exp_delete.xml index 09b78da493..a6fa2b33e8 100644 --- a/dbunit/src/test/resources/items_exp_delete.xml +++ b/dbunit/src/test/resources/items_exp_delete.xml @@ -1,5 +1,4 @@ - diff --git a/dbunit/src/test/resources/items_exp_delete_no_produced.xml b/dbunit/src/test/resources/items_exp_delete_no_produced.xml index dd76e8c6ce..3e7f854f5f 100644 --- a/dbunit/src/test/resources/items_exp_delete_no_produced.xml +++ b/dbunit/src/test/resources/items_exp_delete_no_produced.xml @@ -1,5 +1,4 @@ - diff --git a/dbunit/src/test/resources/items_exp_rename.xml b/dbunit/src/test/resources/items_exp_rename.xml index 830d83499f..32f1d57cf6 100644 --- a/dbunit/src/test/resources/items_exp_rename.xml +++ b/dbunit/src/test/resources/items_exp_rename.xml @@ -1,5 +1,4 @@ - diff --git a/dbunit/src/test/resources/items_exp_rename_no_produced.xml b/dbunit/src/test/resources/items_exp_rename_no_produced.xml index 991c4726a0..b42d3804fa 100644 --- a/dbunit/src/test/resources/items_exp_rename_no_produced.xml +++ b/dbunit/src/test/resources/items_exp_rename_no_produced.xml @@ -1,5 +1,4 @@ - diff --git a/dbunit/src/test/resources/users.xml b/dbunit/src/test/resources/users.xml index 9c14435362..9ac3909bc5 100644 --- a/dbunit/src/test/resources/users.xml +++ b/dbunit/src/test/resources/users.xml @@ -1,5 +1,4 @@ - diff --git a/dbunit/src/test/resources/users_exp_delete.xml b/dbunit/src/test/resources/users_exp_delete.xml index 3780c00c4c..2fe97ae6f6 100644 --- a/dbunit/src/test/resources/users_exp_delete.xml +++ b/dbunit/src/test/resources/users_exp_delete.xml @@ -1,5 +1,4 @@ - diff --git a/dbunit/src/test/resources/users_exp_rename.xml b/dbunit/src/test/resources/users_exp_rename.xml index a576cc9e80..95682118bb 100644 --- a/dbunit/src/test/resources/users_exp_rename.xml +++ b/dbunit/src/test/resources/users_exp_rename.xml @@ -1,5 +1,4 @@ - From 0b1c5e01a5108350a493a06e07d2779a0b9e3f60 Mon Sep 17 00:00:00 2001 From: Joao Esperancinha Date: Tue, 31 Mar 2020 20:18:11 +0200 Subject: [PATCH 067/503] [BAEL-2749] Improves code and makes a copy in libraries-testing --- dbunit/README.md | 2 - dbunit/docs/db_schema.png | Bin 17099 -> 0 bytes .../baeldung/dbunit/DataSourceDBUnitTest.java | 75 ++++---- .../java/com/baeldung/dbunit/DbUnitTest.java | 33 ++-- .../baeldung/dbunit/OldSchoolDbUnitTest.java | 85 +++++---- .../dbunit/PrepAndExpectedDbUnitTest.java | 23 +-- libraries-testing/pom.xml | 37 ++++ .../baeldung/dbunit/ConnectionSettings.java | 8 + .../baeldung/dbunit/DataSourceDBUnitTest.java | 136 +++++++++++++++ .../java/com/baeldung/dbunit/DbUnitTest.java | 90 ++++++++++ .../baeldung/dbunit/OldSchoolDbUnitTest.java | 161 ++++++++++++++++++ .../dbunit/PrepAndExpectedDbUnitTest.java | 89 ++++++++++ .../src/test/resources/dbunit/data.xml | 9 + .../expected-ignoring-registered_at.xml | 9 + .../dbunit/expected-multiple-failures.xml | 9 + .../test/resources/dbunit/expected-user.xml | 4 + .../src/test/resources/dbunit/items.xml | 8 + .../resources/dbunit/items_exp_delete.xml | 7 + .../dbunit/items_exp_delete_no_produced.xml | 7 + .../resources/dbunit/items_exp_rename.xml | 8 + .../dbunit/items_exp_rename_no_produced.xml | 8 + .../src/test/resources/dbunit/schema.sql | 28 +++ .../src/test/resources/dbunit/users.xml | 6 + .../resources/dbunit/users_exp_delete.xml | 5 + .../resources/dbunit/users_exp_rename.xml | 6 + 25 files changed, 758 insertions(+), 95 deletions(-) delete mode 100644 dbunit/docs/db_schema.png create mode 100644 libraries-testing/src/test/java/com/baeldung/dbunit/ConnectionSettings.java create mode 100644 libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java create mode 100644 libraries-testing/src/test/java/com/baeldung/dbunit/DbUnitTest.java create mode 100644 libraries-testing/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java create mode 100644 libraries-testing/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java create mode 100644 libraries-testing/src/test/resources/dbunit/data.xml create mode 100644 libraries-testing/src/test/resources/dbunit/expected-ignoring-registered_at.xml create mode 100644 libraries-testing/src/test/resources/dbunit/expected-multiple-failures.xml create mode 100644 libraries-testing/src/test/resources/dbunit/expected-user.xml create mode 100644 libraries-testing/src/test/resources/dbunit/items.xml create mode 100644 libraries-testing/src/test/resources/dbunit/items_exp_delete.xml create mode 100644 libraries-testing/src/test/resources/dbunit/items_exp_delete_no_produced.xml create mode 100644 libraries-testing/src/test/resources/dbunit/items_exp_rename.xml create mode 100644 libraries-testing/src/test/resources/dbunit/items_exp_rename_no_produced.xml create mode 100644 libraries-testing/src/test/resources/dbunit/schema.sql create mode 100644 libraries-testing/src/test/resources/dbunit/users.xml create mode 100644 libraries-testing/src/test/resources/dbunit/users_exp_delete.xml create mode 100644 libraries-testing/src/test/resources/dbunit/users_exp_rename.xml diff --git a/dbunit/README.md b/dbunit/README.md index 383bd6fb7e..333cac9439 100644 --- a/dbunit/README.md +++ b/dbunit/README.md @@ -1,6 +1,4 @@ ### Database schema -![db schema](docs/db_schema.png) - ### Relevant Articles: - [Introduction To DBUnit](https://www.baeldung.com/dbunit) diff --git a/dbunit/docs/db_schema.png b/dbunit/docs/db_schema.png deleted file mode 100644 index d9185bacd2c624c8e05aea87bf542cfdfd7f1604..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17099 zcmch91VJ!}GI}RUv>+r(2*N1QqxWuf5_R<6d+(z6 z-!1Yy&%5`2fBT$$UFV!XTv)U2wZ3buZ~d&#JpnIY$Y5iTVIUzPVav%%svsfVi2;60 z(eDB+822AMMnVz~my;BG<)XV4zoAOL7CX9s?c%i38RO6$T#=SwZAPC=hhk8vhx^8Q z*#LRjxRBks5RbaoFYa^Wn-AE&AA=r-3LTBMOb=R@GsRgBsavVYrG>wGOr>)A<@u7s z^fs|#&Wtt9po;d?v-)=(LkBv$2R%Cz>lKM!Z?Tb(M9(jn_pok+y9+`_62*OwKtk$8 zo&_Tz9UxT#?LtWZr<(&I!)U8__hyKYxIU@CNRd7xgOCsIRBmSfPkxJaK+5s27#r~* zG6v{|b|Wo_IW3hMBw6xVuqc&L6v7t0DSG9~u4~{8J^CJ)nh02y2NI}y{pRx+^Gg$FS!w(9&E1EFBz$I6)Zflx43pyBK@pRkNHk|*mL@sdv$r;pt=FadpwQ?=zHNdLYUp` zF=E$=R4ZeDuOJz%!k(2ue$8WNeoEsp^^NH#@Xo(m(OzoI=t5# zzXlZrt-6`k>}PDay%Fq$Rk^rGDj)f3K@vy3E-Dw&-~b*&gh!uFTJcZhM}TWc%fgs1HHhc(^S$SoaX%_2&&^E=uy9?xVmmd3L1=gH@|d3U@_L+}J9#zeZdmZmu-5Pbw4##7NQ+(l99IQMFD~j3~ zbQ^50WpOG3nZE_(Y=$Hm&sz7~mjU`Kjq51&gG^89YIt!*& zd#WI1JErze&qk;QrQdye`bWJ35d(&*au%Wk z>GREqQy__f+kVP0D=Mr)x7kKs63{&`nqOAtAk=@y6kYLS6UuX-|2dD+_DCTp)kbk! zMu%93iQ*MAHv>%bql2bqFd`-Bje>Pc>Tdyr2pL{7ok#oU#wAzC6C4uv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kghuf#}(c^Wb z6kYOl?c~F-sY(QS*BsB>VDIE)r{dShNS&bCp2u(;6)ba;y;kupYJS+B6(||nD-7=n zQ&E2MRWDJ-{@w+h-VX?aYq=@ocwtQq1@~BQ!94&gNFr;mRLIw9DQoIItG~Y7QMSOm zA5wqSR}U#r{m=^y-*{>XOOB8Xk`0$^5i@yP*GL-9JWF*-whSECl9)$lN(ybe>OCZC zO8SLji%lUG$7K6sg!ObyyUt>!>e%4mD{bwd^!kfm@{588bQQuXsOH&=%ga|G&6Ygc zdBYY(pa^ZWt=>6Xh)X@zp*j2|if55bF?^O;*3&2qLEi&_Y24di2>QlS zrkTy90&fqbA1bT8I=|8>HNYi8#qU@Bz+cpZcQAOK#N%*CBa>jf!6(*!lF}KVjSh=3 zQw!;w2r;Y=Bu9wlBxC!<3p!@Ey>H|888U3p_;S&9QtNeL*=N_cmV88Z) formatDifference((Difference) d)).collect(joining("\n")); -// throw new AssertionError(message); + try (final InputStream is = getClass() + .getClassLoader() + .getResourceAsStream("expected-multiple-failures.xml")) { + final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); + final ITable expectedTable = expectedDataSet.getTable("ITEMS"); + final Connection conn = getDataSource().getConnection(); + final DiffCollectingFailureHandler collectingHandler = new DiffCollectingFailureHandler(); + + conn.createStatement().executeUpdate("INSERT INTO ITEMS (title, price) VALUES ('Battery', '1000000')"); + final ITable actualData = getConnection().createDataSet().getTable("ITEMS"); + + Assertion.assertEquals(expectedTable, actualData, collectingHandler); + if (!collectingHandler.getDiffList().isEmpty()) { + String message = (String) collectingHandler.getDiffList().stream().map(d -> formatDifference((Difference) d)).collect(joining("\n")); + logger.error(() -> message); + } } } diff --git a/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java index 1dee5afb28..d24410bedf 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java @@ -31,8 +31,9 @@ public class DbUnitTest extends DBTestCase { @Override protected IDataSet getDataSet() throws Exception { - final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("data.xml"); - return new FlatXmlDataSetBuilder().build(is); + try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("data.xml")) { + return new FlatXmlDataSetBuilder().build(is); + } } @Override @@ -52,37 +53,39 @@ public class DbUnitTest extends DBTestCase { final ResultSet rs = connection.createStatement().executeQuery("select * from iTEMS where id = 1"); assertThat(rs.next()).isTrue(); - assertThat(rs.getString( "title")).isEqualTo("Grey T-Shirt"); + assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); } @Test public void testDelete() throws Exception { final Connection connection = getConnection().getConnection(); - final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_delete.xml"); - ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("items"); + try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_delete.xml")) { + ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("items"); - connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); + connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); - final IDataSet databaseDataSet = getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); + final IDataSet databaseDataSet = getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); - Assertion.assertEquals(expectedTable, actualTable); + Assertion.assertEquals(expectedTable, actualTable); + } } @Test public void testUpdate() throws Exception { final Connection connection = getConnection().getConnection(); - final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_rename.xml"); - ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("items"); + try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_rename.xml")) { + ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("items"); - connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); + connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); - final IDataSet databaseDataSet = getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); + final IDataSet databaseDataSet = getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); - Assertion.assertEquals(expectedTable, actualTable); + Assertion.assertEquals(expectedTable, actualTable); + } } } diff --git a/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java index 3b46feb304..41d7ffd8d4 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java @@ -42,8 +42,9 @@ public class OldSchoolDbUnitTest { } private static IDataSet initDataSet() throws Exception { - final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("data.xml"); - return new FlatXmlDataSetBuilder().build(is); + try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("data.xml")) { + return new FlatXmlDataSetBuilder().build(is); + } } @Before @@ -70,78 +71,92 @@ public class OldSchoolDbUnitTest { public void testIgnoringProduced() throws Exception { final Connection connection = tester.getConnection().getConnection(); final String[] excludedColumns = {"id", "produced"}; - final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(getClass().getClassLoader() - .getResourceAsStream("expected-ignoring-registered_at.xml")); - final ITable expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedDataSet.getTable("ITEMS"), excludedColumns); + try (final InputStream is = getClass().getClassLoader() + .getResourceAsStream("expected-ignoring-registered_at.xml")) { + final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); + final ITable expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedDataSet.getTable("ITEMS"), excludedColumns); - connection.createStatement().executeUpdate("INSERT INTO ITEMS (title, price, produced) VALUES('Necklace', 199.99, now())"); + connection.createStatement().executeUpdate("INSERT INTO ITEMS (title, price, produced) VALUES('Necklace', 199.99, now())"); - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - final ITable actualTable = DefaultColumnFilter.excludedColumnsTable(databaseDataSet.getTable("ITEMS"), excludedColumns); + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + final ITable actualTable = DefaultColumnFilter.excludedColumnsTable(databaseDataSet.getTable("ITEMS"), excludedColumns); - Assertion.assertEquals(expectedTable, actualTable); + Assertion.assertEquals(expectedTable, actualTable); + } } @Test public void testDelete() throws Exception { final Connection connection = tester.getConnection().getConnection(); - final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_delete.xml"); - ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); + try (final InputStream is = + OldSchoolDbUnitTest.class.getClassLoader() + .getResourceAsStream("items_exp_delete.xml");) { + ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); - connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); + connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); - assertEquals(expectedTable, actualTable); + assertEquals(expectedTable, actualTable); + } } @Test public void testDeleteWithExcludedColumns() throws Exception { final Connection connection = tester.getConnection().getConnection(); - final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_delete_no_produced.xml"); - ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); + try (final InputStream is = + OldSchoolDbUnitTest.class.getClassLoader() + .getResourceAsStream("items_exp_delete_no_produced.xml")) { + final ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); - connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); + connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); - actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); + actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); - assertEquals(expectedTable, actualTable); + assertEquals(expectedTable, actualTable); + } } @Test public void testUpdate() throws Exception { final Connection connection = tester.getConnection().getConnection(); - final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_rename.xml"); - final ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); + try (final InputStream is = + OldSchoolDbUnitTest.class.getClassLoader() + .getResourceAsStream("items_exp_rename.xml")) { + final ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); - connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); + connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); - assertEquals(expectedTable, actualTable); + assertEquals(expectedTable, actualTable); + } } @Test public void testUpdateWithExcludedColumns() throws Exception { final Connection connection = tester.getConnection().getConnection(); - final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_rename_no_produced.xml"); - ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); + try (final InputStream is = + OldSchoolDbUnitTest.class.getClassLoader() + .getResourceAsStream("items_exp_rename_no_produced.xml")) { + ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); - connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); + connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); - actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); + actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); - assertEquals(expectedTable, actualTable); + assertEquals(expectedTable, actualTable); + } } } diff --git a/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java index 2c7e5de508..b4e23f56ff 100644 --- a/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java +++ b/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java @@ -39,8 +39,9 @@ public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { } private IDataSet initDataSet() throws Exception { - final InputStream is = getClass().getClassLoader().getResourceAsStream("data.xml"); - return new FlatXmlDataSetBuilder().build(is); + try (final InputStream is = getClass().getClassLoader().getResourceAsStream("data.xml")) { + return new FlatXmlDataSetBuilder().build(is); + } } private DataFileLoader initDataFileLoader() { @@ -53,10 +54,8 @@ public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("CLIENTS", new String[]{})}; final String[] prepDataFiles = {"/users.xml"}; final String[] expectedDataFiles = {"/users.xml"}; - final PrepAndExpectedTestCaseSteps testSteps = - () -> connection - .createStatement() - .executeQuery("select * from CLIENTS where id = 1"); + final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement() + .executeQuery("select * from CLIENTS where id = 1"); final ResultSet rs = (ResultSet) super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); @@ -70,10 +69,8 @@ public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("CLIENTS", new String[]{})}; // define tables to verify final String[] prepDataFiles = {"/users.xml"}; final String[] expectedDataFiles = {"/users_exp_rename.xml"}; - final PrepAndExpectedTestCaseSteps testSteps = - () -> connection - .createStatement() - .executeUpdate("update CLIENTS set first_name = 'new name' where id = 1"); + final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement() + .executeUpdate("update CLIENTS set first_name = 'new name' where id = 1"); super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); } @@ -84,10 +81,8 @@ public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("CLIENTS", new String[]{})}; final String[] prepDataFiles = {"/users.xml"}; final String[] expectedDataFiles = {"/users_exp_delete.xml"}; - final PrepAndExpectedTestCaseSteps testSteps = - () -> connection - .createStatement() - .executeUpdate("delete from CLIENTS where id = 2"); + final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement() + .executeUpdate("delete from CLIENTS where id = 2"); super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); } diff --git a/libraries-testing/pom.xml b/libraries-testing/pom.xml index 3ffbb291a0..c4d2786441 100644 --- a/libraries-testing/pom.xml +++ b/libraries-testing/pom.xml @@ -130,6 +130,27 @@ ${asciidoctor.version} + + org.dbunit + dbunit + ${dbunit.version} + test + + + + com.h2database + h2 + ${h2.version} + test + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + @@ -150,6 +171,16 @@ + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${maven-compiler-plugin.source} + ${maven-compiler-plugin.target} + + + @@ -166,6 +197,12 @@ 4.1.1 3.6.2 2.0.0.0 + 1.4.200 + 2.6.0 + 3.14.0 + 1.8 + 1.8 + 3.8.1 diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/ConnectionSettings.java b/libraries-testing/src/test/java/com/baeldung/dbunit/ConnectionSettings.java new file mode 100644 index 0000000000..cc29d9c58a --- /dev/null +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/ConnectionSettings.java @@ -0,0 +1,8 @@ +package com.baeldung.dbunit; + +public class ConnectionSettings { + public static final String JDBC_DRIVER = org.h2.Driver.class.getName(); + public static final String JDBC_URL = "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;init=runscript from 'classpath:dbunit/schema.sql'"; + public static final String USER = "sa"; + public static final String PASSWORD = ""; +} diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java new file mode 100644 index 0000000000..662ed44fb6 --- /dev/null +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java @@ -0,0 +1,136 @@ +package com.baeldung.dbunit; + +import org.dbunit.Assertion; +import org.dbunit.DataSourceBasedDBTestCase; +import org.dbunit.assertion.DiffCollectingFailureHandler; +import org.dbunit.assertion.Difference; +import org.dbunit.dataset.IDataSet; +import org.dbunit.dataset.ITable; +import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; +import org.dbunit.operation.DatabaseOperation; +import org.h2.jdbcx.JdbcDataSource; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.platform.commons.logging.Logger; +import org.junit.platform.commons.logging.LoggerFactory; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; + +import static com.baeldung.dbunit.ConnectionSettings.JDBC_URL; +import static java.util.stream.Collectors.joining; +import static org.assertj.core.api.Assertions.assertThat; + +public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { + + private static Logger logger = LoggerFactory.getLogger(DataSourceDBUnitTest.class); + + @Override + protected javax.sql.DataSource getDataSource() { + JdbcDataSource dataSource = new JdbcDataSource(); + dataSource.setURL(JDBC_URL); + dataSource.setUser("sa"); + dataSource.setPassword(""); + return dataSource; + } + + @Override + protected IDataSet getDataSet() throws Exception { + try (java.io.InputStream resourceAsStream = getClass() + .getClassLoader() + .getResourceAsStream("dbunit/data.xml")) { + return new FlatXmlDataSetBuilder().build(resourceAsStream); + } + } + + @Override + protected DatabaseOperation getSetUpOperation() { + return DatabaseOperation.REFRESH; + } + + @Override + protected DatabaseOperation getTearDownOperation() { + return DatabaseOperation.DELETE_ALL; + } + + @Before + public void setUp() throws Exception { + super.setUp(); + } + + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + + @Test + public void testSimpleDataSet() throws SQLException { + final Connection connection = getDataSource() + .getConnection(); + + final ResultSet rs = connection + .createStatement() + .executeQuery("select * from iTEMS where id = 1"); + + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); + } + + @Test + public void testEmptySchema() throws Exception { + final IDataSet expectedDataSet = getDataSet(); + final ITable expectedTable = expectedDataSet.getTable("CLIENTS"); + final IDataSet databaseDataSet = getConnection().createDataSet(); + final ITable actualTable = databaseDataSet.getTable("CLIENTS"); + Assertion.assertEquals(expectedTable, actualTable); + } + + @Test + public void testAssertByQuery() throws Exception { + try (final java.io.InputStream is = getClass() + .getClassLoader() + .getResourceAsStream("dbunit/expected-user.xml")) { + final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); + final ITable expectedTable = expectedDataSet.getTable("CLIENTS"); + final Connection conn = getDataSource().getConnection(); + + conn.createStatement() + .executeUpdate( + "INSERT INTO CLIENTS (first_name, last_name) VALUES ('John', 'Jansen')"); + final ITable actualData = getConnection() + .createQueryTable( + "result_name", + "SELECT * FROM CLIENTS WHERE last_name='Jansen'"); + + Assertion.assertEqualsIgnoreCols(expectedTable, actualData, new String[]{"id"}); + } + } + + @Test + public void testMultipleFailures() throws Exception { + try (final java.io.InputStream is = getClass() + .getClassLoader() + .getResourceAsStream("dbunit/expected-multiple-failures.xml")) { + final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); + final ITable expectedTable = expectedDataSet.getTable("ITEMS"); + final Connection conn = getDataSource().getConnection(); + final DiffCollectingFailureHandler collectingHandler = new DiffCollectingFailureHandler(); + + conn.createStatement().executeUpdate("INSERT INTO ITEMS (title, price) VALUES ('Battery', '1000000')"); + final ITable actualData = getConnection().createDataSet().getTable("ITEMS"); + + Assertion.assertEquals(expectedTable, actualData, collectingHandler); + if (!collectingHandler.getDiffList().isEmpty()) { + String message = (String) collectingHandler.getDiffList().stream().map(d -> formatDifference((Difference) d)).collect(joining("\n")); + logger.error(() -> message); + } + } + } + + private static String formatDifference(Difference diff) { + return "expected value in " + diff.getExpectedTable().getTableMetaData().getTableName() + "." + diff.getColumnName() + " row " + diff.getRowIndex() + ":" + diff.getExpectedValue() + ", but was: " + diff.getActualValue(); + } +} diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/DbUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/DbUnitTest.java new file mode 100644 index 0000000000..3ed77b2c25 --- /dev/null +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/DbUnitTest.java @@ -0,0 +1,90 @@ +package com.baeldung.dbunit; + +import org.dbunit.Assertion; +import org.dbunit.DBTestCase; +import org.dbunit.PropertiesBasedJdbcDatabaseTester; +import org.dbunit.dataset.IDataSet; +import org.dbunit.dataset.ITable; +import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; +import org.dbunit.operation.DatabaseOperation; +import org.junit.Test; + +import java.sql.Connection; +import java.sql.ResultSet; + +import static com.baeldung.dbunit.ConnectionSettings.JDBC_DRIVER; +import static com.baeldung.dbunit.ConnectionSettings.JDBC_URL; +import static com.baeldung.dbunit.ConnectionSettings.PASSWORD; +import static com.baeldung.dbunit.ConnectionSettings.USER; +import static org.assertj.core.api.Assertions.assertThat; + +public class DbUnitTest extends DBTestCase { + + public DbUnitTest(String name) { + super(name); + System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS, JDBC_DRIVER); + System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL, JDBC_URL); + System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME, USER); + System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD, PASSWORD); + } + + @Override + protected IDataSet getDataSet() throws Exception { + try (final java.io.InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/data.xml")) { + return new FlatXmlDataSetBuilder().build(is); + } + } + + @Override + protected DatabaseOperation getSetUpOperation() { + return DatabaseOperation.REFRESH; + } + + @Override + protected DatabaseOperation getTearDownOperation() { + return DatabaseOperation.DELETE_ALL; + } + + @Test + public void testSelect() throws Exception { + final Connection connection = getConnection().getConnection(); + + final ResultSet rs = connection.createStatement().executeQuery("select * from iTEMS where id = 1"); + + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); + } + + @Test + public void testDelete() throws Exception { + final Connection connection = getConnection().getConnection(); + + try (final java.io.InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_delete.xml")) { + ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("items"); + + connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); + + final IDataSet databaseDataSet = getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); + + Assertion.assertEquals(expectedTable, actualTable); + } + } + + @Test + public void testUpdate() throws Exception { + final Connection connection = getConnection().getConnection(); + + try (final java.io.InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_rename.xml")) { + ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("items"); + + connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); + + final IDataSet databaseDataSet = getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); + + Assertion.assertEquals(expectedTable, actualTable); + } + } + +} diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java new file mode 100644 index 0000000000..aa6d9143bb --- /dev/null +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java @@ -0,0 +1,161 @@ +package com.baeldung.dbunit; + +import org.dbunit.Assertion; +import org.dbunit.IDatabaseTester; +import org.dbunit.JdbcDatabaseTester; +import org.dbunit.dataset.IDataSet; +import org.dbunit.dataset.ITable; +import org.dbunit.dataset.filter.DefaultColumnFilter; +import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; +import org.dbunit.operation.DatabaseOperation; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import java.sql.Connection; +import java.sql.ResultSet; + +import static com.baeldung.dbunit.ConnectionSettings.JDBC_DRIVER; +import static com.baeldung.dbunit.ConnectionSettings.JDBC_URL; +import static com.baeldung.dbunit.ConnectionSettings.PASSWORD; +import static com.baeldung.dbunit.ConnectionSettings.USER; +import static org.assertj.core.api.Assertions.assertThat; +import static org.dbunit.Assertion.assertEquals; + +public class OldSchoolDbUnitTest { + + private static IDatabaseTester tester = null; + + @BeforeClass + public static void setUp() throws Exception { + tester = initDatabaseTester(); + } + + private static IDatabaseTester initDatabaseTester() throws Exception { + final JdbcDatabaseTester tester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER, PASSWORD); + tester.setDataSet(initDataSet()); + tester.setSetUpOperation(DatabaseOperation.REFRESH); + tester.setTearDownOperation(DatabaseOperation.DELETE_ALL); + return tester; + } + + private static IDataSet initDataSet() throws Exception { + try (final java.io.InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/data.xml")) { + return new FlatXmlDataSetBuilder().build(is); + } + } + + @Before + public void setup() throws Exception { + tester.onSetup(); + } + + @After + public void tearDown() throws Exception { + tester.onTearDown(); + } + + @Test + public void testSelect() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + + final ResultSet rs = connection.createStatement().executeQuery("select * from iTEMS where id = 1"); + + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); + } + + @Test + public void testIgnoringProduced() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + final String[] excludedColumns = {"id", "produced"}; + try (final java.io.InputStream is = getClass().getClassLoader() + .getResourceAsStream("dbunit/expected-ignoring-registered_at.xml")) { + final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); + final ITable expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedDataSet.getTable("ITEMS"), excludedColumns); + + connection.createStatement().executeUpdate("INSERT INTO ITEMS (title, price, produced) VALUES('Necklace', 199.99, now())"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + final ITable actualTable = DefaultColumnFilter.excludedColumnsTable(databaseDataSet.getTable("ITEMS"), excludedColumns); + + Assertion.assertEquals(expectedTable, actualTable); + } + } + + @Test + public void testDelete() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + + try (final java.io.InputStream is = + OldSchoolDbUnitTest.class.getClassLoader() + .getResourceAsStream("dbunit/items_exp_delete.xml");) { + ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); + + connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); + + assertEquals(expectedTable, actualTable); + } + } + + @Test + public void testDeleteWithExcludedColumns() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + + try (final java.io.InputStream is = + OldSchoolDbUnitTest.class.getClassLoader() + .getResourceAsStream("dbunit/items_exp_delete_no_produced.xml")) { + final ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); + + connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); + actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); + + assertEquals(expectedTable, actualTable); + } + } + + @Test + public void testUpdate() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + + try (final java.io.InputStream is = + OldSchoolDbUnitTest.class.getClassLoader() + .getResourceAsStream("dbunit/items_exp_rename.xml")) { + final ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); + + connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); + + assertEquals(expectedTable, actualTable); + } + } + + @Test + public void testUpdateWithExcludedColumns() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + + try (final java.io.InputStream is = + OldSchoolDbUnitTest.class.getClassLoader() + .getResourceAsStream("dbunit/items_exp_rename_no_produced.xml")) { + ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); + + connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("items"); + actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); + + assertEquals(expectedTable, actualTable); + } + } + +} diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java new file mode 100644 index 0000000000..7e77cd8fc3 --- /dev/null +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java @@ -0,0 +1,89 @@ +package com.baeldung.dbunit; + +import org.dbunit.DefaultPrepAndExpectedTestCase; +import org.dbunit.IDatabaseTester; +import org.dbunit.JdbcDatabaseTester; +import org.dbunit.PrepAndExpectedTestCaseSteps; +import org.dbunit.VerifyTableDefinition; +import org.dbunit.dataset.IDataSet; +import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; +import org.dbunit.operation.DatabaseOperation; +import org.dbunit.util.fileloader.DataFileLoader; +import org.dbunit.util.fileloader.FlatXmlDataFileLoader; +import org.junit.Test; + +import java.sql.Connection; +import java.sql.ResultSet; + +import static com.baeldung.dbunit.ConnectionSettings.JDBC_DRIVER; +import static com.baeldung.dbunit.ConnectionSettings.JDBC_URL; +import static com.baeldung.dbunit.ConnectionSettings.PASSWORD; +import static com.baeldung.dbunit.ConnectionSettings.USER; +import static org.assertj.core.api.Assertions.assertThat; + +public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { + + @Override + public void setUp() throws Exception { + setDatabaseTester(initDatabaseTester()); + setDataFileLoader(initDataFileLoader()); + super.setUp(); + } + + private IDatabaseTester initDatabaseTester() throws Exception { + final JdbcDatabaseTester tester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER, PASSWORD); + tester.setDataSet(initDataSet()); + tester.setSetUpOperation(DatabaseOperation.REFRESH); + return tester; + } + + private IDataSet initDataSet() throws Exception { + try (final java.io.InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/data.xml")) { + return new FlatXmlDataSetBuilder().build(is); + } + } + + private DataFileLoader initDataFileLoader() { + return new FlatXmlDataFileLoader(); + } + + @Test + public void testSelect() throws Exception { + final Connection connection = getConnection().getConnection(); + final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("CLIENTS", new String[]{})}; + final String[] prepDataFiles = {"/dbunit/users.xml"}; + final String[] expectedDataFiles = {"/dbunit/users.xml"}; + final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement() + .executeQuery("select * from CLIENTS where id = 1"); + + final ResultSet rs = (ResultSet) super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); + + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("last_name")).isEqualTo("Xavier"); + } + + @Test + public void testUpdate() throws Exception { + final Connection connection = getConnection().getConnection(); + final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("CLIENTS", new String[]{})}; // define tables to verify + final String[] prepDataFiles = {"/dbunit/users.xml"}; + final String[] expectedDataFiles = {"/dbunit/users_exp_rename.xml"}; + final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement() + .executeUpdate("update CLIENTS set first_name = 'new name' where id = 1"); + + super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); + } + + @Test + public void testDelete() throws Exception { + final Connection connection = getConnection().getConnection(); + final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("CLIENTS", new String[]{})}; + final String[] prepDataFiles = {"/dbunit/users.xml"}; + final String[] expectedDataFiles = {"/dbunit/users_exp_delete.xml"}; + final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement() + .executeUpdate("delete from CLIENTS where id = 2"); + + super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); + } + +} diff --git a/libraries-testing/src/test/resources/dbunit/data.xml b/libraries-testing/src/test/resources/dbunit/data.xml new file mode 100644 index 0000000000..290cc36890 --- /dev/null +++ b/libraries-testing/src/test/resources/dbunit/data.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/libraries-testing/src/test/resources/dbunit/expected-ignoring-registered_at.xml b/libraries-testing/src/test/resources/dbunit/expected-ignoring-registered_at.xml new file mode 100644 index 0000000000..ea57b6a961 --- /dev/null +++ b/libraries-testing/src/test/resources/dbunit/expected-ignoring-registered_at.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/libraries-testing/src/test/resources/dbunit/expected-multiple-failures.xml b/libraries-testing/src/test/resources/dbunit/expected-multiple-failures.xml new file mode 100644 index 0000000000..ea57b6a961 --- /dev/null +++ b/libraries-testing/src/test/resources/dbunit/expected-multiple-failures.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/libraries-testing/src/test/resources/dbunit/expected-user.xml b/libraries-testing/src/test/resources/dbunit/expected-user.xml new file mode 100644 index 0000000000..631dd84210 --- /dev/null +++ b/libraries-testing/src/test/resources/dbunit/expected-user.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/libraries-testing/src/test/resources/dbunit/items.xml b/libraries-testing/src/test/resources/dbunit/items.xml new file mode 100644 index 0000000000..d13e93bbe0 --- /dev/null +++ b/libraries-testing/src/test/resources/dbunit/items.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/libraries-testing/src/test/resources/dbunit/items_exp_delete.xml b/libraries-testing/src/test/resources/dbunit/items_exp_delete.xml new file mode 100644 index 0000000000..a6fa2b33e8 --- /dev/null +++ b/libraries-testing/src/test/resources/dbunit/items_exp_delete.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/libraries-testing/src/test/resources/dbunit/items_exp_delete_no_produced.xml b/libraries-testing/src/test/resources/dbunit/items_exp_delete_no_produced.xml new file mode 100644 index 0000000000..3e7f854f5f --- /dev/null +++ b/libraries-testing/src/test/resources/dbunit/items_exp_delete_no_produced.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/libraries-testing/src/test/resources/dbunit/items_exp_rename.xml b/libraries-testing/src/test/resources/dbunit/items_exp_rename.xml new file mode 100644 index 0000000000..32f1d57cf6 --- /dev/null +++ b/libraries-testing/src/test/resources/dbunit/items_exp_rename.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/libraries-testing/src/test/resources/dbunit/items_exp_rename_no_produced.xml b/libraries-testing/src/test/resources/dbunit/items_exp_rename_no_produced.xml new file mode 100644 index 0000000000..b42d3804fa --- /dev/null +++ b/libraries-testing/src/test/resources/dbunit/items_exp_rename_no_produced.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/libraries-testing/src/test/resources/dbunit/schema.sql b/libraries-testing/src/test/resources/dbunit/schema.sql new file mode 100644 index 0000000000..c2a8d2d630 --- /dev/null +++ b/libraries-testing/src/test/resources/dbunit/schema.sql @@ -0,0 +1,28 @@ +CREATE TABLE IF NOT EXISTS CLIENTS +( + `id` int AUTO_INCREMENT NOT NULL, + `first_name` varchar(100) NOT NULL, + `last_name` varchar(100) NOT NULL, + PRIMARY KEY (`id`) +); + +CREATE TABLE IF NOT EXISTS ITEMS +( + `id` int AUTO_INCREMENT NOT NULL, + `title` varchar(100) NOT NULL, + `produced` date, + `price` float, + PRIMARY KEY (`id`) +); + +CREATE TABLE IF NOT EXISTS PURCHASES +( + `id` int NOT NULL AUTO_INCREMENT, + `id_user` int NOT NULL, + `id_item` int NOT NULL, + `total_price` float NOT NULL, + `quantity` int(11) NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_user`) REFERENCES CLIENTS (`id`) ON DELETE CASCADE, + FOREIGN KEY (`id_item`) REFERENCES ITEMS (`id`) ON DELETE CASCADE ON UPDATE CASCADE +); diff --git a/libraries-testing/src/test/resources/dbunit/users.xml b/libraries-testing/src/test/resources/dbunit/users.xml new file mode 100644 index 0000000000..9ac3909bc5 --- /dev/null +++ b/libraries-testing/src/test/resources/dbunit/users.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/libraries-testing/src/test/resources/dbunit/users_exp_delete.xml b/libraries-testing/src/test/resources/dbunit/users_exp_delete.xml new file mode 100644 index 0000000000..2fe97ae6f6 --- /dev/null +++ b/libraries-testing/src/test/resources/dbunit/users_exp_delete.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/libraries-testing/src/test/resources/dbunit/users_exp_rename.xml b/libraries-testing/src/test/resources/dbunit/users_exp_rename.xml new file mode 100644 index 0000000000..95682118bb --- /dev/null +++ b/libraries-testing/src/test/resources/dbunit/users_exp_rename.xml @@ -0,0 +1,6 @@ + + + + + + From ee185d85b57e3b5036cec9aa3d5b13c08dc94ada Mon Sep 17 00:00:00 2001 From: Joao Esperancinha Date: Tue, 31 Mar 2020 20:19:11 +0200 Subject: [PATCH 068/503] [BAEL-2749] Removes dbunit module --- dbunit/README.md | 4 - dbunit/pom.xml | 62 ------- .../main/java/com/baeldung/dbunit/.gitkeep | 0 dbunit/src/main/resources/logback.xml | 13 -- .../baeldung/dbunit/ConnectionSettings.java | 8 - .../baeldung/dbunit/DataSourceDBUnitTest.java | 138 --------------- .../java/com/baeldung/dbunit/DbUnitTest.java | 91 ---------- .../baeldung/dbunit/OldSchoolDbUnitTest.java | 162 ------------------ .../dbunit/PrepAndExpectedDbUnitTest.java | 90 ---------- dbunit/src/test/resources/data.xml | 9 - .../expected-ignoring-registered_at.xml | 9 - .../resources/expected-multiple-failures.xml | 9 - dbunit/src/test/resources/expected-user.xml | 4 - dbunit/src/test/resources/items.xml | 8 - .../src/test/resources/items_exp_delete.xml | 7 - .../items_exp_delete_no_produced.xml | 7 - .../src/test/resources/items_exp_rename.xml | 8 - .../items_exp_rename_no_produced.xml | 8 - dbunit/src/test/resources/schema.sql | 28 --- dbunit/src/test/resources/users.xml | 6 - .../src/test/resources/users_exp_delete.xml | 5 - .../src/test/resources/users_exp_rename.xml | 6 - 22 files changed, 682 deletions(-) delete mode 100644 dbunit/README.md delete mode 100644 dbunit/pom.xml delete mode 100644 dbunit/src/main/java/com/baeldung/dbunit/.gitkeep delete mode 100644 dbunit/src/main/resources/logback.xml delete mode 100644 dbunit/src/test/java/com/baeldung/dbunit/ConnectionSettings.java delete mode 100644 dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java delete mode 100644 dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java delete mode 100644 dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java delete mode 100644 dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java delete mode 100644 dbunit/src/test/resources/data.xml delete mode 100644 dbunit/src/test/resources/expected-ignoring-registered_at.xml delete mode 100644 dbunit/src/test/resources/expected-multiple-failures.xml delete mode 100644 dbunit/src/test/resources/expected-user.xml delete mode 100644 dbunit/src/test/resources/items.xml delete mode 100644 dbunit/src/test/resources/items_exp_delete.xml delete mode 100644 dbunit/src/test/resources/items_exp_delete_no_produced.xml delete mode 100644 dbunit/src/test/resources/items_exp_rename.xml delete mode 100644 dbunit/src/test/resources/items_exp_rename_no_produced.xml delete mode 100644 dbunit/src/test/resources/schema.sql delete mode 100644 dbunit/src/test/resources/users.xml delete mode 100644 dbunit/src/test/resources/users_exp_delete.xml delete mode 100644 dbunit/src/test/resources/users_exp_rename.xml diff --git a/dbunit/README.md b/dbunit/README.md deleted file mode 100644 index 333cac9439..0000000000 --- a/dbunit/README.md +++ /dev/null @@ -1,4 +0,0 @@ -### Database schema - -### Relevant Articles: -- [Introduction To DBUnit](https://www.baeldung.com/dbunit) diff --git a/dbunit/pom.xml b/dbunit/pom.xml deleted file mode 100644 index 7ca53cd3be..0000000000 --- a/dbunit/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - 4.0.0 - dbunit - 1.0 - - 1.4.200 - - 1.8 - 1.8 - 3.8.1 - - 3.14.0 - 2.6.0 - - - dbunit - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - - - - - org.dbunit - dbunit - ${dbunit.version} - test - - - - com.h2database - h2 - ${h2.version} - test - - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${maven-compiler-plugin.source} - ${maven-compiler-plugin.target} - - - - - - diff --git a/dbunit/src/main/java/com/baeldung/dbunit/.gitkeep b/dbunit/src/main/java/com/baeldung/dbunit/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/dbunit/src/main/resources/logback.xml b/dbunit/src/main/resources/logback.xml deleted file mode 100644 index 26beb6d5b4..0000000000 --- a/dbunit/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/dbunit/src/test/java/com/baeldung/dbunit/ConnectionSettings.java b/dbunit/src/test/java/com/baeldung/dbunit/ConnectionSettings.java deleted file mode 100644 index e842022292..0000000000 --- a/dbunit/src/test/java/com/baeldung/dbunit/ConnectionSettings.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.dbunit; - -public class ConnectionSettings { - public static final String JDBC_DRIVER = org.h2.Driver.class.getName(); - public static final String JDBC_URL = "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;init=runscript from 'classpath:schema.sql'"; - public static final String USER = "sa"; - public static final String PASSWORD = ""; -} diff --git a/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java deleted file mode 100644 index 606f1a90a3..0000000000 --- a/dbunit/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.baeldung.dbunit; - -import org.dbunit.Assertion; -import org.dbunit.DataSourceBasedDBTestCase; -import org.dbunit.assertion.DiffCollectingFailureHandler; -import org.dbunit.assertion.Difference; -import org.dbunit.dataset.IDataSet; -import org.dbunit.dataset.ITable; -import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; -import org.dbunit.operation.DatabaseOperation; -import org.h2.jdbcx.JdbcDataSource; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.platform.commons.logging.Logger; -import org.junit.platform.commons.logging.LoggerFactory; - -import javax.sql.DataSource; -import java.io.InputStream; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; - -import static com.baeldung.dbunit.ConnectionSettings.JDBC_URL; -import static java.util.stream.Collectors.joining; -import static org.assertj.core.api.Assertions.assertThat; - -public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { - - private static Logger logger = LoggerFactory.getLogger(DataSourceDBUnitTest.class); - - @Override - protected DataSource getDataSource() { - JdbcDataSource dataSource = new JdbcDataSource(); - dataSource.setURL(JDBC_URL); - dataSource.setUser("sa"); - dataSource.setPassword(""); - return dataSource; - } - - @Override - protected IDataSet getDataSet() throws Exception { - try (InputStream resourceAsStream = getClass() - .getClassLoader() - .getResourceAsStream("data.xml")) { - return new FlatXmlDataSetBuilder().build(resourceAsStream); - } - } - - @Override - protected DatabaseOperation getSetUpOperation() { - return DatabaseOperation.REFRESH; - } - - @Override - protected DatabaseOperation getTearDownOperation() { - return DatabaseOperation.DELETE_ALL; - } - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - super.tearDown(); - } - - - @Test - public void testSimpleDataSet() throws SQLException { - final Connection connection = getDataSource() - .getConnection(); - - final ResultSet rs = connection - .createStatement() - .executeQuery("select * from iTEMS where id = 1"); - - assertThat(rs.next()).isTrue(); - assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); - } - - @Test - public void testEmptySchema() throws Exception { - final IDataSet expectedDataSet = getDataSet(); - final ITable expectedTable = expectedDataSet.getTable("CLIENTS"); - final IDataSet databaseDataSet = getConnection().createDataSet(); - final ITable actualTable = databaseDataSet.getTable("CLIENTS"); - Assertion.assertEquals(expectedTable, actualTable); - } - - @Test - public void testAssertByQuery() throws Exception { - try (final InputStream is = getClass() - .getClassLoader() - .getResourceAsStream("expected-user.xml")) { - final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); - final ITable expectedTable = expectedDataSet.getTable("CLIENTS"); - final Connection conn = getDataSource().getConnection(); - - conn.createStatement() - .executeUpdate( - "INSERT INTO CLIENTS (first_name, last_name) VALUES ('John', 'Jansen')"); - final ITable actualData = getConnection() - .createQueryTable( - "result_name", - "SELECT * FROM CLIENTS WHERE last_name='Jansen'"); - - Assertion.assertEqualsIgnoreCols(expectedTable, actualData, new String[]{"id"}); - } - } - - @Test - public void testMultipleFailures() throws Exception { - try (final InputStream is = getClass() - .getClassLoader() - .getResourceAsStream("expected-multiple-failures.xml")) { - final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); - final ITable expectedTable = expectedDataSet.getTable("ITEMS"); - final Connection conn = getDataSource().getConnection(); - final DiffCollectingFailureHandler collectingHandler = new DiffCollectingFailureHandler(); - - conn.createStatement().executeUpdate("INSERT INTO ITEMS (title, price) VALUES ('Battery', '1000000')"); - final ITable actualData = getConnection().createDataSet().getTable("ITEMS"); - - Assertion.assertEquals(expectedTable, actualData, collectingHandler); - if (!collectingHandler.getDiffList().isEmpty()) { - String message = (String) collectingHandler.getDiffList().stream().map(d -> formatDifference((Difference) d)).collect(joining("\n")); - logger.error(() -> message); - } - } - } - - private static String formatDifference(Difference diff) { - return "expected value in " + diff.getExpectedTable().getTableMetaData().getTableName() + "." + diff.getColumnName() + " row " + diff.getRowIndex() + ":" + diff.getExpectedValue() + ", but was: " + diff.getActualValue(); - } -} diff --git a/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java deleted file mode 100644 index d24410bedf..0000000000 --- a/dbunit/src/test/java/com/baeldung/dbunit/DbUnitTest.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.baeldung.dbunit; - -import org.dbunit.Assertion; -import org.dbunit.DBTestCase; -import org.dbunit.PropertiesBasedJdbcDatabaseTester; -import org.dbunit.dataset.IDataSet; -import org.dbunit.dataset.ITable; -import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; -import org.dbunit.operation.DatabaseOperation; -import org.junit.Test; - -import java.io.InputStream; -import java.sql.Connection; -import java.sql.ResultSet; - -import static com.baeldung.dbunit.ConnectionSettings.JDBC_DRIVER; -import static com.baeldung.dbunit.ConnectionSettings.JDBC_URL; -import static com.baeldung.dbunit.ConnectionSettings.PASSWORD; -import static com.baeldung.dbunit.ConnectionSettings.USER; -import static org.assertj.core.api.Assertions.assertThat; - -public class DbUnitTest extends DBTestCase { - - public DbUnitTest(String name) { - super(name); - System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS, JDBC_DRIVER); - System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL, JDBC_URL); - System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME, USER); - System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD, PASSWORD); - } - - @Override - protected IDataSet getDataSet() throws Exception { - try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("data.xml")) { - return new FlatXmlDataSetBuilder().build(is); - } - } - - @Override - protected DatabaseOperation getSetUpOperation() { - return DatabaseOperation.REFRESH; - } - - @Override - protected DatabaseOperation getTearDownOperation() { - return DatabaseOperation.DELETE_ALL; - } - - @Test - public void testSelect() throws Exception { - final Connection connection = getConnection().getConnection(); - - final ResultSet rs = connection.createStatement().executeQuery("select * from iTEMS where id = 1"); - - assertThat(rs.next()).isTrue(); - assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); - } - - @Test - public void testDelete() throws Exception { - final Connection connection = getConnection().getConnection(); - - try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_delete.xml")) { - ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("items"); - - connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); - - final IDataSet databaseDataSet = getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); - - Assertion.assertEquals(expectedTable, actualTable); - } - } - - @Test - public void testUpdate() throws Exception { - final Connection connection = getConnection().getConnection(); - - try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("items_exp_rename.xml")) { - ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("items"); - - connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); - - final IDataSet databaseDataSet = getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); - - Assertion.assertEquals(expectedTable, actualTable); - } - } - -} diff --git a/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java deleted file mode 100644 index 41d7ffd8d4..0000000000 --- a/dbunit/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java +++ /dev/null @@ -1,162 +0,0 @@ -package com.baeldung.dbunit; - -import org.dbunit.Assertion; -import org.dbunit.IDatabaseTester; -import org.dbunit.JdbcDatabaseTester; -import org.dbunit.dataset.IDataSet; -import org.dbunit.dataset.ITable; -import org.dbunit.dataset.filter.DefaultColumnFilter; -import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; -import org.dbunit.operation.DatabaseOperation; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.InputStream; -import java.sql.Connection; -import java.sql.ResultSet; - -import static com.baeldung.dbunit.ConnectionSettings.JDBC_DRIVER; -import static com.baeldung.dbunit.ConnectionSettings.JDBC_URL; -import static com.baeldung.dbunit.ConnectionSettings.PASSWORD; -import static com.baeldung.dbunit.ConnectionSettings.USER; -import static org.assertj.core.api.Assertions.assertThat; -import static org.dbunit.Assertion.assertEquals; - -public class OldSchoolDbUnitTest { - - private static IDatabaseTester tester = null; - - @BeforeClass - public static void setUp() throws Exception { - tester = initDatabaseTester(); - } - - private static IDatabaseTester initDatabaseTester() throws Exception { - final JdbcDatabaseTester tester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER, PASSWORD); - tester.setDataSet(initDataSet()); - tester.setSetUpOperation(DatabaseOperation.REFRESH); - tester.setTearDownOperation(DatabaseOperation.DELETE_ALL); - return tester; - } - - private static IDataSet initDataSet() throws Exception { - try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("data.xml")) { - return new FlatXmlDataSetBuilder().build(is); - } - } - - @Before - public void setup() throws Exception { - tester.onSetup(); - } - - @After - public void tearDown() throws Exception { - tester.onTearDown(); - } - - @Test - public void testSelect() throws Exception { - final Connection connection = tester.getConnection().getConnection(); - - final ResultSet rs = connection.createStatement().executeQuery("select * from iTEMS where id = 1"); - - assertThat(rs.next()).isTrue(); - assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); - } - - @Test - public void testIgnoringProduced() throws Exception { - final Connection connection = tester.getConnection().getConnection(); - final String[] excludedColumns = {"id", "produced"}; - try (final InputStream is = getClass().getClassLoader() - .getResourceAsStream("expected-ignoring-registered_at.xml")) { - final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); - final ITable expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedDataSet.getTable("ITEMS"), excludedColumns); - - connection.createStatement().executeUpdate("INSERT INTO ITEMS (title, price, produced) VALUES('Necklace', 199.99, now())"); - - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - final ITable actualTable = DefaultColumnFilter.excludedColumnsTable(databaseDataSet.getTable("ITEMS"), excludedColumns); - - Assertion.assertEquals(expectedTable, actualTable); - } - } - - @Test - public void testDelete() throws Exception { - final Connection connection = tester.getConnection().getConnection(); - - try (final InputStream is = - OldSchoolDbUnitTest.class.getClassLoader() - .getResourceAsStream("items_exp_delete.xml");) { - ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); - - connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); - - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); - - assertEquals(expectedTable, actualTable); - } - } - - @Test - public void testDeleteWithExcludedColumns() throws Exception { - final Connection connection = tester.getConnection().getConnection(); - - try (final InputStream is = - OldSchoolDbUnitTest.class.getClassLoader() - .getResourceAsStream("items_exp_delete_no_produced.xml")) { - final ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); - - connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); - - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); - actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); - - assertEquals(expectedTable, actualTable); - } - } - - @Test - public void testUpdate() throws Exception { - final Connection connection = tester.getConnection().getConnection(); - - try (final InputStream is = - OldSchoolDbUnitTest.class.getClassLoader() - .getResourceAsStream("items_exp_rename.xml")) { - final ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); - - connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); - - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); - - assertEquals(expectedTable, actualTable); - } - } - - @Test - public void testUpdateWithExcludedColumns() throws Exception { - final Connection connection = tester.getConnection().getConnection(); - - try (final InputStream is = - OldSchoolDbUnitTest.class.getClassLoader() - .getResourceAsStream("items_exp_rename_no_produced.xml")) { - ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); - - connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); - - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); - actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); - - assertEquals(expectedTable, actualTable); - } - } - -} diff --git a/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java b/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java deleted file mode 100644 index b4e23f56ff..0000000000 --- a/dbunit/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.baeldung.dbunit; - -import org.dbunit.DefaultPrepAndExpectedTestCase; -import org.dbunit.IDatabaseTester; -import org.dbunit.JdbcDatabaseTester; -import org.dbunit.PrepAndExpectedTestCaseSteps; -import org.dbunit.VerifyTableDefinition; -import org.dbunit.dataset.IDataSet; -import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; -import org.dbunit.operation.DatabaseOperation; -import org.dbunit.util.fileloader.DataFileLoader; -import org.dbunit.util.fileloader.FlatXmlDataFileLoader; -import org.junit.Test; - -import java.io.InputStream; -import java.sql.Connection; -import java.sql.ResultSet; - -import static com.baeldung.dbunit.ConnectionSettings.JDBC_DRIVER; -import static com.baeldung.dbunit.ConnectionSettings.JDBC_URL; -import static com.baeldung.dbunit.ConnectionSettings.PASSWORD; -import static com.baeldung.dbunit.ConnectionSettings.USER; -import static org.assertj.core.api.Assertions.assertThat; - -public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { - - @Override - public void setUp() throws Exception { - setDatabaseTester(initDatabaseTester()); - setDataFileLoader(initDataFileLoader()); - super.setUp(); - } - - private IDatabaseTester initDatabaseTester() throws Exception { - final JdbcDatabaseTester tester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER, PASSWORD); - tester.setDataSet(initDataSet()); - tester.setSetUpOperation(DatabaseOperation.REFRESH); - return tester; - } - - private IDataSet initDataSet() throws Exception { - try (final InputStream is = getClass().getClassLoader().getResourceAsStream("data.xml")) { - return new FlatXmlDataSetBuilder().build(is); - } - } - - private DataFileLoader initDataFileLoader() { - return new FlatXmlDataFileLoader(); - } - - @Test - public void testSelect() throws Exception { - final Connection connection = getConnection().getConnection(); - final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("CLIENTS", new String[]{})}; - final String[] prepDataFiles = {"/users.xml"}; - final String[] expectedDataFiles = {"/users.xml"}; - final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement() - .executeQuery("select * from CLIENTS where id = 1"); - - final ResultSet rs = (ResultSet) super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); - - assertThat(rs.next()).isTrue(); - assertThat(rs.getString("last_name")).isEqualTo("Xavier"); - } - - @Test - public void testUpdate() throws Exception { - final Connection connection = getConnection().getConnection(); - final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("CLIENTS", new String[]{})}; // define tables to verify - final String[] prepDataFiles = {"/users.xml"}; - final String[] expectedDataFiles = {"/users_exp_rename.xml"}; - final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement() - .executeUpdate("update CLIENTS set first_name = 'new name' where id = 1"); - - super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); - } - - @Test - public void testDelete() throws Exception { - final Connection connection = getConnection().getConnection(); - final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("CLIENTS", new String[]{})}; - final String[] prepDataFiles = {"/users.xml"}; - final String[] expectedDataFiles = {"/users_exp_delete.xml"}; - final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement() - .executeUpdate("delete from CLIENTS where id = 2"); - - super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); - } - -} diff --git a/dbunit/src/test/resources/data.xml b/dbunit/src/test/resources/data.xml deleted file mode 100644 index 290cc36890..0000000000 --- a/dbunit/src/test/resources/data.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/dbunit/src/test/resources/expected-ignoring-registered_at.xml b/dbunit/src/test/resources/expected-ignoring-registered_at.xml deleted file mode 100644 index ea57b6a961..0000000000 --- a/dbunit/src/test/resources/expected-ignoring-registered_at.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/dbunit/src/test/resources/expected-multiple-failures.xml b/dbunit/src/test/resources/expected-multiple-failures.xml deleted file mode 100644 index ea57b6a961..0000000000 --- a/dbunit/src/test/resources/expected-multiple-failures.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/dbunit/src/test/resources/expected-user.xml b/dbunit/src/test/resources/expected-user.xml deleted file mode 100644 index 631dd84210..0000000000 --- a/dbunit/src/test/resources/expected-user.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/dbunit/src/test/resources/items.xml b/dbunit/src/test/resources/items.xml deleted file mode 100644 index d13e93bbe0..0000000000 --- a/dbunit/src/test/resources/items.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/dbunit/src/test/resources/items_exp_delete.xml b/dbunit/src/test/resources/items_exp_delete.xml deleted file mode 100644 index a6fa2b33e8..0000000000 --- a/dbunit/src/test/resources/items_exp_delete.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/dbunit/src/test/resources/items_exp_delete_no_produced.xml b/dbunit/src/test/resources/items_exp_delete_no_produced.xml deleted file mode 100644 index 3e7f854f5f..0000000000 --- a/dbunit/src/test/resources/items_exp_delete_no_produced.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/dbunit/src/test/resources/items_exp_rename.xml b/dbunit/src/test/resources/items_exp_rename.xml deleted file mode 100644 index 32f1d57cf6..0000000000 --- a/dbunit/src/test/resources/items_exp_rename.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/dbunit/src/test/resources/items_exp_rename_no_produced.xml b/dbunit/src/test/resources/items_exp_rename_no_produced.xml deleted file mode 100644 index b42d3804fa..0000000000 --- a/dbunit/src/test/resources/items_exp_rename_no_produced.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/dbunit/src/test/resources/schema.sql b/dbunit/src/test/resources/schema.sql deleted file mode 100644 index c2a8d2d630..0000000000 --- a/dbunit/src/test/resources/schema.sql +++ /dev/null @@ -1,28 +0,0 @@ -CREATE TABLE IF NOT EXISTS CLIENTS -( - `id` int AUTO_INCREMENT NOT NULL, - `first_name` varchar(100) NOT NULL, - `last_name` varchar(100) NOT NULL, - PRIMARY KEY (`id`) -); - -CREATE TABLE IF NOT EXISTS ITEMS -( - `id` int AUTO_INCREMENT NOT NULL, - `title` varchar(100) NOT NULL, - `produced` date, - `price` float, - PRIMARY KEY (`id`) -); - -CREATE TABLE IF NOT EXISTS PURCHASES -( - `id` int NOT NULL AUTO_INCREMENT, - `id_user` int NOT NULL, - `id_item` int NOT NULL, - `total_price` float NOT NULL, - `quantity` int(11) NOT NULL, - PRIMARY KEY (`id`), - FOREIGN KEY (`id_user`) REFERENCES CLIENTS (`id`) ON DELETE CASCADE, - FOREIGN KEY (`id_item`) REFERENCES ITEMS (`id`) ON DELETE CASCADE ON UPDATE CASCADE -); diff --git a/dbunit/src/test/resources/users.xml b/dbunit/src/test/resources/users.xml deleted file mode 100644 index 9ac3909bc5..0000000000 --- a/dbunit/src/test/resources/users.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/dbunit/src/test/resources/users_exp_delete.xml b/dbunit/src/test/resources/users_exp_delete.xml deleted file mode 100644 index 2fe97ae6f6..0000000000 --- a/dbunit/src/test/resources/users_exp_delete.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/dbunit/src/test/resources/users_exp_rename.xml b/dbunit/src/test/resources/users_exp_rename.xml deleted file mode 100644 index 95682118bb..0000000000 --- a/dbunit/src/test/resources/users_exp_rename.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - From d1b40a0c026a07b5780e85bd8170f3a397967189 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Tue, 31 Mar 2020 22:55:19 +0200 Subject: [PATCH 069/503] JAVA-42: Upgrade spring-security-x509 to Spring Boot 2 --- spring-security-modules/spring-security-x509/pom.xml | 4 ++-- .../src/main/resources/application.properties | 6 +++--- .../src/main/resources/application.properties | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spring-security-modules/spring-security-x509/pom.xml b/spring-security-modules/spring-security-x509/pom.xml index a4ff908eed..d4132f058d 100644 --- a/spring-security-modules/spring-security-x509/pom.xml +++ b/spring-security-modules/spring-security-x509/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../../parent-boot-1 + ../../parent-boot-2 diff --git a/spring-security-modules/spring-security-x509/spring-security-x509-basic-auth/src/main/resources/application.properties b/spring-security-modules/spring-security-x509/spring-security-x509-basic-auth/src/main/resources/application.properties index f293d6712d..53dfe9976a 100644 --- a/spring-security-modules/spring-security-x509/spring-security-x509-basic-auth/src/main/resources/application.properties +++ b/spring-security-modules/spring-security-x509/spring-security-x509-basic-auth/src/main/resources/application.properties @@ -1,8 +1,8 @@ -server.ssl.key-store=../keystore/keystore.jks +server.ssl.key-store=keystore/keystore.jks server.ssl.key-store-password=changeit server.ssl.key-alias=localhost server.ssl.key-password=changeit server.ssl.enabled=true server.port=8443 -security.user.name=Admin -security.user.password=admin \ No newline at end of file +spring.security.user.name=Admin +spring.security.user.password=admin \ No newline at end of file diff --git a/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/application.properties b/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/application.properties index 174eba9f98..743c9c4582 100644 --- a/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/application.properties +++ b/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/application.properties @@ -4,8 +4,8 @@ server.ssl.key-alias=localhost server.ssl.key-password=changeit server.ssl.enabled=true server.port=8443 -security.user.name=Admin -security.user.password=admin +spring.security.user.name=Admin +spring.security.user.password=admin server.ssl.trust-store=../keystore/truststore.jks server.ssl.trust-store-password=changeit server.ssl.client-auth=need \ No newline at end of file From dc75e11440a687431620b26d3ed4f8d812e0a293 Mon Sep 17 00:00:00 2001 From: Joao Esperancinha Date: Wed, 1 Apr 2020 07:44:25 +0200 Subject: [PATCH 070/503] [BAEL-2749] DBUnit documentation --- libraries-testing/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries-testing/README.md b/libraries-testing/README.md index 332debfe18..7098c10d28 100644 --- a/libraries-testing/README.md +++ b/libraries-testing/README.md @@ -11,3 +11,4 @@ This module contains articles about test libraries. - [Introduction to Awaitlity](https://www.baeldung.com/awaitlity-testing) - [Introduction to Hoverfly in Java](https://www.baeldung.com/hoverfly) - [Testing with Hamcrest](https://www.baeldung.com/java-junit-hamcrest-guide) +- [Introduction To DBUnit](https://www.baeldung.com/dbunit) From c0abc0ed354f073d0f3958308acb4939f11c49fb Mon Sep 17 00:00:00 2001 From: Joao Esperancinha Date: Wed, 1 Apr 2020 19:44:48 +0200 Subject: [PATCH 071/503] [BAEL-2749] Uses static imports and uses code format --- .../baeldung/dbunit/ConnectionSettings.java | 8 +- .../baeldung/dbunit/DataSourceDBUnitTest.java | 178 ++++++-------- .../java/com/baeldung/dbunit/DbUnitTest.java | 117 +++++----- .../baeldung/dbunit/OldSchoolDbUnitTest.java | 219 ++++++++---------- .../dbunit/PrepAndExpectedDbUnitTest.java | 100 ++++---- pom.xml | 1 - 6 files changed, 285 insertions(+), 338 deletions(-) diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/ConnectionSettings.java b/libraries-testing/src/test/java/com/baeldung/dbunit/ConnectionSettings.java index cc29d9c58a..b30d636a12 100644 --- a/libraries-testing/src/test/java/com/baeldung/dbunit/ConnectionSettings.java +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/ConnectionSettings.java @@ -1,8 +1,8 @@ package com.baeldung.dbunit; public class ConnectionSettings { - public static final String JDBC_DRIVER = org.h2.Driver.class.getName(); - public static final String JDBC_URL = "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;init=runscript from 'classpath:dbunit/schema.sql'"; - public static final String USER = "sa"; - public static final String PASSWORD = ""; + public static final String JDBC_DRIVER = org.h2.Driver.class.getName(); + public static final String JDBC_URL = "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;init=runscript from 'classpath:dbunit/schema.sql'"; + public static final String USER = "sa"; + public static final String PASSWORD = ""; } diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java index 662ed44fb6..1cb7489688 100644 --- a/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java @@ -15,6 +15,7 @@ import org.junit.Test; import org.junit.platform.commons.logging.Logger; import org.junit.platform.commons.logging.LoggerFactory; +import java.io.InputStream; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; @@ -25,112 +26,87 @@ import static org.assertj.core.api.Assertions.assertThat; public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { - private static Logger logger = LoggerFactory.getLogger(DataSourceDBUnitTest.class); + private static final Logger logger = LoggerFactory.getLogger(DataSourceDBUnitTest.class); - @Override - protected javax.sql.DataSource getDataSource() { - JdbcDataSource dataSource = new JdbcDataSource(); - dataSource.setURL(JDBC_URL); - dataSource.setUser("sa"); - dataSource.setPassword(""); - return dataSource; - } - - @Override - protected IDataSet getDataSet() throws Exception { - try (java.io.InputStream resourceAsStream = getClass() - .getClassLoader() - .getResourceAsStream("dbunit/data.xml")) { - return new FlatXmlDataSetBuilder().build(resourceAsStream); + @Override protected javax.sql.DataSource getDataSource() { + JdbcDataSource dataSource = new JdbcDataSource(); + dataSource.setURL(JDBC_URL); + dataSource.setUser("sa"); + dataSource.setPassword(""); + return dataSource; } - } - @Override - protected DatabaseOperation getSetUpOperation() { - return DatabaseOperation.REFRESH; - } - - @Override - protected DatabaseOperation getTearDownOperation() { - return DatabaseOperation.DELETE_ALL; - } - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - super.tearDown(); - } - - - @Test - public void testSimpleDataSet() throws SQLException { - final Connection connection = getDataSource() - .getConnection(); - - final ResultSet rs = connection - .createStatement() - .executeQuery("select * from iTEMS where id = 1"); - - assertThat(rs.next()).isTrue(); - assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); - } - - @Test - public void testEmptySchema() throws Exception { - final IDataSet expectedDataSet = getDataSet(); - final ITable expectedTable = expectedDataSet.getTable("CLIENTS"); - final IDataSet databaseDataSet = getConnection().createDataSet(); - final ITable actualTable = databaseDataSet.getTable("CLIENTS"); - Assertion.assertEquals(expectedTable, actualTable); - } - - @Test - public void testAssertByQuery() throws Exception { - try (final java.io.InputStream is = getClass() - .getClassLoader() - .getResourceAsStream("dbunit/expected-user.xml")) { - final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); - final ITable expectedTable = expectedDataSet.getTable("CLIENTS"); - final Connection conn = getDataSource().getConnection(); - - conn.createStatement() - .executeUpdate( - "INSERT INTO CLIENTS (first_name, last_name) VALUES ('John', 'Jansen')"); - final ITable actualData = getConnection() - .createQueryTable( - "result_name", - "SELECT * FROM CLIENTS WHERE last_name='Jansen'"); - - Assertion.assertEqualsIgnoreCols(expectedTable, actualData, new String[]{"id"}); + @Override protected IDataSet getDataSet() throws Exception { + try (InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream("dbunit/data.xml")) { + return new FlatXmlDataSetBuilder().build(resourceAsStream); + } } - } - @Test - public void testMultipleFailures() throws Exception { - try (final java.io.InputStream is = getClass() - .getClassLoader() - .getResourceAsStream("dbunit/expected-multiple-failures.xml")) { - final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); - final ITable expectedTable = expectedDataSet.getTable("ITEMS"); - final Connection conn = getDataSource().getConnection(); - final DiffCollectingFailureHandler collectingHandler = new DiffCollectingFailureHandler(); - - conn.createStatement().executeUpdate("INSERT INTO ITEMS (title, price) VALUES ('Battery', '1000000')"); - final ITable actualData = getConnection().createDataSet().getTable("ITEMS"); - - Assertion.assertEquals(expectedTable, actualData, collectingHandler); - if (!collectingHandler.getDiffList().isEmpty()) { - String message = (String) collectingHandler.getDiffList().stream().map(d -> formatDifference((Difference) d)).collect(joining("\n")); - logger.error(() -> message); - } + @Override protected DatabaseOperation getSetUpOperation() { + return DatabaseOperation.REFRESH; } - } - private static String formatDifference(Difference diff) { - return "expected value in " + diff.getExpectedTable().getTableMetaData().getTableName() + "." + diff.getColumnName() + " row " + diff.getRowIndex() + ":" + diff.getExpectedValue() + ", but was: " + diff.getActualValue(); - } + @Override protected DatabaseOperation getTearDownOperation() { + return DatabaseOperation.DELETE_ALL; + } + + @Before public void setUp() throws Exception { + super.setUp(); + } + + @After public void tearDown() throws Exception { + super.tearDown(); + } + + @Test public void testSimpleDataSet() throws SQLException { + final Connection connection = getDataSource().getConnection(); + + final ResultSet rs = connection.createStatement().executeQuery("select * from ITEMS where id = 1"); + + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); + } + + @Test public void testEmptySchema() throws Exception { + final IDataSet expectedDataSet = getDataSet(); + final ITable expectedTable = expectedDataSet.getTable("CLIENTS"); + final IDataSet databaseDataSet = getConnection().createDataSet(); + final ITable actualTable = databaseDataSet.getTable("CLIENTS"); + Assertion.assertEquals(expectedTable, actualTable); + } + + @Test public void testAssertByQuery() throws Exception { + try (final InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/expected-user.xml")) { + final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); + final ITable expectedTable = expectedDataSet.getTable("CLIENTS"); + final Connection conn = getDataSource().getConnection(); + + conn.createStatement().executeUpdate("INSERT INTO CLIENTS (first_name, last_name) VALUES ('John', 'Jansen')"); + final ITable actualData = getConnection().createQueryTable("result_name", "SELECT * FROM CLIENTS WHERE last_name='Jansen'"); + + Assertion.assertEqualsIgnoreCols(expectedTable, actualData, new String[] { "id" }); + } + } + + @Test public void testMultipleFailures() throws Exception { + try (final InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/expected-multiple-failures.xml")) { + final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); + final ITable expectedTable = expectedDataSet.getTable("ITEMS"); + final Connection conn = getDataSource().getConnection(); + final DiffCollectingFailureHandler collectingHandler = new DiffCollectingFailureHandler(); + + conn.createStatement().executeUpdate("INSERT INTO ITEMS (title, price) VALUES ('Battery', '1000000')"); + final ITable actualData = getConnection().createDataSet().getTable("ITEMS"); + + Assertion.assertEquals(expectedTable, actualData, collectingHandler); + if (!collectingHandler.getDiffList().isEmpty()) { + String message = (String) collectingHandler.getDiffList().stream().map(d -> formatDifference((Difference) d)).collect(joining("\n")); + logger.error(() -> message); + } + } + } + + private static String formatDifference(Difference diff) { + return "expected value in " + diff.getExpectedTable().getTableMetaData().getTableName() + "." + diff.getColumnName() + " row " + diff.getRowIndex() + ":" + diff.getExpectedValue() + ", but was: " + diff.getActualValue(); + } } diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/DbUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/DbUnitTest.java index 3ed77b2c25..a3a41b9b8d 100644 --- a/libraries-testing/src/test/java/com/baeldung/dbunit/DbUnitTest.java +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/DbUnitTest.java @@ -9,6 +9,7 @@ import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; import org.dbunit.operation.DatabaseOperation; import org.junit.Test; +import java.io.InputStream; import java.sql.Connection; import java.sql.ResultSet; @@ -20,71 +21,65 @@ import static org.assertj.core.api.Assertions.assertThat; public class DbUnitTest extends DBTestCase { - public DbUnitTest(String name) { - super(name); - System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS, JDBC_DRIVER); - System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL, JDBC_URL); - System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME, USER); - System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD, PASSWORD); - } - - @Override - protected IDataSet getDataSet() throws Exception { - try (final java.io.InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/data.xml")) { - return new FlatXmlDataSetBuilder().build(is); + public DbUnitTest(String name) { + super(name); + System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS, JDBC_DRIVER); + System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL, JDBC_URL); + System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME, USER); + System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD, PASSWORD); } - } - @Override - protected DatabaseOperation getSetUpOperation() { - return DatabaseOperation.REFRESH; - } - - @Override - protected DatabaseOperation getTearDownOperation() { - return DatabaseOperation.DELETE_ALL; - } - - @Test - public void testSelect() throws Exception { - final Connection connection = getConnection().getConnection(); - - final ResultSet rs = connection.createStatement().executeQuery("select * from iTEMS where id = 1"); - - assertThat(rs.next()).isTrue(); - assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); - } - - @Test - public void testDelete() throws Exception { - final Connection connection = getConnection().getConnection(); - - try (final java.io.InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_delete.xml")) { - ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("items"); - - connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); - - final IDataSet databaseDataSet = getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); - - Assertion.assertEquals(expectedTable, actualTable); + @Override protected IDataSet getDataSet() throws Exception { + try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/data.xml")) { + return new FlatXmlDataSetBuilder().build(is); + } } - } - @Test - public void testUpdate() throws Exception { - final Connection connection = getConnection().getConnection(); - - try (final java.io.InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_rename.xml")) { - ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("items"); - - connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); - - final IDataSet databaseDataSet = getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); - - Assertion.assertEquals(expectedTable, actualTable); + @Override protected DatabaseOperation getSetUpOperation() { + return DatabaseOperation.REFRESH; + } + + @Override protected DatabaseOperation getTearDownOperation() { + return DatabaseOperation.DELETE_ALL; + } + + @Test public void testSelect() throws Exception { + final Connection connection = getConnection().getConnection(); + + final ResultSet rs = connection.createStatement().executeQuery("select * from ITEMS where id = 1"); + + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); + } + + @Test public void testDelete() throws Exception { + final Connection connection = getConnection().getConnection(); + + try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_delete.xml")) { + ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("ITEMS"); + + connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); + + final IDataSet databaseDataSet = getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("ITEMS"); + + Assertion.assertEquals(expectedTable, actualTable); + } + } + + @Test public void testUpdate() throws Exception { + final Connection connection = getConnection().getConnection(); + + try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_rename.xml")) { + ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("ITEMS"); + + connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); + + final IDataSet databaseDataSet = getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("ITEMS"); + + Assertion.assertEquals(expectedTable, actualTable); + } } - } } diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java index aa6d9143bb..be6023d432 100644 --- a/libraries-testing/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java @@ -13,6 +13,7 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import java.io.InputStream; import java.sql.Connection; import java.sql.ResultSet; @@ -25,137 +26,119 @@ import static org.dbunit.Assertion.assertEquals; public class OldSchoolDbUnitTest { - private static IDatabaseTester tester = null; + private static IDatabaseTester tester = null; - @BeforeClass - public static void setUp() throws Exception { - tester = initDatabaseTester(); - } - - private static IDatabaseTester initDatabaseTester() throws Exception { - final JdbcDatabaseTester tester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER, PASSWORD); - tester.setDataSet(initDataSet()); - tester.setSetUpOperation(DatabaseOperation.REFRESH); - tester.setTearDownOperation(DatabaseOperation.DELETE_ALL); - return tester; - } - - private static IDataSet initDataSet() throws Exception { - try (final java.io.InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/data.xml")) { - return new FlatXmlDataSetBuilder().build(is); + @BeforeClass public static void setUp() throws Exception { + tester = initDatabaseTester(); } - } - @Before - public void setup() throws Exception { - tester.onSetup(); - } - - @After - public void tearDown() throws Exception { - tester.onTearDown(); - } - - @Test - public void testSelect() throws Exception { - final Connection connection = tester.getConnection().getConnection(); - - final ResultSet rs = connection.createStatement().executeQuery("select * from iTEMS where id = 1"); - - assertThat(rs.next()).isTrue(); - assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); - } - - @Test - public void testIgnoringProduced() throws Exception { - final Connection connection = tester.getConnection().getConnection(); - final String[] excludedColumns = {"id", "produced"}; - try (final java.io.InputStream is = getClass().getClassLoader() - .getResourceAsStream("dbunit/expected-ignoring-registered_at.xml")) { - final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); - final ITable expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedDataSet.getTable("ITEMS"), excludedColumns); - - connection.createStatement().executeUpdate("INSERT INTO ITEMS (title, price, produced) VALUES('Necklace', 199.99, now())"); - - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - final ITable actualTable = DefaultColumnFilter.excludedColumnsTable(databaseDataSet.getTable("ITEMS"), excludedColumns); - - Assertion.assertEquals(expectedTable, actualTable); + private static IDatabaseTester initDatabaseTester() throws Exception { + final JdbcDatabaseTester tester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER, PASSWORD); + tester.setDataSet(initDataSet()); + tester.setSetUpOperation(DatabaseOperation.REFRESH); + tester.setTearDownOperation(DatabaseOperation.DELETE_ALL); + return tester; } - } - @Test - public void testDelete() throws Exception { - final Connection connection = tester.getConnection().getConnection(); - - try (final java.io.InputStream is = - OldSchoolDbUnitTest.class.getClassLoader() - .getResourceAsStream("dbunit/items_exp_delete.xml");) { - ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); - - connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); - - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); - - assertEquals(expectedTable, actualTable); + private static IDataSet initDataSet() throws Exception { + try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/data.xml")) { + return new FlatXmlDataSetBuilder().build(is); + } } - } - @Test - public void testDeleteWithExcludedColumns() throws Exception { - final Connection connection = tester.getConnection().getConnection(); - - try (final java.io.InputStream is = - OldSchoolDbUnitTest.class.getClassLoader() - .getResourceAsStream("dbunit/items_exp_delete_no_produced.xml")) { - final ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); - - connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); - - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); - actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); - - assertEquals(expectedTable, actualTable); + @Before public void setup() throws Exception { + tester.onSetup(); } - } - @Test - public void testUpdate() throws Exception { - final Connection connection = tester.getConnection().getConnection(); - - try (final java.io.InputStream is = - OldSchoolDbUnitTest.class.getClassLoader() - .getResourceAsStream("dbunit/items_exp_rename.xml")) { - final ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); - - connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); - - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); - - assertEquals(expectedTable, actualTable); + @After public void tearDown() throws Exception { + tester.onTearDown(); } - } - @Test - public void testUpdateWithExcludedColumns() throws Exception { - final Connection connection = tester.getConnection().getConnection(); + @Test public void testSelect() throws Exception { + final Connection connection = tester.getConnection().getConnection(); - try (final java.io.InputStream is = - OldSchoolDbUnitTest.class.getClassLoader() - .getResourceAsStream("dbunit/items_exp_rename_no_produced.xml")) { - ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("items"); + final ResultSet rs = connection.createStatement().executeQuery("select * from ITEMS where id = 1"); - connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); - - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("items"); - actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[]{"produced"}); - - assertEquals(expectedTable, actualTable); + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); + } + + @Test public void testIgnoringProduced() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + final String[] excludedColumns = { "id", "produced" }; + try (final InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/expected-ignoring-registered_at.xml")) { + final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); + final ITable expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedDataSet.getTable("ITEMS"), excludedColumns); + + connection.createStatement().executeUpdate("INSERT INTO ITEMS (title, price, produced) VALUES('Necklace', 199.99, now())"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + final ITable actualTable = DefaultColumnFilter.excludedColumnsTable(databaseDataSet.getTable("ITEMS"), excludedColumns); + + Assertion.assertEquals(expectedTable, actualTable); + } + } + + @Test public void testDelete() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + + try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_delete.xml")) { + ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("ITEMS"); + + connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("ITEMS"); + + assertEquals(expectedTable, actualTable); + } + } + + @Test public void testDeleteWithExcludedColumns() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + + try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_delete_no_produced.xml")) { + final ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("ITEMS"); + + connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("ITEMS"); + actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[] { "produced" }); + + assertEquals(expectedTable, actualTable); + } + } + + @Test public void testUpdate() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + + try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_rename.xml")) { + final ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("ITEMS"); + + connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("ITEMS"); + + assertEquals(expectedTable, actualTable); + } + } + + @Test public void testUpdateWithExcludedColumns() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + + try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_rename_no_produced.xml")) { + ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("ITEMS"); + + connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("ITEMS"); + actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[] { "produced" }); + + assertEquals(expectedTable, actualTable); + } } - } } diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java index 7e77cd8fc3..f797f153a0 100644 --- a/libraries-testing/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java @@ -12,6 +12,7 @@ import org.dbunit.util.fileloader.DataFileLoader; import org.dbunit.util.fileloader.FlatXmlDataFileLoader; import org.junit.Test; +import java.io.InputStream; import java.sql.Connection; import java.sql.ResultSet; @@ -23,67 +24,60 @@ import static org.assertj.core.api.Assertions.assertThat; public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { - @Override - public void setUp() throws Exception { - setDatabaseTester(initDatabaseTester()); - setDataFileLoader(initDataFileLoader()); - super.setUp(); - } - - private IDatabaseTester initDatabaseTester() throws Exception { - final JdbcDatabaseTester tester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER, PASSWORD); - tester.setDataSet(initDataSet()); - tester.setSetUpOperation(DatabaseOperation.REFRESH); - return tester; - } - - private IDataSet initDataSet() throws Exception { - try (final java.io.InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/data.xml")) { - return new FlatXmlDataSetBuilder().build(is); + @Override public void setUp() throws Exception { + setDatabaseTester(initDatabaseTester()); + setDataFileLoader(initDataFileLoader()); + super.setUp(); } - } - private DataFileLoader initDataFileLoader() { - return new FlatXmlDataFileLoader(); - } + private IDatabaseTester initDatabaseTester() throws Exception { + final JdbcDatabaseTester tester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER, PASSWORD); + tester.setDataSet(initDataSet()); + tester.setSetUpOperation(DatabaseOperation.REFRESH); + return tester; + } - @Test - public void testSelect() throws Exception { - final Connection connection = getConnection().getConnection(); - final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("CLIENTS", new String[]{})}; - final String[] prepDataFiles = {"/dbunit/users.xml"}; - final String[] expectedDataFiles = {"/dbunit/users.xml"}; - final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement() - .executeQuery("select * from CLIENTS where id = 1"); + private IDataSet initDataSet() throws Exception { + try (final InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/data.xml")) { + return new FlatXmlDataSetBuilder().build(is); + } + } - final ResultSet rs = (ResultSet) super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); + private DataFileLoader initDataFileLoader() { + return new FlatXmlDataFileLoader(); + } - assertThat(rs.next()).isTrue(); - assertThat(rs.getString("last_name")).isEqualTo("Xavier"); - } + @Test public void testSelect() throws Exception { + final Connection connection = getConnection().getConnection(); + final VerifyTableDefinition[] verifyTables = { new VerifyTableDefinition("CLIENTS", new String[] {}) }; + final String[] prepDataFiles = { "/dbunit/users.xml" }; + final String[] expectedDataFiles = { "/dbunit/users.xml" }; + final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement().executeQuery("select * from CLIENTS where id = 1"); - @Test - public void testUpdate() throws Exception { - final Connection connection = getConnection().getConnection(); - final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("CLIENTS", new String[]{})}; // define tables to verify - final String[] prepDataFiles = {"/dbunit/users.xml"}; - final String[] expectedDataFiles = {"/dbunit/users_exp_rename.xml"}; - final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement() - .executeUpdate("update CLIENTS set first_name = 'new name' where id = 1"); + final ResultSet rs = (ResultSet) super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); - super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); - } + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("last_name")).isEqualTo("Xavier"); + } - @Test - public void testDelete() throws Exception { - final Connection connection = getConnection().getConnection(); - final VerifyTableDefinition[] verifyTables = {new VerifyTableDefinition("CLIENTS", new String[]{})}; - final String[] prepDataFiles = {"/dbunit/users.xml"}; - final String[] expectedDataFiles = {"/dbunit/users_exp_delete.xml"}; - final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement() - .executeUpdate("delete from CLIENTS where id = 2"); + @Test public void testUpdate() throws Exception { + final Connection connection = getConnection().getConnection(); + final VerifyTableDefinition[] verifyTables = { new VerifyTableDefinition("CLIENTS", new String[] {}) }; // define tables to verify + final String[] prepDataFiles = { "/dbunit/users.xml" }; + final String[] expectedDataFiles = { "/dbunit/users_exp_rename.xml" }; + final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement().executeUpdate("update CLIENTS set first_name = 'new name' where id = 1"); - super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); - } + super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); + } + + @Test public void testDelete() throws Exception { + final Connection connection = getConnection().getConnection(); + final VerifyTableDefinition[] verifyTables = { new VerifyTableDefinition("CLIENTS", new String[] {}) }; + final String[] prepDataFiles = { "/dbunit/users.xml" }; + final String[] expectedDataFiles = { "/dbunit/users_exp_delete.xml" }; + final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement().executeUpdate("delete from CLIENTS where id = 2"); + + super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); + } } diff --git a/pom.xml b/pom.xml index 734e2c8ab9..8b09f69252 100644 --- a/pom.xml +++ b/pom.xml @@ -601,7 +601,6 @@ - dbunit parent-boot-1 parent-boot-2 From 064e16251be28928331af940acf6b39fe9258dda Mon Sep 17 00:00:00 2001 From: Joao Esperancinha Date: Wed, 1 Apr 2020 20:02:46 +0200 Subject: [PATCH 072/503] [BAEL-2749] Formats pom --- pom.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pom.xml b/pom.xml index 8b09f69252..04a2ce054c 100644 --- a/pom.xml +++ b/pom.xml @@ -601,7 +601,6 @@ - parent-boot-1 parent-boot-2 parent-spring-4 @@ -1289,8 +1288,6 @@ - dbunit - parent-boot-1 parent-boot-2 parent-spring-4 From 7a9ec696af348adc1c4c82e9de0ed8568de3ce95 Mon Sep 17 00:00:00 2001 From: Tyrell Flurry Date: Wed, 1 Apr 2020 18:08:39 -0400 Subject: [PATCH 073/503] BAEL-3929: added unused maven dependencies example. --- maven-all/maven-unused-dependencies/pom.xml | 30 +++++++++++++++++++ .../src/main/java/com/baeldung/Main.java | 20 +++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 maven-all/maven-unused-dependencies/pom.xml create mode 100644 maven-all/maven-unused-dependencies/src/main/java/com/baeldung/Main.java diff --git a/maven-all/maven-unused-dependencies/pom.xml b/maven-all/maven-unused-dependencies/pom.xml new file mode 100644 index 0000000000..312f38ed93 --- /dev/null +++ b/maven-all/maven-unused-dependencies/pom.xml @@ -0,0 +1,30 @@ + + 4.0.0 + com.baeldung + maven-unused-dependencies + 0.0.1-SNAPSHOT + + + + commons-collections + commons-collections + 3.2.2 + + + org.slf4j + slf4j-api + 1.7.25 + + + + + + + maven-dependency-plugin + 3.1.1 + + + + \ No newline at end of file diff --git a/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/Main.java b/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/Main.java new file mode 100644 index 0000000000..8143c7d19f --- /dev/null +++ b/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/Main.java @@ -0,0 +1,20 @@ +package com.baeldung; + +import java.util.HashMap; +import java.util.Map; + +import org.slf4j.LoggerFactory; + +public class Main { + + public static void main(String[] args) { + Map teamMap = new HashMap<>(); + teamMap.put("Dallas", "Cowboys"); + teamMap.put("Green Bay", "Packers"); + teamMap.put("Washington", "Redskins"); + + LoggerFactory.getLogger(Main.class) + .info("Team Map: {}", teamMap); + + } +} From 7187cb0dfbd3487877248742309519bed0f55d49 Mon Sep 17 00:00:00 2001 From: ramkumarvenkat Date: Thu, 2 Apr 2020 07:13:19 +0530 Subject: [PATCH 074/503] Change package name --- .../java/com/baeldung/guava/{entity => mapmaker}/Profile.java | 2 +- .../java/com/baeldung/guava/{entity => mapmaker}/Session.java | 2 +- .../java/com/baeldung/guava/{entity => mapmaker}/User.java | 2 +- .../com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java | 3 --- 4 files changed, 3 insertions(+), 6 deletions(-) rename guava-collections-map/src/main/java/com/baeldung/guava/{entity => mapmaker}/Profile.java (88%) rename guava-collections-map/src/main/java/com/baeldung/guava/{entity => mapmaker}/Session.java (81%) rename guava-collections-map/src/main/java/com/baeldung/guava/{entity => mapmaker}/User.java (88%) diff --git a/guava-collections-map/src/main/java/com/baeldung/guava/entity/Profile.java b/guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/Profile.java similarity index 88% rename from guava-collections-map/src/main/java/com/baeldung/guava/entity/Profile.java rename to guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/Profile.java index 17a6502f39..165c5a9f8f 100644 --- a/guava-collections-map/src/main/java/com/baeldung/guava/entity/Profile.java +++ b/guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/Profile.java @@ -1,4 +1,4 @@ -package com.baeldung.guava.entity; +package com.baeldung.guava.mapmaker; public class Profile { private long id; diff --git a/guava-collections-map/src/main/java/com/baeldung/guava/entity/Session.java b/guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/Session.java similarity index 81% rename from guava-collections-map/src/main/java/com/baeldung/guava/entity/Session.java rename to guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/Session.java index b834c23df1..a614f431f8 100644 --- a/guava-collections-map/src/main/java/com/baeldung/guava/entity/Session.java +++ b/guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/Session.java @@ -1,4 +1,4 @@ -package com.baeldung.guava.entity; +package com.baeldung.guava.mapmaker; public class Session { private long id; diff --git a/guava-collections-map/src/main/java/com/baeldung/guava/entity/User.java b/guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/User.java similarity index 88% rename from guava-collections-map/src/main/java/com/baeldung/guava/entity/User.java rename to guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/User.java index 613045ec23..a7f0435049 100644 --- a/guava-collections-map/src/main/java/com/baeldung/guava/entity/User.java +++ b/guava-collections-map/src/main/java/com/baeldung/guava/mapmaker/User.java @@ -1,4 +1,4 @@ -package com.baeldung.guava.entity; +package com.baeldung.guava.mapmaker; public class User { private long id; diff --git a/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java b/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java index e2bc1349c6..754e3ac099 100644 --- a/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java +++ b/guava-collections-map/src/test/java/com/baeldung/guava/mapmaker/GuavaMapMakerUnitTest.java @@ -1,8 +1,5 @@ package com.baeldung.guava.mapmaker; -import com.baeldung.guava.entity.Profile; -import com.baeldung.guava.entity.Session; -import com.baeldung.guava.entity.User; import com.google.common.collect.MapMaker; import org.junit.Assert; import org.junit.Test; From f06af6499859b3dcd45d14d2060631a4fd1f0241 Mon Sep 17 00:00:00 2001 From: Joao Esperancinha Date: Thu, 2 Apr 2020 11:20:34 +0200 Subject: [PATCH 075/503] [BAEL-2749] Indentation and annotations format --- .../baeldung/dbunit/ConnectionSettings.java | 8 +- .../baeldung/dbunit/DataSourceDBUnitTest.java | 162 +++++++------- .../java/com/baeldung/dbunit/DbUnitTest.java | 116 +++++----- .../baeldung/dbunit/OldSchoolDbUnitTest.java | 209 +++++++++--------- .../dbunit/PrepAndExpectedDbUnitTest.java | 96 ++++---- 5 files changed, 310 insertions(+), 281 deletions(-) diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/ConnectionSettings.java b/libraries-testing/src/test/java/com/baeldung/dbunit/ConnectionSettings.java index b30d636a12..cc29d9c58a 100644 --- a/libraries-testing/src/test/java/com/baeldung/dbunit/ConnectionSettings.java +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/ConnectionSettings.java @@ -1,8 +1,8 @@ package com.baeldung.dbunit; public class ConnectionSettings { - public static final String JDBC_DRIVER = org.h2.Driver.class.getName(); - public static final String JDBC_URL = "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;init=runscript from 'classpath:dbunit/schema.sql'"; - public static final String USER = "sa"; - public static final String PASSWORD = ""; + public static final String JDBC_DRIVER = org.h2.Driver.class.getName(); + public static final String JDBC_URL = "jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;init=runscript from 'classpath:dbunit/schema.sql'"; + public static final String USER = "sa"; + public static final String PASSWORD = ""; } diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java index 1cb7489688..93503277b4 100644 --- a/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java @@ -26,87 +26,97 @@ import static org.assertj.core.api.Assertions.assertThat; public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { - private static final Logger logger = LoggerFactory.getLogger(DataSourceDBUnitTest.class); + private static final Logger logger = LoggerFactory.getLogger(DataSourceDBUnitTest.class); - @Override protected javax.sql.DataSource getDataSource() { - JdbcDataSource dataSource = new JdbcDataSource(); - dataSource.setURL(JDBC_URL); - dataSource.setUser("sa"); - dataSource.setPassword(""); - return dataSource; + @Override + protected javax.sql.DataSource getDataSource() { + JdbcDataSource dataSource = new JdbcDataSource(); + dataSource.setURL(JDBC_URL); + dataSource.setUser("sa"); + dataSource.setPassword(""); + return dataSource; + } + + @Override + protected IDataSet getDataSet() throws Exception { + try (InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream("dbunit/data.xml")) { + return new FlatXmlDataSetBuilder().build(resourceAsStream); } + } - @Override protected IDataSet getDataSet() throws Exception { - try (InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream("dbunit/data.xml")) { - return new FlatXmlDataSetBuilder().build(resourceAsStream); - } + @Override + protected DatabaseOperation getSetUpOperation() { + return DatabaseOperation.REFRESH; + } + + @Override + protected DatabaseOperation getTearDownOperation() { + return DatabaseOperation.DELETE_ALL; + } + + @Before + public void setUp() throws Exception { + super.setUp(); + } + + @After + public void tearDown() throws Exception { + super.tearDown(); + } + + @Test + public void testSimpleDataSet() throws SQLException { + final Connection connection = getDataSource().getConnection(); + + final ResultSet rs = connection.createStatement().executeQuery("select * from ITEMS where id = 1"); + + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); + } + + @Test + public void testEmptySchema() throws Exception { + final IDataSet expectedDataSet = getDataSet(); + final ITable expectedTable = expectedDataSet.getTable("CLIENTS"); + final IDataSet databaseDataSet = getConnection().createDataSet(); + final ITable actualTable = databaseDataSet.getTable("CLIENTS"); + Assertion.assertEquals(expectedTable, actualTable); + } + + @Test + public void testAssertByQuery() throws Exception { + try (final InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/expected-user.xml")) { + final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); + final ITable expectedTable = expectedDataSet.getTable("CLIENTS"); + final Connection conn = getDataSource().getConnection(); + + conn.createStatement().executeUpdate("INSERT INTO CLIENTS (first_name, last_name) VALUES ('John', 'Jansen')"); + final ITable actualData = getConnection().createQueryTable("result_name", "SELECT * FROM CLIENTS WHERE last_name='Jansen'"); + + Assertion.assertEqualsIgnoreCols(expectedTable, actualData, new String[] { "id" }); } + } - @Override protected DatabaseOperation getSetUpOperation() { - return DatabaseOperation.REFRESH; + @Test + public void testMultipleFailures() throws Exception { + try (final InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/expected-multiple-failures.xml")) { + final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); + final ITable expectedTable = expectedDataSet.getTable("ITEMS"); + final Connection conn = getDataSource().getConnection(); + final DiffCollectingFailureHandler collectingHandler = new DiffCollectingFailureHandler(); + + conn.createStatement().executeUpdate("INSERT INTO ITEMS (title, price) VALUES ('Battery', '1000000')"); + final ITable actualData = getConnection().createDataSet().getTable("ITEMS"); + + Assertion.assertEquals(expectedTable, actualData, collectingHandler); + if (!collectingHandler.getDiffList().isEmpty()) { + String message = (String) collectingHandler.getDiffList().stream().map(d -> formatDifference((Difference) d)).collect(joining("\n")); + logger.error(() -> message); + } } + } - @Override protected DatabaseOperation getTearDownOperation() { - return DatabaseOperation.DELETE_ALL; - } - - @Before public void setUp() throws Exception { - super.setUp(); - } - - @After public void tearDown() throws Exception { - super.tearDown(); - } - - @Test public void testSimpleDataSet() throws SQLException { - final Connection connection = getDataSource().getConnection(); - - final ResultSet rs = connection.createStatement().executeQuery("select * from ITEMS where id = 1"); - - assertThat(rs.next()).isTrue(); - assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); - } - - @Test public void testEmptySchema() throws Exception { - final IDataSet expectedDataSet = getDataSet(); - final ITable expectedTable = expectedDataSet.getTable("CLIENTS"); - final IDataSet databaseDataSet = getConnection().createDataSet(); - final ITable actualTable = databaseDataSet.getTable("CLIENTS"); - Assertion.assertEquals(expectedTable, actualTable); - } - - @Test public void testAssertByQuery() throws Exception { - try (final InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/expected-user.xml")) { - final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); - final ITable expectedTable = expectedDataSet.getTable("CLIENTS"); - final Connection conn = getDataSource().getConnection(); - - conn.createStatement().executeUpdate("INSERT INTO CLIENTS (first_name, last_name) VALUES ('John', 'Jansen')"); - final ITable actualData = getConnection().createQueryTable("result_name", "SELECT * FROM CLIENTS WHERE last_name='Jansen'"); - - Assertion.assertEqualsIgnoreCols(expectedTable, actualData, new String[] { "id" }); - } - } - - @Test public void testMultipleFailures() throws Exception { - try (final InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/expected-multiple-failures.xml")) { - final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); - final ITable expectedTable = expectedDataSet.getTable("ITEMS"); - final Connection conn = getDataSource().getConnection(); - final DiffCollectingFailureHandler collectingHandler = new DiffCollectingFailureHandler(); - - conn.createStatement().executeUpdate("INSERT INTO ITEMS (title, price) VALUES ('Battery', '1000000')"); - final ITable actualData = getConnection().createDataSet().getTable("ITEMS"); - - Assertion.assertEquals(expectedTable, actualData, collectingHandler); - if (!collectingHandler.getDiffList().isEmpty()) { - String message = (String) collectingHandler.getDiffList().stream().map(d -> formatDifference((Difference) d)).collect(joining("\n")); - logger.error(() -> message); - } - } - } - - private static String formatDifference(Difference diff) { - return "expected value in " + diff.getExpectedTable().getTableMetaData().getTableName() + "." + diff.getColumnName() + " row " + diff.getRowIndex() + ":" + diff.getExpectedValue() + ", but was: " + diff.getActualValue(); - } + private static String formatDifference(Difference diff) { + return "expected value in " + diff.getExpectedTable().getTableMetaData().getTableName() + "." + diff.getColumnName() + " row " + diff.getRowIndex() + ":" + diff.getExpectedValue() + ", but was: " + diff.getActualValue(); + } } diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/DbUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/DbUnitTest.java index a3a41b9b8d..da4ac54f12 100644 --- a/libraries-testing/src/test/java/com/baeldung/dbunit/DbUnitTest.java +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/DbUnitTest.java @@ -21,65 +21,71 @@ import static org.assertj.core.api.Assertions.assertThat; public class DbUnitTest extends DBTestCase { - public DbUnitTest(String name) { - super(name); - System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS, JDBC_DRIVER); - System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL, JDBC_URL); - System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME, USER); - System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD, PASSWORD); + public DbUnitTest(String name) { + super(name); + System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS, JDBC_DRIVER); + System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL, JDBC_URL); + System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME, USER); + System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD, PASSWORD); + } + + @Override + protected IDataSet getDataSet() throws Exception { + try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/data.xml")) { + return new FlatXmlDataSetBuilder().build(is); } + } - @Override protected IDataSet getDataSet() throws Exception { - try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/data.xml")) { - return new FlatXmlDataSetBuilder().build(is); - } + @Override + protected DatabaseOperation getSetUpOperation() { + return DatabaseOperation.REFRESH; + } + + @Override + protected DatabaseOperation getTearDownOperation() { + return DatabaseOperation.DELETE_ALL; + } + + @Test + public void testSelect() throws Exception { + final Connection connection = getConnection().getConnection(); + + final ResultSet rs = connection.createStatement().executeQuery("select * from ITEMS where id = 1"); + + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); + } + + @Test + public void testDelete() throws Exception { + final Connection connection = getConnection().getConnection(); + + try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_delete.xml")) { + ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("ITEMS"); + + connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); + + final IDataSet databaseDataSet = getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("ITEMS"); + + Assertion.assertEquals(expectedTable, actualTable); } + } - @Override protected DatabaseOperation getSetUpOperation() { - return DatabaseOperation.REFRESH; - } - - @Override protected DatabaseOperation getTearDownOperation() { - return DatabaseOperation.DELETE_ALL; - } - - @Test public void testSelect() throws Exception { - final Connection connection = getConnection().getConnection(); - - final ResultSet rs = connection.createStatement().executeQuery("select * from ITEMS where id = 1"); - - assertThat(rs.next()).isTrue(); - assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); - } - - @Test public void testDelete() throws Exception { - final Connection connection = getConnection().getConnection(); - - try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_delete.xml")) { - ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("ITEMS"); - - connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); - - final IDataSet databaseDataSet = getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("ITEMS"); - - Assertion.assertEquals(expectedTable, actualTable); - } - } - - @Test public void testUpdate() throws Exception { - final Connection connection = getConnection().getConnection(); - - try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_rename.xml")) { - ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("ITEMS"); - - connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); - - final IDataSet databaseDataSet = getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("ITEMS"); - - Assertion.assertEquals(expectedTable, actualTable); - } + @Test + public void testUpdate() throws Exception { + final Connection connection = getConnection().getConnection(); + + try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_rename.xml")) { + ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("ITEMS"); + + connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); + + final IDataSet databaseDataSet = getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("ITEMS"); + + Assertion.assertEquals(expectedTable, actualTable); } + } } diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java index be6023d432..a7821102dc 100644 --- a/libraries-testing/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java @@ -26,119 +26,128 @@ import static org.dbunit.Assertion.assertEquals; public class OldSchoolDbUnitTest { - private static IDatabaseTester tester = null; + private static IDatabaseTester tester = null; - @BeforeClass public static void setUp() throws Exception { - tester = initDatabaseTester(); + @BeforeClass + public static void setUp() throws Exception { + tester = initDatabaseTester(); + } + + private static IDatabaseTester initDatabaseTester() throws Exception { + final JdbcDatabaseTester tester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER, PASSWORD); + tester.setDataSet(initDataSet()); + tester.setSetUpOperation(DatabaseOperation.REFRESH); + tester.setTearDownOperation(DatabaseOperation.DELETE_ALL); + return tester; + } + + private static IDataSet initDataSet() throws Exception { + try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/data.xml")) { + return new FlatXmlDataSetBuilder().build(is); } + } - private static IDatabaseTester initDatabaseTester() throws Exception { - final JdbcDatabaseTester tester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER, PASSWORD); - tester.setDataSet(initDataSet()); - tester.setSetUpOperation(DatabaseOperation.REFRESH); - tester.setTearDownOperation(DatabaseOperation.DELETE_ALL); - return tester; + @Before + public void setup() throws Exception { + tester.onSetup(); + } + + @After + public void tearDown() throws Exception { + tester.onTearDown(); + } + + @Test + public void testSelect() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + + final ResultSet rs = connection.createStatement().executeQuery("select * from ITEMS where id = 1"); + + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); + } + + @Test + public void testIgnoringProduced() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + final String[] excludedColumns = { "id", "produced" }; + try (final InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/expected-ignoring-registered_at.xml")) { + final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); + final ITable expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedDataSet.getTable("ITEMS"), excludedColumns); + + connection.createStatement().executeUpdate("INSERT INTO ITEMS (title, price, produced) VALUES('Necklace', 199.99, now())"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + final ITable actualTable = DefaultColumnFilter.excludedColumnsTable(databaseDataSet.getTable("ITEMS"), excludedColumns); + + Assertion.assertEquals(expectedTable, actualTable); } + } - private static IDataSet initDataSet() throws Exception { - try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/data.xml")) { - return new FlatXmlDataSetBuilder().build(is); - } + @Test + public void testDelete() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + + try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_delete.xml")) { + ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("ITEMS"); + + connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("ITEMS"); + + assertEquals(expectedTable, actualTable); } + } - @Before public void setup() throws Exception { - tester.onSetup(); + @Test + public void testDeleteWithExcludedColumns() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + + try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_delete_no_produced.xml")) { + final ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("ITEMS"); + + connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("ITEMS"); + actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[] { "produced" }); + + assertEquals(expectedTable, actualTable); } + } - @After public void tearDown() throws Exception { - tester.onTearDown(); + @Test + public void testUpdate() throws Exception { + final Connection connection = tester.getConnection().getConnection(); + + try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_rename.xml")) { + final ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("ITEMS"); + + connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("ITEMS"); + + assertEquals(expectedTable, actualTable); } + } - @Test public void testSelect() throws Exception { - final Connection connection = tester.getConnection().getConnection(); + @Test + public void testUpdateWithExcludedColumns() throws Exception { + final Connection connection = tester.getConnection().getConnection(); - final ResultSet rs = connection.createStatement().executeQuery("select * from ITEMS where id = 1"); + try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_rename_no_produced.xml")) { + ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("ITEMS"); - assertThat(rs.next()).isTrue(); - assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); - } - - @Test public void testIgnoringProduced() throws Exception { - final Connection connection = tester.getConnection().getConnection(); - final String[] excludedColumns = { "id", "produced" }; - try (final InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/expected-ignoring-registered_at.xml")) { - final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); - final ITable expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedDataSet.getTable("ITEMS"), excludedColumns); - - connection.createStatement().executeUpdate("INSERT INTO ITEMS (title, price, produced) VALUES('Necklace', 199.99, now())"); - - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - final ITable actualTable = DefaultColumnFilter.excludedColumnsTable(databaseDataSet.getTable("ITEMS"), excludedColumns); - - Assertion.assertEquals(expectedTable, actualTable); - } - } - - @Test public void testDelete() throws Exception { - final Connection connection = tester.getConnection().getConnection(); - - try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_delete.xml")) { - ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("ITEMS"); - - connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); - - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("ITEMS"); - - assertEquals(expectedTable, actualTable); - } - } - - @Test public void testDeleteWithExcludedColumns() throws Exception { - final Connection connection = tester.getConnection().getConnection(); - - try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_delete_no_produced.xml")) { - final ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("ITEMS"); - - connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); - - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("ITEMS"); - actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[] { "produced" }); - - assertEquals(expectedTable, actualTable); - } - } - - @Test public void testUpdate() throws Exception { - final Connection connection = tester.getConnection().getConnection(); - - try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_rename.xml")) { - final ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("ITEMS"); - - connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); - - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("ITEMS"); - - assertEquals(expectedTable, actualTable); - } - } - - @Test public void testUpdateWithExcludedColumns() throws Exception { - final Connection connection = tester.getConnection().getConnection(); - - try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_rename_no_produced.xml")) { - ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("ITEMS"); - - connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); - - final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("ITEMS"); - actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[] { "produced" }); - - assertEquals(expectedTable, actualTable); - } + connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); + + final IDataSet databaseDataSet = tester.getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("ITEMS"); + actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[] { "produced" }); + + assertEquals(expectedTable, actualTable); } + } } diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java index f797f153a0..039dfd1639 100644 --- a/libraries-testing/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java @@ -24,60 +24,64 @@ import static org.assertj.core.api.Assertions.assertThat; public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { - @Override public void setUp() throws Exception { - setDatabaseTester(initDatabaseTester()); - setDataFileLoader(initDataFileLoader()); - super.setUp(); + @Override + public void setUp() throws Exception { + setDatabaseTester(initDatabaseTester()); + setDataFileLoader(initDataFileLoader()); + super.setUp(); + } + + private IDatabaseTester initDatabaseTester() throws Exception { + final JdbcDatabaseTester tester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER, PASSWORD); + tester.setDataSet(initDataSet()); + tester.setSetUpOperation(DatabaseOperation.REFRESH); + return tester; + } + + private IDataSet initDataSet() throws Exception { + try (final InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/data.xml")) { + return new FlatXmlDataSetBuilder().build(is); } + } - private IDatabaseTester initDatabaseTester() throws Exception { - final JdbcDatabaseTester tester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER, PASSWORD); - tester.setDataSet(initDataSet()); - tester.setSetUpOperation(DatabaseOperation.REFRESH); - return tester; - } + private DataFileLoader initDataFileLoader() { + return new FlatXmlDataFileLoader(); + } - private IDataSet initDataSet() throws Exception { - try (final InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/data.xml")) { - return new FlatXmlDataSetBuilder().build(is); - } - } + @Test + public void testSelect() throws Exception { + final Connection connection = getConnection().getConnection(); + final VerifyTableDefinition[] verifyTables = { new VerifyTableDefinition("CLIENTS", new String[] {}) }; + final String[] prepDataFiles = { "/dbunit/users.xml" }; + final String[] expectedDataFiles = { "/dbunit/users.xml" }; + final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement().executeQuery("select * from CLIENTS where id = 1"); - private DataFileLoader initDataFileLoader() { - return new FlatXmlDataFileLoader(); - } + final ResultSet rs = (ResultSet) super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); - @Test public void testSelect() throws Exception { - final Connection connection = getConnection().getConnection(); - final VerifyTableDefinition[] verifyTables = { new VerifyTableDefinition("CLIENTS", new String[] {}) }; - final String[] prepDataFiles = { "/dbunit/users.xml" }; - final String[] expectedDataFiles = { "/dbunit/users.xml" }; - final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement().executeQuery("select * from CLIENTS where id = 1"); + assertThat(rs.next()).isTrue(); + assertThat(rs.getString("last_name")).isEqualTo("Xavier"); + } - final ResultSet rs = (ResultSet) super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); + @Test + public void testUpdate() throws Exception { + final Connection connection = getConnection().getConnection(); + final VerifyTableDefinition[] verifyTables = { new VerifyTableDefinition("CLIENTS", new String[] {}) }; // define tables to verify + final String[] prepDataFiles = { "/dbunit/users.xml" }; + final String[] expectedDataFiles = { "/dbunit/users_exp_rename.xml" }; + final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement().executeUpdate("update CLIENTS set first_name = 'new name' where id = 1"); - assertThat(rs.next()).isTrue(); - assertThat(rs.getString("last_name")).isEqualTo("Xavier"); - } + super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); + } - @Test public void testUpdate() throws Exception { - final Connection connection = getConnection().getConnection(); - final VerifyTableDefinition[] verifyTables = { new VerifyTableDefinition("CLIENTS", new String[] {}) }; // define tables to verify - final String[] prepDataFiles = { "/dbunit/users.xml" }; - final String[] expectedDataFiles = { "/dbunit/users_exp_rename.xml" }; - final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement().executeUpdate("update CLIENTS set first_name = 'new name' where id = 1"); + @Test + public void testDelete() throws Exception { + final Connection connection = getConnection().getConnection(); + final VerifyTableDefinition[] verifyTables = { new VerifyTableDefinition("CLIENTS", new String[] {}) }; + final String[] prepDataFiles = { "/dbunit/users.xml" }; + final String[] expectedDataFiles = { "/dbunit/users_exp_delete.xml" }; + final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement().executeUpdate("delete from CLIENTS where id = 2"); - super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); - } - - @Test public void testDelete() throws Exception { - final Connection connection = getConnection().getConnection(); - final VerifyTableDefinition[] verifyTables = { new VerifyTableDefinition("CLIENTS", new String[] {}) }; - final String[] prepDataFiles = { "/dbunit/users.xml" }; - final String[] expectedDataFiles = { "/dbunit/users_exp_delete.xml" }; - final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement().executeUpdate("delete from CLIENTS where id = 2"); - - super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); - } + super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); + } } From 63dcae64238124c6cfe87a96bea4e08358a6e936 Mon Sep 17 00:00:00 2001 From: Sasa M Date: Wed, 1 Apr 2020 19:18:10 +0200 Subject: [PATCH 076/503] Practical example of Hexagonal architecture - add project --- .../baeldung/employee/config/AppConfig.java | 73 +++++++++++++++++++ .../config/ApplicationInitializer.java | 29 ++++++++ .../employee/data/EmployeeDataAdapter.java | 9 +++ .../data/EmployeeDataAdapterImpl.java | 28 +++++++ .../baeldung/employee/data/EmployeeRepo.java | 9 +++ .../baeldung/employee/domain/Employee.java | 43 +++++++++++ .../baeldung/employee/dto/EmployeeDTO.java | 9 +++ .../employee/service/EmployeeController.java | 47 ++++++++++++ .../employee/service/EmployeeService.java | 8 ++ .../employee/service/EmployeeServiceImpl.java | 25 +++++++ EmpServiceApp/src/createEmployeeTable.sql | 11 +++ .../web/WEB-INF/applicationContext.xml | 12 +++ EmpServiceApp/web/WEB-INF/web.xml | 25 +++++++ 13 files changed, 328 insertions(+) create mode 100644 EmpServiceApp/src/com/baeldung/employee/config/AppConfig.java create mode 100644 EmpServiceApp/src/com/baeldung/employee/config/ApplicationInitializer.java create mode 100644 EmpServiceApp/src/com/baeldung/employee/data/EmployeeDataAdapter.java create mode 100644 EmpServiceApp/src/com/baeldung/employee/data/EmployeeDataAdapterImpl.java create mode 100644 EmpServiceApp/src/com/baeldung/employee/data/EmployeeRepo.java create mode 100644 EmpServiceApp/src/com/baeldung/employee/domain/Employee.java create mode 100644 EmpServiceApp/src/com/baeldung/employee/dto/EmployeeDTO.java create mode 100644 EmpServiceApp/src/com/baeldung/employee/service/EmployeeController.java create mode 100644 EmpServiceApp/src/com/baeldung/employee/service/EmployeeService.java create mode 100644 EmpServiceApp/src/com/baeldung/employee/service/EmployeeServiceImpl.java create mode 100644 EmpServiceApp/src/createEmployeeTable.sql create mode 100644 EmpServiceApp/web/WEB-INF/applicationContext.xml create mode 100644 EmpServiceApp/web/WEB-INF/web.xml diff --git a/EmpServiceApp/src/com/baeldung/employee/config/AppConfig.java b/EmpServiceApp/src/com/baeldung/employee/config/AppConfig.java new file mode 100644 index 0000000000..3f6919b8f5 --- /dev/null +++ b/EmpServiceApp/src/com/baeldung/employee/config/AppConfig.java @@ -0,0 +1,73 @@ +package com.baeldung.employee.config; + +import javax.persistence.EntityManagerFactory; +import javax.sql.DataSource; + +import org.modelmapper.ModelMapper; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; +import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; +import org.springframework.orm.jpa.JpaTransactionManager; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; +import org.springframework.transaction.TransactionManager; + +@Configuration +@EnableJpaRepositories(basePackages = "com.baeldung.employee.data", entityManagerFactoryRef = "emf") +@ComponentScan(basePackages = "com.baeldung.employee") +public class AppConfig { + + @Bean + public DataSource h2DataSource() { + + EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); + EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2) + .addScript("createEmployeeTable.sql") + .build(); + return db; + + } + + @Bean + public ModelMapper mapper() { + + return new ModelMapper(); + } + + /* @Bean + public ObjectMapper objectMapper() { + + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, true); + + return mapper; + } + */ + + @Bean(name = "emf") + public LocalContainerEntityManagerFactoryBean entityManagerFactory() { + + HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + + LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); + factory.setJpaVendorAdapter(vendorAdapter); + factory.setPackagesToScan("com.baeldung.employee"); + factory.setDataSource(h2DataSource()); + // factory.setJpaProperties(jpaProperties()); + + return factory; + } + + @Bean + public TransactionManager jpaTransactionManager(EntityManagerFactory emf) { + JpaTransactionManager transactionManager = new JpaTransactionManager(); + transactionManager.setEntityManagerFactory(emf); + return transactionManager; + } + +} diff --git a/EmpServiceApp/src/com/baeldung/employee/config/ApplicationInitializer.java b/EmpServiceApp/src/com/baeldung/employee/config/ApplicationInitializer.java new file mode 100644 index 0000000000..491e97b2c8 --- /dev/null +++ b/EmpServiceApp/src/com/baeldung/employee/config/ApplicationInitializer.java @@ -0,0 +1,29 @@ +package com.baeldung.employee.config; + +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRegistration; + +import org.springframework.web.WebApplicationInitializer; +import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import org.springframework.web.servlet.DispatcherServlet; + +public class ApplicationInitializer implements WebApplicationInitializer { + + @Override + public void onStartup(ServletContext servletContext) throws ServletException { + + AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); + context.register(AppConfig.class); + + servletContext.addListener(new ContextLoaderListener(context)); + + // Create DispatcherServlet + + ServletRegistration.Dynamic dispatcher = servletContext.addServlet("EmployeeSpringApp", new DispatcherServlet()); + dispatcher.setLoadOnStartup(1); + dispatcher.addMapping("/app"); + + } +} diff --git a/EmpServiceApp/src/com/baeldung/employee/data/EmployeeDataAdapter.java b/EmpServiceApp/src/com/baeldung/employee/data/EmployeeDataAdapter.java new file mode 100644 index 0000000000..da5d5bb1a3 --- /dev/null +++ b/EmpServiceApp/src/com/baeldung/employee/data/EmployeeDataAdapter.java @@ -0,0 +1,9 @@ +package com.baeldung.employee.data; + +import com.baeldung.employee.dto.EmployeeDTO; + +public interface EmployeeDataAdapter { + + void addEmployee(EmployeeDTO emp); + +} diff --git a/EmpServiceApp/src/com/baeldung/employee/data/EmployeeDataAdapterImpl.java b/EmpServiceApp/src/com/baeldung/employee/data/EmployeeDataAdapterImpl.java new file mode 100644 index 0000000000..54b3079844 --- /dev/null +++ b/EmpServiceApp/src/com/baeldung/employee/data/EmployeeDataAdapterImpl.java @@ -0,0 +1,28 @@ +package com.baeldung.employee.data; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; + +import org.modelmapper.ModelMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.baeldung.employee.domain.Employee; +import com.baeldung.employee.dto.EmployeeDTO; + +@Component +public class EmployeeDataAdapterImpl implements EmployeeDataAdapter { + + @PersistenceContext + private EntityManager em; + + @Autowired + private ModelMapper modelMapper; + + @Override + public void addEmployee(EmployeeDTO emp) { + + em.persist(modelMapper.map(emp, Employee.class)); + + } +} diff --git a/EmpServiceApp/src/com/baeldung/employee/data/EmployeeRepo.java b/EmpServiceApp/src/com/baeldung/employee/data/EmployeeRepo.java new file mode 100644 index 0000000000..4d63dc391d --- /dev/null +++ b/EmpServiceApp/src/com/baeldung/employee/data/EmployeeRepo.java @@ -0,0 +1,9 @@ +package com.baeldung.employee.data; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.baeldung.employee.domain.Employee; + +public interface EmployeeRepo extends JpaRepository { + +} diff --git a/EmpServiceApp/src/com/baeldung/employee/domain/Employee.java b/EmpServiceApp/src/com/baeldung/employee/domain/Employee.java new file mode 100644 index 0000000000..f9cd937c21 --- /dev/null +++ b/EmpServiceApp/src/com/baeldung/employee/domain/Employee.java @@ -0,0 +1,43 @@ +package com.baeldung.employee.domain; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "EMPLOYEE") +public class Employee { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + private String name; + + public Employee() { + } + + public Employee(int id, String name) { + this.id = id; + this.name = name; + } + + public long getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + // Standard constructors, getters and setters +} diff --git a/EmpServiceApp/src/com/baeldung/employee/dto/EmployeeDTO.java b/EmpServiceApp/src/com/baeldung/employee/dto/EmployeeDTO.java new file mode 100644 index 0000000000..3b6b048a9c --- /dev/null +++ b/EmpServiceApp/src/com/baeldung/employee/dto/EmployeeDTO.java @@ -0,0 +1,9 @@ +package com.baeldung.employee.dto; + +public class EmployeeDTO { + + private long id; + private String name; + + // Standard constructors, getters and setters +} diff --git a/EmpServiceApp/src/com/baeldung/employee/service/EmployeeController.java b/EmpServiceApp/src/com/baeldung/employee/service/EmployeeController.java new file mode 100644 index 0000000000..b258d11018 --- /dev/null +++ b/EmpServiceApp/src/com/baeldung/employee/service/EmployeeController.java @@ -0,0 +1,47 @@ +package com.baeldung.employee.service; + +import java.net.URI; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; + +import com.baeldung.employee.domain.Employee; + +@RestController +public class EmployeeController { + + @Autowired + private EmployeeService empService; + + @GetMapping(value = "/", produces = MediaType.TEXT_HTML_VALUE) + public String home() { + + return "This is employee app page"; + } + + @PostMapping(path = "/employees", consumes = "application/json", produces = "application/json") + public ResponseEntity addEmployee(@RequestBody Map empBody) { + + String id = empBody.get("id"); + String name = empBody.get("name"); + + Employee emp = new Employee(Integer.valueOf(id), name); + empService.addEmployee(emp); + + // Create resource uri + URI uri = ServletUriComponentsBuilder.fromCurrentRequest() + .buildAndExpand(emp.getId()) + .toUri(); + + // Send uri in response + return ResponseEntity.created(uri) + .build(); + } +} diff --git a/EmpServiceApp/src/com/baeldung/employee/service/EmployeeService.java b/EmpServiceApp/src/com/baeldung/employee/service/EmployeeService.java new file mode 100644 index 0000000000..81c7665a50 --- /dev/null +++ b/EmpServiceApp/src/com/baeldung/employee/service/EmployeeService.java @@ -0,0 +1,8 @@ +package com.baeldung.employee.service; + +import com.baeldung.employee.domain.Employee; + +public interface EmployeeService { + + void addEmployee(Employee emp); +} diff --git a/EmpServiceApp/src/com/baeldung/employee/service/EmployeeServiceImpl.java b/EmpServiceApp/src/com/baeldung/employee/service/EmployeeServiceImpl.java new file mode 100644 index 0000000000..45aba2898b --- /dev/null +++ b/EmpServiceApp/src/com/baeldung/employee/service/EmployeeServiceImpl.java @@ -0,0 +1,25 @@ +package com.baeldung.employee.service; + +import org.modelmapper.ModelMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.baeldung.employee.data.EmployeeDataAdapter; +import com.baeldung.employee.domain.Employee; +import com.baeldung.employee.dto.EmployeeDTO; + +@Service +public class EmployeeServiceImpl implements EmployeeService { + + @Autowired + private EmployeeDataAdapter employeeDataAdapter; + + @Autowired + private ModelMapper modelMapper; + + @Override + public void addEmployee(Employee emp) { + employeeDataAdapter.addEmployee(modelMapper.map(emp, EmployeeDTO.class)); + } + +} diff --git a/EmpServiceApp/src/createEmployeeTable.sql b/EmpServiceApp/src/createEmployeeTable.sql new file mode 100644 index 0000000000..14b8347bff --- /dev/null +++ b/EmpServiceApp/src/createEmployeeTable.sql @@ -0,0 +1,11 @@ +DROP TABLE IF EXISTS EMPLOYEE; + +CREATE TABLE EMPLOYEE ( + + ID IDENTITY PRIMARY KEY, + NAME VARCHAR(64) NOT NULL, + +); + +INSERT INTO EMPLOYEE (ID, NAME) VALUES (10, 'EMP 10'); +INSERT INTO EMPLOYEE (ID, NAME) VALUES (20, 'EMP 20'); diff --git a/EmpServiceApp/web/WEB-INF/applicationContext.xml b/EmpServiceApp/web/WEB-INF/applicationContext.xml new file mode 100644 index 0000000000..54b3429708 --- /dev/null +++ b/EmpServiceApp/web/WEB-INF/applicationContext.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/EmpServiceApp/web/WEB-INF/web.xml b/EmpServiceApp/web/WEB-INF/web.xml new file mode 100644 index 0000000000..7731773f82 --- /dev/null +++ b/EmpServiceApp/web/WEB-INF/web.xml @@ -0,0 +1,25 @@ + + + Employee Spring App + + + org.springframework.web.context.ContextLoaderListener + + + + EmployeeSpringApp + org.springframework.web.servlet.DispatcherServlet + + contextConfigLocation + /WEB-INF/applicationContext.xml + + 1 + + + EmployeeSpringApp + /* + + \ No newline at end of file From ce412e718e223baa73b018c0654a0d83e0a34806 Mon Sep 17 00:00:00 2001 From: Sasa M Date: Thu, 2 Apr 2020 18:53:23 +0200 Subject: [PATCH 077/503] Refactoring domain and config classes --- .../src/com/baeldung/employee/config/AppConfig.java | 12 +----------- .../src/com/baeldung/employee/data/EmployeeRepo.java | 2 +- .../src/com/baeldung/employee/domain/Employee.java | 2 +- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/EmpServiceApp/src/com/baeldung/employee/config/AppConfig.java b/EmpServiceApp/src/com/baeldung/employee/config/AppConfig.java index 3f6919b8f5..3bde8fceed 100644 --- a/EmpServiceApp/src/com/baeldung/employee/config/AppConfig.java +++ b/EmpServiceApp/src/com/baeldung/employee/config/AppConfig.java @@ -38,16 +38,6 @@ public class AppConfig { return new ModelMapper(); } - /* @Bean - public ObjectMapper objectMapper() { - - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - mapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, true); - - return mapper; - } - */ @Bean(name = "emf") public LocalContainerEntityManagerFactoryBean entityManagerFactory() { @@ -58,7 +48,7 @@ public class AppConfig { factory.setJpaVendorAdapter(vendorAdapter); factory.setPackagesToScan("com.baeldung.employee"); factory.setDataSource(h2DataSource()); - // factory.setJpaProperties(jpaProperties()); + return factory; } diff --git a/EmpServiceApp/src/com/baeldung/employee/data/EmployeeRepo.java b/EmpServiceApp/src/com/baeldung/employee/data/EmployeeRepo.java index 4d63dc391d..0712f7823a 100644 --- a/EmpServiceApp/src/com/baeldung/employee/data/EmployeeRepo.java +++ b/EmpServiceApp/src/com/baeldung/employee/data/EmployeeRepo.java @@ -4,6 +4,6 @@ import org.springframework.data.jpa.repository.JpaRepository; import com.baeldung.employee.domain.Employee; -public interface EmployeeRepo extends JpaRepository { +public interface EmployeeRepo extends JpaRepository { } diff --git a/EmpServiceApp/src/com/baeldung/employee/domain/Employee.java b/EmpServiceApp/src/com/baeldung/employee/domain/Employee.java index f9cd937c21..3b93b8a97e 100644 --- a/EmpServiceApp/src/com/baeldung/employee/domain/Employee.java +++ b/EmpServiceApp/src/com/baeldung/employee/domain/Employee.java @@ -7,7 +7,7 @@ import javax.persistence.Id; import javax.persistence.Table; @Entity -@Table(name = "EMPLOYEE") +@Table public class Employee { @Id From e98323d913d19af96119a9d9220b8eebda64c2fc Mon Sep 17 00:00:00 2001 From: Joao Esperancinha Date: Fri, 3 Apr 2020 08:51:46 +0200 Subject: [PATCH 078/503] [BAEL-2749] Renaming test methods and running them with JUnit4 --- .../baeldung/dbunit/DataSourceDBUnitTest.java | 63 +++++++++++-- .../java/com/baeldung/dbunit/DbUnitTest.java | 91 ------------------- .../baeldung/dbunit/OldSchoolDbUnitTest.java | 26 ++++-- .../dbunit/PrepAndExpectedDbUnitTest.java | 87 ------------------ .../jsonassert/JsonAssertUnitTest.java | 10 +- .../src/test/resources/dbunit/data.xml | 2 +- .../dbunit/items_exp_rename_no_produced.xml | 2 +- .../src/test/resources/dbunit/users.xml | 2 +- .../resources/dbunit/users_exp_delete.xml | 2 +- .../resources/dbunit/users_exp_rename.xml | 2 +- 10 files changed, 80 insertions(+), 207 deletions(-) delete mode 100644 libraries-testing/src/test/java/com/baeldung/dbunit/DbUnitTest.java delete mode 100644 libraries-testing/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java index 93503277b4..20b0337f4d 100644 --- a/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java @@ -14,6 +14,8 @@ import org.junit.Before; import org.junit.Test; import org.junit.platform.commons.logging.Logger; import org.junit.platform.commons.logging.LoggerFactory; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import java.io.InputStream; import java.sql.Connection; @@ -23,7 +25,9 @@ import java.sql.SQLException; import static com.baeldung.dbunit.ConnectionSettings.JDBC_URL; import static java.util.stream.Collectors.joining; import static org.assertj.core.api.Assertions.assertThat; +import static org.dbunit.Assertion.assertEqualsIgnoreCols; +@RunWith(JUnit4.class) public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { private static final Logger logger = LoggerFactory.getLogger(DataSourceDBUnitTest.class); @@ -65,7 +69,7 @@ public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { } @Test - public void testSimpleDataSet() throws SQLException { + public void givenDataSet_whenSelect_thenFirstTitleIsGreyTShirt() throws SQLException { final Connection connection = getDataSource().getConnection(); final ResultSet rs = connection.createStatement().executeQuery("select * from ITEMS where id = 1"); @@ -75,7 +79,7 @@ public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { } @Test - public void testEmptySchema() throws Exception { + public void givenDataSetEmptySchema_whenDataSetCreated_thenTablesAreEqual() throws Exception { final IDataSet expectedDataSet = getDataSet(); final ITable expectedTable = expectedDataSet.getTable("CLIENTS"); final IDataSet databaseDataSet = getConnection().createDataSet(); @@ -84,33 +88,74 @@ public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { } @Test - public void testAssertByQuery() throws Exception { + public void givenDataSet_whenInsert_thenTableHasNewClient() throws Exception { try (final InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/expected-user.xml")) { final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); final ITable expectedTable = expectedDataSet.getTable("CLIENTS"); final Connection conn = getDataSource().getConnection(); - conn.createStatement().executeUpdate("INSERT INTO CLIENTS (first_name, last_name) VALUES ('John', 'Jansen')"); - final ITable actualData = getConnection().createQueryTable("result_name", "SELECT * FROM CLIENTS WHERE last_name='Jansen'"); + conn.createStatement() + .executeUpdate( + "INSERT INTO CLIENTS (first_name, last_name) VALUES ('John', 'Jansen')"); + final ITable actualData = getConnection() + .createQueryTable( + "result_name", + "SELECT * FROM CLIENTS WHERE last_name='Jansen'"); - Assertion.assertEqualsIgnoreCols(expectedTable, actualData, new String[] { "id" }); + assertEqualsIgnoreCols(expectedTable, actualData, new String[] { "id" }); } } @Test - public void testMultipleFailures() throws Exception { + public void givenDataSet_whenDelete_thenItemIsDeleted() throws Exception { + final Connection connection = getConnection().getConnection(); + + try (final InputStream is = DataSourceDBUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_delete.xml")) { + ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("ITEMS"); + + connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); + + final IDataSet databaseDataSet = getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("ITEMS"); + + Assertion.assertEquals(expectedTable, actualTable); + } + } + + @Test + public void givenDataSet_whenUpdate_thenItemHasNewName() throws Exception { + final Connection connection = getConnection().getConnection(); + + try (final InputStream is = DataSourceDBUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_rename.xml")) { + ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("ITEMS"); + + connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); + + final IDataSet databaseDataSet = getConnection().createDataSet(); + ITable actualTable = databaseDataSet.getTable("ITEMS"); + + Assertion.assertEquals(expectedTable, actualTable); + } + } + + @Test + public void givenDataSet_whenInsertUnexpectedData_thenFailOnAllUnexpectedValues() throws Exception { try (final InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/expected-multiple-failures.xml")) { final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); final ITable expectedTable = expectedDataSet.getTable("ITEMS"); final Connection conn = getDataSource().getConnection(); final DiffCollectingFailureHandler collectingHandler = new DiffCollectingFailureHandler(); - conn.createStatement().executeUpdate("INSERT INTO ITEMS (title, price) VALUES ('Battery', '1000000')"); + conn.createStatement().executeUpdate( + "INSERT INTO ITEMS (title, price) VALUES ('Battery', '1000000')"); final ITable actualData = getConnection().createDataSet().getTable("ITEMS"); Assertion.assertEquals(expectedTable, actualData, collectingHandler); if (!collectingHandler.getDiffList().isEmpty()) { - String message = (String) collectingHandler.getDiffList().stream().map(d -> formatDifference((Difference) d)).collect(joining("\n")); + String message = (String) collectingHandler + .getDiffList() + .stream() + .map(d -> formatDifference((Difference) d)).collect(joining("\n")); logger.error(() -> message); } } diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/DbUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/DbUnitTest.java deleted file mode 100644 index da4ac54f12..0000000000 --- a/libraries-testing/src/test/java/com/baeldung/dbunit/DbUnitTest.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.baeldung.dbunit; - -import org.dbunit.Assertion; -import org.dbunit.DBTestCase; -import org.dbunit.PropertiesBasedJdbcDatabaseTester; -import org.dbunit.dataset.IDataSet; -import org.dbunit.dataset.ITable; -import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; -import org.dbunit.operation.DatabaseOperation; -import org.junit.Test; - -import java.io.InputStream; -import java.sql.Connection; -import java.sql.ResultSet; - -import static com.baeldung.dbunit.ConnectionSettings.JDBC_DRIVER; -import static com.baeldung.dbunit.ConnectionSettings.JDBC_URL; -import static com.baeldung.dbunit.ConnectionSettings.PASSWORD; -import static com.baeldung.dbunit.ConnectionSettings.USER; -import static org.assertj.core.api.Assertions.assertThat; - -public class DbUnitTest extends DBTestCase { - - public DbUnitTest(String name) { - super(name); - System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_DRIVER_CLASS, JDBC_DRIVER); - System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_CONNECTION_URL, JDBC_URL); - System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_USERNAME, USER); - System.setProperty(PropertiesBasedJdbcDatabaseTester.DBUNIT_PASSWORD, PASSWORD); - } - - @Override - protected IDataSet getDataSet() throws Exception { - try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/data.xml")) { - return new FlatXmlDataSetBuilder().build(is); - } - } - - @Override - protected DatabaseOperation getSetUpOperation() { - return DatabaseOperation.REFRESH; - } - - @Override - protected DatabaseOperation getTearDownOperation() { - return DatabaseOperation.DELETE_ALL; - } - - @Test - public void testSelect() throws Exception { - final Connection connection = getConnection().getConnection(); - - final ResultSet rs = connection.createStatement().executeQuery("select * from ITEMS where id = 1"); - - assertThat(rs.next()).isTrue(); - assertThat(rs.getString("title")).isEqualTo("Grey T-Shirt"); - } - - @Test - public void testDelete() throws Exception { - final Connection connection = getConnection().getConnection(); - - try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_delete.xml")) { - ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("ITEMS"); - - connection.createStatement().executeUpdate("delete from ITEMS where id = 2"); - - final IDataSet databaseDataSet = getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("ITEMS"); - - Assertion.assertEquals(expectedTable, actualTable); - } - } - - @Test - public void testUpdate() throws Exception { - final Connection connection = getConnection().getConnection(); - - try (final InputStream is = DbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_rename.xml")) { - ITable expectedTable = (new FlatXmlDataSetBuilder().build(is)).getTable("ITEMS"); - - connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); - - final IDataSet databaseDataSet = getConnection().createDataSet(); - ITable actualTable = databaseDataSet.getTable("ITEMS"); - - Assertion.assertEquals(expectedTable, actualTable); - } - } - -} diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java index a7821102dc..6243af9676 100644 --- a/libraries-testing/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/OldSchoolDbUnitTest.java @@ -12,6 +12,8 @@ import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import java.io.InputStream; import java.sql.Connection; @@ -24,6 +26,7 @@ import static com.baeldung.dbunit.ConnectionSettings.USER; import static org.assertj.core.api.Assertions.assertThat; import static org.dbunit.Assertion.assertEquals; +@RunWith(JUnit4.class) public class OldSchoolDbUnitTest { private static IDatabaseTester tester = null; @@ -58,7 +61,7 @@ public class OldSchoolDbUnitTest { } @Test - public void testSelect() throws Exception { + public void givenDataSet_whenSelect_thenFirstTitleIsGreyTShirt() throws Exception { final Connection connection = tester.getConnection().getConnection(); final ResultSet rs = connection.createStatement().executeQuery("select * from ITEMS where id = 1"); @@ -68,24 +71,27 @@ public class OldSchoolDbUnitTest { } @Test - public void testIgnoringProduced() throws Exception { + public void givenDataSet_whenInsert_thenGetResultsAreStillEqualIfIgnoringColumnsWithDifferentProduced() throws Exception { final Connection connection = tester.getConnection().getConnection(); final String[] excludedColumns = { "id", "produced" }; try (final InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/expected-ignoring-registered_at.xml")) { final IDataSet expectedDataSet = new FlatXmlDataSetBuilder().build(is); - final ITable expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedDataSet.getTable("ITEMS"), excludedColumns); + final ITable expectedTable = DefaultColumnFilter.excludedColumnsTable( + expectedDataSet.getTable("ITEMS"), excludedColumns); - connection.createStatement().executeUpdate("INSERT INTO ITEMS (title, price, produced) VALUES('Necklace', 199.99, now())"); + connection.createStatement().executeUpdate( + "INSERT INTO ITEMS (title, price, produced) VALUES('Necklace', 199.99, now())"); final IDataSet databaseDataSet = tester.getConnection().createDataSet(); - final ITable actualTable = DefaultColumnFilter.excludedColumnsTable(databaseDataSet.getTable("ITEMS"), excludedColumns); + final ITable actualTable = DefaultColumnFilter.excludedColumnsTable( + databaseDataSet.getTable("ITEMS"), excludedColumns); Assertion.assertEquals(expectedTable, actualTable); } } @Test - public void testDelete() throws Exception { + public void givenDataSet_whenDelete_thenItemIsRemoved() throws Exception { final Connection connection = tester.getConnection().getConnection(); try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_delete.xml")) { @@ -101,7 +107,7 @@ public class OldSchoolDbUnitTest { } @Test - public void testDeleteWithExcludedColumns() throws Exception { + public void givenDataSet_whenDelete_thenItemIsRemovedAndResultsEqualIfProducedIsIgnored() throws Exception { final Connection connection = tester.getConnection().getConnection(); try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_delete_no_produced.xml")) { @@ -118,7 +124,7 @@ public class OldSchoolDbUnitTest { } @Test - public void testUpdate() throws Exception { + public void givenDataSet_whenUpdate_thenItemHasNewName() throws Exception { final Connection connection = tester.getConnection().getConnection(); try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_rename.xml")) { @@ -134,18 +140,18 @@ public class OldSchoolDbUnitTest { } @Test - public void testUpdateWithExcludedColumns() throws Exception { + public void givenDataSet_whenUpdateWithNoProduced_thenItemHasNewName() throws Exception { final Connection connection = tester.getConnection().getConnection(); try (final InputStream is = OldSchoolDbUnitTest.class.getClassLoader().getResourceAsStream("dbunit/items_exp_rename_no_produced.xml")) { ITable expectedTable = new FlatXmlDataSetBuilder().build(is).getTable("ITEMS"); + expectedTable = DefaultColumnFilter.excludedColumnsTable(expectedTable, new String[] { "produced" }); connection.createStatement().executeUpdate("update ITEMS set title='new name' where id = 1"); final IDataSet databaseDataSet = tester.getConnection().createDataSet(); ITable actualTable = databaseDataSet.getTable("ITEMS"); actualTable = DefaultColumnFilter.excludedColumnsTable(actualTable, new String[] { "produced" }); - assertEquals(expectedTable, actualTable); } } diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java deleted file mode 100644 index 039dfd1639..0000000000 --- a/libraries-testing/src/test/java/com/baeldung/dbunit/PrepAndExpectedDbUnitTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.baeldung.dbunit; - -import org.dbunit.DefaultPrepAndExpectedTestCase; -import org.dbunit.IDatabaseTester; -import org.dbunit.JdbcDatabaseTester; -import org.dbunit.PrepAndExpectedTestCaseSteps; -import org.dbunit.VerifyTableDefinition; -import org.dbunit.dataset.IDataSet; -import org.dbunit.dataset.xml.FlatXmlDataSetBuilder; -import org.dbunit.operation.DatabaseOperation; -import org.dbunit.util.fileloader.DataFileLoader; -import org.dbunit.util.fileloader.FlatXmlDataFileLoader; -import org.junit.Test; - -import java.io.InputStream; -import java.sql.Connection; -import java.sql.ResultSet; - -import static com.baeldung.dbunit.ConnectionSettings.JDBC_DRIVER; -import static com.baeldung.dbunit.ConnectionSettings.JDBC_URL; -import static com.baeldung.dbunit.ConnectionSettings.PASSWORD; -import static com.baeldung.dbunit.ConnectionSettings.USER; -import static org.assertj.core.api.Assertions.assertThat; - -public class PrepAndExpectedDbUnitTest extends DefaultPrepAndExpectedTestCase { - - @Override - public void setUp() throws Exception { - setDatabaseTester(initDatabaseTester()); - setDataFileLoader(initDataFileLoader()); - super.setUp(); - } - - private IDatabaseTester initDatabaseTester() throws Exception { - final JdbcDatabaseTester tester = new JdbcDatabaseTester(JDBC_DRIVER, JDBC_URL, USER, PASSWORD); - tester.setDataSet(initDataSet()); - tester.setSetUpOperation(DatabaseOperation.REFRESH); - return tester; - } - - private IDataSet initDataSet() throws Exception { - try (final InputStream is = getClass().getClassLoader().getResourceAsStream("dbunit/data.xml")) { - return new FlatXmlDataSetBuilder().build(is); - } - } - - private DataFileLoader initDataFileLoader() { - return new FlatXmlDataFileLoader(); - } - - @Test - public void testSelect() throws Exception { - final Connection connection = getConnection().getConnection(); - final VerifyTableDefinition[] verifyTables = { new VerifyTableDefinition("CLIENTS", new String[] {}) }; - final String[] prepDataFiles = { "/dbunit/users.xml" }; - final String[] expectedDataFiles = { "/dbunit/users.xml" }; - final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement().executeQuery("select * from CLIENTS where id = 1"); - - final ResultSet rs = (ResultSet) super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); - - assertThat(rs.next()).isTrue(); - assertThat(rs.getString("last_name")).isEqualTo("Xavier"); - } - - @Test - public void testUpdate() throws Exception { - final Connection connection = getConnection().getConnection(); - final VerifyTableDefinition[] verifyTables = { new VerifyTableDefinition("CLIENTS", new String[] {}) }; // define tables to verify - final String[] prepDataFiles = { "/dbunit/users.xml" }; - final String[] expectedDataFiles = { "/dbunit/users_exp_rename.xml" }; - final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement().executeUpdate("update CLIENTS set first_name = 'new name' where id = 1"); - - super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); - } - - @Test - public void testDelete() throws Exception { - final Connection connection = getConnection().getConnection(); - final VerifyTableDefinition[] verifyTables = { new VerifyTableDefinition("CLIENTS", new String[] {}) }; - final String[] prepDataFiles = { "/dbunit/users.xml" }; - final String[] expectedDataFiles = { "/dbunit/users_exp_delete.xml" }; - final PrepAndExpectedTestCaseSteps testSteps = () -> connection.createStatement().executeUpdate("delete from CLIENTS where id = 2"); - - super.runTest(verifyTables, prepDataFiles, expectedDataFiles, testSteps); - } - -} diff --git a/libraries-testing/src/test/java/com/baeldung/jsonassert/JsonAssertUnitTest.java b/libraries-testing/src/test/java/com/baeldung/jsonassert/JsonAssertUnitTest.java index ce9638c4af..822468e91f 100644 --- a/libraries-testing/src/test/java/com/baeldung/jsonassert/JsonAssertUnitTest.java +++ b/libraries-testing/src/test/java/com/baeldung/jsonassert/JsonAssertUnitTest.java @@ -78,10 +78,10 @@ public class JsonAssertUnitTest { @Test public void givenArray_whenComparing_thenOrderMustMatchForStrict() throws JSONException { - String result = "[Alex, Barbera, Charlie, Xavier]"; - JSONAssert.assertEquals("[Charlie, Alex, Xavier, Barbera]", result, JSONCompareMode.LENIENT); - JSONAssert.assertEquals("[Alex, Barbera, Charlie, Xavier]", result, JSONCompareMode.STRICT); - JSONAssert.assertNotEquals("[Charlie, Alex, Xavier, Barbera]", result, JSONCompareMode.STRICT); + String result = "[Alex, Barbera, Charlie, Wolf]"; + JSONAssert.assertEquals("[Charlie, Alex, Wolf, Barbera]", result, JSONCompareMode.LENIENT); + JSONAssert.assertEquals("[Alex, Barbera, Charlie, Wolf]", result, JSONCompareMode.STRICT); + JSONAssert.assertNotEquals("[Charlie, Alex, Wolf, Barbera]", result, JSONCompareMode.STRICT); } @Test @@ -94,7 +94,7 @@ public class JsonAssertUnitTest { @Test public void whenComparingSizeOfArray_thenPass() throws JSONException { - String names = "{names:[Alex, Barbera, Charlie, Xavier]}"; + String names = "{names:[Alex, Barbera, Charlie, Wolf]}"; JSONAssert.assertEquals("{names:[4]}", names, new ArraySizeComparator(JSONCompareMode.LENIENT)); } diff --git a/libraries-testing/src/test/resources/dbunit/data.xml b/libraries-testing/src/test/resources/dbunit/data.xml index 290cc36890..4865dec54c 100644 --- a/libraries-testing/src/test/resources/dbunit/data.xml +++ b/libraries-testing/src/test/resources/dbunit/data.xml @@ -1,6 +1,6 @@ - + diff --git a/libraries-testing/src/test/resources/dbunit/items_exp_rename_no_produced.xml b/libraries-testing/src/test/resources/dbunit/items_exp_rename_no_produced.xml index b42d3804fa..4f14b17113 100644 --- a/libraries-testing/src/test/resources/dbunit/items_exp_rename_no_produced.xml +++ b/libraries-testing/src/test/resources/dbunit/items_exp_rename_no_produced.xml @@ -1,6 +1,6 @@ - + diff --git a/libraries-testing/src/test/resources/dbunit/users.xml b/libraries-testing/src/test/resources/dbunit/users.xml index 9ac3909bc5..f04943c4cc 100644 --- a/libraries-testing/src/test/resources/dbunit/users.xml +++ b/libraries-testing/src/test/resources/dbunit/users.xml @@ -1,6 +1,6 @@ - + diff --git a/libraries-testing/src/test/resources/dbunit/users_exp_delete.xml b/libraries-testing/src/test/resources/dbunit/users_exp_delete.xml index 2fe97ae6f6..20a2f2f1a7 100644 --- a/libraries-testing/src/test/resources/dbunit/users_exp_delete.xml +++ b/libraries-testing/src/test/resources/dbunit/users_exp_delete.xml @@ -1,5 +1,5 @@ - + diff --git a/libraries-testing/src/test/resources/dbunit/users_exp_rename.xml b/libraries-testing/src/test/resources/dbunit/users_exp_rename.xml index 95682118bb..1ab6cf53b8 100644 --- a/libraries-testing/src/test/resources/dbunit/users_exp_rename.xml +++ b/libraries-testing/src/test/resources/dbunit/users_exp_rename.xml @@ -1,6 +1,6 @@ - + From 55d1d12216712635a005ab6d7629ebeb2fc97f40 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 4 Apr 2020 12:55:27 +0530 Subject: [PATCH 079/503] JAVA-624: Updated READMEs for prev links --- java-collections-maps-2/README.md | 2 +- java-collections-maps-3/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/java-collections-maps-2/README.md b/java-collections-maps-2/README.md index 71c6a3f32b..2188960543 100644 --- a/java-collections-maps-2/README.md +++ b/java-collections-maps-2/README.md @@ -13,4 +13,4 @@ This module contains articles about Map data structures in Java. - [Sort a HashMap in Java](https://www.baeldung.com/java-hashmap-sort) - [Finding the Highest Value in a Java Map](https://www.baeldung.com/java-find-map-max) - [Initialize a HashMap in Java](https://www.baeldung.com/java-initialize-hashmap) -- More articles: [[<-- prev>]](/java-collections-maps) [[next -->]](/java-collections-maps-3) +- More articles: [[<-- prev]](/java-collections-maps) [[next -->]](/java-collections-maps-3) diff --git a/java-collections-maps-3/README.md b/java-collections-maps-3/README.md index 8f185f6ad4..886461a35c 100644 --- a/java-collections-maps-3/README.md +++ b/java-collections-maps-3/README.md @@ -5,4 +5,4 @@ This module contains articles about Map data structures in Java. ### Relevant Articles: - [Java TreeMap vs HashMap](https://www.baeldung.com/java-treemap-vs-hashmap) - [Comparing Two HashMaps in Java](https://www.baeldung.com/java-compare-hashmaps) -- More articles: [[<-- prev>]](/java-collections-maps-2) +- More articles: [[<-- prev]](/java-collections-maps-2) From 902bb5308945cc37b148ee630832071209ce9361 Mon Sep 17 00:00:00 2001 From: Marius Catalin Munteanu Date: Wed, 11 Mar 2020 10:56:13 +0200 Subject: [PATCH 080/503] [BAEL-3011] Accesing Spring MVC Data from Thymeleaf - Code example for https://jira.baeldung.com/browse/BAEL-3012 --- .../thymeleaf/mvcdata/BeanConfig.java | 14 ++++ .../thymeleaf/mvcdata/EmailController.java | 63 ++++++++++++++++ .../mvcdata/repository/EmailData.java | 48 +++++++++++++ .../templates/mvcdata/email-bean-data.html | 14 ++++ .../mvcdata/email-model-attributes.html | 16 +++++ .../mvcdata/email-request-parameters.html | 20 ++++++ .../mvcdata/email-servlet-context.html | 14 ++++ .../mvcdata/email-session-attributes.html | 14 ++++ .../mvcdata/EmailControllerUnitTest.java | 72 +++++++++++++++++++ 9 files changed, 275 insertions(+) create mode 100644 spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/BeanConfig.java create mode 100644 spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/EmailController.java create mode 100644 spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/repository/EmailData.java create mode 100644 spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-bean-data.html create mode 100644 spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-model-attributes.html create mode 100644 spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-request-parameters.html create mode 100644 spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-servlet-context.html create mode 100644 spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-session-attributes.html create mode 100644 spring-thymeleaf-2/src/test/java/com/baeldung/thymeleaf/mvcdata/EmailControllerUnitTest.java diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/BeanConfig.java b/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/BeanConfig.java new file mode 100644 index 0000000000..19f0101cf2 --- /dev/null +++ b/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/BeanConfig.java @@ -0,0 +1,14 @@ +package com.baeldung.thymeleaf.mvcdata; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import com.baeldung.thymeleaf.mvcdata.repository.EmailData; + +@Configuration +public class BeanConfig { + @Bean + public EmailData emailData() { + return new EmailData(); + } +} diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/EmailController.java b/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/EmailController.java new file mode 100644 index 0000000000..1bfe3f3428 --- /dev/null +++ b/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/EmailController.java @@ -0,0 +1,63 @@ +package com.baeldung.thymeleaf.mvcdata; + +import javax.servlet.ServletContext; +import javax.servlet.http.HttpSession; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestParam; + +import com.baeldung.thymeleaf.mvcdata.repository.EmailData; + +@Controller +public class EmailController { + private EmailData emailData = new EmailData(); + private ServletContext servletContext; + + public EmailController(ServletContext servletContext) { + this.servletContext = servletContext; + } + + @GetMapping(value = "/email/modelattributes") + public String emailModel(Model model) { + model.addAttribute("emaildata", emailData); + return "mvcdata/email-model-attributes"; + } + + @ModelAttribute("emailModelAttribute") + EmailData emailModelAttribute() { + return emailData; + } + + @GetMapping(value = "/email/requestparameters") + public String emailRequestParameters( + @RequestParam(value = "emailsubject") String emailSubject, + @RequestParam(value = "emailcontent") String emailContent, + @RequestParam(value = "emailaddress") String emailAddress1, + @RequestParam(value = "emailaddress") String emailAddress2, + @RequestParam(value = "emaillocale") String emailLocale) { + return "mvcdata/email-request-parameters"; + } + + @GetMapping("/email/sessionattributes") + public String emailSessionAttributes(HttpSession httpSession) { + httpSession.setAttribute("emaildata", emailData); + return "mvcdata/email-session-attributes"; + } + + @GetMapping("/email/servletcontext") + public String emailServletContext() { + servletContext.setAttribute("emailsubject", emailData.getEmailSubject()); + servletContext.setAttribute("emailcontent", emailData.getEmailBody()); + servletContext.setAttribute("emailaddress", emailData.getEmailAddress1()); + servletContext.setAttribute("emaillocale", emailData.getEmailLocale()); + return "mvcdata/email-servlet-context"; + } + + @GetMapping("/email/beandata") + public String emailBeanData() { + return "mvcdata/email-bean-data"; + } +} diff --git a/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/repository/EmailData.java b/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/repository/EmailData.java new file mode 100644 index 0000000000..9dc25bdaa7 --- /dev/null +++ b/spring-thymeleaf-2/src/main/java/com/baeldung/thymeleaf/mvcdata/repository/EmailData.java @@ -0,0 +1,48 @@ +package com.baeldung.thymeleaf.mvcdata.repository; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +public class EmailData implements Serializable { + private String emailSubject; + private String emailBody; + private String emailLocale; + private String emailAddress1; + private String emailAddress2; + + public EmailData() { + this.emailSubject = "You have received a new message"; + this.emailBody = "Good morning !"; + this.emailLocale = "en-US"; + this.emailAddress1 = "jhon.doe@example.com"; + this.emailAddress2 = "mark.jakob@example.com"; + } + + public String getEmailSubject() { + return this.emailSubject; + } + + public String getEmailBody() { + return this.emailBody; + } + + public String getEmailLocale() { + return this.emailLocale; + } + + public String getEmailAddress1() { + return this.emailAddress1; + } + + public String getEmailAddress2() { + return this.emailAddress2; + } + + public List getEmailAddresses() { + List emailAddresses = new ArrayList<>(); + emailAddresses.add(getEmailAddress1()); + emailAddresses.add(getEmailAddress2()); + return emailAddresses; + } +} diff --git a/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-bean-data.html b/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-bean-data.html new file mode 100644 index 0000000000..59073b51c6 --- /dev/null +++ b/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-bean-data.html @@ -0,0 +1,14 @@ + + + +

Subject

+

Subject

+

Content

+

Body

+

Email address

+

Email address

+

Language

+

Language

+ + \ No newline at end of file diff --git a/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-model-attributes.html b/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-model-attributes.html new file mode 100644 index 0000000000..caf136383a --- /dev/null +++ b/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-model-attributes.html @@ -0,0 +1,16 @@ + + + +

Subject

+

Subject

+

Content

+

+

Email addresses

+

+ +

+

Language

+

+ + \ No newline at end of file diff --git a/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-request-parameters.html b/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-request-parameters.html new file mode 100644 index 0000000000..8bcd3e1c62 --- /dev/null +++ b/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-request-parameters.html @@ -0,0 +1,20 @@ + + + +

Subject

+

Subject

+

Content

+

+

Email addresses

+

+ +

+

Email address 1

+

+

Email address 2

+

+

Language

+

+ + \ No newline at end of file diff --git a/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-servlet-context.html b/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-servlet-context.html new file mode 100644 index 0000000000..b07573047e --- /dev/null +++ b/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-servlet-context.html @@ -0,0 +1,14 @@ + + + +

Subject

+

+

Content

+

+

Email address

+

+

Language

+

+ + \ No newline at end of file diff --git a/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-session-attributes.html b/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-session-attributes.html new file mode 100644 index 0000000000..9227171fc6 --- /dev/null +++ b/spring-thymeleaf-2/src/main/resources/templates/mvcdata/email-session-attributes.html @@ -0,0 +1,14 @@ + + + +

Subject

+

+

Content

+

+

Email address

+

+

Language

+

+ + \ No newline at end of file diff --git a/spring-thymeleaf-2/src/test/java/com/baeldung/thymeleaf/mvcdata/EmailControllerUnitTest.java b/spring-thymeleaf-2/src/test/java/com/baeldung/thymeleaf/mvcdata/EmailControllerUnitTest.java new file mode 100644 index 0000000000..5e1190e174 --- /dev/null +++ b/spring-thymeleaf-2/src/test/java/com/baeldung/thymeleaf/mvcdata/EmailControllerUnitTest.java @@ -0,0 +1,72 @@ +package com.baeldung.thymeleaf.mvcdata; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; + +import com.baeldung.thymeleaf.mvcdata.repository.EmailData; + +@RunWith(SpringRunner.class) +@SpringBootTest +@AutoConfigureMockMvc(printOnlyOnFailure = false) +public class EmailControllerUnitTest { + + EmailData emailData = new EmailData(); + + @Autowired + private MockMvc mockMvc; + + @Test + public void whenCallModelAttributes_thenReturnEmailData() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/email/modelattributes")) + .andExpect(status().isOk()) + .andExpect(content().string(containsString("You have received a new message"))); + } + + @Test + public void whenCallRequestParameters_thenReturnEmailData() throws Exception { + MultiValueMap params = new LinkedMultiValueMap<>(); + params.add("emailsubject", emailData.getEmailSubject()); + params.add("emailcontent", emailData.getEmailBody()); + params.add("emailaddress", emailData.getEmailAddress1()); + params.add("emailaddress", emailData.getEmailAddress2()); + params.add("emaillocale", emailData.getEmailLocale()); + mockMvc.perform(MockMvcRequestBuilders.get("/email/requestparameters") + .params(params)) + .andExpect(status().isOk()) + .andExpect(content().string(containsString("en-US"))); + } + + @Test + public void whenCallSessionAttributes_thenReturnEmailData() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/email/sessionattributes")) + .andExpect(status().isOk()) + .andExpect(content().string(containsString("Good morning !"))); + } + + @Test + public void whenCallServletContext_thenReturnEmailData() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/email/servletcontext")) + .andExpect(status().isOk()) + .andExpect(content().string(containsString("jhon.doe@example.com"))); + } + + @Test + public void whenCallBeanData_thenReturnEmailData() throws Exception { + mockMvc.perform(MockMvcRequestBuilders.get("/email/beandata")) + .andExpect(status().isOk()) + .andExpect(content().string(containsString("jhon.doe@example.com"))); + } + +} From 487d6b38fc3ac13af3dd026745c83e56b0716f13 Mon Sep 17 00:00:00 2001 From: mikr Date: Sat, 4 Apr 2020 20:24:48 +0200 Subject: [PATCH 081/503] JAVA-117 Standardize spring-boot-modules/spring-boot --- .../java/{org => com}/baeldung/boot/Application.java | 2 +- .../baeldung/boot/config/H2JpaConfig.java | 6 +++--- .../{org => com}/baeldung/boot/config/WebConfig.java | 8 ++++---- .../boot/controller/servlet/HelloWorldServlet.java | 2 +- .../controller/servlet/SpringHelloWorldServlet.java | 2 +- .../boot/converter/GenericBigDecimalConverter.java | 2 +- .../boot/converter/StringToEmployeeConverter.java | 2 +- .../boot/converter/StringToEnumConverterFactory.java | 2 +- .../StringToEmployeeConverterController.java | 2 +- .../{org => com}/baeldung/boot/domain/Modes.java | 2 +- .../common/error/MyCustomErrorController.java | 2 +- .../error/SpringHelloServletRegistrationBean.java | 2 +- .../common/error/controller/ErrorController.java | 2 +- .../MyServletContainerCustomizationBean.java | 2 +- .../resources/ExecutorServiceExitCodeGenerator.java | 2 +- .../{org => com}/baeldung/demo/DemoApplication.java | 2 +- .../baeldung/demo/boottest/Employee.java | 2 +- .../baeldung/demo/boottest/EmployeeRepository.java | 2 +- .../demo/boottest/EmployeeRestController.java | 2 +- .../baeldung/demo/boottest/EmployeeService.java | 2 +- .../baeldung/demo/boottest/EmployeeServiceImpl.java | 2 +- .../baeldung/demo/components/FooService.java | 6 +++--- .../baeldung/demo/exceptions/CommonException.java | 2 +- .../demo/exceptions/FooNotFoundException.java | 2 +- .../java/{org => com}/baeldung/demo/model/Foo.java | 2 +- .../baeldung/demo/repository/FooRepository.java | 4 ++-- .../baeldung/demo/service/FooController.java | 6 +++--- .../endpoints/info/TotalUsersInfoContributor.java | 4 ++-- .../baeldung/main/SpringBootApplication.java | 12 ++++++------ .../main/java/{org => com}/baeldung/model/User.java | 2 +- .../baeldung/repository/UserRepository.java | 4 ++-- .../baeldung/session/exception/Application.java | 4 ++-- .../session/exception/repository/FooRepository.java | 4 ++-- .../exception/repository/FooRepositoryImpl.java | 4 ++-- .../baeldung/startup/AppStartupRunner.java | 2 +- .../startup/CommandLineAppStartupRunner.java | 2 +- .../baeldung/boot/ApplicationIntegrationTest.java | 4 ++-- .../boot/DemoApplicationIntegrationTest.java | 4 ++-- .../repository/FooRepositoryIntegrationTest.java | 8 ++++---- .../repository/HibernateSessionIntegrationTest.java | 8 ++++---- .../NoHibernateSessionIntegrationTest.java | 8 ++++---- .../converter/CustomConverterIntegrationTest.java | 6 +++--- ...ToEmployeeConverterControllerIntegrationTest.java | 4 ++-- .../boottest/EmployeeControllerIntegrationTest.java | 5 +---- .../boottest/EmployeeRepositoryIntegrationTest.java | 6 +++--- .../EmployeeRestControllerIntegrationTest.java | 4 ++-- .../boottest/EmployeeServiceImplIntegrationTest.java | 6 +++++- .../baeldung/demo/boottest/JsonUtil.java | 2 +- .../repository/UserRepositoryIntegrationTest.java | 7 ++++--- 49 files changed, 93 insertions(+), 91 deletions(-) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/Application.java (93%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/config/H2JpaConfig.java (89%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/config/WebConfig.java (71%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/controller/servlet/HelloWorldServlet.java (96%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java (96%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/converter/GenericBigDecimalConverter.java (96%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/converter/StringToEmployeeConverter.java (90%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/converter/StringToEnumConverterFactory.java (95%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/converter/controller/StringToEmployeeConverterController.java (91%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/boot/domain/Modes.java (54%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/common/error/MyCustomErrorController.java (93%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/common/error/SpringHelloServletRegistrationBean.java (91%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/common/error/controller/ErrorController.java (90%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/common/properties/MyServletContainerCustomizationBean.java (95%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java (94%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/DemoApplication.java (94%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/boottest/Employee.java (95%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/boottest/EmployeeRepository.java (91%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/boottest/EmployeeRestController.java (96%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/boottest/EmployeeService.java (89%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/boottest/EmployeeServiceImpl.java (96%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/components/FooService.java (77%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/exceptions/CommonException.java (85%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/exceptions/FooNotFoundException.java (86%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/model/Foo.java (95%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/repository/FooRepository.java (70%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/demo/service/FooController.java (85%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/endpoints/info/TotalUsersInfoContributor.java (89%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/main/SpringBootApplication.java (78%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/model/User.java (96%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/repository/UserRepository.java (98%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/session/exception/Application.java (87%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/session/exception/repository/FooRepository.java (50%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/session/exception/repository/FooRepositoryImpl.java (88%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/startup/AppStartupRunner.java (95%) rename spring-boot-modules/spring-boot/src/main/java/{org => com}/baeldung/startup/CommandLineAppStartupRunner.java (94%) rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/boot/ApplicationIntegrationTest.java (85%) rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/boot/DemoApplicationIntegrationTest.java (87%) rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/boot/repository/FooRepositoryIntegrationTest.java (82%) rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/boot/repository/HibernateSessionIntegrationTest.java (81%) rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java (78%) rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/converter/CustomConverterIntegrationTest.java (94%) rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java (94%) rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java (93%) rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java (94%) rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java (97%) rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java (94%) rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/demo/boottest/JsonUtil.java (91%) rename spring-boot-modules/spring-boot/src/test/java/{org => com}/baeldung/repository/UserRepositoryIntegrationTest.java (92%) diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/Application.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/Application.java similarity index 93% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/Application.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/Application.java index c1b6558b26..cb0d0c1532 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/Application.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/Application.java @@ -1,4 +1,4 @@ -package org.baeldung.boot; +package com.baeldung.boot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/config/H2JpaConfig.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/config/H2JpaConfig.java similarity index 89% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/config/H2JpaConfig.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/config/H2JpaConfig.java index 92a6ed7ab0..928928c9a5 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/config/H2JpaConfig.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/config/H2JpaConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.boot.config; +package com.baeldung.boot.config; import java.util.Properties; @@ -18,7 +18,7 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.annotation.EnableTransactionManagement; @Configuration -@EnableJpaRepositories(basePackages = { "org.baeldung.boot.repository", "org.baeldung.boot.boottest", "org.baeldung.repository" }) +@EnableJpaRepositories(basePackages = { "com.baeldung.boot.repository", "com.baeldung.boot.boottest", "com.baeldung.repository" }) @PropertySource("classpath:persistence-generic-entity.properties") @EnableTransactionManagement public class H2JpaConfig { @@ -41,7 +41,7 @@ public class H2JpaConfig { public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); - em.setPackagesToScan(new String[] { "org.baeldung.boot.domain", "org.baeldung.boot.model", "org.baeldung.boot.boottest", "org.baeldung.model" }); + em.setPackagesToScan(new String[] { "com.baeldung.boot.domain", "com.baeldung.boot.model", "com.baeldung.boot.boottest", "com.baeldung.model" }); em.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); em.setJpaProperties(additionalProperties()); return em; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/config/WebConfig.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/config/WebConfig.java similarity index 71% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/config/WebConfig.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/config/WebConfig.java index 9554facb12..b23c910a04 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/config/WebConfig.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/config/WebConfig.java @@ -1,8 +1,8 @@ -package org.baeldung.boot.config; +package com.baeldung.boot.config; -import org.baeldung.boot.converter.StringToEmployeeConverter; -import org.baeldung.boot.converter.StringToEnumConverterFactory; -import org.baeldung.boot.converter.GenericBigDecimalConverter; +import com.baeldung.boot.converter.StringToEmployeeConverter; +import com.baeldung.boot.converter.StringToEnumConverterFactory; +import com.baeldung.boot.converter.GenericBigDecimalConverter; import org.springframework.context.annotation.Configuration; import org.springframework.format.FormatterRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/HelloWorldServlet.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/controller/servlet/HelloWorldServlet.java similarity index 96% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/HelloWorldServlet.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/controller/servlet/HelloWorldServlet.java index 34ad11254c..80c75aa8b5 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/HelloWorldServlet.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/controller/servlet/HelloWorldServlet.java @@ -1,4 +1,4 @@ -package org.baeldung.boot.controller.servlet; +package com.baeldung.boot.controller.servlet; import java.io.IOException; import java.io.PrintWriter; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java similarity index 96% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java index 91547683c6..f276f94b7c 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/controller/servlet/SpringHelloWorldServlet.java @@ -1,4 +1,4 @@ -package org.baeldung.boot.controller.servlet; +package com.baeldung.boot.controller.servlet; import java.io.IOException; import java.io.PrintWriter; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/GenericBigDecimalConverter.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/GenericBigDecimalConverter.java similarity index 96% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/GenericBigDecimalConverter.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/GenericBigDecimalConverter.java index 8add28fc2d..fc73cfee5f 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/GenericBigDecimalConverter.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/GenericBigDecimalConverter.java @@ -1,4 +1,4 @@ -package org.baeldung.boot.converter; +package com.baeldung.boot.converter; import com.google.common.collect.ImmutableSet; import org.springframework.core.convert.TypeDescriptor; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEmployeeConverter.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/StringToEmployeeConverter.java similarity index 90% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEmployeeConverter.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/StringToEmployeeConverter.java index 1bf75b38f0..ac635532ea 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEmployeeConverter.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/StringToEmployeeConverter.java @@ -1,4 +1,4 @@ -package org.baeldung.boot.converter; +package com.baeldung.boot.converter; import org.springframework.core.convert.converter.Converter; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEnumConverterFactory.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/StringToEnumConverterFactory.java similarity index 95% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEnumConverterFactory.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/StringToEnumConverterFactory.java index ddb2cd2b08..a2dce11a6a 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/StringToEnumConverterFactory.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/StringToEnumConverterFactory.java @@ -1,4 +1,4 @@ -package org.baeldung.boot.converter; +package com.baeldung.boot.converter; import org.springframework.core.convert.converter.Converter; import org.springframework.core.convert.converter.ConverterFactory; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/controller/StringToEmployeeConverterController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/controller/StringToEmployeeConverterController.java similarity index 91% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/controller/StringToEmployeeConverterController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/controller/StringToEmployeeConverterController.java index 27bad4c387..260b1c734b 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/converter/controller/StringToEmployeeConverterController.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/converter/controller/StringToEmployeeConverterController.java @@ -1,4 +1,4 @@ -package org.baeldung.boot.converter.controller; +package com.baeldung.boot.converter.controller; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/domain/Modes.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/domain/Modes.java similarity index 54% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/domain/Modes.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/domain/Modes.java index dcba064e8c..7717294996 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/boot/domain/Modes.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/boot/domain/Modes.java @@ -1,4 +1,4 @@ -package org.baeldung.boot.domain; +package com.baeldung.boot.domain; public enum Modes { diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/MyCustomErrorController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/MyCustomErrorController.java similarity index 93% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/MyCustomErrorController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/MyCustomErrorController.java index df0e3ec0b2..373ae8f745 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/MyCustomErrorController.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/MyCustomErrorController.java @@ -1,4 +1,4 @@ -package org.baeldung.common.error; +package com.baeldung.common.error; import org.springframework.boot.web.servlet.error.ErrorController; import org.springframework.web.bind.annotation.GetMapping; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/SpringHelloServletRegistrationBean.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/SpringHelloServletRegistrationBean.java similarity index 91% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/SpringHelloServletRegistrationBean.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/SpringHelloServletRegistrationBean.java index 774cf1b970..3f51a4ab69 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/SpringHelloServletRegistrationBean.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/SpringHelloServletRegistrationBean.java @@ -1,4 +1,4 @@ -package org.baeldung.common.error; +package com.baeldung.common.error; import org.springframework.boot.web.servlet.ServletRegistrationBean; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/controller/ErrorController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/controller/ErrorController.java similarity index 90% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/controller/ErrorController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/controller/ErrorController.java index ac5f92e9c9..1e5fbf3ac4 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/error/controller/ErrorController.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/error/controller/ErrorController.java @@ -1,4 +1,4 @@ -package org.baeldung.common.error.controller; +package com.baeldung.common.error.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/properties/MyServletContainerCustomizationBean.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/properties/MyServletContainerCustomizationBean.java similarity index 95% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/properties/MyServletContainerCustomizationBean.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/properties/MyServletContainerCustomizationBean.java index d553d44769..be503b1b6c 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/properties/MyServletContainerCustomizationBean.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/properties/MyServletContainerCustomizationBean.java @@ -1,4 +1,4 @@ -package org.baeldung.common.properties; +package com.baeldung.common.properties; import org.springframework.boot.web.server.ErrorPage; import org.springframework.boot.web.server.WebServerFactoryCustomizer; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java similarity index 94% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java index 64853a9941..1db7054f85 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/common/resources/ExecutorServiceExitCodeGenerator.java @@ -1,4 +1,4 @@ -package org.baeldung.common.resources; +package com.baeldung.common.resources; import org.springframework.boot.ExitCodeGenerator; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/DemoApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/DemoApplication.java similarity index 94% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/DemoApplication.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/DemoApplication.java index 4a88fcea07..eb091b4695 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/DemoApplication.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/DemoApplication.java @@ -1,4 +1,4 @@ -package org.baeldung.demo; +package com.baeldung.demo; import com.baeldung.graphql.GraphqlConfiguration; import org.springframework.boot.SpringApplication; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/Employee.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/Employee.java similarity index 95% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/Employee.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/Employee.java index 645ce2838a..fa3c1dc809 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/Employee.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/Employee.java @@ -1,4 +1,4 @@ -package org.baeldung.demo.boottest; +package com.baeldung.demo.boottest; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRepository.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeRepository.java similarity index 91% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRepository.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeRepository.java index 00fdbfaae4..b6850d587e 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRepository.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeRepository.java @@ -1,4 +1,4 @@ -package org.baeldung.demo.boottest; +package com.baeldung.demo.boottest; import java.util.List; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRestController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeRestController.java similarity index 96% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRestController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeRestController.java index 516bff0e8c..7d2e06d4a0 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeRestController.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeRestController.java @@ -1,4 +1,4 @@ -package org.baeldung.demo.boottest; +package com.baeldung.demo.boottest; import java.util.List; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeService.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeService.java similarity index 89% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeService.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeService.java index 07765a511c..ff1976cad1 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeService.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeService.java @@ -1,4 +1,4 @@ -package org.baeldung.demo.boottest; +package com.baeldung.demo.boottest; import java.util.List; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeServiceImpl.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeServiceImpl.java similarity index 96% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeServiceImpl.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeServiceImpl.java index a1639b29cc..156fc571f3 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/boottest/EmployeeServiceImpl.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/boottest/EmployeeServiceImpl.java @@ -1,4 +1,4 @@ -package org.baeldung.demo.boottest; +package com.baeldung.demo.boottest; import java.util.List; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/components/FooService.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/components/FooService.java similarity index 77% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/components/FooService.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/components/FooService.java index 66943f6461..98a0db67ef 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/components/FooService.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/components/FooService.java @@ -1,7 +1,7 @@ -package org.baeldung.demo.components; +package com.baeldung.demo.components; -import org.baeldung.demo.model.Foo; -import org.baeldung.demo.repository.FooRepository; +import com.baeldung.demo.model.Foo; +import com.baeldung.demo.repository.FooRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/exceptions/CommonException.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/exceptions/CommonException.java similarity index 85% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/exceptions/CommonException.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/exceptions/CommonException.java index 51dd7bbd44..276802d0b9 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/exceptions/CommonException.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/exceptions/CommonException.java @@ -1,4 +1,4 @@ -package org.baeldung.demo.exceptions; +package com.baeldung.demo.exceptions; public class CommonException extends RuntimeException { diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/exceptions/FooNotFoundException.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/exceptions/FooNotFoundException.java similarity index 86% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/exceptions/FooNotFoundException.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/exceptions/FooNotFoundException.java index 59796c58f0..8c425d078e 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/exceptions/FooNotFoundException.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/exceptions/FooNotFoundException.java @@ -1,4 +1,4 @@ -package org.baeldung.demo.exceptions; +package com.baeldung.demo.exceptions; public class FooNotFoundException extends RuntimeException { diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/model/Foo.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/model/Foo.java similarity index 95% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/model/Foo.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/model/Foo.java index e5638cfd3d..796bcca11b 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/model/Foo.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/model/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.demo.model; +package com.baeldung.demo.model; import java.io.Serializable; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/repository/FooRepository.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/repository/FooRepository.java similarity index 70% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/repository/FooRepository.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/repository/FooRepository.java index c04e0c7438..ed27ac23bc 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/repository/FooRepository.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/repository/FooRepository.java @@ -1,6 +1,6 @@ -package org.baeldung.demo.repository; +package com.baeldung.demo.repository; -import org.baeldung.demo.model.Foo; +import com.baeldung.demo.model.Foo; import org.springframework.data.jpa.repository.JpaRepository; public interface FooRepository extends JpaRepository { diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/service/FooController.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/service/FooController.java similarity index 85% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/service/FooController.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/service/FooController.java index c28dcde1a7..c72c52fa3e 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/demo/service/FooController.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/demo/service/FooController.java @@ -1,7 +1,7 @@ -package org.baeldung.demo.service; +package com.baeldung.demo.service; -import org.baeldung.demo.components.FooService; -import org.baeldung.demo.model.Foo; +import com.baeldung.demo.model.Foo; +import com.baeldung.demo.components.FooService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/endpoints/info/TotalUsersInfoContributor.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/endpoints/info/TotalUsersInfoContributor.java similarity index 89% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/endpoints/info/TotalUsersInfoContributor.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/endpoints/info/TotalUsersInfoContributor.java index 34b50a2c0a..c316cabda5 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/endpoints/info/TotalUsersInfoContributor.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/endpoints/info/TotalUsersInfoContributor.java @@ -1,9 +1,9 @@ -package org.baeldung.endpoints.info; +package com.baeldung.endpoints.info; import java.util.HashMap; import java.util.Map; -import org.baeldung.repository.UserRepository; +import com.baeldung.repository.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.info.Info; import org.springframework.boot.actuate.info.InfoContributor; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/main/SpringBootApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/main/SpringBootApplication.java similarity index 78% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/main/SpringBootApplication.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/main/SpringBootApplication.java index a203659d63..c8cfb50f1c 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/main/SpringBootApplication.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/main/SpringBootApplication.java @@ -1,9 +1,9 @@ -package org.baeldung.main; +package com.baeldung.main; -import org.baeldung.boot.controller.servlet.HelloWorldServlet; -import org.baeldung.boot.controller.servlet.SpringHelloWorldServlet; -import org.baeldung.common.error.SpringHelloServletRegistrationBean; -import org.baeldung.common.resources.ExecutorServiceExitCodeGenerator; +import com.baeldung.boot.controller.servlet.HelloWorldServlet; +import com.baeldung.boot.controller.servlet.SpringHelloWorldServlet; +import com.baeldung.common.error.SpringHelloServletRegistrationBean; +import com.baeldung.common.resources.ExecutorServiceExitCodeGenerator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -18,7 +18,7 @@ import java.util.concurrent.Executors; @RestController @EnableAutoConfiguration -@ComponentScan({ "org.baeldung.common.error", "org.baeldung.common.error.controller", "org.baeldung.common.properties", "org.baeldung.common.resources", "org.baeldung.endpoints", "org.baeldung.service", "org.baeldung.monitor.jmx", "org.baeldung.boot.config" }) +@ComponentScan({ "org.baeldung.common.error", "com.baeldung.common.error.controller", "com.baeldung.common.properties", "com.baeldung.common.resources", "com.baeldung.endpoints", "com.baeldung.service", "com.baeldung.monitor.jmx", "com.baeldung.boot.config" }) public class SpringBootApplication { private static ApplicationContext applicationContext; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/model/User.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/model/User.java similarity index 96% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/model/User.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/model/User.java index eb886338a0..cc5f27f38c 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/model/User.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/model/User.java @@ -1,4 +1,4 @@ -package org.baeldung.model; +package com.baeldung.model; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/repository/UserRepository.java similarity index 98% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/repository/UserRepository.java index 752664cd5d..4dd863fb17 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/repository/UserRepository.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/repository/UserRepository.java @@ -1,6 +1,6 @@ -package org.baeldung.repository; +package com.baeldung.repository; -import org.baeldung.model.User; +import com.baeldung.model.User; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/Application.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/Application.java similarity index 87% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/Application.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/Application.java index 354c64c258..de4ca5998e 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/Application.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/Application.java @@ -1,6 +1,6 @@ -package org.baeldung.session.exception; +package com.baeldung.session.exception; -import org.baeldung.demo.model.Foo; +import com.baeldung.demo.model.Foo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepository.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/repository/FooRepository.java similarity index 50% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepository.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/repository/FooRepository.java index ce7bbfe57b..5e748973ed 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepository.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/repository/FooRepository.java @@ -1,6 +1,6 @@ -package org.baeldung.session.exception.repository; +package com.baeldung.session.exception.repository; -import org.baeldung.demo.model.Foo; +import com.baeldung.demo.model.Foo; public interface FooRepository { diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepositoryImpl.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/repository/FooRepositoryImpl.java similarity index 88% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepositoryImpl.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/repository/FooRepositoryImpl.java index 607bae83ba..a304373d6c 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/session/exception/repository/FooRepositoryImpl.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/session/exception/repository/FooRepositoryImpl.java @@ -1,8 +1,8 @@ -package org.baeldung.session.exception.repository; +package com.baeldung.session.exception.repository; import javax.persistence.EntityManagerFactory; -import org.baeldung.demo.model.Foo; +import com.baeldung.demo.model.Foo; import org.hibernate.SessionFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/startup/AppStartupRunner.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/startup/AppStartupRunner.java similarity index 95% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/startup/AppStartupRunner.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/startup/AppStartupRunner.java index d491bdb42c..0495473704 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/startup/AppStartupRunner.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/startup/AppStartupRunner.java @@ -1,4 +1,4 @@ -package org.baeldung.startup; +package com.baeldung.startup; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/startup/CommandLineAppStartupRunner.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/startup/CommandLineAppStartupRunner.java similarity index 94% rename from spring-boot-modules/spring-boot/src/main/java/org/baeldung/startup/CommandLineAppStartupRunner.java rename to spring-boot-modules/spring-boot/src/main/java/com/baeldung/startup/CommandLineAppStartupRunner.java index 6a7be59c21..48c5225cf1 100644 --- a/spring-boot-modules/spring-boot/src/main/java/org/baeldung/startup/CommandLineAppStartupRunner.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/startup/CommandLineAppStartupRunner.java @@ -1,4 +1,4 @@ -package org.baeldung.startup; +package com.baeldung.startup; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/ApplicationIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/ApplicationIntegrationTest.java similarity index 85% rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/ApplicationIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/ApplicationIntegrationTest.java index 5e351157c8..462291e0ac 100644 --- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/ApplicationIntegrationTest.java +++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/ApplicationIntegrationTest.java @@ -1,6 +1,6 @@ -package org.baeldung.boot; +package com.baeldung.boot; -import org.baeldung.session.exception.Application; +import com.baeldung.session.exception.Application; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/DemoApplicationIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/DemoApplicationIntegrationTest.java similarity index 87% rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/DemoApplicationIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/DemoApplicationIntegrationTest.java index 0541da3199..aaf4f1f780 100644 --- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/DemoApplicationIntegrationTest.java +++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/DemoApplicationIntegrationTest.java @@ -1,6 +1,6 @@ -package org.baeldung.boot; +package com.baeldung.boot; -import org.baeldung.demo.DemoApplication; +import com.baeldung.demo.DemoApplication; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/FooRepositoryIntegrationTest.java similarity index 82% rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/FooRepositoryIntegrationTest.java index c32e36d7e3..1772739d20 100644 --- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/FooRepositoryIntegrationTest.java +++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/FooRepositoryIntegrationTest.java @@ -1,8 +1,8 @@ -package org.baeldung.boot.repository; +package com.baeldung.boot.repository; -import org.baeldung.boot.DemoApplicationIntegrationTest; -import org.baeldung.demo.model.Foo; -import org.baeldung.demo.repository.FooRepository; +import com.baeldung.boot.DemoApplicationIntegrationTest; +import com.baeldung.demo.model.Foo; +import com.baeldung.demo.repository.FooRepository; import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/HibernateSessionIntegrationTest.java similarity index 81% rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/HibernateSessionIntegrationTest.java index b22282e896..2fe072bb67 100644 --- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/HibernateSessionIntegrationTest.java +++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/HibernateSessionIntegrationTest.java @@ -1,8 +1,8 @@ -package org.baeldung.boot.repository; +package com.baeldung.boot.repository; -import org.baeldung.boot.DemoApplicationIntegrationTest; -import org.baeldung.demo.model.Foo; -import org.baeldung.demo.repository.FooRepository; +import com.baeldung.boot.DemoApplicationIntegrationTest; +import com.baeldung.demo.model.Foo; +import com.baeldung.demo.repository.FooRepository; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java similarity index 78% rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java index 5c8d10223b..2e3326e6b1 100644 --- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java +++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/boot/repository/NoHibernateSessionIntegrationTest.java @@ -1,8 +1,8 @@ -package org.baeldung.boot.repository; +package com.baeldung.boot.repository; -import org.baeldung.boot.ApplicationIntegrationTest; -import org.baeldung.demo.model.Foo; -import org.baeldung.session.exception.repository.FooRepository; +import com.baeldung.boot.ApplicationIntegrationTest; +import com.baeldung.demo.model.Foo; +import com.baeldung.session.exception.repository.FooRepository; import org.hibernate.HibernateException; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/converter/CustomConverterIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/converter/CustomConverterIntegrationTest.java similarity index 94% rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/converter/CustomConverterIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/converter/CustomConverterIntegrationTest.java index bd1ae2c8fa..4619964783 100644 --- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/converter/CustomConverterIntegrationTest.java +++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/converter/CustomConverterIntegrationTest.java @@ -1,9 +1,9 @@ -package org.baeldung.converter; +package com.baeldung.converter; import com.baeldung.toggle.Employee; -import org.baeldung.boot.Application; -import org.baeldung.boot.domain.Modes; +import com.baeldung.boot.Application; +import com.baeldung.boot.domain.Modes; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java similarity index 94% rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java index 2afda7565a..52dc542ebf 100644 --- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java +++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/converter/controller/StringToEmployeeConverterControllerIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.converter.controller; +package com.baeldung.converter.controller; import org.junit.Test; import org.junit.runner.RunWith; @@ -14,7 +14,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultHandlers. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import org.baeldung.boot.Application; +import com.baeldung.boot.Application; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = Application.class) diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java similarity index 93% rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java index 2d70583a54..962abf0fa3 100644 --- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java +++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeControllerIntegrationTest.java @@ -1,8 +1,5 @@ -package org.baeldung.demo.boottest; +package com.baeldung.demo.boottest; -import org.baeldung.demo.boottest.Employee; -import org.baeldung.demo.boottest.EmployeeRestController; -import org.baeldung.demo.boottest.EmployeeService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java similarity index 94% rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java index 3042f95a46..164887886b 100644 --- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java +++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeRepositoryIntegrationTest.java @@ -1,7 +1,7 @@ -package org.baeldung.demo.boottest; +package com.baeldung.demo.boottest; -import org.baeldung.demo.boottest.Employee; -import org.baeldung.demo.boottest.EmployeeRepository; +import com.baeldung.demo.boottest.Employee; +import com.baeldung.demo.boottest.EmployeeRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java similarity index 97% rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java index a4b35889d6..327e9f9d56 100644 --- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java +++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeRestControllerIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.demo.boottest; +package com.baeldung.demo.boottest; import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.is; @@ -14,7 +14,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import java.io.IOException; import java.util.List; -import org.baeldung.demo.DemoApplication; +import com.baeldung.demo.DemoApplication; import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java similarity index 94% rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java index df28111a57..88f2830a2b 100644 --- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java +++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/EmployeeServiceImplIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.demo.boottest; +package com.baeldung.demo.boottest; import static org.assertj.core.api.Assertions.assertThat; @@ -6,6 +6,10 @@ import java.util.Arrays; import java.util.List; import java.util.Optional; +import com.baeldung.demo.boottest.Employee; +import com.baeldung.demo.boottest.EmployeeRepository; +import com.baeldung.demo.boottest.EmployeeService; +import com.baeldung.demo.boottest.EmployeeServiceImpl; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/JsonUtil.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/JsonUtil.java similarity index 91% rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/JsonUtil.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/JsonUtil.java index 7e04f47696..3fcd709f7c 100644 --- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/demo/boottest/JsonUtil.java +++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/demo/boottest/JsonUtil.java @@ -1,4 +1,4 @@ -package org.baeldung.demo.boottest; +package com.baeldung.demo.boottest; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/repository/UserRepositoryIntegrationTest.java similarity index 92% rename from spring-boot-modules/spring-boot/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java rename to spring-boot-modules/spring-boot/src/test/java/com/baeldung/repository/UserRepositoryIntegrationTest.java index ea7f118967..a1318949f3 100644 --- a/spring-boot-modules/spring-boot/src/test/java/org/baeldung/repository/UserRepositoryIntegrationTest.java +++ b/spring-boot-modules/spring-boot/src/test/java/com/baeldung/repository/UserRepositoryIntegrationTest.java @@ -1,7 +1,8 @@ -package org.baeldung.repository; +package com.baeldung.repository; -import org.baeldung.boot.config.H2JpaConfig; -import org.baeldung.model.User; +import com.baeldung.boot.config.H2JpaConfig; +import com.baeldung.model.User; +import com.baeldung.repository.UserRepository; import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; From 2d0f2c171bba3b8d970de9e8e76c9e78ea07d124 Mon Sep 17 00:00:00 2001 From: mikr Date: Sat, 4 Apr 2020 20:40:09 +0200 Subject: [PATCH 082/503] JAVA-117 Standardize spring-boot-modules/spring-boot-client --- .../main/java/{org => com}/baeldung/boot/Application.java | 2 +- .../java/{org => com}/baeldung/boot/client/Details.java | 2 +- .../baeldung/boot/client/DetailsServiceClient.java | 2 +- .../{org => com}/baeldung/websocket/client/Message.java | 2 +- .../baeldung/websocket/client/MyStompSessionHandler.java | 2 +- .../{org => com}/baeldung/websocket/client/StompClient.java | 2 +- .../test/java/{org => com}/baeldung/SpringContextTest.java | 4 ++-- .../boot/client/DetailsServiceClientIntegrationTest.java | 6 ++++-- .../client/MyStompSessionHandlerIntegrationTest.java | 1 - 9 files changed, 12 insertions(+), 11 deletions(-) rename spring-boot-modules/spring-boot-client/src/main/java/{org => com}/baeldung/boot/Application.java (93%) rename spring-boot-modules/spring-boot-client/src/main/java/{org => com}/baeldung/boot/client/Details.java (93%) rename spring-boot-modules/spring-boot-client/src/main/java/{org => com}/baeldung/boot/client/DetailsServiceClient.java (93%) rename spring-boot-modules/spring-boot-client/src/main/java/{org => com}/baeldung/websocket/client/Message.java (89%) rename spring-boot-modules/spring-boot-client/src/main/java/{org => com}/baeldung/websocket/client/MyStompSessionHandler.java (97%) rename spring-boot-modules/spring-boot-client/src/main/java/{org => com}/baeldung/websocket/client/StompClient.java (96%) rename spring-boot-modules/spring-boot-client/src/test/java/{org => com}/baeldung/SpringContextTest.java (86%) rename spring-boot-modules/spring-boot-client/src/test/java/{org => com}/baeldung/boot/client/DetailsServiceClientIntegrationTest.java (90%) diff --git a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/Application.java b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/Application.java similarity index 93% rename from spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/Application.java rename to spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/Application.java index c1b6558b26..cb0d0c1532 100644 --- a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/Application.java +++ b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/Application.java @@ -1,4 +1,4 @@ -package org.baeldung.boot; +package com.baeldung.boot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/client/Details.java b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/client/Details.java similarity index 93% rename from spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/client/Details.java rename to spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/client/Details.java index 1e3ddf7b21..c806476634 100644 --- a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/client/Details.java +++ b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/client/Details.java @@ -1,4 +1,4 @@ -package org.baeldung.boot.client; +package com.baeldung.boot.client; public class Details { diff --git a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/client/DetailsServiceClient.java b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/client/DetailsServiceClient.java similarity index 93% rename from spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/client/DetailsServiceClient.java rename to spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/client/DetailsServiceClient.java index f2b9d6d030..a9f1b08c97 100644 --- a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/boot/client/DetailsServiceClient.java +++ b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/boot/client/DetailsServiceClient.java @@ -1,4 +1,4 @@ -package org.baeldung.boot.client; +package com.baeldung.boot.client; import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.stereotype.Service; diff --git a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/Message.java b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/Message.java similarity index 89% rename from spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/Message.java rename to spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/Message.java index 2744c49f62..19140f76a2 100644 --- a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/Message.java +++ b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/Message.java @@ -1,4 +1,4 @@ -package org.baeldung.websocket.client; +package com.baeldung.websocket.client; public class Message { diff --git a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/MyStompSessionHandler.java b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/MyStompSessionHandler.java similarity index 97% rename from spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/MyStompSessionHandler.java rename to spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/MyStompSessionHandler.java index 92beab9430..8ccc42c58a 100644 --- a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/MyStompSessionHandler.java +++ b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/MyStompSessionHandler.java @@ -1,4 +1,4 @@ -package org.baeldung.websocket.client; +package com.baeldung.websocket.client; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/StompClient.java b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/StompClient.java similarity index 96% rename from spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/StompClient.java rename to spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/StompClient.java index 2bff07186d..04d87dd2ed 100644 --- a/spring-boot-modules/spring-boot-client/src/main/java/org/baeldung/websocket/client/StompClient.java +++ b/spring-boot-modules/spring-boot-client/src/main/java/com/baeldung/websocket/client/StompClient.java @@ -1,4 +1,4 @@ -package org.baeldung.websocket.client; +package com.baeldung.websocket.client; import java.util.Scanner; diff --git a/spring-boot-modules/spring-boot-client/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/SpringContextTest.java similarity index 86% rename from spring-boot-modules/spring-boot-client/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/SpringContextTest.java index 9c3b83ea79..1341f17eac 100644 --- a/spring-boot-modules/spring-boot-client/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/SpringContextTest.java @@ -1,6 +1,6 @@ -package org.baeldung; +package com.baeldung; -import org.baeldung.boot.Application; +import com.baeldung.boot.Application; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; diff --git a/spring-boot-modules/spring-boot-client/src/test/java/org/baeldung/boot/client/DetailsServiceClientIntegrationTest.java b/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/boot/client/DetailsServiceClientIntegrationTest.java similarity index 90% rename from spring-boot-modules/spring-boot-client/src/test/java/org/baeldung/boot/client/DetailsServiceClientIntegrationTest.java rename to spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/boot/client/DetailsServiceClientIntegrationTest.java index d423300b85..4af5370950 100644 --- a/spring-boot-modules/spring-boot-client/src/test/java/org/baeldung/boot/client/DetailsServiceClientIntegrationTest.java +++ b/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/boot/client/DetailsServiceClientIntegrationTest.java @@ -1,10 +1,12 @@ -package org.baeldung.boot.client; +package com.baeldung.boot.client; import static org.assertj.core.api.Assertions.assertThat; import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; -import org.baeldung.boot.Application; +import com.baeldung.boot.Application; +import com.baeldung.boot.client.Details; +import com.baeldung.boot.client.DetailsServiceClient; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/websocket/client/MyStompSessionHandlerIntegrationTest.java b/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/websocket/client/MyStompSessionHandlerIntegrationTest.java index bb1b5e254e..57eec935f6 100644 --- a/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/websocket/client/MyStompSessionHandlerIntegrationTest.java +++ b/spring-boot-modules/spring-boot-client/src/test/java/com/baeldung/websocket/client/MyStompSessionHandlerIntegrationTest.java @@ -1,6 +1,5 @@ package com.baeldung.websocket.client; -import org.baeldung.websocket.client.MyStompSessionHandler; import org.junit.Test; import org.mockito.Mockito; import org.springframework.messaging.simp.stomp.StompHeaders; From ba65e099896cce714f3616329971d58c47dfa99d Mon Sep 17 00:00:00 2001 From: gindex Date: Sat, 28 Mar 2020 19:01:54 +0100 Subject: [PATCH 083/503] Add blocking and non-blocking mono examples Add article reference Fix url --- reactor-core/README.md | 1 + .../java/com/baeldung/mono/MonoUnitTest.java | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 reactor-core/src/test/java/com/baeldung/mono/MonoUnitTest.java diff --git a/reactor-core/README.md b/reactor-core/README.md index e3cca35f86..f2dbd77981 100644 --- a/reactor-core/README.md +++ b/reactor-core/README.md @@ -7,3 +7,4 @@ This module contains articles about Reactor Core. - [Intro To Reactor Core](https://www.baeldung.com/reactor-core) - [Combining Publishers in Project Reactor](https://www.baeldung.com/reactor-combine-streams) - [Programmatically Creating Sequences with Project Reactor](https://www.baeldung.com/flux-sequences-reactor) +- [How To Get String From Mono In Reactive Java](http://baeldung.com/string-from-mono/) \ No newline at end of file diff --git a/reactor-core/src/test/java/com/baeldung/mono/MonoUnitTest.java b/reactor-core/src/test/java/com/baeldung/mono/MonoUnitTest.java new file mode 100644 index 0000000000..b493cd1159 --- /dev/null +++ b/reactor-core/src/test/java/com/baeldung/mono/MonoUnitTest.java @@ -0,0 +1,39 @@ +package com.baeldung.mono; + +import org.junit.Test; +import reactor.core.publisher.Mono; + +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.Optional; + +import static org.junit.Assert.assertEquals; + +public class MonoUnitTest { + @Test + public void whenMonoProducesString_thenBlockAndConsume() { + String expected = "hello world!"; + + String result1 = Mono.just(expected).block(); + assertEquals(expected, result1); + + String result2 = Mono.just(expected).block(Duration.of(1000, ChronoUnit.MILLIS)); + assertEquals(expected, result2); + + Optional result3 = Mono.empty().blockOptional(); + assertEquals(Optional.empty(), result3); + } + + @Test + public void whenMonoProducesString_thenConsumeNonBlocking() { + String expected = "hello world!"; + + Mono.just(expected) + .doOnNext(result -> assertEquals(expected, result)) + .subscribe(); + + Mono.just(expected) + .subscribe(result -> assertEquals(expected, result)); + + } +} From 641956f87db3f02e3291cc684e868b9d19b808ad Mon Sep 17 00:00:00 2001 From: mikr Date: Sat, 4 Apr 2020 21:16:51 +0200 Subject: [PATCH 084/503] JAVA-117 Standardize spring-boot-modules/spring-boot-gradle --- spring-boot-modules/spring-boot-gradle/build.gradle | 8 ++++---- .../main/java/{org => com}/baeldung/DemoApplication.java | 2 +- .../java/{org => com}/baeldung/DemoApplicationTests.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) rename spring-boot-modules/spring-boot-gradle/src/main/java/{org => com}/baeldung/DemoApplication.java (92%) rename spring-boot-modules/spring-boot-gradle/src/test/java/{org => com}/baeldung/DemoApplicationTests.java (93%) diff --git a/spring-boot-modules/spring-boot-gradle/build.gradle b/spring-boot-modules/spring-boot-gradle/build.gradle index 96055536c3..faae01a1a5 100644 --- a/spring-boot-modules/spring-boot-gradle/build.gradle +++ b/spring-boot-modules/spring-boot-gradle/build.gradle @@ -21,7 +21,7 @@ apply plugin: 'io.spring.dependency-management' //add tasks thinJar and thinResolve for thin JAR deployments apply plugin: 'org.springframework.boot.experimental.thin-launcher' -group = 'org.baeldung' +group = 'com.baeldung' version = '0.0.1-SNAPSHOT' sourceCompatibility = 1.8 @@ -35,16 +35,16 @@ dependencies { } springBoot { - mainClassName = 'org.baeldung.DemoApplication' + mainClassName = 'com.baeldung.DemoApplication' } bootJar { // This is overridden by the mainClassName in springBoot{} and added here for reference purposes. - mainClassName = 'org.baeldung.DemoApplication' + mainClassName = 'com.baeldung.DemoApplication' // This block serves the same purpose as the above thus commented out. Added here for reference purposes // manifest { -// attributes 'Start-Class': 'org.baeldung.DemoApplication' +// attributes 'Start-Class': 'com.baeldung.DemoApplication' // } } diff --git a/spring-boot-modules/spring-boot-gradle/src/main/java/org/baeldung/DemoApplication.java b/spring-boot-modules/spring-boot-gradle/src/main/java/com/baeldung/DemoApplication.java similarity index 92% rename from spring-boot-modules/spring-boot-gradle/src/main/java/org/baeldung/DemoApplication.java rename to spring-boot-modules/spring-boot-gradle/src/main/java/com/baeldung/DemoApplication.java index f8df823f25..64bac6936b 100644 --- a/spring-boot-modules/spring-boot-gradle/src/main/java/org/baeldung/DemoApplication.java +++ b/spring-boot-modules/spring-boot-gradle/src/main/java/com/baeldung/DemoApplication.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-boot-modules/spring-boot-gradle/src/test/java/org/baeldung/DemoApplicationTests.java b/spring-boot-modules/spring-boot-gradle/src/test/java/com/baeldung/DemoApplicationTests.java similarity index 93% rename from spring-boot-modules/spring-boot-gradle/src/test/java/org/baeldung/DemoApplicationTests.java rename to spring-boot-modules/spring-boot-gradle/src/test/java/com/baeldung/DemoApplicationTests.java index b24bfb2cb6..65395582cb 100644 --- a/spring-boot-modules/spring-boot-gradle/src/test/java/org/baeldung/DemoApplicationTests.java +++ b/spring-boot-modules/spring-boot-gradle/src/test/java/com/baeldung/DemoApplicationTests.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; From ad889f6bcd2c597f86434b731141ccb4f0321ca1 Mon Sep 17 00:00:00 2001 From: mikr Date: Sat, 4 Apr 2020 21:47:45 +0200 Subject: [PATCH 085/503] JAVA-117 Standardize spring-boot-modules --- .../src/test/java/org/baeldung/SpringContextTest.java | 2 +- .../src/test/java/org/baeldung/SpringContextTest.java | 2 +- .../src/test/java/org/baeldung/SpringContextTest.java | 2 +- spring-boot-modules/spring-boot-artifacts/pom.xml | 2 +- .../src/test/java/org/baeldung/SpringContextTest.java | 2 +- .../src/test/java/org/baeldung/SpringContextTest.java | 2 +- .../src/test/java/org/baeldung/SpringContextTest.java | 2 +- .../src/test/java/org/baeldung/SpringContextTest.java | 2 +- spring-boot-modules/spring-boot-deployment/pom.xml | 2 +- .../src/test/java/org/baeldung/SpringContextTest.java | 2 +- .../src/test/java/org/baeldung/SpringContextTest.java | 2 +- .../src/test/java/org/baeldung/SpringContextTest.java | 2 +- .../src/test/java/org/baeldung/SpringContextLiveTest.java | 2 +- .../src/test/java/org/baeldung/SpringContextTest.java | 2 +- .../properties/external/ExternalPropertiesWithJavaConfig.java | 2 +- .../properties/external/ExternalPropertiesWithXmlConfig.java | 2 +- .../properties/external/ExternalPropertiesWithXmlConfigOne.java | 2 +- .../src/test/java/org/baeldung/SpringContextTest.java | 2 +- .../src/test/java/org/baeldung/SpringContextTest.java | 2 +- .../src/test/java/org/baeldung/SpringContextTest.java | 2 +- .../src/main/java/com/baeldung/main/SpringBootApplication.java | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java index 834f26dacf..78a1ab7a54 100644 --- a/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java index c185456019..3322193134 100644 --- a/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot-angular/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-angular/src/test/java/org/baeldung/SpringContextTest.java index 961d756a68..0f4fa757d6 100644 --- a/spring-boot-modules/spring-boot-angular/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-boot-modules/spring-boot-angular/src/test/java/org/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot-artifacts/pom.xml b/spring-boot-modules/spring-boot-artifacts/pom.xml index f7c8636593..de9f6ab635 100644 --- a/spring-boot-modules/spring-boot-artifacts/pom.xml +++ b/spring-boot-modules/spring-boot-artifacts/pom.xml @@ -208,7 +208,7 @@ - org.baeldung.boot.Application + com.baeldung.boot.Application 3.1.1 3.3.7-1 2.2 diff --git a/spring-boot-modules/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java index 8324fabfca..ce743e0f77 100644 --- a/spring-boot-modules/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-boot-modules/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java index ff3e795778..ca8989724b 100644 --- a/spring-boot-modules/spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-boot-modules/spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java index e6ce83fab5..b4668e7d2b 100644 --- a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java index b82b67df68..7103da97f3 100644 --- a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot-deployment/pom.xml b/spring-boot-modules/spring-boot-deployment/pom.xml index 64c0e698f6..b3fc3eabd1 100644 --- a/spring-boot-modules/spring-boot-deployment/pom.xml +++ b/spring-boot-modules/spring-boot-deployment/pom.xml @@ -190,7 +190,7 @@ - org.baeldung.boot.Application + com.baeldung.boot.Application 3.1.1 3.3.7-1 2.2 diff --git a/spring-boot-modules/spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java index ab6e4557d5..97810cf590 100644 --- a/spring-boot-modules/spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-boot-modules/spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot-keycloak/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-keycloak/src/test/java/org/baeldung/SpringContextTest.java index 4effccc083..3f3ecd87d0 100644 --- a/spring-boot-modules/spring-boot-keycloak/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-boot-modules/spring-boot-keycloak/src/test/java/org/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java index 9817522e68..d2660ad84e 100644 --- a/spring-boot-modules/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-boot-modules/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextLiveTest.java b/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextLiveTest.java index 069dd41b8d..209a93d94c 100644 --- a/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextLiveTest.java +++ b/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java index 16e0708fc9..e73f4e79f7 100644 --- a/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-boot-modules/spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithJavaConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithJavaConfig.java index d43f18f6a7..5b954f8941 100644 --- a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithJavaConfig.java +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithJavaConfig.java @@ -7,7 +7,7 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; @Configuration -@ComponentScan("org.baeldung.properties.core") +@ComponentScan("com.baeldung.properties.core") @PropertySource("classpath:foo.properties") public class ExternalPropertiesWithJavaConfig { diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfig.java index 6d105428d9..9080e3d0ba 100644 --- a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfig.java +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfig.java @@ -6,7 +6,7 @@ import org.springframework.context.annotation.ImportResource; @Configuration @ImportResource("classpath:configForProperties.xml") -@ComponentScan("org.baeldung.core") +@ComponentScan("com.baeldung.core") public class ExternalPropertiesWithXmlConfig { public ExternalPropertiesWithXmlConfig() { diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfigOne.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfigOne.java index 6f1e4c8490..f45f5b6a03 100644 --- a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfigOne.java +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/external/ExternalPropertiesWithXmlConfigOne.java @@ -6,7 +6,7 @@ import org.springframework.context.annotation.ImportResource; @Configuration @ImportResource("classpath:configForPropertiesOne.xml") -@ComponentScan("org.baeldung.core") +@ComponentScan("com.baeldung.core") public class ExternalPropertiesWithXmlConfigOne { public ExternalPropertiesWithXmlConfigOne() { diff --git a/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java index 874c4f582f..2e1a17199d 100644 --- a/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java index 874c4f582f..2e1a17199d 100644 --- a/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java index 16e0708fc9..e73f4e79f7 100644 --- a/spring-boot-modules/spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-boot-modules/spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/main/SpringBootApplication.java b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/main/SpringBootApplication.java index c8cfb50f1c..383932524f 100644 --- a/spring-boot-modules/spring-boot/src/main/java/com/baeldung/main/SpringBootApplication.java +++ b/spring-boot-modules/spring-boot/src/main/java/com/baeldung/main/SpringBootApplication.java @@ -18,7 +18,7 @@ import java.util.concurrent.Executors; @RestController @EnableAutoConfiguration -@ComponentScan({ "org.baeldung.common.error", "com.baeldung.common.error.controller", "com.baeldung.common.properties", "com.baeldung.common.resources", "com.baeldung.endpoints", "com.baeldung.service", "com.baeldung.monitor.jmx", "com.baeldung.boot.config" }) +@ComponentScan({ "com.baeldung.common.error", "com.baeldung.common.error.controller", "com.baeldung.common.properties", "com.baeldung.common.resources", "com.baeldung.endpoints", "com.baeldung.service", "com.baeldung.monitor.jmx", "com.baeldung.boot.config" }) public class SpringBootApplication { private static ApplicationContext applicationContext; From 5a56276893d3f8e1cce2473aed880b2a8982ca97 Mon Sep 17 00:00:00 2001 From: kkaravitis Date: Sun, 5 Apr 2020 00:45:15 +0300 Subject: [PATCH 086/503] [BAEL-3936] Initial commit --- persistence-modules/java-jpa-2/pom.xml | 31 ++- .../jpa/unrelated/entities/Cocktail.java | 84 ++++++++ .../unrelated/entities/MultipleRecipe.java | 65 ++++++ .../jpa/unrelated/entities/Recipe.java | 48 +++++ .../main/resources/META-INF/persistence.xml | 25 ++- .../entities/UnrelatedEntitiesUnitTest.java | 187 ++++++++++++++++++ 6 files changed, 437 insertions(+), 3 deletions(-) create mode 100644 persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java create mode 100644 persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/MultipleRecipe.java create mode 100644 persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Recipe.java create mode 100644 persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java diff --git a/persistence-modules/java-jpa-2/pom.xml b/persistence-modules/java-jpa-2/pom.xml index f79f6f1633..b41cdccb07 100644 --- a/persistence-modules/java-jpa-2/pom.xml +++ b/persistence-modules/java-jpa-2/pom.xml @@ -48,6 +48,17 @@ ${postgres.version} runtime + + com.querydsl + querydsl-apt + ${querydsl.version} + provided + + + com.querydsl + querydsl-jpa + ${querydsl.version} + org.assertj @@ -101,11 +112,28 @@ target/metamodel + ${project.build.directory}/generated-sources/java/ + + com.mysema.maven + apt-maven-plugin + 1.1.3 + + + + process + + + target/generated-sources/java + com.querydsl.apt.jpa.JPAAnnotationProcessor + + + + @@ -118,6 +146,7 @@ 3.5.1 3.3.3 3.0.0 + 4.2.2 - \ No newline at end of file + diff --git a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java new file mode 100644 index 0000000000..b957ec2ed5 --- /dev/null +++ b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java @@ -0,0 +1,84 @@ +package com.baeldung.jpa.unrelated.entities; + +import org.hibernate.annotations.NotFound; +import org.hibernate.annotations.NotFoundAction; + +import javax.persistence.*; +import java.util.List; +import java.util.Objects; + +@Entity +@Table(name = "cocktails") +public class Cocktail { + @Id + @Column(name="cocktail_name") + private String name; + + @Column + private double price; + + @Column(name="category") + private String category; + + @OneToOne + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn(name = "cocktail_name", + referencedColumnName = "cocktail", + insertable = false, + updatable = false, + foreignKey = @javax.persistence.ForeignKey(value= ConstraintMode.NO_CONSTRAINT)) + private Recipe recipe; + + @OneToMany + @NotFound(action=NotFoundAction.IGNORE) + @JoinColumn(name = "cocktail", + referencedColumnName = "cocktail_name", + insertable = false, + updatable = false, + foreignKey = @javax.persistence.ForeignKey(value= ConstraintMode.NO_CONSTRAINT)) + private List recipeList; + + public Cocktail() { + } + + public Cocktail(String name, double price, String baseIngredient) { + this.name = name; + this.price = price; + this.category = baseIngredient; + } + + public String getName() { + return name; + } + + public double getPrice() { + return price; + } + + public String getCategory() { + return category; + } + + public Recipe getRecipe() { + return recipe; + } + + public List getRecipeList() { + return recipeList; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Cocktail cocktail = (Cocktail) o; + return Double.compare(cocktail.price, price) == 0 && + Objects.equals(name, cocktail.name) && + Objects.equals(category, cocktail.category); + } + + @Override + public int hashCode() { + return Objects.hash(name, price, category); + } +} diff --git a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/MultipleRecipe.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/MultipleRecipe.java new file mode 100644 index 0000000000..e04df150f3 --- /dev/null +++ b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/MultipleRecipe.java @@ -0,0 +1,65 @@ +package com.baeldung.jpa.unrelated.entities; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import java.util.Objects; + +@Entity +@Table(name="multiple_recipes") +public class MultipleRecipe { + @Id + @Column(name="id") + private Long id; + + @Column(name="cocktail") + private String cocktail; + + @Column(name="instructions") + private String instructions; + + @Column(name="base_ingredient") + private String baseIngredient; + + public MultipleRecipe() {} + + public MultipleRecipe(Long id, String cocktail, String instructions, String baseIngredient) { + this.baseIngredient = baseIngredient; + this.cocktail = cocktail; + this.id = id; + this.instructions = instructions; + } + + public Long getId() { + return id; + } + + public String getCocktail() { + return cocktail; + } + + public String getInstructions() { + return instructions; + } + + public String getBaseIngredient() { + return baseIngredient; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + MultipleRecipe that = (MultipleRecipe) o; + return Objects.equals(id, that.id) && + Objects.equals(cocktail, that.cocktail) && + Objects.equals(instructions, that.instructions) && + Objects.equals(baseIngredient, that.baseIngredient); + } + + @Override + public int hashCode() { + return Objects.hash(id, cocktail, instructions, baseIngredient); + } +} diff --git a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Recipe.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Recipe.java new file mode 100644 index 0000000000..585c6abec3 --- /dev/null +++ b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Recipe.java @@ -0,0 +1,48 @@ +package com.baeldung.jpa.unrelated.entities; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import java.util.Objects; + +@Entity +@Table(name="recipes") +public class Recipe { + @Id + @Column(name = "cocktail") + private String cocktail; + + @Column + private String instructions; + + public Recipe() { + } + + public Recipe(String cocktail, String instructions) { + this.cocktail = cocktail; + this.instructions = instructions; + } + + public String getCocktail() { + return cocktail; + } + + public String getInstructions() { + return instructions; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Recipe recipe = (Recipe) o; + return Objects.equals(cocktail, recipe.cocktail) && + Objects.equals(instructions, recipe.instructions); + } + + @Override + public int hashCode() { + return Objects.hash(cocktail, instructions); + } +} diff --git a/persistence-modules/java-jpa-2/src/main/resources/META-INF/persistence.xml b/persistence-modules/java-jpa-2/src/main/resources/META-INF/persistence.xml index 11e007973f..eec7f7cf6e 100644 --- a/persistence-modules/java-jpa-2/src/main/resources/META-INF/persistence.xml +++ b/persistence-modules/java-jpa-2/src/main/resources/META-INF/persistence.xml @@ -162,5 +162,26 @@ value="false" /> - - \ No newline at end of file + + + org.hibernate.jpa.HibernatePersistenceProvider + com.baeldung.jpa.unrelated.entities.Cocktail + com.baeldung.jpa.unrelated.entities.Recipe + com.baeldung.jpa.unrelated.entities.MultipleRecipe + true + + + + + + + + + + + + diff --git a/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java new file mode 100644 index 0000000000..540811c409 --- /dev/null +++ b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java @@ -0,0 +1,187 @@ +package com.baeldung.jpa.unrelated.entities; + +import javax.persistence.*; + +import com.querydsl.jpa.impl.JPAQuery; +import org.junit.jupiter.api.*; + +import java.util.List; +import java.util.function.Consumer; + +import static org.junit.jupiter.api.Assertions.*; + +public class UnrelatedEntitiesUnitTest { + private static EntityManagerFactory entityManagerFactory; + private static EntityManager entityManager; + private static Cocktail mojito; + private static Cocktail ginTonic; + + @BeforeAll + public static void setup() { + entityManagerFactory = Persistence.createEntityManagerFactory("jpa-h2-unrelated-entities"); + entityManager = entityManagerFactory.createEntityManager(); + mojito = new Cocktail("Mojito", 11, "Rum"); + ginTonic = new Cocktail("Gin tonic", 8.50, "Gin"); + entityManager.getTransaction().begin(); + entityManager.persist(mojito); + entityManager.persist(ginTonic); + entityManager.persist(new Recipe(mojito.getName(), "Some instructions")); + entityManager.persist(new MultipleRecipe(1L, mojito.getName(), "some instructions", mojito.getCategory())); + entityManager.persist(new MultipleRecipe(2L, mojito.getName(), "some other instructions", mojito.getCategory())); + entityManager.getTransaction().commit(); + } + + @AfterAll + public static void closeSession() { + entityManager.close(); + } + + @Test + public void whenQueryingForCocktailThatHasRecipe_thenTheExpectedCocktailReturned() { + // JPA + Cocktail cocktail = entityManager.createQuery( + "select c from Cocktail c join c.recipe", Cocktail.class) + .getSingleResult(); + verifyResult(mojito, cocktail); + + cocktail = entityManager.createQuery( + "select c from Cocktail c join Recipe r on c.name = r.cocktail", Cocktail.class) + .getSingleResult(); + verifyResult(mojito, cocktail); + + // QueryDSL + cocktail = new JPAQuery(entityManager) + .from(QCocktail.cocktail) + .join(QCocktail.cocktail.recipe) + .fetchOne(); + verifyResult(mojito, cocktail); + + cocktail = new JPAQuery(entityManager) + .from(QCocktail.cocktail) + .join(QRecipe.recipe) + .on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail)) + .fetchOne(); + verifyResult(mojito, cocktail); + } + + @Test + public void whenQueryingForCocktailThatHasNotARecipe_thenTheExpectedCocktailReturned() { + Cocktail cocktail = entityManager + .createQuery("select c from Cocktail c left join c.recipe r " + + "where r is null", + Cocktail.class) + .getSingleResult(); + verifyResult(ginTonic, cocktail); + + cocktail = entityManager + .createQuery("select c from Cocktail c left join Recipe r " + + "on c.name = r.cocktail " + + "where r is null", + Cocktail.class) + .getSingleResult(); + verifyResult(ginTonic, cocktail); + + QRecipe recipe = new QRecipe("alias"); + cocktail = new JPAQuery(entityManager) + .from(QCocktail.cocktail) + .leftJoin(QCocktail.cocktail.recipe, recipe) + .where(recipe.isNull()).fetchOne(); + verifyResult(ginTonic, cocktail); + + cocktail = new JPAQuery(entityManager) + .from(QCocktail.cocktail) + .leftJoin(QRecipe.recipe) + .on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail)) + .where(QRecipe.recipe.isNull()).fetchOne(); + verifyResult(ginTonic, cocktail); + } + + @Test + public void whenQueringForCocktailThatHasRecipes_thenTheExpectedCocktailReturned() { + // JPQL + Cocktail cocktail = entityManager + .createQuery("select c from Cocktail c join c.recipeList", Cocktail.class) + .getSingleResult(); + verifyResult(mojito, cocktail); + + cocktail = entityManager + .createQuery("select c from Cocktail c join MultipleRecipe mr on mr.cocktail = c.name", Cocktail.class) + .getSingleResult(); + verifyResult(mojito, cocktail); + + // QueryDSL + cocktail = new JPAQuery(entityManager) + .from(QCocktail.cocktail).join(QCocktail.cocktail.recipeList).fetchOne(); + verifyResult(mojito, cocktail); + + cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) + .join(QMultipleRecipe.multipleRecipe) + .on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail)) + .fetchOne(); + verifyResult(mojito, cocktail); + } + + @Test + public void whenQueryingForCocktailThatHasNotRecipes_thenTheExpectedCocktailReturned() { + // JPQL + Cocktail cocktail = entityManager + .createQuery("select c from Cocktail c left join c.recipeList r where r is null", Cocktail.class) + .getSingleResult(); + verifyResult(ginTonic, cocktail); + + cocktail = entityManager.createQuery("select c from Cocktail c left join MultipleRecipe r " + + "on c.name = r.cocktail where r is null", Cocktail.class) + .getSingleResult(); + verifyResult(ginTonic, cocktail); + + // QueryDSL + QMultipleRecipe multipleRecipe = new QMultipleRecipe("alias"); + cocktail = new JPAQuery(entityManager) + .from(QCocktail.cocktail) + .leftJoin(QCocktail.cocktail.recipeList, multipleRecipe) + .where(multipleRecipe.isNull()) + .fetchOne(); + verifyResult(ginTonic, cocktail); + + cocktail = new JPAQuery(entityManager) + .from(QCocktail.cocktail).leftJoin(QMultipleRecipe.multipleRecipe) + .on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail)) + .where(QMultipleRecipe.multipleRecipe.isNull()).fetchOne(); + verifyResult(ginTonic, cocktail); + } + + @Test + public void whenQueryingForRumCocktailsInMenuRecipes_thenTheExpectedRecipesReturned() { + Consumer> verifyResult = recipes -> { + assertEquals(2, recipes.size()); + recipes.forEach(r -> assertEquals(mojito.getName(), r.getCocktail())); + }; + + // JPQL + List recipes = entityManager + .createQuery("select distinct r from MultipleRecipe r join Cocktail c " + + "on r.cocktail = c.name " + + "and " + + "r.baseIngredient = :category", + MultipleRecipe.class) + .setParameter("category", mojito.getCategory()) + .getResultList(); + verifyResult.accept(recipes); + + // QueryDSL + QCocktail cocktail = QCocktail.cocktail; + QMultipleRecipe multipleRecipe = QMultipleRecipe.multipleRecipe; + recipes = new JPAQuery(entityManager) + .from(multipleRecipe) + .join(cocktail) + .on(multipleRecipe.cocktail.eq(cocktail.name) + .and(multipleRecipe.baseIngredient.eq(mojito.getCategory()))) + .fetch(); + verifyResult.accept(recipes); + } + + private void verifyResult(Cocktail expectedCocktail, Cocktail queryResult) { + assertNotNull(queryResult); + assertEquals(expectedCocktail, queryResult); + } +} From 9acc69220be5068d997789d8f1e7db7e2a2dd1bf Mon Sep 17 00:00:00 2001 From: kkaravitis Date: Sun, 5 Apr 2020 01:11:49 +0300 Subject: [PATCH 087/503] [BAEL-3936] Formatted code --- .../jpa/unrelated/entities/Cocktail.java | 41 +++-- .../unrelated/entities/MultipleRecipe.java | 37 +++-- .../entities/UnrelatedEntitiesUnitTest.java | 156 +++++++++--------- 3 files changed, 123 insertions(+), 111 deletions(-) diff --git a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java index b957ec2ed5..7f5ca66570 100644 --- a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java +++ b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java @@ -11,31 +11,34 @@ import java.util.Objects; @Table(name = "cocktails") public class Cocktail { @Id - @Column(name="cocktail_name") + @Column(name = "cocktail_name") private String name; @Column private double price; - @Column(name="category") + @Column(name = "category") private String category; @OneToOne @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "cocktail_name", - referencedColumnName = "cocktail", - insertable = false, - updatable = false, - foreignKey = @javax.persistence.ForeignKey(value= ConstraintMode.NO_CONSTRAINT)) + @JoinColumn(name = "cocktail_name", + referencedColumnName = "cocktail", + insertable = false, updatable = false, + foreignKey = @javax.persistence + .ForeignKey(value = ConstraintMode.NO_CONSTRAINT) + ) private Recipe recipe; @OneToMany - @NotFound(action=NotFoundAction.IGNORE) - @JoinColumn(name = "cocktail", - referencedColumnName = "cocktail_name", - insertable = false, - updatable = false, - foreignKey = @javax.persistence.ForeignKey(value= ConstraintMode.NO_CONSTRAINT)) + @NotFound(action = NotFoundAction.IGNORE) + @JoinColumn( + name = "cocktail", + referencedColumnName = "cocktail_name", + insertable = false, + updatable = false, + foreignKey = @javax.persistence + .ForeignKey(value = ConstraintMode.NO_CONSTRAINT)) private List recipeList; public Cocktail() { @@ -69,12 +72,14 @@ public class Cocktail { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; Cocktail cocktail = (Cocktail) o; - return Double.compare(cocktail.price, price) == 0 && - Objects.equals(name, cocktail.name) && - Objects.equals(category, cocktail.category); + return Double.compare(cocktail.price, price) == 0 && + Objects.equals(name, cocktail.name) && + Objects.equals(category, cocktail.category); } @Override diff --git a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/MultipleRecipe.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/MultipleRecipe.java index e04df150f3..d628af1eaf 100644 --- a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/MultipleRecipe.java +++ b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/MultipleRecipe.java @@ -7,28 +7,30 @@ import javax.persistence.Table; import java.util.Objects; @Entity -@Table(name="multiple_recipes") +@Table(name = "multiple_recipes") public class MultipleRecipe { @Id - @Column(name="id") + @Column(name = "id") private Long id; - @Column(name="cocktail") + @Column(name = "cocktail") private String cocktail; - @Column(name="instructions") + @Column(name = "instructions") private String instructions; - @Column(name="base_ingredient") + @Column(name = "base_ingredient") private String baseIngredient; - public MultipleRecipe() {} + public MultipleRecipe() { + } - public MultipleRecipe(Long id, String cocktail, String instructions, String baseIngredient) { - this.baseIngredient = baseIngredient; - this.cocktail = cocktail; + public MultipleRecipe(Long id, String cocktail, + String instructions, String baseIngredient) { this.id = id; + this.cocktail = cocktail; this.instructions = instructions; + this.baseIngredient = baseIngredient; } public Long getId() { @@ -49,17 +51,20 @@ public class MultipleRecipe { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; MultipleRecipe that = (MultipleRecipe) o; - return Objects.equals(id, that.id) && - Objects.equals(cocktail, that.cocktail) && - Objects.equals(instructions, that.instructions) && - Objects.equals(baseIngredient, that.baseIngredient); + return Objects.equals(id, that.id) && + Objects.equals(cocktail, that.cocktail) && + Objects.equals(instructions, that.instructions) && + Objects.equals(baseIngredient, that.baseIngredient); } @Override public int hashCode() { - return Objects.hash(id, cocktail, instructions, baseIngredient); + return Objects.hash(id, cocktail, + instructions, baseIngredient); } } diff --git a/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java index 540811c409..12042c2ba6 100644 --- a/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java +++ b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java @@ -26,8 +26,10 @@ public class UnrelatedEntitiesUnitTest { entityManager.persist(mojito); entityManager.persist(ginTonic); entityManager.persist(new Recipe(mojito.getName(), "Some instructions")); - entityManager.persist(new MultipleRecipe(1L, mojito.getName(), "some instructions", mojito.getCategory())); - entityManager.persist(new MultipleRecipe(2L, mojito.getName(), "some other instructions", mojito.getCategory())); + entityManager.persist(new MultipleRecipe(1L, mojito.getName(), + "some instructions", mojito.getCategory())); + entityManager.persist(new MultipleRecipe(2L, mojito.getName(), + "some other instructions", mojito.getCategory())); entityManager.getTransaction().commit(); } @@ -39,114 +41,116 @@ public class UnrelatedEntitiesUnitTest { @Test public void whenQueryingForCocktailThatHasRecipe_thenTheExpectedCocktailReturned() { // JPA - Cocktail cocktail = entityManager.createQuery( - "select c from Cocktail c join c.recipe", Cocktail.class) - .getSingleResult(); + Cocktail cocktail = entityManager.createQuery("select c " + + "from Cocktail c join c.recipe", Cocktail.class) + .getSingleResult(); verifyResult(mojito, cocktail); - cocktail = entityManager.createQuery( - "select c from Cocktail c join Recipe r on c.name = r.cocktail", Cocktail.class) - .getSingleResult(); + cocktail = entityManager.createQuery("select c " + + "from Cocktail c join Recipe r " + + "on c.name = r.cocktail", Cocktail.class) + .getSingleResult(); verifyResult(mojito, cocktail); // QueryDSL - cocktail = new JPAQuery(entityManager) - .from(QCocktail.cocktail) - .join(QCocktail.cocktail.recipe) - .fetchOne(); + cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) + .join(QCocktail.cocktail.recipe) + .fetchOne(); verifyResult(mojito, cocktail); - cocktail = new JPAQuery(entityManager) - .from(QCocktail.cocktail) - .join(QRecipe.recipe) - .on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail)) - .fetchOne(); + cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) + .join(QRecipe.recipe) + .on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail)) + .fetchOne(); verifyResult(mojito, cocktail); } @Test public void whenQueryingForCocktailThatHasNotARecipe_thenTheExpectedCocktailReturned() { - Cocktail cocktail = entityManager - .createQuery("select c from Cocktail c left join c.recipe r " + - "where r is null", - Cocktail.class) - .getSingleResult(); + Cocktail cocktail = entityManager.createQuery("select c " + + "from Cocktail c left join c.recipe r " + + "where r is null", Cocktail.class) + .getSingleResult(); verifyResult(ginTonic, cocktail); - cocktail = entityManager - .createQuery("select c from Cocktail c left join Recipe r " + - "on c.name = r.cocktail " + - "where r is null", - Cocktail.class) - .getSingleResult(); + cocktail = entityManager.createQuery("select c " + + "from Cocktail c left join Recipe r " + + "on c.name = r.cocktail " + + "where r is null", Cocktail.class) + .getSingleResult(); verifyResult(ginTonic, cocktail); QRecipe recipe = new QRecipe("alias"); - cocktail = new JPAQuery(entityManager) - .from(QCocktail.cocktail) - .leftJoin(QCocktail.cocktail.recipe, recipe) - .where(recipe.isNull()).fetchOne(); + cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) + .leftJoin(QCocktail.cocktail.recipe, recipe) + .where(recipe.isNull()) + .fetchOne(); verifyResult(ginTonic, cocktail); - cocktail = new JPAQuery(entityManager) - .from(QCocktail.cocktail) - .leftJoin(QRecipe.recipe) - .on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail)) - .where(QRecipe.recipe.isNull()).fetchOne(); + cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) + .leftJoin(QRecipe.recipe) + .on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail)) + .where(QRecipe.recipe.isNull()) + .fetchOne(); verifyResult(ginTonic, cocktail); } @Test public void whenQueringForCocktailThatHasRecipes_thenTheExpectedCocktailReturned() { // JPQL - Cocktail cocktail = entityManager - .createQuery("select c from Cocktail c join c.recipeList", Cocktail.class) - .getSingleResult(); + Cocktail cocktail = entityManager.createQuery("select c " + + "from Cocktail c join c.recipeList", Cocktail.class) + .getSingleResult(); verifyResult(mojito, cocktail); - cocktail = entityManager - .createQuery("select c from Cocktail c join MultipleRecipe mr on mr.cocktail = c.name", Cocktail.class) - .getSingleResult(); + cocktail = entityManager.createQuery("select c " + + "from Cocktail c join MultipleRecipe mr " + + "on mr.cocktail = c.name", Cocktail.class) + .getSingleResult(); verifyResult(mojito, cocktail); // QueryDSL - cocktail = new JPAQuery(entityManager) - .from(QCocktail.cocktail).join(QCocktail.cocktail.recipeList).fetchOne(); + cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) + .join(QCocktail.cocktail.recipeList) + .fetchOne(); verifyResult(mojito, cocktail); cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) - .join(QMultipleRecipe.multipleRecipe) - .on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail)) - .fetchOne(); + .join(QMultipleRecipe.multipleRecipe) + .on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail)) + .fetchOne(); verifyResult(mojito, cocktail); } @Test public void whenQueryingForCocktailThatHasNotRecipes_thenTheExpectedCocktailReturned() { // JPQL - Cocktail cocktail = entityManager - .createQuery("select c from Cocktail c left join c.recipeList r where r is null", Cocktail.class) - .getSingleResult(); + Cocktail cocktail = entityManager.createQuery("select c " + + "from Cocktail c left join c.recipeList r " + + "where r is null", Cocktail.class) + .getSingleResult(); verifyResult(ginTonic, cocktail); - cocktail = entityManager.createQuery("select c from Cocktail c left join MultipleRecipe r " + - "on c.name = r.cocktail where r is null", Cocktail.class) - .getSingleResult(); + cocktail = entityManager.createQuery("select c " + + "from Cocktail c left join MultipleRecipe r " + + "on c.name = r.cocktail " + + "where r is null", Cocktail.class) + .getSingleResult(); verifyResult(ginTonic, cocktail); // QueryDSL QMultipleRecipe multipleRecipe = new QMultipleRecipe("alias"); - cocktail = new JPAQuery(entityManager) - .from(QCocktail.cocktail) - .leftJoin(QCocktail.cocktail.recipeList, multipleRecipe) - .where(multipleRecipe.isNull()) - .fetchOne(); + cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) + .leftJoin(QCocktail.cocktail.recipeList, multipleRecipe) + .where(multipleRecipe.isNull()) + .fetchOne(); verifyResult(ginTonic, cocktail); - cocktail = new JPAQuery(entityManager) - .from(QCocktail.cocktail).leftJoin(QMultipleRecipe.multipleRecipe) - .on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail)) - .where(QMultipleRecipe.multipleRecipe.isNull()).fetchOne(); + cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) + .leftJoin(QMultipleRecipe.multipleRecipe) + .on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail)) + .where(QMultipleRecipe.multipleRecipe.isNull()) + .fetchOne(); verifyResult(ginTonic, cocktail); } @@ -158,25 +162,23 @@ public class UnrelatedEntitiesUnitTest { }; // JPQL - List recipes = entityManager - .createQuery("select distinct r from MultipleRecipe r join Cocktail c " + - "on r.cocktail = c.name " + - "and " + - "r.baseIngredient = :category", - MultipleRecipe.class) - .setParameter("category", mojito.getCategory()) - .getResultList(); + List recipes = entityManager.createQuery("select distinct r " + + "from MultipleRecipe r " + + "join Cocktail c " + + "on r.cocktail = c.name and r.baseIngredient = :category", + MultipleRecipe.class) + .setParameter("category", mojito.getCategory()) + .getResultList(); verifyResult.accept(recipes); // QueryDSL QCocktail cocktail = QCocktail.cocktail; QMultipleRecipe multipleRecipe = QMultipleRecipe.multipleRecipe; - recipes = new JPAQuery(entityManager) - .from(multipleRecipe) - .join(cocktail) - .on(multipleRecipe.cocktail.eq(cocktail.name) - .and(multipleRecipe.baseIngredient.eq(mojito.getCategory()))) - .fetch(); + recipes = new JPAQuery(entityManager).from(multipleRecipe) + .join(cocktail) + .on(multipleRecipe.cocktail.eq(cocktail.name) + .and(multipleRecipe.baseIngredient.eq(mojito.getCategory()))) + .fetch(); verifyResult.accept(recipes); } From 6d60aad5f9487c774e364b09b8446b3c23006732 Mon Sep 17 00:00:00 2001 From: Aitor Cuesta Date: Sun, 5 Apr 2020 12:51:27 +0200 Subject: [PATCH 088/503] BAEL-3075 - Initial commit --- .../spring-boot-persistence-2/README.md | 1 + .../spring-boot-persistence-2/pom.xml | 60 +++++++++++++++++-- .../SpringOraclePoolingApplication.java | 29 +++++++++ .../configuration/C3P0Configuration.java | 27 +++++++++ .../configuration/OracleConfiguration.java | 27 +++++++++ .../configuration/OracleUCPConfiguration.java | 30 ++++++++++ .../controller/BookstoreController.java | 45 ++++++++++++++ .../spring/oracle/pooling/entity/Book.java | 45 ++++++++++++++ .../pooling/exception/BookstoreException.java | 10 ++++ .../pooling/repository/BookRepository.java | 9 +++ ...pplication-oracle-pooling-basic.properties | 27 +++++++++ .../src/main/resources/application.yml | 10 +++- .../SpringBootJdbiApplicationUnitTest.java | 4 +- ...gOraclePoolingApplicationC3P0LiveTest.java | 27 +++++++++ ...clePoolingApplicationHikariCPLiveTest.java | 27 +++++++++ ...raclePoolingApplicationOracleLiveTest.java | 27 +++++++++ ...lePoolingApplicationOracleUCPLiveTest.java | 27 +++++++++ 17 files changed, 424 insertions(+), 8 deletions(-) create mode 100644 persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplication.java create mode 100644 persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/C3P0Configuration.java create mode 100644 persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/OracleConfiguration.java create mode 100644 persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/OracleUCPConfiguration.java create mode 100644 persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/controller/BookstoreController.java create mode 100644 persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/entity/Book.java create mode 100644 persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/exception/BookstoreException.java create mode 100644 persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/repository/BookRepository.java create mode 100644 persistence-modules/spring-boot-persistence-2/src/main/resources/application-oracle-pooling-basic.properties create mode 100644 persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationC3P0LiveTest.java create mode 100644 persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationHikariCPLiveTest.java create mode 100644 persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationOracleLiveTest.java create mode 100644 persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationOracleUCPLiveTest.java diff --git a/persistence-modules/spring-boot-persistence-2/README.md b/persistence-modules/spring-boot-persistence-2/README.md index 5d171fb2ca..a74bf7ff02 100644 --- a/persistence-modules/spring-boot-persistence-2/README.md +++ b/persistence-modules/spring-boot-persistence-2/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Using JDBI with Spring Boot](https://www.baeldung.com/spring-boot-jdbi) +- [Oracle Connection Pooling With Spring](https://www.baeldung.com/oracle-connection-pooling-with-spring) \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-2/pom.xml b/persistence-modules/spring-boot-persistence-2/pom.xml index 048dd45c7f..8f76bce1b3 100644 --- a/persistence-modules/spring-boot-persistence-2/pom.xml +++ b/persistence-modules/spring-boot-persistence-2/pom.xml @@ -41,10 +41,20 @@ - - org.springframework.boot - spring-boot-starter-jdbc - + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + net.bytebuddy + byte-buddy + org.jdbi @@ -82,6 +92,47 @@ spring-boot-starter-test test + + + com.oracle + ojdbc8 + 12.2.0.1 + system + ${basedir}/lib/ojdbc8.jar + + + + com.oracle + ucp + 12.2.0.1 + system + ${basedir}/lib/ucp.jar + + + + com.oracle + ons + 12.2.0.1 + system + ${basedir}/lib/ons.jar + + + + com.mchange + c3p0 + ${c3p0.version} + + + + org.apache.commons + commons-dbcp2 + + + + org.apache.tomcat + tomcat-jdbc + + @@ -96,6 +147,7 @@ 3.9.1 2.1.8.RELEASE + 0.9.5.2 diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplication.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplication.java new file mode 100644 index 0000000000..fa7f884112 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplication.java @@ -0,0 +1,29 @@ +package com.baeldung.spring.oracle.pooling; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import lombok.extern.slf4j.Slf4j; + +@SpringBootApplication +@Slf4j +public class SpringOraclePoolingApplication implements CommandLineRunner{ + + @Autowired + private DataSource dataSource; + + public static void main(String[] args) { + SpringApplication.run(SpringOraclePoolingApplication.class, args); + } + + @Override + public void run(String... args) throws Exception { + log.info("Connection Polling datasource : "+ dataSource); + + } + +} diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/C3P0Configuration.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/C3P0Configuration.java new file mode 100644 index 0000000000..f357924807 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/C3P0Configuration.java @@ -0,0 +1,27 @@ +package com.baeldung.spring.oracle.pooling.configuration; + +import java.sql.SQLException; + +import javax.sql.DataSource; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +import com.mchange.v2.c3p0.ComboPooledDataSource; + +@Configuration +@Profile("c3p0") +public class C3P0Configuration { + + @Bean + public DataSource dataSource() throws SQLException { + ComboPooledDataSource dataSource = new ComboPooledDataSource(); + dataSource.setUser("books"); + dataSource.setPassword("books"); + dataSource.setJdbcUrl("jdbc:oracle:thin:@//localhost:11521/ORCLPDB1"); + dataSource.setMinPoolSize(5); + dataSource.setMaxPoolSize(10); + return dataSource; + } +} diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/OracleConfiguration.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/OracleConfiguration.java new file mode 100644 index 0000000000..327374cb54 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/OracleConfiguration.java @@ -0,0 +1,27 @@ +package com.baeldung.spring.oracle.pooling.configuration; + +import java.sql.SQLException; + +import javax.sql.DataSource; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +import oracle.jdbc.pool.OracleDataSource; + +@Configuration +@Profile("oracle") +public class OracleConfiguration { + + @Bean + public DataSource dataSource() throws SQLException { + OracleDataSource dataSource = new OracleDataSource(); + dataSource.setUser("books"); + dataSource.setPassword("books"); + dataSource.setURL("jdbc:oracle:thin:@//localhost:11521/ORCLPDB1"); + dataSource.setFastConnectionFailoverEnabled(true); + dataSource.setImplicitCachingEnabled(true); + return dataSource; + } +} diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/OracleUCPConfiguration.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/OracleUCPConfiguration.java new file mode 100644 index 0000000000..67b4b40712 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/OracleUCPConfiguration.java @@ -0,0 +1,30 @@ +package com.baeldung.spring.oracle.pooling.configuration; + +import java.sql.SQLException; + +import javax.sql.DataSource; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +import oracle.ucp.jdbc.PoolDataSource; +import oracle.ucp.jdbc.PoolDataSourceFactory; + +@Configuration +@Profile("oracle-ucp") +public class OracleUCPConfiguration { + + @Bean + public DataSource dataSource() throws SQLException { + PoolDataSource dataSource = PoolDataSourceFactory.getPoolDataSource(); + dataSource.setUser("books"); + dataSource.setPassword("books"); + dataSource.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource"); + dataSource.setURL("jdbc:oracle:thin:@//localhost:11521/ORCLPDB1"); + dataSource.setFastConnectionFailoverEnabled(true); + dataSource.setInitialPoolSize(5); + dataSource.setMaxPoolSize(10); + return dataSource; + } +} diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/controller/BookstoreController.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/controller/BookstoreController.java new file mode 100644 index 0000000000..49b998bfb9 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/controller/BookstoreController.java @@ -0,0 +1,45 @@ +package com.baeldung.spring.oracle.pooling.controller; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.spring.oracle.pooling.entity.Book; +import com.baeldung.spring.oracle.pooling.exception.BookstoreException; +import com.baeldung.spring.oracle.pooling.repository.BookRepository; + +@RestController +@RequestMapping("/books") +public class BookstoreController { + + @Autowired + private BookRepository repository; + + @GetMapping(value = "/hello") + public String sayHello() { + return "Hello"; + } + + @GetMapping("/all") + public List findAll() { + return repository.findAll(); + } + + @PostMapping("/create") + public Book newBook(@RequestBody Book newBook) { + return repository.save(newBook); + } + + @GetMapping("/get/{id}") + public Book findOne(@PathVariable Long id) throws BookstoreException { + return repository.findById(id) + .orElseThrow(BookstoreException::new); + } + +} diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/entity/Book.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/entity/Book.java new file mode 100644 index 0000000000..fb2c3fcf6a --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/entity/Book.java @@ -0,0 +1,45 @@ +package com.baeldung.spring.oracle.pooling.entity; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Book { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + private String name; + + public Book() { + } + + public Book(String name) { + this.name = name; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "Book [id=" + id + ", name=" + name + "]"; + } + +} diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/exception/BookstoreException.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/exception/BookstoreException.java new file mode 100644 index 0000000000..d2fb399ab3 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/exception/BookstoreException.java @@ -0,0 +1,10 @@ +package com.baeldung.spring.oracle.pooling.exception; + +public class BookstoreException extends Exception{ + + /** + * + */ + private static final long serialVersionUID = 1L; + +} diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/repository/BookRepository.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/repository/BookRepository.java new file mode 100644 index 0000000000..a50a1b24a4 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/repository/BookRepository.java @@ -0,0 +1,9 @@ +package com.baeldung.spring.oracle.pooling.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.baeldung.spring.oracle.pooling.entity.Book; + +public interface BookRepository extends JpaRepository{ + +} diff --git a/persistence-modules/spring-boot-persistence-2/src/main/resources/application-oracle-pooling-basic.properties b/persistence-modules/spring-boot-persistence-2/src/main/resources/application-oracle-pooling-basic.properties new file mode 100644 index 0000000000..9a1c7fc89d --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/main/resources/application-oracle-pooling-basic.properties @@ -0,0 +1,27 @@ +logging.level.root=INFO + +# OracleDB connection settings +spring.datasource.url=jdbc:oracle:thin:@//localhost:11521/ORCLPDB1 +spring.datasource.username=books +spring.datasource.password=books +spring.datasource.driver-class-name=oracle.jdbc.OracleDriver + +# Comment this line for standard Spring Boot default choosing algorithm +#spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource + +# HikariCP settings +spring.datasource.hikari.minimumIdle=5 +spring.datasource.hikari.maximumPoolSize=20 +spring.datasource.hikari.idleTimeout=30000 +spring.datasource.hikari.maxLifetime=2000000 +spring.datasource.hikari.connectionTimeout=30000 +spring.datasource.hikari.poolName=HikariPoolBooks + +# Tomcat settings +spring.datasource.tomcat.maxActive=15 +spring.datasource.tomcat.minIdle=5 + +# JPA settings +spring.jpa.database-platform=org.hibernate.dialect.Oracle12cDialect +spring.jpa.hibernate.use-new-id-generator-mappings=false +spring.jpa.hibernate.ddl-auto=create \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-2/src/main/resources/application.yml b/persistence-modules/spring-boot-persistence-2/src/main/resources/application.yml index 8b13789179..4b792fd5dc 100644 --- a/persistence-modules/spring-boot-persistence-2/src/main/resources/application.yml +++ b/persistence-modules/spring-boot-persistence-2/src/main/resources/application.yml @@ -1 +1,9 @@ - +# Available profiles +# - none for no profile +# - oracle-pooling-basic - Oracle database with HikariCP. Loads configuration from application-oracle-pooling-basic.properties +# - oracle - Uses OracleDataSource. This profile also needs "oracle-pooling-basic" +# - oracle-ucp - Uses PoolDataSource. This profile also needs "oracle-pooling-basic" +# - c3p0 - Uses ComboPooledDataSource. This profile also needs "oracle-pooling-basic" +spring: + profiles: + active: none \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/boot/jdbi/SpringBootJdbiApplicationUnitTest.java b/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/boot/jdbi/SpringBootJdbiApplicationUnitTest.java index e4b623ee2b..93083f6c4c 100644 --- a/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/boot/jdbi/SpringBootJdbiApplicationUnitTest.java +++ b/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/boot/jdbi/SpringBootJdbiApplicationUnitTest.java @@ -5,10 +5,8 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import org.jdbi.v3.core.Jdbi; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -24,7 +22,7 @@ import com.baeldung.boot.jdbi.service.CarMakerService; import lombok.extern.slf4j.Slf4j; @RunWith(SpringRunner.class) -@SpringBootTest +@SpringBootTest(classes = {SpringBootJdbiApplication.class, JdbiConfiguration.class}) @Slf4j public class SpringBootJdbiApplicationUnitTest { diff --git a/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationC3P0LiveTest.java b/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationC3P0LiveTest.java new file mode 100644 index 0000000000..5a2d3f2d29 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationC3P0LiveTest.java @@ -0,0 +1,27 @@ +package com.baeldung.spring.oracle.pooling; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import javax.sql.DataSource; + +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.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = {SpringOraclePoolingApplication.class}) +@ActiveProfiles({"oracle-pooling-basic", "c3p0"}) +public class SpringOraclePoolingApplicationC3P0LiveTest { + + @Autowired + private DataSource dataSource; + + @Test + public void givenC3p0Configuration_thenBuildsComboPooledDataSource() { + assertTrue(dataSource instanceof com.mchange.v2.c3p0.ComboPooledDataSource); + } + +} diff --git a/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationHikariCPLiveTest.java b/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationHikariCPLiveTest.java new file mode 100644 index 0000000000..ab8fc1e121 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationHikariCPLiveTest.java @@ -0,0 +1,27 @@ +package com.baeldung.spring.oracle.pooling; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import javax.sql.DataSource; + +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.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = {SpringOraclePoolingApplication.class}) +@ActiveProfiles("oracle-pooling-basic") +public class SpringOraclePoolingApplicationHikariCPLiveTest { + + @Autowired + private DataSource dataSource; + + @Test + public void givenHikariCPConfiguration_thenBuildsHikariCP() { + assertTrue(dataSource instanceof com.zaxxer.hikari.HikariDataSource); + } + +} diff --git a/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationOracleLiveTest.java b/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationOracleLiveTest.java new file mode 100644 index 0000000000..229375dadd --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationOracleLiveTest.java @@ -0,0 +1,27 @@ +package com.baeldung.spring.oracle.pooling; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import javax.sql.DataSource; + +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.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = {SpringOraclePoolingApplication.class}) +@ActiveProfiles({"oracle-pooling-basic", "oracle"}) +public class SpringOraclePoolingApplicationOracleLiveTest { + + @Autowired + private DataSource dataSource; + + @Test + public void givenOracleConfiguration_thenBuildsOracleDataSource() { + assertTrue(dataSource instanceof oracle.jdbc.pool.OracleDataSource); + } + +} diff --git a/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationOracleUCPLiveTest.java b/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationOracleUCPLiveTest.java new file mode 100644 index 0000000000..4fb6aa6bae --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/test/java/com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationOracleUCPLiveTest.java @@ -0,0 +1,27 @@ +package com.baeldung.spring.oracle.pooling; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import javax.sql.DataSource; + +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.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = {SpringOraclePoolingApplication.class}) +@ActiveProfiles({"oracle-pooling-basic", "oracle-ucp"}) +public class SpringOraclePoolingApplicationOracleUCPLiveTest { + + @Autowired + private DataSource dataSource; + + @Test + public void givenOracleUCPConfiguration_thenBuildsOraclePoolDataSource() { + assertTrue(dataSource instanceof oracle.ucp.jdbc.PoolDataSource); + } + +} From a3c69eba43cd3e32dfa6d78532736a7211e2f824 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sun, 22 Mar 2020 18:36:02 +0100 Subject: [PATCH 089/503] [BAEL-2808] Added tests for physical naming strategies --- .../spring-data-jpa-4/create.sql | 2 + .../default-naming-strategy-ddl.sql | 1 + persistence-modules/spring-data-jpa-4/pom.xml | 5 ++ .../com/baeldung/namingstrategy/Person.java | 36 ++++++++ .../namingstrategy/PersonRepository.java | 6 ++ .../QuotedLowerCaseNamingStrategy.java | 12 +++ ...DataJpaTableAndColumnNamesApplication.java | 7 ++ .../UnquotedLowerCaseNamingStrategy.java | 12 +++ ...owerCaseNamingStrategyIntegrationTest.java | 78 +++++++++++++++++ ...PhysicalNamingStrategyIntegrationTest.java | 82 ++++++++++++++++++ ...owerCaseNamingStrategyIntegrationTest.java | 83 +++++++++++++++++++ ...oted-lower-case-naming-strategy.properties | 9 ++ ...spring-physical-naming-strategy.properties | 9 ++ ...oted-lower-case-naming-strategy.properties | 9 ++ .../upper-case-naming-strategy-ddl.sql | 1 + 15 files changed, 352 insertions(+) create mode 100644 persistence-modules/spring-data-jpa-4/create.sql create mode 100644 persistence-modules/spring-data-jpa-4/default-naming-strategy-ddl.sql create mode 100644 persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/Person.java create mode 100644 persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/PersonRepository.java create mode 100644 persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategy.java create mode 100644 persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/SpringDataJpaTableAndColumnNamesApplication.java create mode 100644 persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategy.java create mode 100644 persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy.properties create mode 100644 persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy.properties create mode 100644 persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy.properties create mode 100644 persistence-modules/spring-data-jpa-4/upper-case-naming-strategy-ddl.sql diff --git a/persistence-modules/spring-data-jpa-4/create.sql b/persistence-modules/spring-data-jpa-4/create.sql new file mode 100644 index 0000000000..1bbe1640a7 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/create.sql @@ -0,0 +1,2 @@ +create table PERSON (ID int8 not null, FIRST_NAME varchar(255), LAST_NAME varchar(255), primary key (ID)) +create table person (id int8 not null, first_name varchar(255), last_name varchar(255), primary key (id)) diff --git a/persistence-modules/spring-data-jpa-4/default-naming-strategy-ddl.sql b/persistence-modules/spring-data-jpa-4/default-naming-strategy-ddl.sql new file mode 100644 index 0000000000..34d5bd1867 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/default-naming-strategy-ddl.sql @@ -0,0 +1 @@ +create table person (id int8 not null, firstname varchar(255), last_name varchar(255), primary key (id)) diff --git a/persistence-modules/spring-data-jpa-4/pom.xml b/persistence-modules/spring-data-jpa-4/pom.xml index 8a476012c7..71fc21527f 100644 --- a/persistence-modules/spring-data-jpa-4/pom.xml +++ b/persistence-modules/spring-data-jpa-4/pom.xml @@ -33,6 +33,11 @@ mysql-connector-java + + org.postgresql + postgresql + + com.h2database h2 diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/Person.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/Person.java new file mode 100644 index 0000000000..c3e7f50403 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/Person.java @@ -0,0 +1,36 @@ +package com.baeldung.namingstrategy; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class Person { + @Id + private Long id; + + @Column(name = "FIRSTNAME") + private String firstName; + + private String lastName; + + public Person() {} + + public Person(Long id, String firstName, String lastName) { + this.id = id; + this.firstName = firstName; + this.lastName = lastName; + } + + public Long id() { + return id; + } + + public String firstName() { + return firstName; + } + + public String lastName() { + return lastName; + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/PersonRepository.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/PersonRepository.java new file mode 100644 index 0000000000..3c7c25bbcb --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/PersonRepository.java @@ -0,0 +1,6 @@ +package com.baeldung.namingstrategy; + +import org.springframework.data.jpa.repository.JpaRepository; + +public interface PersonRepository extends JpaRepository { +} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategy.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategy.java new file mode 100644 index 0000000000..16b01e50e3 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategy.java @@ -0,0 +1,12 @@ +package com.baeldung.namingstrategy; + +import org.hibernate.boot.model.naming.Identifier; +import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; +import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy; + +public class QuotedLowerCaseNamingStrategy extends SpringPhysicalNamingStrategy { + @Override + protected Identifier getIdentifier(String name, boolean quoted, JdbcEnvironment jdbcEnvironment) { + return new Identifier(name.toLowerCase(), true); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/SpringDataJpaTableAndColumnNamesApplication.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/SpringDataJpaTableAndColumnNamesApplication.java new file mode 100644 index 0000000000..09aaf12b60 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/SpringDataJpaTableAndColumnNamesApplication.java @@ -0,0 +1,7 @@ +package com.baeldung.namingstrategy; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringDataJpaTableAndColumnNamesApplication { +} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategy.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategy.java new file mode 100644 index 0000000000..69e96aee27 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategy.java @@ -0,0 +1,12 @@ +package com.baeldung.namingstrategy; + +import org.hibernate.boot.model.naming.Identifier; +import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; +import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy; + +public class UnquotedLowerCaseNamingStrategy extends SpringPhysicalNamingStrategy { + @Override + protected Identifier getIdentifier(String name, boolean quoted, JdbcEnvironment jdbcEnvironment) { + return new Identifier(name.toLowerCase(), false); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyIntegrationTest.java new file mode 100644 index 0000000000..ffa282da72 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyIntegrationTest.java @@ -0,0 +1,78 @@ +package com.baeldung.namingstrategy; + +import org.hibernate.exception.SQLGrammarException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.context.TestPropertySource; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import java.math.BigInteger; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) +@TestPropertySource("quoted-lower-case-naming-strategy.properties") +class QuotedLowerCaseNamingStrategyIntegrationTest { + + @PersistenceContext + private EntityManager entityManager; + + @Autowired + private PersonRepository personRepository; + + @BeforeEach + void insertPeople() { + personRepository.saveAll(Arrays.asList( + new Person(1L, "John", "Doe"), + new Person(2L, "Jane", "Doe"), + new Person(3L, "Ted", "Mosby") + )); + } + + @ParameterizedTest + @ValueSource(strings = {"person", "PERSON", "Person"}) + void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonUnquoted_thenException(String tableName) { + Query query = entityManager.createNativeQuery("select * from " + tableName); + + assertThrows(SQLGrammarException.class, query::getResultStream); + } + + @Test + void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenException() { + Query query = entityManager.createNativeQuery("select * from \"PERSON\""); + + assertThrows(SQLGrammarException.class, query::getResultStream); + } + + @Test + void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenResult() { + Query query = entityManager.createNativeQuery("select * from \"person\""); + + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + public Person fromDatabase(Object databaseRow) { + Object[] typedDatabaseRow = (Object[]) databaseRow; + + return new Person( + ((BigInteger) typedDatabaseRow[0]).longValue(), + (String) typedDatabaseRow[1], + (String) typedDatabaseRow[2] + ); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyIntegrationTest.java new file mode 100644 index 0000000000..8ad59fe2db --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyIntegrationTest.java @@ -0,0 +1,82 @@ +package com.baeldung.namingstrategy; + +import org.hibernate.exception.SQLGrammarException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.context.TestPropertySource; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import java.math.BigInteger; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) +@TestPropertySource("spring-physical-naming-strategy.properties") +class SpringPhysicalNamingStrategyIntegrationTest { + + @PersistenceContext + private EntityManager entityManager; + + @Autowired + private PersonRepository personRepository; + + @BeforeEach + void insertPeople() { + personRepository.saveAll(Arrays.asList( + new Person(1L, "John", "Doe"), + new Person(2L, "Jane", "Doe"), + new Person(3L, "Ted", "Mosby") + )); + } + + @ParameterizedTest + @ValueSource(strings = {"person", "PERSON", "Person"}) + void givenPeopleAndDefaultNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) { + Query query = entityManager.createNativeQuery("select * from " + tableName); + + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + @Test + void givenPeopleAndDefaultNamingStrategyAndH2Database_whenQueryPersonQuotedUpperCase_thenResult() { + Query query = entityManager.createNativeQuery("select * from \"PERSON\""); + + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + @Test + void givenPeopleAndDefaultNamingStrategyAndH2Database_whenQueryPersonQuotedLowerCase_thenException() { + Query query = entityManager.createNativeQuery("select * from \"person\""); + + assertThrows(SQLGrammarException.class, query::getResultStream); + } + + public Person fromDatabase(Object databaseRow) { + Object[] typedDatabaseRow = (Object[]) databaseRow; + + return new Person( + ((BigInteger) typedDatabaseRow[0]).longValue(), + (String) typedDatabaseRow[1], + (String) typedDatabaseRow[2] + ); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyIntegrationTest.java new file mode 100644 index 0000000000..2d84a17526 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyIntegrationTest.java @@ -0,0 +1,83 @@ +package com.baeldung.namingstrategy; + +import org.hibernate.exception.SQLGrammarException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.context.TestPropertySource; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import java.math.BigInteger; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) +@TestPropertySource("unquoted-lower-case-naming-strategy.properties") +class UnquotedLowerCaseNamingStrategyIntegrationTest { + + @PersistenceContext + private EntityManager entityManager; + + @Autowired + private PersonRepository personRepository; + + @BeforeEach + void insertPeople() { + personRepository.saveAll(Arrays.asList( + new Person(1L, "John", "Doe"), + new Person(2L, "Jane", "Doe"), + new Person(3L, "Ted", "Mosby") + )); + } + + @ParameterizedTest + @ValueSource(strings = {"person", "PERSON", "Person"}) + void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonUnquoted_thenException(String tableName) { + Query query = entityManager.createNativeQuery("select * from " + tableName); + + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + @Test + void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenException() { + Query query = entityManager.createNativeQuery("select * from \"PERSON\""); + + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + @Test + void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenResult() { + Query query = entityManager.createNativeQuery("select * from \"person\""); + + assertThrows(SQLGrammarException.class, query::getResultStream); + } + + public Person fromDatabase(Object databaseRow) { + Object[] typedDatabaseRow = (Object[]) databaseRow; + + return new Person( + ((BigInteger) typedDatabaseRow[0]).longValue(), + (String) typedDatabaseRow[1], + (String) typedDatabaseRow[2] + ); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy.properties new file mode 100644 index 0000000000..dce43e2da5 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy.properties @@ -0,0 +1,9 @@ +spring.datasource.url=jdbc:h2:mem:custom-lower-case-strategy +spring.datasource.username=sa +spring.datasource.password= + +spring.jpa.hibernate.ddl-auto=create +spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.QuotedLowerCaseNamingStrategy +#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata +#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create +#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=upper-case-naming-strategy-ddl.sql \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy.properties new file mode 100644 index 0000000000..a8ba1a3e4d --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy.properties @@ -0,0 +1,9 @@ +spring.datasource.url=jdbc:h2:mem:spring-strategy +spring.datasource.username=sa +spring.datasource.password= + +spring.jpa.hibernate.ddl-auto=create +spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy +#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata +#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create +#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=default-naming-strategy-ddl.sql \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy.properties new file mode 100644 index 0000000000..63f400db0b --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy.properties @@ -0,0 +1,9 @@ +spring.datasource.url=jdbc:h2:mem:custom-lower-case-strategy +spring.datasource.username=sa +spring.datasource.password= + +spring.jpa.hibernate.ddl-auto=create +spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.UnquotedLowerCaseNamingStrategy +#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata +#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create +#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=upper-case-naming-strategy-ddl.sql \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-4/upper-case-naming-strategy-ddl.sql b/persistence-modules/spring-data-jpa-4/upper-case-naming-strategy-ddl.sql new file mode 100644 index 0000000000..b26697ac66 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/upper-case-naming-strategy-ddl.sql @@ -0,0 +1 @@ +create table "PERSON" ("ID" int8 not null, "FIRSTNAME" varchar(255), "LAST_NAME" varchar(255), primary key ("ID")) From aebba04be7812a3ba020cfddfbc38da245dca10b Mon Sep 17 00:00:00 2001 From: dupirefr Date: Tue, 24 Mar 2020 08:09:31 +0100 Subject: [PATCH 090/503] [BAEL-2808] Added a few tests to illustrate my problem --- .../QuotedUpperCaseNamingStrategy.java | 12 +++ .../UnquotedUpperCaseNamingStrategy.java | 12 +++ ...rCaseNamingStrategyH2IntegrationTest.java} | 5 +- ...NamingStrategyPostgresIntegrationTest.java | 85 +++++++++++++++++++ ...erCaseNamingStrategyH2IntegrationTest.java | 85 +++++++++++++++++++ ...NamingStrategyPostgresIntegrationTest.java | 81 ++++++++++++++++++ ...sicalNamingStrategyH2IntegrationTest.java} | 11 ++- ...NamingStrategyPostgresIntegrationTest.java | 85 +++++++++++++++++++ ...rCaseNamingStrategyH2IntegrationTest.java} | 11 ++- ...NamingStrategyPostgresIntegrationTest.java | 85 +++++++++++++++++++ ...erCaseNamingStrategyH2IntegrationTest.java | 85 +++++++++++++++++++ ...NamingStrategyPostgresIntegrationTest.java | 85 +++++++++++++++++++ ...ase-naming-strategy-on-postgres.properties | 9 ++ ...oted-lower-case-naming-strategy.properties | 4 +- ...ase-naming-strategy-on-postgres.properties | 9 ++ ...oted-upper-case-naming-strategy.properties | 9 ++ ...cal-naming-strategy-on-postgres.properties | 9 ++ ...spring-physical-naming-strategy.properties | 2 +- ...ase-naming-strategy-on-postgres.properties | 9 ++ ...oted-lower-case-naming-strategy.properties | 4 +- ...ase-naming-strategy-on-postgres.properties | 9 ++ ...oted-upper-case-naming-strategy.properties | 9 ++ 22 files changed, 701 insertions(+), 14 deletions(-) create mode 100644 persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategy.java create mode 100644 persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategy.java rename persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/{QuotedLowerCaseNamingStrategyIntegrationTest.java => QuotedLowerCaseNamingStrategyH2IntegrationTest.java} (95%) create mode 100644 persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyPostgresIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyH2IntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyPostgresIntegrationTest.java rename persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/{SpringPhysicalNamingStrategyIntegrationTest.java => SpringPhysicalNamingStrategyH2IntegrationTest.java} (85%) create mode 100644 persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyPostgresIntegrationTest.java rename persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/{UnquotedLowerCaseNamingStrategyIntegrationTest.java => UnquotedLowerCaseNamingStrategyH2IntegrationTest.java} (91%) create mode 100644 persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyPostgresIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyH2IntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyPostgresIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy-on-postgres.properties create mode 100644 persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-upper-case-naming-strategy-on-postgres.properties create mode 100644 persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-upper-case-naming-strategy.properties create mode 100644 persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy-on-postgres.properties create mode 100644 persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy-on-postgres.properties create mode 100644 persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-upper-case-naming-strategy-on-postgres.properties create mode 100644 persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-upper-case-naming-strategy.properties diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategy.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategy.java new file mode 100644 index 0000000000..3cb62aa5a2 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategy.java @@ -0,0 +1,12 @@ +package com.baeldung.namingstrategy; + +import org.hibernate.boot.model.naming.Identifier; +import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; +import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy; + +public class QuotedUpperCaseNamingStrategy extends SpringPhysicalNamingStrategy { + @Override + protected Identifier getIdentifier(String name, boolean quoted, JdbcEnvironment jdbcEnvironment) { + return new Identifier(name.toUpperCase(), true); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategy.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategy.java new file mode 100644 index 0000000000..cb87af10f4 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategy.java @@ -0,0 +1,12 @@ +package com.baeldung.namingstrategy; + +import org.hibernate.boot.model.naming.Identifier; +import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; +import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy; + +public class UnquotedUpperCaseNamingStrategy extends SpringPhysicalNamingStrategy { + @Override + protected Identifier getIdentifier(String name, boolean quoted, JdbcEnvironment jdbcEnvironment) { + return new Identifier(name.toUpperCase(), false); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyH2IntegrationTest.java similarity index 95% rename from persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyIntegrationTest.java rename to persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyH2IntegrationTest.java index ffa282da72..71a4dbda3f 100644 --- a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyH2IntegrationTest.java @@ -23,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; @DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) @TestPropertySource("quoted-lower-case-naming-strategy.properties") -class QuotedLowerCaseNamingStrategyIntegrationTest { +class QuotedLowerCaseNamingStrategyH2IntegrationTest { @PersistenceContext private EntityManager entityManager; @@ -45,6 +45,7 @@ class QuotedLowerCaseNamingStrategyIntegrationTest { void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonUnquoted_thenException(String tableName) { Query query = entityManager.createNativeQuery("select * from " + tableName); + // Unexpected result assertThrows(SQLGrammarException.class, query::getResultStream); } @@ -52,6 +53,7 @@ class QuotedLowerCaseNamingStrategyIntegrationTest { void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenException() { Query query = entityManager.createNativeQuery("select * from \"PERSON\""); + // Expected result assertThrows(SQLGrammarException.class, query::getResultStream); } @@ -59,6 +61,7 @@ class QuotedLowerCaseNamingStrategyIntegrationTest { void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenResult() { Query query = entityManager.createNativeQuery("select * from \"person\""); + // Expected result List result = (List) query.getResultStream() .map(this::fromDatabase) .collect(Collectors.toList()); diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyPostgresIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyPostgresIntegrationTest.java new file mode 100644 index 0000000000..79c47e86e0 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyPostgresIntegrationTest.java @@ -0,0 +1,85 @@ +package com.baeldung.namingstrategy; + +import org.hibernate.exception.SQLGrammarException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.context.TestPropertySource; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import java.math.BigInteger; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) +@TestPropertySource("quoted-lower-case-naming-strategy-on-postgres.properties") +class QuotedLowerCaseNamingStrategyPostgresIntegrationTest { + + @PersistenceContext + private EntityManager entityManager; + + @Autowired + private PersonRepository personRepository; + + @BeforeEach + void insertPeople() { + personRepository.saveAll(Arrays.asList( + new Person(1L, "John", "Doe"), + new Person(2L, "Jane", "Doe"), + new Person(3L, "Ted", "Mosby") + )); + } + + @ParameterizedTest + @ValueSource(strings = {"person", "PERSON", "Person"}) + void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) { + Query query = entityManager.createNativeQuery("select * from " + tableName); + + // Expected result + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + @Test + void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenException() { + Query query = entityManager.createNativeQuery("select * from \"PERSON\""); + + // Expected result + assertThrows(SQLGrammarException.class, query::getResultStream); + } + + @Test + void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenResult() { + Query query = entityManager.createNativeQuery("select * from \"person\""); + + // Expected result + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + public Person fromDatabase(Object databaseRow) { + Object[] typedDatabaseRow = (Object[]) databaseRow; + + return new Person( + ((BigInteger) typedDatabaseRow[0]).longValue(), + (String) typedDatabaseRow[1], + (String) typedDatabaseRow[2] + ); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyH2IntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyH2IntegrationTest.java new file mode 100644 index 0000000000..f819327a5c --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyH2IntegrationTest.java @@ -0,0 +1,85 @@ +package com.baeldung.namingstrategy; + +import org.hibernate.exception.SQLGrammarException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.context.TestPropertySource; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import java.math.BigInteger; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) +@TestPropertySource("quoted-upper-case-naming-strategy.properties") +class QuotedUpperCaseNamingStrategyH2IntegrationTest { + + @PersistenceContext + private EntityManager entityManager; + + @Autowired + private PersonRepository personRepository; + + @BeforeEach + void insertPeople() { + personRepository.saveAll(Arrays.asList( + new Person(1L, "John", "Doe"), + new Person(2L, "Jane", "Doe"), + new Person(3L, "Ted", "Mosby") + )); + } + + @ParameterizedTest + @ValueSource(strings = {"person", "PERSON", "Person"}) + void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonUnquoted_thenException(String tableName) { + Query query = entityManager.createNativeQuery("select * from " + tableName); + + // Expected result + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + @Test + void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenResult() { + Query query = entityManager.createNativeQuery("select * from \"PERSON\""); + + // Expected result + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + @Test + void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenException() { + Query query = entityManager.createNativeQuery("select * from \"person\""); + + // Expected result + assertThrows(SQLGrammarException.class, query::getResultStream); + } + + public Person fromDatabase(Object databaseRow) { + Object[] typedDatabaseRow = (Object[]) databaseRow; + + return new Person( + ((BigInteger) typedDatabaseRow[0]).longValue(), + (String) typedDatabaseRow[1], + (String) typedDatabaseRow[2] + ); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyPostgresIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyPostgresIntegrationTest.java new file mode 100644 index 0000000000..20250a7ecb --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyPostgresIntegrationTest.java @@ -0,0 +1,81 @@ +package com.baeldung.namingstrategy; + +import org.hibernate.exception.SQLGrammarException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.context.TestPropertySource; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import java.math.BigInteger; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) +@TestPropertySource("quoted-upper-case-naming-strategy-on-postgres.properties") +class QuotedUpperCaseNamingStrategyPostgresIntegrationTest { + + @PersistenceContext + private EntityManager entityManager; + + @Autowired + private PersonRepository personRepository; + + @BeforeEach + void insertPeople() { + personRepository.saveAll(Arrays.asList( + new Person(1L, "John", "Doe"), + new Person(2L, "Jane", "Doe"), + new Person(3L, "Ted", "Mosby") + )); + } + + @ParameterizedTest + @ValueSource(strings = {"person", "PERSON", "Person"}) + void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) { + Query query = entityManager.createNativeQuery("select * from " + tableName); + + // Unexpected result + assertThrows(SQLGrammarException.class, query::getResultStream); + } + + @Test + void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenException() { + Query query = entityManager.createNativeQuery("select * from \"PERSON\""); + + // Expected result + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + @Test + void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenResult() { + Query query = entityManager.createNativeQuery("select * from \"person\""); + + // Expected result + assertThrows(SQLGrammarException.class, query::getResultStream); + } + + public Person fromDatabase(Object databaseRow) { + Object[] typedDatabaseRow = (Object[]) databaseRow; + + return new Person( + ((BigInteger) typedDatabaseRow[0]).longValue(), + (String) typedDatabaseRow[1], + (String) typedDatabaseRow[2] + ); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyH2IntegrationTest.java similarity index 85% rename from persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyIntegrationTest.java rename to persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyH2IntegrationTest.java index 8ad59fe2db..1850fea173 100644 --- a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyH2IntegrationTest.java @@ -23,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; @DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) @TestPropertySource("spring-physical-naming-strategy.properties") -class SpringPhysicalNamingStrategyIntegrationTest { +class SpringPhysicalNamingStrategyH2IntegrationTest { @PersistenceContext private EntityManager entityManager; @@ -42,9 +42,10 @@ class SpringPhysicalNamingStrategyIntegrationTest { @ParameterizedTest @ValueSource(strings = {"person", "PERSON", "Person"}) - void givenPeopleAndDefaultNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) { + void givenPeopleAndSpringNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) { Query query = entityManager.createNativeQuery("select * from " + tableName); + // Expected result List result = (List) query.getResultStream() .map(this::fromDatabase) .collect(Collectors.toList()); @@ -53,9 +54,10 @@ class SpringPhysicalNamingStrategyIntegrationTest { } @Test - void givenPeopleAndDefaultNamingStrategyAndH2Database_whenQueryPersonQuotedUpperCase_thenResult() { + void givenPeopleAndSpringNamingStrategy_whenQueryPersonQuotedUpperCase_thenResult() { Query query = entityManager.createNativeQuery("select * from \"PERSON\""); + // Unexpected result List result = (List) query.getResultStream() .map(this::fromDatabase) .collect(Collectors.toList()); @@ -64,9 +66,10 @@ class SpringPhysicalNamingStrategyIntegrationTest { } @Test - void givenPeopleAndDefaultNamingStrategyAndH2Database_whenQueryPersonQuotedLowerCase_thenException() { + void givenPeopleAndSpringNamingStrategy_whenQueryPersonQuotedLowerCase_thenException() { Query query = entityManager.createNativeQuery("select * from \"person\""); + // Unexpected result assertThrows(SQLGrammarException.class, query::getResultStream); } diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyPostgresIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyPostgresIntegrationTest.java new file mode 100644 index 0000000000..97f2b601b0 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyPostgresIntegrationTest.java @@ -0,0 +1,85 @@ +package com.baeldung.namingstrategy; + +import org.hibernate.exception.SQLGrammarException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.context.TestPropertySource; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import java.math.BigInteger; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) +@TestPropertySource("spring-physical-naming-strategy-on-postgres.properties") +class SpringPhysicalNamingStrategyPostgresIntegrationTest { + + @PersistenceContext + private EntityManager entityManager; + + @Autowired + private PersonRepository personRepository; + + @BeforeEach + void insertPeople() { + personRepository.saveAll(Arrays.asList( + new Person(1L, "John", "Doe"), + new Person(2L, "Jane", "Doe"), + new Person(3L, "Ted", "Mosby") + )); + } + + @ParameterizedTest + @ValueSource(strings = {"person", "PERSON", "Person"}) + void givenPeopleAndSpringNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) { + Query query = entityManager.createNativeQuery("select * from " + tableName); + + // Expected result + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + @Test + void givenPeopleAndSpringNamingStrategy_whenQueryPersonQuotedUpperCase_thenException() { + Query query = entityManager.createNativeQuery("select * from \"PERSON\""); + + // Expected result + assertThrows(SQLGrammarException.class, query::getResultStream); + } + + @Test + void givenPeopleAndSpringNamingStrategy_whenQueryPersonQuotedLowerCase_thenResult() { + Query query = entityManager.createNativeQuery("select * from \"person\""); + + // Expected result + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + public Person fromDatabase(Object databaseRow) { + Object[] typedDatabaseRow = (Object[]) databaseRow; + + return new Person( + ((BigInteger) typedDatabaseRow[0]).longValue(), + (String) typedDatabaseRow[1], + (String) typedDatabaseRow[2] + ); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyH2IntegrationTest.java similarity index 91% rename from persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyIntegrationTest.java rename to persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyH2IntegrationTest.java index 2d84a17526..6311c42e93 100644 --- a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyH2IntegrationTest.java @@ -24,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; @DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) @TestPropertySource("unquoted-lower-case-naming-strategy.properties") -class UnquotedLowerCaseNamingStrategyIntegrationTest { +class UnquotedLowerCaseNamingStrategyH2IntegrationTest { @PersistenceContext private EntityManager entityManager; @@ -43,9 +43,10 @@ class UnquotedLowerCaseNamingStrategyIntegrationTest { @ParameterizedTest @ValueSource(strings = {"person", "PERSON", "Person"}) - void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonUnquoted_thenException(String tableName) { + void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) { Query query = entityManager.createNativeQuery("select * from " + tableName); + // Expected result List result = (List) query.getResultStream() .map(this::fromDatabase) .collect(Collectors.toList()); @@ -54,9 +55,10 @@ class UnquotedLowerCaseNamingStrategyIntegrationTest { } @Test - void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenException() { + void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenResult() { Query query = entityManager.createNativeQuery("select * from \"PERSON\""); + // Unexpected result List result = (List) query.getResultStream() .map(this::fromDatabase) .collect(Collectors.toList()); @@ -65,9 +67,10 @@ class UnquotedLowerCaseNamingStrategyIntegrationTest { } @Test - void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenResult() { + void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenException() { Query query = entityManager.createNativeQuery("select * from \"person\""); + // Unexpected result assertThrows(SQLGrammarException.class, query::getResultStream); } diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyPostgresIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyPostgresIntegrationTest.java new file mode 100644 index 0000000000..4e1d69ccdb --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyPostgresIntegrationTest.java @@ -0,0 +1,85 @@ +package com.baeldung.namingstrategy; + +import org.hibernate.exception.SQLGrammarException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.context.TestPropertySource; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import java.math.BigInteger; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) +@TestPropertySource("unquoted-lower-case-naming-strategy-on-postgres.properties") +class UnquotedLowerCaseNamingStrategyPostgresIntegrationTest { + + @PersistenceContext + private EntityManager entityManager; + + @Autowired + private PersonRepository personRepository; + + @BeforeEach + void insertPeople() { + personRepository.saveAll(Arrays.asList( + new Person(1L, "John", "Doe"), + new Person(2L, "Jane", "Doe"), + new Person(3L, "Ted", "Mosby") + )); + } + + @ParameterizedTest + @ValueSource(strings = {"person", "PERSON", "Person"}) + void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) { + Query query = entityManager.createNativeQuery("select * from " + tableName); + + // Expected result + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + @Test + void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenException() { + Query query = entityManager.createNativeQuery("select * from \"PERSON\""); + + // Expected result + assertThrows(SQLGrammarException.class, query::getResultStream); + } + + @Test + void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenResult() { + Query query = entityManager.createNativeQuery("select * from \"person\""); + + // Expected result + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + public Person fromDatabase(Object databaseRow) { + Object[] typedDatabaseRow = (Object[]) databaseRow; + + return new Person( + ((BigInteger) typedDatabaseRow[0]).longValue(), + (String) typedDatabaseRow[1], + (String) typedDatabaseRow[2] + ); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyH2IntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyH2IntegrationTest.java new file mode 100644 index 0000000000..7af8001854 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyH2IntegrationTest.java @@ -0,0 +1,85 @@ +package com.baeldung.namingstrategy; + +import org.hibernate.exception.SQLGrammarException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.context.TestPropertySource; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import java.math.BigInteger; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) +@TestPropertySource("unquoted-upper-case-naming-strategy.properties") +class UnquotedUpperCaseNamingStrategyH2IntegrationTest { + + @PersistenceContext + private EntityManager entityManager; + + @Autowired + private PersonRepository personRepository; + + @BeforeEach + void insertPeople() { + personRepository.saveAll(Arrays.asList( + new Person(1L, "John", "Doe"), + new Person(2L, "Jane", "Doe"), + new Person(3L, "Ted", "Mosby") + )); + } + + @ParameterizedTest + @ValueSource(strings = {"person", "PERSON", "Person"}) + void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) { + Query query = entityManager.createNativeQuery("select * from " + tableName); + + // Expected result + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + @Test + void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenResult() { + Query query = entityManager.createNativeQuery("select * from \"PERSON\""); + + // Expected result + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + @Test + void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenException() { + Query query = entityManager.createNativeQuery("select * from \"person\""); + + // Expected result + assertThrows(SQLGrammarException.class, query::getResultStream); + } + + public Person fromDatabase(Object databaseRow) { + Object[] typedDatabaseRow = (Object[]) databaseRow; + + return new Person( + ((BigInteger) typedDatabaseRow[0]).longValue(), + (String) typedDatabaseRow[1], + (String) typedDatabaseRow[2] + ); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyPostgresIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyPostgresIntegrationTest.java new file mode 100644 index 0000000000..0fdb05b0ee --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyPostgresIntegrationTest.java @@ -0,0 +1,85 @@ +package com.baeldung.namingstrategy; + +import org.hibernate.exception.SQLGrammarException; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.test.context.TestPropertySource; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.Query; +import java.math.BigInteger; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertThrows; + +@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) +@TestPropertySource("unquoted-upper-case-naming-strategy-on-postgres.properties") +class UnquotedUpperCaseNamingStrategyPostgresIntegrationTest { + + @PersistenceContext + private EntityManager entityManager; + + @Autowired + private PersonRepository personRepository; + + @BeforeEach + void insertPeople() { + personRepository.saveAll(Arrays.asList( + new Person(1L, "John", "Doe"), + new Person(2L, "Jane", "Doe"), + new Person(3L, "Ted", "Mosby") + )); + } + + @ParameterizedTest + @ValueSource(strings = {"person", "PERSON", "Person"}) + void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) { + Query query = entityManager.createNativeQuery("select * from " + tableName); + + // Expected result + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + @Test + void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenException() { + Query query = entityManager.createNativeQuery("select * from \"PERSON\""); + + // Unexpected result + assertThrows(SQLGrammarException.class, query::getResultStream); + } + + @Test + void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenResult() { + Query query = entityManager.createNativeQuery("select * from \"person\""); + + // Unexpected result + List result = (List) query.getResultStream() + .map(this::fromDatabase) + .collect(Collectors.toList()); + + assertThat(result).isNotEmpty(); + } + + public Person fromDatabase(Object databaseRow) { + Object[] typedDatabaseRow = (Object[]) databaseRow; + + return new Person( + ((BigInteger) typedDatabaseRow[0]).longValue(), + (String) typedDatabaseRow[1], + (String) typedDatabaseRow[2] + ); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy-on-postgres.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy-on-postgres.properties new file mode 100644 index 0000000000..04b29de41f --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy-on-postgres.properties @@ -0,0 +1,9 @@ +spring.datasource.url=jdbc:postgresql://localhost:5432/quoted-lower-case-strategy +spring.datasource.username=postgres +spring.datasource.password=root + +spring.jpa.hibernate.ddl-auto=create-drop +spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.QuotedLowerCaseNamingStrategy +#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata +#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create +#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=upper-case-naming-strategy-ddl.sql \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy.properties index dce43e2da5..6643c12c8a 100644 --- a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy.properties +++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy.properties @@ -1,8 +1,8 @@ -spring.datasource.url=jdbc:h2:mem:custom-lower-case-strategy +spring.datasource.url=jdbc:h2:mem:quoted-lower-case-strategy spring.datasource.username=sa spring.datasource.password= -spring.jpa.hibernate.ddl-auto=create +spring.jpa.hibernate.ddl-auto=create-drop spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.QuotedLowerCaseNamingStrategy #spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata #spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-upper-case-naming-strategy-on-postgres.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-upper-case-naming-strategy-on-postgres.properties new file mode 100644 index 0000000000..36898d5b4f --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-upper-case-naming-strategy-on-postgres.properties @@ -0,0 +1,9 @@ +spring.datasource.url=jdbc:postgresql://localhost:5432/quoted-upper-case-strategy +spring.datasource.username=postgres +spring.datasource.password=root + +spring.jpa.hibernate.ddl-auto=create-drop +spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.QuotedUpperCaseNamingStrategy +#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata +#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create +#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=upper-case-naming-strategy-ddl.sql \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-upper-case-naming-strategy.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-upper-case-naming-strategy.properties new file mode 100644 index 0000000000..6d56d58749 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-upper-case-naming-strategy.properties @@ -0,0 +1,9 @@ +spring.datasource.url=jdbc:h2:mem:quoted-upper-case-strategy +spring.datasource.username=sa +spring.datasource.password= + +spring.jpa.hibernate.ddl-auto=create-drop +spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.QuotedUpperCaseNamingStrategy +#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata +#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create +#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=upper-case-naming-strategy-ddl.sql \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy-on-postgres.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy-on-postgres.properties new file mode 100644 index 0000000000..706b12b1b6 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy-on-postgres.properties @@ -0,0 +1,9 @@ +spring.datasource.url=jdbc:postgresql://localhost:5432/spring-strategy +spring.datasource.username=postgres +spring.datasource.password=root + +spring.jpa.hibernate.ddl-auto=create-drop +spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy +#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata +#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create +#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=default-naming-strategy-ddl.sql \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy.properties index a8ba1a3e4d..c9a0c6f24c 100644 --- a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy.properties +++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy.properties @@ -2,7 +2,7 @@ spring.datasource.url=jdbc:h2:mem:spring-strategy spring.datasource.username=sa spring.datasource.password= -spring.jpa.hibernate.ddl-auto=create +spring.jpa.hibernate.ddl-auto=create-drop spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy #spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata #spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy-on-postgres.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy-on-postgres.properties new file mode 100644 index 0000000000..b22472bd8f --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy-on-postgres.properties @@ -0,0 +1,9 @@ +spring.datasource.url=jdbc:postgresql://localhost:5432/unquoted-lower-case-strategy +spring.datasource.username=postgres +spring.datasource.password=root + +spring.jpa.hibernate.ddl-auto=create-drop +spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.UnquotedLowerCaseNamingStrategy +#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata +#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create +#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=upper-case-naming-strategy-ddl.sql \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy.properties index 63f400db0b..8083515b4b 100644 --- a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy.properties +++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy.properties @@ -1,8 +1,8 @@ -spring.datasource.url=jdbc:h2:mem:custom-lower-case-strategy +spring.datasource.url=jdbc:h2:mem:unquoted-lower-case-strategy spring.datasource.username=sa spring.datasource.password= -spring.jpa.hibernate.ddl-auto=create +spring.jpa.hibernate.ddl-auto=create-drop spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.UnquotedLowerCaseNamingStrategy #spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata #spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-upper-case-naming-strategy-on-postgres.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-upper-case-naming-strategy-on-postgres.properties new file mode 100644 index 0000000000..da03a0d7b5 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-upper-case-naming-strategy-on-postgres.properties @@ -0,0 +1,9 @@ +spring.datasource.url=jdbc:postgresql://localhost:5432/unquoted-upper-case-strategy +spring.datasource.username=postgres +spring.datasource.password=root + +spring.jpa.hibernate.ddl-auto=create-drop +spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.UnquotedUpperCaseNamingStrategy +#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata +#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create +#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=upper-case-naming-strategy-ddl.sql \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-upper-case-naming-strategy.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-upper-case-naming-strategy.properties new file mode 100644 index 0000000000..d1b63e008c --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-upper-case-naming-strategy.properties @@ -0,0 +1,9 @@ +spring.datasource.url=jdbc:h2:mem:unquoted-upper-case-strategy +spring.datasource.username=sa +spring.datasource.password= + +spring.jpa.hibernate.ddl-auto=create-drop +spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.UnquotedUpperCaseNamingStrategy +#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata +#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create +#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=upper-case-naming-strategy-ddl.sql \ No newline at end of file From daab2b383ff6059a9a64af89300e3adc2ae1d743 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Wed, 1 Apr 2020 23:10:07 +0200 Subject: [PATCH 091/503] [BAEL-2808] Last fix --- .../spring-data-jpa-4/default-naming-strategy-ddl.sql | 1 - .../src/main/java/com/baeldung/namingstrategy/Person.java | 1 - .../spring-data-jpa-4/upper-case-naming-strategy-ddl.sql | 1 - 3 files changed, 3 deletions(-) delete mode 100644 persistence-modules/spring-data-jpa-4/default-naming-strategy-ddl.sql delete mode 100644 persistence-modules/spring-data-jpa-4/upper-case-naming-strategy-ddl.sql diff --git a/persistence-modules/spring-data-jpa-4/default-naming-strategy-ddl.sql b/persistence-modules/spring-data-jpa-4/default-naming-strategy-ddl.sql deleted file mode 100644 index 34d5bd1867..0000000000 --- a/persistence-modules/spring-data-jpa-4/default-naming-strategy-ddl.sql +++ /dev/null @@ -1 +0,0 @@ -create table person (id int8 not null, firstname varchar(255), last_name varchar(255), primary key (id)) diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/Person.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/Person.java index c3e7f50403..cfb6e67c2c 100644 --- a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/Person.java +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/Person.java @@ -9,7 +9,6 @@ public class Person { @Id private Long id; - @Column(name = "FIRSTNAME") private String firstName; private String lastName; diff --git a/persistence-modules/spring-data-jpa-4/upper-case-naming-strategy-ddl.sql b/persistence-modules/spring-data-jpa-4/upper-case-naming-strategy-ddl.sql deleted file mode 100644 index b26697ac66..0000000000 --- a/persistence-modules/spring-data-jpa-4/upper-case-naming-strategy-ddl.sql +++ /dev/null @@ -1 +0,0 @@ -create table "PERSON" ("ID" int8 not null, "FIRSTNAME" varchar(255), "LAST_NAME" varchar(255), primary key ("ID")) From c73b8dbf724d4fe5bc2a3f4b5ffbb424b4747c22 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sun, 5 Apr 2020 16:16:27 +0200 Subject: [PATCH 092/503] [BAEL-2808] Migrated PostgreSQL tests to LiveTest --- ...ation.java => SpringDataJpaNamingConventionApplication.java} | 2 +- ....java => QuotedLowerCaseNamingStrategyPostgresLiveTest.java} | 2 +- ....java => QuotedUpperCaseNamingStrategyPostgresLiveTest.java} | 2 +- ...t.java => SpringPhysicalNamingStrategyPostgresLiveTest.java} | 2 +- ...ava => UnquotedLowerCaseNamingStrategyPostgresLiveTest.java} | 2 +- ...ava => UnquotedUpperCaseNamingStrategyPostgresLiveTest.java} | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) rename persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/{SpringDataJpaTableAndColumnNamesApplication.java => SpringDataJpaNamingConventionApplication.java} (69%) rename persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/{QuotedLowerCaseNamingStrategyPostgresIntegrationTest.java => QuotedLowerCaseNamingStrategyPostgresLiveTest.java} (97%) rename persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/{QuotedUpperCaseNamingStrategyPostgresIntegrationTest.java => QuotedUpperCaseNamingStrategyPostgresLiveTest.java} (97%) rename persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/{SpringPhysicalNamingStrategyPostgresIntegrationTest.java => SpringPhysicalNamingStrategyPostgresLiveTest.java} (97%) rename persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/{UnquotedLowerCaseNamingStrategyPostgresIntegrationTest.java => UnquotedLowerCaseNamingStrategyPostgresLiveTest.java} (97%) rename persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/{UnquotedUpperCaseNamingStrategyPostgresIntegrationTest.java => UnquotedUpperCaseNamingStrategyPostgresLiveTest.java} (97%) diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/SpringDataJpaTableAndColumnNamesApplication.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/SpringDataJpaNamingConventionApplication.java similarity index 69% rename from persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/SpringDataJpaTableAndColumnNamesApplication.java rename to persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/SpringDataJpaNamingConventionApplication.java index 09aaf12b60..f223015db8 100644 --- a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/SpringDataJpaTableAndColumnNamesApplication.java +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/SpringDataJpaNamingConventionApplication.java @@ -3,5 +3,5 @@ package com.baeldung.namingstrategy; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class SpringDataJpaTableAndColumnNamesApplication { +public class SpringDataJpaNamingConventionApplication { } diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyPostgresIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyPostgresLiveTest.java similarity index 97% rename from persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyPostgresIntegrationTest.java rename to persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyPostgresLiveTest.java index 79c47e86e0..6b1c984600 100644 --- a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyPostgresIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyPostgresLiveTest.java @@ -23,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; @DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) @TestPropertySource("quoted-lower-case-naming-strategy-on-postgres.properties") -class QuotedLowerCaseNamingStrategyPostgresIntegrationTest { +class QuotedLowerCaseNamingStrategyPostgresLiveTest { @PersistenceContext private EntityManager entityManager; diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyPostgresIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyPostgresLiveTest.java similarity index 97% rename from persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyPostgresIntegrationTest.java rename to persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyPostgresLiveTest.java index 20250a7ecb..bd23b81b4b 100644 --- a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyPostgresIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyPostgresLiveTest.java @@ -23,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; @DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) @TestPropertySource("quoted-upper-case-naming-strategy-on-postgres.properties") -class QuotedUpperCaseNamingStrategyPostgresIntegrationTest { +class QuotedUpperCaseNamingStrategyPostgresLiveTest { @PersistenceContext private EntityManager entityManager; diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyPostgresIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyPostgresLiveTest.java similarity index 97% rename from persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyPostgresIntegrationTest.java rename to persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyPostgresLiveTest.java index 97f2b601b0..e26ebb148d 100644 --- a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyPostgresIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyPostgresLiveTest.java @@ -23,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; @DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) @TestPropertySource("spring-physical-naming-strategy-on-postgres.properties") -class SpringPhysicalNamingStrategyPostgresIntegrationTest { +class SpringPhysicalNamingStrategyPostgresLiveTest { @PersistenceContext private EntityManager entityManager; diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyPostgresIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyPostgresLiveTest.java similarity index 97% rename from persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyPostgresIntegrationTest.java rename to persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyPostgresLiveTest.java index 4e1d69ccdb..033a213cf5 100644 --- a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyPostgresIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyPostgresLiveTest.java @@ -23,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; @DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) @TestPropertySource("unquoted-lower-case-naming-strategy-on-postgres.properties") -class UnquotedLowerCaseNamingStrategyPostgresIntegrationTest { +class UnquotedLowerCaseNamingStrategyPostgresLiveTest { @PersistenceContext private EntityManager entityManager; diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyPostgresIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyPostgresLiveTest.java similarity index 97% rename from persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyPostgresIntegrationTest.java rename to persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyPostgresLiveTest.java index 0fdb05b0ee..0151e7ece4 100644 --- a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyPostgresIntegrationTest.java +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyPostgresLiveTest.java @@ -23,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; @DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class) @TestPropertySource("unquoted-upper-case-naming-strategy-on-postgres.properties") -class UnquotedUpperCaseNamingStrategyPostgresIntegrationTest { +class UnquotedUpperCaseNamingStrategyPostgresLiveTest { @PersistenceContext private EntityManager entityManager; From b2bc2dca8f3651e54edf7e62c8be87601ba1bd92 Mon Sep 17 00:00:00 2001 From: Aitor Cuesta Date: Sun, 5 Apr 2020 17:10:49 +0200 Subject: [PATCH 093/503] BAEL-3075 - Adding ojdbc8.jar, ons.jar and ucp.jar --- .../spring-boot-persistence-2/lib/ons.jar | Bin 0 -> 139977 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 persistence-modules/spring-boot-persistence-2/lib/ons.jar diff --git a/persistence-modules/spring-boot-persistence-2/lib/ons.jar b/persistence-modules/spring-boot-persistence-2/lib/ons.jar new file mode 100644 index 0000000000000000000000000000000000000000..637cf11887b54ddf4d567b7251ee51a18d235af7 GIT binary patch literal 139977 zcmbrmW0Ymvk~W;Kw9QJ}cBO6Gww+mN+qP}nwpD3orHwbwJ@Wj4eYaoA({~(p(lNJ*eQc$Fk5|)aph4rID7J4Lk502uv3tav#%wovEhaM7C zNq&!z9+QNO`nh#F;4X97d1T#@Zo0W2zkBLO3(7yFcHkn`i2h0vTL&`Dt0}^O)wzGK z0O{lhHHP3|cbr$t7|Jm~ELdN76I(wN!IYe5;SmXmY#4*<=wN{d3@ubu`$G{tMGx~5 zt^oNxGNu=lSZ|G3|LT9CC zt!H9nWn}I6Z>C`WPg87ct*rmeJmP;l&&=A<$i!aH(Z>GYECKbOOW0WdJGS8dN@#Cu z@NZWA!yx`Ct3Ou#gV@Z<*7D!X_}lUhwr2l9{HMKn%OV%leJy+cHMstB`7c%c7ZLwM zUjKz}0UIk@8|yFO3+P!|^6ME`&=^?iIXD4mN^kC`0&!BCg zdp1zQo30Aiyiz)ewtXr7^nGW~#M5YRrP#QBdLSu$G-_u1lvq^_Hxphs6qWRTcN`N* zCB+PfV1hT(lLgd6y0FALLisZ#pOzR#)11!7tnUhK4Idt}Bv?IwMEyRtAO1 zr!3kEW`mP}0RY~?zMi}Ptt@1|Y)R}tOoB+(%-TfW$j-^g!BNu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P+|bKtW-FK|3%1 z27S337yYomb2{*IKqe9PyP< z|B~_^354XG0L>l)a2=|1K;SdmUzp@d%=2!5^>RL`IFD8K08RP&a-|)6j=^{vjp7Wdhh|J zRKc3hh0zsEoLqrI4OcbE(tw8~Mt~mDfY!tRH;-q!HRJtPOrUlK;IHPt8Yz%xI9{y| zW4Qn+c))$b0V4{65h54<4}{Fl_AEL4v)x`zsxGFV0S+J)0+0fiDOlt`kg~CJIUg?m zwOi(DLPODuZ@huQaX2%iiI>FxjnL&LCP;(Q^#x*f1K{qIU|P!2xe^g5qh@d7;B-af z_H5l(F9p2(2hg%H!640a!61P*jF&T&5fqn`4d^o(&?g-jf+R2x{|~m<+vMRV&Xl3BXcW5ri<)$f5g2U&LX`5eH&m;56~ZY6cb8-g!`9>Gso(dX$oX) z<3Rfbhq44--~Cf!V3PS~h`nl52zdtex&E^Kk)DG=U2!5cWUPifV)+8k3z%j22W!9Z zuHp;w^wJ9)i(D|AUwg+c&N7AM2=ds<3#7VyaHR90+rK6Lkf$P$L19Cg`1un%L817}8qam4u+=hGs zcJL>#KfjcN-0ynrT z^y|Ic#l9v;T|#b;x{o+AF4esNb=mzF(5nZWkgJz2Kwln#fnKtf2~ujv zbwL+cg~z{PUA9UH5)g9f%>`iM$rXUVh7Xr}5aeQ&3%r`s-|!%&U(OL>fMf~^$`bew OhYSiT6$(iBp#BHktRXf4 literal 0 HcmV?d00001 From b30ee628059d55773e18420d9ed8df9f079678eb Mon Sep 17 00:00:00 2001 From: Belma Jakupovic Date: Mon, 6 Apr 2020 20:22:28 +0200 Subject: [PATCH 094/503] Belma Jakupovic - Mockito additional answers (#9041) --- .../mockito/additionalanswers/Book.java | 58 ++++++++++++++++ .../additionalanswers/BookRepository.java | 17 +++++ .../additionalanswers/BookService.java | 22 ++++++ .../BookServiceUnitTest.java | 68 +++++++++++++++++++ 4 files changed, 165 insertions(+) create mode 100644 testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/Book.java create mode 100644 testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookRepository.java create mode 100644 testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookService.java create mode 100644 testing-modules/mockito-2/src/test/java/com/baeldung/mockito/additionalanswers/BookServiceUnitTest.java diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/Book.java b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/Book.java new file mode 100644 index 0000000000..fa021f8cba --- /dev/null +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/Book.java @@ -0,0 +1,58 @@ +package com.baeldung.mockito.additionalanswers; + +public class Book { + + private Long bookId; + + private String title; + + private String author; + + private int numberOfPages; + + public Book(String title, String author, int numberOfPages) { + this.title = title; + this.author = author; + this.numberOfPages = numberOfPages; + } + + public Book(Long bookId, String title, String author, int numberOfPages) { + this.bookId = bookId; + this.title = title; + this.author = author; + this.numberOfPages = numberOfPages; + } + + public Long getBookId() { + return bookId; + } + + public void setBookId(Long bookId) { + this.bookId = bookId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + + public int getNumberOfPages() { + return numberOfPages; + } + + public void setNumberOfPages(int numberOfPages) { + this.numberOfPages = numberOfPages; + } +} + diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookRepository.java b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookRepository.java new file mode 100644 index 0000000000..78187e3f01 --- /dev/null +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookRepository.java @@ -0,0 +1,17 @@ +package com.baeldung.mockito.additionalanswers; + +public class BookRepository { + public Book getByBookId(Long bookId) { + return new Book(bookId, "To Kill a Mocking Bird", "Harper Lee", 256); + } + + public Book save(Book book) { + return new Book(book.getBookId(), book.getTitle(), book.getAuthor(), book.getNumberOfPages()); + } + + public Book checkIfEquals(Book bookOne, Book bookTwo, Book bookThree) { + if (bookOne.equals(bookTwo) && bookTwo.equals(bookThree) && bookThree.equals(bookOne)) { + return bookOne; + } else return bookTwo; + } +} diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookService.java b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookService.java new file mode 100644 index 0000000000..92c01f8a70 --- /dev/null +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookService.java @@ -0,0 +1,22 @@ +package com.baeldung.mockito.additionalanswers; + +public class BookService { + private final BookRepository bookRepository; + + public BookService(BookRepository bookRepository) { + this.bookRepository = bookRepository; + } + + public Book getByBookId(Long id) { + return bookRepository.getByBookId(id); + } + + public Book save(Book book) { + return bookRepository.save(book); + } + + public Book checkifEquals(Book book1, Book book2, Book book3) { + return bookRepository.checkIfEquals(book1, book2, book3); + } +} + diff --git a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/additionalanswers/BookServiceUnitTest.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/additionalanswers/BookServiceUnitTest.java new file mode 100644 index 0000000000..c9527ec0ec --- /dev/null +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/additionalanswers/BookServiceUnitTest.java @@ -0,0 +1,68 @@ +package com.baeldung.mockito.additionalanswers; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.AdditionalAnswers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; + +@RunWith(MockitoJUnitRunner.class) +public class BookServiceUnitTest { + @InjectMocks + private BookService bookService; + + @Mock + private BookRepository bookRepository; + + @Test + public void givenSaveMethodMocked_whenSaveInvoked_ThenReturnFirstArgument_UnitTest() { + Book book = new Book("To Kill a Mocking Bird", "Harper Lee", 256); + Mockito.when(bookRepository.save(any(Book.class))).then(AdditionalAnswers.returnsFirstArg()); + + Book savedBook = bookService.save(book); + + assertEquals(savedBook, book); + } + + @Test + public void givenCheckifEqualsMethodMocked_whenCheckifEqualsInvoked_ThenReturnSecondArgument_UnitTest() { + Book book1 = new Book(1L, "The Stranger", "Albert Camus", 456); + Book book2 = new Book(2L, "Animal Farm", "George Orwell", 300); + Book book3 = new Book(3L, "Romeo and Juliet", "William Shakespeare", 200); + + Mockito.when(bookRepository.checkIfEquals(any(Book.class), any(Book.class), any(Book.class))).then(AdditionalAnswers.returnsSecondArg()); + + Book secondBook = bookService.checkifEquals(book1, book2, book3); + + assertEquals(secondBook, book2); + } + + @Test + public void givenCheckifEqualsMethodMocked_whenCheckifEqualsInvoked_ThenReturnLastArgument_UnitTest() { + Book book1 = new Book(1L, "The Stranger", "Albert Camus", 456); + Book book2 = new Book(2L, "Animal Farm", "George Orwell", 300); + Book book3 = new Book(3L, "Romeo and Juliet", "William Shakespeare", 200); + + Mockito.when(bookRepository.checkIfEquals(any(Book.class), any(Book.class), any(Book.class))).then(AdditionalAnswers.returnsLastArg()); + + Book lastBook = bookService.checkifEquals(book1, book2, book3); + assertEquals(lastBook, book3); + } + + @Test + public void givenCheckifEqualsMethodMocked_whenCheckifEqualsInvoked_ThenReturnArgumentAtIndex_UnitTest() { + Book book1 = new Book(1L, "The Stranger", "Albert Camus", 456); + Book book2 = new Book(2L, "Animal Farm", "George Orwell", 300); + Book book3 = new Book(3L, "Romeo and Juliet", "William Shakespeare", 200); + + Mockito.when(bookRepository.checkIfEquals(any(Book.class), any(Book.class), any(Book.class))).then(AdditionalAnswers.returnsArgAt(1)); + + Book bookOnIndex = bookService.checkifEquals(book1, book2, book3); + + assertEquals(bookOnIndex, book2); + } +} From ab6fee6012ba5ab83ab4263ea3a53a771b4f7ecf Mon Sep 17 00:00:00 2001 From: Jonathan Cook Date: Mon, 6 Apr 2020 22:21:24 +0200 Subject: [PATCH 095/503] BAEL-3868 - Fix the integrations tests in mocks (#9039) * BAEL-3491 - Check for null before calling parse in the Double.parseDouble * BAEL-3491 - Check for null before calling parse in the Double.parseDouble - Return to indentation with spaces. * BAEL-3854 - Pattern Matching for instanceof in Java 14 * BAEL-3854 - Pattern Matching for instanceof in Java 14 - add unit test * BAEL-3868 - Fix the integrations tests in mocks Co-authored-by: Jonathan Cook --- .../jmockit/ExpectationsCollaborator.java | 2 +- .../jmockit/ExpectationsIntegrationTest.java | 35 ++++++++++--------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/testing-modules/mocks/src/main/java/com/baeldung/jmockit/ExpectationsCollaborator.java b/testing-modules/mocks/src/main/java/com/baeldung/jmockit/ExpectationsCollaborator.java index 799e7721e0..1aafa28a6a 100644 --- a/testing-modules/mocks/src/main/java/com/baeldung/jmockit/ExpectationsCollaborator.java +++ b/testing-modules/mocks/src/main/java/com/baeldung/jmockit/ExpectationsCollaborator.java @@ -15,5 +15,5 @@ public interface ExpectationsCollaborator { void methodForArgThat(Object o); String methodReturnsString(); int methodReturnsInt(); - Object methodForDelegate(int i); + int methodForDelegate(int i); } diff --git a/testing-modules/mocks/src/test/java/com/baeldung/jmockit/ExpectationsIntegrationTest.java b/testing-modules/mocks/src/test/java/com/baeldung/jmockit/ExpectationsIntegrationTest.java index 8b0c3ab4ec..1ff90111d1 100644 --- a/testing-modules/mocks/src/test/java/com/baeldung/jmockit/ExpectationsIntegrationTest.java +++ b/testing-modules/mocks/src/test/java/com/baeldung/jmockit/ExpectationsIntegrationTest.java @@ -1,21 +1,21 @@ package com.baeldung.jmockit; -import com.baeldung.jmockit.ExpectationsCollaborator; -import com.baeldung.jmockit.Model; -import mockit.Delegate; -import mockit.Expectations; -import mockit.Mocked; -import mockit.Verifications; -import mockit.integration.junit4.JMockit; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.List; + import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.Test; import org.junit.runner.RunWith; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; +import mockit.Delegate; +import mockit.Expectations; +import mockit.Mocked; +import mockit.Verifications; +import mockit.integration.junit4.JMockit; @RunWith(JMockit.class) @SuppressWarnings("unchecked") @@ -112,17 +112,16 @@ public class ExpectationsIntegrationTest { result = "foo"; result = new Exception(); result = "bar"; - mock.methodReturnsInt(); - result = new int[]{1, 2, 3}; - mock.methodReturnsString(); returns("foo", "bar"); mock.methodReturnsInt(); + result = new int[]{1, 2, 3}; result = 1; }}; assertEquals("Should return foo", "foo", mock.methodReturnsString()); try { mock.methodReturnsString(); + fail("Shouldn't reach here"); } catch (Exception e) { // NOOP } @@ -134,13 +133,14 @@ public class ExpectationsIntegrationTest { assertEquals("Should return bar", "bar", mock.methodReturnsString()); assertEquals("Should return 1", 1, mock.methodReturnsInt()); } - + @Test public void testDelegate(@Mocked ExpectationsCollaborator mock) { new Expectations() {{ mock.methodForDelegate(anyInt); - result = new Delegate() { - public int delegate(int i) throws Exception { + + result = new Delegate() { + int delegate(int i) throws Exception { if (i < 3) { return 5; } else { @@ -153,6 +153,7 @@ public class ExpectationsIntegrationTest { assertEquals("Should return 5", 5, mock.methodForDelegate(1)); try { mock.methodForDelegate(3); + fail("Shouldn't reach here"); } catch (Exception e) { } } From ad669c87a4c4de7df98f6dddf5db813cd76b254d Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Mon, 6 Apr 2020 22:28:19 +0200 Subject: [PATCH 096/503] JAVA-1201: Disable libraries-concurrency in the main pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e21c13efc2..bc9b820766 100644 --- a/pom.xml +++ b/pom.xml @@ -1263,7 +1263,7 @@ wildfly xml xstream - libraries-concurrency + From 7f010f0f98ee07b1fc42237bc864a30ea622596a Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Tue, 7 Apr 2020 08:50:55 +0200 Subject: [PATCH 097/503] Revert "JAVA-1201: Disable libraries-concurrency in the main pom.xml" This reverts commit ad669c87a4c4de7df98f6dddf5db813cd76b254d. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index bc9b820766..e21c13efc2 100644 --- a/pom.xml +++ b/pom.xml @@ -1263,7 +1263,7 @@ wildfly xml xstream - + libraries-concurrency From 5bd296e8d0470a9eea32f8b7c42e56b992e222f7 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Tue, 7 Apr 2020 08:52:00 +0200 Subject: [PATCH 098/503] JAVA-1201: Disable coroutines-with-quasar as it needs Java 12 --- libraries-concurrency/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries-concurrency/pom.xml b/libraries-concurrency/pom.xml index 7ae834025f..cb59b17674 100644 --- a/libraries-concurrency/pom.xml +++ b/libraries-concurrency/pom.xml @@ -14,7 +14,7 @@ - coroutines-with-quasar + \ No newline at end of file From 222a1363756975e00c7580f40db6ab3190457fcd Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 15:02:49 +0800 Subject: [PATCH 099/503] Update README.md --- cas/cas-server/README.md | 145 --------------------------------------- 1 file changed, 145 deletions(-) diff --git a/cas/cas-server/README.md b/cas/cas-server/README.md index b224738732..8b13789179 100644 --- a/cas/cas-server/README.md +++ b/cas/cas-server/README.md @@ -1,146 +1 @@ -CAS Overlay Template [![Build Status](https://travis-ci.org/apereo/cas-overlay-template.svg?branch=master)](https://travis-ci.org/apereo/cas-overlay-template) -======================= -Generic CAS WAR overlay to exercise the latest versions of CAS. This overlay could be freely used as a starting template for local CAS war overlays. - -# Versions - -- CAS `6.1.x` -- JDK `11` - -# Overview - -To build the project, use: - -```bash -# Use --refresh-dependencies to force-update SNAPSHOT versions -./gradlew[.bat] clean build -``` - -To see what commands are available to the build script, run: - -```bash -./gradlew[.bat] tasks -``` - -To launch into the CAS command-line shell: - -```bash -./gradlew[.bat] downloadShell runShell -``` - -To fetch and overlay a CAS resource or view, use: - -```bash -./gradlew[.bat] getResource -PresourceName=[resource-name] -``` - -To list all available CAS views and templates: - -```bash -./gradlew[.bat] listTemplateViews -``` - -To unzip and explode the CAS web application file and the internal resources jar: - -```bash -./gradlew[.bat] explodeWar -``` - -# Configuration - -- The `etc` directory contains the configuration files and directories that need to be copied to `/etc/cas/config`. - -```bash -./gradlew[.bat] copyCasConfiguration -``` - -- The specifics of the build are controlled using the `gradle.properties` file. - -## Adding Modules - -CAS modules may be specified under the `dependencies` block of the [Gradle build script](build.gradle): - -```gradle -dependencies { - compile "org.apereo.cas:cas-server-some-module:${project.casVersion}" - ... -} -``` - -To collect the list of all project modules and dependencies: - -```bash -./gradlew[.bat] allDependencies -``` - -### Clear Gradle Cache - -If you need to, on Linux/Unix systems, you can delete all the existing artifacts (artifacts and metadata) Gradle has downloaded using: - -```bash -# Only do this when absolutely necessary -rm -rf $HOME/.gradle/caches/ -``` - -Same strategy applies to Windows too, provided you switch `$HOME` to its equivalent in the above command. - -# Deployment - -- Create a keystore file `thekeystore` under `/etc/cas`. Use the password `changeit` for both the keystore and the key/certificate entries. This can either be done using the JDK's `keytool` utility or via the following command: - -```bash -./gradlew[.bat] createKeystore -``` - -- Ensure the keystore is loaded up with keys and certificates of the server. - -On a successful deployment via the following methods, CAS will be available at: - -* `https://cas.server.name:8443/cas` - -## Executable WAR - -Run the CAS web application as an executable WAR: - -```bash -./gradlew[.bat] run -``` - -Debug the CAS web application as an executable WAR: - -```bash -./gradlew[.bat] debug -``` - -Run the CAS web application as a *standalone* executable WAR: - -```bash -./gradlew[.bat] clean executable -``` - -## External - -Deploy the binary web application file `cas.war` after a successful build to a servlet container of choice. - -## Docker - -The following strategies outline how to build and deploy CAS Docker images. - -### Jib - -The overlay embraces the [Jib Gradle Plugin](https://github.com/GoogleContainerTools/jib) to provide easy-to-use out-of-the-box tooling for building CAS docker images. Jib is an open-source Java containerizer from Google that lets Java developers build containers using the tools they know. It is a container image builder that handles all the steps of packaging your application into a container image. It does not require you to write a Dockerfile or have Docker installed, and it is directly integrated into the overlay. - -```bash -./gradlew build jibDockerBuild -``` - -### Dockerfile - -You can also use the native Docker tooling and the provided `Dockerfile` to build and run CAS. - -```bash -chmod +x *.sh -./docker-build.sh -./docker-run.sh -``` From 911c746f23022890bcc39b2a1e936f7109dbae11 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 15:02:57 +0800 Subject: [PATCH 100/503] Delete README.md --- cas/cas-server/README.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 cas/cas-server/README.md diff --git a/cas/cas-server/README.md b/cas/cas-server/README.md deleted file mode 100644 index 8b13789179..0000000000 --- a/cas/cas-server/README.md +++ /dev/null @@ -1 +0,0 @@ - From c76c811b1cb72b71c8c127c9e3da41a731e4adff Mon Sep 17 00:00:00 2001 From: patkorek Date: Tue, 7 Apr 2020 10:23:15 +0200 Subject: [PATCH 101/503] BAEL-2660 few examples to convert String to Int --- .../strings/ConvertStringToInt.groovy | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy diff --git a/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy b/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy new file mode 100644 index 0000000000..40c53965a5 --- /dev/null +++ b/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy @@ -0,0 +1,92 @@ +package com.baeldung.strings + +import org.junit.Test + +import java.text.DecimalFormat + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertNull + +class ConvertStringToInt { + + @Test + void givenString_thenConvertToIntegerUsingAsInteger() { + def stringNum = "123" + def invalidString = "123a" + Integer expectedInteger = 123 + Integer integerNum = stringNum as Integer + def intNum = invalidString?.isInteger() ? invalidString as Integer : null + + assertNull(null, intNum) + assertEquals(integerNum, expectedInteger) + } + + @Test + void givenString_thenConvertToIntUsingAsInt() { + def stringNum = "123" + int expectedInt = 123 + int intNum = stringNum as int + + assertEquals(intNum, expectedInt) + } + + @Test + void givenString_thenConvertToIntegerUsingToInteger() { + def stringNum = "123" + int expectedInt = 123 + int intNum = stringNum.toInteger() + + assertEquals(intNum, expectedInt) + } + + @Test + void givenString_thenConvertToIntegerUsingParseInt() { + def stringNum = "123" + int expectedInt = 123 + int intNum = Integer.parseInt(stringNum) + + assertEquals(intNum, expectedInt) + } + + @Test + void givenString_thenConvertToIntegerUsingValueOf() { + def stringNum = "123" + int expectedInt = 123 + int intNum = Integer.valueOf(stringNum) + + assertEquals(intNum, expectedInt) + } + + @Test + void givenString_thenConvertToIntegerUsingIntValue() { + def stringNum = "123" + int expectedInt = 123 + int intNum = new Integer(stringNum).intValue() + int secondIntNum = new Integer(stringNum) + + assertEquals(intNum, expectedInt) + assertEquals(secondIntNum, expectedInt) + } + + @Test + void givenString_thenConvertToIntegerUsingDecimalFormat() { + def stringNum = "123" + int expectedInt = 123 + DecimalFormat decimalFormat = new DecimalFormat("#") + int intNum = decimalFormat.parse(stringNum).intValue() + + assertEquals(intNum, expectedInt) + } + + @Test(expected = NumberFormatException.class) + void givenInvalidString_whenUsingAs_thenThrowNumberFormatException() { + def invalidString = "123a" + invalidString as Integer + } + + @Test(expected = NullPointerException.class) + void givenNullString_whenUsingToInteger_thenThrowNullPointerException() { + def invalidString = null + invalidString.toInteger() + } +} From 5e90298049ebf59769a0397e2cfebf14eabd3a8b Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 16:24:27 +0800 Subject: [PATCH 102/503] Update README.md --- libraries-3/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries-3/README.md b/libraries-3/README.md index f3c3375098..62bd3b9f66 100644 --- a/libraries-3/README.md +++ b/libraries-3/README.md @@ -15,4 +15,4 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Introduction to the jcabi-aspects AOP Annotations Library](https://www.baeldung.com/java-jcabi-aspects) - [Introduction to Takes](https://www.baeldung.com/java-takes) - [Using NullAway to Avoid NullPointerExceptions](https://www.baeldung.com/java-nullaway) - +- [Introduction to Alibaba Arthas](https://www.baeldung.com/java-alibaba-arthas-intro) From 2ecd4cb204e6856476f5cf2b24877a591612248a Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 16:27:04 +0800 Subject: [PATCH 103/503] Update README.md --- persistence-modules/spring-boot-persistence-h2/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/persistence-modules/spring-boot-persistence-h2/README.md b/persistence-modules/spring-boot-persistence-h2/README.md index a0f9c67a33..d11ec1f409 100644 --- a/persistence-modules/spring-boot-persistence-h2/README.md +++ b/persistence-modules/spring-boot-persistence-h2/README.md @@ -1,4 +1,5 @@ ### Relevant Articles: - [Access the Same In-Memory H2 Database in Multiple Spring Boot Applications](https://www.baeldung.com/spring-boot-access-h2-database-multiple-apps) - [Spring Boot With H2 Database](https://www.baeldung.com/spring-boot-h2-database) -- [Hibernate @NotNull vs @Column(nullable = false)](https://www.baeldung.com/hibernate-notnull-vs-nullable) \ No newline at end of file +- [Hibernate @NotNull vs @Column(nullable = false)](https://www.baeldung.com/hibernate-notnull-vs-nullable) +- [Quick Guide to Hibernate enable_lazy_load_no_trans Property](https://www.baeldung.com/hibernate-lazy-loading-workaround) From fb594d2b2734aa68bdffaf636729f52461b9439c Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 16:30:42 +0800 Subject: [PATCH 104/503] Update README.md --- core-java-modules/core-java-io-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-io-2/README.md b/core-java-modules/core-java-io-2/README.md index 62461be0ff..84cabc5992 100644 --- a/core-java-modules/core-java-io-2/README.md +++ b/core-java-modules/core-java-io-2/README.md @@ -12,4 +12,5 @@ This module contains articles about core Java input and output (IO) - [Java – Append Data to a File](https://www.baeldung.com/java-append-to-file) - [How to Copy a File with Java](https://www.baeldung.com/java-copy-file) - [Create a Directory in Java](https://www.baeldung.com/java-create-directory) +- [Java IO vs NIO](https://www.baeldung.com/java-io-vs-nio) - [[<-- Prev]](/core-java-modules/core-java-io) From a59aa144001d35a75c7014eb03f7e0457e67161f Mon Sep 17 00:00:00 2001 From: patkorek Date: Tue, 7 Apr 2020 10:34:38 +0200 Subject: [PATCH 105/503] Renamed methods --- .../com/baeldung/strings/ConvertStringToInt.groovy | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy b/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy index 40c53965a5..3b179ee193 100644 --- a/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy +++ b/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy @@ -10,7 +10,7 @@ import static org.junit.Assert.assertNull class ConvertStringToInt { @Test - void givenString_thenConvertToIntegerUsingAsInteger() { + void givenString_whenUsingAsInteger_thenConvertToInteger() { def stringNum = "123" def invalidString = "123a" Integer expectedInteger = 123 @@ -22,7 +22,7 @@ class ConvertStringToInt { } @Test - void givenString_thenConvertToIntUsingAsInt() { + void givenString_whenUsingAsInt_thenConvertToInt() { def stringNum = "123" int expectedInt = 123 int intNum = stringNum as int @@ -31,7 +31,7 @@ class ConvertStringToInt { } @Test - void givenString_thenConvertToIntegerUsingToInteger() { + void givenString_whenUsingToInteger_thenConvertToInteger() { def stringNum = "123" int expectedInt = 123 int intNum = stringNum.toInteger() @@ -40,7 +40,7 @@ class ConvertStringToInt { } @Test - void givenString_thenConvertToIntegerUsingParseInt() { + void givenString_whenUsingParseInt_thenConvertToInteger() { def stringNum = "123" int expectedInt = 123 int intNum = Integer.parseInt(stringNum) @@ -49,7 +49,7 @@ class ConvertStringToInt { } @Test - void givenString_thenConvertToIntegerUsingValueOf() { + void givenString_whenUsingValueOf_thenConvertToInteger() { def stringNum = "123" int expectedInt = 123 int intNum = Integer.valueOf(stringNum) @@ -58,7 +58,7 @@ class ConvertStringToInt { } @Test - void givenString_thenConvertToIntegerUsingIntValue() { + void givenString_whenUsingIntValue_thenConvertToInteger() { def stringNum = "123" int expectedInt = 123 int intNum = new Integer(stringNum).intValue() @@ -69,7 +69,7 @@ class ConvertStringToInt { } @Test - void givenString_thenConvertToIntegerUsingDecimalFormat() { + void givenString_whenUsingDecimalFormat_thenConvertToInteger() { def stringNum = "123" int expectedInt = 123 DecimalFormat decimalFormat = new DecimalFormat("#") From c9847d5036664bd35d88332b33836e85e293249d Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 16:37:03 +0800 Subject: [PATCH 106/503] Create README.md --- linux-bash/functions/src/main/bash/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 linux-bash/functions/src/main/bash/README.md diff --git a/linux-bash/functions/src/main/bash/README.md b/linux-bash/functions/src/main/bash/README.md new file mode 100644 index 0000000000..5fb6958b9d --- /dev/null +++ b/linux-bash/functions/src/main/bash/README.md @@ -0,0 +1,3 @@ +### Relevant Articles + +- [Bash Functions in Linux](https://www.baeldung.com/linux/bash-functions) From 23a7314302d4f9bb1f7949d1b009f965cb43d340 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 16:39:13 +0800 Subject: [PATCH 107/503] Create README.md --- lombok/src/main/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 lombok/src/main/README.md diff --git a/lombok/src/main/README.md b/lombok/src/main/README.md new file mode 100644 index 0000000000..4092d8ce99 --- /dev/null +++ b/lombok/src/main/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Guide to the Linux wc Command](https://www.baeldung.com/linux/wc-command) From 4d9ae47da774264f984f77203e20a9908bd42d40 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 16:44:15 +0800 Subject: [PATCH 108/503] Create README.md --- linux-bash/read/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 linux-bash/read/README.md diff --git a/linux-bash/read/README.md b/linux-bash/read/README.md new file mode 100644 index 0000000000..56c1dd5b24 --- /dev/null +++ b/linux-bash/read/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Guide to the Linux read Command](https://www.baeldung.com/linux/read-command) From 850b02f07e04b3adebc27384ba8aad13c05945c6 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 16:48:21 +0800 Subject: [PATCH 109/503] Create README.md --- linux-bash/command-line-arguments/src/main/bash/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 linux-bash/command-line-arguments/src/main/bash/README.md diff --git a/linux-bash/command-line-arguments/src/main/bash/README.md b/linux-bash/command-line-arguments/src/main/bash/README.md new file mode 100644 index 0000000000..27d89fff99 --- /dev/null +++ b/linux-bash/command-line-arguments/src/main/bash/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [How to Use Command Line Arguments in a Bash Script](https://www.baeldung.com/linux/use-command-line-arguments-in-bash-script) From 1f6163f45cb9a0bf94cca287e5bfc0e4a765b779 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 16:49:44 +0800 Subject: [PATCH 110/503] Update README.md --- linux-bash/text/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-bash/text/README.md b/linux-bash/text/README.md index de99c1962a..20df2a33ec 100644 --- a/linux-bash/text/README.md +++ b/linux-bash/text/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Linux Commands – Remove All Text After X](https://www.baeldung.com/linux/tr-manipulate-strings) +- [Linux Commands for Appending Multiple Lines to a File](https://www.baeldung.com/linux/appending-multiple-lines-to-file2) From 83cf886628977eb17779e46eb2edcd3a13c367e4 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 16:56:28 +0800 Subject: [PATCH 111/503] Create README.md --- .../core-java-concurrency-collections-2/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 core-java-modules/core-java-concurrency-collections-2/README.md diff --git a/core-java-modules/core-java-concurrency-collections-2/README.md b/core-java-modules/core-java-concurrency-collections-2/README.md new file mode 100644 index 0000000000..91da6c623c --- /dev/null +++ b/core-java-modules/core-java-concurrency-collections-2/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Introduction to Lock Striping](https://www.baeldung.com/java-lock-stripping) From 073f9c9067e96c56fee2af7580174b56c9c95a8b Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 17:09:25 +0800 Subject: [PATCH 112/503] Create README.md --- core-scala/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 core-scala/README.md diff --git a/core-scala/README.md b/core-scala/README.md new file mode 100644 index 0000000000..72b583c22b --- /dev/null +++ b/core-scala/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Pattern Matching in Scala](https://www.baeldung.com/scala/pattern-matching) From 40825b6f1fd4896b868d08b95e86aed98109d3a7 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 7 Apr 2020 14:49:42 +0530 Subject: [PATCH 113/503] JAVA-1188: Moved modules to core-java-modules --- java-collections-maps-2/README.md | 16 - java-collections-maps-2/pom.xml | 79 ---- .../main/java/com/baeldung/map/Product.java | 133 ------- .../com/baeldung/map/convert/MapToString.java | 34 -- .../com/baeldung/map/convert/StringToMap.java | 21 -- .../baeldung/map/copyhashmap/CopyHashMap.java | 55 --- .../map/initialize/MapInitializer.java | 80 ----- .../baeldung/map/iteration/MapIteration.java | 74 ---- .../java/com/baeldung/map/mapmax/MapMax.java | 92 ----- .../com/baeldung/map/mergemaps/Employee.java | 60 ---- .../com/baeldung/map/mergemaps/MergeMaps.java | 105 ------ .../map/primitives/PrimitiveMaps.java | 69 ---- .../com/baeldung/map/sort/SortHashMap.java | 104 ------ .../com/baeldung/map/ProductUnitTest.java | 174 --------- .../map/convert/MapToStringUnitTest.java | 48 --- .../map/convert/StringToMapUnitTest.java | 23 -- .../map/copyhashmap/CopyHashMapUnitTest.java | 76 ---- .../baeldung/map/copyhashmap/Employee.java | 28 -- .../initialize/MapInitializerUnitTest.java | 27 -- .../baeldung/map/mapmax/MapMaxUnitTest.java | 58 --- .../map/weakhashmap/WeakHashMapUnitTest.java | 72 ---- java-collections-maps-3/README.md | 8 - java-collections-maps-3/pom.xml | 26 -- .../compare/HashMapComparisonUnitTest.java | 225 ------------ .../TreeMapVsHashMapUnitTest.java | 58 --- java-collections-maps/README.md | 16 - java-collections-maps/pom.xml | 35 -- .../main/java/com/baeldung/map/MapUtil.java | 44 --- .../src/main/java/com/baeldung/map/MyKey.java | 64 ---- .../com/baeldung/map/MyLinkedHashMap.java | 23 -- .../src/main/resources/logback.xml | 13 - .../baeldung/guava/GuavaBiMapUnitTest.java | 120 ------- .../baeldung/map/ImmutableMapUnitTest.java | 84 ----- .../com/baeldung/map/KeyCheckUnitTest.java | 27 -- .../map/MapMultipleValuesUnitTest.java | 119 ------- .../java/com/baeldung/map/MapUnitTest.java | 336 ------------------ .../com/baeldung/map/MapUtilUnitTest.java | 103 ------ .../baeldung/map/MultiValuedMapUnitTest.java | 227 ------------ 38 files changed, 2956 deletions(-) delete mode 100644 java-collections-maps-2/README.md delete mode 100644 java-collections-maps-2/pom.xml delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/Product.java delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/convert/MapToString.java delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/convert/StringToMap.java delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/copyhashmap/CopyHashMap.java delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/initialize/MapInitializer.java delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/iteration/MapIteration.java delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/mapmax/MapMax.java delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/Employee.java delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/MergeMaps.java delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/primitives/PrimitiveMaps.java delete mode 100644 java-collections-maps-2/src/main/java/com/baeldung/map/sort/SortHashMap.java delete mode 100644 java-collections-maps-2/src/test/java/com/baeldung/map/ProductUnitTest.java delete mode 100644 java-collections-maps-2/src/test/java/com/baeldung/map/convert/MapToStringUnitTest.java delete mode 100644 java-collections-maps-2/src/test/java/com/baeldung/map/convert/StringToMapUnitTest.java delete mode 100644 java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/CopyHashMapUnitTest.java delete mode 100644 java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/Employee.java delete mode 100644 java-collections-maps-2/src/test/java/com/baeldung/map/initialize/MapInitializerUnitTest.java delete mode 100644 java-collections-maps-2/src/test/java/com/baeldung/map/mapmax/MapMaxUnitTest.java delete mode 100644 java-collections-maps-2/src/test/java/com/baeldung/map/weakhashmap/WeakHashMapUnitTest.java delete mode 100644 java-collections-maps-3/README.md delete mode 100644 java-collections-maps-3/pom.xml delete mode 100644 java-collections-maps-3/src/test/java/com/baeldung/map/compare/HashMapComparisonUnitTest.java delete mode 100644 java-collections-maps-3/src/test/java/com/baeldung/map/treemaphashmap/TreeMapVsHashMapUnitTest.java delete mode 100644 java-collections-maps/README.md delete mode 100644 java-collections-maps/pom.xml delete mode 100644 java-collections-maps/src/main/java/com/baeldung/map/MapUtil.java delete mode 100644 java-collections-maps/src/main/java/com/baeldung/map/MyKey.java delete mode 100644 java-collections-maps/src/main/java/com/baeldung/map/MyLinkedHashMap.java delete mode 100644 java-collections-maps/src/main/resources/logback.xml delete mode 100644 java-collections-maps/src/test/java/com/baeldung/guava/GuavaBiMapUnitTest.java delete mode 100644 java-collections-maps/src/test/java/com/baeldung/map/ImmutableMapUnitTest.java delete mode 100644 java-collections-maps/src/test/java/com/baeldung/map/KeyCheckUnitTest.java delete mode 100644 java-collections-maps/src/test/java/com/baeldung/map/MapMultipleValuesUnitTest.java delete mode 100644 java-collections-maps/src/test/java/com/baeldung/map/MapUnitTest.java delete mode 100644 java-collections-maps/src/test/java/com/baeldung/map/MapUtilUnitTest.java delete mode 100644 java-collections-maps/src/test/java/com/baeldung/map/MultiValuedMapUnitTest.java diff --git a/java-collections-maps-2/README.md b/java-collections-maps-2/README.md deleted file mode 100644 index 2188960543..0000000000 --- a/java-collections-maps-2/README.md +++ /dev/null @@ -1,16 +0,0 @@ -## Java Collections Cookbooks and Examples - -This module contains articles about Map data structures in Java. - -### Relevant Articles: -- [Map of Primitives in Java](https://www.baeldung.com/java-map-primitives) -- [Copying a HashMap in Java](https://www.baeldung.com/java-copy-hashmap) -- [A Guide to Java HashMap](https://www.baeldung.com/java-hashmap) -- [Guide to WeakHashMap in Java](https://www.baeldung.com/java-weakhashmap) -- [Map to String Conversion in Java](https://www.baeldung.com/java-map-to-string-conversion) -- [Iterate over a Map in Java](https://www.baeldung.com/java-iterate-map) -- [Merging Two Maps with Java 8](https://www.baeldung.com/java-merge-maps) -- [Sort a HashMap in Java](https://www.baeldung.com/java-hashmap-sort) -- [Finding the Highest Value in a Java Map](https://www.baeldung.com/java-find-map-max) -- [Initialize a HashMap in Java](https://www.baeldung.com/java-initialize-hashmap) -- More articles: [[<-- prev]](/java-collections-maps) [[next -->]](/java-collections-maps-3) diff --git a/java-collections-maps-2/pom.xml b/java-collections-maps-2/pom.xml deleted file mode 100644 index a246559f61..0000000000 --- a/java-collections-maps-2/pom.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - 4.0.0 - java-collections-maps-2 - 0.1.0-SNAPSHOT - java-collections-maps-2 - jar - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../parent-java - - - - - org.eclipse.collections - eclipse-collections - ${eclipse-collections.version} - - - net.sf.trove4j - trove4j - ${trove4j.version} - - - it.unimi.dsi - fastutil - ${fastutil.version} - - - colt - colt - ${colt.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - - - one.util - streamex - ${streamex.version} - - - com.jayway.awaitility - awaitility - ${avaitility.version} - test - - - org.assertj - assertj-core - ${assertj.version} - test - - - - - 0.6.5 - 4.1 - 1.7.0 - 8.2.0 - 3.0.2 - 8.1.0 - 1.2.0 - 3.11.1 - - - \ No newline at end of file diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/Product.java b/java-collections-maps-2/src/main/java/com/baeldung/map/Product.java deleted file mode 100644 index 5559895730..0000000000 --- a/java-collections-maps-2/src/main/java/com/baeldung/map/Product.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.baeldung.map; - -import java.util.*; - -public class Product { - - private String name; - private String description; - private List tags; - - public Product(String name, String description) { - this.name = name; - this.description = description; - this.tags = new ArrayList<>(); - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public List getTags() { - return tags; - } - - public Product addTagsOfOtherProdcut(Product product) { - this.tags.addAll(product.getTags()); - return this; - } - - @Override - public boolean equals(Object o) { - - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - Product product = (Product) o; - return Objects.equals(name, product.name) && - Objects.equals(description, product.description); - } - - @Override - public int hashCode() { - return Objects.hash(name, description); - } - - public static void forEach() { - - HashMap productsByName = new HashMap<>(); - productsByName.forEach( (key, product) - -> System.out.println("Key: " + key + " Product:" + product.getDescription()) - //do something with the key and value - ); - - //Prior to Java 8: - for(Map.Entry entry : productsByName.entrySet()) { - Product product = entry.getValue(); - String key = entry.getKey(); - //do something with the key and value - } - } - - public static void getOrDefault() { - - HashMap productsByName = new HashMap<>(); - Product chocolate = new Product("chocolate", "something sweet"); - Product defaultProduct = productsByName.getOrDefault("horse carriage", chocolate); - Product bike = productsByName.getOrDefault("E-Bike", chocolate); - - //Prior to Java 8: - Product bike2 = productsByName.containsKey("E-Bike") - ? productsByName.get("E-Bike") - : chocolate; - Product defaultProduct2 = productsByName.containsKey("horse carriage") - ? productsByName.get("horse carriage") - : chocolate; - } - - public static void putIfAbsent() { - - HashMap productsByName = new HashMap<>(); - Product chocolate = new Product("chocolate", "something sweet"); - productsByName.putIfAbsent("E-Bike", chocolate); - - //Prior to Java 8: - if(productsByName.containsKey("E-Bike")) { - productsByName.put("E-Bike", chocolate); - } - } - - public static void merge() { - - HashMap productsByName = new HashMap<>(); - Product eBike2 = new Product("E-Bike", "A bike with a battery"); - eBike2.getTags().add("sport"); - productsByName.merge("E-Bike", eBike2, Product::addTagsOfOtherProdcut); - - //Prior to Java 8: - if(productsByName.containsKey("E-Bike")) { - productsByName.get("E-Bike").addTagsOfOtherProdcut(eBike2); - } else { - productsByName.put("E-Bike", eBike2); - } - } - - public static void compute() { - - HashMap productsByName = new HashMap<>(); - Product eBike2 = new Product("E-Bike", "A bike with a battery"); - - productsByName.compute("E-Bike", (k,v) -> { - if(v != null) { - return v.addTagsOfOtherProdcut(eBike2); - } else { - return eBike2; - } - }); - - //Prior to Java 8: - if(productsByName.containsKey("E-Bike")) { - productsByName.get("E-Bike").addTagsOfOtherProdcut(eBike2); - } else { - productsByName.put("E-Bike", eBike2); - } - } -} diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/convert/MapToString.java b/java-collections-maps-2/src/main/java/com/baeldung/map/convert/MapToString.java deleted file mode 100644 index d13be924ff..0000000000 --- a/java-collections-maps-2/src/main/java/com/baeldung/map/convert/MapToString.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.baeldung.map.convert; - -import com.google.common.base.Joiner; -import org.apache.commons.lang3.StringUtils; - -import java.util.Map; -import java.util.stream.Collectors; - -public class MapToString { - - public static String convertWithIteration(Map map) { - StringBuilder mapAsString = new StringBuilder("{"); - for (Integer key : map.keySet()) { - mapAsString.append(key + "=" + map.get(key) + ", "); - } - mapAsString.delete(mapAsString.length()-2, mapAsString.length()).append("}"); - return mapAsString.toString(); - } - - public static String convertWithStream(Map map) { - String mapAsString = map.keySet().stream() - .map(key -> key + "=" + map.get(key)) - .collect(Collectors.joining(", ", "{", "}")); - return mapAsString; - } - - public static String convertWithGuava(Map map) { - return Joiner.on(",").withKeyValueSeparator("=").join(map); - } - - public static String convertWithApache(Map map) { - return StringUtils.join(map); - } -} diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/convert/StringToMap.java b/java-collections-maps-2/src/main/java/com/baeldung/map/convert/StringToMap.java deleted file mode 100644 index 416ba4dd9a..0000000000 --- a/java-collections-maps-2/src/main/java/com/baeldung/map/convert/StringToMap.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.map.convert; - -import com.google.common.base.Splitter; - -import java.util.Arrays; -import java.util.Map; -import java.util.stream.Collectors; - -public class StringToMap { - - public static Map convertWithStream(String mapAsString) { - Map map = Arrays.stream(mapAsString.split(",")) - .map(entry -> entry.split("=")) - .collect(Collectors.toMap(entry -> entry[0], entry -> entry[1])); - return map; - } - - public static Map convertWithGuava(String mapAsString) { - return Splitter.on(',').withKeyValueSeparator('=').split(mapAsString); - } -} diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/copyhashmap/CopyHashMap.java b/java-collections-maps-2/src/main/java/com/baeldung/map/copyhashmap/CopyHashMap.java deleted file mode 100644 index cb18f3aa11..0000000000 --- a/java-collections-maps-2/src/main/java/com/baeldung/map/copyhashmap/CopyHashMap.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.baeldung.map.copyhashmap; - -import org.apache.commons.lang3.SerializationUtils; - -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.stream.Collectors; - -public class CopyHashMap { - - public static HashMap copyUsingConstructor(HashMap originalMap) { - return new HashMap(originalMap); - } - - public static HashMap copyUsingClone(HashMap originalMap) { - return (HashMap) originalMap.clone(); - } - - public static HashMap copyUsingPut(HashMap originalMap) { - HashMap shallowCopy = new HashMap(); - Set> entries = originalMap.entrySet(); - for(Map.Entry mapEntry: entries) { - shallowCopy.put(mapEntry.getKey(), mapEntry.getValue()); - } - - return shallowCopy; - } - - public static HashMap copyUsingPutAll(HashMap originalMap) { - HashMap shallowCopy = new HashMap(); - shallowCopy.putAll(originalMap); - - return shallowCopy; - } - - public static HashMap copyUsingJava8Stream(HashMap originalMap) { - Set> entries = originalMap.entrySet(); - HashMap shallowCopy = (HashMap) entries - .stream() - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - return shallowCopy; - } - - public static HashMap shallowCopy(HashMap originalMap) { - return (HashMap) originalMap.clone(); - } - - public static HashMap deepCopy(HashMap originalMap) { - return SerializationUtils.clone(originalMap); - } - -} diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/initialize/MapInitializer.java b/java-collections-maps-2/src/main/java/com/baeldung/map/initialize/MapInitializer.java deleted file mode 100644 index 4d63abcfd0..0000000000 --- a/java-collections-maps-2/src/main/java/com/baeldung/map/initialize/MapInitializer.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.baeldung.map.initialize; - -import java.util.AbstractMap; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class MapInitializer { - - public static Map articleMapOne; - static { - articleMapOne = new HashMap<>(); - articleMapOne.put("ar01", "Intro to Map"); - articleMapOne.put("ar02", "Some article"); - } - - public static Map createSingletonMap() { - Map passwordMap = Collections.singletonMap("username1", "password1"); - return passwordMap; - - } - - public Map createEmptyMap() { - Map emptyMap = Collections.emptyMap(); - return emptyMap; - } - - public Map createUsingDoubleBrace() { - Map doubleBraceMap = new HashMap() { - - /** - * - */ - private static final long serialVersionUID = 1L; - - { - put("key1", "value1"); - put("key2", "value2"); - } - }; - return doubleBraceMap; - } - - public Map createMapUsingStreamStringArray() { - Map map = Stream.of(new String[][] { { "Hello", "World" }, { "John", "Doe" }, }) - .collect(Collectors.toMap(data -> data[0], data -> data[1])); - - return map; - } - - public Map createMapUsingStreamObjectArray() { - Map map = Stream.of(new Object[][] { { "data1", 1 }, { "data2", 2 }, }) - .collect(Collectors.toMap(data -> (String) data[0], data -> (Integer) data[1])); - - return map; - } - - public Map createMapUsingStreamSimpleEntry() { - Map map = Stream.of(new AbstractMap.SimpleEntry<>("idea", 1), new AbstractMap.SimpleEntry<>("mobile", 2)) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - return map; - } - - public Map createMapUsingStreamSimpleImmutableEntry() { - Map map = Stream.of(new AbstractMap.SimpleImmutableEntry<>("idea", 1), new AbstractMap.SimpleImmutableEntry<>("mobile", 2)) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - return map; - } - - public Map createImmutableMapWithStreams() { - Map map = Stream.of(new String[][] { { "Hello", "World" }, { "John", "Doe" }, }) - .collect(Collectors.collectingAndThen(Collectors.toMap(data -> data[0], data -> data[1]), Collections:: unmodifiableMap)); - return map; - - } -} diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/iteration/MapIteration.java b/java-collections-maps-2/src/main/java/com/baeldung/map/iteration/MapIteration.java deleted file mode 100644 index b0c32e1487..0000000000 --- a/java-collections-maps-2/src/main/java/com/baeldung/map/iteration/MapIteration.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.baeldung.map.iteration; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -public class MapIteration { - - public static void main(String[] args) { - MapIteration mapIteration = new MapIteration(); - Map map = new HashMap<>(); - - map.put("One", 1); - map.put("Three", 3); - map.put("Two", 2); - - System.out.println("Iterating Keys of Map Using KeySet"); - mapIteration.iterateKeys(map); - - System.out.println("Iterating Map Using Entry Set"); - mapIteration.iterateUsingEntrySet(map); - - System.out.println("Iterating Using Iterator and Map Entry"); - mapIteration.iterateUsingIteratorAndEntry(map); - - System.out.println("Iterating Using KeySet and For Each"); - mapIteration.iterateUsingKeySetAndForeach(map); - - System.out.println("Iterating Map Using Lambda Expression"); - mapIteration.iterateUsingLambda(map); - - System.out.println("Iterating Using Stream API"); - mapIteration.iterateUsingStreamAPI(map); - } - - public void iterateUsingEntrySet(Map map) { - for (Map.Entry entry : map.entrySet()) { - System.out.println(entry.getKey() + ":" + entry.getValue()); - } - } - - public void iterateUsingLambda(Map map) { - map.forEach((k, v) -> System.out.println((k + ":" + v))); - } - - public void iterateUsingIteratorAndEntry(Map map) { - Iterator> iterator = map.entrySet() - .iterator(); - while (iterator.hasNext()) { - Map.Entry pair = iterator.next(); - System.out.println(pair.getKey() + ":" + pair.getValue()); - } - } - - public void iterateUsingKeySetAndForeach(Map map) { - for (String key : map.keySet()) { - System.out.println(key + ":" + map.get(key)); - } - } - - public void iterateUsingStreamAPI(Map map) { - map.entrySet() - .stream() - .forEach(e -> System.out.println(e.getKey() + ":" + e.getValue())); - } - - public void iterateKeys(Map map) { - for (String key : map.keySet()) { - System.out.println(key); - } - - } - -} \ No newline at end of file diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/mapmax/MapMax.java b/java-collections-maps-2/src/main/java/com/baeldung/map/mapmax/MapMax.java deleted file mode 100644 index 8c33c857ee..0000000000 --- a/java-collections-maps-2/src/main/java/com/baeldung/map/mapmax/MapMax.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.baeldung.map.mapmax; - -import java.util.*; -import java.util.Map.Entry; - -public class MapMax { - - public > V maxUsingIteration(Map map) { - - Map.Entry maxEntry = null; - - for (Map.Entry entry : map.entrySet()) { - - if (maxEntry == null || entry.getValue() - .compareTo(maxEntry.getValue()) > 0) { - maxEntry = entry; - } - } - - return maxEntry.getValue(); - } - - public > V maxUsingCollectionsMax(Map map) { - - Entry maxEntry = Collections.max(map.entrySet(), new Comparator>() { - public int compare(Entry e1, Entry e2) { - return e1.getValue() - .compareTo(e2.getValue()); - } - }); - - return maxEntry.getValue(); - } - - public > V maxUsingCollectionsMaxAndLambda(Map map) { - - Entry maxEntry = Collections.max(map.entrySet(), (Entry e1, Entry e2) -> e1.getValue() - .compareTo(e2.getValue())); - - return maxEntry.getValue(); - } - - public > V maxUsingCollectionsMaxAndMethodReference(Map map) { - - Entry maxEntry = Collections.max(map.entrySet(), Comparator.comparing(Map.Entry::getValue)); - - return maxEntry.getValue(); - } - - public > V maxUsingStreamAndLambda(Map map) { - - Optional> maxEntry = map.entrySet() - .stream() - .max((Entry e1, Entry e2) -> e1.getValue() - .compareTo(e2.getValue())); - - return maxEntry.get() - .getValue(); - } - - public > V maxUsingStreamAndMethodReference(Map map) { - - Optional> maxEntry = map.entrySet() - .stream() - .max(Comparator.comparing(Map.Entry::getValue)); - - return maxEntry.get() - .getValue(); - } - - public static void main(String[] args) { - - Map map = new HashMap(); - - map.put(1, 3); - map.put(2, 4); - map.put(3, 5); - map.put(4, 6); - map.put(5, 7); - - MapMax mapMax = new MapMax(); - - System.out.println(mapMax.maxUsingIteration(map)); - System.out.println(mapMax.maxUsingCollectionsMax(map)); - System.out.println(mapMax.maxUsingCollectionsMaxAndLambda(map)); - System.out.println(mapMax.maxUsingCollectionsMaxAndMethodReference(map)); - System.out.println(mapMax.maxUsingStreamAndLambda(map)); - System.out.println(mapMax.maxUsingStreamAndMethodReference(map)); - - } - -} diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/Employee.java b/java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/Employee.java deleted file mode 100644 index d7fb0d1a1d..0000000000 --- a/java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/Employee.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.baeldung.map.mergemaps; - -public class Employee implements Comparable { - - private Long id; - private String name; - - public Employee(Long id, String name) { - this.name = name; - this.id = id; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Employee employee = (Employee) o; - - if (!id.equals(employee.id)) return false; - return name.equals(employee.name); - - } - - @Override - public int hashCode() { - int result = id.hashCode(); - result = 31 * result + name.hashCode(); - return result; - } - - @Override - public String toString() { - return "Employee{" + - "id=" + id + - ", name='" + name + '\'' + - '}'; - } - - @Override - public int compareTo(Employee employee) { - return (int)(this.id - employee.getId()); - } -} diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/MergeMaps.java b/java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/MergeMaps.java deleted file mode 100644 index 4f187bad90..0000000000 --- a/java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/MergeMaps.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.baeldung.map.mergemaps; - -import one.util.streamex.EntryStream; - -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class MergeMaps { - - private static Map map1 = new HashMap<>(); - private static Map map2 = new HashMap<>(); - - public static void main(String[] args) { - - initialize(); - - mergeFunction(); - - streamConcat(); - - streamOf(); - - streamEx(); - - streamMerge(); - } - - private static void streamMerge() { - - Map map3 = map2.entrySet() - .stream() - .collect( - Collectors.toMap( - Map.Entry::getKey, - Map.Entry::getValue, - (v1, v2) -> new Employee(v1.getId(), v2.getName()), - () -> new HashMap<>(map1) - ) - ); - - System.out.println(map3); - } - - private static void streamEx() { - Map map3 = EntryStream.of(map1) - .append(EntryStream.of(map2)) - .toMap((e1, e2) -> e1); - - System.out.println(map3); - - } - - private static void streamOf() { - Map map3 = Stream.of(map1, map2) - .flatMap(map -> map.entrySet().stream()) - .collect( - Collectors.toMap( - Map.Entry::getKey, - Map.Entry::getValue, - (v1, v2) -> new Employee(v1.getId(), v2.getName()) - ) - ); - - map3.entrySet().forEach(System.out::println); - } - - private static void streamConcat() { - Map result = Stream.concat(map1.entrySet().stream(), map2.entrySet().stream()).collect(Collectors.toMap( - Map.Entry::getKey, - Map.Entry::getValue, - (value1, value2) -> new Employee(value2.getId(), value1.getName()) - )); - - result.entrySet().forEach(System.out::println); - } - - private static void mergeFunction() { - Map map3 = new HashMap<>(map1); - - map2.forEach( - (key, value) -> map3.merge(key, value, (v1, v2) -> - new Employee(v1.getId(), v2.getName())) - ); - - map3.entrySet().forEach(System.out::println); - } - - - private static void initialize() { - Employee employee1 = new Employee(1L, "Henry"); - map1.put(employee1.getName(), employee1); - Employee employee2 = new Employee(22L, "Annie"); - map1.put(employee2.getName(), employee2); - Employee employee3 = new Employee(8L, "John"); - map1.put(employee3.getName(), employee3); - - Employee employee4 = new Employee(2L, "George"); - map2.put(employee4.getName(), employee4); - Employee employee5 = new Employee(3L, "Henry"); - map2.put(employee5.getName(), employee5); - } - -} diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/primitives/PrimitiveMaps.java b/java-collections-maps-2/src/main/java/com/baeldung/map/primitives/PrimitiveMaps.java deleted file mode 100644 index 30bec12ccc..0000000000 --- a/java-collections-maps-2/src/main/java/com/baeldung/map/primitives/PrimitiveMaps.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.baeldung.map.primitives; - -import cern.colt.map.AbstractIntDoubleMap; -import cern.colt.map.OpenIntDoubleHashMap; -import gnu.trove.map.TDoubleIntMap; -import gnu.trove.map.hash.TDoubleIntHashMap; -import it.unimi.dsi.fastutil.ints.Int2BooleanMap; -import it.unimi.dsi.fastutil.ints.Int2BooleanOpenHashMap; -import it.unimi.dsi.fastutil.ints.Int2BooleanSortedMap; -import it.unimi.dsi.fastutil.ints.Int2BooleanSortedMaps; -import org.eclipse.collections.api.map.primitive.ImmutableIntIntMap; -import org.eclipse.collections.api.map.primitive.MutableIntIntMap; -import org.eclipse.collections.api.map.primitive.MutableObjectDoubleMap; -import org.eclipse.collections.impl.factory.primitive.IntIntMaps; -import org.eclipse.collections.impl.factory.primitive.ObjectDoubleMaps; - -public class PrimitiveMaps { - - public static void main(String[] args) { - - eclipseCollectionsMap(); - troveMap(); - coltMap(); - fastutilMap(); - } - - private static void fastutilMap() { - Int2BooleanMap int2BooleanMap = new Int2BooleanOpenHashMap(); - int2BooleanMap.put(1, true); - int2BooleanMap.put(7, false); - int2BooleanMap.put(4, true); - - boolean value = int2BooleanMap.get(1); - - Int2BooleanSortedMap int2BooleanSorted = Int2BooleanSortedMaps.EMPTY_MAP; - } - - private static void coltMap() { - AbstractIntDoubleMap map = new OpenIntDoubleHashMap(); - map.put(1, 4.5); - double value = map.get(1); - } - - private static void eclipseCollectionsMap() { - MutableIntIntMap mutableIntIntMap = IntIntMaps.mutable.empty(); - mutableIntIntMap.addToValue(1, 1); - - ImmutableIntIntMap immutableIntIntMap = IntIntMaps.immutable.empty(); - - MutableObjectDoubleMap dObject = ObjectDoubleMaps.mutable.empty(); - dObject.addToValue("price", 150.5); - dObject.addToValue("quality", 4.4); - dObject.addToValue("stability", 0.8); - } - - private static void troveMap() { - double[] doubles = new double[] {1.2, 4.5, 0.3}; - int[] ints = new int[] {1, 4, 0}; - - TDoubleIntMap doubleIntMap = new TDoubleIntHashMap(doubles, ints); - - doubleIntMap.put(1.2, 22); - doubleIntMap.put(4.5, 16); - - doubleIntMap.adjustValue(1.2, 1); - doubleIntMap.adjustValue(4.5, 4); - doubleIntMap.adjustValue(0.3, 7); - } -} diff --git a/java-collections-maps-2/src/main/java/com/baeldung/map/sort/SortHashMap.java b/java-collections-maps-2/src/main/java/com/baeldung/map/sort/SortHashMap.java deleted file mode 100644 index 14610ffb00..0000000000 --- a/java-collections-maps-2/src/main/java/com/baeldung/map/sort/SortHashMap.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.baeldung.map.sort; - -import com.baeldung.map.mergemaps.Employee; -import com.google.common.base.Functions; -import com.google.common.collect.ImmutableSortedMap; -import com.google.common.collect.Ordering; - -import java.util.*; -import java.util.stream.Collectors; - -public class SortHashMap { - - private static Map map = new HashMap<>(); - - public static void main(String[] args) { - - initialize(); - - treeMapSortByKey(); - - arrayListSortByValue(); - arrayListSortByKey(); - - sortStream(); - - sortGuava(); - - addDuplicates(); - - treeSetByKey(); - treeSetByValue(); - - } - - private static void sortGuava() { - final Ordering naturalOrdering = - Ordering.natural().onResultOf(Functions.forMap(map, null)); - - System.out.println(ImmutableSortedMap.copyOf(map, naturalOrdering)); - } - - private static void sortStream() { - map.entrySet().stream() - .sorted(Map.Entry.comparingByKey().reversed()) - .forEach(System.out::println); - - Map result = map.entrySet().stream() - .sorted(Map.Entry.comparingByValue()) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, - (oldValue, newValue) -> oldValue, LinkedHashMap::new)); - - result.entrySet().forEach(System.out::println); - } - - private static void treeSetByValue() { - SortedSet values = new TreeSet<>(map.values()); - System.out.println(values); - } - - private static void treeSetByKey() { - SortedSet keysSet = new TreeSet<>(map.keySet()); - System.out.println(keysSet); - } - - private static void treeMapSortByKey() { - TreeMap sorted = new TreeMap<>(map); - sorted.putAll(map); - - sorted.entrySet().forEach(System.out::println); - - } - - private static void arrayListSortByValue() { - List employeeById = new ArrayList<>(map.values()); - - Collections.sort(employeeById); - - System.out.println(employeeById); - } - - private static void arrayListSortByKey() { - List employeeByKey = new ArrayList<>(map.keySet()); - Collections.sort(employeeByKey); - System.out.println(employeeByKey); - } - - private static void initialize() { - Employee employee1 = new Employee(1L, "Mher"); - map.put(employee1.getName(), employee1); - Employee employee2 = new Employee(22L, "Annie"); - map.put(employee2.getName(), employee2); - Employee employee3 = new Employee(8L, "John"); - map.put(employee3.getName(), employee3); - Employee employee4 = new Employee(2L, "George"); - map.put(employee4.getName(), employee4); - } - - private static void addDuplicates() { - Employee employee5 = new Employee(1L, "Mher"); - map.put(employee5.getName(), employee5); - Employee employee6 = new Employee(22L, "Annie"); - map.put(employee6.getName(), employee6); - } -} diff --git a/java-collections-maps-2/src/test/java/com/baeldung/map/ProductUnitTest.java b/java-collections-maps-2/src/test/java/com/baeldung/map/ProductUnitTest.java deleted file mode 100644 index ba29d5c454..0000000000 --- a/java-collections-maps-2/src/test/java/com/baeldung/map/ProductUnitTest.java +++ /dev/null @@ -1,174 +0,0 @@ -package com.baeldung.map; - -import org.junit.jupiter.api.Test; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import static org.junit.jupiter.api.Assertions.*; - -class ProductUnitTest { - - - @Test - public void getExistingValue() { - HashMap productsByName = new HashMap<>(); - - Product eBike = new Product("E-Bike", "A bike with a battery"); - Product roadBike = new Product("Road bike", "A bike for competition"); - - productsByName.put(eBike.getName(), eBike); - productsByName.put(roadBike.getName(), roadBike); - - Product nextPurchase = productsByName.get("E-Bike"); - - assertEquals("A bike with a battery", nextPurchase.getDescription()); - } - - @Test - public void getNonExistingValue() { - HashMap productsByName = new HashMap<>(); - - Product eBike = new Product("E-Bike", "A bike with a battery"); - Product roadBike = new Product("Road bike", "A bike for competition"); - - productsByName.put(eBike.getName(), eBike); - productsByName.put(roadBike.getName(), roadBike); - - Product nextPurchase = productsByName.get("Car"); - - assertNull(nextPurchase); - } - - @Test - public void getExistingValueAfterSameKeyInsertedTwice() { - HashMap productsByName = new HashMap<>(); - - Product eBike = new Product("E-Bike", "A bike with a battery"); - Product roadBike = new Product("Road bike", "A bike for competition"); - Product newEBike = new Product("E-Bike", "A bike with a better battery"); - - productsByName.put(eBike.getName(), eBike); - productsByName.put(roadBike.getName(), roadBike); - productsByName.put(newEBike.getName(), newEBike); - - Product nextPurchase = productsByName.get("E-Bike"); - - assertEquals("A bike with a better battery", nextPurchase.getDescription()); - } - - @Test - public void getExistingValueWithNullKey() { - HashMap productsByName = new HashMap<>(); - - Product defaultProduct = new Product("Chocolate", "At least buy chocolate"); - - productsByName.put(null, defaultProduct); - productsByName.put(defaultProduct.getName(), defaultProduct); - - Product nextPurchase = productsByName.get(null); - assertEquals("At least buy chocolate", nextPurchase.getDescription()); - - nextPurchase = productsByName.get("Chocolate"); - assertEquals("At least buy chocolate", nextPurchase.getDescription()); - } - - @Test - public void insertSameObjectWithDifferentKey() { - HashMap productsByName = new HashMap<>(); - - Product defaultProduct = new Product("Chocolate", "At least buy chocolate"); - - productsByName.put(null, defaultProduct); - productsByName.put(defaultProduct.getName(), defaultProduct); - - assertSame(productsByName.get(null), productsByName.get("Chocolate")); - } - - @Test - public void checkIfKeyExists() { - HashMap productsByName = new HashMap<>(); - - Product eBike = new Product("E-Bike", "A bike with a battery"); - - productsByName.put(eBike.getName(), eBike); - - assertTrue(productsByName.containsKey("E-Bike")); - } - - @Test - public void checkIfValueExists() { - HashMap productsByName = new HashMap<>(); - - Product eBike = new Product("E-Bike", "A bike with a battery"); - - productsByName.put(eBike.getName(), eBike); - - assertTrue(productsByName.containsValue(eBike)); - } - - @Test - public void removeExistingKey() { - HashMap productsByName = new HashMap<>(); - - Product eBike = new Product("E-Bike", "A bike with a battery"); - Product roadBike = new Product("Road bike", "A bike for competition"); - - productsByName.put(eBike.getName(), eBike); - productsByName.put(roadBike.getName(), roadBike); - - productsByName.remove("E-Bike"); - - assertNull(productsByName.get("E-Bike")); - } - - @Test - public void givenMutableKeyWhenKeyChangeThenValueNotFound() { - // Given - MutableKey key = new MutableKey("initial"); - - Map items = new HashMap<>(); - items.put(key, "success"); - - // When - key.setName("changed"); - - // Then - assertNull(items.get(key)); - } - - static class MutableKey { - private String name; - - public MutableKey(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - MutableKey that = (MutableKey) o; - return Objects.equals(name, that.name); - } - - @Override - public int hashCode() { - return Objects.hash(name); - } - } - -} diff --git a/java-collections-maps-2/src/test/java/com/baeldung/map/convert/MapToStringUnitTest.java b/java-collections-maps-2/src/test/java/com/baeldung/map/convert/MapToStringUnitTest.java deleted file mode 100644 index 4517dea328..0000000000 --- a/java-collections-maps-2/src/test/java/com/baeldung/map/convert/MapToStringUnitTest.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.baeldung.map.convert; - -import org.apache.commons.collections4.MapUtils; -import org.junit.Assert; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.util.HashMap; -import java.util.Map; - -public class MapToStringUnitTest { - - private Map wordsByKey = new HashMap<>(); - - @BeforeEach - public void setup() { - wordsByKey.clear(); - wordsByKey.put(1, "one"); - wordsByKey.put(2, "two"); - wordsByKey.put(3, "three"); - wordsByKey.put(4, "four"); - } - - @Test - public void givenMap_WhenUsingIteration_ThenResultingMapIsCorrect() { - String mapAsString = MapToString.convertWithIteration(wordsByKey); - Assert.assertEquals("{1=one, 2=two, 3=three, 4=four}", mapAsString); - } - - @Test - public void givenMap_WhenUsingStream_ThenResultingMapIsCorrect() { - String mapAsString = MapToString.convertWithStream(wordsByKey); - Assert.assertEquals("{1=one, 2=two, 3=three, 4=four}", mapAsString); - } - - @Test - public void givenMap_WhenUsingGuava_ThenResultingMapIsCorrect() { - String mapAsString = MapToString.convertWithGuava(wordsByKey); - Assert.assertEquals("1=one,2=two,3=three,4=four", mapAsString); - } - - @Test - public void givenMap_WhenUsingApache_ThenResultingMapIsCorrect() { - String mapAsString = MapToString.convertWithApache(wordsByKey); - Assert.assertEquals("{1=one, 2=two, 3=three, 4=four}", mapAsString); - MapUtils.debugPrint(System.out, "Map as String", wordsByKey); - } -} \ No newline at end of file diff --git a/java-collections-maps-2/src/test/java/com/baeldung/map/convert/StringToMapUnitTest.java b/java-collections-maps-2/src/test/java/com/baeldung/map/convert/StringToMapUnitTest.java deleted file mode 100644 index 2f80b30871..0000000000 --- a/java-collections-maps-2/src/test/java/com/baeldung/map/convert/StringToMapUnitTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.baeldung.map.convert; - -import org.junit.Assert; -import org.junit.jupiter.api.Test; - -import java.util.Map; - -public class StringToMapUnitTest { - - @Test - public void givenString_WhenUsingStream_ThenResultingStringIsCorrect() { - Map wordsByKey = StringToMap.convertWithStream("1=one,2=two,3=three,4=four"); - Assert.assertEquals(4, wordsByKey.size()); - Assert.assertEquals("one", wordsByKey.get("1")); - } - - @Test - void givenString_WhenUsingGuava_ThenResultingStringIsCorrect() { - Map wordsByKey = StringToMap.convertWithGuava("1=one,2=two,3=three,4=four"); - Assert.assertEquals(4, wordsByKey.size()); - Assert.assertEquals("one", wordsByKey.get("1")); - } -} \ No newline at end of file diff --git a/java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/CopyHashMapUnitTest.java b/java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/CopyHashMapUnitTest.java deleted file mode 100644 index e2d5e327e1..0000000000 --- a/java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/CopyHashMapUnitTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.baeldung.map.copyhashmap; - -import com.google.common.collect.ImmutableMap; -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CopyHashMapUnitTest { - - @Test - public void givenHashMap_whenShallowCopy_thenCopyisNotSameAsOriginal() { - - HashMap map = new HashMap<>(); - Employee emp1 = new Employee("John"); - Employee emp2 = new Employee("Norman"); - map.put("emp1",emp1); - map.put("emp2",emp2); - - HashMap shallowCopy = CopyHashMap.shallowCopy(map); - - assertThat(shallowCopy).isNotSameAs(map); - - } - - @Test - public void givenHashMap_whenShallowCopyModifyingOriginalObject_thenCopyShouldChange() { - - HashMap map = new HashMap<>(); - Employee emp1 = new Employee("John"); - Employee emp2 = new Employee("Norman"); - map.put("emp1",emp1); - map.put("emp2",emp2); - - HashMap shallowCopy = CopyHashMap.shallowCopy(map); - - emp1.setName("Johny"); - - assertThat(shallowCopy.get("emp1")).isEqualTo(map.get("emp1")); - - } - - @Test - public void givenHashMap_whenDeepCopyModifyingOriginalObject_thenCopyShouldNotChange() { - - HashMap map = new HashMap<>(); - Employee emp1 = new Employee("John"); - Employee emp2 = new Employee("Norman"); - map.put("emp1",emp1); - map.put("emp2",emp2); - HashMap deepCopy = CopyHashMap.deepCopy(map); - - emp1.setName("Johny"); - - assertThat(deepCopy.get("emp1")).isNotEqualTo(map.get("emp1")); - - } - - @Test - public void givenImmutableMap_whenCopyUsingGuava_thenCopyShouldNotChange() { - Employee emp1 = new Employee("John"); - Employee emp2 = new Employee("Norman"); - - Map map = ImmutableMap. builder() - .put("emp1",emp1) - .put("emp2",emp2) - .build(); - Map shallowCopy = ImmutableMap.copyOf(map); - - assertThat(shallowCopy).isSameAs(map); - - } - -} diff --git a/java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/Employee.java b/java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/Employee.java deleted file mode 100644 index 5db55c26ea..0000000000 --- a/java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/Employee.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.map.copyhashmap; - -import java.io.Serializable; - -public class Employee implements Serializable{ - - private String name; - - public Employee(String name) { - super(); - this.name = name; - } - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public String toString() { - return this.name; - } - -} - - diff --git a/java-collections-maps-2/src/test/java/com/baeldung/map/initialize/MapInitializerUnitTest.java b/java-collections-maps-2/src/test/java/com/baeldung/map/initialize/MapInitializerUnitTest.java deleted file mode 100644 index 7c6dffe787..0000000000 --- a/java-collections-maps-2/src/test/java/com/baeldung/map/initialize/MapInitializerUnitTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.baeldung.map.initialize; - -import org.junit.Test; - -import java.util.Map; - -import static org.junit.Assert.assertEquals; - -public class MapInitializerUnitTest { - - @Test - public void givenStaticMap_whenUpdated_thenCorrect() { - - MapInitializer.articleMapOne.put("NewArticle1", "Convert array to List"); - - assertEquals(MapInitializer.articleMapOne.get("NewArticle1"), "Convert array to List"); - - } - - @Test(expected=UnsupportedOperationException.class) - public void givenSingleTonMap_whenEntriesAdded_throwsException() { - - Map map = MapInitializer.createSingletonMap(); - map.put("username2", "password2"); - } - -} diff --git a/java-collections-maps-2/src/test/java/com/baeldung/map/mapmax/MapMaxUnitTest.java b/java-collections-maps-2/src/test/java/com/baeldung/map/mapmax/MapMaxUnitTest.java deleted file mode 100644 index 30b945bfc8..0000000000 --- a/java-collections-maps-2/src/test/java/com/baeldung/map/mapmax/MapMaxUnitTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.baeldung.map.mapmax; - - -import org.junit.Before; -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.assertEquals; - -public class MapMaxUnitTest { - - Map map = null; - MapMax mapMax = null; - - - @Before - public void setupTestData() { - map = new HashMap(); - map.put(23, 12); - map.put(46, 24); - map.put(27, 38); - mapMax = new MapMax(); - } - - @Test - public void givenMap_whenIterated_thenReturnMaxValue() { - assertEquals(new Integer(38), mapMax.maxUsingIteration(map)); - } - - @Test - public void givenMap_whenUsingCollectionsMax_thenReturnMaxValue() { - assertEquals(new Integer(38), mapMax.maxUsingCollectionsMax(map)); - } - - @Test - public void givenMap_whenUsingCollectionsMaxAndLambda_thenReturnMaxValue() { - assertEquals(new Integer(38), mapMax.maxUsingCollectionsMaxAndLambda(map)); - } - - @Test - public void givenMap_whenUsingCollectionsMaxAndMethodReference_thenReturnMaxValue() { - assertEquals(new Integer(38), mapMax.maxUsingCollectionsMaxAndMethodReference(map)); - } - - @Test - public void givenMap_whenUsingStreamAndLambda_thenReturnMaxValue() { - assertEquals(new Integer(38), mapMax.maxUsingStreamAndLambda(map)); - } - - @Test - public void givenMap_whenUsingStreamAndMethodReference_thenReturnMaxValue() { - assertEquals(new Integer(38), mapMax.maxUsingStreamAndMethodReference (map)); - } - - -} diff --git a/java-collections-maps-2/src/test/java/com/baeldung/map/weakhashmap/WeakHashMapUnitTest.java b/java-collections-maps-2/src/test/java/com/baeldung/map/weakhashmap/WeakHashMapUnitTest.java deleted file mode 100644 index 293f24c378..0000000000 --- a/java-collections-maps-2/src/test/java/com/baeldung/map/weakhashmap/WeakHashMapUnitTest.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.baeldung.map.weakhashmap; - - -import org.junit.Test; - -import java.util.WeakHashMap; -import java.util.concurrent.TimeUnit; - -import static com.jayway.awaitility.Awaitility.await; -import static org.junit.Assert.assertTrue; - -public class WeakHashMapUnitTest { - - @Test - public void givenWeakHashMap_whenCacheValueThatHasNoReferenceToIt_GCShouldReclaimThatObject() { - //given - WeakHashMap map = new WeakHashMap<>(); - BigImage bigImage = new BigImage("image_id"); - UniqueImageName imageName = new UniqueImageName("name_of_big_image"); - - map.put(imageName, bigImage); - assertTrue(map.containsKey(imageName)); - - //when big image key is not reference anywhere - imageName = null; - System.gc(); - - //then GC will finally reclaim that object - await().atMost(10, TimeUnit.SECONDS).until(map::isEmpty); - } - - @Test - public void givenWeakHashMap_whenCacheValueThatHasNoReferenceToIt_GCShouldReclaimThatObjectButLeaveReferencedObject() { - //given - WeakHashMap map = new WeakHashMap<>(); - BigImage bigImageFirst = new BigImage("foo"); - UniqueImageName imageNameFirst = new UniqueImageName("name_of_big_image"); - - BigImage bigImageSecond = new BigImage("foo_2"); - UniqueImageName imageNameSecond = new UniqueImageName("name_of_big_image_2"); - - map.put(imageNameFirst, bigImageFirst); - map.put(imageNameSecond, bigImageSecond); - assertTrue(map.containsKey(imageNameFirst)); - assertTrue(map.containsKey(imageNameSecond)); - - //when - imageNameFirst = null; - System.gc(); - - //then - await().atMost(10, TimeUnit.SECONDS).until(() -> map.size() == 1); - await().atMost(10, TimeUnit.SECONDS).until(() -> map.containsKey(imageNameSecond)); - } - - - class BigImage { - public final String imageId; - - BigImage(String imageId) { - this.imageId = imageId; - } - } - - class UniqueImageName { - public final String imageName; - - UniqueImageName(String imageName) { - this.imageName = imageName; - } - } -} diff --git a/java-collections-maps-3/README.md b/java-collections-maps-3/README.md deleted file mode 100644 index 886461a35c..0000000000 --- a/java-collections-maps-3/README.md +++ /dev/null @@ -1,8 +0,0 @@ -## Java Collections Cookbooks and Examples - -This module contains articles about Map data structures in Java. - -### Relevant Articles: -- [Java TreeMap vs HashMap](https://www.baeldung.com/java-treemap-vs-hashmap) -- [Comparing Two HashMaps in Java](https://www.baeldung.com/java-compare-hashmaps) -- More articles: [[<-- prev]](/java-collections-maps-2) diff --git a/java-collections-maps-3/pom.xml b/java-collections-maps-3/pom.xml deleted file mode 100644 index 30b0d01528..0000000000 --- a/java-collections-maps-3/pom.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - 4.0.0 - java-collections-maps-3 - 0.1.0-SNAPSHOT - java-collections-maps-3 - jar - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../parent-java - - - - - - - - - - - \ No newline at end of file diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/compare/HashMapComparisonUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/compare/HashMapComparisonUnitTest.java deleted file mode 100644 index 0edd0cd87b..0000000000 --- a/java-collections-maps-3/src/test/java/com/baeldung/map/compare/HashMapComparisonUnitTest.java +++ /dev/null @@ -1,225 +0,0 @@ -package com.baeldung.map.compare; - -import com.google.common.base.Equivalence; -import com.google.common.collect.MapDifference; -import com.google.common.collect.MapDifference.ValueDifference; -import com.google.common.collect.Maps; -import org.junit.Before; -import org.junit.Test; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.collection.IsMapContaining.hasEntry; -import static org.hamcrest.collection.IsMapContaining.hasKey; -import static org.junit.Assert.*; - -public class HashMapComparisonUnitTest { - - Map asiaCapital1; - Map asiaCapital2; - Map asiaCapital3; - - Map asiaCity1; - Map asiaCity2; - Map asiaCity3; - - @Before - public void setup(){ - asiaCapital1 = new HashMap(); - asiaCapital1.put("Japan", "Tokyo"); - asiaCapital1.put("South Korea", "Seoul"); - - asiaCapital2 = new HashMap(); - asiaCapital2.put("South Korea", "Seoul"); - asiaCapital2.put("Japan", "Tokyo"); - - asiaCapital3 = new HashMap(); - asiaCapital3.put("Japan", "Tokyo"); - asiaCapital3.put("China", "Beijing"); - - asiaCity1 = new HashMap(); - asiaCity1.put("Japan", new String[] { "Tokyo", "Osaka" }); - asiaCity1.put("South Korea", new String[] { "Seoul", "Busan" }); - - asiaCity2 = new HashMap(); - asiaCity2.put("South Korea", new String[] { "Seoul", "Busan" }); - asiaCity2.put("Japan", new String[] { "Tokyo", "Osaka" }); - - asiaCity3 = new HashMap(); - asiaCity3.put("Japan", new String[] { "Tokyo", "Osaka" }); - asiaCity3.put("China", new String[] { "Beijing", "Hong Kong" }); - } - - @Test - public void whenCompareTwoHashMapsUsingEquals_thenSuccess() { - assertTrue(asiaCapital1.equals(asiaCapital2)); - assertFalse(asiaCapital1.equals(asiaCapital3)); - } - - @Test - public void whenCompareTwoHashMapsWithArrayValuesUsingEquals_thenFail() { - assertFalse(asiaCity1.equals(asiaCity2)); - } - - @Test - public void whenCompareTwoHashMapsUsingStreamAPI_thenSuccess() { - assertTrue(areEqual(asiaCapital1, asiaCapital2)); - assertFalse(areEqual(asiaCapital1, asiaCapital3)); - } - - @Test - public void whenCompareTwoHashMapsWithArrayValuesUsingStreamAPI_thenSuccess() { - assertTrue(areEqualWithArrayValue(asiaCity1, asiaCity2)); - assertFalse(areEqualWithArrayValue(asiaCity1, asiaCity3)); - } - - @Test - public void whenCompareTwoHashMapKeys_thenSuccess() { - assertTrue(asiaCapital1.keySet().equals(asiaCapital2.keySet())); - assertFalse(asiaCapital1.keySet().equals(asiaCapital3.keySet())); - } - - @Test - public void whenCompareTwoHashMapKeyValuesUsingStreamAPI_thenSuccess() { - Map asiaCapital3 = new HashMap(); - asiaCapital3.put("Japan", "Tokyo"); - asiaCapital3.put("South Korea", "Seoul"); - asiaCapital3.put("China", "Beijing"); - - Map asiaCapital4 = new HashMap(); - asiaCapital4.put("South Korea", "Seoul"); - asiaCapital4.put("Japan", "Osaka"); - asiaCapital4.put("China", "Beijing"); - - Map result = areEqualKeyValues(asiaCapital3, asiaCapital4); - - assertEquals(3, result.size()); - assertThat(result, hasEntry("Japan", false)); - assertThat(result, hasEntry("South Korea", true)); - assertThat(result, hasEntry("China", true)); - } - - @Test - public void givenDifferentMaps_whenGetDiffUsingGuava_thenSuccess() { - Map asia1 = new HashMap(); - asia1.put("Japan", "Tokyo"); - asia1.put("South Korea", "Seoul"); - asia1.put("India", "New Delhi"); - - Map asia2 = new HashMap(); - asia2.put("Japan", "Tokyo"); - asia2.put("China", "Beijing"); - asia2.put("India", "Delhi"); - - MapDifference diff = Maps.difference(asia1, asia2); - Map> entriesDiffering = diff.entriesDiffering(); - - assertFalse(diff.areEqual()); - assertEquals(1, entriesDiffering.size()); - assertThat(entriesDiffering, hasKey("India")); - assertEquals("New Delhi", entriesDiffering.get("India").leftValue()); - assertEquals("Delhi", entriesDiffering.get("India").rightValue()); - } - - @Test - public void givenDifferentMaps_whenGetEntriesOnOneSideUsingGuava_thenSuccess() { - Map asia1 = new HashMap(); - asia1.put("Japan", "Tokyo"); - asia1.put("South Korea", "Seoul"); - asia1.put("India", "New Delhi"); - - Map asia2 = new HashMap(); - asia2.put("Japan", "Tokyo"); - asia2.put("China", "Beijing"); - asia2.put("India", "Delhi"); - - MapDifference diff = Maps.difference(asia1, asia2); - Map entriesOnlyOnRight = diff.entriesOnlyOnRight(); - Map entriesOnlyOnLeft = diff.entriesOnlyOnLeft(); - - assertEquals(1, entriesOnlyOnRight.size()); - assertThat(entriesOnlyOnRight, hasEntry("China", "Beijing")); - assertEquals(1, entriesOnlyOnLeft.size()); - assertThat(entriesOnlyOnLeft, hasEntry("South Korea", "Seoul")); - } - - @Test - public void givenDifferentMaps_whenGetCommonEntriesUsingGuava_thenSuccess() { - Map asia1 = new HashMap(); - asia1.put("Japan", "Tokyo"); - asia1.put("South Korea", "Seoul"); - asia1.put("India", "New Delhi"); - - Map asia2 = new HashMap(); - asia2.put("Japan", "Tokyo"); - asia2.put("China", "Beijing"); - asia2.put("India", "Delhi"); - - MapDifference diff = Maps.difference(asia1, asia2); - Map entriesInCommon = diff.entriesInCommon(); - - assertEquals(1, entriesInCommon.size()); - assertThat(entriesInCommon, hasEntry("Japan", "Tokyo")); - } - - @Test - public void givenSimilarMapsWithArrayValue_whenCompareUsingGuava_thenFail() { - MapDifference diff = Maps.difference(asiaCity1, asiaCity2); - assertFalse(diff.areEqual()); - } - - @Test - public void givenSimilarMapsWithArrayValue_whenCompareUsingGuavaEquivalence_thenSuccess() { - Equivalence eq = new Equivalence() { - @Override - protected boolean doEquivalent(String[] a, String[] b) { - return Arrays.equals(a, b); - } - - @Override - protected int doHash(String[] value) { - return value.hashCode(); - } - }; - - MapDifference diff = Maps.difference(asiaCity1, asiaCity2, eq); - assertTrue(diff.areEqual()); - - diff = Maps.difference(asiaCity1, asiaCity3, eq); - assertFalse(diff.areEqual()); - } - - // =========================================================================== - - private boolean areEqual(Map first, Map second) { - if (first.size() != second.size()) { - return false; - } - - return first.entrySet() - .stream() - .allMatch(e -> e.getValue() - .equals(second.get(e.getKey()))); - } - - private boolean areEqualWithArrayValue(Map first, Map second) { - if (first.size() != second.size()) { - return false; - } - - return first.entrySet() - .stream() - .allMatch(e -> Arrays.equals(e.getValue(), second.get(e.getKey()))); - } - - private Map areEqualKeyValues(Map first, Map second) { - return first.entrySet() - .stream() - .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().equals(second.get(e.getKey())))); - } - -} diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/treemaphashmap/TreeMapVsHashMapUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/treemaphashmap/TreeMapVsHashMapUnitTest.java deleted file mode 100644 index 1057e3b9f0..0000000000 --- a/java-collections-maps-3/src/test/java/com/baeldung/map/treemaphashmap/TreeMapVsHashMapUnitTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.baeldung.map.treemaphashmap; - -import org.hamcrest.Matchers; -import org.junit.Assert; -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; -import java.util.TreeMap; - -public class TreeMapVsHashMapUnitTest { - - @Test - public void whenInsertObjectsTreeMap_thenNaturalOrder() { - Map treemap = new TreeMap<>(); - treemap.put(3, "TreeMap"); - treemap.put(2, "vs"); - treemap.put(1, "HashMap"); - Assert.assertThat(treemap.keySet(), Matchers.contains(1, 2, 3)); - } - - @Test(expected = NullPointerException.class) - public void whenInsertNullInTreeMap_thenException() { - Map treemap = new TreeMap<>(); - treemap.put(null, "NullPointerException"); - } - - @Test - public void whenInsertObjectsHashMap_thenRandomOrder() { - Map hashmap = new HashMap<>(); - hashmap.put(3, "TreeMap"); - hashmap.put(2, "vs"); - hashmap.put(1, "HashMap"); - Assert.assertThat(hashmap.keySet(), Matchers.containsInAnyOrder(1, 2, 3)); - } - - @Test - public void whenInsertNullInHashMap_thenInsertsNull() { - Map hashmap = new HashMap<>(); - hashmap.put(null, null); - Assert.assertNull(hashmap.get(null)); - } - - @Test - public void givenHashMapAndTreeMap_whenputDuplicates_thenOnlyUnique() { - Map treeMap = new HashMap<>(); - treeMap.put(1, "Baeldung"); - treeMap.put(1, "Baeldung"); - - Assert.assertTrue(treeMap.size() == 1); - - Map treeMap2 = new TreeMap<>(); - treeMap2.put(1, "Baeldung"); - treeMap2.put(1, "Baeldung"); - - Assert.assertTrue(treeMap2.size() == 1); - } -} \ No newline at end of file diff --git a/java-collections-maps/README.md b/java-collections-maps/README.md deleted file mode 100644 index 8fa6fa32fa..0000000000 --- a/java-collections-maps/README.md +++ /dev/null @@ -1,16 +0,0 @@ -## Java Collections Cookbooks and Examples - -This module contains articles about Map data structures in Java. - -### Relevant Articles: -- [Guide to the Guava BiMap](https://www.baeldung.com/guava-bimap) -- [A Guide to Java HashMap](https://www.baeldung.com/java-hashmap) -- [A Guide to LinkedHashMap in Java](https://www.baeldung.com/java-linked-hashmap) -- [A Guide to TreeMap in Java](https://www.baeldung.com/java-treemap) -- [How to Store Duplicate Keys in a Map in Java?](https://www.baeldung.com/java-map-duplicate-keys) -- [Get the Key for a Value from a Java Map](https://www.baeldung.com/java-map-key-from-value) -- [How to Check If a Key Exists in a Map](https://www.baeldung.com/java-map-key-exists) -- [Immutable Map Implementations in Java](https://www.baeldung.com/java-immutable-maps) -- [Guide to Apache Commons MultiValuedMap](https://www.baeldung.com/apache-commons-multi-valued-map) -- [The Java HashMap Under the Hood](https://www.baeldung.com/java-hashmap-advanced) -- More articles: [[next -->]](/java-collections-maps-2) diff --git a/java-collections-maps/pom.xml b/java-collections-maps/pom.xml deleted file mode 100644 index 38cf1c38ad..0000000000 --- a/java-collections-maps/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - 4.0.0 - java-collections-maps - 0.1.0-SNAPSHOT - java-collections-maps - jar - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../parent-java - - - - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - - - org.assertj - assertj-core - ${assertj.version} - test - - - - - 4.1 - 3.6.1 - - diff --git a/java-collections-maps/src/main/java/com/baeldung/map/MapUtil.java b/java-collections-maps/src/main/java/com/baeldung/map/MapUtil.java deleted file mode 100644 index 91b7197a92..0000000000 --- a/java-collections-maps/src/main/java/com/baeldung/map/MapUtil.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * - */ -package com.baeldung.map; - -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.stream.Stream; - -/** - * @author swpraman - * - */ -public class MapUtil { - - public static Stream keys(Map map, V value) { - return map.entrySet() - .stream() - .filter(entry -> value.equals(entry.getValue())) - .map(Map.Entry::getKey); - } - - public static Set getKeys(Map map, V value) { - Set keys = new HashSet<>(); - for (Entry entry : map.entrySet()) { - if (entry.getValue().equals(value)) { - keys.add(entry.getKey()); - } - } - return keys; - } - - public static K getKey(Map map, V value) { - for (Entry entry : map.entrySet()) { - if (entry.getValue().equals(value)) { - return entry.getKey(); - } - } - return null; - } - -} diff --git a/java-collections-maps/src/main/java/com/baeldung/map/MyKey.java b/java-collections-maps/src/main/java/com/baeldung/map/MyKey.java deleted file mode 100644 index 9993d7862c..0000000000 --- a/java-collections-maps/src/main/java/com/baeldung/map/MyKey.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.baeldung.map; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class MyKey { - private static final Logger LOG = LoggerFactory.getLogger(MyKey.class); - - private String name; - private int id; - - public MyKey(int id, String name) { - this.id = id; - this.name = name; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - @Override - public int hashCode() { - LOG.debug("Calling hashCode()"); - return id; - } - - @Override - public String toString() { - return "MyKey [name=" + name + ", id=" + id + "]"; - } - - @Override - public boolean equals(Object obj) { - LOG.debug("Calling equals() for key: " + obj); - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - MyKey other = (MyKey) obj; - if (id != other.id) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - return true; - } - -} diff --git a/java-collections-maps/src/main/java/com/baeldung/map/MyLinkedHashMap.java b/java-collections-maps/src/main/java/com/baeldung/map/MyLinkedHashMap.java deleted file mode 100644 index b687e57d85..0000000000 --- a/java-collections-maps/src/main/java/com/baeldung/map/MyLinkedHashMap.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.baeldung.map; - -import java.util.LinkedHashMap; -import java.util.Map; - -public class MyLinkedHashMap extends LinkedHashMap { - - /** - * - */ - private static final long serialVersionUID = 1L; - private static final int MAX_ENTRIES = 5; - - public MyLinkedHashMap(int initialCapacity, float loadFactor, boolean accessOrder) { - super(initialCapacity, loadFactor, accessOrder); - } - - @Override - protected boolean removeEldestEntry(Map.Entry eldest) { - return size() > MAX_ENTRIES; - } - -} diff --git a/java-collections-maps/src/main/resources/logback.xml b/java-collections-maps/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/java-collections-maps/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/java-collections-maps/src/test/java/com/baeldung/guava/GuavaBiMapUnitTest.java b/java-collections-maps/src/test/java/com/baeldung/guava/GuavaBiMapUnitTest.java deleted file mode 100644 index b44d2db1aa..0000000000 --- a/java-collections-maps/src/test/java/com/baeldung/guava/GuavaBiMapUnitTest.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.baeldung.guava; - -import static org.junit.Assert.*; -import java.util.HashMap; -import java.util.Map; -import org.junit.Test; -import com.google.common.collect.BiMap; -import com.google.common.collect.EnumHashBiMap; -import com.google.common.collect.HashBiMap; -import com.google.common.collect.ImmutableBiMap; - -public class GuavaBiMapUnitTest { - @Test - public void whenQueryByValue_returnsKey() { - final BiMap capitalCountryBiMap = HashBiMap.create(); - capitalCountryBiMap.put("New Delhi", "India"); - capitalCountryBiMap.put("Washingon, D.C.", "USA"); - capitalCountryBiMap.put("Moscow", "Russia"); - - final String countryCapitalName = capitalCountryBiMap.inverse().get("India"); - - assertEquals("New Delhi", countryCapitalName); - } - - @Test - public void whenCreateBiMapFromExistingMap_returnsKey() { - final Map capitalCountryMap = new HashMap<>(); - capitalCountryMap.put("New Delhi", "India"); - capitalCountryMap.put("Washingon, D.C.", "USA"); - capitalCountryMap.put("Moscow", "Russia"); - final BiMap capitalCountryBiMap = HashBiMap.create(capitalCountryMap); - - final String countryCapitalName = capitalCountryBiMap.inverse().get("India"); - - assertEquals("New Delhi", countryCapitalName); - } - - @Test - public void whenQueryByKey_returnsValue() { - final BiMap capitalCountryBiMap = HashBiMap.create(); - - capitalCountryBiMap.put("New Delhi", "India"); - capitalCountryBiMap.put("Washingon, D.C.", "USA"); - capitalCountryBiMap.put("Moscow", "Russia"); - - assertEquals("USA", capitalCountryBiMap.get("Washingon, D.C.")); - } - - @Test(expected = IllegalArgumentException.class) - public void whenSameValueIsPresent_throwsException() { - final BiMap capitalCountryBiMap = HashBiMap.create(); - - capitalCountryBiMap.put("New Delhi", "India"); - capitalCountryBiMap.put("Washingon, D.C.", "USA"); - capitalCountryBiMap.put("Moscow", "Russia"); - capitalCountryBiMap.put("Trump", "USA"); - } - - @Test - public void givenSameValueIsPresent_whenForcePut_completesSuccessfully() { - final BiMap capitalCountryBiMap = HashBiMap.create(); - - capitalCountryBiMap.put("New Delhi", "India"); - capitalCountryBiMap.put("Washingon, D.C.", "USA"); - capitalCountryBiMap.put("Moscow", "Russia"); - capitalCountryBiMap.forcePut("Trump", "USA"); - - assertEquals("USA", capitalCountryBiMap.get("Trump")); - assertEquals("Trump", capitalCountryBiMap.inverse().get("USA")); - } - - @Test - public void whenSameKeyIsPresent_replacesAlreadyPresent() { - final BiMap capitalCountryBiMap = HashBiMap.create(); - - capitalCountryBiMap.put("New Delhi", "India"); - capitalCountryBiMap.put("Washingon, D.C.", "USA"); - capitalCountryBiMap.put("Moscow", "Russia"); - capitalCountryBiMap.put("Washingon, D.C.", "HongKong"); - - assertEquals("HongKong", capitalCountryBiMap.get("Washingon, D.C.")); - } - - @Test - public void whenUsingImmutableBiMap_allowsPutSuccessfully() { - final BiMap capitalCountryBiMap = new ImmutableBiMap.Builder().put("New Delhi", "India").put("Washingon, D.C.", "USA").put("Moscow", "Russia").build(); - - assertEquals("USA", capitalCountryBiMap.get("Washingon, D.C.")); - } - - @Test(expected = UnsupportedOperationException.class) - public void whenUsingImmutableBiMap_doesntAllowRemove() { - final BiMap capitalCountryBiMap = new ImmutableBiMap.Builder().put("New Delhi", "India").put("Washingon, D.C.", "USA").put("Moscow", "Russia").build(); - - capitalCountryBiMap.remove("New Delhi"); - } - - @Test(expected = UnsupportedOperationException.class) - public void whenUsingImmutableBiMap_doesntAllowPut() { - final BiMap capitalCountryBiMap = new ImmutableBiMap.Builder().put("New Delhi", "India").put("Washingon, D.C.", "USA").put("Moscow", "Russia").build(); - - capitalCountryBiMap.put("New York", "USA"); - } - - private enum Operation { - ADD, SUBTRACT, MULTIPLY, DIVIDE - } - - @Test - public void whenUsingEnumAsKeyInMap_replacesAlreadyPresent() { - final BiMap operationStringBiMap = EnumHashBiMap.create(Operation.class); - - operationStringBiMap.put(Operation.ADD, "Add"); - operationStringBiMap.put(Operation.SUBTRACT, "Subtract"); - operationStringBiMap.put(Operation.MULTIPLY, "Multiply"); - operationStringBiMap.put(Operation.DIVIDE, "Divide"); - - assertEquals("Divide", operationStringBiMap.get(Operation.DIVIDE)); - } -} \ No newline at end of file diff --git a/java-collections-maps/src/test/java/com/baeldung/map/ImmutableMapUnitTest.java b/java-collections-maps/src/test/java/com/baeldung/map/ImmutableMapUnitTest.java deleted file mode 100644 index d308aac7eb..0000000000 --- a/java-collections-maps/src/test/java/com/baeldung/map/ImmutableMapUnitTest.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.baeldung.map; - -import com.google.common.collect.ImmutableMap; -import org.junit.jupiter.api.Test; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.*; - - -public class ImmutableMapUnitTest { - - @Test - public void whenCollectionsUnModifiableMapMethod_thenOriginalCollectionChangesReflectInUnmodifiableMap() { - - Map mutableMap = new HashMap<>(); - mutableMap.put("USA", "North America"); - - Map unmodifiableMap = Collections.unmodifiableMap(mutableMap); - assertThrows(UnsupportedOperationException.class, () -> unmodifiableMap.put("Canada", "North America")); - - mutableMap.remove("USA"); - assertFalse(unmodifiableMap.containsKey("USA")); - - mutableMap.put("Mexico", "North America"); - assertTrue(unmodifiableMap.containsKey("Mexico")); - } - - @Test - @SuppressWarnings("deprecation") - public void whenGuavaImmutableMapFromCopyOfMethod_thenOriginalCollectionChangesDoNotReflectInImmutableMap() { - - Map mutableMap = new HashMap<>(); - mutableMap.put("USA", "North America"); - - ImmutableMap immutableMap = ImmutableMap.copyOf(mutableMap); - assertTrue(immutableMap.containsKey("USA")); - - assertThrows(UnsupportedOperationException.class, () -> immutableMap.put("Canada", "North America")); - - mutableMap.remove("USA"); - assertTrue(immutableMap.containsKey("USA")); - - mutableMap.put("Mexico", "North America"); - assertFalse(immutableMap.containsKey("Mexico")); - } - - @Test - @SuppressWarnings("deprecation") - public void whenGuavaImmutableMapFromBuilderMethod_thenOriginalCollectionChangesDoNotReflectInImmutableMap() { - - Map mutableMap = new HashMap<>(); - mutableMap.put("USA", "North America"); - - ImmutableMap immutableMap = ImmutableMap.builder() - .putAll(mutableMap) - .put("Costa Rica", "North America") - .build(); - assertTrue(immutableMap.containsKey("USA")); - assertTrue(immutableMap.containsKey("Costa Rica")); - - assertThrows(UnsupportedOperationException.class, () -> immutableMap.put("Canada", "North America")); - - mutableMap.remove("USA"); - assertTrue(immutableMap.containsKey("USA")); - - mutableMap.put("Mexico", "North America"); - assertFalse(immutableMap.containsKey("Mexico")); - } - - @Test - @SuppressWarnings("deprecation") - public void whenGuavaImmutableMapFromOfMethod_thenOriginalCollectionChangesDoNotReflectInImmutableMap() { - - ImmutableMap immutableMap = ImmutableMap.of("USA", "North America", "Costa Rica", "North America"); - assertTrue(immutableMap.containsKey("USA")); - assertTrue(immutableMap.containsKey("Costa Rica")); - - assertThrows(UnsupportedOperationException.class, () -> immutableMap.put("Canada", "North America")); - } - -} diff --git a/java-collections-maps/src/test/java/com/baeldung/map/KeyCheckUnitTest.java b/java-collections-maps/src/test/java/com/baeldung/map/KeyCheckUnitTest.java deleted file mode 100644 index dbad2e5b5e..0000000000 --- a/java-collections-maps/src/test/java/com/baeldung/map/KeyCheckUnitTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.baeldung.map; - -import org.junit.Test; - -import java.util.Collections; -import java.util.Map; - -import static org.junit.Assert.*; - -public class KeyCheckUnitTest { - - @Test - public void whenKeyIsPresent_thenContainsKeyReturnsTrue() { - Map map = Collections.singletonMap("key", "value"); - - assertTrue(map.containsKey("key")); - assertFalse(map.containsKey("missing")); - } - - @Test - public void whenKeyHasNullValue_thenGetStillWorks() { - Map map = Collections.singletonMap("nothing", null); - - assertTrue(map.containsKey("nothing")); - assertNull(map.get("nothing")); - } -} \ No newline at end of file diff --git a/java-collections-maps/src/test/java/com/baeldung/map/MapMultipleValuesUnitTest.java b/java-collections-maps/src/test/java/com/baeldung/map/MapMultipleValuesUnitTest.java deleted file mode 100644 index 721b48ea7b..0000000000 --- a/java-collections-maps/src/test/java/com/baeldung/map/MapMultipleValuesUnitTest.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.baeldung.map; - -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.LinkedHashMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.TreeMultimap; -import org.apache.commons.collections4.MultiMap; -import org.apache.commons.collections4.MultiMapUtils; -import org.apache.commons.collections4.MultiValuedMap; -import org.apache.commons.collections4.map.MultiValueMap; -import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; -import org.apache.commons.collections4.multimap.HashSetValuedHashMap; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; - -import static org.assertj.core.api.Assertions.assertThat; - -public class MapMultipleValuesUnitTest { - private static final Logger LOG = LoggerFactory.getLogger(MapMultipleValuesUnitTest.class); - - @Test - public void givenHashMap_whenPuttingTwice_thenReturningFirstValue() { - Map map = new HashMap<>(); - assertThat(map.put("key1", "value1")).isEqualTo(null); - assertThat(map.put("key1", "value2")).isEqualTo("value1"); - assertThat(map.get("key1")).isEqualTo("value2"); - } - - @Test - public void givenCollectionAsValue_whenPuttingTwice_thenReturningCollection() { - Map> map = new HashMap<>(); - List list = new ArrayList<>(); - map.put("key1", list); - map.get("key1").add("value1"); - map.get("key1").add("value2"); - assertThat(map.get("key1").get(0)).isEqualTo("value1"); - assertThat(map.get("key1").get(1)).isEqualTo("value2"); - } - - @Test - public void givenCollectionAsValueAndJava8_whenPuttingTwice_thenReturningCollection() { - Map> map = new HashMap<>(); - map.computeIfAbsent("key1", k -> new ArrayList<>()).add("value1"); - map.computeIfAbsent("key1", k -> new ArrayList<>()).add("value2"); - assertThat(map.get("key1").get(0)).isEqualTo("value1"); - assertThat(map.get("key1").get(1)).isEqualTo("value2"); - } - - @Test - public void givenMultiValueMap_whenPuttingTwice_thenReturningValues() { - MultiMap map = new MultiValueMap<>(); - map.put("key1", "value1"); - map.put("key1", "value2"); - assertThat((Collection) map.get("key1")) - .contains("value1", "value2"); - } - - @Test - public void givenArrayListValuedHashMap_whenPuttingDoubleValues_thenReturningAllValues() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - map.put("key1", "value1"); - map.put("key1", "value2"); - map.put("key1", "value2"); - assertThat((Collection) map.get("key1")) - .containsExactly("value1", "value2", "value2"); - } - - @Test - public void givenHashSetValuedHashMap_whenPuttingTwiceTheSame_thenReturningOneValue() { - MultiValuedMap map = new HashSetValuedHashMap<>(); - map.put("key1", "value1"); - map.put("key1", "value1"); - assertThat((Collection) map.get("key1")) - .containsExactly("value1"); - } - - @Test(expected = UnsupportedOperationException.class) - public void givenUnmodifiableMultiValuedMap_whenInserting_thenThrowingException() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - map.put("key1", "value1"); - map.put("key1", "value2"); - MultiValuedMap immutableMap = - MultiMapUtils.unmodifiableMultiValuedMap(map); - immutableMap.put("key1", "value3"); - } - - @Test - public void givenArrayListMultiMap_whenInserting_thenCorrectOutput() { - Multimap map = ArrayListMultimap.create(); - map.put("key1", "value2"); - map.put("key1", "value1"); - assertThat((Collection) map.get("key1")) - .containsExactly("value2", "value1"); - } - - @Test - public void givenLinkedHashMultiMap_whenInserting_thenReturningValuesInInsertionOrder() { - Multimap map = LinkedHashMultimap.create(); - map.put("key1", "value3"); - map.put("key1", "value1"); - map.put("key1", "value2"); - assertThat((Collection) map.get("key1")) - .containsExactly("value3", "value1", "value2"); - } - - @Test - public void givenTreeMultimap_whenInserting_thenReturningValuesInNaturalOrder() { - Multimap map = TreeMultimap.create(); - map.put("key1", "value3"); - map.put("key1", "value1"); - map.put("key1", "value2"); - assertThat((Collection) map.get("key1")) - .containsExactly("value1", "value2", "value3"); - } - -} \ No newline at end of file diff --git a/java-collections-maps/src/test/java/com/baeldung/map/MapUnitTest.java b/java-collections-maps/src/test/java/com/baeldung/map/MapUnitTest.java deleted file mode 100644 index eaf68ccba5..0000000000 --- a/java-collections-maps/src/test/java/com/baeldung/map/MapUnitTest.java +++ /dev/null @@ -1,336 +0,0 @@ -package com.baeldung.map; - -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; -import java.util.Map.Entry; - -import static org.junit.Assert.*; - -public class MapUnitTest { - private static final Logger LOG = LoggerFactory.getLogger(MapUnitTest.class); - - - @Test - public void givenHashMap_whenRetrievesKeyset_thenCorrect() { - Map map = new HashMap<>(); - map.put("name", "baeldung"); - map.put("type", "blog"); - - Set keys = map.keySet(); - - assertEquals(2, keys.size()); - assertTrue(keys.contains("name")); - assertTrue(keys.contains("type")); - } - - @Test - public void givenHashMap_whenRetrievesValues_thenCorrect() { - Map map = new HashMap<>(); - map.put("name", "baeldung"); - map.put("type", "blog"); - - Collection values = map.values(); - - assertEquals(2, values.size()); - assertTrue(values.contains("baeldung")); - assertTrue(values.contains("blog")); - } - - @Test - public void givenHashMap_whenRetrievesEntries_thenCorrect() { - Map map = new HashMap<>(); - map.put("name", "baeldung"); - map.put("type", "blog"); - - Set> entries = map.entrySet(); - - assertEquals(2, entries.size()); - for (Entry e : entries) { - String key = e.getKey(); - String val = e.getValue(); - assertTrue(key.equals("name") || key.equals("type")); - assertTrue(val.equals("baeldung") || val.equals("blog")); - } - } - - @Test - public void givenKeySet_whenChangeReflectsInMap_thenCorrect() { - Map map = new HashMap<>(); - map.put("name", "baeldung"); - map.put("type", "blog"); - - assertEquals(2, map.size()); - - Set keys = map.keySet(); - - keys.remove("name"); - assertEquals(1, map.size()); - } - - @Test(expected = ConcurrentModificationException.class) - public void givenIterator_whenFailsFastOnModification_thenCorrect() { - Map map = new HashMap<>(); - map.put("name", "baeldung"); - map.put("type", "blog"); - - Set keys = map.keySet(); - Iterator it = keys.iterator(); - map.remove("type"); - while (it.hasNext()) { - String key = it.next(); - } - } - - public void givenIterator_whenRemoveWorks_thenCorrect() { - Map map = new HashMap<>(); - map.put("name", "baeldung"); - map.put("type", "blog"); - - Set keys = map.keySet(); - Iterator it = keys.iterator(); - while (it.hasNext()) { - it.next(); - it.remove(); - } - assertEquals(0, map.size()); - } - - @Test - public void whenHashCodeIsCalledOnPut_thenCorrect() { - MyKey key = new MyKey(1, "name"); - Map map = new HashMap<>(); - map.put(key, "val"); - } - - @Test - public void whenHashCodeIsCalledOnGet_thenCorrect() { - MyKey key = new MyKey(1, "name"); - Map map = new HashMap<>(); - map.put(key, "val"); - map.get(key); - } - - @Test - public void whenGetWorks_thenCorrect() { - Map map = new HashMap<>(); - map.put("key", "val"); - - String val = map.get("key"); - - assertEquals("val", val); - } - - @Test - public void givenNewKey_whenPutReturnsNull_thenCorrect() { - Map map = new HashMap<>(); - - String rtnVal = map.put("key1", "val1"); - - assertNull(rtnVal); - } - - @Test - public void givenUnmappedKey_whenGetReturnsNull_thenCorrect() { - Map map = new HashMap<>(); - - String rtnVal = map.get("key1"); - - assertNull(rtnVal); - } - - @Test - public void givenNullVal_whenPutReturnsNull_thenCorrect() { - Map map = new HashMap<>(); - - String rtnVal = map.put("key1", null); - - assertNull(rtnVal); - } - - @Test - public void givenNullKeyAndVal_whenAccepts_thenCorrect() { - Map map = new HashMap<>(); - - map.put(null, null); - } - - @Test - public void givenNullVal_whenRetrieves_thenCorrect() { - Map map = new HashMap<>(); - map.put("key", null); - - String val = map.get("key"); - - assertNull(val); - } - - @Test - public void whenContainsDistinguishesNullValues_thenCorrect() { - Map map = new HashMap<>(); - - String val1 = map.get("key"); - boolean valPresent = map.containsKey("key"); - - assertNull(val1); - assertFalse(valPresent); - - map.put("key", null); - String val = map.get("key"); - valPresent = map.containsKey("key"); - - assertNull(val); - assertTrue(valPresent); - - } - - @Test - public void whenPutReturnsPrevValue_thenCorrect() { - Map map = new HashMap<>(); - map.put("key1", "val1"); - String rtnVal = map.put("key1", "val2"); - - assertEquals("val1", rtnVal); - } - - @Test - public void whenCallsEqualsOnCollision_thenCorrect() { - HashMap map = new HashMap<>(); - MyKey k1 = new MyKey(1, "firstKey"); - MyKey k2 = new MyKey(2, "secondKey"); - MyKey k3 = new MyKey(2, "thirdKey"); - - LOG.debug("storing value for k1"); - map.put(k1, "firstValue"); - - LOG.debug("storing value for k2"); - map.put(k2, "secondValue"); - - LOG.debug("storing value for k3"); - map.put(k3, "thirdValue"); - - LOG.debug("retrieving value for k1"); - String v1 = map.get(k1); - - LOG.debug("retrieving value for k2"); - String v2 = map.get(k2); - - LOG.debug("retrieving value for k3"); - String v3 = map.get(k3); - - assertEquals("firstValue", v1); - assertEquals("secondValue", v2); - assertEquals("thirdValue", v3); - - } - - @Test - public void givenLinkedHashMap_whenGetsOrderedKeyset_thenCorrect() { - LinkedHashMap map = new LinkedHashMap<>(); - map.put(1, null); - map.put(2, null); - map.put(3, null); - map.put(4, null); - map.put(5, null); - Set keys = map.keySet(); - Integer[] arr = keys.toArray(new Integer[0]); - for (int i = 0; i < arr.length; i++) { - assertEquals(new Integer(i + 1), arr[i]); - - } - } - - @Test - public void givenLinkedHashMap_whenAccessOrderWorks_thenCorrect() { - LinkedHashMap map = new LinkedHashMap<>(16, .75f, true); - map.put(1, null); - map.put(2, null); - map.put(3, null); - map.put(4, null); - map.put(5, null); - Set keys = map.keySet(); - assertEquals("[1, 2, 3, 4, 5]", keys.toString()); - map.get(4); - assertEquals("[1, 2, 3, 5, 4]", keys.toString()); - map.get(1); - assertEquals("[2, 3, 5, 4, 1]", keys.toString()); - map.get(3); - assertEquals("[2, 5, 4, 1, 3]", keys.toString()); - } - - @Test - public void givenLinkedHashMap_whenRemovesEldestEntry_thenCorrect() { - LinkedHashMap map = new MyLinkedHashMap<>(16, .75f, true); - map.put(1, null); - map.put(2, null); - map.put(3, null); - map.put(4, null); - map.put(5, null); - Set keys = map.keySet(); - assertEquals("[1, 2, 3, 4, 5]", keys.toString()); - map.put(6, null); - assertEquals("[2, 3, 4, 5, 6]", keys.toString()); - map.put(7, null); - assertEquals("[3, 4, 5, 6, 7]", keys.toString()); - map.put(8, null); - assertEquals("[4, 5, 6, 7, 8]", keys.toString()); - } - - @Test - public void givenTreeMap_whenOrdersEntriesNaturally_thenCorrect() { - TreeMap map = new TreeMap<>(); - map.put(3, "val"); - map.put(2, "val"); - map.put(1, "val"); - map.put(5, "val"); - map.put(4, "val"); - assertEquals("[1, 2, 3, 4, 5]", map.keySet().toString()); - } - - @Test - public void givenTreeMap_whenOrdersEntriesNaturally_thenCorrect2() { - TreeMap map = new TreeMap<>(); - map.put("c", "val"); - map.put("b", "val"); - map.put("a", "val"); - map.put("e", "val"); - map.put("d", "val"); - - assertEquals("[a, b, c, d, e]", map.keySet().toString()); - } - - @Test - public void givenTreeMap_whenOrdersEntriesByComparator_thenCorrect() { - TreeMap map = new TreeMap<>(Comparator.reverseOrder()); - map.put(3, "val"); - map.put(2, "val"); - map.put(1, "val"); - map.put(5, "val"); - map.put(4, "val"); - - assertEquals("[5, 4, 3, 2, 1]", map.keySet().toString()); - } - - @Test - public void givenTreeMap_whenPerformsQueries_thenCorrect() { - TreeMap map = new TreeMap<>(); - map.put(3, "val"); - map.put(2, "val"); - map.put(1, "val"); - map.put(5, "val"); - map.put(4, "val"); - - Integer highestKey = map.lastKey(); - Integer lowestKey = map.firstKey(); - Set keysLessThan3 = map.headMap(3).keySet(); - Set keysGreaterThanEqTo3 = map.tailMap(3).keySet(); - - assertEquals(new Integer(5), highestKey); - assertEquals(new Integer(1), lowestKey); - assertEquals("[1, 2]", keysLessThan3.toString()); - assertEquals("[3, 4, 5]", keysGreaterThanEqTo3.toString()); - } - -} diff --git a/java-collections-maps/src/test/java/com/baeldung/map/MapUtilUnitTest.java b/java-collections-maps/src/test/java/com/baeldung/map/MapUtilUnitTest.java deleted file mode 100644 index f8e4c8fd8a..0000000000 --- a/java-collections-maps/src/test/java/com/baeldung/map/MapUtilUnitTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * - */ -package com.baeldung.map; - -import com.google.common.collect.HashBiMap; -import org.apache.commons.collections4.BidiMap; -import org.apache.commons.collections4.bidimap.DualHashBidiMap; -import org.junit.Test; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.stream.Collectors; - -import static org.junit.Assert.assertEquals; - -/** - * @author swpraman - * - */ -public class MapUtilUnitTest { - - - @Test - public void whenUsingImperativeWayForSingleKey_shouldReturnSingleKey() { - Map capitalCountryMap = new HashMap<>(); - capitalCountryMap.put("Tokyo", "Japan"); - capitalCountryMap.put("New Delhi", "India"); - assertEquals("New Delhi", MapUtil.getKey(capitalCountryMap, "India")); - } - - @Test - public void whenUsingImperativeWayForAllKeys_shouldReturnAllKeys() { - Map capitalCountryMap = new HashMap<>(); - capitalCountryMap.put("Tokyo", "Japan"); - capitalCountryMap.put("Berlin", "Germany"); - capitalCountryMap.put("Cape Town", "South Africa"); - capitalCountryMap.put("Pretoria", "South Africa"); - capitalCountryMap.put("Bloemfontein", "South Africa"); - - assertEquals(new HashSet(Arrays.asList( - new String[] {"Cape Town", "Pretoria", "Bloemfontein"})), - MapUtil.getKeys(capitalCountryMap, "South Africa")); - } - - @Test - public void whenUsingFunctionalWayForSingleKey_shouldReturnSingleKey() { - Map capitalCountryMap = new HashMap<>(); - capitalCountryMap.put("Tokyo", "Japan"); - capitalCountryMap.put("Berlin", "Germany"); - assertEquals("Berlin", MapUtil.keys(capitalCountryMap, "Germany").findFirst().get()); - } - - @Test - public void whenUsingFunctionalWayForAllKeys_shouldReturnAllKeys() { - Map capitalCountryMap = new HashMap<>(); - capitalCountryMap.put("Tokyo", "Japan"); - capitalCountryMap.put("Berlin", "Germany"); - capitalCountryMap.put("Cape Town", "South Africa"); - capitalCountryMap.put("Pretoria", "South Africa"); - capitalCountryMap.put("Bloemfontein", "South Africa"); - assertEquals(new HashSet(Arrays.asList( - new String[] {"Cape Town", "Pretoria", "Bloemfontein"})), - MapUtil.keys(capitalCountryMap, "South Africa").collect(Collectors.toSet())); - } - - @Test - public void whenUsingBidiMap_shouldReturnKey() { - BidiMap capitalCountryMap = new DualHashBidiMap(); - capitalCountryMap.put("Berlin", "Germany"); - capitalCountryMap.put("Cape Town", "South Africa"); - assertEquals("Berlin", capitalCountryMap.getKey("Germany")); - } - - @Test - public void whenUsingBidiMapAddDuplicateValue_shouldRemoveOldEntry() { - BidiMap capitalCountryMap = new DualHashBidiMap(); - capitalCountryMap.put("Berlin", "Germany"); - capitalCountryMap.put("Cape Town", "South Africa"); - capitalCountryMap.put("Pretoria", "South Africa"); - assertEquals("Pretoria", capitalCountryMap.getKey("South Africa")); - } - - @Test - public void whenUsingBiMap_shouldReturnKey() { - HashBiMap capitalCountryMap = HashBiMap.create(); - capitalCountryMap.put("Berlin", "Germany"); - capitalCountryMap.put("Cape Town", "South Africa"); - assertEquals("Berlin", capitalCountryMap.inverse().get("Germany")); - } - - @Test(expected=IllegalArgumentException.class) - public void whenUsingBiMapAddDuplicateValue_shouldThrowException() { - HashBiMap capitalCountryMap = HashBiMap.create(); - capitalCountryMap.put("Berlin", "Germany"); - capitalCountryMap.put("Cape Town", "South Africa"); - capitalCountryMap.put("Pretoria", "South Africa"); - assertEquals("Berlin", capitalCountryMap.inverse().get("Germany")); - } - -} diff --git a/java-collections-maps/src/test/java/com/baeldung/map/MultiValuedMapUnitTest.java b/java-collections-maps/src/test/java/com/baeldung/map/MultiValuedMapUnitTest.java deleted file mode 100644 index 686c1cef87..0000000000 --- a/java-collections-maps/src/test/java/com/baeldung/map/MultiValuedMapUnitTest.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.baeldung.map; - -import org.apache.commons.collections4.MultiMapUtils; -import org.apache.commons.collections4.MultiSet; -import org.apache.commons.collections4.MultiValuedMap; -import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; -import org.apache.commons.collections4.multimap.HashSetValuedHashMap; -import org.junit.Test; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; - -public class MultiValuedMapUnitTest { - - @Test - public void givenMultiValuesMap_whenPuttingMultipleValuesUsingPutMethod_thenReturningAllValues() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - - map.put("fruits", "apple"); - map.put("fruits", "orange"); - - assertThat((Collection) map.get("fruits")).containsExactly("apple", "orange"); - - } - - @Test - public void givenMultiValuesMap_whenPuttingMultipleValuesUsingPutAllMethod_thenReturningAllValues() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - - map.putAll("vehicles", Arrays.asList("car", "bike")); - - assertThat((Collection) map.get("vehicles")).containsExactly("car", "bike"); - - } - - @Test - public void givenMultiValuesMap_whenGettingValueUsingGetMethod_thenReturningValue() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - - map.put("fruits", "apple"); - - assertThat((Collection) map.get("fruits")).containsExactly("apple"); - } - - @Test - public void givenMultiValuesMap_whenUsingEntriesMethod_thenReturningMappings() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - map.put("fruits", "apple"); - map.put("fruits", "orange"); - - Collection> entries = (Collection>) map.entries(); - - for(Map.Entry entry : entries) { - assertThat(entry.getKey()).contains("fruits"); - assertTrue(entry.getValue().equals("apple") || entry.getValue().equals("orange") ); - } - } - - @Test - public void givenMultiValuesMap_whenUsingKeysMethod_thenReturningAllKeys() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - map.put("fruits", "apple"); - map.put("fruits", "orange"); - map.put("vehicles", "car"); - map.put("vehicles", "bike"); - - MultiSet keys = map.keys(); - - assertThat((keys)).contains("fruits", "vehicles"); - - } - - @Test - public void givenMultiValuesMap_whenUsingKeySetMethod_thenReturningAllKeys() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - map.put("fruits", "apple"); - map.put("fruits", "orange"); - map.put("vehicles", "car"); - map.put("vehicles", "bike"); - - Set keys = map.keySet(); - - assertThat(keys).contains("fruits", "vehicles"); - - } - - @Test - public void givenMultiValuesMap_whenUsingValuesMethod_thenReturningAllValues() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - - map.put("fruits", "apple"); - map.put("fruits", "orange"); - map.put("vehicles", "car"); - map.put("vehicles", "bike"); - - assertThat(((Collection) map.values())).contains("apple", "orange", "car", "bike"); - } - - @Test - public void givenMultiValuesMap_whenUsingRemoveMethod_thenReturningUpdatedMap() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - - map.put("fruits", "apple"); - map.put("fruits", "orange"); - map.put("vehicles", "car"); - map.put("vehicles", "bike"); - assertThat(((Collection) map.values())).contains("apple", "orange", "car", "bike"); - - map.remove("fruits"); - - assertThat(((Collection) map.values())).contains("car", "bike"); - - } - - @Test - public void givenMultiValuesMap_whenUsingRemoveMappingMethod_thenReturningUpdatedMapAfterMappingRemoved() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - - map.put("fruits", "apple"); - map.put("fruits", "orange"); - map.put("vehicles", "car"); - map.put("vehicles", "bike"); - assertThat(((Collection) map.values())).contains("apple", "orange", "car", "bike"); - - map.removeMapping("fruits", "apple"); - - assertThat(((Collection) map.values())).contains("orange", "car", "bike"); - } - - @Test - public void givenMultiValuesMap_whenUsingClearMethod_thenReturningEmptyMap() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - map.put("fruits", "apple"); - map.put("fruits", "orange"); - map.put("vehicles", "car"); - map.put("vehicles", "bike"); - assertThat(((Collection) map.values())).contains("apple", "orange", "car", "bike"); - - map.clear(); - - assertTrue(map.isEmpty()); - } - - @Test - public void givenMultiValuesMap_whenUsingContainsKeyMethod_thenReturningTrue() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - map.put("fruits", "apple"); - map.put("fruits", "orange"); - map.put("vehicles", "car"); - map.put("vehicles", "bike"); - - assertTrue(map.containsKey("fruits")); - } - - @Test - public void givenMultiValuesMap_whenUsingContainsValueMethod_thenReturningTrue() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - map.put("fruits", "apple"); - map.put("fruits", "orange"); - map.put("vehicles", "car"); - map.put("vehicles", "bike"); - - assertTrue(map.containsValue("orange")); - } - - @Test - public void givenMultiValuesMap_whenUsingIsEmptyMethod_thenReturningFalse() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - map.put("fruits", "apple"); - map.put("fruits", "orange"); - map.put("vehicles", "car"); - map.put("vehicles", "bike"); - - assertFalse(map.isEmpty()); - } - - @Test - public void givenMultiValuesMap_whenUsingSizeMethod_thenReturningElementCount() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - map.put("fruits", "apple"); - map.put("fruits", "orange"); - map.put("vehicles", "car"); - map.put("vehicles", "bike"); - - assertEquals(4, map.size()); - } - - @Test - public void givenArrayListValuedHashMap_whenPuttingDoubleValues_thenReturningAllValues() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - map.put("fruits", "apple"); - map.put("fruits", "orange"); - map.put("fruits", "orange"); - - assertThat((Collection) map.get("fruits")).containsExactly("apple", "orange", "orange"); - } - - @Test - public void givenHashSetValuedHashMap_whenPuttingTwiceTheSame_thenReturningOneValue() { - MultiValuedMap map = new HashSetValuedHashMap<>(); - map.put("fruits", "apple"); - map.put("fruits", "apple"); - - assertThat((Collection) map.get("fruits")).containsExactly("apple"); - } - - @Test(expected = UnsupportedOperationException.class) - public void givenUnmodifiableMultiValuedMap_whenInserting_thenThrowingException() { - MultiValuedMap map = new ArrayListValuedHashMap<>(); - map.put("fruits", "apple"); - map.put("fruits", "orange"); - MultiValuedMap immutableMap = MultiMapUtils.unmodifiableMultiValuedMap(map); - - immutableMap.put("fruits", "banana"); - - } - - -} From cb7bd8d2f2d6e94ad5d8846886c041edbd8bbdcb Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 7 Apr 2020 14:50:03 +0530 Subject: [PATCH 114/503] JAVA-1188: Moved modules to core-java-modules --- .../core-java-collections-maps-2/README.md | 16 + .../core-java-collections-maps-2/pom.xml | 79 ++++ .../main/java/com/baeldung/map/Product.java | 133 +++++++ .../com/baeldung/map/convert/MapToString.java | 34 ++ .../com/baeldung/map/convert/StringToMap.java | 21 ++ .../baeldung/map/copyhashmap/CopyHashMap.java | 55 +++ .../map/initialize/MapInitializer.java | 80 +++++ .../baeldung/map/iteration/MapIteration.java | 74 ++++ .../java/com/baeldung/map/mapmax/MapMax.java | 92 +++++ .../com/baeldung/map/mergemaps/Employee.java | 60 ++++ .../com/baeldung/map/mergemaps/MergeMaps.java | 105 ++++++ .../map/primitives/PrimitiveMaps.java | 69 ++++ .../com/baeldung/map/sort/SortHashMap.java | 104 ++++++ .../com/baeldung/map/ProductUnitTest.java | 174 +++++++++ .../map/convert/MapToStringUnitTest.java | 48 +++ .../map/convert/StringToMapUnitTest.java | 23 ++ .../map/copyhashmap/CopyHashMapUnitTest.java | 76 ++++ .../baeldung/map/copyhashmap/Employee.java | 28 ++ .../initialize/MapInitializerUnitTest.java | 27 ++ .../baeldung/map/mapmax/MapMaxUnitTest.java | 58 +++ .../map/weakhashmap/WeakHashMapUnitTest.java | 72 ++++ .../core-java-collections-maps-3/README.md | 8 + .../core-java-collections-maps-3/pom.xml | 26 ++ .../compare/HashMapComparisonUnitTest.java | 225 ++++++++++++ .../TreeMapVsHashMapUnitTest.java | 58 +++ .../core-java-collections-maps/README.md | 16 + .../core-java-collections-maps/pom.xml | 35 ++ .../main/java/com/baeldung/map/MapUtil.java | 44 +++ .../src/main/java/com/baeldung/map/MyKey.java | 64 ++++ .../com/baeldung/map/MyLinkedHashMap.java | 23 ++ .../src/main/resources/logback.xml | 13 + .../baeldung/guava/GuavaBiMapUnitTest.java | 120 +++++++ .../baeldung/map/ImmutableMapUnitTest.java | 84 +++++ .../com/baeldung/map/KeyCheckUnitTest.java | 27 ++ .../map/MapMultipleValuesUnitTest.java | 119 +++++++ .../java/com/baeldung/map/MapUnitTest.java | 336 ++++++++++++++++++ .../com/baeldung/map/MapUtilUnitTest.java | 103 ++++++ .../baeldung/map/MultiValuedMapUnitTest.java | 227 ++++++++++++ core-java-modules/pom.xml | 3 + 39 files changed, 2959 insertions(+) create mode 100644 core-java-modules/core-java-collections-maps-2/README.md create mode 100644 core-java-modules/core-java-collections-maps-2/pom.xml create mode 100644 core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/Product.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/convert/MapToString.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/convert/StringToMap.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/copyhashmap/CopyHashMap.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/initialize/MapInitializer.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/iteration/MapIteration.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/mapmax/MapMax.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/Employee.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/MergeMaps.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/primitives/PrimitiveMaps.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/sort/SortHashMap.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/ProductUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/convert/MapToStringUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/convert/StringToMapUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/CopyHashMapUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/Employee.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/initialize/MapInitializerUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/mapmax/MapMaxUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/weakhashmap/WeakHashMapUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps-3/README.md create mode 100644 core-java-modules/core-java-collections-maps-3/pom.xml create mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/compare/HashMapComparisonUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/treemaphashmap/TreeMapVsHashMapUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps/README.md create mode 100644 core-java-modules/core-java-collections-maps/pom.xml create mode 100644 core-java-modules/core-java-collections-maps/src/main/java/com/baeldung/map/MapUtil.java create mode 100644 core-java-modules/core-java-collections-maps/src/main/java/com/baeldung/map/MyKey.java create mode 100644 core-java-modules/core-java-collections-maps/src/main/java/com/baeldung/map/MyLinkedHashMap.java create mode 100644 core-java-modules/core-java-collections-maps/src/main/resources/logback.xml create mode 100644 core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/guava/GuavaBiMapUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/ImmutableMapUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/KeyCheckUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/MapMultipleValuesUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/MapUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/MapUtilUnitTest.java create mode 100644 core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/MultiValuedMapUnitTest.java diff --git a/core-java-modules/core-java-collections-maps-2/README.md b/core-java-modules/core-java-collections-maps-2/README.md new file mode 100644 index 0000000000..da9279b191 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/README.md @@ -0,0 +1,16 @@ +## Java Collections Cookbooks and Examples + +This module contains articles about Map data structures in Java. + +### Relevant Articles: +- [Map of Primitives in Java](https://www.baeldung.com/java-map-primitives) +- [Copying a HashMap in Java](https://www.baeldung.com/java-copy-hashmap) +- [A Guide to Java HashMap](https://www.baeldung.com/java-hashmap) +- [Guide to WeakHashMap in Java](https://www.baeldung.com/java-weakhashmap) +- [Map to String Conversion in Java](https://www.baeldung.com/java-map-to-string-conversion) +- [Iterate over a Map in Java](https://www.baeldung.com/java-iterate-map) +- [Merging Two Maps with Java 8](https://www.baeldung.com/java-merge-maps) +- [Sort a HashMap in Java](https://www.baeldung.com/java-hashmap-sort) +- [Finding the Highest Value in a Java Map](https://www.baeldung.com/java-find-map-max) +- [Initialize a HashMap in Java](https://www.baeldung.com/java-initialize-hashmap) +- More articles: [[<-- prev]](/core-java-collections-maps) [[next -->]](/core-java-collections-maps-3) diff --git a/core-java-modules/core-java-collections-maps-2/pom.xml b/core-java-modules/core-java-collections-maps-2/pom.xml new file mode 100644 index 0000000000..a08a4ac072 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/pom.xml @@ -0,0 +1,79 @@ + + + 4.0.0 + core-java-collections-maps-2 + 0.1.0-SNAPSHOT + core-java-collections-maps-2 + jar + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + + + + + org.eclipse.collections + eclipse-collections + ${eclipse-collections.version} + + + net.sf.trove4j + trove4j + ${trove4j.version} + + + it.unimi.dsi + fastutil + ${fastutil.version} + + + colt + colt + ${colt.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + one.util + streamex + ${streamex.version} + + + com.jayway.awaitility + awaitility + ${avaitility.version} + test + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + 0.6.5 + 4.1 + 1.7.0 + 8.2.0 + 3.0.2 + 8.1.0 + 1.2.0 + 3.11.1 + + + \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/Product.java b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/Product.java new file mode 100644 index 0000000000..5559895730 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/Product.java @@ -0,0 +1,133 @@ +package com.baeldung.map; + +import java.util.*; + +public class Product { + + private String name; + private String description; + private List tags; + + public Product(String name, String description) { + this.name = name; + this.description = description; + this.tags = new ArrayList<>(); + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public List getTags() { + return tags; + } + + public Product addTagsOfOtherProdcut(Product product) { + this.tags.addAll(product.getTags()); + return this; + } + + @Override + public boolean equals(Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + Product product = (Product) o; + return Objects.equals(name, product.name) && + Objects.equals(description, product.description); + } + + @Override + public int hashCode() { + return Objects.hash(name, description); + } + + public static void forEach() { + + HashMap productsByName = new HashMap<>(); + productsByName.forEach( (key, product) + -> System.out.println("Key: " + key + " Product:" + product.getDescription()) + //do something with the key and value + ); + + //Prior to Java 8: + for(Map.Entry entry : productsByName.entrySet()) { + Product product = entry.getValue(); + String key = entry.getKey(); + //do something with the key and value + } + } + + public static void getOrDefault() { + + HashMap productsByName = new HashMap<>(); + Product chocolate = new Product("chocolate", "something sweet"); + Product defaultProduct = productsByName.getOrDefault("horse carriage", chocolate); + Product bike = productsByName.getOrDefault("E-Bike", chocolate); + + //Prior to Java 8: + Product bike2 = productsByName.containsKey("E-Bike") + ? productsByName.get("E-Bike") + : chocolate; + Product defaultProduct2 = productsByName.containsKey("horse carriage") + ? productsByName.get("horse carriage") + : chocolate; + } + + public static void putIfAbsent() { + + HashMap productsByName = new HashMap<>(); + Product chocolate = new Product("chocolate", "something sweet"); + productsByName.putIfAbsent("E-Bike", chocolate); + + //Prior to Java 8: + if(productsByName.containsKey("E-Bike")) { + productsByName.put("E-Bike", chocolate); + } + } + + public static void merge() { + + HashMap productsByName = new HashMap<>(); + Product eBike2 = new Product("E-Bike", "A bike with a battery"); + eBike2.getTags().add("sport"); + productsByName.merge("E-Bike", eBike2, Product::addTagsOfOtherProdcut); + + //Prior to Java 8: + if(productsByName.containsKey("E-Bike")) { + productsByName.get("E-Bike").addTagsOfOtherProdcut(eBike2); + } else { + productsByName.put("E-Bike", eBike2); + } + } + + public static void compute() { + + HashMap productsByName = new HashMap<>(); + Product eBike2 = new Product("E-Bike", "A bike with a battery"); + + productsByName.compute("E-Bike", (k,v) -> { + if(v != null) { + return v.addTagsOfOtherProdcut(eBike2); + } else { + return eBike2; + } + }); + + //Prior to Java 8: + if(productsByName.containsKey("E-Bike")) { + productsByName.get("E-Bike").addTagsOfOtherProdcut(eBike2); + } else { + productsByName.put("E-Bike", eBike2); + } + } +} diff --git a/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/convert/MapToString.java b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/convert/MapToString.java new file mode 100644 index 0000000000..d13be924ff --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/convert/MapToString.java @@ -0,0 +1,34 @@ +package com.baeldung.map.convert; + +import com.google.common.base.Joiner; +import org.apache.commons.lang3.StringUtils; + +import java.util.Map; +import java.util.stream.Collectors; + +public class MapToString { + + public static String convertWithIteration(Map map) { + StringBuilder mapAsString = new StringBuilder("{"); + for (Integer key : map.keySet()) { + mapAsString.append(key + "=" + map.get(key) + ", "); + } + mapAsString.delete(mapAsString.length()-2, mapAsString.length()).append("}"); + return mapAsString.toString(); + } + + public static String convertWithStream(Map map) { + String mapAsString = map.keySet().stream() + .map(key -> key + "=" + map.get(key)) + .collect(Collectors.joining(", ", "{", "}")); + return mapAsString; + } + + public static String convertWithGuava(Map map) { + return Joiner.on(",").withKeyValueSeparator("=").join(map); + } + + public static String convertWithApache(Map map) { + return StringUtils.join(map); + } +} diff --git a/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/convert/StringToMap.java b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/convert/StringToMap.java new file mode 100644 index 0000000000..416ba4dd9a --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/convert/StringToMap.java @@ -0,0 +1,21 @@ +package com.baeldung.map.convert; + +import com.google.common.base.Splitter; + +import java.util.Arrays; +import java.util.Map; +import java.util.stream.Collectors; + +public class StringToMap { + + public static Map convertWithStream(String mapAsString) { + Map map = Arrays.stream(mapAsString.split(",")) + .map(entry -> entry.split("=")) + .collect(Collectors.toMap(entry -> entry[0], entry -> entry[1])); + return map; + } + + public static Map convertWithGuava(String mapAsString) { + return Splitter.on(',').withKeyValueSeparator('=').split(mapAsString); + } +} diff --git a/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/copyhashmap/CopyHashMap.java b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/copyhashmap/CopyHashMap.java new file mode 100644 index 0000000000..cb18f3aa11 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/copyhashmap/CopyHashMap.java @@ -0,0 +1,55 @@ +package com.baeldung.map.copyhashmap; + +import org.apache.commons.lang3.SerializationUtils; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.stream.Collectors; + +public class CopyHashMap { + + public static HashMap copyUsingConstructor(HashMap originalMap) { + return new HashMap(originalMap); + } + + public static HashMap copyUsingClone(HashMap originalMap) { + return (HashMap) originalMap.clone(); + } + + public static HashMap copyUsingPut(HashMap originalMap) { + HashMap shallowCopy = new HashMap(); + Set> entries = originalMap.entrySet(); + for(Map.Entry mapEntry: entries) { + shallowCopy.put(mapEntry.getKey(), mapEntry.getValue()); + } + + return shallowCopy; + } + + public static HashMap copyUsingPutAll(HashMap originalMap) { + HashMap shallowCopy = new HashMap(); + shallowCopy.putAll(originalMap); + + return shallowCopy; + } + + public static HashMap copyUsingJava8Stream(HashMap originalMap) { + Set> entries = originalMap.entrySet(); + HashMap shallowCopy = (HashMap) entries + .stream() + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + return shallowCopy; + } + + public static HashMap shallowCopy(HashMap originalMap) { + return (HashMap) originalMap.clone(); + } + + public static HashMap deepCopy(HashMap originalMap) { + return SerializationUtils.clone(originalMap); + } + +} diff --git a/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/initialize/MapInitializer.java b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/initialize/MapInitializer.java new file mode 100644 index 0000000000..4d63abcfd0 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/initialize/MapInitializer.java @@ -0,0 +1,80 @@ +package com.baeldung.map.initialize; + +import java.util.AbstractMap; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class MapInitializer { + + public static Map articleMapOne; + static { + articleMapOne = new HashMap<>(); + articleMapOne.put("ar01", "Intro to Map"); + articleMapOne.put("ar02", "Some article"); + } + + public static Map createSingletonMap() { + Map passwordMap = Collections.singletonMap("username1", "password1"); + return passwordMap; + + } + + public Map createEmptyMap() { + Map emptyMap = Collections.emptyMap(); + return emptyMap; + } + + public Map createUsingDoubleBrace() { + Map doubleBraceMap = new HashMap() { + + /** + * + */ + private static final long serialVersionUID = 1L; + + { + put("key1", "value1"); + put("key2", "value2"); + } + }; + return doubleBraceMap; + } + + public Map createMapUsingStreamStringArray() { + Map map = Stream.of(new String[][] { { "Hello", "World" }, { "John", "Doe" }, }) + .collect(Collectors.toMap(data -> data[0], data -> data[1])); + + return map; + } + + public Map createMapUsingStreamObjectArray() { + Map map = Stream.of(new Object[][] { { "data1", 1 }, { "data2", 2 }, }) + .collect(Collectors.toMap(data -> (String) data[0], data -> (Integer) data[1])); + + return map; + } + + public Map createMapUsingStreamSimpleEntry() { + Map map = Stream.of(new AbstractMap.SimpleEntry<>("idea", 1), new AbstractMap.SimpleEntry<>("mobile", 2)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + return map; + } + + public Map createMapUsingStreamSimpleImmutableEntry() { + Map map = Stream.of(new AbstractMap.SimpleImmutableEntry<>("idea", 1), new AbstractMap.SimpleImmutableEntry<>("mobile", 2)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + return map; + } + + public Map createImmutableMapWithStreams() { + Map map = Stream.of(new String[][] { { "Hello", "World" }, { "John", "Doe" }, }) + .collect(Collectors.collectingAndThen(Collectors.toMap(data -> data[0], data -> data[1]), Collections:: unmodifiableMap)); + return map; + + } +} diff --git a/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/iteration/MapIteration.java b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/iteration/MapIteration.java new file mode 100644 index 0000000000..b0c32e1487 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/iteration/MapIteration.java @@ -0,0 +1,74 @@ +package com.baeldung.map.iteration; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public class MapIteration { + + public static void main(String[] args) { + MapIteration mapIteration = new MapIteration(); + Map map = new HashMap<>(); + + map.put("One", 1); + map.put("Three", 3); + map.put("Two", 2); + + System.out.println("Iterating Keys of Map Using KeySet"); + mapIteration.iterateKeys(map); + + System.out.println("Iterating Map Using Entry Set"); + mapIteration.iterateUsingEntrySet(map); + + System.out.println("Iterating Using Iterator and Map Entry"); + mapIteration.iterateUsingIteratorAndEntry(map); + + System.out.println("Iterating Using KeySet and For Each"); + mapIteration.iterateUsingKeySetAndForeach(map); + + System.out.println("Iterating Map Using Lambda Expression"); + mapIteration.iterateUsingLambda(map); + + System.out.println("Iterating Using Stream API"); + mapIteration.iterateUsingStreamAPI(map); + } + + public void iterateUsingEntrySet(Map map) { + for (Map.Entry entry : map.entrySet()) { + System.out.println(entry.getKey() + ":" + entry.getValue()); + } + } + + public void iterateUsingLambda(Map map) { + map.forEach((k, v) -> System.out.println((k + ":" + v))); + } + + public void iterateUsingIteratorAndEntry(Map map) { + Iterator> iterator = map.entrySet() + .iterator(); + while (iterator.hasNext()) { + Map.Entry pair = iterator.next(); + System.out.println(pair.getKey() + ":" + pair.getValue()); + } + } + + public void iterateUsingKeySetAndForeach(Map map) { + for (String key : map.keySet()) { + System.out.println(key + ":" + map.get(key)); + } + } + + public void iterateUsingStreamAPI(Map map) { + map.entrySet() + .stream() + .forEach(e -> System.out.println(e.getKey() + ":" + e.getValue())); + } + + public void iterateKeys(Map map) { + for (String key : map.keySet()) { + System.out.println(key); + } + + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/mapmax/MapMax.java b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/mapmax/MapMax.java new file mode 100644 index 0000000000..8c33c857ee --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/mapmax/MapMax.java @@ -0,0 +1,92 @@ +package com.baeldung.map.mapmax; + +import java.util.*; +import java.util.Map.Entry; + +public class MapMax { + + public > V maxUsingIteration(Map map) { + + Map.Entry maxEntry = null; + + for (Map.Entry entry : map.entrySet()) { + + if (maxEntry == null || entry.getValue() + .compareTo(maxEntry.getValue()) > 0) { + maxEntry = entry; + } + } + + return maxEntry.getValue(); + } + + public > V maxUsingCollectionsMax(Map map) { + + Entry maxEntry = Collections.max(map.entrySet(), new Comparator>() { + public int compare(Entry e1, Entry e2) { + return e1.getValue() + .compareTo(e2.getValue()); + } + }); + + return maxEntry.getValue(); + } + + public > V maxUsingCollectionsMaxAndLambda(Map map) { + + Entry maxEntry = Collections.max(map.entrySet(), (Entry e1, Entry e2) -> e1.getValue() + .compareTo(e2.getValue())); + + return maxEntry.getValue(); + } + + public > V maxUsingCollectionsMaxAndMethodReference(Map map) { + + Entry maxEntry = Collections.max(map.entrySet(), Comparator.comparing(Map.Entry::getValue)); + + return maxEntry.getValue(); + } + + public > V maxUsingStreamAndLambda(Map map) { + + Optional> maxEntry = map.entrySet() + .stream() + .max((Entry e1, Entry e2) -> e1.getValue() + .compareTo(e2.getValue())); + + return maxEntry.get() + .getValue(); + } + + public > V maxUsingStreamAndMethodReference(Map map) { + + Optional> maxEntry = map.entrySet() + .stream() + .max(Comparator.comparing(Map.Entry::getValue)); + + return maxEntry.get() + .getValue(); + } + + public static void main(String[] args) { + + Map map = new HashMap(); + + map.put(1, 3); + map.put(2, 4); + map.put(3, 5); + map.put(4, 6); + map.put(5, 7); + + MapMax mapMax = new MapMax(); + + System.out.println(mapMax.maxUsingIteration(map)); + System.out.println(mapMax.maxUsingCollectionsMax(map)); + System.out.println(mapMax.maxUsingCollectionsMaxAndLambda(map)); + System.out.println(mapMax.maxUsingCollectionsMaxAndMethodReference(map)); + System.out.println(mapMax.maxUsingStreamAndLambda(map)); + System.out.println(mapMax.maxUsingStreamAndMethodReference(map)); + + } + +} diff --git a/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/Employee.java b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/Employee.java new file mode 100644 index 0000000000..d7fb0d1a1d --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/Employee.java @@ -0,0 +1,60 @@ +package com.baeldung.map.mergemaps; + +public class Employee implements Comparable { + + private Long id; + private String name; + + public Employee(Long id, String name) { + this.name = name; + this.id = id; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Employee employee = (Employee) o; + + if (!id.equals(employee.id)) return false; + return name.equals(employee.name); + + } + + @Override + public int hashCode() { + int result = id.hashCode(); + result = 31 * result + name.hashCode(); + return result; + } + + @Override + public String toString() { + return "Employee{" + + "id=" + id + + ", name='" + name + '\'' + + '}'; + } + + @Override + public int compareTo(Employee employee) { + return (int)(this.id - employee.getId()); + } +} diff --git a/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/MergeMaps.java b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/MergeMaps.java new file mode 100644 index 0000000000..4f187bad90 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/mergemaps/MergeMaps.java @@ -0,0 +1,105 @@ +package com.baeldung.map.mergemaps; + +import one.util.streamex.EntryStream; + +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class MergeMaps { + + private static Map map1 = new HashMap<>(); + private static Map map2 = new HashMap<>(); + + public static void main(String[] args) { + + initialize(); + + mergeFunction(); + + streamConcat(); + + streamOf(); + + streamEx(); + + streamMerge(); + } + + private static void streamMerge() { + + Map map3 = map2.entrySet() + .stream() + .collect( + Collectors.toMap( + Map.Entry::getKey, + Map.Entry::getValue, + (v1, v2) -> new Employee(v1.getId(), v2.getName()), + () -> new HashMap<>(map1) + ) + ); + + System.out.println(map3); + } + + private static void streamEx() { + Map map3 = EntryStream.of(map1) + .append(EntryStream.of(map2)) + .toMap((e1, e2) -> e1); + + System.out.println(map3); + + } + + private static void streamOf() { + Map map3 = Stream.of(map1, map2) + .flatMap(map -> map.entrySet().stream()) + .collect( + Collectors.toMap( + Map.Entry::getKey, + Map.Entry::getValue, + (v1, v2) -> new Employee(v1.getId(), v2.getName()) + ) + ); + + map3.entrySet().forEach(System.out::println); + } + + private static void streamConcat() { + Map result = Stream.concat(map1.entrySet().stream(), map2.entrySet().stream()).collect(Collectors.toMap( + Map.Entry::getKey, + Map.Entry::getValue, + (value1, value2) -> new Employee(value2.getId(), value1.getName()) + )); + + result.entrySet().forEach(System.out::println); + } + + private static void mergeFunction() { + Map map3 = new HashMap<>(map1); + + map2.forEach( + (key, value) -> map3.merge(key, value, (v1, v2) -> + new Employee(v1.getId(), v2.getName())) + ); + + map3.entrySet().forEach(System.out::println); + } + + + private static void initialize() { + Employee employee1 = new Employee(1L, "Henry"); + map1.put(employee1.getName(), employee1); + Employee employee2 = new Employee(22L, "Annie"); + map1.put(employee2.getName(), employee2); + Employee employee3 = new Employee(8L, "John"); + map1.put(employee3.getName(), employee3); + + Employee employee4 = new Employee(2L, "George"); + map2.put(employee4.getName(), employee4); + Employee employee5 = new Employee(3L, "Henry"); + map2.put(employee5.getName(), employee5); + } + +} diff --git a/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/primitives/PrimitiveMaps.java b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/primitives/PrimitiveMaps.java new file mode 100644 index 0000000000..30bec12ccc --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/primitives/PrimitiveMaps.java @@ -0,0 +1,69 @@ +package com.baeldung.map.primitives; + +import cern.colt.map.AbstractIntDoubleMap; +import cern.colt.map.OpenIntDoubleHashMap; +import gnu.trove.map.TDoubleIntMap; +import gnu.trove.map.hash.TDoubleIntHashMap; +import it.unimi.dsi.fastutil.ints.Int2BooleanMap; +import it.unimi.dsi.fastutil.ints.Int2BooleanOpenHashMap; +import it.unimi.dsi.fastutil.ints.Int2BooleanSortedMap; +import it.unimi.dsi.fastutil.ints.Int2BooleanSortedMaps; +import org.eclipse.collections.api.map.primitive.ImmutableIntIntMap; +import org.eclipse.collections.api.map.primitive.MutableIntIntMap; +import org.eclipse.collections.api.map.primitive.MutableObjectDoubleMap; +import org.eclipse.collections.impl.factory.primitive.IntIntMaps; +import org.eclipse.collections.impl.factory.primitive.ObjectDoubleMaps; + +public class PrimitiveMaps { + + public static void main(String[] args) { + + eclipseCollectionsMap(); + troveMap(); + coltMap(); + fastutilMap(); + } + + private static void fastutilMap() { + Int2BooleanMap int2BooleanMap = new Int2BooleanOpenHashMap(); + int2BooleanMap.put(1, true); + int2BooleanMap.put(7, false); + int2BooleanMap.put(4, true); + + boolean value = int2BooleanMap.get(1); + + Int2BooleanSortedMap int2BooleanSorted = Int2BooleanSortedMaps.EMPTY_MAP; + } + + private static void coltMap() { + AbstractIntDoubleMap map = new OpenIntDoubleHashMap(); + map.put(1, 4.5); + double value = map.get(1); + } + + private static void eclipseCollectionsMap() { + MutableIntIntMap mutableIntIntMap = IntIntMaps.mutable.empty(); + mutableIntIntMap.addToValue(1, 1); + + ImmutableIntIntMap immutableIntIntMap = IntIntMaps.immutable.empty(); + + MutableObjectDoubleMap dObject = ObjectDoubleMaps.mutable.empty(); + dObject.addToValue("price", 150.5); + dObject.addToValue("quality", 4.4); + dObject.addToValue("stability", 0.8); + } + + private static void troveMap() { + double[] doubles = new double[] {1.2, 4.5, 0.3}; + int[] ints = new int[] {1, 4, 0}; + + TDoubleIntMap doubleIntMap = new TDoubleIntHashMap(doubles, ints); + + doubleIntMap.put(1.2, 22); + doubleIntMap.put(4.5, 16); + + doubleIntMap.adjustValue(1.2, 1); + doubleIntMap.adjustValue(4.5, 4); + doubleIntMap.adjustValue(0.3, 7); + } +} diff --git a/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/sort/SortHashMap.java b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/sort/SortHashMap.java new file mode 100644 index 0000000000..14610ffb00 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/main/java/com/baeldung/map/sort/SortHashMap.java @@ -0,0 +1,104 @@ +package com.baeldung.map.sort; + +import com.baeldung.map.mergemaps.Employee; +import com.google.common.base.Functions; +import com.google.common.collect.ImmutableSortedMap; +import com.google.common.collect.Ordering; + +import java.util.*; +import java.util.stream.Collectors; + +public class SortHashMap { + + private static Map map = new HashMap<>(); + + public static void main(String[] args) { + + initialize(); + + treeMapSortByKey(); + + arrayListSortByValue(); + arrayListSortByKey(); + + sortStream(); + + sortGuava(); + + addDuplicates(); + + treeSetByKey(); + treeSetByValue(); + + } + + private static void sortGuava() { + final Ordering naturalOrdering = + Ordering.natural().onResultOf(Functions.forMap(map, null)); + + System.out.println(ImmutableSortedMap.copyOf(map, naturalOrdering)); + } + + private static void sortStream() { + map.entrySet().stream() + .sorted(Map.Entry.comparingByKey().reversed()) + .forEach(System.out::println); + + Map result = map.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, + (oldValue, newValue) -> oldValue, LinkedHashMap::new)); + + result.entrySet().forEach(System.out::println); + } + + private static void treeSetByValue() { + SortedSet values = new TreeSet<>(map.values()); + System.out.println(values); + } + + private static void treeSetByKey() { + SortedSet keysSet = new TreeSet<>(map.keySet()); + System.out.println(keysSet); + } + + private static void treeMapSortByKey() { + TreeMap sorted = new TreeMap<>(map); + sorted.putAll(map); + + sorted.entrySet().forEach(System.out::println); + + } + + private static void arrayListSortByValue() { + List employeeById = new ArrayList<>(map.values()); + + Collections.sort(employeeById); + + System.out.println(employeeById); + } + + private static void arrayListSortByKey() { + List employeeByKey = new ArrayList<>(map.keySet()); + Collections.sort(employeeByKey); + System.out.println(employeeByKey); + } + + private static void initialize() { + Employee employee1 = new Employee(1L, "Mher"); + map.put(employee1.getName(), employee1); + Employee employee2 = new Employee(22L, "Annie"); + map.put(employee2.getName(), employee2); + Employee employee3 = new Employee(8L, "John"); + map.put(employee3.getName(), employee3); + Employee employee4 = new Employee(2L, "George"); + map.put(employee4.getName(), employee4); + } + + private static void addDuplicates() { + Employee employee5 = new Employee(1L, "Mher"); + map.put(employee5.getName(), employee5); + Employee employee6 = new Employee(22L, "Annie"); + map.put(employee6.getName(), employee6); + } +} diff --git a/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/ProductUnitTest.java b/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/ProductUnitTest.java new file mode 100644 index 0000000000..ba29d5c454 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/ProductUnitTest.java @@ -0,0 +1,174 @@ +package com.baeldung.map; + +import org.junit.jupiter.api.Test; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +import static org.junit.jupiter.api.Assertions.*; + +class ProductUnitTest { + + + @Test + public void getExistingValue() { + HashMap productsByName = new HashMap<>(); + + Product eBike = new Product("E-Bike", "A bike with a battery"); + Product roadBike = new Product("Road bike", "A bike for competition"); + + productsByName.put(eBike.getName(), eBike); + productsByName.put(roadBike.getName(), roadBike); + + Product nextPurchase = productsByName.get("E-Bike"); + + assertEquals("A bike with a battery", nextPurchase.getDescription()); + } + + @Test + public void getNonExistingValue() { + HashMap productsByName = new HashMap<>(); + + Product eBike = new Product("E-Bike", "A bike with a battery"); + Product roadBike = new Product("Road bike", "A bike for competition"); + + productsByName.put(eBike.getName(), eBike); + productsByName.put(roadBike.getName(), roadBike); + + Product nextPurchase = productsByName.get("Car"); + + assertNull(nextPurchase); + } + + @Test + public void getExistingValueAfterSameKeyInsertedTwice() { + HashMap productsByName = new HashMap<>(); + + Product eBike = new Product("E-Bike", "A bike with a battery"); + Product roadBike = new Product("Road bike", "A bike for competition"); + Product newEBike = new Product("E-Bike", "A bike with a better battery"); + + productsByName.put(eBike.getName(), eBike); + productsByName.put(roadBike.getName(), roadBike); + productsByName.put(newEBike.getName(), newEBike); + + Product nextPurchase = productsByName.get("E-Bike"); + + assertEquals("A bike with a better battery", nextPurchase.getDescription()); + } + + @Test + public void getExistingValueWithNullKey() { + HashMap productsByName = new HashMap<>(); + + Product defaultProduct = new Product("Chocolate", "At least buy chocolate"); + + productsByName.put(null, defaultProduct); + productsByName.put(defaultProduct.getName(), defaultProduct); + + Product nextPurchase = productsByName.get(null); + assertEquals("At least buy chocolate", nextPurchase.getDescription()); + + nextPurchase = productsByName.get("Chocolate"); + assertEquals("At least buy chocolate", nextPurchase.getDescription()); + } + + @Test + public void insertSameObjectWithDifferentKey() { + HashMap productsByName = new HashMap<>(); + + Product defaultProduct = new Product("Chocolate", "At least buy chocolate"); + + productsByName.put(null, defaultProduct); + productsByName.put(defaultProduct.getName(), defaultProduct); + + assertSame(productsByName.get(null), productsByName.get("Chocolate")); + } + + @Test + public void checkIfKeyExists() { + HashMap productsByName = new HashMap<>(); + + Product eBike = new Product("E-Bike", "A bike with a battery"); + + productsByName.put(eBike.getName(), eBike); + + assertTrue(productsByName.containsKey("E-Bike")); + } + + @Test + public void checkIfValueExists() { + HashMap productsByName = new HashMap<>(); + + Product eBike = new Product("E-Bike", "A bike with a battery"); + + productsByName.put(eBike.getName(), eBike); + + assertTrue(productsByName.containsValue(eBike)); + } + + @Test + public void removeExistingKey() { + HashMap productsByName = new HashMap<>(); + + Product eBike = new Product("E-Bike", "A bike with a battery"); + Product roadBike = new Product("Road bike", "A bike for competition"); + + productsByName.put(eBike.getName(), eBike); + productsByName.put(roadBike.getName(), roadBike); + + productsByName.remove("E-Bike"); + + assertNull(productsByName.get("E-Bike")); + } + + @Test + public void givenMutableKeyWhenKeyChangeThenValueNotFound() { + // Given + MutableKey key = new MutableKey("initial"); + + Map items = new HashMap<>(); + items.put(key, "success"); + + // When + key.setName("changed"); + + // Then + assertNull(items.get(key)); + } + + static class MutableKey { + private String name; + + public MutableKey(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MutableKey that = (MutableKey) o; + return Objects.equals(name, that.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } + } + +} diff --git a/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/convert/MapToStringUnitTest.java b/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/convert/MapToStringUnitTest.java new file mode 100644 index 0000000000..4517dea328 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/convert/MapToStringUnitTest.java @@ -0,0 +1,48 @@ +package com.baeldung.map.convert; + +import org.apache.commons.collections4.MapUtils; +import org.junit.Assert; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.util.HashMap; +import java.util.Map; + +public class MapToStringUnitTest { + + private Map wordsByKey = new HashMap<>(); + + @BeforeEach + public void setup() { + wordsByKey.clear(); + wordsByKey.put(1, "one"); + wordsByKey.put(2, "two"); + wordsByKey.put(3, "three"); + wordsByKey.put(4, "four"); + } + + @Test + public void givenMap_WhenUsingIteration_ThenResultingMapIsCorrect() { + String mapAsString = MapToString.convertWithIteration(wordsByKey); + Assert.assertEquals("{1=one, 2=two, 3=three, 4=four}", mapAsString); + } + + @Test + public void givenMap_WhenUsingStream_ThenResultingMapIsCorrect() { + String mapAsString = MapToString.convertWithStream(wordsByKey); + Assert.assertEquals("{1=one, 2=two, 3=three, 4=four}", mapAsString); + } + + @Test + public void givenMap_WhenUsingGuava_ThenResultingMapIsCorrect() { + String mapAsString = MapToString.convertWithGuava(wordsByKey); + Assert.assertEquals("1=one,2=two,3=three,4=four", mapAsString); + } + + @Test + public void givenMap_WhenUsingApache_ThenResultingMapIsCorrect() { + String mapAsString = MapToString.convertWithApache(wordsByKey); + Assert.assertEquals("{1=one, 2=two, 3=three, 4=four}", mapAsString); + MapUtils.debugPrint(System.out, "Map as String", wordsByKey); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/convert/StringToMapUnitTest.java b/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/convert/StringToMapUnitTest.java new file mode 100644 index 0000000000..2f80b30871 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/convert/StringToMapUnitTest.java @@ -0,0 +1,23 @@ +package com.baeldung.map.convert; + +import org.junit.Assert; +import org.junit.jupiter.api.Test; + +import java.util.Map; + +public class StringToMapUnitTest { + + @Test + public void givenString_WhenUsingStream_ThenResultingStringIsCorrect() { + Map wordsByKey = StringToMap.convertWithStream("1=one,2=two,3=three,4=four"); + Assert.assertEquals(4, wordsByKey.size()); + Assert.assertEquals("one", wordsByKey.get("1")); + } + + @Test + void givenString_WhenUsingGuava_ThenResultingStringIsCorrect() { + Map wordsByKey = StringToMap.convertWithGuava("1=one,2=two,3=three,4=four"); + Assert.assertEquals(4, wordsByKey.size()); + Assert.assertEquals("one", wordsByKey.get("1")); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/CopyHashMapUnitTest.java b/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/CopyHashMapUnitTest.java new file mode 100644 index 0000000000..e2d5e327e1 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/CopyHashMapUnitTest.java @@ -0,0 +1,76 @@ +package com.baeldung.map.copyhashmap; + +import com.google.common.collect.ImmutableMap; +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; + +import static org.assertj.core.api.Assertions.assertThat; + +public class CopyHashMapUnitTest { + + @Test + public void givenHashMap_whenShallowCopy_thenCopyisNotSameAsOriginal() { + + HashMap map = new HashMap<>(); + Employee emp1 = new Employee("John"); + Employee emp2 = new Employee("Norman"); + map.put("emp1",emp1); + map.put("emp2",emp2); + + HashMap shallowCopy = CopyHashMap.shallowCopy(map); + + assertThat(shallowCopy).isNotSameAs(map); + + } + + @Test + public void givenHashMap_whenShallowCopyModifyingOriginalObject_thenCopyShouldChange() { + + HashMap map = new HashMap<>(); + Employee emp1 = new Employee("John"); + Employee emp2 = new Employee("Norman"); + map.put("emp1",emp1); + map.put("emp2",emp2); + + HashMap shallowCopy = CopyHashMap.shallowCopy(map); + + emp1.setName("Johny"); + + assertThat(shallowCopy.get("emp1")).isEqualTo(map.get("emp1")); + + } + + @Test + public void givenHashMap_whenDeepCopyModifyingOriginalObject_thenCopyShouldNotChange() { + + HashMap map = new HashMap<>(); + Employee emp1 = new Employee("John"); + Employee emp2 = new Employee("Norman"); + map.put("emp1",emp1); + map.put("emp2",emp2); + HashMap deepCopy = CopyHashMap.deepCopy(map); + + emp1.setName("Johny"); + + assertThat(deepCopy.get("emp1")).isNotEqualTo(map.get("emp1")); + + } + + @Test + public void givenImmutableMap_whenCopyUsingGuava_thenCopyShouldNotChange() { + Employee emp1 = new Employee("John"); + Employee emp2 = new Employee("Norman"); + + Map map = ImmutableMap. builder() + .put("emp1",emp1) + .put("emp2",emp2) + .build(); + Map shallowCopy = ImmutableMap.copyOf(map); + + assertThat(shallowCopy).isSameAs(map); + + } + +} diff --git a/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/Employee.java b/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/Employee.java new file mode 100644 index 0000000000..5db55c26ea --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/copyhashmap/Employee.java @@ -0,0 +1,28 @@ +package com.baeldung.map.copyhashmap; + +import java.io.Serializable; + +public class Employee implements Serializable{ + + private String name; + + public Employee(String name) { + super(); + this.name = name; + } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return this.name; + } + +} + + diff --git a/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/initialize/MapInitializerUnitTest.java b/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/initialize/MapInitializerUnitTest.java new file mode 100644 index 0000000000..7c6dffe787 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/initialize/MapInitializerUnitTest.java @@ -0,0 +1,27 @@ +package com.baeldung.map.initialize; + +import org.junit.Test; + +import java.util.Map; + +import static org.junit.Assert.assertEquals; + +public class MapInitializerUnitTest { + + @Test + public void givenStaticMap_whenUpdated_thenCorrect() { + + MapInitializer.articleMapOne.put("NewArticle1", "Convert array to List"); + + assertEquals(MapInitializer.articleMapOne.get("NewArticle1"), "Convert array to List"); + + } + + @Test(expected=UnsupportedOperationException.class) + public void givenSingleTonMap_whenEntriesAdded_throwsException() { + + Map map = MapInitializer.createSingletonMap(); + map.put("username2", "password2"); + } + +} diff --git a/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/mapmax/MapMaxUnitTest.java b/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/mapmax/MapMaxUnitTest.java new file mode 100644 index 0000000000..30b945bfc8 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/mapmax/MapMaxUnitTest.java @@ -0,0 +1,58 @@ +package com.baeldung.map.mapmax; + + +import org.junit.Before; +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; + +public class MapMaxUnitTest { + + Map map = null; + MapMax mapMax = null; + + + @Before + public void setupTestData() { + map = new HashMap(); + map.put(23, 12); + map.put(46, 24); + map.put(27, 38); + mapMax = new MapMax(); + } + + @Test + public void givenMap_whenIterated_thenReturnMaxValue() { + assertEquals(new Integer(38), mapMax.maxUsingIteration(map)); + } + + @Test + public void givenMap_whenUsingCollectionsMax_thenReturnMaxValue() { + assertEquals(new Integer(38), mapMax.maxUsingCollectionsMax(map)); + } + + @Test + public void givenMap_whenUsingCollectionsMaxAndLambda_thenReturnMaxValue() { + assertEquals(new Integer(38), mapMax.maxUsingCollectionsMaxAndLambda(map)); + } + + @Test + public void givenMap_whenUsingCollectionsMaxAndMethodReference_thenReturnMaxValue() { + assertEquals(new Integer(38), mapMax.maxUsingCollectionsMaxAndMethodReference(map)); + } + + @Test + public void givenMap_whenUsingStreamAndLambda_thenReturnMaxValue() { + assertEquals(new Integer(38), mapMax.maxUsingStreamAndLambda(map)); + } + + @Test + public void givenMap_whenUsingStreamAndMethodReference_thenReturnMaxValue() { + assertEquals(new Integer(38), mapMax.maxUsingStreamAndMethodReference (map)); + } + + +} diff --git a/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/weakhashmap/WeakHashMapUnitTest.java b/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/weakhashmap/WeakHashMapUnitTest.java new file mode 100644 index 0000000000..293f24c378 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-2/src/test/java/com/baeldung/map/weakhashmap/WeakHashMapUnitTest.java @@ -0,0 +1,72 @@ +package com.baeldung.map.weakhashmap; + + +import org.junit.Test; + +import java.util.WeakHashMap; +import java.util.concurrent.TimeUnit; + +import static com.jayway.awaitility.Awaitility.await; +import static org.junit.Assert.assertTrue; + +public class WeakHashMapUnitTest { + + @Test + public void givenWeakHashMap_whenCacheValueThatHasNoReferenceToIt_GCShouldReclaimThatObject() { + //given + WeakHashMap map = new WeakHashMap<>(); + BigImage bigImage = new BigImage("image_id"); + UniqueImageName imageName = new UniqueImageName("name_of_big_image"); + + map.put(imageName, bigImage); + assertTrue(map.containsKey(imageName)); + + //when big image key is not reference anywhere + imageName = null; + System.gc(); + + //then GC will finally reclaim that object + await().atMost(10, TimeUnit.SECONDS).until(map::isEmpty); + } + + @Test + public void givenWeakHashMap_whenCacheValueThatHasNoReferenceToIt_GCShouldReclaimThatObjectButLeaveReferencedObject() { + //given + WeakHashMap map = new WeakHashMap<>(); + BigImage bigImageFirst = new BigImage("foo"); + UniqueImageName imageNameFirst = new UniqueImageName("name_of_big_image"); + + BigImage bigImageSecond = new BigImage("foo_2"); + UniqueImageName imageNameSecond = new UniqueImageName("name_of_big_image_2"); + + map.put(imageNameFirst, bigImageFirst); + map.put(imageNameSecond, bigImageSecond); + assertTrue(map.containsKey(imageNameFirst)); + assertTrue(map.containsKey(imageNameSecond)); + + //when + imageNameFirst = null; + System.gc(); + + //then + await().atMost(10, TimeUnit.SECONDS).until(() -> map.size() == 1); + await().atMost(10, TimeUnit.SECONDS).until(() -> map.containsKey(imageNameSecond)); + } + + + class BigImage { + public final String imageId; + + BigImage(String imageId) { + this.imageId = imageId; + } + } + + class UniqueImageName { + public final String imageName; + + UniqueImageName(String imageName) { + this.imageName = imageName; + } + } +} diff --git a/core-java-modules/core-java-collections-maps-3/README.md b/core-java-modules/core-java-collections-maps-3/README.md new file mode 100644 index 0000000000..142aa34800 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/README.md @@ -0,0 +1,8 @@ +## Java Collections Cookbooks and Examples + +This module contains articles about Map data structures in Java. + +### Relevant Articles: +- [Java TreeMap vs HashMap](https://www.baeldung.com/java-treemap-vs-hashmap) +- [Comparing Two HashMaps in Java](https://www.baeldung.com/java-compare-hashmaps) +- More articles: [[<-- prev]](/core-java-collections-maps-2) diff --git a/core-java-modules/core-java-collections-maps-3/pom.xml b/core-java-modules/core-java-collections-maps-3/pom.xml new file mode 100644 index 0000000000..95414c12c2 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + core-java-collections-maps-3 + 0.1.0-SNAPSHOT + core-java-collections-maps-3 + jar + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + + + + + + + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/compare/HashMapComparisonUnitTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/compare/HashMapComparisonUnitTest.java new file mode 100644 index 0000000000..0edd0cd87b --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/compare/HashMapComparisonUnitTest.java @@ -0,0 +1,225 @@ +package com.baeldung.map.compare; + +import com.google.common.base.Equivalence; +import com.google.common.collect.MapDifference; +import com.google.common.collect.MapDifference.ValueDifference; +import com.google.common.collect.Maps; +import org.junit.Before; +import org.junit.Test; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.collection.IsMapContaining.hasEntry; +import static org.hamcrest.collection.IsMapContaining.hasKey; +import static org.junit.Assert.*; + +public class HashMapComparisonUnitTest { + + Map asiaCapital1; + Map asiaCapital2; + Map asiaCapital3; + + Map asiaCity1; + Map asiaCity2; + Map asiaCity3; + + @Before + public void setup(){ + asiaCapital1 = new HashMap(); + asiaCapital1.put("Japan", "Tokyo"); + asiaCapital1.put("South Korea", "Seoul"); + + asiaCapital2 = new HashMap(); + asiaCapital2.put("South Korea", "Seoul"); + asiaCapital2.put("Japan", "Tokyo"); + + asiaCapital3 = new HashMap(); + asiaCapital3.put("Japan", "Tokyo"); + asiaCapital3.put("China", "Beijing"); + + asiaCity1 = new HashMap(); + asiaCity1.put("Japan", new String[] { "Tokyo", "Osaka" }); + asiaCity1.put("South Korea", new String[] { "Seoul", "Busan" }); + + asiaCity2 = new HashMap(); + asiaCity2.put("South Korea", new String[] { "Seoul", "Busan" }); + asiaCity2.put("Japan", new String[] { "Tokyo", "Osaka" }); + + asiaCity3 = new HashMap(); + asiaCity3.put("Japan", new String[] { "Tokyo", "Osaka" }); + asiaCity3.put("China", new String[] { "Beijing", "Hong Kong" }); + } + + @Test + public void whenCompareTwoHashMapsUsingEquals_thenSuccess() { + assertTrue(asiaCapital1.equals(asiaCapital2)); + assertFalse(asiaCapital1.equals(asiaCapital3)); + } + + @Test + public void whenCompareTwoHashMapsWithArrayValuesUsingEquals_thenFail() { + assertFalse(asiaCity1.equals(asiaCity2)); + } + + @Test + public void whenCompareTwoHashMapsUsingStreamAPI_thenSuccess() { + assertTrue(areEqual(asiaCapital1, asiaCapital2)); + assertFalse(areEqual(asiaCapital1, asiaCapital3)); + } + + @Test + public void whenCompareTwoHashMapsWithArrayValuesUsingStreamAPI_thenSuccess() { + assertTrue(areEqualWithArrayValue(asiaCity1, asiaCity2)); + assertFalse(areEqualWithArrayValue(asiaCity1, asiaCity3)); + } + + @Test + public void whenCompareTwoHashMapKeys_thenSuccess() { + assertTrue(asiaCapital1.keySet().equals(asiaCapital2.keySet())); + assertFalse(asiaCapital1.keySet().equals(asiaCapital3.keySet())); + } + + @Test + public void whenCompareTwoHashMapKeyValuesUsingStreamAPI_thenSuccess() { + Map asiaCapital3 = new HashMap(); + asiaCapital3.put("Japan", "Tokyo"); + asiaCapital3.put("South Korea", "Seoul"); + asiaCapital3.put("China", "Beijing"); + + Map asiaCapital4 = new HashMap(); + asiaCapital4.put("South Korea", "Seoul"); + asiaCapital4.put("Japan", "Osaka"); + asiaCapital4.put("China", "Beijing"); + + Map result = areEqualKeyValues(asiaCapital3, asiaCapital4); + + assertEquals(3, result.size()); + assertThat(result, hasEntry("Japan", false)); + assertThat(result, hasEntry("South Korea", true)); + assertThat(result, hasEntry("China", true)); + } + + @Test + public void givenDifferentMaps_whenGetDiffUsingGuava_thenSuccess() { + Map asia1 = new HashMap(); + asia1.put("Japan", "Tokyo"); + asia1.put("South Korea", "Seoul"); + asia1.put("India", "New Delhi"); + + Map asia2 = new HashMap(); + asia2.put("Japan", "Tokyo"); + asia2.put("China", "Beijing"); + asia2.put("India", "Delhi"); + + MapDifference diff = Maps.difference(asia1, asia2); + Map> entriesDiffering = diff.entriesDiffering(); + + assertFalse(diff.areEqual()); + assertEquals(1, entriesDiffering.size()); + assertThat(entriesDiffering, hasKey("India")); + assertEquals("New Delhi", entriesDiffering.get("India").leftValue()); + assertEquals("Delhi", entriesDiffering.get("India").rightValue()); + } + + @Test + public void givenDifferentMaps_whenGetEntriesOnOneSideUsingGuava_thenSuccess() { + Map asia1 = new HashMap(); + asia1.put("Japan", "Tokyo"); + asia1.put("South Korea", "Seoul"); + asia1.put("India", "New Delhi"); + + Map asia2 = new HashMap(); + asia2.put("Japan", "Tokyo"); + asia2.put("China", "Beijing"); + asia2.put("India", "Delhi"); + + MapDifference diff = Maps.difference(asia1, asia2); + Map entriesOnlyOnRight = diff.entriesOnlyOnRight(); + Map entriesOnlyOnLeft = diff.entriesOnlyOnLeft(); + + assertEquals(1, entriesOnlyOnRight.size()); + assertThat(entriesOnlyOnRight, hasEntry("China", "Beijing")); + assertEquals(1, entriesOnlyOnLeft.size()); + assertThat(entriesOnlyOnLeft, hasEntry("South Korea", "Seoul")); + } + + @Test + public void givenDifferentMaps_whenGetCommonEntriesUsingGuava_thenSuccess() { + Map asia1 = new HashMap(); + asia1.put("Japan", "Tokyo"); + asia1.put("South Korea", "Seoul"); + asia1.put("India", "New Delhi"); + + Map asia2 = new HashMap(); + asia2.put("Japan", "Tokyo"); + asia2.put("China", "Beijing"); + asia2.put("India", "Delhi"); + + MapDifference diff = Maps.difference(asia1, asia2); + Map entriesInCommon = diff.entriesInCommon(); + + assertEquals(1, entriesInCommon.size()); + assertThat(entriesInCommon, hasEntry("Japan", "Tokyo")); + } + + @Test + public void givenSimilarMapsWithArrayValue_whenCompareUsingGuava_thenFail() { + MapDifference diff = Maps.difference(asiaCity1, asiaCity2); + assertFalse(diff.areEqual()); + } + + @Test + public void givenSimilarMapsWithArrayValue_whenCompareUsingGuavaEquivalence_thenSuccess() { + Equivalence eq = new Equivalence() { + @Override + protected boolean doEquivalent(String[] a, String[] b) { + return Arrays.equals(a, b); + } + + @Override + protected int doHash(String[] value) { + return value.hashCode(); + } + }; + + MapDifference diff = Maps.difference(asiaCity1, asiaCity2, eq); + assertTrue(diff.areEqual()); + + diff = Maps.difference(asiaCity1, asiaCity3, eq); + assertFalse(diff.areEqual()); + } + + // =========================================================================== + + private boolean areEqual(Map first, Map second) { + if (first.size() != second.size()) { + return false; + } + + return first.entrySet() + .stream() + .allMatch(e -> e.getValue() + .equals(second.get(e.getKey()))); + } + + private boolean areEqualWithArrayValue(Map first, Map second) { + if (first.size() != second.size()) { + return false; + } + + return first.entrySet() + .stream() + .allMatch(e -> Arrays.equals(e.getValue(), second.get(e.getKey()))); + } + + private Map areEqualKeyValues(Map first, Map second) { + return first.entrySet() + .stream() + .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().equals(second.get(e.getKey())))); + } + +} diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/treemaphashmap/TreeMapVsHashMapUnitTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/treemaphashmap/TreeMapVsHashMapUnitTest.java new file mode 100644 index 0000000000..1057e3b9f0 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/treemaphashmap/TreeMapVsHashMapUnitTest.java @@ -0,0 +1,58 @@ +package com.baeldung.map.treemaphashmap; + +import org.hamcrest.Matchers; +import org.junit.Assert; +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; +import java.util.TreeMap; + +public class TreeMapVsHashMapUnitTest { + + @Test + public void whenInsertObjectsTreeMap_thenNaturalOrder() { + Map treemap = new TreeMap<>(); + treemap.put(3, "TreeMap"); + treemap.put(2, "vs"); + treemap.put(1, "HashMap"); + Assert.assertThat(treemap.keySet(), Matchers.contains(1, 2, 3)); + } + + @Test(expected = NullPointerException.class) + public void whenInsertNullInTreeMap_thenException() { + Map treemap = new TreeMap<>(); + treemap.put(null, "NullPointerException"); + } + + @Test + public void whenInsertObjectsHashMap_thenRandomOrder() { + Map hashmap = new HashMap<>(); + hashmap.put(3, "TreeMap"); + hashmap.put(2, "vs"); + hashmap.put(1, "HashMap"); + Assert.assertThat(hashmap.keySet(), Matchers.containsInAnyOrder(1, 2, 3)); + } + + @Test + public void whenInsertNullInHashMap_thenInsertsNull() { + Map hashmap = new HashMap<>(); + hashmap.put(null, null); + Assert.assertNull(hashmap.get(null)); + } + + @Test + public void givenHashMapAndTreeMap_whenputDuplicates_thenOnlyUnique() { + Map treeMap = new HashMap<>(); + treeMap.put(1, "Baeldung"); + treeMap.put(1, "Baeldung"); + + Assert.assertTrue(treeMap.size() == 1); + + Map treeMap2 = new TreeMap<>(); + treeMap2.put(1, "Baeldung"); + treeMap2.put(1, "Baeldung"); + + Assert.assertTrue(treeMap2.size() == 1); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps/README.md b/core-java-modules/core-java-collections-maps/README.md new file mode 100644 index 0000000000..1323fb97cd --- /dev/null +++ b/core-java-modules/core-java-collections-maps/README.md @@ -0,0 +1,16 @@ +## Java Collections Cookbooks and Examples + +This module contains articles about Map data structures in Java. + +### Relevant Articles: +- [Guide to the Guava BiMap](https://www.baeldung.com/guava-bimap) +- [A Guide to Java HashMap](https://www.baeldung.com/java-hashmap) +- [A Guide to LinkedHashMap in Java](https://www.baeldung.com/java-linked-hashmap) +- [A Guide to TreeMap in Java](https://www.baeldung.com/java-treemap) +- [How to Store Duplicate Keys in a Map in Java?](https://www.baeldung.com/java-map-duplicate-keys) +- [Get the Key for a Value from a Java Map](https://www.baeldung.com/java-map-key-from-value) +- [How to Check If a Key Exists in a Map](https://www.baeldung.com/java-map-key-exists) +- [Immutable Map Implementations in Java](https://www.baeldung.com/java-immutable-maps) +- [Guide to Apache Commons MultiValuedMap](https://www.baeldung.com/apache-commons-multi-valued-map) +- [The Java HashMap Under the Hood](https://www.baeldung.com/java-hashmap-advanced) +- More articles: [[next -->]](/core-java-collections-maps-2) diff --git a/core-java-modules/core-java-collections-maps/pom.xml b/core-java-modules/core-java-collections-maps/pom.xml new file mode 100644 index 0000000000..c0dd705c1c --- /dev/null +++ b/core-java-modules/core-java-collections-maps/pom.xml @@ -0,0 +1,35 @@ + + + 4.0.0 + core-java-collections-maps + 0.1.0-SNAPSHOT + core-java-collections-maps + jar + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + + + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + 4.1 + 3.6.1 + + diff --git a/core-java-modules/core-java-collections-maps/src/main/java/com/baeldung/map/MapUtil.java b/core-java-modules/core-java-collections-maps/src/main/java/com/baeldung/map/MapUtil.java new file mode 100644 index 0000000000..91b7197a92 --- /dev/null +++ b/core-java-modules/core-java-collections-maps/src/main/java/com/baeldung/map/MapUtil.java @@ -0,0 +1,44 @@ +/** + * + */ +package com.baeldung.map; + +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.stream.Stream; + +/** + * @author swpraman + * + */ +public class MapUtil { + + public static Stream keys(Map map, V value) { + return map.entrySet() + .stream() + .filter(entry -> value.equals(entry.getValue())) + .map(Map.Entry::getKey); + } + + public static Set getKeys(Map map, V value) { + Set keys = new HashSet<>(); + for (Entry entry : map.entrySet()) { + if (entry.getValue().equals(value)) { + keys.add(entry.getKey()); + } + } + return keys; + } + + public static K getKey(Map map, V value) { + for (Entry entry : map.entrySet()) { + if (entry.getValue().equals(value)) { + return entry.getKey(); + } + } + return null; + } + +} diff --git a/core-java-modules/core-java-collections-maps/src/main/java/com/baeldung/map/MyKey.java b/core-java-modules/core-java-collections-maps/src/main/java/com/baeldung/map/MyKey.java new file mode 100644 index 0000000000..9993d7862c --- /dev/null +++ b/core-java-modules/core-java-collections-maps/src/main/java/com/baeldung/map/MyKey.java @@ -0,0 +1,64 @@ +package com.baeldung.map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MyKey { + private static final Logger LOG = LoggerFactory.getLogger(MyKey.class); + + private String name; + private int id; + + public MyKey(int id, String name) { + this.id = id; + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + @Override + public int hashCode() { + LOG.debug("Calling hashCode()"); + return id; + } + + @Override + public String toString() { + return "MyKey [name=" + name + ", id=" + id + "]"; + } + + @Override + public boolean equals(Object obj) { + LOG.debug("Calling equals() for key: " + obj); + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + MyKey other = (MyKey) obj; + if (id != other.id) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + +} diff --git a/core-java-modules/core-java-collections-maps/src/main/java/com/baeldung/map/MyLinkedHashMap.java b/core-java-modules/core-java-collections-maps/src/main/java/com/baeldung/map/MyLinkedHashMap.java new file mode 100644 index 0000000000..b687e57d85 --- /dev/null +++ b/core-java-modules/core-java-collections-maps/src/main/java/com/baeldung/map/MyLinkedHashMap.java @@ -0,0 +1,23 @@ +package com.baeldung.map; + +import java.util.LinkedHashMap; +import java.util.Map; + +public class MyLinkedHashMap extends LinkedHashMap { + + /** + * + */ + private static final long serialVersionUID = 1L; + private static final int MAX_ENTRIES = 5; + + public MyLinkedHashMap(int initialCapacity, float loadFactor, boolean accessOrder) { + super(initialCapacity, loadFactor, accessOrder); + } + + @Override + protected boolean removeEldestEntry(Map.Entry eldest) { + return size() > MAX_ENTRIES; + } + +} diff --git a/core-java-modules/core-java-collections-maps/src/main/resources/logback.xml b/core-java-modules/core-java-collections-maps/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/core-java-modules/core-java-collections-maps/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/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/guava/GuavaBiMapUnitTest.java b/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/guava/GuavaBiMapUnitTest.java new file mode 100644 index 0000000000..b44d2db1aa --- /dev/null +++ b/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/guava/GuavaBiMapUnitTest.java @@ -0,0 +1,120 @@ +package com.baeldung.guava; + +import static org.junit.Assert.*; +import java.util.HashMap; +import java.util.Map; +import org.junit.Test; +import com.google.common.collect.BiMap; +import com.google.common.collect.EnumHashBiMap; +import com.google.common.collect.HashBiMap; +import com.google.common.collect.ImmutableBiMap; + +public class GuavaBiMapUnitTest { + @Test + public void whenQueryByValue_returnsKey() { + final BiMap capitalCountryBiMap = HashBiMap.create(); + capitalCountryBiMap.put("New Delhi", "India"); + capitalCountryBiMap.put("Washingon, D.C.", "USA"); + capitalCountryBiMap.put("Moscow", "Russia"); + + final String countryCapitalName = capitalCountryBiMap.inverse().get("India"); + + assertEquals("New Delhi", countryCapitalName); + } + + @Test + public void whenCreateBiMapFromExistingMap_returnsKey() { + final Map capitalCountryMap = new HashMap<>(); + capitalCountryMap.put("New Delhi", "India"); + capitalCountryMap.put("Washingon, D.C.", "USA"); + capitalCountryMap.put("Moscow", "Russia"); + final BiMap capitalCountryBiMap = HashBiMap.create(capitalCountryMap); + + final String countryCapitalName = capitalCountryBiMap.inverse().get("India"); + + assertEquals("New Delhi", countryCapitalName); + } + + @Test + public void whenQueryByKey_returnsValue() { + final BiMap capitalCountryBiMap = HashBiMap.create(); + + capitalCountryBiMap.put("New Delhi", "India"); + capitalCountryBiMap.put("Washingon, D.C.", "USA"); + capitalCountryBiMap.put("Moscow", "Russia"); + + assertEquals("USA", capitalCountryBiMap.get("Washingon, D.C.")); + } + + @Test(expected = IllegalArgumentException.class) + public void whenSameValueIsPresent_throwsException() { + final BiMap capitalCountryBiMap = HashBiMap.create(); + + capitalCountryBiMap.put("New Delhi", "India"); + capitalCountryBiMap.put("Washingon, D.C.", "USA"); + capitalCountryBiMap.put("Moscow", "Russia"); + capitalCountryBiMap.put("Trump", "USA"); + } + + @Test + public void givenSameValueIsPresent_whenForcePut_completesSuccessfully() { + final BiMap capitalCountryBiMap = HashBiMap.create(); + + capitalCountryBiMap.put("New Delhi", "India"); + capitalCountryBiMap.put("Washingon, D.C.", "USA"); + capitalCountryBiMap.put("Moscow", "Russia"); + capitalCountryBiMap.forcePut("Trump", "USA"); + + assertEquals("USA", capitalCountryBiMap.get("Trump")); + assertEquals("Trump", capitalCountryBiMap.inverse().get("USA")); + } + + @Test + public void whenSameKeyIsPresent_replacesAlreadyPresent() { + final BiMap capitalCountryBiMap = HashBiMap.create(); + + capitalCountryBiMap.put("New Delhi", "India"); + capitalCountryBiMap.put("Washingon, D.C.", "USA"); + capitalCountryBiMap.put("Moscow", "Russia"); + capitalCountryBiMap.put("Washingon, D.C.", "HongKong"); + + assertEquals("HongKong", capitalCountryBiMap.get("Washingon, D.C.")); + } + + @Test + public void whenUsingImmutableBiMap_allowsPutSuccessfully() { + final BiMap capitalCountryBiMap = new ImmutableBiMap.Builder().put("New Delhi", "India").put("Washingon, D.C.", "USA").put("Moscow", "Russia").build(); + + assertEquals("USA", capitalCountryBiMap.get("Washingon, D.C.")); + } + + @Test(expected = UnsupportedOperationException.class) + public void whenUsingImmutableBiMap_doesntAllowRemove() { + final BiMap capitalCountryBiMap = new ImmutableBiMap.Builder().put("New Delhi", "India").put("Washingon, D.C.", "USA").put("Moscow", "Russia").build(); + + capitalCountryBiMap.remove("New Delhi"); + } + + @Test(expected = UnsupportedOperationException.class) + public void whenUsingImmutableBiMap_doesntAllowPut() { + final BiMap capitalCountryBiMap = new ImmutableBiMap.Builder().put("New Delhi", "India").put("Washingon, D.C.", "USA").put("Moscow", "Russia").build(); + + capitalCountryBiMap.put("New York", "USA"); + } + + private enum Operation { + ADD, SUBTRACT, MULTIPLY, DIVIDE + } + + @Test + public void whenUsingEnumAsKeyInMap_replacesAlreadyPresent() { + final BiMap operationStringBiMap = EnumHashBiMap.create(Operation.class); + + operationStringBiMap.put(Operation.ADD, "Add"); + operationStringBiMap.put(Operation.SUBTRACT, "Subtract"); + operationStringBiMap.put(Operation.MULTIPLY, "Multiply"); + operationStringBiMap.put(Operation.DIVIDE, "Divide"); + + assertEquals("Divide", operationStringBiMap.get(Operation.DIVIDE)); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/ImmutableMapUnitTest.java b/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/ImmutableMapUnitTest.java new file mode 100644 index 0000000000..d308aac7eb --- /dev/null +++ b/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/ImmutableMapUnitTest.java @@ -0,0 +1,84 @@ +package com.baeldung.map; + +import com.google.common.collect.ImmutableMap; +import org.junit.jupiter.api.Test; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.*; + + +public class ImmutableMapUnitTest { + + @Test + public void whenCollectionsUnModifiableMapMethod_thenOriginalCollectionChangesReflectInUnmodifiableMap() { + + Map mutableMap = new HashMap<>(); + mutableMap.put("USA", "North America"); + + Map unmodifiableMap = Collections.unmodifiableMap(mutableMap); + assertThrows(UnsupportedOperationException.class, () -> unmodifiableMap.put("Canada", "North America")); + + mutableMap.remove("USA"); + assertFalse(unmodifiableMap.containsKey("USA")); + + mutableMap.put("Mexico", "North America"); + assertTrue(unmodifiableMap.containsKey("Mexico")); + } + + @Test + @SuppressWarnings("deprecation") + public void whenGuavaImmutableMapFromCopyOfMethod_thenOriginalCollectionChangesDoNotReflectInImmutableMap() { + + Map mutableMap = new HashMap<>(); + mutableMap.put("USA", "North America"); + + ImmutableMap immutableMap = ImmutableMap.copyOf(mutableMap); + assertTrue(immutableMap.containsKey("USA")); + + assertThrows(UnsupportedOperationException.class, () -> immutableMap.put("Canada", "North America")); + + mutableMap.remove("USA"); + assertTrue(immutableMap.containsKey("USA")); + + mutableMap.put("Mexico", "North America"); + assertFalse(immutableMap.containsKey("Mexico")); + } + + @Test + @SuppressWarnings("deprecation") + public void whenGuavaImmutableMapFromBuilderMethod_thenOriginalCollectionChangesDoNotReflectInImmutableMap() { + + Map mutableMap = new HashMap<>(); + mutableMap.put("USA", "North America"); + + ImmutableMap immutableMap = ImmutableMap.builder() + .putAll(mutableMap) + .put("Costa Rica", "North America") + .build(); + assertTrue(immutableMap.containsKey("USA")); + assertTrue(immutableMap.containsKey("Costa Rica")); + + assertThrows(UnsupportedOperationException.class, () -> immutableMap.put("Canada", "North America")); + + mutableMap.remove("USA"); + assertTrue(immutableMap.containsKey("USA")); + + mutableMap.put("Mexico", "North America"); + assertFalse(immutableMap.containsKey("Mexico")); + } + + @Test + @SuppressWarnings("deprecation") + public void whenGuavaImmutableMapFromOfMethod_thenOriginalCollectionChangesDoNotReflectInImmutableMap() { + + ImmutableMap immutableMap = ImmutableMap.of("USA", "North America", "Costa Rica", "North America"); + assertTrue(immutableMap.containsKey("USA")); + assertTrue(immutableMap.containsKey("Costa Rica")); + + assertThrows(UnsupportedOperationException.class, () -> immutableMap.put("Canada", "North America")); + } + +} diff --git a/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/KeyCheckUnitTest.java b/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/KeyCheckUnitTest.java new file mode 100644 index 0000000000..dbad2e5b5e --- /dev/null +++ b/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/KeyCheckUnitTest.java @@ -0,0 +1,27 @@ +package com.baeldung.map; + +import org.junit.Test; + +import java.util.Collections; +import java.util.Map; + +import static org.junit.Assert.*; + +public class KeyCheckUnitTest { + + @Test + public void whenKeyIsPresent_thenContainsKeyReturnsTrue() { + Map map = Collections.singletonMap("key", "value"); + + assertTrue(map.containsKey("key")); + assertFalse(map.containsKey("missing")); + } + + @Test + public void whenKeyHasNullValue_thenGetStillWorks() { + Map map = Collections.singletonMap("nothing", null); + + assertTrue(map.containsKey("nothing")); + assertNull(map.get("nothing")); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/MapMultipleValuesUnitTest.java b/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/MapMultipleValuesUnitTest.java new file mode 100644 index 0000000000..721b48ea7b --- /dev/null +++ b/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/MapMultipleValuesUnitTest.java @@ -0,0 +1,119 @@ +package com.baeldung.map; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.LinkedHashMultimap; +import com.google.common.collect.Multimap; +import com.google.common.collect.TreeMultimap; +import org.apache.commons.collections4.MultiMap; +import org.apache.commons.collections4.MultiMapUtils; +import org.apache.commons.collections4.MultiValuedMap; +import org.apache.commons.collections4.map.MultiValueMap; +import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; +import org.apache.commons.collections4.multimap.HashSetValuedHashMap; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.*; + +import static org.assertj.core.api.Assertions.assertThat; + +public class MapMultipleValuesUnitTest { + private static final Logger LOG = LoggerFactory.getLogger(MapMultipleValuesUnitTest.class); + + @Test + public void givenHashMap_whenPuttingTwice_thenReturningFirstValue() { + Map map = new HashMap<>(); + assertThat(map.put("key1", "value1")).isEqualTo(null); + assertThat(map.put("key1", "value2")).isEqualTo("value1"); + assertThat(map.get("key1")).isEqualTo("value2"); + } + + @Test + public void givenCollectionAsValue_whenPuttingTwice_thenReturningCollection() { + Map> map = new HashMap<>(); + List list = new ArrayList<>(); + map.put("key1", list); + map.get("key1").add("value1"); + map.get("key1").add("value2"); + assertThat(map.get("key1").get(0)).isEqualTo("value1"); + assertThat(map.get("key1").get(1)).isEqualTo("value2"); + } + + @Test + public void givenCollectionAsValueAndJava8_whenPuttingTwice_thenReturningCollection() { + Map> map = new HashMap<>(); + map.computeIfAbsent("key1", k -> new ArrayList<>()).add("value1"); + map.computeIfAbsent("key1", k -> new ArrayList<>()).add("value2"); + assertThat(map.get("key1").get(0)).isEqualTo("value1"); + assertThat(map.get("key1").get(1)).isEqualTo("value2"); + } + + @Test + public void givenMultiValueMap_whenPuttingTwice_thenReturningValues() { + MultiMap map = new MultiValueMap<>(); + map.put("key1", "value1"); + map.put("key1", "value2"); + assertThat((Collection) map.get("key1")) + .contains("value1", "value2"); + } + + @Test + public void givenArrayListValuedHashMap_whenPuttingDoubleValues_thenReturningAllValues() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("key1", "value1"); + map.put("key1", "value2"); + map.put("key1", "value2"); + assertThat((Collection) map.get("key1")) + .containsExactly("value1", "value2", "value2"); + } + + @Test + public void givenHashSetValuedHashMap_whenPuttingTwiceTheSame_thenReturningOneValue() { + MultiValuedMap map = new HashSetValuedHashMap<>(); + map.put("key1", "value1"); + map.put("key1", "value1"); + assertThat((Collection) map.get("key1")) + .containsExactly("value1"); + } + + @Test(expected = UnsupportedOperationException.class) + public void givenUnmodifiableMultiValuedMap_whenInserting_thenThrowingException() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("key1", "value1"); + map.put("key1", "value2"); + MultiValuedMap immutableMap = + MultiMapUtils.unmodifiableMultiValuedMap(map); + immutableMap.put("key1", "value3"); + } + + @Test + public void givenArrayListMultiMap_whenInserting_thenCorrectOutput() { + Multimap map = ArrayListMultimap.create(); + map.put("key1", "value2"); + map.put("key1", "value1"); + assertThat((Collection) map.get("key1")) + .containsExactly("value2", "value1"); + } + + @Test + public void givenLinkedHashMultiMap_whenInserting_thenReturningValuesInInsertionOrder() { + Multimap map = LinkedHashMultimap.create(); + map.put("key1", "value3"); + map.put("key1", "value1"); + map.put("key1", "value2"); + assertThat((Collection) map.get("key1")) + .containsExactly("value3", "value1", "value2"); + } + + @Test + public void givenTreeMultimap_whenInserting_thenReturningValuesInNaturalOrder() { + Multimap map = TreeMultimap.create(); + map.put("key1", "value3"); + map.put("key1", "value1"); + map.put("key1", "value2"); + assertThat((Collection) map.get("key1")) + .containsExactly("value1", "value2", "value3"); + } + +} \ No newline at end of file diff --git a/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/MapUnitTest.java b/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/MapUnitTest.java new file mode 100644 index 0000000000..eaf68ccba5 --- /dev/null +++ b/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/MapUnitTest.java @@ -0,0 +1,336 @@ +package com.baeldung.map; + +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.*; +import java.util.Map.Entry; + +import static org.junit.Assert.*; + +public class MapUnitTest { + private static final Logger LOG = LoggerFactory.getLogger(MapUnitTest.class); + + + @Test + public void givenHashMap_whenRetrievesKeyset_thenCorrect() { + Map map = new HashMap<>(); + map.put("name", "baeldung"); + map.put("type", "blog"); + + Set keys = map.keySet(); + + assertEquals(2, keys.size()); + assertTrue(keys.contains("name")); + assertTrue(keys.contains("type")); + } + + @Test + public void givenHashMap_whenRetrievesValues_thenCorrect() { + Map map = new HashMap<>(); + map.put("name", "baeldung"); + map.put("type", "blog"); + + Collection values = map.values(); + + assertEquals(2, values.size()); + assertTrue(values.contains("baeldung")); + assertTrue(values.contains("blog")); + } + + @Test + public void givenHashMap_whenRetrievesEntries_thenCorrect() { + Map map = new HashMap<>(); + map.put("name", "baeldung"); + map.put("type", "blog"); + + Set> entries = map.entrySet(); + + assertEquals(2, entries.size()); + for (Entry e : entries) { + String key = e.getKey(); + String val = e.getValue(); + assertTrue(key.equals("name") || key.equals("type")); + assertTrue(val.equals("baeldung") || val.equals("blog")); + } + } + + @Test + public void givenKeySet_whenChangeReflectsInMap_thenCorrect() { + Map map = new HashMap<>(); + map.put("name", "baeldung"); + map.put("type", "blog"); + + assertEquals(2, map.size()); + + Set keys = map.keySet(); + + keys.remove("name"); + assertEquals(1, map.size()); + } + + @Test(expected = ConcurrentModificationException.class) + public void givenIterator_whenFailsFastOnModification_thenCorrect() { + Map map = new HashMap<>(); + map.put("name", "baeldung"); + map.put("type", "blog"); + + Set keys = map.keySet(); + Iterator it = keys.iterator(); + map.remove("type"); + while (it.hasNext()) { + String key = it.next(); + } + } + + public void givenIterator_whenRemoveWorks_thenCorrect() { + Map map = new HashMap<>(); + map.put("name", "baeldung"); + map.put("type", "blog"); + + Set keys = map.keySet(); + Iterator it = keys.iterator(); + while (it.hasNext()) { + it.next(); + it.remove(); + } + assertEquals(0, map.size()); + } + + @Test + public void whenHashCodeIsCalledOnPut_thenCorrect() { + MyKey key = new MyKey(1, "name"); + Map map = new HashMap<>(); + map.put(key, "val"); + } + + @Test + public void whenHashCodeIsCalledOnGet_thenCorrect() { + MyKey key = new MyKey(1, "name"); + Map map = new HashMap<>(); + map.put(key, "val"); + map.get(key); + } + + @Test + public void whenGetWorks_thenCorrect() { + Map map = new HashMap<>(); + map.put("key", "val"); + + String val = map.get("key"); + + assertEquals("val", val); + } + + @Test + public void givenNewKey_whenPutReturnsNull_thenCorrect() { + Map map = new HashMap<>(); + + String rtnVal = map.put("key1", "val1"); + + assertNull(rtnVal); + } + + @Test + public void givenUnmappedKey_whenGetReturnsNull_thenCorrect() { + Map map = new HashMap<>(); + + String rtnVal = map.get("key1"); + + assertNull(rtnVal); + } + + @Test + public void givenNullVal_whenPutReturnsNull_thenCorrect() { + Map map = new HashMap<>(); + + String rtnVal = map.put("key1", null); + + assertNull(rtnVal); + } + + @Test + public void givenNullKeyAndVal_whenAccepts_thenCorrect() { + Map map = new HashMap<>(); + + map.put(null, null); + } + + @Test + public void givenNullVal_whenRetrieves_thenCorrect() { + Map map = new HashMap<>(); + map.put("key", null); + + String val = map.get("key"); + + assertNull(val); + } + + @Test + public void whenContainsDistinguishesNullValues_thenCorrect() { + Map map = new HashMap<>(); + + String val1 = map.get("key"); + boolean valPresent = map.containsKey("key"); + + assertNull(val1); + assertFalse(valPresent); + + map.put("key", null); + String val = map.get("key"); + valPresent = map.containsKey("key"); + + assertNull(val); + assertTrue(valPresent); + + } + + @Test + public void whenPutReturnsPrevValue_thenCorrect() { + Map map = new HashMap<>(); + map.put("key1", "val1"); + String rtnVal = map.put("key1", "val2"); + + assertEquals("val1", rtnVal); + } + + @Test + public void whenCallsEqualsOnCollision_thenCorrect() { + HashMap map = new HashMap<>(); + MyKey k1 = new MyKey(1, "firstKey"); + MyKey k2 = new MyKey(2, "secondKey"); + MyKey k3 = new MyKey(2, "thirdKey"); + + LOG.debug("storing value for k1"); + map.put(k1, "firstValue"); + + LOG.debug("storing value for k2"); + map.put(k2, "secondValue"); + + LOG.debug("storing value for k3"); + map.put(k3, "thirdValue"); + + LOG.debug("retrieving value for k1"); + String v1 = map.get(k1); + + LOG.debug("retrieving value for k2"); + String v2 = map.get(k2); + + LOG.debug("retrieving value for k3"); + String v3 = map.get(k3); + + assertEquals("firstValue", v1); + assertEquals("secondValue", v2); + assertEquals("thirdValue", v3); + + } + + @Test + public void givenLinkedHashMap_whenGetsOrderedKeyset_thenCorrect() { + LinkedHashMap map = new LinkedHashMap<>(); + map.put(1, null); + map.put(2, null); + map.put(3, null); + map.put(4, null); + map.put(5, null); + Set keys = map.keySet(); + Integer[] arr = keys.toArray(new Integer[0]); + for (int i = 0; i < arr.length; i++) { + assertEquals(new Integer(i + 1), arr[i]); + + } + } + + @Test + public void givenLinkedHashMap_whenAccessOrderWorks_thenCorrect() { + LinkedHashMap map = new LinkedHashMap<>(16, .75f, true); + map.put(1, null); + map.put(2, null); + map.put(3, null); + map.put(4, null); + map.put(5, null); + Set keys = map.keySet(); + assertEquals("[1, 2, 3, 4, 5]", keys.toString()); + map.get(4); + assertEquals("[1, 2, 3, 5, 4]", keys.toString()); + map.get(1); + assertEquals("[2, 3, 5, 4, 1]", keys.toString()); + map.get(3); + assertEquals("[2, 5, 4, 1, 3]", keys.toString()); + } + + @Test + public void givenLinkedHashMap_whenRemovesEldestEntry_thenCorrect() { + LinkedHashMap map = new MyLinkedHashMap<>(16, .75f, true); + map.put(1, null); + map.put(2, null); + map.put(3, null); + map.put(4, null); + map.put(5, null); + Set keys = map.keySet(); + assertEquals("[1, 2, 3, 4, 5]", keys.toString()); + map.put(6, null); + assertEquals("[2, 3, 4, 5, 6]", keys.toString()); + map.put(7, null); + assertEquals("[3, 4, 5, 6, 7]", keys.toString()); + map.put(8, null); + assertEquals("[4, 5, 6, 7, 8]", keys.toString()); + } + + @Test + public void givenTreeMap_whenOrdersEntriesNaturally_thenCorrect() { + TreeMap map = new TreeMap<>(); + map.put(3, "val"); + map.put(2, "val"); + map.put(1, "val"); + map.put(5, "val"); + map.put(4, "val"); + assertEquals("[1, 2, 3, 4, 5]", map.keySet().toString()); + } + + @Test + public void givenTreeMap_whenOrdersEntriesNaturally_thenCorrect2() { + TreeMap map = new TreeMap<>(); + map.put("c", "val"); + map.put("b", "val"); + map.put("a", "val"); + map.put("e", "val"); + map.put("d", "val"); + + assertEquals("[a, b, c, d, e]", map.keySet().toString()); + } + + @Test + public void givenTreeMap_whenOrdersEntriesByComparator_thenCorrect() { + TreeMap map = new TreeMap<>(Comparator.reverseOrder()); + map.put(3, "val"); + map.put(2, "val"); + map.put(1, "val"); + map.put(5, "val"); + map.put(4, "val"); + + assertEquals("[5, 4, 3, 2, 1]", map.keySet().toString()); + } + + @Test + public void givenTreeMap_whenPerformsQueries_thenCorrect() { + TreeMap map = new TreeMap<>(); + map.put(3, "val"); + map.put(2, "val"); + map.put(1, "val"); + map.put(5, "val"); + map.put(4, "val"); + + Integer highestKey = map.lastKey(); + Integer lowestKey = map.firstKey(); + Set keysLessThan3 = map.headMap(3).keySet(); + Set keysGreaterThanEqTo3 = map.tailMap(3).keySet(); + + assertEquals(new Integer(5), highestKey); + assertEquals(new Integer(1), lowestKey); + assertEquals("[1, 2]", keysLessThan3.toString()); + assertEquals("[3, 4, 5]", keysGreaterThanEqTo3.toString()); + } + +} diff --git a/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/MapUtilUnitTest.java b/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/MapUtilUnitTest.java new file mode 100644 index 0000000000..f8e4c8fd8a --- /dev/null +++ b/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/MapUtilUnitTest.java @@ -0,0 +1,103 @@ +/** + * + */ +package com.baeldung.map; + +import com.google.common.collect.HashBiMap; +import org.apache.commons.collections4.BidiMap; +import org.apache.commons.collections4.bidimap.DualHashBidiMap; +import org.junit.Test; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.stream.Collectors; + +import static org.junit.Assert.assertEquals; + +/** + * @author swpraman + * + */ +public class MapUtilUnitTest { + + + @Test + public void whenUsingImperativeWayForSingleKey_shouldReturnSingleKey() { + Map capitalCountryMap = new HashMap<>(); + capitalCountryMap.put("Tokyo", "Japan"); + capitalCountryMap.put("New Delhi", "India"); + assertEquals("New Delhi", MapUtil.getKey(capitalCountryMap, "India")); + } + + @Test + public void whenUsingImperativeWayForAllKeys_shouldReturnAllKeys() { + Map capitalCountryMap = new HashMap<>(); + capitalCountryMap.put("Tokyo", "Japan"); + capitalCountryMap.put("Berlin", "Germany"); + capitalCountryMap.put("Cape Town", "South Africa"); + capitalCountryMap.put("Pretoria", "South Africa"); + capitalCountryMap.put("Bloemfontein", "South Africa"); + + assertEquals(new HashSet(Arrays.asList( + new String[] {"Cape Town", "Pretoria", "Bloemfontein"})), + MapUtil.getKeys(capitalCountryMap, "South Africa")); + } + + @Test + public void whenUsingFunctionalWayForSingleKey_shouldReturnSingleKey() { + Map capitalCountryMap = new HashMap<>(); + capitalCountryMap.put("Tokyo", "Japan"); + capitalCountryMap.put("Berlin", "Germany"); + assertEquals("Berlin", MapUtil.keys(capitalCountryMap, "Germany").findFirst().get()); + } + + @Test + public void whenUsingFunctionalWayForAllKeys_shouldReturnAllKeys() { + Map capitalCountryMap = new HashMap<>(); + capitalCountryMap.put("Tokyo", "Japan"); + capitalCountryMap.put("Berlin", "Germany"); + capitalCountryMap.put("Cape Town", "South Africa"); + capitalCountryMap.put("Pretoria", "South Africa"); + capitalCountryMap.put("Bloemfontein", "South Africa"); + assertEquals(new HashSet(Arrays.asList( + new String[] {"Cape Town", "Pretoria", "Bloemfontein"})), + MapUtil.keys(capitalCountryMap, "South Africa").collect(Collectors.toSet())); + } + + @Test + public void whenUsingBidiMap_shouldReturnKey() { + BidiMap capitalCountryMap = new DualHashBidiMap(); + capitalCountryMap.put("Berlin", "Germany"); + capitalCountryMap.put("Cape Town", "South Africa"); + assertEquals("Berlin", capitalCountryMap.getKey("Germany")); + } + + @Test + public void whenUsingBidiMapAddDuplicateValue_shouldRemoveOldEntry() { + BidiMap capitalCountryMap = new DualHashBidiMap(); + capitalCountryMap.put("Berlin", "Germany"); + capitalCountryMap.put("Cape Town", "South Africa"); + capitalCountryMap.put("Pretoria", "South Africa"); + assertEquals("Pretoria", capitalCountryMap.getKey("South Africa")); + } + + @Test + public void whenUsingBiMap_shouldReturnKey() { + HashBiMap capitalCountryMap = HashBiMap.create(); + capitalCountryMap.put("Berlin", "Germany"); + capitalCountryMap.put("Cape Town", "South Africa"); + assertEquals("Berlin", capitalCountryMap.inverse().get("Germany")); + } + + @Test(expected=IllegalArgumentException.class) + public void whenUsingBiMapAddDuplicateValue_shouldThrowException() { + HashBiMap capitalCountryMap = HashBiMap.create(); + capitalCountryMap.put("Berlin", "Germany"); + capitalCountryMap.put("Cape Town", "South Africa"); + capitalCountryMap.put("Pretoria", "South Africa"); + assertEquals("Berlin", capitalCountryMap.inverse().get("Germany")); + } + +} diff --git a/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/MultiValuedMapUnitTest.java b/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/MultiValuedMapUnitTest.java new file mode 100644 index 0000000000..686c1cef87 --- /dev/null +++ b/core-java-modules/core-java-collections-maps/src/test/java/com/baeldung/map/MultiValuedMapUnitTest.java @@ -0,0 +1,227 @@ +package com.baeldung.map; + +import org.apache.commons.collections4.MultiMapUtils; +import org.apache.commons.collections4.MultiSet; +import org.apache.commons.collections4.MultiValuedMap; +import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; +import org.apache.commons.collections4.multimap.HashSetValuedHashMap; +import org.junit.Test; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + +public class MultiValuedMapUnitTest { + + @Test + public void givenMultiValuesMap_whenPuttingMultipleValuesUsingPutMethod_thenReturningAllValues() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + + map.put("fruits", "apple"); + map.put("fruits", "orange"); + + assertThat((Collection) map.get("fruits")).containsExactly("apple", "orange"); + + } + + @Test + public void givenMultiValuesMap_whenPuttingMultipleValuesUsingPutAllMethod_thenReturningAllValues() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + + map.putAll("vehicles", Arrays.asList("car", "bike")); + + assertThat((Collection) map.get("vehicles")).containsExactly("car", "bike"); + + } + + @Test + public void givenMultiValuesMap_whenGettingValueUsingGetMethod_thenReturningValue() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + + map.put("fruits", "apple"); + + assertThat((Collection) map.get("fruits")).containsExactly("apple"); + } + + @Test + public void givenMultiValuesMap_whenUsingEntriesMethod_thenReturningMappings() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("fruits", "apple"); + map.put("fruits", "orange"); + + Collection> entries = (Collection>) map.entries(); + + for(Map.Entry entry : entries) { + assertThat(entry.getKey()).contains("fruits"); + assertTrue(entry.getValue().equals("apple") || entry.getValue().equals("orange") ); + } + } + + @Test + public void givenMultiValuesMap_whenUsingKeysMethod_thenReturningAllKeys() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("fruits", "apple"); + map.put("fruits", "orange"); + map.put("vehicles", "car"); + map.put("vehicles", "bike"); + + MultiSet keys = map.keys(); + + assertThat((keys)).contains("fruits", "vehicles"); + + } + + @Test + public void givenMultiValuesMap_whenUsingKeySetMethod_thenReturningAllKeys() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("fruits", "apple"); + map.put("fruits", "orange"); + map.put("vehicles", "car"); + map.put("vehicles", "bike"); + + Set keys = map.keySet(); + + assertThat(keys).contains("fruits", "vehicles"); + + } + + @Test + public void givenMultiValuesMap_whenUsingValuesMethod_thenReturningAllValues() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + + map.put("fruits", "apple"); + map.put("fruits", "orange"); + map.put("vehicles", "car"); + map.put("vehicles", "bike"); + + assertThat(((Collection) map.values())).contains("apple", "orange", "car", "bike"); + } + + @Test + public void givenMultiValuesMap_whenUsingRemoveMethod_thenReturningUpdatedMap() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + + map.put("fruits", "apple"); + map.put("fruits", "orange"); + map.put("vehicles", "car"); + map.put("vehicles", "bike"); + assertThat(((Collection) map.values())).contains("apple", "orange", "car", "bike"); + + map.remove("fruits"); + + assertThat(((Collection) map.values())).contains("car", "bike"); + + } + + @Test + public void givenMultiValuesMap_whenUsingRemoveMappingMethod_thenReturningUpdatedMapAfterMappingRemoved() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + + map.put("fruits", "apple"); + map.put("fruits", "orange"); + map.put("vehicles", "car"); + map.put("vehicles", "bike"); + assertThat(((Collection) map.values())).contains("apple", "orange", "car", "bike"); + + map.removeMapping("fruits", "apple"); + + assertThat(((Collection) map.values())).contains("orange", "car", "bike"); + } + + @Test + public void givenMultiValuesMap_whenUsingClearMethod_thenReturningEmptyMap() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("fruits", "apple"); + map.put("fruits", "orange"); + map.put("vehicles", "car"); + map.put("vehicles", "bike"); + assertThat(((Collection) map.values())).contains("apple", "orange", "car", "bike"); + + map.clear(); + + assertTrue(map.isEmpty()); + } + + @Test + public void givenMultiValuesMap_whenUsingContainsKeyMethod_thenReturningTrue() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("fruits", "apple"); + map.put("fruits", "orange"); + map.put("vehicles", "car"); + map.put("vehicles", "bike"); + + assertTrue(map.containsKey("fruits")); + } + + @Test + public void givenMultiValuesMap_whenUsingContainsValueMethod_thenReturningTrue() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("fruits", "apple"); + map.put("fruits", "orange"); + map.put("vehicles", "car"); + map.put("vehicles", "bike"); + + assertTrue(map.containsValue("orange")); + } + + @Test + public void givenMultiValuesMap_whenUsingIsEmptyMethod_thenReturningFalse() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("fruits", "apple"); + map.put("fruits", "orange"); + map.put("vehicles", "car"); + map.put("vehicles", "bike"); + + assertFalse(map.isEmpty()); + } + + @Test + public void givenMultiValuesMap_whenUsingSizeMethod_thenReturningElementCount() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("fruits", "apple"); + map.put("fruits", "orange"); + map.put("vehicles", "car"); + map.put("vehicles", "bike"); + + assertEquals(4, map.size()); + } + + @Test + public void givenArrayListValuedHashMap_whenPuttingDoubleValues_thenReturningAllValues() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("fruits", "apple"); + map.put("fruits", "orange"); + map.put("fruits", "orange"); + + assertThat((Collection) map.get("fruits")).containsExactly("apple", "orange", "orange"); + } + + @Test + public void givenHashSetValuedHashMap_whenPuttingTwiceTheSame_thenReturningOneValue() { + MultiValuedMap map = new HashSetValuedHashMap<>(); + map.put("fruits", "apple"); + map.put("fruits", "apple"); + + assertThat((Collection) map.get("fruits")).containsExactly("apple"); + } + + @Test(expected = UnsupportedOperationException.class) + public void givenUnmodifiableMultiValuedMap_whenInserting_thenThrowingException() { + MultiValuedMap map = new ArrayListValuedHashMap<>(); + map.put("fruits", "apple"); + map.put("fruits", "orange"); + MultiValuedMap immutableMap = MultiMapUtils.unmodifiableMultiValuedMap(map); + + immutableMap.put("fruits", "banana"); + + } + + +} diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index ebdb11925b..3fc978a68c 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -42,6 +42,9 @@ core-java-collections-list core-java-collections-list-2 core-java-collections-list-3 + core-java-collections-maps + core-java-collections-maps-2 + core-java-collections-maps-3 core-java-concurrency-2 From 39abe6bfd14ee2f8f7f248f3c4e7d9feb0f86b01 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 7 Apr 2020 14:53:59 +0530 Subject: [PATCH 115/503] JAVA-1188: README changes --- core-java-modules/core-java-collections-maps-2/README.md | 2 +- core-java-modules/core-java-collections-maps-3/README.md | 2 +- core-java-modules/core-java-collections-maps/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core-java-modules/core-java-collections-maps-2/README.md b/core-java-modules/core-java-collections-maps-2/README.md index da9279b191..f49ba25c8c 100644 --- a/core-java-modules/core-java-collections-maps-2/README.md +++ b/core-java-modules/core-java-collections-maps-2/README.md @@ -13,4 +13,4 @@ This module contains articles about Map data structures in Java. - [Sort a HashMap in Java](https://www.baeldung.com/java-hashmap-sort) - [Finding the Highest Value in a Java Map](https://www.baeldung.com/java-find-map-max) - [Initialize a HashMap in Java](https://www.baeldung.com/java-initialize-hashmap) -- More articles: [[<-- prev]](/core-java-collections-maps) [[next -->]](/core-java-collections-maps-3) +- More articles: [[<-- prev]](/core-java-modules/core-java-collections-maps) [[next -->]](/core-java-modules/core-java-collections-maps-3) diff --git a/core-java-modules/core-java-collections-maps-3/README.md b/core-java-modules/core-java-collections-maps-3/README.md index 142aa34800..64a3b75d83 100644 --- a/core-java-modules/core-java-collections-maps-3/README.md +++ b/core-java-modules/core-java-collections-maps-3/README.md @@ -5,4 +5,4 @@ This module contains articles about Map data structures in Java. ### Relevant Articles: - [Java TreeMap vs HashMap](https://www.baeldung.com/java-treemap-vs-hashmap) - [Comparing Two HashMaps in Java](https://www.baeldung.com/java-compare-hashmaps) -- More articles: [[<-- prev]](/core-java-collections-maps-2) +- More articles: [[<-- prev]](/core-java-modules/core-java-collections-maps-2) diff --git a/core-java-modules/core-java-collections-maps/README.md b/core-java-modules/core-java-collections-maps/README.md index 1323fb97cd..828f8992e1 100644 --- a/core-java-modules/core-java-collections-maps/README.md +++ b/core-java-modules/core-java-collections-maps/README.md @@ -13,4 +13,4 @@ This module contains articles about Map data structures in Java. - [Immutable Map Implementations in Java](https://www.baeldung.com/java-immutable-maps) - [Guide to Apache Commons MultiValuedMap](https://www.baeldung.com/apache-commons-multi-valued-map) - [The Java HashMap Under the Hood](https://www.baeldung.com/java-hashmap-advanced) -- More articles: [[next -->]](/core-java-collections-maps-2) +- More articles: [[next -->]](/core-java-modules/core-java-collections-maps-2) From 298cc81d7d16cfd9acbd9dc6ab9933f808414da7 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 7 Apr 2020 15:03:43 +0530 Subject: [PATCH 116/503] JAVA-1188: main pom changes to remove java-collections-maps --- pom.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pom.xml b/pom.xml index e21c13efc2..219c7ce599 100644 --- a/pom.xml +++ b/pom.xml @@ -453,9 +453,6 @@ java-collections-conversions java-collections-conversions-2 - java-collections-maps - java-collections-maps-2 - java-collections-maps-3 javafx From 2986e1ace50b1fe369b2e6856be3def7dc2b00c8 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 17:35:51 +0800 Subject: [PATCH 117/503] Update README.md --- persistence-modules/spring-hibernate4/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/persistence-modules/spring-hibernate4/README.md b/persistence-modules/spring-hibernate4/README.md index cfa13ca3b0..a5a72a9b7e 100644 --- a/persistence-modules/spring-hibernate4/README.md +++ b/persistence-modules/spring-hibernate4/README.md @@ -9,7 +9,6 @@ This module contains articles about Spring with Hibernate 4 - [Stored Procedures with Hibernate](https://www.baeldung.com/stored-procedures-with-hibernate-tutorial) - [Hibernate: save, persist, update, merge, saveOrUpdate](https://www.baeldung.com/hibernate-save-persist-update-merge-saveorupdate) - [Eager/Lazy Loading In Hibernate](https://www.baeldung.com/hibernate-lazy-eager-loading) -- [The DAO with Spring and Hibernate](https://www.baeldung.com/persistence-layer-with-spring-and-hibernate) - [Auditing with JPA, Hibernate, and Spring Data JPA](https://www.baeldung.com/database-auditing-jpa) ### Quick Start From 83be0892e7d536956ddc0a65607ba16e0b4b8e07 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 7 Apr 2020 15:08:09 +0530 Subject: [PATCH 118/503] JAVA-1188: main pom changes to remove java-collections-maps --- pom.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pom.xml b/pom.xml index 219c7ce599..d5e2ddd0c7 100644 --- a/pom.xml +++ b/pom.xml @@ -962,9 +962,6 @@ java-collections-conversions java-collections-conversions-2 - java-collections-maps - java-collections-maps-2 - java-collections-maps-3 javafx From 6ffe07efff4ddda7822faa2ca4bcdea1b0e3b3e0 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 17:39:12 +0800 Subject: [PATCH 119/503] Update README.md --- core-java-modules/core-java-8-2/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/core-java-modules/core-java-8-2/README.md b/core-java-modules/core-java-8-2/README.md index 961941aac7..c1c09d2192 100644 --- a/core-java-modules/core-java-8-2/README.md +++ b/core-java-modules/core-java-8-2/README.md @@ -4,7 +4,6 @@ This module contains articles about Java 8 core features ### Relevant Articles: -- [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) - [Guide to Java BiFunction Interface](https://www.baeldung.com/java-bifunction-interface) From 34927fcc12acb04047bd854a93157366b45896fd Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 17:44:36 +0800 Subject: [PATCH 120/503] Update README.md --- core-java-modules/core-java-collections/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core-java-modules/core-java-collections/README.md b/core-java-modules/core-java-collections/README.md index 340c2b286e..12e3c5ac17 100644 --- a/core-java-modules/core-java-collections/README.md +++ b/core-java-modules/core-java-collections/README.md @@ -3,7 +3,6 @@ This module contains articles about Java collections ### Relevant Articles: -- [Collect a Java Stream to an Immutable Collection](https://www.baeldung.com/java-stream-immutable-collection) - [Introduction to the Java ArrayDeque](https://www.baeldung.com/java-array-deque) - [An Introduction to Java.util.Hashtable Class](https://www.baeldung.com/java-hash-table) - [Thread Safe LIFO Data Structure Implementations](https://www.baeldung.com/java-lifo-thread-safe) @@ -13,4 +12,4 @@ This module contains articles about Java collections - [Defining a Char Stack in Java](https://www.baeldung.com/java-char-stack) - [Guide to the Java Queue Interface](https://www.baeldung.com/java-queue) - [An Introduction to Synchronized Java Collections](https://www.baeldung.com/java-synchronized-collections) -- [[More -->]](/core-java-modules/core-java-collections-2) \ No newline at end of file +- [[More -->]](/core-java-modules/core-java-collections-2) From 959bf74b1e1cf184df9186ea7f68f7032d64f6a2 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 17:48:34 +0800 Subject: [PATCH 121/503] Delete README.md --- apache-olingo/olingo2/README.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 apache-olingo/olingo2/README.md diff --git a/apache-olingo/olingo2/README.md b/apache-olingo/olingo2/README.md deleted file mode 100644 index 826cd0133e..0000000000 --- a/apache-olingo/olingo2/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: - -- [Intro to OData with Olingo](https://www.baeldung.com/olingo) From 9ae4555a4f031263925e7958dd76fc5277e65ec2 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 17:52:32 +0800 Subject: [PATCH 122/503] Update README.md --- algorithms-miscellaneous-3/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/algorithms-miscellaneous-3/README.md b/algorithms-miscellaneous-3/README.md index 00b785c1b2..dd5bbac162 100644 --- a/algorithms-miscellaneous-3/README.md +++ b/algorithms-miscellaneous-3/README.md @@ -13,6 +13,5 @@ This module contains articles about algorithms. Some classes of algorithms, e.g. - [Checking if a Java Graph has a Cycle](https://www.baeldung.com/java-graph-has-a-cycle) - [A Guide to the Folding Technique in Java](https://www.baeldung.com/folding-hashing-technique) - [Creating a Triangle with for Loops in Java](https://www.baeldung.com/java-print-triangle) -- [Efficient Word Frequency Calculator in Java](https://www.baeldung.com/java-word-frequency) - [The K-Means Clustering Algorithm in Java](https://www.baeldung.com/java-k-means-clustering-algorithm) - More articles: [[<-- prev]](/algorithms-miscellaneous-2) [[next -->]](/algorithms-miscellaneous-4) From 0625de19744d47721bc313ce1ef193859cc536c6 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 17:54:20 +0800 Subject: [PATCH 123/503] Update README.md --- core-java-modules/core-java-collections-2/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/core-java-modules/core-java-collections-2/README.md b/core-java-modules/core-java-collections-2/README.md index de5daddb38..e5f6126811 100644 --- a/core-java-modules/core-java-collections-2/README.md +++ b/core-java-modules/core-java-collections-2/README.md @@ -12,4 +12,3 @@ - [Sorting in Java](https://www.baeldung.com/java-sorting) - [Getting the Size of an Iterable in Java](https://www.baeldung.com/java-iterable-size) - [Java Null-Safe Streams from Collections](https://www.baeldung.com/java-null-safe-streams-from-collections) -- [Operating on and Removing an Item from Stream](https://www.baeldung.com/java-use-remove-item-stream) From 4ccdaeb5f1f5fa718f63e0ba1a46d38e5b14bce9 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 17:56:49 +0800 Subject: [PATCH 124/503] Update README.md --- spring-core-2/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-core-2/README.md b/spring-core-2/README.md index 1fb591f693..0c0dac3dbf 100644 --- a/spring-core-2/README.md +++ b/spring-core-2/README.md @@ -7,7 +7,6 @@ This module contains articles about core Spring functionality - [Guide to Spring @Autowired](http://www.baeldung.com/spring-autowire) - [Spring Profiles](http://www.baeldung.com/spring-profiles) - [A Spring Custom Annotation for a Better DAO](http://www.baeldung.com/spring-annotation-bean-pre-processor) -- [Running Setup Data on Startup in Spring](http://www.baeldung.com/running-setup-logic-on-startup-in-spring) - [Quick Guide to Spring Bean Scopes](http://www.baeldung.com/spring-bean-scopes) - [Custom Scope in Spring](http://www.baeldung.com/spring-custom-scope) - [@Order in Spring](http://www.baeldung.com/spring-order) From 44517677a68e52717cacce6ab503249fe3d14ff6 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 17:59:28 +0800 Subject: [PATCH 125/503] Update README.md --- spring-core-2/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-core-2/README.md b/spring-core-2/README.md index 0c0dac3dbf..a144f5203c 100644 --- a/spring-core-2/README.md +++ b/spring-core-2/README.md @@ -14,6 +14,5 @@ This module contains articles about core Spring functionality - [Spring Events](https://www.baeldung.com/spring-events) - [Spring Null-Safety Annotations](https://www.baeldung.com/spring-null-safety-annotations) - [Using @Autowired in Abstract Classes](https://www.baeldung.com/spring-autowired-abstract-class) -- [Guide to the Spring BeanFactory](https://www.baeldung.com/spring-beanfactory) - [Reading HttpServletRequest Multiple Times in Spring](https://www.baeldung.com/spring-reading-httpservletrequest-multiple-times) - More articles: [[<-- prev]](/spring-core)[[next -->]](/spring-core-3) From 694ed29f705e3e228b866625dbdfea0b11523ec3 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 7 Apr 2020 18:02:08 +0800 Subject: [PATCH 126/503] Update README.md --- spring-core-2/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-core-2/README.md b/spring-core-2/README.md index a144f5203c..947b816db8 100644 --- a/spring-core-2/README.md +++ b/spring-core-2/README.md @@ -14,5 +14,4 @@ This module contains articles about core Spring functionality - [Spring Events](https://www.baeldung.com/spring-events) - [Spring Null-Safety Annotations](https://www.baeldung.com/spring-null-safety-annotations) - [Using @Autowired in Abstract Classes](https://www.baeldung.com/spring-autowired-abstract-class) -- [Reading HttpServletRequest Multiple Times in Spring](https://www.baeldung.com/spring-reading-httpservletrequest-multiple-times) - More articles: [[<-- prev]](/spring-core)[[next -->]](/spring-core-3) From 8e107d118090a1704ae096aecf101c6dd3c37858 Mon Sep 17 00:00:00 2001 From: Sampada <46674082+sampada07@users.noreply.github.com> Date: Wed, 8 Apr 2020 02:26:53 +0530 Subject: [PATCH 127/503] BAEL-3895: HTTP/2 in Netty (#9036) * BAEL-3895 : HTTP/2 in Netty * BAEL-3895: Added Live Test in place of java client * BAEL-3895: Commented out netty module from main pom as it needs Java 13 --- netty/README.md | 6 + netty/pom.xml | 34 +++++ .../com/baeldung/netty/http2/Http2Util.java | 135 ++++++++++++++++++ .../http2/client/Http2ClientInitializer.java | 46 ++++++ .../client/Http2ClientResponseHandler.java | 128 +++++++++++++++++ .../http2/client/Http2SettingsHandler.java | 30 ++++ .../netty/http2/server/Http2Server.java | 59 ++++++++ .../server/Http2ServerResponseHandler.java | 52 +++++++ netty/src/main/resources/logback.xml | 13 ++ .../baeldung/netty/Http2ClientLiveTest.java | 91 ++++++++++++ pom.xml | 2 + 11 files changed, 596 insertions(+) create mode 100644 netty/README.md create mode 100644 netty/pom.xml create mode 100644 netty/src/main/java/com/baeldung/netty/http2/Http2Util.java create mode 100644 netty/src/main/java/com/baeldung/netty/http2/client/Http2ClientInitializer.java create mode 100644 netty/src/main/java/com/baeldung/netty/http2/client/Http2ClientResponseHandler.java create mode 100644 netty/src/main/java/com/baeldung/netty/http2/client/Http2SettingsHandler.java create mode 100644 netty/src/main/java/com/baeldung/netty/http2/server/Http2Server.java create mode 100644 netty/src/main/java/com/baeldung/netty/http2/server/Http2ServerResponseHandler.java create mode 100644 netty/src/main/resources/logback.xml create mode 100644 netty/src/test/java/com/baeldung/netty/Http2ClientLiveTest.java diff --git a/netty/README.md b/netty/README.md new file mode 100644 index 0000000000..b006c1c686 --- /dev/null +++ b/netty/README.md @@ -0,0 +1,6 @@ +## Netty + +This module contains articles about Netty. + +### Relevant Articles: + diff --git a/netty/pom.xml b/netty/pom.xml new file mode 100644 index 0000000000..1a33eef92e --- /dev/null +++ b/netty/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + netty + 0.0.1-SNAPSHOT + netty + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + io.netty + netty-all + ${netty.version} + + + + org.conscrypt + conscrypt-openjdk-uber + 2.4.0 + + + + + + 4.1.48.Final + + + \ No newline at end of file diff --git a/netty/src/main/java/com/baeldung/netty/http2/Http2Util.java b/netty/src/main/java/com/baeldung/netty/http2/Http2Util.java new file mode 100644 index 0000000000..62b6d4c4ed --- /dev/null +++ b/netty/src/main/java/com/baeldung/netty/http2/Http2Util.java @@ -0,0 +1,135 @@ +package com.baeldung.netty.http2; + +import static io.netty.handler.logging.LogLevel.INFO; + +import java.security.cert.CertificateException; + +import javax.net.ssl.SSLException; + +import com.baeldung.netty.http2.client.Http2ClientResponseHandler; +import com.baeldung.netty.http2.client.Http2SettingsHandler; +import com.baeldung.netty.http2.server.Http2ServerResponseHandler; + +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelPipeline; +import io.netty.handler.codec.http.DefaultFullHttpRequest; +import io.netty.handler.codec.http.FullHttpRequest; +import io.netty.handler.codec.http.HttpHeaderNames; +import io.netty.handler.codec.http.HttpHeaderValues; +import io.netty.handler.codec.http.HttpMethod; +import io.netty.handler.codec.http.HttpScheme; +import io.netty.handler.codec.http.HttpVersion; +import io.netty.handler.codec.http2.DefaultHttp2Connection; +import io.netty.handler.codec.http2.DelegatingDecompressorFrameListener; +import io.netty.handler.codec.http2.Http2Connection; +import io.netty.handler.codec.http2.Http2FrameCodecBuilder; +import io.netty.handler.codec.http2.Http2FrameLogger; +import io.netty.handler.codec.http2.Http2SecurityUtil; +import io.netty.handler.codec.http2.HttpConversionUtil; +import io.netty.handler.codec.http2.HttpToHttp2ConnectionHandler; +import io.netty.handler.codec.http2.HttpToHttp2ConnectionHandlerBuilder; +import io.netty.handler.codec.http2.InboundHttp2ToHttpAdapterBuilder; +import io.netty.handler.ssl.ApplicationProtocolConfig; +import io.netty.handler.ssl.ApplicationProtocolConfig.Protocol; +import io.netty.handler.ssl.ApplicationProtocolConfig.SelectedListenerFailureBehavior; +import io.netty.handler.ssl.ApplicationProtocolConfig.SelectorFailureBehavior; +import io.netty.handler.ssl.ApplicationProtocolNames; +import io.netty.handler.ssl.ApplicationProtocolNegotiationHandler; +import io.netty.handler.ssl.SslContext; +import io.netty.handler.ssl.SslContextBuilder; +import io.netty.handler.ssl.SslProvider; +import io.netty.handler.ssl.SupportedCipherSuiteFilter; +import io.netty.handler.ssl.util.InsecureTrustManagerFactory; +import io.netty.handler.ssl.util.SelfSignedCertificate; + +public class Http2Util { + public static SslContext createSSLContext(boolean isServer) throws SSLException, CertificateException { + + SslContext sslCtx; + + SelfSignedCertificate ssc = new SelfSignedCertificate(); + + if (isServer) { + sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()) + .sslProvider(SslProvider.JDK) + .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE) + .applicationProtocolConfig(new ApplicationProtocolConfig(Protocol.ALPN, + SelectorFailureBehavior.NO_ADVERTISE, + SelectedListenerFailureBehavior.ACCEPT, ApplicationProtocolNames.HTTP_2, ApplicationProtocolNames.HTTP_1_1)) + .build(); + } else { + sslCtx = SslContextBuilder.forClient() + .sslProvider(SslProvider.JDK) + .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE) + .trustManager(InsecureTrustManagerFactory.INSTANCE) + .applicationProtocolConfig(new ApplicationProtocolConfig(Protocol.ALPN, + SelectorFailureBehavior.NO_ADVERTISE, + SelectedListenerFailureBehavior.ACCEPT, ApplicationProtocolNames.HTTP_2)) + .build(); + } + return sslCtx; + + } + + public static ApplicationProtocolNegotiationHandler getServerAPNHandler() { + ApplicationProtocolNegotiationHandler serverAPNHandler = new ApplicationProtocolNegotiationHandler(ApplicationProtocolNames.HTTP_2) { + + @Override + protected void configurePipeline(ChannelHandlerContext ctx, String protocol) throws Exception { + if (ApplicationProtocolNames.HTTP_2.equals(protocol)) { + ctx.pipeline() + .addLast(Http2FrameCodecBuilder.forServer() + .build(), new Http2ServerResponseHandler()); + return; + } + throw new IllegalStateException("Protocol: " + protocol + " not supported"); + } + }; + return serverAPNHandler; + + } + + public static ApplicationProtocolNegotiationHandler getClientAPNHandler(int maxContentLength, Http2SettingsHandler settingsHandler, Http2ClientResponseHandler responseHandler) { + final Http2FrameLogger logger = new Http2FrameLogger(INFO, Http2Util.class); + final Http2Connection connection = new DefaultHttp2Connection(false); + + HttpToHttp2ConnectionHandler connectionHandler = new HttpToHttp2ConnectionHandlerBuilder() + .frameListener(new DelegatingDecompressorFrameListener(connection, new InboundHttp2ToHttpAdapterBuilder(connection).maxContentLength(maxContentLength) + .propagateSettings(true) + .build())) + .frameLogger(logger) + .connection(connection) + .build(); + + ApplicationProtocolNegotiationHandler clientAPNHandler = new ApplicationProtocolNegotiationHandler(ApplicationProtocolNames.HTTP_2) { + @Override + protected void configurePipeline(ChannelHandlerContext ctx, String protocol) { + if (ApplicationProtocolNames.HTTP_2.equals(protocol)) { + ChannelPipeline p = ctx.pipeline(); + p.addLast(connectionHandler); + p.addLast(settingsHandler, responseHandler); + return; + } + ctx.close(); + throw new IllegalStateException("Protocol: " + protocol + " not supported"); + } + }; + + return clientAPNHandler; + + } + + public static FullHttpRequest createGetRequest(String host, int port) { + FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.valueOf("HTTP/2.0"), HttpMethod.GET, "/", Unpooled.EMPTY_BUFFER); + request.headers() + .add(HttpHeaderNames.HOST, new String(host + ":" + port)); + request.headers() + .add(HttpConversionUtil.ExtensionHeaderNames.SCHEME.text(), HttpScheme.HTTPS); + request.headers() + .add(HttpHeaderNames.ACCEPT_ENCODING, HttpHeaderValues.GZIP); + request.headers() + .add(HttpHeaderNames.ACCEPT_ENCODING, HttpHeaderValues.DEFLATE); + return request; + } +} diff --git a/netty/src/main/java/com/baeldung/netty/http2/client/Http2ClientInitializer.java b/netty/src/main/java/com/baeldung/netty/http2/client/Http2ClientInitializer.java new file mode 100644 index 0000000000..d50240fcb2 --- /dev/null +++ b/netty/src/main/java/com/baeldung/netty/http2/client/Http2ClientInitializer.java @@ -0,0 +1,46 @@ +package com.baeldung.netty.http2.client; + +import com.baeldung.netty.http2.Http2Util; + +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.socket.SocketChannel; +import io.netty.handler.ssl.SslContext; + +public class Http2ClientInitializer extends ChannelInitializer { + + private final SslContext sslCtx; + private final int maxContentLength; + private Http2SettingsHandler settingsHandler; + private Http2ClientResponseHandler responseHandler; + private String host; + private int port; + + public Http2ClientInitializer(SslContext sslCtx, int maxContentLength, String host, int port) { + this.sslCtx = sslCtx; + this.maxContentLength = maxContentLength; + this.host = host; + this.port = port; + } + + @Override + public void initChannel(SocketChannel ch) throws Exception { + + settingsHandler = new Http2SettingsHandler(ch.newPromise()); + responseHandler = new Http2ClientResponseHandler(); + + if (sslCtx != null) { + ChannelPipeline pipeline = ch.pipeline(); + pipeline.addLast(sslCtx.newHandler(ch.alloc(), host, port)); + pipeline.addLast(Http2Util.getClientAPNHandler(maxContentLength, settingsHandler, responseHandler)); + } + } + + public Http2SettingsHandler getSettingsHandler() { + return settingsHandler; + } + + public Http2ClientResponseHandler getResponseHandler() { + return responseHandler; + } +} diff --git a/netty/src/main/java/com/baeldung/netty/http2/client/Http2ClientResponseHandler.java b/netty/src/main/java/com/baeldung/netty/http2/client/Http2ClientResponseHandler.java new file mode 100644 index 0000000000..4e17155bbc --- /dev/null +++ b/netty/src/main/java/com/baeldung/netty/http2/client/Http2ClientResponseHandler.java @@ -0,0 +1,128 @@ +package com.baeldung.netty.http2.client; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelPromise; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.handler.codec.http.FullHttpResponse; +import io.netty.handler.codec.http2.HttpConversionUtil; +import io.netty.util.CharsetUtil; + +public class Http2ClientResponseHandler extends SimpleChannelInboundHandler { + + private final Logger logger = LoggerFactory.getLogger(Http2ClientResponseHandler.class); + private final Map streamidMap; + + public Http2ClientResponseHandler() { + streamidMap = new HashMap(); + } + + public MapValues put(int streamId, ChannelFuture writeFuture, ChannelPromise promise) { + return streamidMap.put(streamId, new MapValues(writeFuture, promise)); + } + + public String awaitResponses(long timeout, TimeUnit unit) { + + Iterator> itr = streamidMap.entrySet() + .iterator(); + + String response = null; + + while (itr.hasNext()) { + Entry entry = itr.next(); + ChannelFuture writeFuture = entry.getValue() + .getWriteFuture(); + + if (!writeFuture.awaitUninterruptibly(timeout, unit)) { + throw new IllegalStateException("Timed out waiting to write for stream id " + entry.getKey()); + } + if (!writeFuture.isSuccess()) { + throw new RuntimeException(writeFuture.cause()); + } + ChannelPromise promise = entry.getValue() + .getPromise(); + + if (!promise.awaitUninterruptibly(timeout, unit)) { + throw new IllegalStateException("Timed out waiting for response on stream id " + entry.getKey()); + } + if (!promise.isSuccess()) { + throw new RuntimeException(promise.cause()); + } + logger.info("---Stream id: " + entry.getKey() + " received---"); + response = entry.getValue().getResponse(); + + itr.remove(); + } + + return response; + + } + + @Override + protected void channelRead0(ChannelHandlerContext ctx, FullHttpResponse msg) throws Exception { + Integer streamId = msg.headers() + .getInt(HttpConversionUtil.ExtensionHeaderNames.STREAM_ID.text()); + if (streamId == null) { + logger.error("HttpResponseHandler unexpected message received: " + msg); + return; + } + + MapValues value = streamidMap.get(streamId); + + if (value == null) { + logger.error("Message received for unknown stream id " + streamId); + ctx.close(); + } else { + ByteBuf content = msg.content(); + if (content.isReadable()) { + int contentLength = content.readableBytes(); + byte[] arr = new byte[contentLength]; + content.readBytes(arr); + String response = new String(arr, 0, contentLength, CharsetUtil.UTF_8); + logger.info("Response from Server: "+ (response)); + value.setResponse(response); + } + + value.getPromise() + .setSuccess(); + } + } + + public static class MapValues { + ChannelFuture writeFuture; + ChannelPromise promise; + String response; + + public String getResponse() { + return response; + } + + public void setResponse(String response) { + this.response = response; + } + + public MapValues(ChannelFuture writeFuture2, ChannelPromise promise2) { + this.writeFuture = writeFuture2; + this.promise = promise2; + } + + public ChannelFuture getWriteFuture() { + return writeFuture; + } + + public ChannelPromise getPromise() { + return promise; + } + + } +} diff --git a/netty/src/main/java/com/baeldung/netty/http2/client/Http2SettingsHandler.java b/netty/src/main/java/com/baeldung/netty/http2/client/Http2SettingsHandler.java new file mode 100644 index 0000000000..93841187c7 --- /dev/null +++ b/netty/src/main/java/com/baeldung/netty/http2/client/Http2SettingsHandler.java @@ -0,0 +1,30 @@ +package com.baeldung.netty.http2.client; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelPromise; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.handler.codec.http2.Http2Settings; + +import java.util.concurrent.TimeUnit; + +public class Http2SettingsHandler extends SimpleChannelInboundHandler { + private final ChannelPromise promise; + + public Http2SettingsHandler(ChannelPromise promise) { + this.promise = promise; + } + + public void awaitSettings(long timeout, TimeUnit unit) throws Exception { + if (!promise.awaitUninterruptibly(timeout, unit)) { + throw new IllegalStateException("Timed out waiting for settings"); + } + } + + @Override + protected void channelRead0(ChannelHandlerContext ctx, Http2Settings msg) throws Exception { + promise.setSuccess(); + + ctx.pipeline() + .remove(this); + } +} diff --git a/netty/src/main/java/com/baeldung/netty/http2/server/Http2Server.java b/netty/src/main/java/com/baeldung/netty/http2/server/Http2Server.java new file mode 100644 index 0000000000..a8e9e59953 --- /dev/null +++ b/netty/src/main/java/com/baeldung/netty/http2/server/Http2Server.java @@ -0,0 +1,59 @@ +package com.baeldung.netty.http2.server; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.baeldung.netty.http2.Http2Util; + +import io.netty.bootstrap.ServerBootstrap; +import io.netty.channel.Channel; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelOption; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.SocketChannel; +import io.netty.channel.socket.nio.NioServerSocketChannel; +import io.netty.handler.logging.LogLevel; +import io.netty.handler.logging.LoggingHandler; +import io.netty.handler.ssl.SslContext; + +public final class Http2Server { + + private static final int PORT = 8443; + private static final Logger logger = LoggerFactory.getLogger(Http2Server.class); + + public static void main(String[] args) throws Exception { + SslContext sslCtx = Http2Util.createSSLContext(true); + + EventLoopGroup group = new NioEventLoopGroup(); + try { + ServerBootstrap b = new ServerBootstrap(); + b.option(ChannelOption.SO_BACKLOG, 1024); + b.group(group) + .channel(NioServerSocketChannel.class) + .handler(new LoggingHandler(LogLevel.INFO)) + .childHandler(new ChannelInitializer() { + @Override + protected void initChannel(SocketChannel ch) throws Exception { + if (sslCtx != null) { + ch.pipeline() + .addLast(sslCtx.newHandler(ch.alloc()), Http2Util.getServerAPNHandler()); + } + } + + }); + + Channel ch = b.bind(PORT) + .sync() + .channel(); + + logger.info("HTTP/2 Server is listening on https://127.0.0.1:" + PORT + '/'); + + ch.closeFuture() + .sync(); + } finally { + group.shutdownGracefully(); + } + } + +} diff --git a/netty/src/main/java/com/baeldung/netty/http2/server/Http2ServerResponseHandler.java b/netty/src/main/java/com/baeldung/netty/http2/server/Http2ServerResponseHandler.java new file mode 100644 index 0000000000..24c66f15bb --- /dev/null +++ b/netty/src/main/java/com/baeldung/netty/http2/server/Http2ServerResponseHandler.java @@ -0,0 +1,52 @@ +package com.baeldung.netty.http2.server; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelDuplexHandler; +import io.netty.channel.ChannelHandler.Sharable; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.http.HttpResponseStatus; +import io.netty.handler.codec.http2.DefaultHttp2DataFrame; +import io.netty.handler.codec.http2.DefaultHttp2Headers; +import io.netty.handler.codec.http2.DefaultHttp2HeadersFrame; +import io.netty.handler.codec.http2.Http2Headers; +import io.netty.handler.codec.http2.Http2HeadersFrame; +import io.netty.util.CharsetUtil; + +@Sharable +public class Http2ServerResponseHandler extends ChannelDuplexHandler { + + static final ByteBuf RESPONSE_BYTES = Unpooled.unreleasableBuffer(Unpooled.copiedBuffer("Hello World", CharsetUtil.UTF_8)); + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + super.exceptionCaught(ctx, cause); + cause.printStackTrace(); + ctx.close(); + } + + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + if (msg instanceof Http2HeadersFrame) { + Http2HeadersFrame msgHeader = (Http2HeadersFrame) msg; + if (msgHeader.isEndStream()) { + ByteBuf content = ctx.alloc() + .buffer(); + content.writeBytes(RESPONSE_BYTES.duplicate()); + + Http2Headers headers = new DefaultHttp2Headers().status(HttpResponseStatus.OK.codeAsText()); + ctx.write(new DefaultHttp2HeadersFrame(headers).stream(msgHeader.stream())); + ctx.write(new DefaultHttp2DataFrame(content, true).stream(msgHeader.stream())); + } + + } else { + super.channelRead(ctx, msg); + } + } + + @Override + public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { + ctx.flush(); + } + +} diff --git a/netty/src/main/resources/logback.xml b/netty/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/netty/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/netty/src/test/java/com/baeldung/netty/Http2ClientLiveTest.java b/netty/src/test/java/com/baeldung/netty/Http2ClientLiveTest.java new file mode 100644 index 0000000000..6b9a53a1b3 --- /dev/null +++ b/netty/src/test/java/com/baeldung/netty/Http2ClientLiveTest.java @@ -0,0 +1,91 @@ +package com.baeldung.netty; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.concurrent.TimeUnit; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.baeldung.netty.http2.Http2Util; +import com.baeldung.netty.http2.client.Http2ClientInitializer; +import com.baeldung.netty.http2.client.Http2ClientResponseHandler; +import com.baeldung.netty.http2.client.Http2SettingsHandler; + +import io.netty.bootstrap.Bootstrap; +import io.netty.channel.Channel; +import io.netty.channel.ChannelOption; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioSocketChannel; +import io.netty.handler.codec.http.FullHttpRequest; +import io.netty.handler.ssl.SslContext; + +//Ensure the server class - Http2Server.java is already started before running this test +public class Http2ClientLiveTest { + + private static final Logger logger = LoggerFactory.getLogger(Http2ClientLiveTest.class); + + private static final String HOST = "127.0.0.1"; + private static final int PORT = 8443; + private SslContext sslCtx; + private Channel channel; + + @Before + public void setup() throws Exception { + sslCtx = Http2Util.createSSLContext(false); + } + + @Test + public void whenRequestSent_thenHelloWorldReceived() throws Exception { + + EventLoopGroup workerGroup = new NioEventLoopGroup(); + Http2ClientInitializer initializer = new Http2ClientInitializer(sslCtx, Integer.MAX_VALUE, HOST, PORT); + + try { + Bootstrap b = new Bootstrap(); + b.group(workerGroup); + b.channel(NioSocketChannel.class); + b.option(ChannelOption.SO_KEEPALIVE, true); + b.remoteAddress(HOST, PORT); + b.handler(initializer); + + channel = b.connect() + .syncUninterruptibly() + .channel(); + + logger.info("Connected to [" + HOST + ':' + PORT + ']'); + + Http2SettingsHandler http2SettingsHandler = initializer.getSettingsHandler(); + http2SettingsHandler.awaitSettings(60, TimeUnit.SECONDS); + + logger.info("Sending request(s)..."); + + FullHttpRequest request = Http2Util.createGetRequest(HOST, PORT); + + Http2ClientResponseHandler responseHandler = initializer.getResponseHandler(); + int streamId = 3; + + responseHandler.put(streamId, channel.write(request), channel.newPromise()); + channel.flush(); + String response = responseHandler.awaitResponses(60, TimeUnit.SECONDS); + + assertEquals("Hello World", response); + + logger.info("Finished HTTP/2 request(s)"); + + } finally { + workerGroup.shutdownGracefully(); + } + + } + + @After + public void cleanup() { + channel.close() + .syncUninterruptibly(); + } +} diff --git a/pom.xml b/pom.xml index e21c13efc2..5602e807b9 100644 --- a/pom.xml +++ b/pom.xml @@ -536,6 +536,7 @@ mybatis netflix-modules + ninja open-liberty @@ -1047,6 +1048,7 @@ mybatis netflix-modules + ninja open-liberty From 6640e14f8bec1c63a117a75acebc16a0e4fd14a6 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 8 Apr 2020 13:11:01 +0800 Subject: [PATCH 128/503] Update README.md --- logging-modules/log-mdc/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logging-modules/log-mdc/README.md b/logging-modules/log-mdc/README.md index b676d3ba76..0d516619ef 100644 --- a/logging-modules/log-mdc/README.md +++ b/logging-modules/log-mdc/README.md @@ -1,7 +1,7 @@ ### Relevant Articles: - TBD - [Improved Java Logging with Mapped Diagnostic Context (MDC)](https://www.baeldung.com/mdc-in-log4j-2-logback) -- [Java Logging with Nested Diagnostic Context (NDC)](https:www.baeldung.com/java-logging-ndc-log4j) +- [Java Logging with Nested Diagnostic Context (NDC)](https://www.baeldung.com/java-logging-ndc-log4j) - [Drools Using Rules from Excel Files](https://www.baeldung.com/drools-excel) ### References From 15d4893d2e2742261e2661d3ffabcfca443a6851 Mon Sep 17 00:00:00 2001 From: Joao Esperancinha Date: Wed, 8 Apr 2020 08:13:28 +0200 Subject: [PATCH 129/503] [BAEL-2749] Bumps DBUnit to version 2.7.0 --- libraries-testing/pom.xml | 2 +- .../test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libraries-testing/pom.xml b/libraries-testing/pom.xml index c4d2786441..ad6c81a3d6 100644 --- a/libraries-testing/pom.xml +++ b/libraries-testing/pom.xml @@ -198,7 +198,7 @@ 3.6.2 2.0.0.0 1.4.200 - 2.6.0 + 2.7.0 3.14.0 1.8 1.8 diff --git a/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java b/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java index 20b0337f4d..93c7e9a456 100644 --- a/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java +++ b/libraries-testing/src/test/java/com/baeldung/dbunit/DataSourceDBUnitTest.java @@ -17,6 +17,7 @@ import org.junit.platform.commons.logging.LoggerFactory; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; +import javax.sql.DataSource; import java.io.InputStream; import java.sql.Connection; import java.sql.ResultSet; @@ -33,7 +34,7 @@ public class DataSourceDBUnitTest extends DataSourceBasedDBTestCase { private static final Logger logger = LoggerFactory.getLogger(DataSourceDBUnitTest.class); @Override - protected javax.sql.DataSource getDataSource() { + protected DataSource getDataSource() { JdbcDataSource dataSource = new JdbcDataSource(); dataSource.setURL(JDBC_URL); dataSource.setUser("sa"); From 5fc5e76929e92bb781dcc0dc707be61ffd98078b Mon Sep 17 00:00:00 2001 From: Aitor Cuesta Date: Wed, 8 Apr 2020 11:30:52 +0200 Subject: [PATCH 130/503] BAEL-3075 - PR reviews, removing Oracle jars, adding extra explanation/configuration to Oracle configurations --- .../spring-boot-persistence-2/README.md | 3 +- .../spring-boot-persistence-2/lib/ons.jar | Bin 139977 -> 0 bytes .../spring-boot-persistence-2/pom.xml | 101 ++++++++---------- .../configuration/OracleConfiguration.java | 2 + .../configuration/OracleUCPConfiguration.java | 4 +- 5 files changed, 53 insertions(+), 57 deletions(-) delete mode 100644 persistence-modules/spring-boot-persistence-2/lib/ons.jar diff --git a/persistence-modules/spring-boot-persistence-2/README.md b/persistence-modules/spring-boot-persistence-2/README.md index a74bf7ff02..fac8b75615 100644 --- a/persistence-modules/spring-boot-persistence-2/README.md +++ b/persistence-modules/spring-boot-persistence-2/README.md @@ -1,4 +1,3 @@ ### Relevant Articles: -- [Using JDBI with Spring Boot](https://www.baeldung.com/spring-boot-jdbi) -- [Oracle Connection Pooling With Spring](https://www.baeldung.com/oracle-connection-pooling-with-spring) \ No newline at end of file +- [Using JDBI with Spring Boot](https://www.baeldung.com/spring-boot-jdbi) \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-2/lib/ons.jar b/persistence-modules/spring-boot-persistence-2/lib/ons.jar deleted file mode 100644 index 637cf11887b54ddf4d567b7251ee51a18d235af7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 139977 zcmbrmW0Ymvk~W;Kw9QJ}cBO6Gww+mN+qP}nwpD3orHwb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kk)DG=U2!5cWUPifV)+8k3z%j22W!9Z zuHp;w^wJ9)i(D|AUwg+c&N7AM2=ds<3#7VyaHR90+rK6Lkf$P$L19Cg`1un%L817}8qam4u+=hGs zcJL>#KfjcN-0ynrT z^y|Ic#l9v;T|#b;x{o+AF4esNb=mzF(5nZWkgJz2Kwln#fnKtf2~ujv zbwL+cg~z{PUA9UH5)g9f%>`iM$rXUVh7Xr}5aeQ&3%r`s-|!%&U(OL>fMf~^$`bew OhYSiT6$(iBp#BHktRXf4 diff --git a/persistence-modules/spring-boot-persistence-2/pom.xml b/persistence-modules/spring-boot-persistence-2/pom.xml index 8f76bce1b3..c1afededb0 100644 --- a/persistence-modules/spring-boot-persistence-2/pom.xml +++ b/persistence-modules/spring-boot-persistence-2/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.baeldung.boot.persistence spring-boot-persistence-2 @@ -41,20 +41,20 @@ - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - - net.bytebuddy - byte-buddy - + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + net.bytebuddy + byte-buddy + org.jdbi @@ -92,47 +92,23 @@ spring-boot-starter-test test - + - com.oracle - ojdbc8 - 12.2.0.1 - system - ${basedir}/lib/ojdbc8.jar - - - - com.oracle - ucp - 12.2.0.1 - system - ${basedir}/lib/ucp.jar - - - - com.oracle - ons - 12.2.0.1 - system - ${basedir}/lib/ons.jar - + com.mchange + c3p0 + ${c3p0.version} + - - com.mchange - c3p0 - ${c3p0.version} - + + org.apache.commons + commons-dbcp2 + + + + org.apache.tomcat + tomcat-jdbc + - - org.apache.commons - commons-dbcp2 - - - - org.apache.tomcat - tomcat-jdbc - - @@ -141,6 +117,23 @@ org.springframework.boot spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + + + com/baeldung/spring/oracle/pooling/configuration/OracleConfiguration.java + com/baeldung/spring/oracle/pooling/configuration/OracleUCPConfiguration.java + + + com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationOracleLiveTest.java + com/baeldung/spring/oracle/pooling/SpringOraclePoolingApplicationOracleUCPLiveTest.java + + + diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/OracleConfiguration.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/OracleConfiguration.java index 327374cb54..9cf7e27c99 100644 --- a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/OracleConfiguration.java +++ b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/OracleConfiguration.java @@ -22,6 +22,8 @@ public class OracleConfiguration { dataSource.setURL("jdbc:oracle:thin:@//localhost:11521/ORCLPDB1"); dataSource.setFastConnectionFailoverEnabled(true); dataSource.setImplicitCachingEnabled(true); + // Only with clients prior to v11.2 + // dataSource.setConnectionCachingEnabled(true); return dataSource; } } diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/OracleUCPConfiguration.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/OracleUCPConfiguration.java index 67b4b40712..b4c1544149 100644 --- a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/OracleUCPConfiguration.java +++ b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/oracle/pooling/configuration/OracleUCPConfiguration.java @@ -21,9 +21,11 @@ public class OracleUCPConfiguration { dataSource.setUser("books"); dataSource.setPassword("books"); dataSource.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource"); - dataSource.setURL("jdbc:oracle:thin:@//localhost:11521/ORCLPDB1"); + dataSource.setURL("jdbc:oracle:thin:@//localhost:11521/ORCLPDB1"); + dataSource.setFastConnectionFailoverEnabled(true); dataSource.setInitialPoolSize(5); + dataSource.setMinPoolSize(5); dataSource.setMaxPoolSize(10); return dataSource; } From 6677cf74d16bbb163adc8a4f873acc3c89920bc2 Mon Sep 17 00:00:00 2001 From: Kostas Karavitis Date: Wed, 8 Apr 2020 16:12:14 +0300 Subject: [PATCH 131/503] [BAEL-3936] Many to many underlying relationship test --- .../jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java index 12042c2ba6..27bf1d8b62 100644 --- a/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java +++ b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java @@ -155,7 +155,7 @@ public class UnrelatedEntitiesUnitTest { } @Test - public void whenQueryingForRumCocktailsInMenuRecipes_thenTheExpectedRecipesReturned() { + public void whenQueryingForMultipleRecipes_thenTheExpectedRecipesReturned() { Consumer> verifyResult = recipes -> { assertEquals(2, recipes.size()); recipes.forEach(r -> assertEquals(mojito.getName(), r.getCocktail())); @@ -165,9 +165,8 @@ public class UnrelatedEntitiesUnitTest { List recipes = entityManager.createQuery("select distinct r " + "from MultipleRecipe r " + "join Cocktail c " - + "on r.cocktail = c.name and r.baseIngredient = :category", + + "on r.baseIngredient = c.category", MultipleRecipe.class) - .setParameter("category", mojito.getCategory()) .getResultList(); verifyResult.accept(recipes); @@ -176,8 +175,7 @@ public class UnrelatedEntitiesUnitTest { QMultipleRecipe multipleRecipe = QMultipleRecipe.multipleRecipe; recipes = new JPAQuery(entityManager).from(multipleRecipe) .join(cocktail) - .on(multipleRecipe.cocktail.eq(cocktail.name) - .and(multipleRecipe.baseIngredient.eq(mojito.getCategory()))) + .on(multipleRecipe.baseIngredient.eq(cocktail.category)) .fetch(); verifyResult.accept(recipes); } From 74e02b22165fe8b0046b516e0355e43167e427a4 Mon Sep 17 00:00:00 2001 From: Kostas Karavitis Date: Wed, 8 Apr 2020 18:44:32 +0300 Subject: [PATCH 132/503] [BAEL-3936] Fixed the name of menu table --- .../com/baeldung/jpa/unrelated/entities/Cocktail.java | 8 +++++--- .../jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java index 7f5ca66570..fdccad6bd7 100644 --- a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java +++ b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java @@ -1,5 +1,7 @@ package com.baeldung.jpa.unrelated.entities; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; @@ -8,7 +10,7 @@ import java.util.List; import java.util.Objects; @Entity -@Table(name = "cocktails") +@Table(name = "menu") public class Cocktail { @Id @Column(name = "cocktail_name") @@ -22,7 +24,7 @@ public class Cocktail { @OneToOne @NotFound(action = NotFoundAction.IGNORE) - @JoinColumn(name = "cocktail_name", + @JoinColumn(name = "cocktail_name", referencedColumnName = "cocktail", insertable = false, updatable = false, foreignKey = @javax.persistence @@ -30,7 +32,7 @@ public class Cocktail { ) private Recipe recipe; - @OneToMany + @OneToMany(fetch = FetchType.LAZY) @NotFound(action = NotFoundAction.IGNORE) @JoinColumn( name = "cocktail", diff --git a/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java index 27bf1d8b62..8733b3e7da 100644 --- a/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java +++ b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java @@ -38,6 +38,7 @@ public class UnrelatedEntitiesUnitTest { entityManager.close(); } + @Test public void whenQueryingForCocktailThatHasRecipe_thenTheExpectedCocktailReturned() { // JPA From f9ac384b8567a06c65e7b1e47c3ec2c3026a8dda Mon Sep 17 00:00:00 2001 From: Sam Millington Date: Wed, 8 Apr 2020 18:40:34 +0100 Subject: [PATCH 133/503] Added BAEL-3604 code (#9020) * Added BAEL-3604 code --- .../core-java-security-2/pom.xml | 11 ++++ .../com/baeldung/checksums/ChecksumUtils.java | 23 +++++++++ .../checksums/ChecksumUtilsUnitTest.java | 51 +++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 core-java-modules/core-java-security-2/src/main/java/com/baeldung/checksums/ChecksumUtils.java create mode 100644 core-java-modules/core-java-security-2/src/test/java/com/baeldung/checksums/ChecksumUtilsUnitTest.java diff --git a/core-java-modules/core-java-security-2/pom.xml b/core-java-modules/core-java-security-2/pom.xml index 9315ab4af2..5db3b67c04 100644 --- a/core-java-modules/core-java-security-2/pom.xml +++ b/core-java-modules/core-java-security-2/pom.xml @@ -17,6 +17,7 @@ + commons-codec commons-codec @@ -36,6 +37,15 @@ ${assertj-core.version} test + + + + javax.xml.bind + jaxb-api + 2.3.1 + + + @@ -46,4 +56,5 @@ 3.10.0 + diff --git a/core-java-modules/core-java-security-2/src/main/java/com/baeldung/checksums/ChecksumUtils.java b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/checksums/ChecksumUtils.java new file mode 100644 index 0000000000..d214a0f757 --- /dev/null +++ b/core-java-modules/core-java-security-2/src/main/java/com/baeldung/checksums/ChecksumUtils.java @@ -0,0 +1,23 @@ +package com.baeldung.checksums; + +import java.io.IOException; +import java.io.InputStream; +import java.util.zip.CRC32; +import java.util.zip.CheckedInputStream; +import java.util.zip.Checksum; + +public class ChecksumUtils { + + public static long getChecksumCRC32(byte[] bytes) { + Checksum crc32 = new CRC32(); + crc32.update(bytes, 0, bytes.length); + return crc32.getValue(); + } + + public static long getChecksumCRC32(InputStream stream, int bufferSize) throws IOException { + CheckedInputStream checkedInputStream = new CheckedInputStream(stream, new CRC32()); + byte[] buffer = new byte[bufferSize]; + while (checkedInputStream.read(buffer, 0, buffer.length) >= 0) {} + return checkedInputStream.getChecksum().getValue(); + } +} diff --git a/core-java-modules/core-java-security-2/src/test/java/com/baeldung/checksums/ChecksumUtilsUnitTest.java b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/checksums/ChecksumUtilsUnitTest.java new file mode 100644 index 0000000000..f5366917f6 --- /dev/null +++ b/core-java-modules/core-java-security-2/src/test/java/com/baeldung/checksums/ChecksumUtilsUnitTest.java @@ -0,0 +1,51 @@ +package com.baeldung.checksums; + + +import org.junit.Before; +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +import static org.junit.jupiter.api.Assertions.*; + +class ChecksumUtilsUnitTest { + + byte[] arr; + + @Before + void setUp() { + arr = new byte[]{0,10,21,20,35,40,120,56,72,22}; + } + + @Test + void givenByteArray_whenChecksumCreated_checkCorrect() { + + long checksum = ChecksumUtils.getChecksumCRC32(arr); + + assertEquals(3915397664L, checksum); + } + + @Test + void givenTwoDifferentStrings_whenChecksumCreated_checkCollision() { + + String plumless = "plumless"; + String buckeroo = "buckeroo"; + + long plumlessChecksum = ChecksumUtils.getChecksumCRC32(plumless.getBytes()); + long buckerooChecksum = ChecksumUtils.getChecksumCRC32(buckeroo.getBytes()); + + assertEquals(plumlessChecksum, buckerooChecksum); + } + + @Test + void givenInputString_whenChecksumCreated_checkCorrect() throws IOException { + + InputStream inputStream = new ByteArrayInputStream(arr); + long checksum = ChecksumUtils.getChecksumCRC32(inputStream, 10); + + assertEquals(3915397664L, checksum); + + } +} \ No newline at end of file From 88cc732dc7bfffba9f086bd0d77f0487b56bd0bb Mon Sep 17 00:00:00 2001 From: Catalin Burcea Date: Thu, 9 Apr 2020 10:30:04 +0300 Subject: [PATCH 134/503] BAEL-3649 Quick Guide to Spring Cloud Circuit Breaker (#8819) --- .../spring-cloud-circuit-breaker/README.md | 5 ++ .../spring-cloud-circuit-breaker/pom.xml | 55 ++++++++++++++ .../baeldung/circuitbreaker/AlbumService.java | 40 +++++++++++ .../baeldung/circuitbreaker/Controller.java | 18 +++++ .../baeldung/circuitbreaker/SpringApp.java | 71 +++++++++++++++++++ .../main/resources/fallback-album-list.json | 12 ++++ 6 files changed, 201 insertions(+) create mode 100644 spring-cloud/spring-cloud-circuit-breaker/README.md create mode 100644 spring-cloud/spring-cloud-circuit-breaker/pom.xml create mode 100644 spring-cloud/spring-cloud-circuit-breaker/src/main/java/com/baeldung/circuitbreaker/AlbumService.java create mode 100644 spring-cloud/spring-cloud-circuit-breaker/src/main/java/com/baeldung/circuitbreaker/Controller.java create mode 100644 spring-cloud/spring-cloud-circuit-breaker/src/main/java/com/baeldung/circuitbreaker/SpringApp.java create mode 100644 spring-cloud/spring-cloud-circuit-breaker/src/main/resources/fallback-album-list.json diff --git a/spring-cloud/spring-cloud-circuit-breaker/README.md b/spring-cloud/spring-cloud-circuit-breaker/README.md new file mode 100644 index 0000000000..040eb0ccee --- /dev/null +++ b/spring-cloud/spring-cloud-circuit-breaker/README.md @@ -0,0 +1,5 @@ +## Spring Cloud Circuit Breaker + +This module contains articles about Spring Cloud Circuit Breaker + +### Relevant Articles: diff --git a/spring-cloud/spring-cloud-circuit-breaker/pom.xml b/spring-cloud/spring-cloud-circuit-breaker/pom.xml new file mode 100644 index 0000000000..188fc4bf8e --- /dev/null +++ b/spring-cloud/spring-cloud-circuit-breaker/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + spring-cloud-circuit-breaker + spring-cloud-gateway + jar + + + com.baeldung.spring.cloud + spring-cloud + 1.0.0-SNAPSHOT + .. + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/libs-snapshot + + true + + + false + + + + + + + + org.springframework.boot + spring-boot-dependencies + 2.2.4.RELEASE + pom + import + + + + + + + org.springframework.cloud + spring-cloud-starter-circuitbreaker-resilience4j + 1.0.2.RELEASE + + + org.springframework.boot + spring-boot-starter-web + + + + diff --git a/spring-cloud/spring-cloud-circuit-breaker/src/main/java/com/baeldung/circuitbreaker/AlbumService.java b/spring-cloud/spring-cloud-circuit-breaker/src/main/java/com/baeldung/circuitbreaker/AlbumService.java new file mode 100644 index 0000000000..67163c8c9a --- /dev/null +++ b/spring-cloud/spring-cloud-circuit-breaker/src/main/java/com/baeldung/circuitbreaker/AlbumService.java @@ -0,0 +1,40 @@ +package com.baeldung.circuitbreaker; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.client.circuitbreaker.CircuitBreaker; +import org.springframework.cloud.client.circuitbreaker.CircuitBreakerFactory; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import java.nio.file.Files; +import java.nio.file.Paths; + +@Service +public class AlbumService { + + private static final Logger LOGGER = LoggerFactory.getLogger(AlbumService.class); + + @Autowired + private CircuitBreakerFactory circuitBreakerFactory; + + private RestTemplate restTemplate = new RestTemplate(); + + public String getAlbumList() { + CircuitBreaker circuitBreaker = circuitBreakerFactory.create("circuitbreaker"); + String url = "https://jsonplaceholder.typicode.com/albums"; + + return circuitBreaker.run(() -> restTemplate.getForObject(url, String.class), throwable -> getDefaultAlbumList()); + } + + private String getDefaultAlbumList() { + try { + return new String(Files.readAllBytes(Paths.get(getClass().getClassLoader().getResource("fallback-album-list.json").toURI()))); + } catch (Exception e) { + LOGGER.error("error occurred while reading the file", e); + } + return null; + } + +} diff --git a/spring-cloud/spring-cloud-circuit-breaker/src/main/java/com/baeldung/circuitbreaker/Controller.java b/spring-cloud/spring-cloud-circuit-breaker/src/main/java/com/baeldung/circuitbreaker/Controller.java new file mode 100644 index 0000000000..10f7c57a7a --- /dev/null +++ b/spring-cloud/spring-cloud-circuit-breaker/src/main/java/com/baeldung/circuitbreaker/Controller.java @@ -0,0 +1,18 @@ +package com.baeldung.circuitbreaker; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class Controller { + + @Autowired + private AlbumService service; + + @GetMapping("/albums") + public String albums() { + return service.getAlbumList(); + } + +} \ No newline at end of file diff --git a/spring-cloud/spring-cloud-circuit-breaker/src/main/java/com/baeldung/circuitbreaker/SpringApp.java b/spring-cloud/spring-cloud-circuit-breaker/src/main/java/com/baeldung/circuitbreaker/SpringApp.java new file mode 100644 index 0000000000..f891e7693f --- /dev/null +++ b/spring-cloud/spring-cloud-circuit-breaker/src/main/java/com/baeldung/circuitbreaker/SpringApp.java @@ -0,0 +1,71 @@ +package com.baeldung.circuitbreaker; + +import io.github.resilience4j.circuitbreaker.CircuitBreakerConfig; +import io.github.resilience4j.timelimiter.TimeLimiterConfig; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.circuitbreaker.resilience4j.Resilience4JCircuitBreakerFactory; +import org.springframework.cloud.circuitbreaker.resilience4j.Resilience4JConfigBuilder; +import org.springframework.cloud.client.circuitbreaker.Customizer; +import org.springframework.context.annotation.Bean; + +import java.time.Duration; + +@SpringBootApplication +public class SpringApp { + + public static void main(String[] args) { + SpringApplication.run(SpringApp.class, args); + } + + @Bean + public Customizer globalCustomConfiguration() { + TimeLimiterConfig timeLimiterConfig = TimeLimiterConfig.custom() + .timeoutDuration(Duration.ofSeconds(4)) + .build(); + CircuitBreakerConfig circuitBreakerConfig = CircuitBreakerConfig.custom() + .failureRateThreshold(50) + .waitDurationInOpenState(Duration.ofMillis(1000)) + .slidingWindowSize(2) + .build(); + + return factory -> factory.configureDefault(id -> new Resilience4JConfigBuilder(id) + .timeLimiterConfig(timeLimiterConfig) + .circuitBreakerConfig(circuitBreakerConfig) + .build()); + } + + @Bean + public Customizer specificCustomConfiguration1() { + + TimeLimiterConfig timeLimiterConfig = TimeLimiterConfig.custom() + .timeoutDuration(Duration.ofSeconds(4)) + .build(); + CircuitBreakerConfig circuitBreakerConfig = CircuitBreakerConfig.custom() + .failureRateThreshold(50) + .waitDurationInOpenState(Duration.ofMillis(1000)) + .slidingWindowSize(2) + .build(); + + return factory -> factory.configure(builder -> builder.circuitBreakerConfig(circuitBreakerConfig) + .timeLimiterConfig(timeLimiterConfig).build(), "circuitBreaker"); + } + + @Bean + public Customizer specificCustomConfiguration2() { + + TimeLimiterConfig timeLimiterConfig = TimeLimiterConfig.custom() + .timeoutDuration(Duration.ofSeconds(4)) + .build(); + CircuitBreakerConfig circuitBreakerConfig = CircuitBreakerConfig.custom() + .failureRateThreshold(50) + .waitDurationInOpenState(Duration.ofMillis(1000)) + .slidingWindowSize(2) + .build(); + + return factory -> factory.configure(builder -> builder.circuitBreakerConfig(circuitBreakerConfig) + .timeLimiterConfig(timeLimiterConfig).build(), + "circuitBreaker1", "circuitBreaker2", "circuitBreaker3"); + } + +} diff --git a/spring-cloud/spring-cloud-circuit-breaker/src/main/resources/fallback-album-list.json b/spring-cloud/spring-cloud-circuit-breaker/src/main/resources/fallback-album-list.json new file mode 100644 index 0000000000..001df7610a --- /dev/null +++ b/spring-cloud/spring-cloud-circuit-breaker/src/main/resources/fallback-album-list.json @@ -0,0 +1,12 @@ +[ + { + "userId": 1, + "id": 1, + "title": "quidem molestiae enim" + }, + { + "userId": 1, + "id": 2, + "title": "sunt qui excepturi placeat culpa" + } +] \ No newline at end of file From 3786d6309db285b8d8f2b999b2ee020593816050 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 9 Apr 2020 16:48:25 +0800 Subject: [PATCH 135/503] Update README.md --- java-numbers/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/java-numbers/README.md b/java-numbers/README.md index 8f53006b38..f4b76c3c98 100644 --- a/java-numbers/README.md +++ b/java-numbers/README.md @@ -12,4 +12,5 @@ This module contains articles about numbers in Java. - [Calculating the nth Root in Java](https://www.baeldung.com/java-nth-root) - [Convert Double to String, Removing Decimal Places](https://www.baeldung.com/java-double-to-string) - [Changing the Order in a Sum Operation Can Produce Different Results?](https://www.baeldung.com/java-floating-point-sum-order) +- [Using Math.sin with Degrees](https://www.baeldung.com/java-math-sin-degrees) - More articles: [[next -->]](/../java-numbers-2) From d29fef1f518a3d35cb35d74204ba468a263a825b Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Thu, 9 Apr 2020 16:50:03 +0800 Subject: [PATCH 136/503] Update README.md --- core-kotlin-modules/core-kotlin/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-kotlin-modules/core-kotlin/README.md b/core-kotlin-modules/core-kotlin/README.md index 90caccf5c8..151da607ac 100644 --- a/core-kotlin-modules/core-kotlin/README.md +++ b/core-kotlin-modules/core-kotlin/README.md @@ -3,7 +3,7 @@ This module contains articles about Kotlin core features. ### Relevant articles: -- [Introduction to the Kotlin Language](https://www.baeldung.com/kotlin-intro) +- [Introduction to the Kotlin Language](https://www.baeldung.com/kotlin/tutorial) - [Kotlin Java Interoperability](https://www.baeldung.com/kotlin-java-interoperability) - [Get a Random Number in Kotlin](https://www.baeldung.com/kotlin-random-number) - [Create a Java and Kotlin Project with Maven](https://www.baeldung.com/kotlin-maven-java-project) From b132703ce9a61e3ca0a8b6ea69b9790075907265 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Thu, 9 Apr 2020 21:04:10 +0530 Subject: [PATCH 137/503] JWs module dependency fix --- jws/pom.xml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/jws/pom.xml b/jws/pom.xml index e6ab7e05ec..f867df8051 100644 --- a/jws/pom.xml +++ b/jws/pom.xml @@ -17,7 +17,7 @@ OpenNMS Repository - http://repo.opennms.org/maven2/ + https://repo.opennms.org/maven2/ @@ -27,11 +27,6 @@ jnlp-servlet ${jnlp-servlet.version} - - javax.samples.jnlp - jnlp-jardiff - ${jnlp-jardiff.version} - @@ -84,7 +79,6 @@ 3.0.2 - 1.6.0 1.6.0 From bcf5d50baa5e4b8ce46be437095123a985dcadda Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Thu, 9 Apr 2020 23:42:31 +0530 Subject: [PATCH 138/503] JAVA-1188: Removed duplicate entry from README --- core-java-modules/core-java-collections-maps/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/core-java-modules/core-java-collections-maps/README.md b/core-java-modules/core-java-collections-maps/README.md index 828f8992e1..15cb32fbe8 100644 --- a/core-java-modules/core-java-collections-maps/README.md +++ b/core-java-modules/core-java-collections-maps/README.md @@ -4,7 +4,6 @@ This module contains articles about Map data structures in Java. ### Relevant Articles: - [Guide to the Guava BiMap](https://www.baeldung.com/guava-bimap) -- [A Guide to Java HashMap](https://www.baeldung.com/java-hashmap) - [A Guide to LinkedHashMap in Java](https://www.baeldung.com/java-linked-hashmap) - [A Guide to TreeMap in Java](https://www.baeldung.com/java-treemap) - [How to Store Duplicate Keys in a Map in Java?](https://www.baeldung.com/java-map-duplicate-keys) From db789ae6748a944168dda12c507406e748405315 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 9 Apr 2020 20:55:15 +0200 Subject: [PATCH 139/503] JAVA-976: Fix spring-security-mvc-login configuration --- .../src/test/java/com/baeldung/SpringContextTest.java | 2 +- .../security/RedirectionSecurityIntegrationTest.java | 2 +- .../src/test/resources/mvc-servlet.xml | 8 -------- 3 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 spring-security-modules/spring-security-mvc-login/src/test/resources/mvc-servlet.xml diff --git a/spring-security-modules/spring-security-mvc-login/src/test/java/com/baeldung/SpringContextTest.java b/spring-security-modules/spring-security-mvc-login/src/test/java/com/baeldung/SpringContextTest.java index 4cf3b736ea..dfc83a40b0 100644 --- a/spring-security-modules/spring-security-mvc-login/src/test/java/com/baeldung/SpringContextTest.java +++ b/spring-security-modules/spring-security-mvc-login/src/test/java/com/baeldung/SpringContextTest.java @@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration({ "/RedirectionWebSecurityConfig.xml", "/mvc-servlet.xml" }) +@ContextConfiguration({ "/RedirectionWebSecurityConfig.xml" }) @WebAppConfiguration public class SpringContextTest { @Test diff --git a/spring-security-modules/spring-security-mvc-login/src/test/java/com/baeldung/security/RedirectionSecurityIntegrationTest.java b/spring-security-modules/spring-security-mvc-login/src/test/java/com/baeldung/security/RedirectionSecurityIntegrationTest.java index 1235e2e69f..e2b444de20 100644 --- a/spring-security-modules/spring-security-mvc-login/src/test/java/com/baeldung/security/RedirectionSecurityIntegrationTest.java +++ b/spring-security-modules/spring-security-mvc-login/src/test/java/com/baeldung/security/RedirectionSecurityIntegrationTest.java @@ -25,7 +25,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration({ "/RedirectionWebSecurityConfig.xml", "/mvc-servlet.xml" }) +@ContextConfiguration({ "/RedirectionWebSecurityConfig.xml" }) @WebAppConfiguration public class RedirectionSecurityIntegrationTest { diff --git a/spring-security-modules/spring-security-mvc-login/src/test/resources/mvc-servlet.xml b/spring-security-modules/spring-security-mvc-login/src/test/resources/mvc-servlet.xml deleted file mode 100644 index aee837c977..0000000000 --- a/spring-security-modules/spring-security-mvc-login/src/test/resources/mvc-servlet.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - \ No newline at end of file From 6205b4965841c366c97fcb62bfe9f2d26ceb17b9 Mon Sep 17 00:00:00 2001 From: Sasa m Date: Thu, 9 Apr 2020 20:56:42 +0200 Subject: [PATCH 140/503] Remove unused commit --- .../baeldung/employee/config/AppConfig.java | 63 ------------------- .../config/ApplicationInitializer.java | 29 --------- .../employee/data/EmployeeDataAdapter.java | 9 --- .../data/EmployeeDataAdapterImpl.java | 28 --------- .../baeldung/employee/data/EmployeeRepo.java | 9 --- .../baeldung/employee/domain/Employee.java | 43 ------------- .../baeldung/employee/dto/EmployeeDTO.java | 9 --- .../employee/service/EmployeeController.java | 47 -------------- .../employee/service/EmployeeService.java | 8 --- .../employee/service/EmployeeServiceImpl.java | 25 -------- EmpServiceApp/src/createEmployeeTable.sql | 11 ---- .../web/WEB-INF/applicationContext.xml | 12 ---- EmpServiceApp/web/WEB-INF/web.xml | 25 -------- 13 files changed, 318 deletions(-) delete mode 100644 EmpServiceApp/src/com/baeldung/employee/config/AppConfig.java delete mode 100644 EmpServiceApp/src/com/baeldung/employee/config/ApplicationInitializer.java delete mode 100644 EmpServiceApp/src/com/baeldung/employee/data/EmployeeDataAdapter.java delete mode 100644 EmpServiceApp/src/com/baeldung/employee/data/EmployeeDataAdapterImpl.java delete mode 100644 EmpServiceApp/src/com/baeldung/employee/data/EmployeeRepo.java delete mode 100644 EmpServiceApp/src/com/baeldung/employee/domain/Employee.java delete mode 100644 EmpServiceApp/src/com/baeldung/employee/dto/EmployeeDTO.java delete mode 100644 EmpServiceApp/src/com/baeldung/employee/service/EmployeeController.java delete mode 100644 EmpServiceApp/src/com/baeldung/employee/service/EmployeeService.java delete mode 100644 EmpServiceApp/src/com/baeldung/employee/service/EmployeeServiceImpl.java delete mode 100644 EmpServiceApp/src/createEmployeeTable.sql delete mode 100644 EmpServiceApp/web/WEB-INF/applicationContext.xml delete mode 100644 EmpServiceApp/web/WEB-INF/web.xml diff --git a/EmpServiceApp/src/com/baeldung/employee/config/AppConfig.java b/EmpServiceApp/src/com/baeldung/employee/config/AppConfig.java deleted file mode 100644 index 3bde8fceed..0000000000 --- a/EmpServiceApp/src/com/baeldung/employee/config/AppConfig.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.baeldung.employee.config; - -import javax.persistence.EntityManagerFactory; -import javax.sql.DataSource; - -import org.modelmapper.ModelMapper; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase; -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; -import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; -import org.springframework.orm.jpa.JpaTransactionManager; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; -import org.springframework.transaction.TransactionManager; - -@Configuration -@EnableJpaRepositories(basePackages = "com.baeldung.employee.data", entityManagerFactoryRef = "emf") -@ComponentScan(basePackages = "com.baeldung.employee") -public class AppConfig { - - @Bean - public DataSource h2DataSource() { - - EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); - EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2) - .addScript("createEmployeeTable.sql") - .build(); - return db; - - } - - @Bean - public ModelMapper mapper() { - - return new ModelMapper(); - } - - - @Bean(name = "emf") - public LocalContainerEntityManagerFactoryBean entityManagerFactory() { - - HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - - LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); - factory.setJpaVendorAdapter(vendorAdapter); - factory.setPackagesToScan("com.baeldung.employee"); - factory.setDataSource(h2DataSource()); - - - return factory; - } - - @Bean - public TransactionManager jpaTransactionManager(EntityManagerFactory emf) { - JpaTransactionManager transactionManager = new JpaTransactionManager(); - transactionManager.setEntityManagerFactory(emf); - return transactionManager; - } - -} diff --git a/EmpServiceApp/src/com/baeldung/employee/config/ApplicationInitializer.java b/EmpServiceApp/src/com/baeldung/employee/config/ApplicationInitializer.java deleted file mode 100644 index 491e97b2c8..0000000000 --- a/EmpServiceApp/src/com/baeldung/employee/config/ApplicationInitializer.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.employee.config; - -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletRegistration; - -import org.springframework.web.WebApplicationInitializer; -import org.springframework.web.context.ContextLoaderListener; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import org.springframework.web.servlet.DispatcherServlet; - -public class ApplicationInitializer implements WebApplicationInitializer { - - @Override - public void onStartup(ServletContext servletContext) throws ServletException { - - AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); - context.register(AppConfig.class); - - servletContext.addListener(new ContextLoaderListener(context)); - - // Create DispatcherServlet - - ServletRegistration.Dynamic dispatcher = servletContext.addServlet("EmployeeSpringApp", new DispatcherServlet()); - dispatcher.setLoadOnStartup(1); - dispatcher.addMapping("/app"); - - } -} diff --git a/EmpServiceApp/src/com/baeldung/employee/data/EmployeeDataAdapter.java b/EmpServiceApp/src/com/baeldung/employee/data/EmployeeDataAdapter.java deleted file mode 100644 index da5d5bb1a3..0000000000 --- a/EmpServiceApp/src/com/baeldung/employee/data/EmployeeDataAdapter.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.employee.data; - -import com.baeldung.employee.dto.EmployeeDTO; - -public interface EmployeeDataAdapter { - - void addEmployee(EmployeeDTO emp); - -} diff --git a/EmpServiceApp/src/com/baeldung/employee/data/EmployeeDataAdapterImpl.java b/EmpServiceApp/src/com/baeldung/employee/data/EmployeeDataAdapterImpl.java deleted file mode 100644 index 54b3079844..0000000000 --- a/EmpServiceApp/src/com/baeldung/employee/data/EmployeeDataAdapterImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.employee.data; - -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; - -import org.modelmapper.ModelMapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import com.baeldung.employee.domain.Employee; -import com.baeldung.employee.dto.EmployeeDTO; - -@Component -public class EmployeeDataAdapterImpl implements EmployeeDataAdapter { - - @PersistenceContext - private EntityManager em; - - @Autowired - private ModelMapper modelMapper; - - @Override - public void addEmployee(EmployeeDTO emp) { - - em.persist(modelMapper.map(emp, Employee.class)); - - } -} diff --git a/EmpServiceApp/src/com/baeldung/employee/data/EmployeeRepo.java b/EmpServiceApp/src/com/baeldung/employee/data/EmployeeRepo.java deleted file mode 100644 index 0712f7823a..0000000000 --- a/EmpServiceApp/src/com/baeldung/employee/data/EmployeeRepo.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.employee.data; - -import org.springframework.data.jpa.repository.JpaRepository; - -import com.baeldung.employee.domain.Employee; - -public interface EmployeeRepo extends JpaRepository { - -} diff --git a/EmpServiceApp/src/com/baeldung/employee/domain/Employee.java b/EmpServiceApp/src/com/baeldung/employee/domain/Employee.java deleted file mode 100644 index 3b93b8a97e..0000000000 --- a/EmpServiceApp/src/com/baeldung/employee/domain/Employee.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.baeldung.employee.domain; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; - -@Entity -@Table -public class Employee { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private int id; - - private String name; - - public Employee() { - } - - public Employee(int id, String name) { - this.id = id; - this.name = name; - } - - public long getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - // Standard constructors, getters and setters -} diff --git a/EmpServiceApp/src/com/baeldung/employee/dto/EmployeeDTO.java b/EmpServiceApp/src/com/baeldung/employee/dto/EmployeeDTO.java deleted file mode 100644 index 3b6b048a9c..0000000000 --- a/EmpServiceApp/src/com/baeldung/employee/dto/EmployeeDTO.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.employee.dto; - -public class EmployeeDTO { - - private long id; - private String name; - - // Standard constructors, getters and setters -} diff --git a/EmpServiceApp/src/com/baeldung/employee/service/EmployeeController.java b/EmpServiceApp/src/com/baeldung/employee/service/EmployeeController.java deleted file mode 100644 index b258d11018..0000000000 --- a/EmpServiceApp/src/com/baeldung/employee/service/EmployeeController.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.baeldung.employee.service; - -import java.net.URI; -import java.util.Map; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.servlet.support.ServletUriComponentsBuilder; - -import com.baeldung.employee.domain.Employee; - -@RestController -public class EmployeeController { - - @Autowired - private EmployeeService empService; - - @GetMapping(value = "/", produces = MediaType.TEXT_HTML_VALUE) - public String home() { - - return "This is employee app page"; - } - - @PostMapping(path = "/employees", consumes = "application/json", produces = "application/json") - public ResponseEntity addEmployee(@RequestBody Map empBody) { - - String id = empBody.get("id"); - String name = empBody.get("name"); - - Employee emp = new Employee(Integer.valueOf(id), name); - empService.addEmployee(emp); - - // Create resource uri - URI uri = ServletUriComponentsBuilder.fromCurrentRequest() - .buildAndExpand(emp.getId()) - .toUri(); - - // Send uri in response - return ResponseEntity.created(uri) - .build(); - } -} diff --git a/EmpServiceApp/src/com/baeldung/employee/service/EmployeeService.java b/EmpServiceApp/src/com/baeldung/employee/service/EmployeeService.java deleted file mode 100644 index 81c7665a50..0000000000 --- a/EmpServiceApp/src/com/baeldung/employee/service/EmployeeService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.baeldung.employee.service; - -import com.baeldung.employee.domain.Employee; - -public interface EmployeeService { - - void addEmployee(Employee emp); -} diff --git a/EmpServiceApp/src/com/baeldung/employee/service/EmployeeServiceImpl.java b/EmpServiceApp/src/com/baeldung/employee/service/EmployeeServiceImpl.java deleted file mode 100644 index 45aba2898b..0000000000 --- a/EmpServiceApp/src/com/baeldung/employee/service/EmployeeServiceImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.baeldung.employee.service; - -import org.modelmapper.ModelMapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.baeldung.employee.data.EmployeeDataAdapter; -import com.baeldung.employee.domain.Employee; -import com.baeldung.employee.dto.EmployeeDTO; - -@Service -public class EmployeeServiceImpl implements EmployeeService { - - @Autowired - private EmployeeDataAdapter employeeDataAdapter; - - @Autowired - private ModelMapper modelMapper; - - @Override - public void addEmployee(Employee emp) { - employeeDataAdapter.addEmployee(modelMapper.map(emp, EmployeeDTO.class)); - } - -} diff --git a/EmpServiceApp/src/createEmployeeTable.sql b/EmpServiceApp/src/createEmployeeTable.sql deleted file mode 100644 index 14b8347bff..0000000000 --- a/EmpServiceApp/src/createEmployeeTable.sql +++ /dev/null @@ -1,11 +0,0 @@ -DROP TABLE IF EXISTS EMPLOYEE; - -CREATE TABLE EMPLOYEE ( - - ID IDENTITY PRIMARY KEY, - NAME VARCHAR(64) NOT NULL, - -); - -INSERT INTO EMPLOYEE (ID, NAME) VALUES (10, 'EMP 10'); -INSERT INTO EMPLOYEE (ID, NAME) VALUES (20, 'EMP 20'); diff --git a/EmpServiceApp/web/WEB-INF/applicationContext.xml b/EmpServiceApp/web/WEB-INF/applicationContext.xml deleted file mode 100644 index 54b3429708..0000000000 --- a/EmpServiceApp/web/WEB-INF/applicationContext.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/EmpServiceApp/web/WEB-INF/web.xml b/EmpServiceApp/web/WEB-INF/web.xml deleted file mode 100644 index 7731773f82..0000000000 --- a/EmpServiceApp/web/WEB-INF/web.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - Employee Spring App - - - org.springframework.web.context.ContextLoaderListener - - - - EmployeeSpringApp - org.springframework.web.servlet.DispatcherServlet - - contextConfigLocation - /WEB-INF/applicationContext.xml - - 1 - - - EmployeeSpringApp - /* - - \ No newline at end of file From 2231a044ea3f24eafad7040ea9854f1cbbf2c87d Mon Sep 17 00:00:00 2001 From: Tyrell Flurry Date: Thu, 9 Apr 2020 16:52:54 -0400 Subject: [PATCH 141/503] BAEL-3929: modified java. --- .../src/main/java/com/baeldung/Main.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/Main.java b/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/Main.java index 8143c7d19f..abf6c7a03d 100644 --- a/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/Main.java +++ b/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/Main.java @@ -6,15 +6,13 @@ import java.util.Map; import org.slf4j.LoggerFactory; public class Main { - public static void main(String[] args) { - Map teamMap = new HashMap<>(); - teamMap.put("Dallas", "Cowboys"); - teamMap.put("Green Bay", "Packers"); - teamMap.put("Washington", "Redskins"); + Map map = new HashMap<>(); + map.put("Dallas", "Texas"); + map.put("Green Bay", "Wisconsin"); + map.put("Seattle", "Washington"); LoggerFactory.getLogger(Main.class) - .info("Team Map: {}", teamMap); - + .info("Map: {}", map); } } From 06a4e640bb6da563db64c2d2d949b2ddbf4c73cf Mon Sep 17 00:00:00 2001 From: Ali Dehghani Date: Fri, 10 Apr 2020 03:15:39 +0430 Subject: [PATCH 142/503] Fixed a few cassandra related issues --- persistence-modules/java-cassandra/pom.xml | 6 +++ .../src/test/resources/cassandra.yaml | 51 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 persistence-modules/java-cassandra/src/test/resources/cassandra.yaml diff --git a/persistence-modules/java-cassandra/pom.xml b/persistence-modules/java-cassandra/pom.xml index 54879fb321..091efaeff4 100644 --- a/persistence-modules/java-cassandra/pom.xml +++ b/persistence-modules/java-cassandra/pom.xml @@ -18,6 +18,12 @@ cassandra-driver-core ${cassandra-driver-core.version} true + + + com.google.guava + guava + + diff --git a/persistence-modules/java-cassandra/src/test/resources/cassandra.yaml b/persistence-modules/java-cassandra/src/test/resources/cassandra.yaml new file mode 100644 index 0000000000..59687444d0 --- /dev/null +++ b/persistence-modules/java-cassandra/src/test/resources/cassandra.yaml @@ -0,0 +1,51 @@ +cluster_name: 'Test Cluster' +hinted_handoff_enabled: true +max_hint_window_in_ms: 10800000 +hinted_handoff_throttle_in_kb: 1024 +max_hints_delivery_threads: 2 +hints_directory: target/embeddedCassandra/hints +authenticator: AllowAllAuthenticator +authorizer: AllowAllAuthorizer +permissions_validity_in_ms: 2000 +partitioner: RandomPartitioner +data_file_directories: + - target/embeddedCassandra/data +commitlog_directory: target/embeddedCassandra/commitlog +cdc_raw_directory: target/embeddedCassandra/cdc +disk_failure_policy: stop +key_cache_size_in_mb: +key_cache_save_period: 14400 +row_cache_size_in_mb: 0 +row_cache_save_period: 0 +saved_caches_directory: target/embeddedCassandra/saved_caches +commitlog_sync: periodic +commitlog_sync_period_in_ms: 10000 +commitlog_segment_size_in_mb: 32 +concurrent_reads: 32 +concurrent_writes: 32 +trickle_fsync: false +trickle_fsync_interval_in_kb: 10240 +thrift_framed_transport_size_in_mb: 15 +thrift_max_message_length_in_mb: 16 +incremental_backups: false +snapshot_before_compaction: false +auto_snapshot: false +column_index_size_in_kb: 64 +compaction_throughput_mb_per_sec: 16 +read_request_timeout_in_ms: 5000 +range_request_timeout_in_ms: 10000 +write_request_timeout_in_ms: 2000 +cas_contention_timeout_in_ms: 1000 +truncate_request_timeout_in_ms: 60000 +request_timeout_in_ms: 10000 +cross_node_timeout: false +endpoint_snitch: SimpleSnitch +dynamic_snitch_update_interval_in_ms: 100 +dynamic_snitch_reset_interval_in_ms: 600000 +dynamic_snitch_badness_threshold: 0.1 +request_scheduler: org.apache.cassandra.scheduler.NoScheduler +index_interval: 128 +seed_provider: + - class_name: org.apache.cassandra.locator.SimpleSeedProvider + parameters: + - seeds: "127.0.0.1" From 7e26a04973e631dcb6ea88cf0e9fbc7b2ad35a34 Mon Sep 17 00:00:00 2001 From: Kai Yuan Date: Fri, 10 Apr 2020 09:24:15 +0200 Subject: [PATCH 143/503] springboot shedlock building fix --- spring-boot-modules/spring-boot-libraries/pom.xml | 4 ++++ .../shedlock/SpringBootShedlockApplication.java} | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) rename spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/{Application.java => scheduling/shedlock/SpringBootShedlockApplication.java} (71%) diff --git a/spring-boot-modules/spring-boot-libraries/pom.xml b/spring-boot-modules/spring-boot-libraries/pom.xml index 2b1b1b7d12..090967d8a8 100644 --- a/spring-boot-modules/spring-boot-libraries/pom.xml +++ b/spring-boot-modules/spring-boot-libraries/pom.xml @@ -28,6 +28,10 @@ org.springframework.boot spring-boot-starter-tomcat + + org.springframework.boot + spring-boot-starter-data-jpa + org.springframework.boot spring-boot-starter-test diff --git a/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/Application.java b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/scheduling/shedlock/SpringBootShedlockApplication.java similarity index 71% rename from spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/Application.java rename to spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/scheduling/shedlock/SpringBootShedlockApplication.java index 15422e1065..cebb234036 100644 --- a/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/Application.java +++ b/spring-boot-modules/spring-boot-libraries/src/main/java/com/baeldung/scheduling/shedlock/SpringBootShedlockApplication.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.scheduling.shedlock; import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock; import org.springframework.boot.SpringApplication; @@ -8,8 +8,8 @@ import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication @EnableScheduling @EnableSchedulerLock(defaultLockAtMostFor = "PT30S") -public class Application { +public class SpringBootShedlockApplication { public static void main(String[] args) { - SpringApplication.run(Application.class, args); + SpringApplication.run(SpringBootShedlockApplication.class, args); } } From 52ca4fbcd9e8d1d42eafdb1b4b16326fa09eb404 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 15:29:38 +0800 Subject: [PATCH 144/503] Update README.md --- core-java-modules/core-java-date-operations-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-date-operations-2/README.md b/core-java-modules/core-java-date-operations-2/README.md index 728162ca1a..19c7b98d30 100644 --- a/core-java-modules/core-java-date-operations-2/README.md +++ b/core-java-modules/core-java-date-operations-2/README.md @@ -7,4 +7,5 @@ This module contains articles about date operations in Java. - [Checking If Two Java Dates Are on the Same Day](https://www.baeldung.com/java-check-two-dates-on-same-day) - [Converting Java Date to OffsetDateTime](https://www.baeldung.com/java-convert-date-to-offsetdatetime) - [How to Set the JVM Time Zone](https://www.baeldung.com/java-jvm-time-zone) +- [How to determine day of week by passing specific date in Java?](https://www.baeldung.com/java-get-day-of-week) - [[<-- Prev]](/core-java-modules/core-java-date-operations-1) From bf764f5f44da4adf16a24d08313c85fecf4a93c2 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 15:31:19 +0800 Subject: [PATCH 145/503] Update README.md --- spring-reactive-kotlin/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-reactive-kotlin/README.md b/spring-reactive-kotlin/README.md index 629f7e7f58..d6ce3b7645 100644 --- a/spring-reactive-kotlin/README.md +++ b/spring-reactive-kotlin/README.md @@ -4,3 +4,4 @@ This module contains articles about reactive Kotlin ### Relevant Articles: - [Spring Webflux with Kotlin](https://www.baeldung.com/spring-webflux-kotlin) +- [Kotlin Reactive Microservice With Spring Boot](https://www.baeldung.com/spring-boot-kotlin-reactive-microservice) From e1cf55dc822408210083eff3d52f6502d2c4060f Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 15:40:36 +0800 Subject: [PATCH 146/503] Update README.md --- core-java-modules/core-java-lang-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-lang-2/README.md b/core-java-modules/core-java-lang-2/README.md index 65d40c6a26..3ade982397 100644 --- a/core-java-modules/core-java-lang-2/README.md +++ b/core-java-modules/core-java-lang-2/README.md @@ -10,4 +10,5 @@ This module contains articles about core features in the Java language - [How to Return Multiple Values From a Java Method](https://www.baeldung.com/java-method-return-multiple-values) - [Guide to the Java finally Keyword](https://www.baeldung.com/java-finally-keyword) - [The Java Headless Mode](https://www.baeldung.com/java-headless-mode) +- [Comparing Long Values in Java](https://www.baeldung.com/java-compare-long-values) - [[<-- Prev]](/core-java-modules/core-java-lang) From 404f13f940d2f2d7143f5d6bcd9231c27f63059a Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 15:46:47 +0800 Subject: [PATCH 147/503] Update README.md --- spring-security-modules/spring-security-mvc/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-security-modules/spring-security-mvc/README.md b/spring-security-modules/spring-security-mvc/README.md index 7d1a492cd3..bb4cfe1a4f 100644 --- a/spring-security-modules/spring-security-mvc/README.md +++ b/spring-security-modules/spring-security-mvc/README.md @@ -10,6 +10,7 @@ The "Learn Spring Security" Classes: http://github.learnspringsecurity.com - [HttpSessionListener Example – Monitoring](https://www.baeldung.com/httpsessionlistener_with_metrics) - [Control the Session with Spring Security](https://www.baeldung.com/spring-security-session) +- [The Clear-Site-Data Header in Spring Security](https://www.baeldung.com/spring-security-clear-site-data-header) ### Build the Project From 721f339d8c32ba93f908e021a298e90666544ce5 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 15:50:44 +0800 Subject: [PATCH 148/503] Update README.md --- core-java-modules/core-java-strings/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-strings/README.md b/core-java-modules/core-java-strings/README.md index 4a418db29f..5daae8394a 100644 --- a/core-java-modules/core-java-strings/README.md +++ b/core-java-modules/core-java-strings/README.md @@ -12,3 +12,4 @@ This module contains articles about strings in Java. - [Java String Interview Questions and Answers](https://www.baeldung.com/java-string-interview-questions) - [Java Multi-line String](https://www.baeldung.com/java-multiline-string) - [Guide to Java String Pool](https://www.baeldung.com/java-string-pool) +- [Fixing “constant string too long” Build Error](https://www.baeldung.com/java-constant-string-too-long-error) From 086d6a9531a5f42f1284ed1809254d22226c688a Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 15:54:59 +0800 Subject: [PATCH 149/503] Update README.md --- persistence-modules/hibernate-jpa/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/hibernate-jpa/README.md b/persistence-modules/hibernate-jpa/README.md index d0a253f028..fb48f975bc 100644 --- a/persistence-modules/hibernate-jpa/README.md +++ b/persistence-modules/hibernate-jpa/README.md @@ -13,3 +13,4 @@ This module contains articles specific to use of Hibernate as a JPA implementati - [Enabling Transaction Locks in Spring Data JPA](https://www.baeldung.com/java-jpa-transaction-locks) - [TransactionRequiredException Error](https://www.baeldung.com/jpa-transaction-required-exception) - [JPA/Hibernate Persistence Context](https://www.baeldung.com/jpa-hibernate-persistence-context) +- [Quick Guide to EntityManager#getReference()](https://www.baeldung.com/jpa-entity-manager-get-reference) From f88c53eb4921eb6aac480f4524912e8ef5620f10 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 15:57:27 +0800 Subject: [PATCH 150/503] Update README.md --- core-java-modules/core-java-regex/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-regex/README.md b/core-java-modules/core-java-regex/README.md index 21cd7a95a3..6fdea9f2ca 100644 --- a/core-java-modules/core-java-regex/README.md +++ b/core-java-modules/core-java-regex/README.md @@ -9,3 +9,4 @@ - [Pre-compile Regex Patterns Into Pattern Objects](https://www.baeldung.com/java-regex-pre-compile) - [Difference Between Java Matcher find() and matches()](https://www.baeldung.com/java-matcher-find-vs-matches) - [How to Use Regular Expressions to Replace Tokens in Strings](https://www.baeldung.com/java-regex-token-replacement) +- [Regular Expressions \s and \s+ in Java](https://www.baeldung.com/java-regex-s-splus) From 012465bed2504d614c0c694e24c0f023492ba1dc Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:00:00 +0800 Subject: [PATCH 151/503] Create README.md --- persistence-modules/spring-persistence-simple-2/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 persistence-modules/spring-persistence-simple-2/README.md diff --git a/persistence-modules/spring-persistence-simple-2/README.md b/persistence-modules/spring-persistence-simple-2/README.md new file mode 100644 index 0000000000..a6408df8f2 --- /dev/null +++ b/persistence-modules/spring-persistence-simple-2/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Spring JdbcTemplate Unit Testing](https://www.baeldung.com/spring-jdbctemplate-testing) From 564e7fc0337630a6b7e53a49abbd018dabf3eb06 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:02:20 +0800 Subject: [PATCH 152/503] Create README.md --- algorithms-miscellaneous-6/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 algorithms-miscellaneous-6/README.md diff --git a/algorithms-miscellaneous-6/README.md b/algorithms-miscellaneous-6/README.md new file mode 100644 index 0000000000..d9d6483a39 --- /dev/null +++ b/algorithms-miscellaneous-6/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Boruvka’s Algorithm for Minimum Spanning Trees](https://www.baeldung.com/java-boruvka-algorithm) From 09b03f875416b14694b3491c46cbcf52e796bb91 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:05:30 +0800 Subject: [PATCH 153/503] Update README.md --- algorithms-miscellaneous-6/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/algorithms-miscellaneous-6/README.md b/algorithms-miscellaneous-6/README.md index d9d6483a39..99be63d7ca 100644 --- a/algorithms-miscellaneous-6/README.md +++ b/algorithms-miscellaneous-6/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Boruvka’s Algorithm for Minimum Spanning Trees](https://www.baeldung.com/java-boruvka-algorithm) +- [Gradient Descent in Java](https://www.baeldung.com/java-gradient-descent) From acdcb5cacab872b1ce9b907483efa67a67e9cc23 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:07:16 +0800 Subject: [PATCH 154/503] Update README.md --- core-java-modules/core-java-concurrency-basic-2/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core-java-modules/core-java-concurrency-basic-2/README.md b/core-java-modules/core-java-concurrency-basic-2/README.md index e3f7a94e14..c7143baf36 100644 --- a/core-java-modules/core-java-concurrency-basic-2/README.md +++ b/core-java-modules/core-java-concurrency-basic-2/README.md @@ -8,4 +8,5 @@ This module contains articles about basic Java concurrency - [Difference Between Wait and Sleep in Java](https://www.baeldung.com/java-wait-and-sleep) - [Guide to the Synchronized Keyword in Java](https://www.baeldung.com/java-synchronized) - [Life Cycle of a Thread in Java](https://www.baeldung.com/java-thread-lifecycle) -- [[<-- Prev]](/core-java-modules/core-java-concurrency-basic) \ No newline at end of file +- [Guide to AtomicMarkableReference](https://www.baeldung.com/java-atomicmarkablereference) +- [[<-- Prev]](/core-java-modules/core-java-concurrency-basic) From 88afc279cffb8c58ec7f0e5416a34d2efb5ca282 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:10:17 +0800 Subject: [PATCH 155/503] Update README.md --- core-java-modules/core-java-string-operations/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-string-operations/README.md b/core-java-modules/core-java-string-operations/README.md index 18a2649a6a..c40e56bc46 100644 --- a/core-java-modules/core-java-string-operations/README.md +++ b/core-java-modules/core-java-string-operations/README.md @@ -13,4 +13,5 @@ This module contains articles about string operations. - [Adding a Newline Character to a String in Java](https://www.baeldung.com/java-string-newline) - [Check If a String Contains a Substring](https://www.baeldung.com/java-string-contains-substring) - [Java Base64 Encoding and Decoding](https://www.baeldung.com/java-base64-encode-and-decode) +- [Java Convert PDF to Base64](https://www.baeldung.com/java-convert-pdf-to-base64) - More articles: [[next -->]](../core-java-string-operations-2) From c34f99f42aac0ea22d6afbbbf356568c1afaa24c Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:21:07 +0800 Subject: [PATCH 156/503] Update README.md --- libraries-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries-3/README.md b/libraries-3/README.md index 62bd3b9f66..ec433960ef 100644 --- a/libraries-3/README.md +++ b/libraries-3/README.md @@ -16,3 +16,4 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Introduction to Takes](https://www.baeldung.com/java-takes) - [Using NullAway to Avoid NullPointerExceptions](https://www.baeldung.com/java-nullaway) - [Introduction to Alibaba Arthas](https://www.baeldung.com/java-alibaba-arthas-intro) +- [Quick Guide to Spring Cloud Circuit Breaker](https://www.baeldung.com/spring-cloud-circuit-breaker) From 45abeb493b4d34a3b6502faa632d0bcd160cc3c7 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:22:40 +0800 Subject: [PATCH 157/503] Update README.md --- core-java-modules/core-java-concurrency-advanced-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-concurrency-advanced-3/README.md b/core-java-modules/core-java-concurrency-advanced-3/README.md index 2c554e948b..b11cde5158 100644 --- a/core-java-modules/core-java-concurrency-advanced-3/README.md +++ b/core-java-modules/core-java-concurrency-advanced-3/README.md @@ -10,4 +10,5 @@ This module contains articles about advanced topics about multithreading with co - [Guide to RejectedExecutionHandler](https://www.baeldung.com/java-rejectedexecutionhandler) - [Guide to Work Stealing in Java](https://www.baeldung.com/java-work-stealing) - [Asynchronous Programming in Java](https://www.baeldung.com/java-asynchronous-programming) +- [Java Thread Deadlock and Livelock](https://www.baeldung.com/java-deadlock-livelock) - [[<-- previous]](/core-java-modules/core-java-concurrency-advanced-2) From 76d15b81c505e8f82db8f70d786ee09c253622d6 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:25:53 +0800 Subject: [PATCH 158/503] Update README.md --- java-numbers-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/java-numbers-3/README.md b/java-numbers-3/README.md index 598acfb927..f818bdb675 100644 --- a/java-numbers-3/README.md +++ b/java-numbers-3/README.md @@ -10,4 +10,5 @@ This module contains articles about numbers in Java. - [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) +- [Guide to the Number Class in Java](https://www.baeldung.com/java-number-class) - More articles: [[<-- prev]](/java-numbers-2) From cb016c1027f8ec8b9bcea4c87f88fd2a5a622fa0 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:28:18 +0800 Subject: [PATCH 159/503] Update README.md --- core-java-modules/core-java-security-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-security-2/README.md b/core-java-modules/core-java-security-2/README.md index 2eb21fb77e..24a821bd4d 100644 --- a/core-java-modules/core-java-security-2/README.md +++ b/core-java-modules/core-java-security-2/README.md @@ -8,4 +8,5 @@ This module contains articles about core Java Security - [MD5 Hashing in Java](http://www.baeldung.com/java-md5) - [Hashing a Password in Java](https://www.baeldung.com/java-password-hashing) - [SHA-256 and SHA3-256 Hashing in Java](https://www.baeldung.com/sha-256-hashing-java) +- [Checksums in Java](https://www.baeldung.com/java-checksums) - More articles: [[<-- prev]](/core-java-modules/core-java-security) From 618916b6ab8753bf6d419031d21e9e1db934e8f1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:31:17 +0800 Subject: [PATCH 160/503] Update README.md --- guava-collections-map/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/guava-collections-map/README.md b/guava-collections-map/README.md index b3ec5e2157..4f8743dcfb 100644 --- a/guava-collections-map/README.md +++ b/guava-collections-map/README.md @@ -9,4 +9,5 @@ This module contains articles about map collections in Guava - [Guide to Guava Multimap](https://www.baeldung.com/guava-multimap) - [Guide to Guava RangeMap](https://www.baeldung.com/guava-rangemap) - [Initialize a HashMap in Java](https://www.baeldung.com/java-initialize-hashmap) -- [Guide to Guava ClassToInstanceMap](https://www.baeldung.com/guava-class-to-instance-map) \ No newline at end of file +- [Guide to Guava ClassToInstanceMap](https://www.baeldung.com/guava-class-to-instance-map) +- [Using Guava’s MapMaker](https://www.baeldung.com/guava-mapmaker) From 2b27994c13acca8ad0af453eb05c6e82749e6543 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:35:28 +0800 Subject: [PATCH 161/503] Update README.md --- spring-batch/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-batch/README.md b/spring-batch/README.md index d637de269c..3a89459629 100644 --- a/spring-batch/README.md +++ b/spring-batch/README.md @@ -3,6 +3,7 @@ This module contains articles about Spring Batch ### Relevant Articles: + - [Introduction to Spring Batch](https://www.baeldung.com/introduction-to-spring-batch) - [Spring Batch using Partitioner](https://www.baeldung.com/spring-batch-partitioner) - [Spring Batch – Tasklets vs Chunks](https://www.baeldung.com/spring-batch-tasklet-chunk) @@ -10,3 +11,4 @@ This module contains articles about Spring Batch - [Configuring Skip Logic in Spring Batch](https://www.baeldung.com/spring-batch-skip-logic) - [Testing a Spring Batch Job](https://www.baeldung.com/spring-batch-testing-job) - [Configuring Retry Logic in Spring Batch](https://www.baeldung.com/spring-batch-retry-logic) +- [Conditional Flow in Spring Batch](https://www.baeldung.com/spring-batch-conditional-flow) From 44f3912f83a0aa0f7aa4dcdec5a0496d020e7bfa Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:38:35 +0800 Subject: [PATCH 162/503] Update README.md --- core-kotlin-modules/core-kotlin-collections/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-kotlin-modules/core-kotlin-collections/README.md b/core-kotlin-modules/core-kotlin-collections/README.md index bbea5869af..f0da2b4cfd 100644 --- a/core-kotlin-modules/core-kotlin-collections/README.md +++ b/core-kotlin-modules/core-kotlin-collections/README.md @@ -8,3 +8,4 @@ This module contains articles about core Kotlin collections. - [Overview of Kotlin Collections API](https://www.baeldung.com/kotlin-collections-api) - [Converting a List to Map in Kotlin](https://www.baeldung.com/kotlin-list-to-map) - [Filtering Kotlin Collections](https://www.baeldung.com/kotlin-filter-collection) +- [Collection Transformations in Kotlin](https://www.baeldung.com/kotlin-collection-transformations) From fba81f5e629ca568d197622b6d32dbe1c653de15 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:40:10 +0800 Subject: [PATCH 163/503] Update README.md --- guava/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guava/README.md b/guava/README.md index c67a3604ea..71f76c1360 100644 --- a/guava/README.md +++ b/guava/README.md @@ -12,4 +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) From a70207b99317ff43992f9704b1832de960132d79 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:42:37 +0800 Subject: [PATCH 164/503] Update README.md --- core-java-modules/core-java-14/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-14/README.md b/core-java-modules/core-java-14/README.md index 0e8278c4f6..13bb468b30 100644 --- a/core-java-modules/core-java-14/README.md +++ b/core-java-modules/core-java-14/README.md @@ -7,3 +7,4 @@ This module contains articles about Java 14. - [Guide to the @Serial Annotation in Java 14](https://www.baeldung.com/java-14-serial-annotation) - [Java Text Blocks](https://www.baeldung.com/java-text-blocks) - [Pattern Matching for instanceof in Java 14](https://www.baeldung.com/java-pattern-matching-instanceof) +- [Helpful NullPointerExceptions in Java 14](https://www.baeldung.com/java-14-nullpointerexception) From 28401da21a1410bd54c2c4be125d68ffc529f933 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:44:41 +0800 Subject: [PATCH 165/503] Create README.md --- libraries-concurrency/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 libraries-concurrency/README.md diff --git a/libraries-concurrency/README.md b/libraries-concurrency/README.md new file mode 100644 index 0000000000..d1ffe81fa8 --- /dev/null +++ b/libraries-concurrency/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Intro to Coroutines with Quasar](https://www.baeldung.com/java-quasar-coroutines) From a1b1870921120ac90c7b68fa3a19004f564b801a Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:46:53 +0800 Subject: [PATCH 166/503] Update README.md --- core-java-modules/core-java-streams-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-streams-3/README.md b/core-java-modules/core-java-streams-3/README.md index a739245399..05c4b99900 100644 --- a/core-java-modules/core-java-streams-3/README.md +++ b/core-java-modules/core-java-streams-3/README.md @@ -9,4 +9,5 @@ This module contains articles about the Stream API in Java. - [Guide to Java 8’s Collectors](https://www.baeldung.com/java-8-collectors) - [Primitive Type Streams in Java 8](https://www.baeldung.com/java-8-primitive-streams) - [Debugging Java 8 Streams with IntelliJ](https://www.baeldung.com/intellij-debugging-java-streams) +- [Add BigDecimals using the Stream API](https://www.baeldung.com/java-stream-add-bigdecimals) - More articles: [[<-- prev>]](/../core-java-streams-2) From 8e1787ffeacc858d72180a8d0919650feb796e2e Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:48:28 +0800 Subject: [PATCH 167/503] Update README.md --- spring-5-mvc/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-5-mvc/README.md b/spring-5-mvc/README.md index e98012c047..aff8bb227c 100644 --- a/spring-5-mvc/README.md +++ b/spring-5-mvc/README.md @@ -6,3 +6,4 @@ This module contains articles about Spring 5 model-view-controller (MVC) pattern - [Spring Boot and Kotlin](https://www.baeldung.com/spring-boot-kotlin) - [Spring MVC Streaming and SSE Request Processing](https://www.baeldung.com/spring-mvc-sse-streams) - [Interface Driven Controllers in Spring](https://www.baeldung.com/spring-interface-driven-controllers) +- [Returning Plain HTML From a Spring MVC Controller](https://www.baeldung.com/spring-mvc-return-html) From 08472ff2e9e2dc28f7d7975a9d01a81d2e330742 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:50:04 +0800 Subject: [PATCH 168/503] Update README.md --- spring-thymeleaf-3/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-thymeleaf-3/README.md b/spring-thymeleaf-3/README.md index e1ddd727d7..a8e234b067 100644 --- a/spring-thymeleaf-3/README.md +++ b/spring-thymeleaf-3/README.md @@ -2,4 +2,5 @@ This module contains articles about Spring with Thymeleaf -## Relevant Articles: \ No newline at end of file +## Relevant Articles: +- [Add CSS and JS to Thymeleaf](https://www.baeldung.com/spring-thymeleaf-css-js) From fd1b953c2760173a9679638862a3ad79216a7e50 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Fri, 10 Apr 2020 16:51:50 +0800 Subject: [PATCH 169/503] Update README.md --- spring-core-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-core-3/README.md b/spring-core-3/README.md index b2c4f694a8..6c210b23ef 100644 --- a/spring-core-3/README.md +++ b/spring-core-3/README.md @@ -10,4 +10,5 @@ This module contains articles about core Spring functionality - [Spring – Injecting Collections](https://www.baeldung.com/spring-injecting-collections) - [Design Patterns in the Spring Framework](https://www.baeldung.com/spring-framework-design-patterns) - [Injecting a Value in a Static Field in Spring](https://www.baeldung.com/spring-inject-static-field) +- [Difference Between BeanFactory and ApplicationContext](https://www.baeldung.com/spring-beanfactory-vs-applicationcontext) - More articles: [[<-- prev]](/spring-core-2) From 76cdbd811ebe8ad93758b22807b8ff4b331a50c5 Mon Sep 17 00:00:00 2001 From: patkorek Date: Fri, 10 Apr 2020 12:49:52 +0200 Subject: [PATCH 170/503] Modified one method --- .../com/baeldung/strings/ConvertStringToInt.groovy | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy b/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy index 3b179ee193..3b73c31596 100644 --- a/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy +++ b/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy @@ -62,10 +62,17 @@ class ConvertStringToInt { def stringNum = "123" int expectedInt = 123 int intNum = new Integer(stringNum).intValue() - int secondIntNum = new Integer(stringNum) assertEquals(intNum, expectedInt) - assertEquals(secondIntNum, expectedInt) + } + + @Test + void givenString_whenUsingNewInteger_thenConvertToInteger() { + def stringNum = "123" + int expectedInt = 123 + int intNum = new Integer(stringNum) + + assertEquals(intNum, expectedInt) } @Test From 949881921e6513972cc7143517c94b85b81f5644 Mon Sep 17 00:00:00 2001 From: patkorek Date: Fri, 10 Apr 2020 13:27:27 +0200 Subject: [PATCH 171/503] Added test case with isInteger() method. --- .../com/baeldung/strings/ConvertStringToInt.groovy | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy b/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy index 3b73c31596..7a4be4a957 100644 --- a/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy +++ b/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy @@ -96,4 +96,15 @@ class ConvertStringToInt { def invalidString = null invalidString.toInteger() } + + @Test + void givenString_whenUsingIsInteger_thenCheckIfCorrectValue() { + def invalidString = "123a" + def validString = "123" + def invalidNum = invalidString?.isInteger() ? invalidString as Integer : false + def correctNum = validString?.isInteger() ? validString as Integer : false + + assertEquals(false, invalidNum) + assertEquals(123, correctNum) + } } From 5a1f7ffea8d617a80d38234bb0f097de49747aed Mon Sep 17 00:00:00 2001 From: gindex Date: Fri, 10 Apr 2020 13:36:51 +0200 Subject: [PATCH 172/503] Add blockingHelloWorld() --- .../java/com/baeldung/mono/MonoUnitTest.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/reactor-core/src/test/java/com/baeldung/mono/MonoUnitTest.java b/reactor-core/src/test/java/com/baeldung/mono/MonoUnitTest.java index b493cd1159..f9e67b0a2f 100644 --- a/reactor-core/src/test/java/com/baeldung/mono/MonoUnitTest.java +++ b/reactor-core/src/test/java/com/baeldung/mono/MonoUnitTest.java @@ -12,13 +12,13 @@ import static org.junit.Assert.assertEquals; public class MonoUnitTest { @Test public void whenMonoProducesString_thenBlockAndConsume() { - String expected = "hello world!"; - String result1 = Mono.just(expected).block(); - assertEquals(expected, result1); + String result1 = blockingHelloWorld().block(); + assertEquals("Hello world!", result1); - String result2 = Mono.just(expected).block(Duration.of(1000, ChronoUnit.MILLIS)); - assertEquals(expected, result2); + String result2 = blockingHelloWorld() + .block(Duration.of(1000, ChronoUnit.MILLIS)); + assertEquals("Hello world!", result2); Optional result3 = Mono.empty().blockOptional(); assertEquals(Optional.empty(), result3); @@ -26,14 +26,18 @@ public class MonoUnitTest { @Test public void whenMonoProducesString_thenConsumeNonBlocking() { - String expected = "hello world!"; - Mono.just(expected) - .doOnNext(result -> assertEquals(expected, result)) + blockingHelloWorld() + .doOnNext(result -> assertEquals("Hello world!", result)) .subscribe(); - Mono.just(expected) - .subscribe(result -> assertEquals(expected, result)); + blockingHelloWorld() + .subscribe(result -> assertEquals("Hello world!", result)); } + + private Mono blockingHelloWorld() { + // blocking + return Mono.just("Hello world!"); + } } From c1b13d09314f92424cddca0c00171fc4ad87e139 Mon Sep 17 00:00:00 2001 From: Kirill Vlasov Date: Fri, 10 Apr 2020 20:21:01 +0500 Subject: [PATCH 173/503] BAEL-3969 Spring Security - Custom Logout Handler --- .../LogoutDemoApplication.java | 13 +++ .../customlogouthandler/MvcConfiguration.java | 51 +++++++++ .../services/UserCache.java | 33 ++++++ .../customlogouthandler/user/User.java | 61 ++++++++++ .../customlogouthandler/user/UserUtils.java | 13 +++ .../web/CustomLogoutHandler.java | 27 +++++ .../web/UserController.java | 30 +++++ ...application-customlogouthandler.properties | 5 + .../CustomLogoutHandlerIntegrationTest.java | 106 ++++++++++++++++++ .../resources/customlogouthandler/after.sql | 1 + .../application.properties | 5 + .../resources/customlogouthandler/before.sql | 1 + 12 files changed, 346 insertions(+) create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/LogoutDemoApplication.java create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/MvcConfiguration.java create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/services/UserCache.java create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/User.java create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/UserUtils.java create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/CustomLogoutHandler.java create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/UserController.java create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/main/resources/application-customlogouthandler.properties create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/customlogouthandler/CustomLogoutHandlerIntegrationTest.java create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/after.sql create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/application.properties create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/before.sql diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/LogoutDemoApplication.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/LogoutDemoApplication.java new file mode 100644 index 0000000000..027334dd6b --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/LogoutDemoApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.customlogouthandler; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class LogoutDemoApplication { + + public static void main(String[] args) { + SpringApplication.run(LogoutDemoApplication.class, args); + } + +} diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/MvcConfiguration.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/MvcConfiguration.java new file mode 100644 index 0000000000..36de049a31 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/MvcConfiguration.java @@ -0,0 +1,51 @@ +package com.baeldung.customlogouthandler; + +import com.baeldung.customlogouthandler.web.CustomLogoutHandler; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +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.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler; + +import javax.sql.DataSource; + +@Configuration +@EnableWebSecurity +public class MvcConfiguration extends WebSecurityConfigurerAdapter { + + @Autowired + private DataSource dataSource; + + @Autowired + private CustomLogoutHandler logoutHandler; + + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .httpBasic().and() + .authorizeRequests() + .antMatchers(HttpMethod.GET, "/user/**").hasRole("USER") + .and() + .logout() + .logoutUrl("/user/logout") + .addLogoutHandler(logoutHandler) + .logoutSuccessHandler((new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK))) + .permitAll() + .and() + .csrf().disable() + .formLogin().disable(); + } + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + auth.jdbcAuthentication() + .dataSource(dataSource) + .usersByUsernameQuery("select login, password, true from users where login=?") + .authoritiesByUsernameQuery("select login, role from users where login=?"); + } + +} diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/services/UserCache.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/services/UserCache.java new file mode 100644 index 0000000000..56c4d1e7c9 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/services/UserCache.java @@ -0,0 +1,33 @@ +package com.baeldung.customlogouthandler.services; + +import com.baeldung.customlogouthandler.user.User; +import org.springframework.stereotype.Service; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +@Service +public class UserCache { + + @PersistenceContext + private EntityManager entityManager; + + private final ConcurrentMap store = new ConcurrentHashMap<>(256); + + public User getByLogin(String login) { + return store.computeIfAbsent(login, k -> entityManager.createQuery("from User where login=:login", User.class) + .setParameter("login", k) + .getSingleResult()); + } + + public void evictUser(String login) { + store.remove(login); + } + + public int size() { + return this.store.size(); + } + +} diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/User.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/User.java new file mode 100644 index 0000000000..ca3a998c5c --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/User.java @@ -0,0 +1,61 @@ +package com.baeldung.customlogouthandler.user; + +import javax.persistence.*; + +@Entity +@Table(name = "users") +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @Column(unique = true) + private String login; + + private String password; + + private String role; + + private String language; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getLogin() { + return login; + } + + public void setLogin(String login) { + this.login = login; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } +} diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/UserUtils.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/UserUtils.java new file mode 100644 index 0000000000..195497f7ba --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/UserUtils.java @@ -0,0 +1,13 @@ +package com.baeldung.customlogouthandler.user; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; + +public class UserUtils { + + public static String getAuthenticatedUserLogin() { + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + return auth != null ? ((org.springframework.security.core.userdetails.User) auth.getPrincipal()).getUsername() : null; + } + +} diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/CustomLogoutHandler.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/CustomLogoutHandler.java new file mode 100644 index 0000000000..2a335cd122 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/CustomLogoutHandler.java @@ -0,0 +1,27 @@ +package com.baeldung.customlogouthandler.web; + +import com.baeldung.customlogouthandler.services.UserCache; +import com.baeldung.customlogouthandler.user.UserUtils; +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.logout.LogoutHandler; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@Service +public class CustomLogoutHandler implements LogoutHandler { + + private final UserCache userCache; + + public CustomLogoutHandler(UserCache userCache) { + this.userCache = userCache; + } + + @Override + public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { + String login = UserUtils.getAuthenticatedUserLogin(); + userCache.evictUser(login); + } + +} diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/UserController.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/UserController.java new file mode 100644 index 0000000000..18cd8dda98 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/UserController.java @@ -0,0 +1,30 @@ +package com.baeldung.customlogouthandler.web; + +import com.baeldung.customlogouthandler.services.UserCache; +import com.baeldung.customlogouthandler.user.User; +import com.baeldung.customlogouthandler.user.UserUtils; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + + +@Controller +@RequestMapping(path = "/user") +public class UserController { + + private final UserCache userCache; + + public UserController(UserCache userCache) { + this.userCache = userCache; + } + + @GetMapping(path = "/language") + @ResponseBody + public String getLanguage() { + String login = UserUtils.getAuthenticatedUserLogin(); + User user = userCache.getByLogin(login); + return user.getLanguage(); + } + +} diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/application-customlogouthandler.properties b/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/application-customlogouthandler.properties new file mode 100644 index 0000000000..2cb766378d --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/application-customlogouthandler.properties @@ -0,0 +1,5 @@ +spring.datasource.url=jdbc:postgresql://localhost:5432/test +spring.datasource.username=test +spring.datasource.password=test + +spring.jpa.hibernate.ddl-auto=create \ No newline at end of file diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/customlogouthandler/CustomLogoutHandlerIntegrationTest.java b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/customlogouthandler/CustomLogoutHandlerIntegrationTest.java new file mode 100644 index 0000000000..3c325a2006 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/customlogouthandler/CustomLogoutHandlerIntegrationTest.java @@ -0,0 +1,106 @@ +package com.baeldung.customlogouthandler; + +import com.baeldung.customlogouthandler.services.UserCache; +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.jdbc.Sql; +import org.springframework.test.context.jdbc.SqlGroup; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringJUnit4ClassRunner.class) +@SpringBootTest(classes = {LogoutDemoApplication.class, MvcConfiguration.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SqlGroup({ + @Sql(value = "classpath:customlogouthandler/before.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD), + @Sql(value = "classpath:customlogouthandler/after.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) +}) +class CustomLogoutHandlerIntegrationTest { + + @Autowired + private TestRestTemplate restTemplate; + + @Autowired + private UserCache userCache; + + @LocalServerPort + private int port; + + @Test + public void whenLogin_thenUseUserCache() throws Exception { + // User cache should be empty on start + assertThat(userCache.size()).isEqualTo(0); + + // Request using first login + ResponseEntity response = restTemplate + .withBasicAuth("user", "pass") + .getForEntity(getLanguageUrl(), String.class); + + assertThat(response.getBody()).contains("english"); + + // User cache must contain the user + assertThat(userCache.size()).isEqualTo(1); + + // Getting the session cookie + HttpHeaders requestHeaders = new HttpHeaders(); + requestHeaders.add("Cookie", response.getHeaders().getFirst(HttpHeaders.SET_COOKIE)); + + // Request with the session cookie + response = restTemplate + .exchange(getLanguageUrl(), HttpMethod.GET, new HttpEntity(requestHeaders), String.class); + assertThat(response.getBody()).contains("english"); + + // Logging out using the session cookies + response = restTemplate.exchange(getLogoutUrl(), HttpMethod.GET, new HttpEntity(requestHeaders), String.class); + assertThat(response.getStatusCode().value()).isEqualTo(200); + } + + @Test + public void whenLogout_thenCacheIsEmpty() throws Exception { + // User cache should be empty on start + assertThat(userCache.size()).isEqualTo(0); + + // Request using first login + ResponseEntity response = restTemplate + .withBasicAuth("user", "pass") + .getForEntity(getLanguageUrl(), String.class); + + assertThat(response.getBody()).contains("english"); + + // User cache must contain the user + assertThat(userCache.size()).isEqualTo(1); + + // Getting the session cookie + HttpHeaders requestHeaders = new HttpHeaders(); + requestHeaders.add("Cookie", response.getHeaders().getFirst(HttpHeaders.SET_COOKIE)); + + // Logging out using the session cookies + response = restTemplate.exchange(getLogoutUrl(), HttpMethod.GET, new HttpEntity(requestHeaders), String.class); + assertThat(response.getStatusCode().value()).isEqualTo(200); + + // User cache must be empty now + // this is the reaction on custom logout filter execution + assertThat(userCache.size()).isEqualTo(0); + + // Assert unathorized request + response = restTemplate.exchange(getLanguageUrl(), HttpMethod.GET, new HttpEntity(requestHeaders), String.class); + assertThat(response.getStatusCode().value()).isEqualTo(401); + } + + private String getLanguageUrl() { + return "http://localhost:" + port + "/user/language"; + } + + private String getLogoutUrl() { + return "http://localhost:" + port + "/user/logout"; + } + +} diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/after.sql b/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/after.sql new file mode 100644 index 0000000000..df6f312987 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/after.sql @@ -0,0 +1 @@ +delete from users; \ No newline at end of file diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/application.properties b/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/application.properties new file mode 100644 index 0000000000..8b6d47ebe9 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/application.properties @@ -0,0 +1,5 @@ +spring.datasource.url=jdbc:postgresql://localhost:5432/develop +spring.datasource.username=develop +spring.datasource.password=develop + +spring.jpa.hibernate.ddl-auto=create diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/before.sql b/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/before.sql new file mode 100644 index 0000000000..bb0a85f613 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/before.sql @@ -0,0 +1 @@ +insert into users (login, password, role, language) values ('user', '{noop}pass', 'ROLE_USER', 'english'); \ No newline at end of file From 82e69447a54a650c59953fed9b0fab312fe552e6 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Fri, 10 Apr 2020 21:58:48 +0200 Subject: [PATCH 174/503] BAEL-3730: Add example of usage CacheManagerCustomizer in Spring Boot (#9048) --- spring-caching/pom.xml | 4 ++++ .../caching/boot/CacheApplication.java | 14 +++++++++++ .../caching/boot/SimpleCacheCustomizer.java | 24 +++++++++++++++++++ .../SimpleCacheCustomizerIntegrationTest.java | 24 +++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 spring-caching/src/main/java/com/baeldung/caching/boot/CacheApplication.java create mode 100644 spring-caching/src/main/java/com/baeldung/caching/boot/SimpleCacheCustomizer.java create mode 100644 spring-caching/src/test/java/com/baeldung/caching/boot/SimpleCacheCustomizerIntegrationTest.java diff --git a/spring-caching/pom.xml b/spring-caching/pom.xml index c3ededbd14..d33f24de1f 100644 --- a/spring-caching/pom.xml +++ b/spring-caching/pom.xml @@ -19,6 +19,10 @@ org.springframework spring-context + + org.springframework.boot + spring-boot-starter-cache + org.springframework spring-web diff --git a/spring-caching/src/main/java/com/baeldung/caching/boot/CacheApplication.java b/spring-caching/src/main/java/com/baeldung/caching/boot/CacheApplication.java new file mode 100644 index 0000000000..714dc443e0 --- /dev/null +++ b/spring-caching/src/main/java/com/baeldung/caching/boot/CacheApplication.java @@ -0,0 +1,14 @@ +package com.baeldung.caching.boot; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cache.annotation.EnableCaching; + +@SpringBootApplication +@EnableCaching +public class CacheApplication { + + public static void main(String[] args) { + SpringApplication.run(CacheApplication.class, args); + } +} diff --git a/spring-caching/src/main/java/com/baeldung/caching/boot/SimpleCacheCustomizer.java b/spring-caching/src/main/java/com/baeldung/caching/boot/SimpleCacheCustomizer.java new file mode 100644 index 0000000000..a76a01caae --- /dev/null +++ b/spring-caching/src/main/java/com/baeldung/caching/boot/SimpleCacheCustomizer.java @@ -0,0 +1,24 @@ +package com.baeldung.caching.boot; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.autoconfigure.cache.CacheManagerCustomizer; +import org.springframework.cache.concurrent.ConcurrentMapCacheManager; +import org.springframework.stereotype.Component; + +import static java.util.Arrays.asList; + +@Component +public class SimpleCacheCustomizer implements CacheManagerCustomizer { + + private static final Logger LOGGER = LoggerFactory.getLogger(SimpleCacheCustomizer.class); + + static final String USERS_CACHE = "users"; + static final String TRANSACTIONS_CACHE = "transactions"; + + @Override + public void customize(ConcurrentMapCacheManager cacheManager) { + LOGGER.info("Customizing Cache Manager"); + cacheManager.setCacheNames(asList(USERS_CACHE, TRANSACTIONS_CACHE)); + } +} diff --git a/spring-caching/src/test/java/com/baeldung/caching/boot/SimpleCacheCustomizerIntegrationTest.java b/spring-caching/src/test/java/com/baeldung/caching/boot/SimpleCacheCustomizerIntegrationTest.java new file mode 100644 index 0000000000..56a4bd4745 --- /dev/null +++ b/spring-caching/src/test/java/com/baeldung/caching/boot/SimpleCacheCustomizerIntegrationTest.java @@ -0,0 +1,24 @@ +package com.baeldung.caching.boot; + +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.cache.CacheManager; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class SimpleCacheCustomizerIntegrationTest { + + @Autowired + private CacheManager cacheManager; + + @Test + public void givenCacheManagerCustomizerWhenBootstrappedThenCacheManagerCustomized() { + assertThat(cacheManager.getCacheNames()) + .containsOnly(SimpleCacheCustomizer.USERS_CACHE, SimpleCacheCustomizer.TRANSACTIONS_CACHE); + } +} \ No newline at end of file From a6e5f78a488bbad61cf592185e9b1981cdd3140d Mon Sep 17 00:00:00 2001 From: mikr Date: Fri, 10 Apr 2020 23:59:34 +0200 Subject: [PATCH 175/503] JAVA-1225 Add dependency to Hibernate Code --- spring-boot-modules/spring-boot-springdoc/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spring-boot-modules/spring-boot-springdoc/pom.xml b/spring-boot-modules/spring-boot-springdoc/pom.xml index c99a9c2b24..375cf06c2c 100644 --- a/spring-boot-modules/spring-boot-springdoc/pom.xml +++ b/spring-boot-modules/spring-boot-springdoc/pom.xml @@ -37,6 +37,12 @@ test + + org.hibernate + hibernate-core + ${hibernate.version} + + org.springdoc @@ -61,6 +67,7 @@ 1.8 + 5.2.10.Final 1.2.32 From f154a172398ed6d3b8aa5cda91ad5d3cad08cde6 Mon Sep 17 00:00:00 2001 From: "ramprasad.devarakonda@gmail.com" Date: Tue, 24 Mar 2020 00:55:23 +0000 Subject: [PATCH 176/503] BAEL-3769 | Writing templates for test cases using JUnit 5 --- testing-modules/junit5-annotations/pom.xml | 9 +- .../junit5/templates/UserIdGenerator.java | 5 ++ .../junit5/templates/UserIdGeneratorImpl.java | 15 ++++ .../DisabledOnQAEnvironmentExtension.java | 27 ++++++ .../GenericTypedParameterResolver.java | 26 ++++++ .../UserIdGeneratorImplUnitTest.java | 18 ++++ .../templates/UserIdGeneratorTestCase.java | 37 ++++++++ ...eneratorTestInvocationContextProvider.java | 87 +++++++++++++++++++ .../src/test/resources/application.properties | 1 + 9 files changed, 224 insertions(+), 1 deletion(-) create mode 100644 testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/templates/UserIdGenerator.java create mode 100644 testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/templates/UserIdGeneratorImpl.java create mode 100644 testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/DisabledOnQAEnvironmentExtension.java create mode 100644 testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/GenericTypedParameterResolver.java create mode 100644 testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/UserIdGeneratorImplUnitTest.java create mode 100644 testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/UserIdGeneratorTestCase.java create mode 100644 testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/UserIdGeneratorTestInvocationContextProvider.java create mode 100644 testing-modules/junit5-annotations/src/test/resources/application.properties diff --git a/testing-modules/junit5-annotations/pom.xml b/testing-modules/junit5-annotations/pom.xml index d0fba4d21b..9e51d0ab55 100644 --- a/testing-modules/junit5-annotations/pom.xml +++ b/testing-modules/junit5-annotations/pom.xml @@ -46,12 +46,19 @@ ${junit.platform.version} test + + org.assertj + assertj-core + ${assertj-core.version} + test + - 5.6.0 + 5.6.2 1.6.0 2.8.2 + 3.11.1 diff --git a/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/templates/UserIdGenerator.java b/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/templates/UserIdGenerator.java new file mode 100644 index 0000000000..f19adb13c8 --- /dev/null +++ b/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/templates/UserIdGenerator.java @@ -0,0 +1,5 @@ +package com.baeldung.junit5.templates; + +public interface UserIdGenerator { + String generate(String firstName, String lastName); +} diff --git a/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/templates/UserIdGeneratorImpl.java b/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/templates/UserIdGeneratorImpl.java new file mode 100644 index 0000000000..b39b07bc4b --- /dev/null +++ b/testing-modules/junit5-annotations/src/main/java/com/baeldung/junit5/templates/UserIdGeneratorImpl.java @@ -0,0 +1,15 @@ +package com.baeldung.junit5.templates; + +public class UserIdGeneratorImpl implements UserIdGenerator { + private boolean isFeatureEnabled; + + public UserIdGeneratorImpl(boolean isFeatureEnabled) { + this.isFeatureEnabled = isFeatureEnabled; + } + + public String generate(String firstName, String lastName) { + String initialAndLastName = firstName.substring(0, 1) + .concat(lastName); + return isFeatureEnabled ? "bael".concat(initialAndLastName) : initialAndLastName; + } +} diff --git a/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/DisabledOnQAEnvironmentExtension.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/DisabledOnQAEnvironmentExtension.java new file mode 100644 index 0000000000..cd8b7b677d --- /dev/null +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/DisabledOnQAEnvironmentExtension.java @@ -0,0 +1,27 @@ +package com.baeldung.junit5.templates; + +import org.junit.jupiter.api.extension.ConditionEvaluationResult; +import org.junit.jupiter.api.extension.ExecutionCondition; +import org.junit.jupiter.api.extension.ExtensionContext; + +import java.io.IOException; +import java.util.Properties; + +public class DisabledOnQAEnvironmentExtension implements ExecutionCondition { + @Override + public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { + Properties properties = new Properties(); + try { + properties.load(DisabledOnQAEnvironmentExtension.class.getClassLoader() + .getResourceAsStream("application.properties")); + if ("qa".equalsIgnoreCase(properties.getProperty("env"))) { + String reason = String.format("The test '%s' is disabled on QA environment", context.getDisplayName()); + System.out.println(reason); + return ConditionEvaluationResult.disabled(reason); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + return ConditionEvaluationResult.enabled("Test enabled"); + } +} \ No newline at end of file diff --git a/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/GenericTypedParameterResolver.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/GenericTypedParameterResolver.java new file mode 100644 index 0000000000..76321be101 --- /dev/null +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/GenericTypedParameterResolver.java @@ -0,0 +1,26 @@ +package com.baeldung.junit5.templates; + +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.ParameterContext; +import org.junit.jupiter.api.extension.ParameterResolutionException; +import org.junit.jupiter.api.extension.ParameterResolver; + +public class GenericTypedParameterResolver implements ParameterResolver { + T data; + + public GenericTypedParameterResolver(T data) { + this.data = data; + } + + @Override + public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { + return parameterContext.getParameter() + .getType() + .isInstance(data); + } + + @Override + public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { + return data; + } +} diff --git a/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/UserIdGeneratorImplUnitTest.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/UserIdGeneratorImplUnitTest.java new file mode 100644 index 0000000000..a2306154a6 --- /dev/null +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/UserIdGeneratorImplUnitTest.java @@ -0,0 +1,18 @@ +package com.baeldung.junit5.templates; + +import org.junit.jupiter.api.TestTemplate; +import org.junit.jupiter.api.extension.ExtendWith; + +import static org.assertj.core.api.Assertions.assertThat; + +public class UserIdGeneratorImplUnitTest { + @TestTemplate + @ExtendWith(UserIdGeneratorTestInvocationContextProvider.class) + public void whenUserIdRequested_thenUserIdIsReturnedInCorrectFormat(UserIdGeneratorTestCase testCase) { + UserIdGenerator userIdGenerator = new UserIdGeneratorImpl(testCase.isFeatureEnabled()); + + String actualUserId = userIdGenerator.generate(testCase.getFirstName(), testCase.getLastName()); + + assertThat(actualUserId).isEqualTo(testCase.getExpectedUserId()); + } +} \ No newline at end of file diff --git a/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/UserIdGeneratorTestCase.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/UserIdGeneratorTestCase.java new file mode 100644 index 0000000000..dd41dd5a27 --- /dev/null +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/UserIdGeneratorTestCase.java @@ -0,0 +1,37 @@ +package com.baeldung.junit5.templates; + +public class UserIdGeneratorTestCase { + private String displayName; + private boolean isFeatureEnabled; + private String firstName; + private String lastName; + private String expectedUserId; + + public UserIdGeneratorTestCase(String displayName, boolean isFeatureEnabled, String firstName, String lastName, String expectedUserId) { + this.displayName = displayName; + this.isFeatureEnabled = isFeatureEnabled; + this.firstName = firstName; + this.lastName = lastName; + this.expectedUserId = expectedUserId; + } + + public String getDisplayName() { + return displayName; + } + + public boolean isFeatureEnabled() { + return isFeatureEnabled; + } + + public String getFirstName() { + return firstName; + } + + public String getLastName() { + return lastName; + } + + public String getExpectedUserId() { + return expectedUserId; + } +} diff --git a/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/UserIdGeneratorTestInvocationContextProvider.java b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/UserIdGeneratorTestInvocationContextProvider.java new file mode 100644 index 0000000000..277ec03f05 --- /dev/null +++ b/testing-modules/junit5-annotations/src/test/java/com/baeldung/junit5/templates/UserIdGeneratorTestInvocationContextProvider.java @@ -0,0 +1,87 @@ +package com.baeldung.junit5.templates; + +import org.junit.jupiter.api.extension.*; + +import java.util.List; +import java.util.stream.Stream; + +import static java.util.Arrays.asList; + +public class UserIdGeneratorTestInvocationContextProvider implements TestTemplateInvocationContextProvider { + + @Override + public boolean supportsTestTemplate(ExtensionContext extensionContext) { + return true; + } + + @Override + public Stream provideTestTemplateInvocationContexts(ExtensionContext extensionContext) { + boolean featureDisabled = false; + boolean featureEnabled = true; + return Stream.of( + featureDisabledContext( + new UserIdGeneratorTestCase( + "Given feature switch disabled When user name is John Smith Then generated userid is JSmith", + featureDisabled, "John", "Smith", "JSmith")), + featureEnabledContext( + new UserIdGeneratorTestCase( + "Given feature switch enabled When user name is John Smith Then generated userid is baelJSmith", + featureEnabled, "John", "Smith", "baelJSmith")) + ); + } + + private TestTemplateInvocationContext featureDisabledContext(UserIdGeneratorTestCase userIdGeneratorTestCase) { + return new TestTemplateInvocationContext() { + @Override + public String getDisplayName(int invocationIndex) { + return userIdGeneratorTestCase.getDisplayName(); + } + + @Override + public List getAdditionalExtensions() { + return asList( + new GenericTypedParameterResolver(userIdGeneratorTestCase), + new BeforeTestExecutionCallback() { + @Override + public void beforeTestExecution(ExtensionContext extensionContext) { + System.out.println("BeforeTestExecutionCallback:Disabled context"); + } + }, + new AfterTestExecutionCallback() { + @Override + public void afterTestExecution(ExtensionContext extensionContext) { + System.out.println("AfterTestExecutionCallback:Disabled context"); + } + }); + } + }; + } + + private TestTemplateInvocationContext featureEnabledContext(UserIdGeneratorTestCase userIdGeneratorTestCase) { + return new TestTemplateInvocationContext() { + @Override + public String getDisplayName(int invocationIndex) { + return userIdGeneratorTestCase.getDisplayName(); + } + + @Override + public List getAdditionalExtensions() { + return asList( + new GenericTypedParameterResolver(userIdGeneratorTestCase), + new DisabledOnQAEnvironmentExtension(), + new BeforeEachCallback() { + @Override + public void beforeEach(ExtensionContext extensionContext) { + System.out.println("BeforeEachCallback:Enabled context"); + } + }, + new AfterEachCallback() { + @Override + public void afterEach(ExtensionContext extensionContext) { + System.out.println("AfterEachCallback:Enabled context"); + } + }); + } + }; + } +} diff --git a/testing-modules/junit5-annotations/src/test/resources/application.properties b/testing-modules/junit5-annotations/src/test/resources/application.properties new file mode 100644 index 0000000000..bbfa14d866 --- /dev/null +++ b/testing-modules/junit5-annotations/src/test/resources/application.properties @@ -0,0 +1 @@ +env=qa \ No newline at end of file From dcb65ba8bc29dee95c8e338cd710320ca26fdeac Mon Sep 17 00:00:00 2001 From: Tyrell Flurry Date: Sat, 11 Apr 2020 08:31:06 -0400 Subject: [PATCH 177/503] BAEL-3929: addressed code review comments. --- maven-all/maven-unused-dependencies/pom.xml | 23 ++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/maven-all/maven-unused-dependencies/pom.xml b/maven-all/maven-unused-dependencies/pom.xml index 312f38ed93..19a06fc605 100644 --- a/maven-all/maven-unused-dependencies/pom.xml +++ b/maven-all/maven-unused-dependencies/pom.xml @@ -10,21 +10,38 @@ commons-collections commons-collections - 3.2.2 + ${commons-collections.version} org.slf4j slf4j-api - 1.7.25 + ${slf4j-api.version} + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + + maven-dependency-plugin - 3.1.1 + ${maven-dependency-plugin.version} + + + 3.2.2 + 1.7.25 + 3.1.1 + 3.1 + + \ No newline at end of file From 552c1d805b281c6c575b269892e58d9b13d84b5b Mon Sep 17 00:00:00 2001 From: patkorek Date: Sat, 11 Apr 2020 14:39:36 +0200 Subject: [PATCH 178/503] Moved to com.baeldung.stringtoint package. --- .../baeldung/{strings => stringtoint}/ConvertStringToInt.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename core-groovy/src/test/groovy/com/baeldung/{strings => stringtoint}/ConvertStringToInt.groovy (98%) diff --git a/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy b/core-groovy/src/test/groovy/com/baeldung/stringtoint/ConvertStringToInt.groovy similarity index 98% rename from core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy rename to core-groovy/src/test/groovy/com/baeldung/stringtoint/ConvertStringToInt.groovy index 7a4be4a957..48cf48fa8a 100644 --- a/core-groovy/src/test/groovy/com/baeldung/strings/ConvertStringToInt.groovy +++ b/core-groovy/src/test/groovy/com/baeldung/stringtoint/ConvertStringToInt.groovy @@ -1,4 +1,4 @@ -package com.baeldung.strings +package com.baeldung.stringtoint import org.junit.Test From 3bdfd8f72681b94c3ca21bea00bf039a387d89dd Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sat, 11 Apr 2020 18:16:13 +0200 Subject: [PATCH 179/503] [JAVA-1265] Review build time * Migrate UserMapperUnitTest to UserMapperIntegrationTest as it uses Spring and takes a lot of time to execute --- jhipster-5/bookstore-monolith/pom.xml | 4 ++-- ...UserMapperUnitTest.java => UserMapperIntegrationTest.java} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/mapper/{UserMapperUnitTest.java => UserMapperIntegrationTest.java} (99%) diff --git a/jhipster-5/bookstore-monolith/pom.xml b/jhipster-5/bookstore-monolith/pom.xml index 5eaf761921..233765e0f3 100644 --- a/jhipster-5/bookstore-monolith/pom.xml +++ b/jhipster-5/bookstore-monolith/pom.xml @@ -7,7 +7,7 @@ 0.0.1-SNAPSHOT war Bookstore - + jhipster-5 com.baeldung.jhipster @@ -982,7 +982,7 @@ com.github.eirslett - frontend-maven-plugin + frontend-maven-plugin ${frontend-maven-plugin.version} install-node-and-npm diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/mapper/UserMapperUnitTest.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/mapper/UserMapperIntegrationTest.java similarity index 99% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/mapper/UserMapperUnitTest.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/mapper/UserMapperIntegrationTest.java index cd6a326c06..cd49135d63 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/mapper/UserMapperUnitTest.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/mapper/UserMapperIntegrationTest.java @@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ @RunWith(SpringRunner.class) @SpringBootTest(classes = BookstoreApp.class) -public class UserMapperUnitTest { +public class UserMapperIntegrationTest { private static final String DEFAULT_LOGIN = "johndoe"; From bbae9153a8cb2fe1179736acb4fb38ede9e80e78 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Sat, 11 Apr 2020 22:39:52 +0530 Subject: [PATCH 180/503] Disabling JWS module --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 8d4632fb3e..b3d949d495 100644 --- a/pom.xml +++ b/pom.xml @@ -803,7 +803,7 @@ jenkins/plugins jhipster - jws + libraries @@ -1296,7 +1296,7 @@ jenkins/plugins jhipster - jws + libraries From 5b88ab42df3e40721064ad4892b2ee62a9bf1bd4 Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sun, 12 Apr 2020 00:01:36 +0530 Subject: [PATCH 181/503] sync source code with article --- .../jackson/date/JacksonDateUnitTest.java | 20 ++++++- .../hibernate/audit/AuditorAwareImpl.java | 21 +++++++ .../baeldung/spring/PersistenceConfig.java | 2 +- .../spring-boot-annotations/pom.xml | 17 ++++++ .../ConditionalBeanConfiguration.java | 16 +++++ .../annotations/HealthCheckController.java | 16 +++++ .../annotations/HibernateCondition.java | 15 +++++ .../annotations/MySQLAutoconfiguration.java | 59 +++++++++++++++++++ .../WebApplicationSpecificConfiguration.java | 13 ++++ .../ConfigPropertiesDemoApplication.java | 2 +- .../com/baeldung/properties/Database.java | 33 +++++++++++ .../src/main/resources/application.properties | 6 +- .../DatabasePropertiesIntegrationTest.java | 30 ++++++++++ .../src/test/resources/application.properties | 6 +- .../web/config/MainWebAppInitializer.java | 32 ++++++++++ .../baeldung/spring/web/config/WebConfig.java | 8 +++ .../FooMappingExamplesController.java | 2 +- ...egrationTest.java => SpringRetryTest.java} | 2 +- .../web/config/MainWebAppInitializer.java | 16 +++++ .../web/controller/SecurityController.java | 2 +- 20 files changed, 310 insertions(+), 8 deletions(-) create mode 100644 persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java create mode 100644 spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/ConditionalBeanConfiguration.java create mode 100644 spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/HealthCheckController.java create mode 100644 spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/HibernateCondition.java create mode 100644 spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/MySQLAutoconfiguration.java create mode 100644 spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/WebApplicationSpecificConfiguration.java create mode 100644 spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/Database.java create mode 100644 spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/DatabasePropertiesIntegrationTest.java create mode 100644 spring-mvc-java/src/main/java/com/baeldung/spring/web/config/MainWebAppInitializer.java rename spring-scheduling/src/test/java/com/baeldung/springretry/{SpringRetryIntegrationTest.java => SpringRetryTest.java} (96%) create mode 100644 spring-security-modules/spring-security-mvc/src/main/java/com/baeldung/session/web/config/MainWebAppInitializer.java diff --git a/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/date/JacksonDateUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/date/JacksonDateUnitTest.java index a264dd52f2..924ec1162f 100644 --- a/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/date/JacksonDateUnitTest.java +++ b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/date/JacksonDateUnitTest.java @@ -1,6 +1,7 @@ package com.baeldung.jackson.date; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; @@ -8,6 +9,8 @@ import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.util.Date; import java.util.TimeZone; @@ -30,7 +33,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; public class JacksonDateUnitTest { @Test - public void whenSerializingDateWithJackson_thenSerializedToNumber() throws JsonProcessingException, ParseException { + public void whenSerializingDateWithJackson_thenSerializedToTimestamp() throws JsonProcessingException, ParseException { final SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy hh:mm"); df.setTimeZone(TimeZone.getTimeZone("UTC")); @@ -61,6 +64,21 @@ public class JacksonDateUnitTest { final String result = mapper.writeValueAsString(event); assertThat(result, containsString("1970-01-01T02:30:00.000+00:00")); } + + @Test + public void whenDeserialisingZonedDateTimeWithDefaults_thenNotCorrect() + throws IOException { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.findAndRegisterModules(); + objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC")); + String converted = objectMapper.writeValueAsString(now); + + ZonedDateTime restored = objectMapper.readValue(converted, ZonedDateTime.class); + System.out.println("serialized: " + now); + System.out.println("restored: " + restored); + assertThat(now, is(restored)); + } @Test public void whenSettingObjectMapperDateFormat_thenCorrect() throws JsonProcessingException, ParseException { diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java new file mode 100644 index 0000000000..d59497c2dc --- /dev/null +++ b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java @@ -0,0 +1,21 @@ +package com.baeldung.hibernate.audit; + +import java.util.Optional; + +import org.springframework.data.domain.AuditorAware; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Component; + +@Component("auditorProvider") +public class AuditorAwareImpl implements AuditorAware { + + @Override + public String getCurrentAuditor() { + return Optional.ofNullable(SecurityContextHolder.getContext()) + .map(e -> e.getAuthentication()) + .map(Authentication::getName) + .orElse(null); + } + +} diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java index b7cf0fadf2..195df6fb81 100644 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java +++ b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java @@ -46,7 +46,7 @@ import com.google.common.base.Preconditions; @Configuration @EnableTransactionManagement @EnableJpaRepositories(basePackages = { "com.baeldung.persistence" }, transactionManagerRef = "jpaTransactionManager") -@EnableJpaAuditing +@EnableJpaAuditing(auditorAwareRef = "auditorProvider") @PropertySource({ "classpath:persistence-h2.properties" }) @ComponentScan({ "com.baeldung.persistence" }) public class PersistenceConfig { diff --git a/spring-boot-modules/spring-boot-annotations/pom.xml b/spring-boot-modules/spring-boot-annotations/pom.xml index 9ad63214ef..59de83b4e5 100644 --- a/spring-boot-modules/spring-boot-annotations/pom.xml +++ b/spring-boot-modules/spring-boot-annotations/pom.xml @@ -24,6 +24,22 @@ org.springframework.boot spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-data-jpa + + + com.zaxxer + HikariCP + + + + + + org.hibernate + hibernate-core + @@ -32,4 +48,5 @@ test + diff --git a/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/ConditionalBeanConfiguration.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/ConditionalBeanConfiguration.java new file mode 100644 index 0000000000..4719425663 --- /dev/null +++ b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/ConditionalBeanConfiguration.java @@ -0,0 +1,16 @@ +package com.baeldung.annotations; + +import java.util.Properties; + +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class ConditionalBeanConfiguration { + + @Conditional(HibernateCondition.class) + Properties additionalProperties() { + // application specific properties + return new Properties(); + } +} diff --git a/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/HealthCheckController.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/HealthCheckController.java new file mode 100644 index 0000000000..e87ed6cb47 --- /dev/null +++ b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/HealthCheckController.java @@ -0,0 +1,16 @@ +package com.baeldung.annotations; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HealthCheckController { + + private static final String STATUS = "UP"; + + @GetMapping("/health") + public ResponseEntity healthCheck() { + return ResponseEntity.ok(STATUS); + } +} diff --git a/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/HibernateCondition.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/HibernateCondition.java new file mode 100644 index 0000000000..e2d77cc5d0 --- /dev/null +++ b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/HibernateCondition.java @@ -0,0 +1,15 @@ +package com.baeldung.annotations; + +import org.springframework.context.annotation.Condition; +import org.springframework.context.annotation.ConditionContext; +import org.springframework.core.type.AnnotatedTypeMetadata; + +public class HibernateCondition implements Condition { + + @Override + public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { + // application specific condition check + return true; + } + +} diff --git a/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/MySQLAutoconfiguration.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/MySQLAutoconfiguration.java new file mode 100644 index 0000000000..ba23267525 --- /dev/null +++ b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/MySQLAutoconfiguration.java @@ -0,0 +1,59 @@ +package com.baeldung.annotations; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import javax.sql.DataSource; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.autoconfigure.condition.ConditionalOnResource; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; +import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.orm.jpa.JpaVendorAdapter; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; + +@Configuration +@ConditionalOnClass(DataSource.class) +public class MySQLAutoconfiguration { + + @Bean + @ConditionalOnBean(name = "dataSource") + LocalContainerEntityManagerFactoryBean entityManagerFactory() throws IOException { + final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); + em.setDataSource(dataSource()); + em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); + + final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + em.setJpaVendorAdapter(vendorAdapter); + em.setJpaProperties(additionalProperties()); + return em; + } + + @Bean + @ConditionalOnProperty(name = "usemysql", havingValue = "local") + DataSource dataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("org.hsqldb.jdbcDriver"); + dataSource.setUrl("jdbc:hsqldb:mem:testdb"); + dataSource.setUsername( "sa" ); + dataSource.setPassword( "" ); + return dataSource; + } + + @ConditionalOnResource(resources = "classpath:mysql.properties") + Properties additionalProperties() throws IOException { + final Properties additionalProperties = new Properties(); + + try (InputStream inputStream = new ClassPathResource("classpath:mysql.properties").getInputStream()) { + additionalProperties.load(inputStream); + } + + return additionalProperties; + } +} diff --git a/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/WebApplicationSpecificConfiguration.java b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/WebApplicationSpecificConfiguration.java new file mode 100644 index 0000000000..62f68bee29 --- /dev/null +++ b/spring-boot-modules/spring-boot-annotations/src/main/java/com/baeldung/annotations/WebApplicationSpecificConfiguration.java @@ -0,0 +1,13 @@ +package com.baeldung.annotations; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class WebApplicationSpecificConfiguration { + + @ConditionalOnWebApplication + HealthCheckController healthCheckController() { + return new HealthCheckController(); + } +} diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/ConfigPropertiesDemoApplication.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/ConfigPropertiesDemoApplication.java index 41f26d51f7..e54f28837d 100644 --- a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/ConfigPropertiesDemoApplication.java +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/ConfigPropertiesDemoApplication.java @@ -7,7 +7,7 @@ import org.springframework.context.annotation.ComponentScan; import com.baeldung.configurationproperties.ConfigProperties; @SpringBootApplication -@ComponentScan(basePackageClasses = { ConfigProperties.class, JsonProperties.class, CustomJsonProperties.class }) +@ComponentScan(basePackageClasses = { ConfigProperties.class, JsonProperties.class, CustomJsonProperties.class, Database.class }) public class ConfigPropertiesDemoApplication { public static void main(String[] args) { new SpringApplicationBuilder(ConfigPropertiesDemoApplication.class).initializers(new JsonPropertyContextInitializer()) diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/Database.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/Database.java new file mode 100644 index 0000000000..6e798672e7 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/Database.java @@ -0,0 +1,33 @@ +package com.baeldung.properties; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ConfigurationProperties(prefix = "database") +public class Database { + + private String url; + private String username; + private String password; + + public String getUrl() { + return url; + } + public void setUrl(String url) { + this.url = url; + } + public String getUsername() { + return username; + } + public void setUsername(String username) { + this.username = username; + } + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + +} diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/application.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/application.properties index 2e06fad574..d4d1df7abc 100644 --- a/spring-boot-modules/spring-boot-properties/src/main/resources/application.properties +++ b/spring-boot-modules/spring-boot-properties/src/main/resources/application.properties @@ -1,4 +1,8 @@ management.endpoints.web.exposure.include=refresh spring.properties.refreshDelay=1000 spring.config.location=file:extra.properties -spring.main.allow-bean-definition-overriding=true \ No newline at end of file +spring.main.allow-bean-definition-overriding=true + +database.url=jdbc:postgresql:/localhost:5432/instance +database.username=foo +database.password=bar \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/DatabasePropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/DatabasePropertiesIntegrationTest.java new file mode 100644 index 0000000000..0b9bd797ae --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/DatabasePropertiesIntegrationTest.java @@ -0,0 +1,30 @@ +package com.baeldung.configurationproperties; + +import org.junit.Assert; +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.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import com.baeldung.properties.ConfigPropertiesDemoApplication; +import com.baeldung.properties.Database; + + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = ConfigPropertiesDemoApplication.class) +@TestPropertySource("classpath:application.properties") +public class DatabasePropertiesIntegrationTest { + + @Autowired + private Database database; + + @Test + public void testDatabaseProperties() { + Assert.assertNotNull(database); + Assert.assertEquals("jdbc:postgresql:/localhost:5432/instance", database.getUrl()); + Assert.assertEquals("foo", database.getUsername()); + Assert.assertEquals("bar", database.getPassword()); + } +} diff --git a/spring-boot-modules/spring-boot-properties/src/test/resources/application.properties b/spring-boot-modules/spring-boot-properties/src/test/resources/application.properties index 2e06fad574..d4d1df7abc 100644 --- a/spring-boot-modules/spring-boot-properties/src/test/resources/application.properties +++ b/spring-boot-modules/spring-boot-properties/src/test/resources/application.properties @@ -1,4 +1,8 @@ management.endpoints.web.exposure.include=refresh spring.properties.refreshDelay=1000 spring.config.location=file:extra.properties -spring.main.allow-bean-definition-overriding=true \ No newline at end of file +spring.main.allow-bean-definition-overriding=true + +database.url=jdbc:postgresql:/localhost:5432/instance +database.username=foo +database.password=bar \ No newline at end of file diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/MainWebAppInitializer.java b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/MainWebAppInitializer.java new file mode 100644 index 0000000000..3623217130 --- /dev/null +++ b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/MainWebAppInitializer.java @@ -0,0 +1,32 @@ +package com.baeldung.spring.web.config; + +import javax.servlet.MultipartConfigElement; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletRegistration; + +import org.springframework.web.WebApplicationInitializer; +import org.springframework.web.context.support.GenericWebApplicationContext; +import org.springframework.web.servlet.DispatcherServlet; + +public class MainWebAppInitializer implements WebApplicationInitializer { + + private String TMP_FOLDER = "/tmp"; + private int MAX_UPLOAD_SIZE = 5 * 1024 * 1024; + + @Override + public void onStartup(ServletContext sc) throws ServletException { + + ServletRegistration.Dynamic appServlet = sc.addServlet("mvc", new DispatcherServlet( + new GenericWebApplicationContext())); + + appServlet.setLoadOnStartup(1); + + MultipartConfigElement multipartConfigElement = new MultipartConfigElement(TMP_FOLDER, + MAX_UPLOAD_SIZE, MAX_UPLOAD_SIZE * 2, MAX_UPLOAD_SIZE / 2); + + appServlet.setMultipartConfig(multipartConfigElement); + + } + +} diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebConfig.java b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebConfig.java index 96e300464b..768fda1c4a 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebConfig.java +++ b/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/WebConfig.java @@ -12,6 +12,7 @@ import org.springframework.context.support.ResourceBundleMessageSource; import org.springframework.http.MediaType; import org.springframework.http.converter.ByteArrayHttpMessageConverter; import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.web.multipart.commons.CommonsMultipartResolver; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; @@ -121,4 +122,11 @@ public class WebConfig implements WebMvcConfigurer { public ExcelPOIHelper excelPOIHelper() { return new ExcelPOIHelper(); } + + @Bean(name = "multipartResolver") + public CommonsMultipartResolver multipartResolver() { + CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver(); + multipartResolver.setMaxUploadSize(100000); + return multipartResolver; + } } \ No newline at end of file diff --git a/spring-rest-http/src/main/java/com/baeldung/requestmapping/FooMappingExamplesController.java b/spring-rest-http/src/main/java/com/baeldung/requestmapping/FooMappingExamplesController.java index 543ba76273..cafd9a38e3 100644 --- a/spring-rest-http/src/main/java/com/baeldung/requestmapping/FooMappingExamplesController.java +++ b/spring-rest-http/src/main/java/com/baeldung/requestmapping/FooMappingExamplesController.java @@ -72,7 +72,7 @@ public class FooMappingExamplesController { @RequestMapping(value = "/foos", produces = { "application/json", "application/xml" }) @ResponseBody - public String getFoosAsJsonFromREST() { + public String getFoosAsJsonFromBrowser() { return "Get some Foos with Header New"; } diff --git a/spring-scheduling/src/test/java/com/baeldung/springretry/SpringRetryIntegrationTest.java b/spring-scheduling/src/test/java/com/baeldung/springretry/SpringRetryTest.java similarity index 96% rename from spring-scheduling/src/test/java/com/baeldung/springretry/SpringRetryIntegrationTest.java rename to spring-scheduling/src/test/java/com/baeldung/springretry/SpringRetryTest.java index 2e5fb75482..b22d5e620e 100644 --- a/spring-scheduling/src/test/java/com/baeldung/springretry/SpringRetryIntegrationTest.java +++ b/spring-scheduling/src/test/java/com/baeldung/springretry/SpringRetryTest.java @@ -12,7 +12,7 @@ import java.sql.SQLException; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = AppConfig.class, loader = AnnotationConfigContextLoader.class) -public class SpringRetryIntegrationTest { +public class SpringRetryTest { @Autowired private MyService myService; diff --git a/spring-security-modules/spring-security-mvc/src/main/java/com/baeldung/session/web/config/MainWebAppInitializer.java b/spring-security-modules/spring-security-mvc/src/main/java/com/baeldung/session/web/config/MainWebAppInitializer.java new file mode 100644 index 0000000000..f85f9f3fb0 --- /dev/null +++ b/spring-security-modules/spring-security-mvc/src/main/java/com/baeldung/session/web/config/MainWebAppInitializer.java @@ -0,0 +1,16 @@ +package com.baeldung.session.web.config; + +import javax.servlet.ServletContext; +import javax.servlet.ServletException; + +import org.springframework.web.WebApplicationInitializer; + +public class MainWebAppInitializer implements WebApplicationInitializer { + + @Override + public void onStartup(ServletContext sc) throws ServletException { + sc.getSessionCookieConfig().setHttpOnly(true); + sc.getSessionCookieConfig().setSecure(true); + } + +} diff --git a/spring-security-modules/spring-security-rest-custom/src/main/java/com/baeldung/web/controller/SecurityController.java b/spring-security-modules/spring-security-rest-custom/src/main/java/com/baeldung/web/controller/SecurityController.java index f35940f54c..ece442430f 100644 --- a/spring-security-modules/spring-security-rest-custom/src/main/java/com/baeldung/web/controller/SecurityController.java +++ b/spring-security-modules/spring-security-rest-custom/src/main/java/com/baeldung/web/controller/SecurityController.java @@ -18,7 +18,7 @@ public class SecurityController { @RequestMapping(value = "/username2", method = RequestMethod.GET) @ResponseBody - public String currentUserNameSimple(final Principal principal) { + public String currentUserName(final Principal principal) { return principal.getName(); } From 2478c10c84b0b3f72f9253fa0fb4f17c075a9607 Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sun, 12 Apr 2020 01:05:59 +0530 Subject: [PATCH 182/503] reverted the file name --- .../{SpringRetryTest.java => SpringRetryIntegrationTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename spring-scheduling/src/test/java/com/baeldung/springretry/{SpringRetryTest.java => SpringRetryIntegrationTest.java} (96%) diff --git a/spring-scheduling/src/test/java/com/baeldung/springretry/SpringRetryTest.java b/spring-scheduling/src/test/java/com/baeldung/springretry/SpringRetryIntegrationTest.java similarity index 96% rename from spring-scheduling/src/test/java/com/baeldung/springretry/SpringRetryTest.java rename to spring-scheduling/src/test/java/com/baeldung/springretry/SpringRetryIntegrationTest.java index b22d5e620e..2e5fb75482 100644 --- a/spring-scheduling/src/test/java/com/baeldung/springretry/SpringRetryTest.java +++ b/spring-scheduling/src/test/java/com/baeldung/springretry/SpringRetryIntegrationTest.java @@ -12,7 +12,7 @@ import java.sql.SQLException; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = AppConfig.class, loader = AnnotationConfigContextLoader.class) -public class SpringRetryTest { +public class SpringRetryIntegrationTest { @Autowired private MyService myService; From b43d6e9bc8d2bf09f9588a250d61670b31e19936 Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sun, 12 Apr 2020 01:23:02 +0530 Subject: [PATCH 183/503] fix junit test case --- .../java/com/baeldung/hibernate/audit/AuditorAwareImpl.java | 2 -- .../main/java/com/baeldung/spring/PersistenceConfig.java | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java index d59497c2dc..7aef08b2ce 100644 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java +++ b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/hibernate/audit/AuditorAwareImpl.java @@ -5,9 +5,7 @@ import java.util.Optional; import org.springframework.data.domain.AuditorAware; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Component; -@Component("auditorProvider") public class AuditorAwareImpl implements AuditorAware { @Override diff --git a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java index 195df6fb81..6ae133ca7a 100644 --- a/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java +++ b/persistence-modules/spring-hibernate4/src/main/java/com/baeldung/spring/PersistenceConfig.java @@ -23,6 +23,7 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; +import com.baeldung.hibernate.audit.AuditorAwareImpl; import com.baeldung.persistence.dao.IBarAuditableDao; import com.baeldung.persistence.dao.IBarDao; import com.baeldung.persistence.dao.IFooAuditableDao; @@ -58,6 +59,11 @@ public class PersistenceConfig { super(); } + @Bean("auditorProvider") + public AuditorAwareImpl auditorAwareImpl() { + return new AuditorAwareImpl(); + } + @Bean public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); From 7facbd6bf6458eba0dea40234f036077d48d799e Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sun, 12 Apr 2020 04:31:53 +0530 Subject: [PATCH 184/503] update artifictId in pom file --- ddd-modules/pom.xml | 2 +- jgit/pom.xml | 4 ++-- persistence-modules/r2dbc/pom.xml | 2 +- persistence-modules/sirix/pom.xml | 2 +- quarkus-extension/quarkus-liquibase/deployment/pom.xml | 6 +++--- quarkus-extension/quarkus-liquibase/pom.xml | 4 ++-- quarkus-extension/quarkus-liquibase/runtime/pom.xml | 6 +++--- spring-cloud/spring-cloud-openfeign/pom.xml | 4 ++-- spring-cloud/spring-cloud-task/springcloudtasksink/pom.xml | 4 ++-- twitter4j/pom.xml | 4 ++-- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ddd-modules/pom.xml b/ddd-modules/pom.xml index 38e48ff27d..c6dd6e1f25 100644 --- a/ddd-modules/pom.xml +++ b/ddd-modules/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.dddmodules - dddmodules + ddd-modules 1.0 ddd-modules pom diff --git a/jgit/pom.xml b/jgit/pom.xml index eef3c9b8e8..d960843868 100644 --- a/jgit/pom.xml +++ b/jgit/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - JGit + jgit 1.0-SNAPSHOT - JGit + jgit jar http://maven.apache.org diff --git a/persistence-modules/r2dbc/pom.xml b/persistence-modules/r2dbc/pom.xml index 55197ad560..70ff8d6a87 100644 --- a/persistence-modules/r2dbc/pom.xml +++ b/persistence-modules/r2dbc/pom.xml @@ -6,7 +6,7 @@ com.baeldung.examples.r2dbc r2dbc-example 0.0.1-SNAPSHOT - r2dbc-example + r2dbc Sample R2DBC Project diff --git a/persistence-modules/sirix/pom.xml b/persistence-modules/sirix/pom.xml index d8e065ec2f..0f114966f7 100644 --- a/persistence-modules/sirix/pom.xml +++ b/persistence-modules/sirix/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 io.sirix - core-api-tutorial + sirix 1.0-SNAPSHOT core-api-tutorial jar diff --git a/quarkus-extension/quarkus-liquibase/deployment/pom.xml b/quarkus-extension/quarkus-liquibase/deployment/pom.xml index c85d986390..5c6b56e152 100644 --- a/quarkus-extension/quarkus-liquibase/deployment/pom.xml +++ b/quarkus-extension/quarkus-liquibase/deployment/pom.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - quarkus-liquibase-deployment - quarkus-liquibase-deployment + deployment + deployment com.baeldung.quarkus.liquibase @@ -58,4 +58,4 @@ 3.8.1 - \ No newline at end of file + diff --git a/quarkus-extension/quarkus-liquibase/pom.xml b/quarkus-extension/quarkus-liquibase/pom.xml index 9536561701..8ed6555ed7 100644 --- a/quarkus-extension/quarkus-liquibase/pom.xml +++ b/quarkus-extension/quarkus-liquibase/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.baeldung.quarkus.liquibase quarkus-liquibase-parent - quarkus-liquibase-parent + quarkus-liquibase pom @@ -23,4 +23,4 @@ 1.0.0.Final - \ No newline at end of file + diff --git a/quarkus-extension/quarkus-liquibase/runtime/pom.xml b/quarkus-extension/quarkus-liquibase/runtime/pom.xml index 83f7c8d4cc..760e6ab719 100644 --- a/quarkus-extension/quarkus-liquibase/runtime/pom.xml +++ b/quarkus-extension/quarkus-liquibase/runtime/pom.xml @@ -2,8 +2,8 @@ 4.0.0 - quarkus-liquibase-runtime - quarkus-liquibase-runtime + runtime + runtime com.baeldung.quarkus.liquibase @@ -70,4 +70,4 @@ 3.8.1 - \ No newline at end of file + diff --git a/spring-cloud/spring-cloud-openfeign/pom.xml b/spring-cloud/spring-cloud-openfeign/pom.xml index e20fe338c1..df529d7fb1 100644 --- a/spring-cloud/spring-cloud-openfeign/pom.xml +++ b/spring-cloud/spring-cloud-openfeign/pom.xml @@ -3,9 +3,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.cloud - openfeign + spring-cloud-openfeign 0.0.1-SNAPSHOT - openfeign + spring-cloud-openfeign OpenFeign project for Spring Boot diff --git a/spring-cloud/spring-cloud-task/springcloudtasksink/pom.xml b/spring-cloud/spring-cloud-task/springcloudtasksink/pom.xml index 441924f1d3..93255959e4 100644 --- a/spring-cloud/spring-cloud-task/springcloudtasksink/pom.xml +++ b/spring-cloud/spring-cloud-task/springcloudtasksink/pom.xml @@ -2,8 +2,8 @@ 4.0.0 - SpringCloudTaskSink - SpringCloudTaskSink + springcloudtasksink + springcloudtasksink jar Demo project for Spring Boot diff --git a/twitter4j/pom.xml b/twitter4j/pom.xml index 6d98e2fe58..274b5c75c3 100644 --- a/twitter4j/pom.xml +++ b/twitter4j/pom.xml @@ -2,8 +2,8 @@ 4.0.0 - Twitter4J - Twitter4J + twitter4J + twitter4J jar From 4a83c738350acd32e9c6d2035dce0a91238be503 Mon Sep 17 00:00:00 2001 From: Kumar Chandrakant Date: Sun, 12 Apr 2020 10:06:34 +0530 Subject: [PATCH 185/503] Adding codebase for the article tracked under BAEL-2046. (#9055) --- atomikos/README.md | 7 ++ atomikos/pom.xml | 119 ++++++++++++++++++ .../baeldung/atomikos/direct/Application.java | 53 ++++++++ .../baeldung/atomikos/spring/Application.java | 41 ++++++ .../atomikos/spring/config/Config.java | 68 ++++++++++ .../atomikos/spring/jpa/Application.java | 48 +++++++ .../atomikos/spring/jpa/config/Config.java | 38 ++++++ .../spring/jpa/inventory/Inventory.java | 31 +++++ .../spring/jpa/inventory/InventoryConfig.java | 53 ++++++++ .../jpa/inventory/InventoryRepository.java | 9 ++ .../atomikos/spring/jpa/order/Order.java | 42 +++++++ .../spring/jpa/order/OrderConfig.java | 53 ++++++++ .../spring/jpa/order/OrderRepository.java | 9 ++ atomikos/src/main/resources/logback.xml | 13 ++ atomikos/src/main/resources/schema.sql | 10 ++ .../main/resources/transactions.properties | 1 + .../atomikos/direct/ApplicationUnitTest.java | 118 +++++++++++++++++ .../atomikos/spring/ApplicationUnitTest.java | 108 ++++++++++++++++ .../spring/jpa/ApplicationUnitTest.java | 80 ++++++++++++ atomikos/src/test/resources/logback.xml | 13 ++ .../test/resources/transactions.properties | 1 + pom.xml | 4 + 22 files changed, 919 insertions(+) create mode 100644 atomikos/README.md create mode 100644 atomikos/pom.xml create mode 100644 atomikos/src/main/java/com/baeldung/atomikos/direct/Application.java create mode 100644 atomikos/src/main/java/com/baeldung/atomikos/spring/Application.java create mode 100644 atomikos/src/main/java/com/baeldung/atomikos/spring/config/Config.java create mode 100644 atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/Application.java create mode 100644 atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/config/Config.java create mode 100644 atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/Inventory.java create mode 100644 atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/InventoryConfig.java create mode 100644 atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/InventoryRepository.java create mode 100644 atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/Order.java create mode 100644 atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/OrderConfig.java create mode 100644 atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/OrderRepository.java create mode 100644 atomikos/src/main/resources/logback.xml create mode 100644 atomikos/src/main/resources/schema.sql create mode 100644 atomikos/src/main/resources/transactions.properties create mode 100644 atomikos/src/test/java/com/baeldung/atomikos/direct/ApplicationUnitTest.java create mode 100644 atomikos/src/test/java/com/baeldung/atomikos/spring/ApplicationUnitTest.java create mode 100644 atomikos/src/test/java/com/baeldung/atomikos/spring/jpa/ApplicationUnitTest.java create mode 100644 atomikos/src/test/resources/logback.xml create mode 100644 atomikos/src/test/resources/transactions.properties diff --git a/atomikos/README.md b/atomikos/README.md new file mode 100644 index 0000000000..19f2e871d4 --- /dev/null +++ b/atomikos/README.md @@ -0,0 +1,7 @@ +## Atomikos + +This module contains articles about Atomikos + +### Relevant Articles: + +- [Guide Transactions Using Atomikos]() diff --git a/atomikos/pom.xml b/atomikos/pom.xml new file mode 100644 index 0000000000..881adae074 --- /dev/null +++ b/atomikos/pom.xml @@ -0,0 +1,119 @@ + + + 4.0.0 + atomikos + atomikos + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + com.atomikos + transactions-jdbc + ${atomikos-version} + + + com.atomikos + transactions-jms + ${atomikos-version} + + + com.atomikos + transactions-hibernate4 + ${atomikos-version} + + + org.springframework + spring-context + ${spring-version} + + + org.springframework + spring-tx + ${spring-version} + + + org.springframework.data + spring-data-jpa + 1.11.23.RELEASE + + + org.springframework + spring-test + ${spring-version} + test + + + org.hibernate + hibernate-entitymanager + ${hibernate.version} + provided + + + javax.transaction + jta + + + + + org.apache.activemq + activemq-core + 5.7.0 + + + org.apache.derby + derby + 10.8.1.2 + + + junit + junit + 4.12 + test + + + + javax.transaction + jta + 1.1 + + + org.apache.geronimo.specs + geronimo-jta_1.0.1B_spec + 1.0 + + + javax.validation + validation-api + 2.0.1.Final + + + org.hibernate.validator + hibernate-validator + 6.1.2.Final + + + javax.el + javax.el-api + 3.0.0 + + + org.glassfish.web + javax.el + 2.2.4 + + + + + 5.0.6 + 5.1.6.RELEASE + 5.4.3.Final + + + \ No newline at end of file diff --git a/atomikos/src/main/java/com/baeldung/atomikos/direct/Application.java b/atomikos/src/main/java/com/baeldung/atomikos/direct/Application.java new file mode 100644 index 0000000000..c51ce70dde --- /dev/null +++ b/atomikos/src/main/java/com/baeldung/atomikos/direct/Application.java @@ -0,0 +1,53 @@ +package com.baeldung.atomikos.direct; + +import java.sql.Connection; +import java.sql.Statement; +import java.util.UUID; + +import javax.sql.DataSource; + +import com.atomikos.icatch.jta.UserTransactionImp; + +public class Application { + + private DataSource inventoryDataSource; + private DataSource orderDataSource; + + public Application(DataSource inventoryDataSource, DataSource orderDataSource) { + this.inventoryDataSource = inventoryDataSource; + this.orderDataSource = orderDataSource; + } + + public void placeOrder(String productId, int amount) throws Exception { + + UserTransactionImp utx = new UserTransactionImp(); + String orderId = UUID.randomUUID() + .toString(); + boolean rollback = false; + try { + utx.begin(); + Connection inventoryConnection = inventoryDataSource.getConnection(); + Connection orderConnection = orderDataSource.getConnection(); + Statement s1 = inventoryConnection.createStatement(); + String q1 = "update Inventory set balance = balance - " + amount + " where productId ='" + productId + "'"; + s1.executeUpdate(q1); + s1.close(); + Statement s2 = orderConnection.createStatement(); + String q2 = "insert into Orders values ( '" + orderId + "', '" + productId + "', " + amount + " )"; + s2.executeUpdate(q2); + s2.close(); + inventoryConnection.close(); + orderConnection.close(); + } catch (Exception e) { + System.out.println(e.getMessage()); + rollback = true; + } finally { + if (!rollback) + utx.commit(); + else + utx.rollback(); + } + + } + +} diff --git a/atomikos/src/main/java/com/baeldung/atomikos/spring/Application.java b/atomikos/src/main/java/com/baeldung/atomikos/spring/Application.java new file mode 100644 index 0000000000..b480e68d8d --- /dev/null +++ b/atomikos/src/main/java/com/baeldung/atomikos/spring/Application.java @@ -0,0 +1,41 @@ +package com.baeldung.atomikos.spring; + +import java.sql.Connection; +import java.sql.Statement; +import java.util.UUID; + +import javax.sql.DataSource; + +import org.springframework.transaction.annotation.Transactional; + +public class Application { + + private DataSource inventoryDataSource; + private DataSource orderDataSource; + + public Application(DataSource inventoryDataSource, DataSource orderDataSource) { + this.inventoryDataSource = inventoryDataSource; + this.orderDataSource = orderDataSource; + } + + @Transactional(rollbackFor = Exception.class) + public void placeOrder(String productId, int amount) throws Exception { + + String orderId = UUID.randomUUID() + .toString(); + Connection inventoryConnection = inventoryDataSource.getConnection(); + Connection orderConnection = orderDataSource.getConnection(); + Statement s1 = inventoryConnection.createStatement(); + String q1 = "update Inventory set balance = balance - " + amount + " where productId ='" + productId + "'"; + s1.executeUpdate(q1); + s1.close(); + Statement s2 = orderConnection.createStatement(); + String q2 = "insert into Orders values ( '" + orderId + "', '" + productId + "', " + amount + " )"; + s2.executeUpdate(q2); + s2.close(); + inventoryConnection.close(); + orderConnection.close(); + + } + +} diff --git a/atomikos/src/main/java/com/baeldung/atomikos/spring/config/Config.java b/atomikos/src/main/java/com/baeldung/atomikos/spring/config/Config.java new file mode 100644 index 0000000000..c6ef83c4ca --- /dev/null +++ b/atomikos/src/main/java/com/baeldung/atomikos/spring/config/Config.java @@ -0,0 +1,68 @@ +package com.baeldung.atomikos.spring.config; + +import java.util.Properties; + +import javax.transaction.SystemException; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.transaction.annotation.EnableTransactionManagement; +import org.springframework.transaction.jta.JtaTransactionManager; + +import com.atomikos.icatch.jta.UserTransactionManager; +import com.atomikos.jdbc.AtomikosDataSourceBean; +import com.baeldung.atomikos.spring.Application; + +@Configuration +@EnableTransactionManagement +public class Config { + + @Bean(initMethod = "init", destroyMethod = "close") + public AtomikosDataSourceBean inventoryDataSource() { + AtomikosDataSourceBean dataSource = new AtomikosDataSourceBean(); + dataSource.setLocalTransactionMode(true); + dataSource.setUniqueResourceName("db1"); + dataSource.setXaDataSourceClassName("org.apache.derby.jdbc.EmbeddedXADataSource"); + Properties xaProperties = new Properties(); + xaProperties.put("databaseName", "db1"); + xaProperties.put("createDatabase", "create"); + dataSource.setXaProperties(xaProperties); + dataSource.setPoolSize(10); + return dataSource; + } + + @Bean(initMethod = "init", destroyMethod = "close") + public AtomikosDataSourceBean orderDataSource() { + AtomikosDataSourceBean dataSource = new AtomikosDataSourceBean(); + dataSource.setLocalTransactionMode(true); + dataSource.setUniqueResourceName("db2"); + dataSource.setXaDataSourceClassName("org.apache.derby.jdbc.EmbeddedXADataSource"); + Properties xaProperties = new Properties(); + xaProperties.put("databaseName", "db2"); + xaProperties.put("createDatabase", "create"); + dataSource.setXaProperties(xaProperties); + dataSource.setPoolSize(10); + return dataSource; + } + + @Bean(initMethod = "init", destroyMethod = "close") + public UserTransactionManager userTransactionManager() throws SystemException { + UserTransactionManager userTransactionManager = new UserTransactionManager(); + userTransactionManager.setTransactionTimeout(300); + userTransactionManager.setForceShutdown(true); + return userTransactionManager; + } + + @Bean + public JtaTransactionManager jtaTransactionManager() throws SystemException { + JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(); + jtaTransactionManager.setTransactionManager(userTransactionManager()); + jtaTransactionManager.setUserTransaction(userTransactionManager()); + return jtaTransactionManager; + } + + @Bean + public Application application() { + return new Application(inventoryDataSource(), orderDataSource()); + } +} \ No newline at end of file diff --git a/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/Application.java b/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/Application.java new file mode 100644 index 0000000000..cf1fef2cd8 --- /dev/null +++ b/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/Application.java @@ -0,0 +1,48 @@ +package com.baeldung.atomikos.spring.jpa; + +import java.util.Set; +import java.util.UUID; + +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.Validator; +import javax.validation.ValidatorFactory; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; + +import com.baeldung.atomikos.spring.jpa.inventory.Inventory; +import com.baeldung.atomikos.spring.jpa.inventory.InventoryRepository; +import com.baeldung.atomikos.spring.jpa.order.Order; +import com.baeldung.atomikos.spring.jpa.order.OrderRepository; + +public class Application { + + @Autowired + private InventoryRepository inventoryRepository; + + @Autowired + private OrderRepository orderRepository; + + @Transactional(rollbackFor = Exception.class) + public void placeOrder(String productId, int amount) throws Exception { + + String orderId = UUID.randomUUID() + .toString(); + Inventory inventory = inventoryRepository.findOne(productId); + inventory.setBalance(inventory.getBalance() - amount); + inventoryRepository.save(inventory); + Order order = new Order(); + order.setOrderId(orderId); + order.setProductId(productId); + order.setAmount(new Long(amount)); + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + Validator validator = factory.getValidator(); + Set> violations = validator.validate(order); + if (violations.size() > 0) + throw new Exception("Invalid instance of an order."); + orderRepository.save(order); + + } + +} diff --git a/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/config/Config.java b/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/config/Config.java new file mode 100644 index 0000000000..6716f19576 --- /dev/null +++ b/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/config/Config.java @@ -0,0 +1,38 @@ +package com.baeldung.atomikos.spring.jpa.config; + +import javax.transaction.SystemException; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.transaction.annotation.EnableTransactionManagement; +import org.springframework.transaction.jta.JtaTransactionManager; + +import com.atomikos.icatch.jta.UserTransactionManager; +import com.baeldung.atomikos.spring.jpa.Application; + +@Configuration +@EnableTransactionManagement +public class Config { + + @Bean(initMethod = "init", destroyMethod = "close") + public UserTransactionManager userTransactionManager() throws SystemException { + UserTransactionManager userTransactionManager = new UserTransactionManager(); + userTransactionManager.setTransactionTimeout(300); + userTransactionManager.setForceShutdown(true); + return userTransactionManager; + } + + @Bean + public JtaTransactionManager transactionManager() throws SystemException { + JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(); + jtaTransactionManager.setTransactionManager(userTransactionManager()); + jtaTransactionManager.setUserTransaction(userTransactionManager()); + return jtaTransactionManager; + } + + @Bean + public Application application() { + return new Application(); + } + +} \ No newline at end of file diff --git a/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/Inventory.java b/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/Inventory.java new file mode 100644 index 0000000000..999879218c --- /dev/null +++ b/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/Inventory.java @@ -0,0 +1,31 @@ +package com.baeldung.atomikos.spring.jpa.inventory; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name = "INVENTORY") +public class Inventory { + + @Id + private String productId; + private Long balance; + + public String getProductId() { + return productId; + } + + public void setProductId(String productId) { + this.productId = productId; + } + + public Long getBalance() { + return balance; + } + + public void setBalance(Long balance) { + this.balance = balance; + } + +} diff --git a/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/InventoryConfig.java b/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/InventoryConfig.java new file mode 100644 index 0000000000..5301ad6ff2 --- /dev/null +++ b/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/InventoryConfig.java @@ -0,0 +1,53 @@ +package com.baeldung.atomikos.spring.jpa.inventory; + +import java.util.Properties; + +import javax.persistence.EntityManagerFactory; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; + +import com.atomikos.jdbc.AtomikosDataSourceBean; + +@Configuration +@EnableJpaRepositories(basePackages = "com.baeldung.atomikos.spring.jpa.inventory", entityManagerFactoryRef = "inventoryEntityManager", transactionManagerRef = "transactionManager") +public class InventoryConfig { + + @Bean(initMethod = "init", destroyMethod = "close") + public AtomikosDataSourceBean inventoryDataSource() { + AtomikosDataSourceBean dataSource = new AtomikosDataSourceBean(); + dataSource.setLocalTransactionMode(true); + dataSource.setUniqueResourceName("db1"); + dataSource.setXaDataSourceClassName("org.apache.derby.jdbc.EmbeddedXADataSource"); + Properties xaProperties = new Properties(); + xaProperties.put("databaseName", "db1"); + xaProperties.put("createDatabase", "create"); + dataSource.setXaProperties(xaProperties); + dataSource.setPoolSize(10); + return dataSource; + } + + @Bean + public EntityManagerFactory inventoryEntityManager() { + HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); + factory.setJpaVendorAdapter(vendorAdapter); + factory.setPackagesToScan("com.baeldung.atomikos.spring.jpa.inventory"); + factory.setDataSource(inventoryDataSource()); + Properties jpaProperties = new Properties(); + //jpaProperties.put("hibernate.show_sql", "true"); + //jpaProperties.put("hibernate.format_sql", "true"); + jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.DerbyDialect"); + jpaProperties.put("hibernate.current_session_context_class", "jta"); + jpaProperties.put("javax.persistence.transactionType", "jta"); + jpaProperties.put("hibernate.transaction.manager_lookup_class", "com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"); + jpaProperties.put("hibernate.hbm2ddl.auto", "create-drop"); + factory.setJpaProperties(jpaProperties); + factory.afterPropertiesSet(); + return factory.getObject(); + } + +} \ No newline at end of file diff --git a/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/InventoryRepository.java b/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/InventoryRepository.java new file mode 100644 index 0000000000..c3868e51bf --- /dev/null +++ b/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/inventory/InventoryRepository.java @@ -0,0 +1,9 @@ +package com.baeldung.atomikos.spring.jpa.inventory; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface InventoryRepository extends JpaRepository { + +} diff --git a/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/Order.java b/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/Order.java new file mode 100644 index 0000000000..4b9ae2dd1d --- /dev/null +++ b/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/Order.java @@ -0,0 +1,42 @@ +package com.baeldung.atomikos.spring.jpa.order; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.validation.constraints.Max; + +@Entity +@Table(name = "ORDERS") +public class Order { + + @Id + private String orderId; + private String productId; + @Max(5) + private Long amount; + + public String getOrderId() { + return orderId; + } + + public void setOrderId(String orderId) { + this.orderId = orderId; + } + + public String getProductId() { + return productId; + } + + public void setProductId(String productId) { + this.productId = productId; + } + + public Long getAmount() { + return amount; + } + + public void setAmount(Long amount) { + this.amount = amount; + } + +} diff --git a/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/OrderConfig.java b/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/OrderConfig.java new file mode 100644 index 0000000000..b4274bb64c --- /dev/null +++ b/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/OrderConfig.java @@ -0,0 +1,53 @@ +package com.baeldung.atomikos.spring.jpa.order; + +import java.util.Properties; + +import javax.persistence.EntityManagerFactory; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; +import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; + +import com.atomikos.jdbc.AtomikosDataSourceBean; + +@Configuration +@EnableJpaRepositories(basePackages = "com.baeldung.atomikos.spring.jpa.order", entityManagerFactoryRef = "orderEntityManager", transactionManagerRef = "transactionManager") +public class OrderConfig { + + @Bean(initMethod = "init", destroyMethod = "close") + public AtomikosDataSourceBean orderDataSource() { + AtomikosDataSourceBean dataSource = new AtomikosDataSourceBean(); + dataSource.setLocalTransactionMode(true); + dataSource.setUniqueResourceName("db2"); + dataSource.setXaDataSourceClassName("org.apache.derby.jdbc.EmbeddedXADataSource"); + Properties xaProperties = new Properties(); + xaProperties.put("databaseName", "db2"); + xaProperties.put("createDatabase", "create"); + dataSource.setXaProperties(xaProperties); + dataSource.setPoolSize(10); + return dataSource; + } + + @Bean + public EntityManagerFactory orderEntityManager() { + HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); + LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); + factory.setJpaVendorAdapter(vendorAdapter); + factory.setPackagesToScan("com.baeldung.atomikos.spring.jpa.order"); + factory.setDataSource(orderDataSource()); + Properties jpaProperties = new Properties(); + //jpaProperties.put("hibernate.show_sql", "true"); + //jpaProperties.put("hibernate.format_sql", "true"); + jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.DerbyDialect"); + jpaProperties.put("hibernate.current_session_context_class", "jta"); + jpaProperties.put("javax.persistence.transactionType", "jta"); + jpaProperties.put("hibernate.transaction.manager_lookup_class", "com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"); + jpaProperties.put("hibernate.hbm2ddl.auto", "create-drop"); + factory.setJpaProperties(jpaProperties); + factory.afterPropertiesSet(); + return factory.getObject(); + } + +} \ No newline at end of file diff --git a/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/OrderRepository.java b/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/OrderRepository.java new file mode 100644 index 0000000000..2d5610ebca --- /dev/null +++ b/atomikos/src/main/java/com/baeldung/atomikos/spring/jpa/order/OrderRepository.java @@ -0,0 +1,9 @@ +package com.baeldung.atomikos.spring.jpa.order; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface OrderRepository extends JpaRepository { + +} diff --git a/atomikos/src/main/resources/logback.xml b/atomikos/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/atomikos/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/atomikos/src/main/resources/schema.sql b/atomikos/src/main/resources/schema.sql new file mode 100644 index 0000000000..5136ad1284 --- /dev/null +++ b/atomikos/src/main/resources/schema.sql @@ -0,0 +1,10 @@ +CREATE TABLE INVENTORY ( + productId VARCHAR PRIMARY KEY, + balance INT +); + +CREATE TABLE ORDERS ( + orderId VARCHAR PRIMARY KEY, + productId VARCHAR, + amount INT NOT NULL CHECK (amount <= 5) +); \ No newline at end of file diff --git a/atomikos/src/main/resources/transactions.properties b/atomikos/src/main/resources/transactions.properties new file mode 100644 index 0000000000..8e027032fa --- /dev/null +++ b/atomikos/src/main/resources/transactions.properties @@ -0,0 +1 @@ +com.atomikos.icatch.file=logs \ No newline at end of file diff --git a/atomikos/src/test/java/com/baeldung/atomikos/direct/ApplicationUnitTest.java b/atomikos/src/test/java/com/baeldung/atomikos/direct/ApplicationUnitTest.java new file mode 100644 index 0000000000..1a467807ba --- /dev/null +++ b/atomikos/src/test/java/com/baeldung/atomikos/direct/ApplicationUnitTest.java @@ -0,0 +1,118 @@ +package com.baeldung.atomikos.direct; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; +import java.util.UUID; + +import javax.sql.DataSource; + +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import com.atomikos.icatch.jta.UserTransactionImp; +import com.atomikos.jdbc.AtomikosDataSourceBean; + +public class ApplicationUnitTest { + + private static DataSource inventoryDataSource; + private static DataSource orderDataSource; + + private static String productId = UUID.randomUUID() + .toString(); + + @Test + @Ignore + public void testPlaceOrderSuccess() throws Exception { + int amount = 1; + long initialBalance = getBalance(inventoryDataSource, productId); + Application application = new Application(inventoryDataSource, orderDataSource); + application.placeOrder(productId, amount); + long finalBalance = getBalance(inventoryDataSource, productId); + assertEquals(initialBalance - amount, finalBalance); + } + + @Test + @Ignore + public void testPlaceOrderFailure() throws Exception { + int amount = 10; + long initialBalance = getBalance(inventoryDataSource, productId); + Application application = new Application(inventoryDataSource, orderDataSource); + application.placeOrder(productId, amount); + long finalBalance = getBalance(inventoryDataSource, productId); + assertEquals(initialBalance, finalBalance); + } + + @BeforeClass + public static void setUp() throws SQLException { + + inventoryDataSource = getDataSource("db1"); + orderDataSource = getDataSource("db2"); + Connection inventoryConnection = inventoryDataSource.getConnection(); + Connection orderConnection = orderDataSource.getConnection(); + String createInventoryTable = "create table Inventory ( " + " productId VARCHAR ( 100 ) PRIMARY KEY, balance INT )"; + String createInventoryRow = "insert into Inventory values ( '" + productId + "', 10000 )"; + Statement s1 = inventoryConnection.createStatement(); + try { + s1.executeUpdate(createInventoryTable); + } catch (Exception e) { + System.out.println("Inventory table exists"); + } + try { + s1.executeUpdate(createInventoryRow); + } catch (Exception e) { + System.out.println("Product row exists"); + } + s1.close(); + String createOrderTable = "create table Orders ( orderId VARCHAR ( 100 ) PRIMARY KEY, productId VARCHAR ( 100 ), amount INT NOT NULL CHECK (amount <= 5) )"; + Statement s2 = orderConnection.createStatement(); + try { + s2.executeUpdate(createOrderTable); + } catch (Exception e) { + System.out.println("Orders table exists"); + } + s2.close(); + inventoryConnection.close(); + orderConnection.close(); + } + + private static DataSource getDataSource(String db) { + + DataSource ds; + AtomikosDataSourceBean ads = new AtomikosDataSourceBean(); + ads.setXaDataSourceClassName("org.apache.derby.jdbc.EmbeddedXADataSource"); + Properties properties = new Properties(); + properties.put("databaseName", db); + properties.put("createDatabase", "create"); + ads.setXaProperties(properties); + ads.setUniqueResourceName(db); + ads.setPoolSize(10); // optional + ads.setBorrowConnectionTimeout(10); // optional + ds = ads; + return ds; + + } + + private static long getBalance(DataSource inventoryDataSource, String productId) throws Exception { + + UserTransactionImp utx = new UserTransactionImp(); + utx.begin(); + Connection inventoryConnection = inventoryDataSource.getConnection(); + Statement s1 = inventoryConnection.createStatement(); + String q1 = "select balance from Inventory where productId='" + productId + "'"; + ResultSet rs1 = s1.executeQuery(q1); + if (rs1 == null || !rs1.next()) + throw new Exception("Product not found: " + productId); + long balance = rs1.getLong(1); + inventoryConnection.close(); + utx.commit(); + return balance; + + } + +} diff --git a/atomikos/src/test/java/com/baeldung/atomikos/spring/ApplicationUnitTest.java b/atomikos/src/test/java/com/baeldung/atomikos/spring/ApplicationUnitTest.java new file mode 100644 index 0000000000..0c9392eac4 --- /dev/null +++ b/atomikos/src/test/java/com/baeldung/atomikos/spring/ApplicationUnitTest.java @@ -0,0 +1,108 @@ +package com.baeldung.atomikos.spring; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.UUID; + +import javax.sql.DataSource; + +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.baeldung.atomikos.spring.config.Config; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Config.class }) +public class ApplicationUnitTest { + + private static String productId = UUID.randomUUID() + .toString(); + + @Autowired + Application application; + + @Autowired + DataSource inventoryDataSource; + + @Autowired + DataSource orderDataSource; + + @Test + @Ignore + public void testPlaceOrderSuccess() throws Exception { + int amount = 1; + long initialBalance = getBalance(inventoryDataSource, productId); + application.placeOrder(productId, amount); + long finalBalance = getBalance(inventoryDataSource, productId); + assertEquals(initialBalance - amount, finalBalance); + } + + @Test + @Ignore + public void testPlaceOrderFailure() throws Exception { + int amount = 10; + long initialBalance = getBalance(inventoryDataSource, productId); + try { + application.placeOrder(productId, amount); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + long finalBalance = getBalance(inventoryDataSource, productId); + assertEquals(initialBalance, finalBalance); + } + + @Before + public void setUp() throws SQLException { + + Connection inventoryConnection = inventoryDataSource.getConnection(); + Connection orderConnection = orderDataSource.getConnection(); + String createInventoryTable = "create table Inventory ( " + " productId VARCHAR ( 100 ) PRIMARY KEY, balance INT )"; + String createInventoryRow = "insert into Inventory values ( '" + productId + "', 10000 )"; + Statement s1 = inventoryConnection.createStatement(); + try { + s1.executeUpdate(createInventoryTable); + } catch (Exception e) { + System.out.println("Inventory table exists"); + } + try { + s1.executeUpdate(createInventoryRow); + } catch (Exception e) { + System.out.println("Product row exists"); + } + s1.close(); + String createOrderTable = "create table Orders ( orderId VARCHAR ( 100 ) PRIMARY KEY, productId VARCHAR ( 100 ), amount INT NOT NULL CHECK (amount <= 5) )"; + Statement s2 = orderConnection.createStatement(); + try { + s2.executeUpdate(createOrderTable); + } catch (Exception e) { + System.out.println("Orders table exists"); + } + s2.close(); + inventoryConnection.close(); + orderConnection.close(); + } + + private static long getBalance(DataSource inventoryDataSource, String productId) throws Exception { + + Connection inventoryConnection = inventoryDataSource.getConnection(); + Statement s1 = inventoryConnection.createStatement(); + String q1 = "select balance from Inventory where productId='" + productId + "'"; + ResultSet rs1 = s1.executeQuery(q1); + if (rs1 == null || !rs1.next()) + throw new Exception("Product not found: " + productId); + long balance = rs1.getLong(1); + inventoryConnection.close(); + return balance; + + } + +} diff --git a/atomikos/src/test/java/com/baeldung/atomikos/spring/jpa/ApplicationUnitTest.java b/atomikos/src/test/java/com/baeldung/atomikos/spring/jpa/ApplicationUnitTest.java new file mode 100644 index 0000000000..e6a3c1982c --- /dev/null +++ b/atomikos/src/test/java/com/baeldung/atomikos/spring/jpa/ApplicationUnitTest.java @@ -0,0 +1,80 @@ +package com.baeldung.atomikos.spring.jpa; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.sql.SQLException; +import java.util.UUID; + +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.baeldung.atomikos.spring.jpa.config.Config; +import com.baeldung.atomikos.spring.jpa.inventory.Inventory; +import com.baeldung.atomikos.spring.jpa.inventory.InventoryConfig; +import com.baeldung.atomikos.spring.jpa.inventory.InventoryRepository; +import com.baeldung.atomikos.spring.jpa.order.OrderConfig; +import com.baeldung.atomikos.spring.jpa.order.OrderRepository; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = { Config.class, InventoryConfig.class, OrderConfig.class }) +public class ApplicationUnitTest { + + private static String productId = UUID.randomUUID() + .toString(); + + @Autowired + Application application; + + @Autowired + InventoryRepository inventoryRepository; + + @Autowired + OrderRepository orderRepository; + + @Test + @Ignore + public void testPlaceOrderSuccess() throws Exception { + int amount = 1; + long initialBalance = getBalance(inventoryRepository, productId); + application.placeOrder(productId, amount); + long finalBalance = getBalance(inventoryRepository, productId); + assertEquals(initialBalance - amount, finalBalance); + } + + @Test + @Ignore + public void testPlaceOrderFailure() throws Exception { + int amount = 10; + long initialBalance = getBalance(inventoryRepository, productId); + try { + application.placeOrder(productId, amount); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + long finalBalance = getBalance(inventoryRepository, productId); + assertEquals(initialBalance, finalBalance); + } + + @Before + public void setUp() throws SQLException { + + Inventory inventory = new Inventory(); + inventory.setProductId(productId); + inventory.setBalance(new Long(10000)); + inventoryRepository.save(inventory); + + } + + private static long getBalance(InventoryRepository inventoryRepository, String productId) throws Exception { + + return inventoryRepository.findOne(productId) + .getBalance(); + + } + +} diff --git a/atomikos/src/test/resources/logback.xml b/atomikos/src/test/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/atomikos/src/test/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/atomikos/src/test/resources/transactions.properties b/atomikos/src/test/resources/transactions.properties new file mode 100644 index 0000000000..8e027032fa --- /dev/null +++ b/atomikos/src/test/resources/transactions.properties @@ -0,0 +1 @@ +com.atomikos.icatch.file=logs \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8d4632fb3e..8a8b8e1b55 100644 --- a/pom.xml +++ b/pom.xml @@ -564,6 +564,8 @@ rxjava-libraries rxjava-observables rxjava-operators + + atomikos @@ -1073,6 +1075,8 @@ rxjava-libraries rxjava-observables rxjava-operators + + atomikos From 40f2f2ea8a431fa6e675ce6d31900f515ea55e31 Mon Sep 17 00:00:00 2001 From: omerfinger Date: Thu, 26 Mar 2020 12:29:05 +0200 Subject: [PATCH 186/503] BAEL-3926 - Java Map with case-insensitive keys --- .../core-java-collections-maps/pom.xml | 7 ++++ .../map/CaseInsensitiveMapUnitTest.java | 37 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 java-collections-maps/src/test/java/com/baeldung/map/CaseInsensitiveMapUnitTest.java diff --git a/core-java-modules/core-java-collections-maps/pom.xml b/core-java-modules/core-java-collections-maps/pom.xml index c0dd705c1c..b459213e17 100644 --- a/core-java-modules/core-java-collections-maps/pom.xml +++ b/core-java-modules/core-java-collections-maps/pom.xml @@ -26,10 +26,17 @@ ${assertj.version} test + + org.springframework + spring-core + ${spring.version} + test + 4.1 3.6.1 + 5.2.5.RELEASE diff --git a/java-collections-maps/src/test/java/com/baeldung/map/CaseInsensitiveMapUnitTest.java b/java-collections-maps/src/test/java/com/baeldung/map/CaseInsensitiveMapUnitTest.java new file mode 100644 index 0000000000..a2171aa326 --- /dev/null +++ b/java-collections-maps/src/test/java/com/baeldung/map/CaseInsensitiveMapUnitTest.java @@ -0,0 +1,37 @@ +package com.baeldung.map; + +import org.apache.commons.collections4.map.CaseInsensitiveMap; +import org.junit.Test; +import org.springframework.util.LinkedCaseInsensitiveMap; +import static org.junit.Assert.*; + +import java.util.TreeMap; + +public class CaseInsensitiveMapUnitTest { + @Test + public void givenCaseInsensitiveTreeMap_whenTwoEntriesAdded_thenSizeIsOne(){ + TreeMap treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + treeMap.put("abc", 1); + treeMap.put("ABC", 2); + + assertEquals(treeMap.size(), 1); + } + + @Test + public void givenCommonsCaseInsensitiveMap_whenSameEntryAdded_thenValueUpdated(){ + CaseInsensitiveMap commonsHashMap = new CaseInsensitiveMap<>(); + commonsHashMap.put("abc", 1); + commonsHashMap.put("ABC", 2); + + assertEquals(commonsHashMap.get("aBc"), (Integer)2); + } + + @Test + public void givenLinkedCaseInsensitiveMap_whenEntryRemoved_thenSizeIsZero(){ + LinkedCaseInsensitiveMap linkedHashMap = new LinkedCaseInsensitiveMap<>(); + linkedHashMap.put("abc", 3); + linkedHashMap.remove("aBC"); + + assertEquals(linkedHashMap.size(), 0); + } +} From 7d9d3c5f607260be7a466600bb09b9926a252770 Mon Sep 17 00:00:00 2001 From: omerfinger Date: Sat, 28 Mar 2020 17:50:20 +0300 Subject: [PATCH 187/503] new module has been added --- .../core-java-collections-maps/pom.xml | 7 ---- java-collections-maps-3/README.md | 8 ++++ java-collections-maps-3/pom.xml | 39 +++++++++++++++++++ .../CaseInsensitiveMapUnitTest.java | 7 ++-- pom.xml | 10 ++++- 5 files changed, 59 insertions(+), 12 deletions(-) create mode 100644 java-collections-maps-3/README.md create mode 100644 java-collections-maps-3/pom.xml rename {java-collections-maps/src/test/java/com/baeldung/map => java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys}/CaseInsensitiveMapUnitTest.java (84%) diff --git a/core-java-modules/core-java-collections-maps/pom.xml b/core-java-modules/core-java-collections-maps/pom.xml index b459213e17..c0dd705c1c 100644 --- a/core-java-modules/core-java-collections-maps/pom.xml +++ b/core-java-modules/core-java-collections-maps/pom.xml @@ -26,17 +26,10 @@ ${assertj.version} test - - org.springframework - spring-core - ${spring.version} - test - 4.1 3.6.1 - 5.2.5.RELEASE diff --git a/java-collections-maps-3/README.md b/java-collections-maps-3/README.md new file mode 100644 index 0000000000..9df666296b --- /dev/null +++ b/java-collections-maps-3/README.md @@ -0,0 +1,8 @@ +## Java Collections Cookbooks and Examples + +This module contains articles about Map data structures in Java. + +### Relevant Articles: +- [Java Map With Case-Insensitive Keys](https://www.baeldung.com/java-map-case-insensitive-keys) +- More articles: [[<-- prev>]](/../java-collections-maps) +- More articles: [[<-- prev>]](/../java-collections-maps-2) diff --git a/java-collections-maps-3/pom.xml b/java-collections-maps-3/pom.xml new file mode 100644 index 0000000000..0dd915c87b --- /dev/null +++ b/java-collections-maps-3/pom.xml @@ -0,0 +1,39 @@ + + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + 4.0.0 + java-collections-maps-3 + + + + org.springframework + spring-core + ${spring.version} + test + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + + + 4.1 + 3.6.1 + 5.2.5.RELEASE + + \ No newline at end of file diff --git a/java-collections-maps/src/test/java/com/baeldung/map/CaseInsensitiveMapUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java similarity index 84% rename from java-collections-maps/src/test/java/com/baeldung/map/CaseInsensitiveMapUnitTest.java rename to java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java index a2171aa326..b12080e368 100644 --- a/java-collections-maps/src/test/java/com/baeldung/map/CaseInsensitiveMapUnitTest.java +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java @@ -1,6 +1,7 @@ -package com.baeldung.map; +package com.baeldung.map.caseinsensitivekeys; import org.apache.commons.collections4.map.CaseInsensitiveMap; +import org.junit.Assert; import org.junit.Test; import org.springframework.util.LinkedCaseInsensitiveMap; import static org.junit.Assert.*; @@ -23,7 +24,7 @@ public class CaseInsensitiveMapUnitTest { commonsHashMap.put("abc", 1); commonsHashMap.put("ABC", 2); - assertEquals(commonsHashMap.get("aBc"), (Integer)2); + Assert.assertEquals(commonsHashMap.get("aBc"), (Integer)2); } @Test @@ -32,6 +33,6 @@ public class CaseInsensitiveMapUnitTest { linkedHashMap.put("abc", 3); linkedHashMap.remove("aBC"); - assertEquals(linkedHashMap.size(), 0); + Assert.assertEquals(linkedHashMap.size(), 0); } } diff --git a/pom.xml b/pom.xml index 8a8b8e1b55..cb0c0cf5d7 100644 --- a/pom.xml +++ b/pom.xml @@ -453,6 +453,9 @@ java-collections-conversions java-collections-conversions-2 + java-collections-maps + java-collections-maps-2 + java-collections-maps-3 javafx @@ -564,7 +567,7 @@ rxjava-libraries rxjava-observables rxjava-operators - + atomikos @@ -965,6 +968,9 @@ java-collections-conversions java-collections-conversions-2 + java-collections-maps + java-collections-maps-2 + java-collections-maps-3 javafx @@ -1075,7 +1081,7 @@ rxjava-libraries rxjava-observables rxjava-operators - + atomikos From 5137f8fa209d1a0c2f8847017cb959e0a6db69b1 Mon Sep 17 00:00:00 2001 From: omerfinger Date: Sat, 28 Mar 2020 17:58:34 +0300 Subject: [PATCH 188/503] tests has been added and split --- .../CaseInsensitiveMapUnitTest.java | 63 ++++++++++++++++++- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java index b12080e368..b3653a97c2 100644 --- a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java @@ -15,7 +15,37 @@ public class CaseInsensitiveMapUnitTest { treeMap.put("abc", 1); treeMap.put("ABC", 2); - assertEquals(treeMap.size(), 1); + assertEquals(1, treeMap.size()); + + } + + @Test + public void givenCommonsCaseInsensitiveMap_whenTwoEntriesAdded_thenSizeIsOne(){ + CaseInsensitiveMap commonsHashMap = new CaseInsensitiveMap<>(); + commonsHashMap.put("abc", 1); + commonsHashMap.put("ABC", 2); + + assertEquals(1, commonsHashMap.size()); + + } + + @Test + public void givenLinkedCaseInsensitiveMap_whenTwoEntriesAdded_thenSizeIsOne(){ + LinkedCaseInsensitiveMap linkedHashMap = new LinkedCaseInsensitiveMap<>(); + linkedHashMap.put("abc", 1); + linkedHashMap.put("ABC", 2); + + assertEquals(1, linkedHashMap.size()); + + } + + @Test + public void givenCaseInsensitiveTreeMap_whenSameEntryAdded_thenValueUpdated(){ + TreeMap treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + treeMap.put("abc", 1); + treeMap.put("ABC", 2); + + Assert.assertEquals((Integer)2, treeMap.get("aBc")); } @Test @@ -24,7 +54,34 @@ public class CaseInsensitiveMapUnitTest { commonsHashMap.put("abc", 1); commonsHashMap.put("ABC", 2); - Assert.assertEquals(commonsHashMap.get("aBc"), (Integer)2); + Assert.assertEquals((Integer)2, commonsHashMap.get("aBc")); + } + + @Test + public void givenLinkedCaseInsensitiveMap_whenSameEntryAdded_thenValueUpdated(){ + LinkedCaseInsensitiveMap linkedHashMap = new LinkedCaseInsensitiveMap<>(); + linkedHashMap.put("abc", 1); + linkedHashMap.put("ABC", 2); + + Assert.assertEquals((Integer)2, linkedHashMap.get("aBc")); + } + + @Test + public void givenCaseInsensitiveTreeMap_whenEntryRemoved_thenSizeIsZero(){ + TreeMap treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + treeMap.put("abc", 3); + treeMap.remove("aBC"); + + Assert.assertEquals(0, treeMap.size()); + } + + @Test + public void givenCommonsCaseInsensitiveMap_whenEntryRemoved_thenSizeIsZero(){ + CaseInsensitiveMap commonsHashMap = new CaseInsensitiveMap<>(); + commonsHashMap.put("abc", 3); + commonsHashMap.remove("aBC"); + + Assert.assertEquals(0, commonsHashMap.size()); } @Test @@ -33,6 +90,6 @@ public class CaseInsensitiveMapUnitTest { linkedHashMap.put("abc", 3); linkedHashMap.remove("aBC"); - Assert.assertEquals(linkedHashMap.size(), 0); + Assert.assertEquals(0, linkedHashMap.size()); } } From 9fc999311cdc4fa83b733631a4213b48728cb9d7 Mon Sep 17 00:00:00 2001 From: omerfinger Date: Sat, 28 Mar 2020 22:41:07 +0300 Subject: [PATCH 189/503] tests has been added and split --- java-collections-maps-3/README.md | 2 +- .../CaseInsensitiveMapUnitTest.java | 29 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/java-collections-maps-3/README.md b/java-collections-maps-3/README.md index 9df666296b..ab6a37d00c 100644 --- a/java-collections-maps-3/README.md +++ b/java-collections-maps-3/README.md @@ -3,6 +3,6 @@ This module contains articles about Map data structures in Java. ### Relevant Articles: -- [Java Map With Case-Insensitive Keys](https://www.baeldung.com/java-map-case-insensitive-keys) +- [Java Map With Case-Insensitive Keys](https://www.baeldung.com/java-map-with-case-insensitive-keys/) - More articles: [[<-- prev>]](/../java-collections-maps) - More articles: [[<-- prev>]](/../java-collections-maps-2) diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java index b3653a97c2..82feef869a 100644 --- a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java @@ -1,17 +1,16 @@ package com.baeldung.map.caseinsensitivekeys; import org.apache.commons.collections4.map.CaseInsensitiveMap; -import org.junit.Assert; import org.junit.Test; import org.springframework.util.LinkedCaseInsensitiveMap; -import static org.junit.Assert.*; - +import java.util.Map; import java.util.TreeMap; +import static org.junit.Assert.*; public class CaseInsensitiveMapUnitTest { @Test public void givenCaseInsensitiveTreeMap_whenTwoEntriesAdded_thenSizeIsOne(){ - TreeMap treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + Map treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); treeMap.put("abc", 1); treeMap.put("ABC", 2); @@ -21,7 +20,7 @@ public class CaseInsensitiveMapUnitTest { @Test public void givenCommonsCaseInsensitiveMap_whenTwoEntriesAdded_thenSizeIsOne(){ - CaseInsensitiveMap commonsHashMap = new CaseInsensitiveMap<>(); + Map commonsHashMap = new CaseInsensitiveMap<>(); commonsHashMap.put("abc", 1); commonsHashMap.put("ABC", 2); @@ -41,20 +40,20 @@ public class CaseInsensitiveMapUnitTest { @Test public void givenCaseInsensitiveTreeMap_whenSameEntryAdded_thenValueUpdated(){ - TreeMap treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + Map treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); treeMap.put("abc", 1); treeMap.put("ABC", 2); - Assert.assertEquals((Integer)2, treeMap.get("aBc")); + assertEquals((Integer)2, treeMap.get("aBc")); } @Test public void givenCommonsCaseInsensitiveMap_whenSameEntryAdded_thenValueUpdated(){ - CaseInsensitiveMap commonsHashMap = new CaseInsensitiveMap<>(); + Map commonsHashMap = new CaseInsensitiveMap<>(); commonsHashMap.put("abc", 1); commonsHashMap.put("ABC", 2); - Assert.assertEquals((Integer)2, commonsHashMap.get("aBc")); + assertEquals((Integer)2, commonsHashMap.get("aBc")); } @Test @@ -63,25 +62,25 @@ public class CaseInsensitiveMapUnitTest { linkedHashMap.put("abc", 1); linkedHashMap.put("ABC", 2); - Assert.assertEquals((Integer)2, linkedHashMap.get("aBc")); + assertEquals((Integer)2, linkedHashMap.get("aBc")); } @Test public void givenCaseInsensitiveTreeMap_whenEntryRemoved_thenSizeIsZero(){ - TreeMap treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + Map treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); treeMap.put("abc", 3); treeMap.remove("aBC"); - Assert.assertEquals(0, treeMap.size()); + assertEquals(0, treeMap.size()); } @Test public void givenCommonsCaseInsensitiveMap_whenEntryRemoved_thenSizeIsZero(){ - CaseInsensitiveMap commonsHashMap = new CaseInsensitiveMap<>(); + Map commonsHashMap = new CaseInsensitiveMap<>(); commonsHashMap.put("abc", 3); commonsHashMap.remove("aBC"); - Assert.assertEquals(0, commonsHashMap.size()); + assertEquals(0, commonsHashMap.size()); } @Test @@ -90,6 +89,6 @@ public class CaseInsensitiveMapUnitTest { linkedHashMap.put("abc", 3); linkedHashMap.remove("aBC"); - Assert.assertEquals(0, linkedHashMap.size()); + assertEquals(0, linkedHashMap.size()); } } From 640f8ce5d28cc78265d13e2f957895e36c7a719c Mon Sep 17 00:00:00 2001 From: omerfinger Date: Sat, 28 Mar 2020 22:50:07 +0300 Subject: [PATCH 190/503] varius get cases --- .../map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java index 82feef869a..60dd1da9c0 100644 --- a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java @@ -45,6 +45,7 @@ public class CaseInsensitiveMapUnitTest { treeMap.put("ABC", 2); assertEquals((Integer)2, treeMap.get("aBc")); + assertEquals((Integer)2, treeMap.get("ABc")); } @Test @@ -54,6 +55,7 @@ public class CaseInsensitiveMapUnitTest { commonsHashMap.put("ABC", 2); assertEquals((Integer)2, commonsHashMap.get("aBc")); + assertEquals((Integer)2, commonsHashMap.get("ABc")); } @Test @@ -63,6 +65,7 @@ public class CaseInsensitiveMapUnitTest { linkedHashMap.put("ABC", 2); assertEquals((Integer)2, linkedHashMap.get("aBc")); + assertEquals((Integer)2, linkedHashMap.get("ABc")); } @Test From c2e37ce399ab221298a7914275a146c8ce23fb68 Mon Sep 17 00:00:00 2001 From: omerfinger Date: Mon, 30 Mar 2020 13:28:29 +0300 Subject: [PATCH 191/503] changed README, assert has changed --- java-collections-maps-3/README.md | 2 +- .../CaseInsensitiveMapUnitTest.java | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/java-collections-maps-3/README.md b/java-collections-maps-3/README.md index ab6a37d00c..ed68eb00a0 100644 --- a/java-collections-maps-3/README.md +++ b/java-collections-maps-3/README.md @@ -3,6 +3,6 @@ This module contains articles about Map data structures in Java. ### Relevant Articles: -- [Java Map With Case-Insensitive Keys](https://www.baeldung.com/java-map-with-case-insensitive-keys/) + - More articles: [[<-- prev>]](/../java-collections-maps) - More articles: [[<-- prev>]](/../java-collections-maps-2) diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java index 60dd1da9c0..37d9af7535 100644 --- a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java @@ -25,7 +25,6 @@ public class CaseInsensitiveMapUnitTest { commonsHashMap.put("ABC", 2); assertEquals(1, commonsHashMap.size()); - } @Test @@ -35,7 +34,6 @@ public class CaseInsensitiveMapUnitTest { linkedHashMap.put("ABC", 2); assertEquals(1, linkedHashMap.size()); - } @Test @@ -44,8 +42,8 @@ public class CaseInsensitiveMapUnitTest { treeMap.put("abc", 1); treeMap.put("ABC", 2); - assertEquals((Integer)2, treeMap.get("aBc")); - assertEquals((Integer)2, treeMap.get("ABc")); + assertEquals(2, treeMap.get("aBc").intValue()); + assertEquals(2, treeMap.get("ABc").intValue()); } @Test @@ -54,8 +52,8 @@ public class CaseInsensitiveMapUnitTest { commonsHashMap.put("abc", 1); commonsHashMap.put("ABC", 2); - assertEquals((Integer)2, commonsHashMap.get("aBc")); - assertEquals((Integer)2, commonsHashMap.get("ABc")); + assertEquals(2, commonsHashMap.get("aBc").intValue()); + assertEquals(2, commonsHashMap.get("ABc").intValue()); } @Test @@ -64,8 +62,8 @@ public class CaseInsensitiveMapUnitTest { linkedHashMap.put("abc", 1); linkedHashMap.put("ABC", 2); - assertEquals((Integer)2, linkedHashMap.get("aBc")); - assertEquals((Integer)2, linkedHashMap.get("ABc")); + assertEquals(2, linkedHashMap.get("aBc").intValue()); + assertEquals(2, linkedHashMap.get("ABc").intValue()); } @Test From 46843866bd569096bed78d1d261a82363ada9ff2 Mon Sep 17 00:00:00 2001 From: omerfinger Date: Thu, 2 Apr 2020 10:06:43 +0300 Subject: [PATCH 192/503] changed LinkedHashMap to Map interface --- .../map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java index 37d9af7535..c64738a266 100644 --- a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java @@ -29,7 +29,7 @@ public class CaseInsensitiveMapUnitTest { @Test public void givenLinkedCaseInsensitiveMap_whenTwoEntriesAdded_thenSizeIsOne(){ - LinkedCaseInsensitiveMap linkedHashMap = new LinkedCaseInsensitiveMap<>(); + Map linkedHashMap = new LinkedCaseInsensitiveMap<>(); linkedHashMap.put("abc", 1); linkedHashMap.put("ABC", 2); @@ -58,7 +58,7 @@ public class CaseInsensitiveMapUnitTest { @Test public void givenLinkedCaseInsensitiveMap_whenSameEntryAdded_thenValueUpdated(){ - LinkedCaseInsensitiveMap linkedHashMap = new LinkedCaseInsensitiveMap<>(); + Map linkedHashMap = new LinkedCaseInsensitiveMap<>(); linkedHashMap.put("abc", 1); linkedHashMap.put("ABC", 2); @@ -86,7 +86,7 @@ public class CaseInsensitiveMapUnitTest { @Test public void givenLinkedCaseInsensitiveMap_whenEntryRemoved_thenSizeIsZero(){ - LinkedCaseInsensitiveMap linkedHashMap = new LinkedCaseInsensitiveMap<>(); + Map linkedHashMap = new LinkedCaseInsensitiveMap<>(); linkedHashMap.put("abc", 3); linkedHashMap.remove("aBC"); From 73892202d1aacee43417e413ba14a1ba3b90b67b Mon Sep 17 00:00:00 2001 From: omerfinger Date: Thu, 2 Apr 2020 12:18:03 +0300 Subject: [PATCH 193/503] changed LinkedHashMap to Map interface --- .../map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java index c64738a266..833807c692 100644 --- a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java @@ -15,7 +15,6 @@ public class CaseInsensitiveMapUnitTest { treeMap.put("ABC", 2); assertEquals(1, treeMap.size()); - } @Test From db989e2322d3214326c3b5b316d566e0260175bb Mon Sep 17 00:00:00 2001 From: omerfinger <43134354+omerfinger@users.noreply.github.com> Date: Wed, 8 Apr 2020 12:12:26 +0300 Subject: [PATCH 194/503] Revert to original pom settings --- java-collections-maps-3/pom.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/java-collections-maps-3/pom.xml b/java-collections-maps-3/pom.xml index 0dd915c87b..a397eaa033 100644 --- a/java-collections-maps-3/pom.xml +++ b/java-collections-maps-3/pom.xml @@ -8,9 +8,13 @@ 0.0.1-SNAPSHOT ../parent-java + 4.0.0 java-collections-maps-3 - + 0.1.0-SNAPSHOT + java-collections-maps-3 + jar + org.springframework @@ -36,4 +40,4 @@ 3.6.1 5.2.5.RELEASE - \ No newline at end of file + From 0b2e7e9f7c7089329e783fe3e096fe74cfe4767c Mon Sep 17 00:00:00 2001 From: omerfinger Date: Thu, 26 Mar 2020 12:29:05 +0200 Subject: [PATCH 195/503] BAEL-3926 - Java Map with case-insensitive keys --- .../core-java-collections-maps/pom.xml | 7 ++++ .../map/CaseInsensitiveMapUnitTest.java | 37 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 java-collections-maps/src/test/java/com/baeldung/map/CaseInsensitiveMapUnitTest.java diff --git a/core-java-modules/core-java-collections-maps/pom.xml b/core-java-modules/core-java-collections-maps/pom.xml index c0dd705c1c..b459213e17 100644 --- a/core-java-modules/core-java-collections-maps/pom.xml +++ b/core-java-modules/core-java-collections-maps/pom.xml @@ -26,10 +26,17 @@ ${assertj.version} test + + org.springframework + spring-core + ${spring.version} + test + 4.1 3.6.1 + 5.2.5.RELEASE diff --git a/java-collections-maps/src/test/java/com/baeldung/map/CaseInsensitiveMapUnitTest.java b/java-collections-maps/src/test/java/com/baeldung/map/CaseInsensitiveMapUnitTest.java new file mode 100644 index 0000000000..a2171aa326 --- /dev/null +++ b/java-collections-maps/src/test/java/com/baeldung/map/CaseInsensitiveMapUnitTest.java @@ -0,0 +1,37 @@ +package com.baeldung.map; + +import org.apache.commons.collections4.map.CaseInsensitiveMap; +import org.junit.Test; +import org.springframework.util.LinkedCaseInsensitiveMap; +import static org.junit.Assert.*; + +import java.util.TreeMap; + +public class CaseInsensitiveMapUnitTest { + @Test + public void givenCaseInsensitiveTreeMap_whenTwoEntriesAdded_thenSizeIsOne(){ + TreeMap treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + treeMap.put("abc", 1); + treeMap.put("ABC", 2); + + assertEquals(treeMap.size(), 1); + } + + @Test + public void givenCommonsCaseInsensitiveMap_whenSameEntryAdded_thenValueUpdated(){ + CaseInsensitiveMap commonsHashMap = new CaseInsensitiveMap<>(); + commonsHashMap.put("abc", 1); + commonsHashMap.put("ABC", 2); + + assertEquals(commonsHashMap.get("aBc"), (Integer)2); + } + + @Test + public void givenLinkedCaseInsensitiveMap_whenEntryRemoved_thenSizeIsZero(){ + LinkedCaseInsensitiveMap linkedHashMap = new LinkedCaseInsensitiveMap<>(); + linkedHashMap.put("abc", 3); + linkedHashMap.remove("aBC"); + + assertEquals(linkedHashMap.size(), 0); + } +} From b2bc2dc00408c6d1fd223e73258f03a5aac4d5cf Mon Sep 17 00:00:00 2001 From: omerfinger Date: Sat, 28 Mar 2020 17:50:20 +0300 Subject: [PATCH 196/503] new module has been added --- .../core-java-collections-maps/pom.xml | 7 -- java-collections-maps-3/pom.xml | 4 +- .../CaseInsensitiveMapUnitTest.java | 74 +++---------------- .../map/CaseInsensitiveMapUnitTest.java | 37 ---------- 4 files changed, 11 insertions(+), 111 deletions(-) delete mode 100644 java-collections-maps/src/test/java/com/baeldung/map/CaseInsensitiveMapUnitTest.java diff --git a/core-java-modules/core-java-collections-maps/pom.xml b/core-java-modules/core-java-collections-maps/pom.xml index b459213e17..c0dd705c1c 100644 --- a/core-java-modules/core-java-collections-maps/pom.xml +++ b/core-java-modules/core-java-collections-maps/pom.xml @@ -26,17 +26,10 @@ ${assertj.version} test - - org.springframework - spring-core - ${spring.version} - test - 4.1 3.6.1 - 5.2.5.RELEASE diff --git a/java-collections-maps-3/pom.xml b/java-collections-maps-3/pom.xml index a397eaa033..3888623a7f 100644 --- a/java-collections-maps-3/pom.xml +++ b/java-collections-maps-3/pom.xml @@ -8,13 +8,13 @@ 0.0.1-SNAPSHOT ../parent-java - + 4.0.0 java-collections-maps-3 0.1.0-SNAPSHOT java-collections-maps-3 jar - + org.springframework diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java index 833807c692..b12080e368 100644 --- a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java @@ -1,94 +1,38 @@ package com.baeldung.map.caseinsensitivekeys; import org.apache.commons.collections4.map.CaseInsensitiveMap; +import org.junit.Assert; import org.junit.Test; import org.springframework.util.LinkedCaseInsensitiveMap; -import java.util.Map; -import java.util.TreeMap; import static org.junit.Assert.*; +import java.util.TreeMap; + public class CaseInsensitiveMapUnitTest { @Test public void givenCaseInsensitiveTreeMap_whenTwoEntriesAdded_thenSizeIsOne(){ - Map treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + TreeMap treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); treeMap.put("abc", 1); treeMap.put("ABC", 2); - assertEquals(1, treeMap.size()); - } - - @Test - public void givenCommonsCaseInsensitiveMap_whenTwoEntriesAdded_thenSizeIsOne(){ - Map commonsHashMap = new CaseInsensitiveMap<>(); - commonsHashMap.put("abc", 1); - commonsHashMap.put("ABC", 2); - - assertEquals(1, commonsHashMap.size()); - } - - @Test - public void givenLinkedCaseInsensitiveMap_whenTwoEntriesAdded_thenSizeIsOne(){ - Map linkedHashMap = new LinkedCaseInsensitiveMap<>(); - linkedHashMap.put("abc", 1); - linkedHashMap.put("ABC", 2); - - assertEquals(1, linkedHashMap.size()); - } - - @Test - public void givenCaseInsensitiveTreeMap_whenSameEntryAdded_thenValueUpdated(){ - Map treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); - treeMap.put("abc", 1); - treeMap.put("ABC", 2); - - assertEquals(2, treeMap.get("aBc").intValue()); - assertEquals(2, treeMap.get("ABc").intValue()); + assertEquals(treeMap.size(), 1); } @Test public void givenCommonsCaseInsensitiveMap_whenSameEntryAdded_thenValueUpdated(){ - Map commonsHashMap = new CaseInsensitiveMap<>(); + CaseInsensitiveMap commonsHashMap = new CaseInsensitiveMap<>(); commonsHashMap.put("abc", 1); commonsHashMap.put("ABC", 2); - assertEquals(2, commonsHashMap.get("aBc").intValue()); - assertEquals(2, commonsHashMap.get("ABc").intValue()); - } - - @Test - public void givenLinkedCaseInsensitiveMap_whenSameEntryAdded_thenValueUpdated(){ - Map linkedHashMap = new LinkedCaseInsensitiveMap<>(); - linkedHashMap.put("abc", 1); - linkedHashMap.put("ABC", 2); - - assertEquals(2, linkedHashMap.get("aBc").intValue()); - assertEquals(2, linkedHashMap.get("ABc").intValue()); - } - - @Test - public void givenCaseInsensitiveTreeMap_whenEntryRemoved_thenSizeIsZero(){ - Map treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); - treeMap.put("abc", 3); - treeMap.remove("aBC"); - - assertEquals(0, treeMap.size()); - } - - @Test - public void givenCommonsCaseInsensitiveMap_whenEntryRemoved_thenSizeIsZero(){ - Map commonsHashMap = new CaseInsensitiveMap<>(); - commonsHashMap.put("abc", 3); - commonsHashMap.remove("aBC"); - - assertEquals(0, commonsHashMap.size()); + Assert.assertEquals(commonsHashMap.get("aBc"), (Integer)2); } @Test public void givenLinkedCaseInsensitiveMap_whenEntryRemoved_thenSizeIsZero(){ - Map linkedHashMap = new LinkedCaseInsensitiveMap<>(); + LinkedCaseInsensitiveMap linkedHashMap = new LinkedCaseInsensitiveMap<>(); linkedHashMap.put("abc", 3); linkedHashMap.remove("aBC"); - assertEquals(0, linkedHashMap.size()); + Assert.assertEquals(linkedHashMap.size(), 0); } } diff --git a/java-collections-maps/src/test/java/com/baeldung/map/CaseInsensitiveMapUnitTest.java b/java-collections-maps/src/test/java/com/baeldung/map/CaseInsensitiveMapUnitTest.java deleted file mode 100644 index a2171aa326..0000000000 --- a/java-collections-maps/src/test/java/com/baeldung/map/CaseInsensitiveMapUnitTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.baeldung.map; - -import org.apache.commons.collections4.map.CaseInsensitiveMap; -import org.junit.Test; -import org.springframework.util.LinkedCaseInsensitiveMap; -import static org.junit.Assert.*; - -import java.util.TreeMap; - -public class CaseInsensitiveMapUnitTest { - @Test - public void givenCaseInsensitiveTreeMap_whenTwoEntriesAdded_thenSizeIsOne(){ - TreeMap treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); - treeMap.put("abc", 1); - treeMap.put("ABC", 2); - - assertEquals(treeMap.size(), 1); - } - - @Test - public void givenCommonsCaseInsensitiveMap_whenSameEntryAdded_thenValueUpdated(){ - CaseInsensitiveMap commonsHashMap = new CaseInsensitiveMap<>(); - commonsHashMap.put("abc", 1); - commonsHashMap.put("ABC", 2); - - assertEquals(commonsHashMap.get("aBc"), (Integer)2); - } - - @Test - public void givenLinkedCaseInsensitiveMap_whenEntryRemoved_thenSizeIsZero(){ - LinkedCaseInsensitiveMap linkedHashMap = new LinkedCaseInsensitiveMap<>(); - linkedHashMap.put("abc", 3); - linkedHashMap.remove("aBC"); - - assertEquals(linkedHashMap.size(), 0); - } -} From da97125e2068af38e4e3dd53ba196a644b195aa4 Mon Sep 17 00:00:00 2001 From: omerfinger Date: Sat, 28 Mar 2020 17:58:34 +0300 Subject: [PATCH 197/503] tests has been added and split --- .../CaseInsensitiveMapUnitTest.java | 63 ++++++++++++++++++- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java index b12080e368..b3653a97c2 100644 --- a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java @@ -15,7 +15,37 @@ public class CaseInsensitiveMapUnitTest { treeMap.put("abc", 1); treeMap.put("ABC", 2); - assertEquals(treeMap.size(), 1); + assertEquals(1, treeMap.size()); + + } + + @Test + public void givenCommonsCaseInsensitiveMap_whenTwoEntriesAdded_thenSizeIsOne(){ + CaseInsensitiveMap commonsHashMap = new CaseInsensitiveMap<>(); + commonsHashMap.put("abc", 1); + commonsHashMap.put("ABC", 2); + + assertEquals(1, commonsHashMap.size()); + + } + + @Test + public void givenLinkedCaseInsensitiveMap_whenTwoEntriesAdded_thenSizeIsOne(){ + LinkedCaseInsensitiveMap linkedHashMap = new LinkedCaseInsensitiveMap<>(); + linkedHashMap.put("abc", 1); + linkedHashMap.put("ABC", 2); + + assertEquals(1, linkedHashMap.size()); + + } + + @Test + public void givenCaseInsensitiveTreeMap_whenSameEntryAdded_thenValueUpdated(){ + TreeMap treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + treeMap.put("abc", 1); + treeMap.put("ABC", 2); + + Assert.assertEquals((Integer)2, treeMap.get("aBc")); } @Test @@ -24,7 +54,34 @@ public class CaseInsensitiveMapUnitTest { commonsHashMap.put("abc", 1); commonsHashMap.put("ABC", 2); - Assert.assertEquals(commonsHashMap.get("aBc"), (Integer)2); + Assert.assertEquals((Integer)2, commonsHashMap.get("aBc")); + } + + @Test + public void givenLinkedCaseInsensitiveMap_whenSameEntryAdded_thenValueUpdated(){ + LinkedCaseInsensitiveMap linkedHashMap = new LinkedCaseInsensitiveMap<>(); + linkedHashMap.put("abc", 1); + linkedHashMap.put("ABC", 2); + + Assert.assertEquals((Integer)2, linkedHashMap.get("aBc")); + } + + @Test + public void givenCaseInsensitiveTreeMap_whenEntryRemoved_thenSizeIsZero(){ + TreeMap treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + treeMap.put("abc", 3); + treeMap.remove("aBC"); + + Assert.assertEquals(0, treeMap.size()); + } + + @Test + public void givenCommonsCaseInsensitiveMap_whenEntryRemoved_thenSizeIsZero(){ + CaseInsensitiveMap commonsHashMap = new CaseInsensitiveMap<>(); + commonsHashMap.put("abc", 3); + commonsHashMap.remove("aBC"); + + Assert.assertEquals(0, commonsHashMap.size()); } @Test @@ -33,6 +90,6 @@ public class CaseInsensitiveMapUnitTest { linkedHashMap.put("abc", 3); linkedHashMap.remove("aBC"); - Assert.assertEquals(linkedHashMap.size(), 0); + Assert.assertEquals(0, linkedHashMap.size()); } } From ac21dcc346f1c3debe4b8bd370f937c5aa6f7ba0 Mon Sep 17 00:00:00 2001 From: omerfinger Date: Sat, 28 Mar 2020 22:41:07 +0300 Subject: [PATCH 198/503] tests has been added and split --- .../CaseInsensitiveMapUnitTest.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java index b3653a97c2..82feef869a 100644 --- a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java @@ -1,17 +1,16 @@ package com.baeldung.map.caseinsensitivekeys; import org.apache.commons.collections4.map.CaseInsensitiveMap; -import org.junit.Assert; import org.junit.Test; import org.springframework.util.LinkedCaseInsensitiveMap; -import static org.junit.Assert.*; - +import java.util.Map; import java.util.TreeMap; +import static org.junit.Assert.*; public class CaseInsensitiveMapUnitTest { @Test public void givenCaseInsensitiveTreeMap_whenTwoEntriesAdded_thenSizeIsOne(){ - TreeMap treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + Map treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); treeMap.put("abc", 1); treeMap.put("ABC", 2); @@ -21,7 +20,7 @@ public class CaseInsensitiveMapUnitTest { @Test public void givenCommonsCaseInsensitiveMap_whenTwoEntriesAdded_thenSizeIsOne(){ - CaseInsensitiveMap commonsHashMap = new CaseInsensitiveMap<>(); + Map commonsHashMap = new CaseInsensitiveMap<>(); commonsHashMap.put("abc", 1); commonsHashMap.put("ABC", 2); @@ -41,20 +40,20 @@ public class CaseInsensitiveMapUnitTest { @Test public void givenCaseInsensitiveTreeMap_whenSameEntryAdded_thenValueUpdated(){ - TreeMap treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + Map treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); treeMap.put("abc", 1); treeMap.put("ABC", 2); - Assert.assertEquals((Integer)2, treeMap.get("aBc")); + assertEquals((Integer)2, treeMap.get("aBc")); } @Test public void givenCommonsCaseInsensitiveMap_whenSameEntryAdded_thenValueUpdated(){ - CaseInsensitiveMap commonsHashMap = new CaseInsensitiveMap<>(); + Map commonsHashMap = new CaseInsensitiveMap<>(); commonsHashMap.put("abc", 1); commonsHashMap.put("ABC", 2); - Assert.assertEquals((Integer)2, commonsHashMap.get("aBc")); + assertEquals((Integer)2, commonsHashMap.get("aBc")); } @Test @@ -63,25 +62,25 @@ public class CaseInsensitiveMapUnitTest { linkedHashMap.put("abc", 1); linkedHashMap.put("ABC", 2); - Assert.assertEquals((Integer)2, linkedHashMap.get("aBc")); + assertEquals((Integer)2, linkedHashMap.get("aBc")); } @Test public void givenCaseInsensitiveTreeMap_whenEntryRemoved_thenSizeIsZero(){ - TreeMap treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + Map treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); treeMap.put("abc", 3); treeMap.remove("aBC"); - Assert.assertEquals(0, treeMap.size()); + assertEquals(0, treeMap.size()); } @Test public void givenCommonsCaseInsensitiveMap_whenEntryRemoved_thenSizeIsZero(){ - CaseInsensitiveMap commonsHashMap = new CaseInsensitiveMap<>(); + Map commonsHashMap = new CaseInsensitiveMap<>(); commonsHashMap.put("abc", 3); commonsHashMap.remove("aBC"); - Assert.assertEquals(0, commonsHashMap.size()); + assertEquals(0, commonsHashMap.size()); } @Test @@ -90,6 +89,6 @@ public class CaseInsensitiveMapUnitTest { linkedHashMap.put("abc", 3); linkedHashMap.remove("aBC"); - Assert.assertEquals(0, linkedHashMap.size()); + assertEquals(0, linkedHashMap.size()); } } From dac08f02db475176443be050cc929b1c40699913 Mon Sep 17 00:00:00 2001 From: omerfinger Date: Sat, 28 Mar 2020 22:50:07 +0300 Subject: [PATCH 199/503] varius get cases --- .../map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java index 82feef869a..60dd1da9c0 100644 --- a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java @@ -45,6 +45,7 @@ public class CaseInsensitiveMapUnitTest { treeMap.put("ABC", 2); assertEquals((Integer)2, treeMap.get("aBc")); + assertEquals((Integer)2, treeMap.get("ABc")); } @Test @@ -54,6 +55,7 @@ public class CaseInsensitiveMapUnitTest { commonsHashMap.put("ABC", 2); assertEquals((Integer)2, commonsHashMap.get("aBc")); + assertEquals((Integer)2, commonsHashMap.get("ABc")); } @Test @@ -63,6 +65,7 @@ public class CaseInsensitiveMapUnitTest { linkedHashMap.put("ABC", 2); assertEquals((Integer)2, linkedHashMap.get("aBc")); + assertEquals((Integer)2, linkedHashMap.get("ABc")); } @Test From 22a94cd61c2b5f936e85aeecf6c52c7a5f9153d7 Mon Sep 17 00:00:00 2001 From: omerfinger Date: Mon, 30 Mar 2020 13:28:29 +0300 Subject: [PATCH 200/503] changed README, assert has changed --- .../CaseInsensitiveMapUnitTest.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java index 60dd1da9c0..37d9af7535 100644 --- a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java @@ -25,7 +25,6 @@ public class CaseInsensitiveMapUnitTest { commonsHashMap.put("ABC", 2); assertEquals(1, commonsHashMap.size()); - } @Test @@ -35,7 +34,6 @@ public class CaseInsensitiveMapUnitTest { linkedHashMap.put("ABC", 2); assertEquals(1, linkedHashMap.size()); - } @Test @@ -44,8 +42,8 @@ public class CaseInsensitiveMapUnitTest { treeMap.put("abc", 1); treeMap.put("ABC", 2); - assertEquals((Integer)2, treeMap.get("aBc")); - assertEquals((Integer)2, treeMap.get("ABc")); + assertEquals(2, treeMap.get("aBc").intValue()); + assertEquals(2, treeMap.get("ABc").intValue()); } @Test @@ -54,8 +52,8 @@ public class CaseInsensitiveMapUnitTest { commonsHashMap.put("abc", 1); commonsHashMap.put("ABC", 2); - assertEquals((Integer)2, commonsHashMap.get("aBc")); - assertEquals((Integer)2, commonsHashMap.get("ABc")); + assertEquals(2, commonsHashMap.get("aBc").intValue()); + assertEquals(2, commonsHashMap.get("ABc").intValue()); } @Test @@ -64,8 +62,8 @@ public class CaseInsensitiveMapUnitTest { linkedHashMap.put("abc", 1); linkedHashMap.put("ABC", 2); - assertEquals((Integer)2, linkedHashMap.get("aBc")); - assertEquals((Integer)2, linkedHashMap.get("ABc")); + assertEquals(2, linkedHashMap.get("aBc").intValue()); + assertEquals(2, linkedHashMap.get("ABc").intValue()); } @Test From 7848c39d7b634f6b90d3e2832429bfad5be311dd Mon Sep 17 00:00:00 2001 From: omerfinger Date: Thu, 2 Apr 2020 10:06:43 +0300 Subject: [PATCH 201/503] changed LinkedHashMap to Map interface --- .../map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java index 37d9af7535..c64738a266 100644 --- a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java @@ -29,7 +29,7 @@ public class CaseInsensitiveMapUnitTest { @Test public void givenLinkedCaseInsensitiveMap_whenTwoEntriesAdded_thenSizeIsOne(){ - LinkedCaseInsensitiveMap linkedHashMap = new LinkedCaseInsensitiveMap<>(); + Map linkedHashMap = new LinkedCaseInsensitiveMap<>(); linkedHashMap.put("abc", 1); linkedHashMap.put("ABC", 2); @@ -58,7 +58,7 @@ public class CaseInsensitiveMapUnitTest { @Test public void givenLinkedCaseInsensitiveMap_whenSameEntryAdded_thenValueUpdated(){ - LinkedCaseInsensitiveMap linkedHashMap = new LinkedCaseInsensitiveMap<>(); + Map linkedHashMap = new LinkedCaseInsensitiveMap<>(); linkedHashMap.put("abc", 1); linkedHashMap.put("ABC", 2); @@ -86,7 +86,7 @@ public class CaseInsensitiveMapUnitTest { @Test public void givenLinkedCaseInsensitiveMap_whenEntryRemoved_thenSizeIsZero(){ - LinkedCaseInsensitiveMap linkedHashMap = new LinkedCaseInsensitiveMap<>(); + Map linkedHashMap = new LinkedCaseInsensitiveMap<>(); linkedHashMap.put("abc", 3); linkedHashMap.remove("aBC"); From edb8e8b341e45de9c5aec23aedf309c3aeccec96 Mon Sep 17 00:00:00 2001 From: omerfinger Date: Thu, 2 Apr 2020 12:18:03 +0300 Subject: [PATCH 202/503] changed LinkedHashMap to Map interface --- .../map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java index c64738a266..833807c692 100644 --- a/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java +++ b/java-collections-maps-3/src/test/java/com/baeldung/map/caseinsensitivekeys/CaseInsensitiveMapUnitTest.java @@ -15,7 +15,6 @@ public class CaseInsensitiveMapUnitTest { treeMap.put("ABC", 2); assertEquals(1, treeMap.size()); - } @Test From 33d6f3853c64ad9df288e39508753402a9e262dc Mon Sep 17 00:00:00 2001 From: Aitor Cuesta Date: Sun, 12 Apr 2020 10:46:36 +0200 Subject: [PATCH 203/503] BAEL-3075 - Undo whitespaces from pom.xml. README.md is replaced with the original version --- persistence-modules/spring-boot-persistence-2/README.md | 2 +- persistence-modules/spring-boot-persistence-2/pom.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/persistence-modules/spring-boot-persistence-2/README.md b/persistence-modules/spring-boot-persistence-2/README.md index fac8b75615..5d171fb2ca 100644 --- a/persistence-modules/spring-boot-persistence-2/README.md +++ b/persistence-modules/spring-boot-persistence-2/README.md @@ -1,3 +1,3 @@ ### Relevant Articles: -- [Using JDBI with Spring Boot](https://www.baeldung.com/spring-boot-jdbi) \ No newline at end of file +- [Using JDBI with Spring Boot](https://www.baeldung.com/spring-boot-jdbi) diff --git a/persistence-modules/spring-boot-persistence-2/pom.xml b/persistence-modules/spring-boot-persistence-2/pom.xml index c1afededb0..fd7cc467f9 100644 --- a/persistence-modules/spring-boot-persistence-2/pom.xml +++ b/persistence-modules/spring-boot-persistence-2/pom.xml @@ -1,7 +1,7 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.baeldung.boot.persistence spring-boot-persistence-2 From 7930d2c72e6e33d163a475abc7166e02cafb2d89 Mon Sep 17 00:00:00 2001 From: omerfinger Date: Sun, 12 Apr 2020 11:48:00 +0300 Subject: [PATCH 204/503] rebase parent pom on upstream --- pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pom.xml b/pom.xml index cb0c0cf5d7..24d9fd1d0b 100644 --- a/pom.xml +++ b/pom.xml @@ -453,8 +453,6 @@ java-collections-conversions java-collections-conversions-2 - java-collections-maps - java-collections-maps-2 java-collections-maps-3 @@ -968,8 +966,6 @@ java-collections-conversions java-collections-conversions-2 - java-collections-maps - java-collections-maps-2 java-collections-maps-3 From a0dd4a537db8332ab8790b0ee0dca3e7a42c3e5f Mon Sep 17 00:00:00 2001 From: gindex Date: Sun, 12 Apr 2020 13:01:52 +0200 Subject: [PATCH 205/503] Revert README.md to 1acadab1 --- reactor-core/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/reactor-core/README.md b/reactor-core/README.md index f2dbd77981..e3cca35f86 100644 --- a/reactor-core/README.md +++ b/reactor-core/README.md @@ -7,4 +7,3 @@ This module contains articles about Reactor Core. - [Intro To Reactor Core](https://www.baeldung.com/reactor-core) - [Combining Publishers in Project Reactor](https://www.baeldung.com/reactor-combine-streams) - [Programmatically Creating Sequences with Project Reactor](https://www.baeldung.com/flux-sequences-reactor) -- [How To Get String From Mono In Reactive Java](http://baeldung.com/string-from-mono/) \ No newline at end of file From 07b5c1f01020dfbd7a3dfa17054f21347d451c65 Mon Sep 17 00:00:00 2001 From: Kirill Vlasov Date: Sun, 12 Apr 2020 16:16:36 +0500 Subject: [PATCH 206/503] Code review fixes --- ...tion.java => CustomLogoutApplication.java} | 8 +- .../customlogouthandler/MvcConfiguration.java | 30 ++-- .../services/UserCache.java | 24 ++-- .../customlogouthandler/user/UserUtils.java | 5 +- .../web/CustomLogoutHandler.java | 13 +- .../web/UserController.java | 10 +- .../CustomLogoutHandlerIntegrationTest.java | 132 +++++++++--------- .../application.properties | 6 +- 8 files changed, 119 insertions(+), 109 deletions(-) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/{LogoutDemoApplication.java => CustomLogoutApplication.java} (54%) diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/LogoutDemoApplication.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/CustomLogoutApplication.java similarity index 54% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/LogoutDemoApplication.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/CustomLogoutApplication.java index 027334dd6b..39d867b1f4 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/LogoutDemoApplication.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/CustomLogoutApplication.java @@ -4,10 +4,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -public class LogoutDemoApplication { +public class CustomLogoutApplication { - public static void main(String[] args) { - SpringApplication.run(LogoutDemoApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(CustomLogoutApplication.class, args); + } } diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/MvcConfiguration.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/MvcConfiguration.java index 36de049a31..3e17a7c397 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/MvcConfiguration.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/MvcConfiguration.java @@ -1,6 +1,7 @@ package com.baeldung.customlogouthandler; -import com.baeldung.customlogouthandler.web.CustomLogoutHandler; +import javax.sql.DataSource; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; @@ -11,7 +12,7 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler; -import javax.sql.DataSource; +import com.baeldung.customlogouthandler.web.CustomLogoutHandler; @Configuration @EnableWebSecurity @@ -25,27 +26,30 @@ public class MvcConfiguration extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { - http - .httpBasic().and() + http.httpBasic() + .and() .authorizeRequests() - .antMatchers(HttpMethod.GET, "/user/**").hasRole("USER") - .and() - .logout() + .antMatchers(HttpMethod.GET, "/user/**") + .hasRole("USER") + .and() + .logout() .logoutUrl("/user/logout") .addLogoutHandler(logoutHandler) .logoutSuccessHandler((new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK))) .permitAll() - .and() - .csrf().disable() - .formLogin().disable(); + .and() + .csrf() + .disable() + .formLogin() + .disable(); } @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.jdbcAuthentication() - .dataSource(dataSource) - .usersByUsernameQuery("select login, password, true from users where login=?") - .authoritiesByUsernameQuery("select login, role from users where login=?"); + .dataSource(dataSource) + .usersByUsernameQuery("select login, password, true from users where login=?") + .authoritiesByUsernameQuery("select login, role from users where login=?"); } } diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/services/UserCache.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/services/UserCache.java index 56c4d1e7c9..b86edc0dee 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/services/UserCache.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/services/UserCache.java @@ -1,12 +1,14 @@ package com.baeldung.customlogouthandler.services; -import com.baeldung.customlogouthandler.user.User; -import org.springframework.stereotype.Service; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; + +import org.springframework.stereotype.Service; + +import com.baeldung.customlogouthandler.user.User; @Service public class UserCache { @@ -16,18 +18,18 @@ public class UserCache { private final ConcurrentMap store = new ConcurrentHashMap<>(256); - public User getByLogin(String login) { - return store.computeIfAbsent(login, k -> entityManager.createQuery("from User where login=:login", User.class) - .setParameter("login", k) - .getSingleResult()); + public User getByUserName(String userName) { + return store.computeIfAbsent(userName, k -> entityManager.createQuery("from User where login=:login", User.class) + .setParameter("login", k) + .getSingleResult()); } - public void evictUser(String login) { - store.remove(login); + public void evictUser(String userName) { + store.remove(userName); } public int size() { - return this.store.size(); + return store.size(); } } diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/UserUtils.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/UserUtils.java index 195497f7ba..aa9a521b01 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/UserUtils.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/user/UserUtils.java @@ -5,8 +5,9 @@ import org.springframework.security.core.context.SecurityContextHolder; public class UserUtils { - public static String getAuthenticatedUserLogin() { - Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + public static String getAuthenticatedUserName() { + Authentication auth = SecurityContextHolder.getContext() + .getAuthentication(); return auth != null ? ((org.springframework.security.core.userdetails.User) auth.getPrincipal()).getUsername() : null; } diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/CustomLogoutHandler.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/CustomLogoutHandler.java index 2a335cd122..a89c9a570d 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/CustomLogoutHandler.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/CustomLogoutHandler.java @@ -1,13 +1,14 @@ package com.baeldung.customlogouthandler.web; -import com.baeldung.customlogouthandler.services.UserCache; -import com.baeldung.customlogouthandler.user.UserUtils; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.logout.LogoutHandler; import org.springframework.stereotype.Service; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import com.baeldung.customlogouthandler.services.UserCache; +import com.baeldung.customlogouthandler.user.UserUtils; @Service public class CustomLogoutHandler implements LogoutHandler { @@ -20,8 +21,8 @@ public class CustomLogoutHandler implements LogoutHandler { @Override public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { - String login = UserUtils.getAuthenticatedUserLogin(); - userCache.evictUser(login); + String userName = UserUtils.getAuthenticatedUserName(); + userCache.evictUser(userName); } } diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/UserController.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/UserController.java index 18cd8dda98..b2d332a1bb 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/UserController.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/web/UserController.java @@ -1,13 +1,13 @@ package com.baeldung.customlogouthandler.web; -import com.baeldung.customlogouthandler.services.UserCache; -import com.baeldung.customlogouthandler.user.User; -import com.baeldung.customlogouthandler.user.UserUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; +import com.baeldung.customlogouthandler.services.UserCache; +import com.baeldung.customlogouthandler.user.User; +import com.baeldung.customlogouthandler.user.UserUtils; @Controller @RequestMapping(path = "/user") @@ -22,8 +22,8 @@ public class UserController { @GetMapping(path = "/language") @ResponseBody public String getLanguage() { - String login = UserUtils.getAuthenticatedUserLogin(); - User user = userCache.getByLogin(login); + String userName = UserUtils.getAuthenticatedUserName(); + User user = userCache.getByUserName(userName); return user.getLanguage(); } diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/customlogouthandler/CustomLogoutHandlerIntegrationTest.java b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/customlogouthandler/CustomLogoutHandlerIntegrationTest.java index 3c325a2006..cd8a1a72d6 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/customlogouthandler/CustomLogoutHandlerIntegrationTest.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/customlogouthandler/CustomLogoutHandlerIntegrationTest.java @@ -1,6 +1,7 @@ package com.baeldung.customlogouthandler; -import com.baeldung.customlogouthandler.services.UserCache; +import static org.assertj.core.api.Assertions.assertThat; + import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -11,96 +12,97 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.jdbc.Sql; import org.springframework.test.context.jdbc.SqlGroup; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import static org.assertj.core.api.Assertions.assertThat; +import com.baeldung.customlogouthandler.services.UserCache; @RunWith(SpringJUnit4ClassRunner.class) -@SpringBootTest(classes = {LogoutDemoApplication.class, MvcConfiguration.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@SqlGroup({ - @Sql(value = "classpath:customlogouthandler/before.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD), - @Sql(value = "classpath:customlogouthandler/after.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) -}) +@SpringBootTest(classes = { CustomLogoutApplication.class }, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SqlGroup({ @Sql(value = "classpath:customlogouthandler/before.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD), @Sql(value = "classpath:customlogouthandler/after.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) }) +@TestPropertySource(locations="classpath:customlogouthandler/application.properties") class CustomLogoutHandlerIntegrationTest { - @Autowired - private TestRestTemplate restTemplate; + @Autowired + private TestRestTemplate restTemplate; - @Autowired - private UserCache userCache; + @Autowired + private UserCache userCache; - @LocalServerPort - private int port; + @LocalServerPort + private int port; - @Test - public void whenLogin_thenUseUserCache() throws Exception { - // User cache should be empty on start - assertThat(userCache.size()).isEqualTo(0); + @Test + public void whenLogin_thenUseUserCache() { + // User cache should be empty on start + assertThat(userCache.size()).isEqualTo(0); - // Request using first login - ResponseEntity response = restTemplate - .withBasicAuth("user", "pass") - .getForEntity(getLanguageUrl(), String.class); + // Request using first login + ResponseEntity response = restTemplate.withBasicAuth("user", "pass") + .getForEntity(getLanguageUrl(), String.class); - assertThat(response.getBody()).contains("english"); + assertThat(response.getBody()).contains("english"); - // User cache must contain the user - assertThat(userCache.size()).isEqualTo(1); + // User cache must contain the user + assertThat(userCache.size()).isEqualTo(1); - // Getting the session cookie - HttpHeaders requestHeaders = new HttpHeaders(); - requestHeaders.add("Cookie", response.getHeaders().getFirst(HttpHeaders.SET_COOKIE)); + // Getting the session cookie + HttpHeaders requestHeaders = new HttpHeaders(); + requestHeaders.add("Cookie", response.getHeaders() + .getFirst(HttpHeaders.SET_COOKIE)); - // Request with the session cookie - response = restTemplate - .exchange(getLanguageUrl(), HttpMethod.GET, new HttpEntity(requestHeaders), String.class); - assertThat(response.getBody()).contains("english"); + // Request with the session cookie + response = restTemplate.exchange(getLanguageUrl(), HttpMethod.GET, new HttpEntity(requestHeaders), String.class); + assertThat(response.getBody()).contains("english"); - // Logging out using the session cookies - response = restTemplate.exchange(getLogoutUrl(), HttpMethod.GET, new HttpEntity(requestHeaders), String.class); - assertThat(response.getStatusCode().value()).isEqualTo(200); - } + // Logging out using the session cookies + response = restTemplate.exchange(getLogoutUrl(), HttpMethod.GET, new HttpEntity(requestHeaders), String.class); + assertThat(response.getStatusCode() + .value()).isEqualTo(200); + } - @Test - public void whenLogout_thenCacheIsEmpty() throws Exception { - // User cache should be empty on start - assertThat(userCache.size()).isEqualTo(0); + @Test + public void whenLogout_thenCacheIsEmpty() { + // User cache should be empty on start + assertThat(userCache.size()).isEqualTo(0); - // Request using first login - ResponseEntity response = restTemplate - .withBasicAuth("user", "pass") - .getForEntity(getLanguageUrl(), String.class); + // Request using first login + ResponseEntity response = restTemplate.withBasicAuth("user", "pass") + .getForEntity(getLanguageUrl(), String.class); - assertThat(response.getBody()).contains("english"); + assertThat(response.getBody()).contains("english"); - // User cache must contain the user - assertThat(userCache.size()).isEqualTo(1); + // User cache must contain the user + assertThat(userCache.size()).isEqualTo(1); - // Getting the session cookie - HttpHeaders requestHeaders = new HttpHeaders(); - requestHeaders.add("Cookie", response.getHeaders().getFirst(HttpHeaders.SET_COOKIE)); + // Getting the session cookie + HttpHeaders requestHeaders = new HttpHeaders(); + requestHeaders.add("Cookie", response.getHeaders() + .getFirst(HttpHeaders.SET_COOKIE)); - // Logging out using the session cookies - response = restTemplate.exchange(getLogoutUrl(), HttpMethod.GET, new HttpEntity(requestHeaders), String.class); - assertThat(response.getStatusCode().value()).isEqualTo(200); + // Logging out using the session cookies + response = restTemplate.exchange(getLogoutUrl(), HttpMethod.GET, new HttpEntity(requestHeaders), String.class); + assertThat(response.getStatusCode() + .value()).isEqualTo(200); - // User cache must be empty now - // this is the reaction on custom logout filter execution - assertThat(userCache.size()).isEqualTo(0); + // User cache must be empty now + // this is the reaction on custom logout filter execution + assertThat(userCache.size()).isEqualTo(0); - // Assert unathorized request - response = restTemplate.exchange(getLanguageUrl(), HttpMethod.GET, new HttpEntity(requestHeaders), String.class); - assertThat(response.getStatusCode().value()).isEqualTo(401); - } + // Assert unauthorized request + response = restTemplate.exchange(getLanguageUrl(), HttpMethod.GET, new HttpEntity(requestHeaders), String.class); + assertThat(response.getStatusCode() + .value()).isEqualTo(401); + } - private String getLanguageUrl() { - return "http://localhost:" + port + "/user/language"; - } + private String getLanguageUrl() { + return "http://localhost:" + port + "/user/language"; + } - private String getLogoutUrl() { - return "http://localhost:" + port + "/user/logout"; - } + private String getLogoutUrl() { + return "http://localhost:" + port + "/user/logout"; + } } diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/application.properties b/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/application.properties index 8b6d47ebe9..9edd853f2c 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/application.properties +++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/application.properties @@ -1,5 +1,5 @@ -spring.datasource.url=jdbc:postgresql://localhost:5432/develop -spring.datasource.username=develop -spring.datasource.password=develop +spring.datasource.url=jdbc:postgresql://localhost:5432/test +spring.datasource.username=test +spring.datasource.password=test spring.jpa.hibernate.ddl-auto=create From 856c0473068fef84d5a68c532bd2ecd28884ea38 Mon Sep 17 00:00:00 2001 From: Eric Martin Date: Sun, 12 Apr 2020 13:53:06 -0500 Subject: [PATCH 207/503] Update terraform/best-practices/k8s-modules/SETUP.md Co-Authored-By: KevinGilmore --- terraform/best-practices/k8s-modules/SETUP.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/terraform/best-practices/k8s-modules/SETUP.md b/terraform/best-practices/k8s-modules/SETUP.md index b7e4c2764d..f00247a293 100644 --- a/terraform/best-practices/k8s-modules/SETUP.md +++ b/terraform/best-practices/k8s-modules/SETUP.md @@ -4,7 +4,7 @@ This sample deploys two services behind a Kubernetes ingress. # Setup instructions -1. Mak sure you have a working Kubernetes environment. Use a simple command such as _kubectl get nodes_ and check its output. +1. Make sure you have a working Kubernetes environment. Use a simple command such as _kubectl get nodes_ and check its output. If you get a list of nodes that contains at least one _ready_ module, you're good to go 2. Download the Terraform package for your environment from Hashicorp's site. Unzip it and put the _terraform_ binary somewhere in the OS's PATH. @@ -18,4 +18,3 @@ This sample deploys two services behind a Kubernetes ingress. 6. Run _terraform destroy_ to remove the previously creates namespace. - From bf0ff591457cef341514a54764c1b944f87b7cd2 Mon Sep 17 00:00:00 2001 From: Eric Martin Date: Sun, 12 Apr 2020 13:53:19 -0500 Subject: [PATCH 208/503] Update terraform/best-practices/k8s-basic/SETUP.md Co-Authored-By: KevinGilmore --- terraform/best-practices/k8s-basic/SETUP.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/terraform/best-practices/k8s-basic/SETUP.md b/terraform/best-practices/k8s-basic/SETUP.md index 479bb75274..35e690d88e 100644 --- a/terraform/best-practices/k8s-basic/SETUP.md +++ b/terraform/best-practices/k8s-basic/SETUP.md @@ -1,6 +1,6 @@ # Setup instructions -1. Mak sure you have a working Kubernetes environment. Use a simple command such as _kubectl get nodes_ and check its output. +1. Make sure you have a working Kubernetes environment. Use a simple command such as _kubectl get nodes_ and check its output. If you get a list of nodes that contains at least one _ready_ module, you're good to go 2. Download the Terraform package for your environment from Hashicorp's site. Unzip it and put the _terraform_ binary somewhere in the OS's PATH. @@ -12,4 +12,3 @@ ''' 5. Wait until Terraform create all resources and run _kubectl get namespaces_. The output should now have a new "hello-terraform" namespace. 6. Run _terraform destroy_ to remove the previously creates namespace. - From 02a4eee18c9a91af3aa64747cdf036f0a645f464 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 13 Apr 2020 15:09:40 +0530 Subject: [PATCH 209/503] JAVA-620: New module core-java-io-conversions-2 --- .../core-java-io-conversions-2/README.md | 9 + .../core-java-io-conversions-2/pom.xml | 37 +++ .../InputStreamToByteBufferUnitTest.java | 56 ++++ .../JavaInputStreamToXUnitTest.java | 248 ++++++++++++++++++ .../src/test/resources/sample.txt | 1 + .../src/test/resources/targetFile.tmp | 1 + 6 files changed, 352 insertions(+) create mode 100644 core-java-modules/core-java-io-conversions-2/README.md create mode 100644 core-java-modules/core-java-io-conversions-2/pom.xml create mode 100644 core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/inputstreamtobytes/InputStreamToByteBufferUnitTest.java create mode 100644 core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/inputstreamtostring/JavaInputStreamToXUnitTest.java create mode 100644 core-java-modules/core-java-io-conversions-2/src/test/resources/sample.txt create mode 100644 core-java-modules/core-java-io-conversions-2/src/test/resources/targetFile.tmp diff --git a/core-java-modules/core-java-io-conversions-2/README.md b/core-java-modules/core-java-io-conversions-2/README.md new file mode 100644 index 0000000000..404d4aa400 --- /dev/null +++ b/core-java-modules/core-java-io-conversions-2/README.md @@ -0,0 +1,9 @@ +## Core Java IO Conversions + +This module contains articles about core Java input/output(IO) conversions. + +### Relevant Articles: +- [Java InputStream to String](https://www.baeldung.com/convert-input-stream-to-string) +- [Java InputStream to Byte Array and ByteBuffer](https://www.baeldung.com/convert-input-stream-to-array-of-bytes) +- [Java – Write an InputStream to a File](https://www.baeldung.com/convert-input-stream-to-a-file) +- More articles: [[<-- prev]](/core-java-modules/core-java-io-conversions) diff --git a/core-java-modules/core-java-io-conversions-2/pom.xml b/core-java-modules/core-java-io-conversions-2/pom.xml new file mode 100644 index 0000000000..e95d1f4b67 --- /dev/null +++ b/core-java-modules/core-java-io-conversions-2/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + core-java-io-conversions-2 + 0.1.0-SNAPSHOT + core-java-io-conversions-2 + jar + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + + core-java-io-conversions + + + src/main/resources + true + + + + + \ No newline at end of file diff --git a/core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/inputstreamtobytes/InputStreamToByteBufferUnitTest.java b/core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/inputstreamtobytes/InputStreamToByteBufferUnitTest.java new file mode 100644 index 0000000000..c10aaae22a --- /dev/null +++ b/core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/inputstreamtobytes/InputStreamToByteBufferUnitTest.java @@ -0,0 +1,56 @@ +package com.baeldung.inputstreamtobytes; + +import com.google.common.io.ByteSource; +import com.google.common.io.ByteStreams; +import org.apache.commons.io.IOUtils; +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.nio.channels.ReadableByteChannel; + +import static java.nio.channels.Channels.newChannel; +import static org.junit.Assert.assertEquals; + +public class InputStreamToByteBufferUnitTest { + + @Test + public void givenUsingCoreClasses_whenByteArrayInputStreamToAByteBuffer_thenLengthMustMatch() throws IOException { + byte[] input = new byte[] { 0, 1, 2 }; + InputStream initialStream = new ByteArrayInputStream(input); + ByteBuffer byteBuffer = ByteBuffer.allocate(3); + while (initialStream.available() > 0) { + byteBuffer.put((byte) initialStream.read()); + } + + assertEquals(byteBuffer.position(), input.length); + } + + @Test + public void givenUsingGuava__whenByteArrayInputStreamToAByteBuffer_thenLengthMustMatch() throws IOException { + InputStream initialStream = ByteSource + .wrap(new byte[] { 0, 1, 2 }) + .openStream(); + byte[] targetArray = ByteStreams.toByteArray(initialStream); + ByteBuffer bufferByte = ByteBuffer.wrap(targetArray); + while (bufferByte.hasRemaining()) { + bufferByte.get(); + } + + assertEquals(bufferByte.position(), targetArray.length); + } + + @Test + public void givenUsingCommonsIo_whenByteArrayInputStreamToAByteBuffer_thenLengthMustMatch() throws IOException { + byte[] input = new byte[] { 0, 1, 2 }; + InputStream initialStream = new ByteArrayInputStream(input); + ByteBuffer byteBuffer = ByteBuffer.allocate(3); + ReadableByteChannel channel = newChannel(initialStream); + IOUtils.readFully(channel, byteBuffer); + + assertEquals(byteBuffer.position(), input.length); + } + +} diff --git a/core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/inputstreamtostring/JavaInputStreamToXUnitTest.java b/core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/inputstreamtostring/JavaInputStreamToXUnitTest.java new file mode 100644 index 0000000000..eb8c39f2d9 --- /dev/null +++ b/core-java-modules/core-java-io-conversions-2/src/test/java/com/baeldung/inputstreamtostring/JavaInputStreamToXUnitTest.java @@ -0,0 +1,248 @@ +package com.baeldung.inputstreamtostring; + +import com.google.common.base.Charsets; +import com.google.common.io.ByteSource; +import com.google.common.io.ByteStreams; +import com.google.common.io.CharStreams; +import com.google.common.io.Files; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.*; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.util.Scanner; +import java.util.UUID; + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.hamcrest.Matchers.equalTo; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +@SuppressWarnings("unused") +public class JavaInputStreamToXUnitTest { + protected final Logger logger = LoggerFactory.getLogger(getClass()); + private static final int DEFAULT_SIZE = 1500000; + + // tests - InputStream to String + + @Test + public final void givenUsingJava5_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + final String originalString = randomAlphabetic(DEFAULT_SIZE); + final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); + + final StringBuilder textBuilder = new StringBuilder(); + try (Reader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName(StandardCharsets.UTF_8.name())))) { + int c; + while ((c = reader.read()) != -1) { + textBuilder.append((char) c); + } + } + assertEquals(textBuilder.toString(), originalString); + } + + @Test + public final void givenUsingJava7_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + final String originalString = randomAlphabetic(DEFAULT_SIZE); + final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); // exampleString.getBytes(StandardCharsets.UTF_8); + + // When + String text; + try (Scanner scanner = new Scanner(inputStream, StandardCharsets.UTF_8.name())) { + text = scanner.useDelimiter("\\A").next(); + } + + assertThat(text, equalTo(originalString)); + } + + @Test + public final void givenUsingGuava_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + final String originalString = randomAlphabetic(DEFAULT_SIZE); + final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); + + final ByteSource byteSource = new ByteSource() { + @Override + public final InputStream openStream() throws IOException { + return inputStream; + } + }; + + final String text = byteSource.asCharSource(Charsets.UTF_8).read(); + + assertThat(text, equalTo(originalString)); + } + + @Test + public final void givenUsingGuavaAndJava7_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + final String originalString = randomAlphabetic(DEFAULT_SIZE); + final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); + + // When + String text; + try (final Reader reader = new InputStreamReader(inputStream)) { + text = CharStreams.toString(reader); + } + + assertThat(text, equalTo(originalString)); + } + + @Test + public final void givenUsingCommonsIo_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + final String originalString = randomAlphabetic(DEFAULT_SIZE); + final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); + + // When + final String text = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name()); + assertThat(text, equalTo(originalString)); + } + + @Test + public final void givenUsingCommonsIoWithCopy_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + final String originalString = randomAlphabetic(DEFAULT_SIZE); + final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); + + // When + final StringWriter writer = new StringWriter(); + final String encoding = StandardCharsets.UTF_8.name(); + IOUtils.copy(inputStream, writer, encoding); + + assertThat(writer.toString(), equalTo(originalString)); + } + + @Test + public final void givenUsingTempFile_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { + final String originalString = randomAlphabetic(DEFAULT_SIZE); + final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); + + // When + Path tempFile = java.nio.file.Files.createTempDirectory("").resolve(UUID.randomUUID().toString() + ".tmp"); + java.nio.file.Files.copy(inputStream, tempFile, StandardCopyOption.REPLACE_EXISTING); + String result = new String(java.nio.file.Files.readAllBytes(tempFile)); + + assertThat(result, equalTo(originalString)); + } + + // tests - InputStream to byte[] + + @Test + public final void givenUsingPlainJavaOnFixedSizeStream_whenConvertingAnInputStreamToAByteArray_thenCorrect() throws IOException { + final InputStream initialStream = new ByteArrayInputStream(new byte[] { 0, 1, 2 }); + final byte[] targetArray = new byte[initialStream.available()]; + initialStream.read(targetArray); + } + + @Test + public final void givenUsingPlainJavaOnUnknownSizeStream_whenConvertingAnInputStreamToAByteArray_thenCorrect() throws IOException { + final InputStream is = new ByteArrayInputStream(new byte[] { 0, 1, 2 }); + + final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + int nRead; + final byte[] data = new byte[1024]; + while ((nRead = is.read(data, 0, data.length)) != -1) { + buffer.write(data, 0, nRead); + } + + buffer.flush(); + final byte[] byteArray = buffer.toByteArray(); + } + + @Test + public final void givenUsingGuava_whenConvertingAnInputStreamToAByteArray_thenCorrect() throws IOException { + final InputStream initialStream = ByteSource.wrap(new byte[] { 0, 1, 2 }).openStream(); + final byte[] targetArray = ByteStreams.toByteArray(initialStream); + } + + @Test + public final void givenUsingCommonsIO_whenConvertingAnInputStreamToAByteArray_thenCorrect() throws IOException { + final InputStream initialStream = new ByteArrayInputStream(new byte[] { 0, 1, 2 }); + final byte[] targetArray = IOUtils.toByteArray(initialStream); + } + + // tests - InputStream to File + + @Test + public final void whenConvertingToFile_thenCorrect() throws IOException { + final InputStream initialStream = new FileInputStream(new File("src/test/resources/sample.txt")); + final byte[] buffer = new byte[initialStream.available()]; + initialStream.read(buffer); + + final File targetFile = new File("src/test/resources/targetFile.tmp"); + final OutputStream outStream = new FileOutputStream(targetFile); + outStream.write(buffer); + + IOUtils.closeQuietly(initialStream); + IOUtils.closeQuietly(outStream); + } + + @Test + public final void whenConvertingInProgressToFile_thenCorrect() throws IOException { + final InputStream initialStream = new FileInputStream(new File("src/test/resources/sample.txt")); + final File targetFile = new File("src/test/resources/targetFile.tmp"); + final OutputStream outStream = new FileOutputStream(targetFile); + + final byte[] buffer = new byte[8 * 1024]; + int bytesRead; + while ((bytesRead = initialStream.read(buffer)) != -1) { + outStream.write(buffer, 0, bytesRead); + } + + IOUtils.closeQuietly(initialStream); + IOUtils.closeQuietly(outStream); + } + + @Test + public final void whenConvertingAnInProgressInputStreamToFile_thenCorrect2() throws IOException { + final InputStream initialStream = new FileInputStream(new File("src/test/resources/sample.txt")); + final File targetFile = new File("src/test/resources/targetFile.tmp"); + + java.nio.file.Files.copy(initialStream, targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING); + + IOUtils.closeQuietly(initialStream); + } + + @Test + public final void whenConvertingInputStreamToFile_thenCorrect3() throws IOException { + final InputStream initialStream = new FileInputStream(new File("src/test/resources/sample.txt")); + final byte[] buffer = new byte[initialStream.available()]; + initialStream.read(buffer); + + final File targetFile = new File("src/test/resources/targetFile.tmp"); + Files.write(buffer, targetFile); + + IOUtils.closeQuietly(initialStream); + } + + @Test + public final void whenConvertingInputStreamToFile_thenCorrect4() throws IOException { + final InputStream initialStream = FileUtils.openInputStream(new File("src/test/resources/sample.txt")); + + final File targetFile = new File("src/test/resources/targetFile.tmp"); + + FileUtils.copyInputStreamToFile(initialStream, targetFile); + } + + @Test + public final void givenUsingPlainJava_whenConvertingAnInputStreamToString_thenCorrect() throws IOException { + String originalString = randomAlphabetic(8); + InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); + + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + int nRead; + byte[] data = new byte[1024]; + while ((nRead = inputStream.read(data, 0, data.length)) != -1) { + buffer.write(data, 0, nRead); + } + + buffer.flush(); + byte[] byteArray = buffer.toByteArray(); + + String text = new String(byteArray, StandardCharsets.UTF_8); + assertThat(text, equalTo(originalString)); + } + +} diff --git a/core-java-modules/core-java-io-conversions-2/src/test/resources/sample.txt b/core-java-modules/core-java-io-conversions-2/src/test/resources/sample.txt new file mode 100644 index 0000000000..5e1c309dae --- /dev/null +++ b/core-java-modules/core-java-io-conversions-2/src/test/resources/sample.txt @@ -0,0 +1 @@ +Hello World \ No newline at end of file diff --git a/core-java-modules/core-java-io-conversions-2/src/test/resources/targetFile.tmp b/core-java-modules/core-java-io-conversions-2/src/test/resources/targetFile.tmp new file mode 100644 index 0000000000..5e1c309dae --- /dev/null +++ b/core-java-modules/core-java-io-conversions-2/src/test/resources/targetFile.tmp @@ -0,0 +1 @@ +Hello World \ No newline at end of file From b2cf180785486bb722f6f014199b92f376eac415 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 13 Apr 2020 15:10:22 +0530 Subject: [PATCH 210/503] JAVA-620: Moved articles to new module --- .../core-java-io-conversions/README.md | 3 +- .../InputStreamToByteBufferUnitTest.java | 56 ---- .../JavaInputStreamToXUnitTest.java | 248 ------------------ .../src/test/resources/targetFile.tmp | 1 - 4 files changed, 1 insertion(+), 307 deletions(-) delete mode 100644 core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/inputstreamtobytes/InputStreamToByteBufferUnitTest.java delete mode 100644 core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/inputstreamtostring/JavaInputStreamToXUnitTest.java delete mode 100644 core-java-modules/core-java-io-conversions/src/test/resources/targetFile.tmp diff --git a/core-java-modules/core-java-io-conversions/README.md b/core-java-modules/core-java-io-conversions/README.md index cdb7df04d0..1f12c87241 100644 --- a/core-java-modules/core-java-io-conversions/README.md +++ b/core-java-modules/core-java-io-conversions/README.md @@ -3,10 +3,8 @@ This module contains articles about core Java input/output(IO) conversions. ### Relevant Articles: -- [Java InputStream to String](https://www.baeldung.com/convert-input-stream-to-string) - [Java – Convert File to InputStream](https://www.baeldung.com/convert-file-to-input-stream) - [Java – Byte Array to Writer](https://www.baeldung.com/java-convert-byte-array-to-writer) -- [Java InputStream to Byte Array and ByteBuffer](https://www.baeldung.com/convert-input-stream-to-array-of-bytes) - [Java – String to Reader](https://www.baeldung.com/java-convert-string-to-reader) - [Java – Byte Array to Reader](https://www.baeldung.com/java-convert-byte-array-to-reader) - [Java – File to Reader](https://www.baeldung.com/java-convert-file-to-reader) @@ -15,3 +13,4 @@ This module contains articles about core Java input/output(IO) conversions. - [Java – Write a Reader to File](https://www.baeldung.com/java-write-reader-to-file) - [Java – Reader to Byte Array](https://www.baeldung.com/java-convert-reader-to-byte-array) - [Java – Reader to InputStream](https://www.baeldung.com/java-convert-reader-to-inputstream) +- More articles: [[next -->]](/core-java-modules/core-java-io-conversions-2) diff --git a/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/inputstreamtobytes/InputStreamToByteBufferUnitTest.java b/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/inputstreamtobytes/InputStreamToByteBufferUnitTest.java deleted file mode 100644 index c10aaae22a..0000000000 --- a/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/inputstreamtobytes/InputStreamToByteBufferUnitTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.baeldung.inputstreamtobytes; - -import com.google.common.io.ByteSource; -import com.google.common.io.ByteStreams; -import org.apache.commons.io.IOUtils; -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.nio.channels.ReadableByteChannel; - -import static java.nio.channels.Channels.newChannel; -import static org.junit.Assert.assertEquals; - -public class InputStreamToByteBufferUnitTest { - - @Test - public void givenUsingCoreClasses_whenByteArrayInputStreamToAByteBuffer_thenLengthMustMatch() throws IOException { - byte[] input = new byte[] { 0, 1, 2 }; - InputStream initialStream = new ByteArrayInputStream(input); - ByteBuffer byteBuffer = ByteBuffer.allocate(3); - while (initialStream.available() > 0) { - byteBuffer.put((byte) initialStream.read()); - } - - assertEquals(byteBuffer.position(), input.length); - } - - @Test - public void givenUsingGuava__whenByteArrayInputStreamToAByteBuffer_thenLengthMustMatch() throws IOException { - InputStream initialStream = ByteSource - .wrap(new byte[] { 0, 1, 2 }) - .openStream(); - byte[] targetArray = ByteStreams.toByteArray(initialStream); - ByteBuffer bufferByte = ByteBuffer.wrap(targetArray); - while (bufferByte.hasRemaining()) { - bufferByte.get(); - } - - assertEquals(bufferByte.position(), targetArray.length); - } - - @Test - public void givenUsingCommonsIo_whenByteArrayInputStreamToAByteBuffer_thenLengthMustMatch() throws IOException { - byte[] input = new byte[] { 0, 1, 2 }; - InputStream initialStream = new ByteArrayInputStream(input); - ByteBuffer byteBuffer = ByteBuffer.allocate(3); - ReadableByteChannel channel = newChannel(initialStream); - IOUtils.readFully(channel, byteBuffer); - - assertEquals(byteBuffer.position(), input.length); - } - -} diff --git a/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/inputstreamtostring/JavaInputStreamToXUnitTest.java b/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/inputstreamtostring/JavaInputStreamToXUnitTest.java deleted file mode 100644 index eb8c39f2d9..0000000000 --- a/core-java-modules/core-java-io-conversions/src/test/java/com/baeldung/inputstreamtostring/JavaInputStreamToXUnitTest.java +++ /dev/null @@ -1,248 +0,0 @@ -package com.baeldung.inputstreamtostring; - -import com.google.common.base.Charsets; -import com.google.common.io.ByteSource; -import com.google.common.io.ByteStreams; -import com.google.common.io.CharStreams; -import com.google.common.io.Files; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.*; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; -import java.util.Scanner; -import java.util.UUID; - -import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; - -@SuppressWarnings("unused") -public class JavaInputStreamToXUnitTest { - protected final Logger logger = LoggerFactory.getLogger(getClass()); - private static final int DEFAULT_SIZE = 1500000; - - // tests - InputStream to String - - @Test - public final void givenUsingJava5_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { - final String originalString = randomAlphabetic(DEFAULT_SIZE); - final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); - - final StringBuilder textBuilder = new StringBuilder(); - try (Reader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName(StandardCharsets.UTF_8.name())))) { - int c; - while ((c = reader.read()) != -1) { - textBuilder.append((char) c); - } - } - assertEquals(textBuilder.toString(), originalString); - } - - @Test - public final void givenUsingJava7_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { - final String originalString = randomAlphabetic(DEFAULT_SIZE); - final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); // exampleString.getBytes(StandardCharsets.UTF_8); - - // When - String text; - try (Scanner scanner = new Scanner(inputStream, StandardCharsets.UTF_8.name())) { - text = scanner.useDelimiter("\\A").next(); - } - - assertThat(text, equalTo(originalString)); - } - - @Test - public final void givenUsingGuava_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { - final String originalString = randomAlphabetic(DEFAULT_SIZE); - final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); - - final ByteSource byteSource = new ByteSource() { - @Override - public final InputStream openStream() throws IOException { - return inputStream; - } - }; - - final String text = byteSource.asCharSource(Charsets.UTF_8).read(); - - assertThat(text, equalTo(originalString)); - } - - @Test - public final void givenUsingGuavaAndJava7_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { - final String originalString = randomAlphabetic(DEFAULT_SIZE); - final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); - - // When - String text; - try (final Reader reader = new InputStreamReader(inputStream)) { - text = CharStreams.toString(reader); - } - - assertThat(text, equalTo(originalString)); - } - - @Test - public final void givenUsingCommonsIo_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { - final String originalString = randomAlphabetic(DEFAULT_SIZE); - final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); - - // When - final String text = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name()); - assertThat(text, equalTo(originalString)); - } - - @Test - public final void givenUsingCommonsIoWithCopy_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { - final String originalString = randomAlphabetic(DEFAULT_SIZE); - final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); - - // When - final StringWriter writer = new StringWriter(); - final String encoding = StandardCharsets.UTF_8.name(); - IOUtils.copy(inputStream, writer, encoding); - - assertThat(writer.toString(), equalTo(originalString)); - } - - @Test - public final void givenUsingTempFile_whenConvertingAnInputStreamToAString_thenCorrect() throws IOException { - final String originalString = randomAlphabetic(DEFAULT_SIZE); - final InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); - - // When - Path tempFile = java.nio.file.Files.createTempDirectory("").resolve(UUID.randomUUID().toString() + ".tmp"); - java.nio.file.Files.copy(inputStream, tempFile, StandardCopyOption.REPLACE_EXISTING); - String result = new String(java.nio.file.Files.readAllBytes(tempFile)); - - assertThat(result, equalTo(originalString)); - } - - // tests - InputStream to byte[] - - @Test - public final void givenUsingPlainJavaOnFixedSizeStream_whenConvertingAnInputStreamToAByteArray_thenCorrect() throws IOException { - final InputStream initialStream = new ByteArrayInputStream(new byte[] { 0, 1, 2 }); - final byte[] targetArray = new byte[initialStream.available()]; - initialStream.read(targetArray); - } - - @Test - public final void givenUsingPlainJavaOnUnknownSizeStream_whenConvertingAnInputStreamToAByteArray_thenCorrect() throws IOException { - final InputStream is = new ByteArrayInputStream(new byte[] { 0, 1, 2 }); - - final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - int nRead; - final byte[] data = new byte[1024]; - while ((nRead = is.read(data, 0, data.length)) != -1) { - buffer.write(data, 0, nRead); - } - - buffer.flush(); - final byte[] byteArray = buffer.toByteArray(); - } - - @Test - public final void givenUsingGuava_whenConvertingAnInputStreamToAByteArray_thenCorrect() throws IOException { - final InputStream initialStream = ByteSource.wrap(new byte[] { 0, 1, 2 }).openStream(); - final byte[] targetArray = ByteStreams.toByteArray(initialStream); - } - - @Test - public final void givenUsingCommonsIO_whenConvertingAnInputStreamToAByteArray_thenCorrect() throws IOException { - final InputStream initialStream = new ByteArrayInputStream(new byte[] { 0, 1, 2 }); - final byte[] targetArray = IOUtils.toByteArray(initialStream); - } - - // tests - InputStream to File - - @Test - public final void whenConvertingToFile_thenCorrect() throws IOException { - final InputStream initialStream = new FileInputStream(new File("src/test/resources/sample.txt")); - final byte[] buffer = new byte[initialStream.available()]; - initialStream.read(buffer); - - final File targetFile = new File("src/test/resources/targetFile.tmp"); - final OutputStream outStream = new FileOutputStream(targetFile); - outStream.write(buffer); - - IOUtils.closeQuietly(initialStream); - IOUtils.closeQuietly(outStream); - } - - @Test - public final void whenConvertingInProgressToFile_thenCorrect() throws IOException { - final InputStream initialStream = new FileInputStream(new File("src/test/resources/sample.txt")); - final File targetFile = new File("src/test/resources/targetFile.tmp"); - final OutputStream outStream = new FileOutputStream(targetFile); - - final byte[] buffer = new byte[8 * 1024]; - int bytesRead; - while ((bytesRead = initialStream.read(buffer)) != -1) { - outStream.write(buffer, 0, bytesRead); - } - - IOUtils.closeQuietly(initialStream); - IOUtils.closeQuietly(outStream); - } - - @Test - public final void whenConvertingAnInProgressInputStreamToFile_thenCorrect2() throws IOException { - final InputStream initialStream = new FileInputStream(new File("src/test/resources/sample.txt")); - final File targetFile = new File("src/test/resources/targetFile.tmp"); - - java.nio.file.Files.copy(initialStream, targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING); - - IOUtils.closeQuietly(initialStream); - } - - @Test - public final void whenConvertingInputStreamToFile_thenCorrect3() throws IOException { - final InputStream initialStream = new FileInputStream(new File("src/test/resources/sample.txt")); - final byte[] buffer = new byte[initialStream.available()]; - initialStream.read(buffer); - - final File targetFile = new File("src/test/resources/targetFile.tmp"); - Files.write(buffer, targetFile); - - IOUtils.closeQuietly(initialStream); - } - - @Test - public final void whenConvertingInputStreamToFile_thenCorrect4() throws IOException { - final InputStream initialStream = FileUtils.openInputStream(new File("src/test/resources/sample.txt")); - - final File targetFile = new File("src/test/resources/targetFile.tmp"); - - FileUtils.copyInputStreamToFile(initialStream, targetFile); - } - - @Test - public final void givenUsingPlainJava_whenConvertingAnInputStreamToString_thenCorrect() throws IOException { - String originalString = randomAlphabetic(8); - InputStream inputStream = new ByteArrayInputStream(originalString.getBytes()); - - ByteArrayOutputStream buffer = new ByteArrayOutputStream(); - int nRead; - byte[] data = new byte[1024]; - while ((nRead = inputStream.read(data, 0, data.length)) != -1) { - buffer.write(data, 0, nRead); - } - - buffer.flush(); - byte[] byteArray = buffer.toByteArray(); - - String text = new String(byteArray, StandardCharsets.UTF_8); - assertThat(text, equalTo(originalString)); - } - -} diff --git a/core-java-modules/core-java-io-conversions/src/test/resources/targetFile.tmp b/core-java-modules/core-java-io-conversions/src/test/resources/targetFile.tmp deleted file mode 100644 index 5e1c309dae..0000000000 --- a/core-java-modules/core-java-io-conversions/src/test/resources/targetFile.tmp +++ /dev/null @@ -1 +0,0 @@ -Hello World \ No newline at end of file From effbd4cb6e080136046ece92f38554d576c2f389 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 13 Apr 2020 15:10:47 +0530 Subject: [PATCH 211/503] JAVA-620: parent pom changes to include new module --- core-java-modules/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 3fc978a68c..00ef24be92 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -69,6 +69,7 @@ core-java-io-2 core-java-io-apis core-java-io-conversions + core-java-io-conversions-2 core-java-jar core-java-jndi From dc0f9adabdba48b450814d8022f43361858e989e Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 13 Apr 2020 15:19:27 +0530 Subject: [PATCH 212/503] JAVA-620: Updated README --- core-java-modules/core-java-io-conversions-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-io-conversions-2/README.md b/core-java-modules/core-java-io-conversions-2/README.md index 404d4aa400..4a28bf37c5 100644 --- a/core-java-modules/core-java-io-conversions-2/README.md +++ b/core-java-modules/core-java-io-conversions-2/README.md @@ -1,4 +1,4 @@ -## Core Java IO Conversions +## Core Java IO Conversions (Part 2) This module contains articles about core Java input/output(IO) conversions. From a6b0996346beedb9066b1aa0ab334c65ee79080a Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 13 Apr 2020 22:34:36 +0530 Subject: [PATCH 213/503] BAEL-3909: Update README to include article in correct module --- core-java-modules/core-java-string-operations-2/README.md | 1 + core-java-modules/core-java-string-operations/README.md | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) 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 5e92738f5c..bc00c6a915 100644 --- a/core-java-modules/core-java-string-operations-2/README.md +++ b/core-java-modules/core-java-string-operations-2/README.md @@ -11,4 +11,5 @@ This module contains articles about string operations. - [Case-Insensitive String Matching in Java](https://www.baeldung.com/java-case-insensitive-string-matching) - [L-Trim and R-Trim in Java](https://www.baeldung.com/l-trim-and-r-trim-in-java) - [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) - More articles: [[<-- prev]](../core-java-string-operations) diff --git a/core-java-modules/core-java-string-operations/README.md b/core-java-modules/core-java-string-operations/README.md index c40e56bc46..18a2649a6a 100644 --- a/core-java-modules/core-java-string-operations/README.md +++ b/core-java-modules/core-java-string-operations/README.md @@ -13,5 +13,4 @@ This module contains articles about string operations. - [Adding a Newline Character to a String in Java](https://www.baeldung.com/java-string-newline) - [Check If a String Contains a Substring](https://www.baeldung.com/java-string-contains-substring) - [Java Base64 Encoding and Decoding](https://www.baeldung.com/java-base64-encode-and-decode) -- [Java Convert PDF to Base64](https://www.baeldung.com/java-convert-pdf-to-base64) - More articles: [[next -->]](../core-java-string-operations-2) From 676738e7cbe702b85cf11c84b526d18e5b47b503 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Mon, 13 Apr 2020 21:21:19 +0200 Subject: [PATCH 214/503] JAVA-1295: Fix node.left -> node.right --- data-structures/src/main/java/com/baeldung/tree/BinaryTree.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data-structures/src/main/java/com/baeldung/tree/BinaryTree.java b/data-structures/src/main/java/com/baeldung/tree/BinaryTree.java index bb62714006..7469e8ba64 100644 --- a/data-structures/src/main/java/com/baeldung/tree/BinaryTree.java +++ b/data-structures/src/main/java/com/baeldung/tree/BinaryTree.java @@ -142,7 +142,7 @@ public class BinaryTree { nodes.add(node.left); } - if (node.left != null) { + if (node.right != null) { nodes.add(node.right); } } From 123485714d03e71beb5f313746fc082b0e755a82 Mon Sep 17 00:00:00 2001 From: Ali Dehghani Date: Tue, 14 Apr 2020 01:28:10 +0430 Subject: [PATCH 215/503] Renaming the Class to Reflect the Article Update --- .../concurrent/threadsafety/application/Application.java | 8 ++++---- .../callables/ExtrinsicLockCounterCallable.java | 6 +++--- .../{ExtrinsicLockCounter.java => ObjectLockCounter.java} | 4 ++-- ...ounterUnitTest.java => ObjectLockCounterUnitTest.java} | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) rename core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/{ExtrinsicLockCounter.java => ObjectLockCounter.java} (84%) rename core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/threadsafety/{ExtrinsicLockCounterUnitTest.java => ObjectLockCounterUnitTest.java} (82%) diff --git a/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/application/Application.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/application/Application.java index 5fcb28cd2a..ebd027ea68 100644 --- a/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/application/Application.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/application/Application.java @@ -9,7 +9,7 @@ import com.baeldung.concurrent.threadsafety.callables.ReentranReadWriteLockCount import com.baeldung.concurrent.threadsafety.callables.ReentrantLockCounterCallable; import com.baeldung.concurrent.threadsafety.services.AtomicCounter; import com.baeldung.concurrent.threadsafety.services.Counter; -import com.baeldung.concurrent.threadsafety.services.ExtrinsicLockCounter; +import com.baeldung.concurrent.threadsafety.services.ObjectLockCounter; import com.baeldung.concurrent.threadsafety.services.MessageService; import com.baeldung.concurrent.threadsafety.services.ReentrantLockCounter; import com.baeldung.concurrent.threadsafety.services.ReentrantReadWriteLockCounter; @@ -48,9 +48,9 @@ public class Application { System.out.println(future3.get()); System.out.println(future4.get()); - ExtrinsicLockCounter extrinsicLockCounter = new ExtrinsicLockCounter(); - Future future5 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(extrinsicLockCounter)); - Future future6 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(extrinsicLockCounter)); + ObjectLockCounter objectLockCounter = new ObjectLockCounter(); + Future future5 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(objectLockCounter)); + Future future6 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(objectLockCounter)); System.out.println(future5.get()); System.out.println(future6.get()); diff --git a/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ExtrinsicLockCounterCallable.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ExtrinsicLockCounterCallable.java index 370e5d1f00..dcc929d3c4 100644 --- a/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ExtrinsicLockCounterCallable.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/callables/ExtrinsicLockCounterCallable.java @@ -1,13 +1,13 @@ package com.baeldung.concurrent.threadsafety.callables; -import com.baeldung.concurrent.threadsafety.services.ExtrinsicLockCounter; +import com.baeldung.concurrent.threadsafety.services.ObjectLockCounter; import java.util.concurrent.Callable; public class ExtrinsicLockCounterCallable implements Callable { - private final ExtrinsicLockCounter counter; + private final ObjectLockCounter counter; - public ExtrinsicLockCounterCallable(ExtrinsicLockCounter counter) { + public ExtrinsicLockCounterCallable(ObjectLockCounter counter) { this.counter = counter; } diff --git a/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ExtrinsicLockCounter.java b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ObjectLockCounter.java similarity index 84% rename from core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ExtrinsicLockCounter.java rename to core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ObjectLockCounter.java index 0a6ff3f60e..f31cf899ba 100644 --- a/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ExtrinsicLockCounter.java +++ b/core-java-modules/core-java-concurrency-basic/src/main/java/com/baeldung/concurrent/threadsafety/services/ObjectLockCounter.java @@ -1,11 +1,11 @@ package com.baeldung.concurrent.threadsafety.services; -public class ExtrinsicLockCounter { +public class ObjectLockCounter { private int counter; private final Object lock = new Object(); - public ExtrinsicLockCounter() { + public ObjectLockCounter() { this.counter = 0; } diff --git a/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/threadsafety/ExtrinsicLockCounterUnitTest.java b/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/threadsafety/ObjectLockCounterUnitTest.java similarity index 82% rename from core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/threadsafety/ExtrinsicLockCounterUnitTest.java rename to core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/threadsafety/ObjectLockCounterUnitTest.java index 0fc3dd3a54..b0ac80a3aa 100644 --- a/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/threadsafety/ExtrinsicLockCounterUnitTest.java +++ b/core-java-modules/core-java-concurrency-basic/src/test/java/com/baeldung/concurrent/threadsafety/ObjectLockCounterUnitTest.java @@ -1,7 +1,7 @@ package com.baeldung.concurrent.threadsafety; import com.baeldung.concurrent.threadsafety.callables.ExtrinsicLockCounterCallable; -import com.baeldung.concurrent.threadsafety.services.ExtrinsicLockCounter; +import com.baeldung.concurrent.threadsafety.services.ObjectLockCounter; import org.junit.Test; import java.util.concurrent.ExecutorService; @@ -10,12 +10,12 @@ import java.util.concurrent.Future; import static org.assertj.core.api.Assertions.assertThat; -public class ExtrinsicLockCounterUnitTest { +public class ObjectLockCounterUnitTest { @Test public void whenCalledIncrementCounter_thenCorrect() throws Exception { ExecutorService executorService = Executors.newFixedThreadPool(2); - ExtrinsicLockCounter counter = new ExtrinsicLockCounter(); + ObjectLockCounter counter = new ObjectLockCounter(); Future future1 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(counter)); Future future2 = (Future) executorService.submit(new ExtrinsicLockCounterCallable(counter)); From bc872d37428127eed4088f141205d1583588159c Mon Sep 17 00:00:00 2001 From: Benjamin Caure Date: Tue, 14 Apr 2020 07:08:04 +0200 Subject: [PATCH 216/503] BAEL-3943 Bson to json (#9079) --- persistence-modules/java-mongodb/README.md | 1 + .../com/baeldung/morphia/domain/Book.java | 88 ++++++++--- .../bsontojson/BsonToJsonIntegrationTest.java | 142 ++++++++++++++++++ .../bsontojson/JsonDateTimeConverter.java | 30 ++++ 4 files changed, 243 insertions(+), 18 deletions(-) create mode 100644 persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonIntegrationTest.java create mode 100644 persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/JsonDateTimeConverter.java diff --git a/persistence-modules/java-mongodb/README.md b/persistence-modules/java-mongodb/README.md index a8539e644f..5c3c448b03 100644 --- a/persistence-modules/java-mongodb/README.md +++ b/persistence-modules/java-mongodb/README.md @@ -10,3 +10,4 @@ This module contains articles about MongoDB in Java. - [Geospatial Support in MongoDB](https://www.baeldung.com/mongodb-geospatial-support) - [Introduction to Morphia – Java ODM for MongoDB](https://www.baeldung.com/mongodb-morphia) - [MongoDB Aggregations Using Java](https://www.baeldung.com/java-mongodb-aggregations) +- [MongoDB BSON to JSON](https://www.baeldung.com/bson-to-json) diff --git a/persistence-modules/java-mongodb/src/main/java/com/baeldung/morphia/domain/Book.java b/persistence-modules/java-mongodb/src/main/java/com/baeldung/morphia/domain/Book.java index 172c916ad9..4ed2ab8580 100644 --- a/persistence-modules/java-mongodb/src/main/java/com/baeldung/morphia/domain/Book.java +++ b/persistence-modules/java-mongodb/src/main/java/com/baeldung/morphia/domain/Book.java @@ -1,5 +1,7 @@ package com.baeldung.morphia.domain; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.HashSet; import java.util.Set; @@ -29,28 +31,13 @@ public class Book { private double cost; @Reference private Set companionBooks; + @Property + private LocalDateTime publishDate; public Book() { } - public String getTitle() { - return title; - } - - public String getAuthor() { - return author; - } - - public double getCost() { - return cost; - } - - public void addCompanionBooks(Book book) { - if (companionBooks != null) - this.companionBooks.add(book); - } - public Book(String isbn, String title, String author, double cost, Publisher publisher) { this.isbn = isbn; this.title = title; @@ -60,6 +47,71 @@ public class Book { this.companionBooks = new HashSet<>(); } + // Getters and setters ... + public String getIsbn() { + return isbn; + } + + public Book setIsbn(String isbn) { + this.isbn = isbn; + return this; + } + + public String getTitle() { + return title; + } + + public Book setTitle(String title) { + this.title = title; + return this; + } + + public String getAuthor() { + return author; + } + + public Book setAuthor(String author) { + this.author = author; + return this; + } + + public Publisher getPublisher() { + return publisher; + } + + public Book setPublisher(Publisher publisher) { + this.publisher = publisher; + return this; + } + + public double getCost() { + return cost; + } + + public Book setCost(double cost) { + this.cost = cost; + return this; + } + + public LocalDateTime getPublishDate() { + return publishDate; + } + + public Book setPublishDate(LocalDateTime publishDate) { + this.publishDate = publishDate; + return this; + } + + public Set getCompanionBooks() { + return companionBooks; + } + + public Book addCompanionBooks(Book book) { + if (companionBooks != null) + this.companionBooks.add(book); + return this; + } + @Override public String toString() { return "Book [isbn=" + isbn + ", title=" + title + ", author=" + author + ", publisher=" + publisher + ", cost=" + cost + "]"; @@ -113,4 +165,4 @@ public class Book { return true; } -} \ No newline at end of file +} diff --git a/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonIntegrationTest.java b/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonIntegrationTest.java new file mode 100644 index 0000000000..e382ea4ab2 --- /dev/null +++ b/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonIntegrationTest.java @@ -0,0 +1,142 @@ +package com.baeldung.bsontojson; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.sql.Timestamp; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.TimeZone; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.bson.Document; +import org.bson.json.Converter; +import org.bson.json.JsonMode; +import org.bson.json.JsonWriterSettings; +import org.bson.json.StrictJsonWriter; +import org.bson.types.ObjectId; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.baeldung.morphia.domain.Book; +import com.baeldung.morphia.domain.Publisher; +import com.mongodb.MongoClient; +import com.mongodb.client.MongoDatabase; + +import dev.morphia.Datastore; +import dev.morphia.Morphia; + +public class BsonToJsonIntegrationTest { + + private static final String DB_NAME = "library"; + private static Datastore datastore; + + @BeforeClass + public static void setUp() { + Morphia morphia = new Morphia(); + morphia.mapPackage("com.baeldung.morphia"); + datastore = morphia.createDatastore(new MongoClient(), DB_NAME); + datastore.ensureIndexes(); + + datastore.save(new Book() + .setIsbn("isbn") + .setTitle("title") + .setAuthor("author") + .setCost(3.95) + .setPublisher(new Publisher(new ObjectId("fffffffffffffffffffffffa"),"publisher")) + .setPublishDate(LocalDateTime.parse("2020-01-01T18:13:32Z", DateTimeFormatter.ISO_DATE_TIME)) + .addCompanionBooks(new Book().setIsbn("isbn2"))); + } + + @AfterClass + public static void tearDown() { + datastore.delete(datastore.createQuery(Book.class)); + } + + @Test + public void givenBsonDocument_whenUsingStandardJsonTransformation_thenJsonDateIsObjectEpochTime() { + + String json = null; + try (MongoClient mongoClient = new MongoClient()) { + MongoDatabase mongoDatabase = mongoClient.getDatabase(DB_NAME); + Document bson = mongoDatabase.getCollection("Books").find().first(); + json = bson.toJson(); + } + + String expectedJson = "{\"_id\": \"isbn\", " + + "\"className\": \"com.baeldung.morphia.domain.Book\", " + + "\"title\": \"title\", " + + "\"author\": \"author\", " + + "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " + + "\"name\": \"publisher\"}, " + + "\"price\": 3.95, " + + "\"publishDate\": {\"$date\": 1577898812000}}"; + + assertNotNull(json); + + assertEquals(expectedJson, json); + } + + + @Test + public void givenBsonDocument_whenUsingRelaxedJsonTransformation_thenJsonDateIsObjectIsoDate() { + + String json = null; + try (MongoClient mongoClient = new MongoClient()) { + MongoDatabase mongoDatabase = mongoClient.getDatabase(DB_NAME); + Document bson = mongoDatabase.getCollection("Books").find().first(); + json = bson.toJson(JsonWriterSettings + .builder() + .outputMode(JsonMode.RELAXED) + .build()); + } + + String expectedJson = "{\"_id\": \"isbn\", " + + "\"className\": \"com.baeldung.morphia.domain.Book\", " + + "\"title\": \"title\", " + + "\"author\": \"author\", " + + "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " + + "\"name\": \"publisher\"}, " + + "\"price\": 3.95, " + + "\"publishDate\": {\"$date\": \"2020-01-01T17:13:32Z\"}}"; + + assertNotNull(json); + + assertEquals(expectedJson, json); + } + + @Test + public void givenBsonDocument_whenUsingCustomJsonTransformation_thenJsonDateIsStringField() { + + String json = null; + try (MongoClient mongoClient = new MongoClient()) { + MongoDatabase mongoDatabase = mongoClient.getDatabase(DB_NAME); + Document bson = mongoDatabase.getCollection("Books").find().first(); + json = bson.toJson(JsonWriterSettings + .builder() + .dateTimeConverter(new JsonDateTimeConverter()) + .build()); + } + + String expectedJson = "{\"_id\": \"isbn\", " + + "\"className\": \"com.baeldung.morphia.domain.Book\", " + + "\"title\": \"title\", " + + "\"author\": \"author\", " + + "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " + + "\"name\": \"publisher\"}, " + + "\"price\": 3.95, " + + "\"publishDate\": \"2020-01-01T17:13:32Z\"}"; + + assertEquals(expectedJson, json); + + } + +} diff --git a/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/JsonDateTimeConverter.java b/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/JsonDateTimeConverter.java new file mode 100644 index 0000000000..46023e363f --- /dev/null +++ b/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/JsonDateTimeConverter.java @@ -0,0 +1,30 @@ +package com.baeldung.bsontojson; + +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.TimeZone; + +import org.bson.json.Converter; +import org.bson.json.StrictJsonWriter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class JsonDateTimeConverter implements Converter { + + private static final Logger LOGGER = LoggerFactory.getLogger(JsonDateTimeConverter.class); + static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ISO_INSTANT + .withZone(ZoneId.of("UTC")); + + @Override + public void convert(Long value, StrictJsonWriter writer) { + try { + Instant instant = new Date(value).toInstant(); + String s = DATE_TIME_FORMATTER.format(instant); + writer.writeString(s); + } catch (Exception e) { + LOGGER.error(String.format("Fail to convert offset %d to JSON date", value), e); + } + } +} From 405230e25bf2cf92932b16d6dcc64acff80b9846 Mon Sep 17 00:00:00 2001 From: Kumar Chandrakant Date: Tue, 14 Apr 2020 10:52:05 +0530 Subject: [PATCH 217/503] Testing multithreading (#9088) --- .../core-java-concurrency-testing/.gitignore | 26 --- .../core-java-concurrency-testing/pom.xml | 170 +++++++++--------- 2 files changed, 85 insertions(+), 111 deletions(-) delete mode 100644 core-java-modules/core-java-concurrency-testing/.gitignore diff --git a/core-java-modules/core-java-concurrency-testing/.gitignore b/core-java-modules/core-java-concurrency-testing/.gitignore deleted file mode 100644 index 3de4cc647e..0000000000 --- a/core-java-modules/core-java-concurrency-testing/.gitignore +++ /dev/null @@ -1,26 +0,0 @@ -*.class - -0.* - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* -.resourceCache - -# Packaged files # -*.jar -*.war -*.ear - -# Files generated by integration tests -*.txt -backup-pom.xml -/bin/ -/temp - -#IntelliJ specific -.idea/ -*.iml \ No newline at end of file diff --git a/core-java-modules/core-java-concurrency-testing/pom.xml b/core-java-modules/core-java-concurrency-testing/pom.xml index bb3e6f5152..51de83f67c 100644 --- a/core-java-modules/core-java-concurrency-testing/pom.xml +++ b/core-java-modules/core-java-concurrency-testing/pom.xml @@ -1,93 +1,93 @@ - 4.0.0 - core-java-concurrency-testing - 0.1.0-SNAPSHOT - core-java-concurrency-testing - jar + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + core-java-concurrency-testing + 0.1.0-SNAPSHOT + core-java-concurrency-testing + jar - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../../parent-java - + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + - - - junit - junit - 4.13 - test - - - com.googlecode.thread-weaver - threadweaver - 0.2 - test - - - com.google.code.tempus-fugit - tempus-fugit - 1.1 - test - - - com.googlecode.multithreadedtc - multithreadedtc - 1.01 - test - - - org.openjdk.jcstress - jcstress-core - 0.5 - - + + + junit + junit + 4.13 + test + + + com.googlecode.thread-weaver + threadweaver + 0.2 + test + + + com.google.code.tempus-fugit + tempus-fugit + 1.1 + test + + + com.googlecode.multithreadedtc + multithreadedtc + 1.01 + test + + + org.openjdk.jcstress + jcstress-core + 0.5 + + - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - ${javac.target} - ${javac.target} - ${javac.target} - - + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + ${javac.target} + ${javac.target} + ${javac.target} + + - - org.apache.maven.plugins - maven-shade-plugin - 2.2 - - - main - package - - shade - - - jcstress - - - org.openjdk.jcstress.Main - - - META-INF/TestList - - - - - - - - + + org.apache.maven.plugins + maven-shade-plugin + 2.2 + + + main + package + + shade + + + jcstress + + + org.openjdk.jcstress.Main + + + META-INF/TestList + + + + + + + + From 63027fd269c46259d39e56b9ddd87380e99a5232 Mon Sep 17 00:00:00 2001 From: Gang Wu Date: Tue, 14 Apr 2020 00:43:27 -0600 Subject: [PATCH 218/503] BAEL-3961 Using a list of values in a JDBCTemplate IN clause --- .../main/java/com/baeldung/jdbc/Employee.java | 7 +++ .../java/com/baeldung/jdbc/EmployeeDAO.java | 43 ++++++++++++- .../baeldung/jdbc/EmployeeDAOUnitTest.java | 63 +++++++++++++++++-- 3 files changed, 106 insertions(+), 7 deletions(-) diff --git a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/Employee.java b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/Employee.java index a43eb265c7..d5f87ca3df 100644 --- a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/Employee.java +++ b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/Employee.java @@ -9,6 +9,13 @@ public class Employee { private String address; + public Employee(int id, String firstName, String lastName, String address) { + setId(id); + setFirstName(firstName); + setLastName(lastName); + setAddress(address); + } + public int getId() { return id; } diff --git a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java index b5bf9452ed..dec88ee1f6 100644 --- a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java +++ b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java @@ -1,21 +1,62 @@ package com.baeldung.jdbc; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import javax.sql.DataSource; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; +import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; +import org.springframework.jdbc.core.namedparam.SqlParameterSource; import org.springframework.stereotype.Repository; @Repository public class EmployeeDAO { private JdbcTemplate jdbcTemplate; + private NamedParameterJdbcTemplate namedJdbcTemplate; public void setDataSource(DataSource dataSource) { jdbcTemplate = new JdbcTemplate(dataSource); + namedJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); } public int getCountOfEmployees() { return jdbcTemplate.queryForObject("SELECT COUNT(*) FROM EMPLOYEE", Integer.class); } - + public List getEmployeesFromIdListNamed(List ids) { + SqlParameterSource parameters = new MapSqlParameterSource("ids", ids); + List employees = namedJdbcTemplate.query("SELECT * FROM EMPLOYEE WHERE id IN (:ids)", + parameters, + (rs, rowNum) -> new Employee(rs.getInt("id"), rs.getString("first_name"), rs.getString("last_name"), rs.getString("address"))); + + return employees; + } + + public List getEmployeesFromIdList(List ids) { + String inSql = String.join(",", Collections.nCopies(ids.size(), "?")); + List employees = jdbcTemplate.query("SELECT * FROM EMPLOYEE WHERE id IN (" + inSql +")", + ids.toArray(), + (rs, rowNum) -> new Employee(rs.getInt("id"), rs.getString("first_name"), rs.getString("last_name"), rs.getString("address"))); + + return employees; + } + + public List getEmployeesFromLargeIdList(List ids) { + jdbcTemplate.execute("CREATE TEMPORARY TABLE employee_tmp (id INT NOT NULL)"); + + List employeeIds = new ArrayList<>(); + for (Integer id : ids) { + employeeIds.add(new Object[] { id }); + } + jdbcTemplate.batchUpdate("INSERT INTO employee_tmp VALUES(?)", employeeIds); + + List employees = jdbcTemplate.query("SELECT * FROM EMPLOYEE WHERE id IN (SELECT id FROM employee_tmp)", + (rs, rowNum) -> new Employee(rs.getInt("id"), rs.getString("first_name"), rs.getString("last_name"), rs.getString("address"))); + + return employees; + } + } diff --git a/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java b/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java index 71e8fb4263..f21704221b 100644 --- a/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java +++ b/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java @@ -2,8 +2,12 @@ package com.baeldung.jdbc; import static org.junit.jupiter.api.Assertions.assertEquals; +import java.util.ArrayList; +import java.util.List; + import javax.sql.DataSource; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -14,13 +18,24 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import org.springframework.test.util.ReflectionTestUtils; - @RunWith(MockitoJUnitRunner.class) public class EmployeeDAOUnitTest { @Mock JdbcTemplate jdbcTemplate; + DataSource dataSource; + + @Before + public void setup() { + dataSource = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2) + .generateUniqueName(true) + .addScript("classpath:jdbc/schema.sql") + .addScript("classpath:jdbc/test-data.sql") + .build(); + + } + @Test public void whenMockJdbcTemplate_thenReturnCorrectEmployeeCount() { EmployeeDAO employeeDAO = new EmployeeDAO(); @@ -38,14 +53,50 @@ public class EmployeeDAOUnitTest { @Test public void whenInjectInMemoryDataSource_thenReturnCorrectEmployeeCount() { - DataSource dataSource = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2) - .addScript("classpath:jdbc/schema.sql") - .addScript("classpath:jdbc/test-data.sql") - .build(); - EmployeeDAO employeeDAO = new EmployeeDAO(); employeeDAO.setDataSource(dataSource); assertEquals(4, employeeDAO.getCountOfEmployees()); } + + @Test + public void givenSmallIdList_whenGetEmployeesFromIdList_thenReturnCorrectEmployees() { + List ids = new ArrayList<>(); + ids.add(1); + ids.add(3); + ids.add(4); + EmployeeDAO employeeDAO = new EmployeeDAO(); + employeeDAO.setDataSource(dataSource); + + List employees = employeeDAO.getEmployeesFromIdList(ids); + + assertEquals(3, employees.size()); + assertEquals(1, employees.get(0).getId()); + assertEquals(3, employees.get(1).getId()); + assertEquals(4, employees.get(2).getId()); + + employees = employeeDAO.getEmployeesFromIdListNamed(ids); + + assertEquals(3, employees.size()); + assertEquals(1, employees.get(0).getId()); + assertEquals(3, employees.get(1).getId()); + assertEquals(4, employees.get(2).getId()); + } + + @Test + public void givenLargeIdList_whenGetEmployeesFromIdList_thenReturnCorrectEmployees() { + List ids = new ArrayList<>(); + ids.add(1); + ids.add(3); + ids.add(4); + EmployeeDAO employeeDAO = new EmployeeDAO(); + employeeDAO.setDataSource(dataSource); + + List employees = employeeDAO.getEmployeesFromLargeIdList(ids); + + assertEquals(3, employees.size()); + assertEquals(1, employees.get(0).getId()); + assertEquals(3, employees.get(1).getId()); + assertEquals(4, employees.get(2).getId()); + } } From 4556829955c8a4a6718ecf32776fc70f55a9ec25 Mon Sep 17 00:00:00 2001 From: mthomas Date: Tue, 14 Apr 2020 06:44:36 -0500 Subject: [PATCH 219/503] Rename classes --- .../{SafeAccount.java => StampedAccount.java} | 16 ++++++++-------- ...st.java => ThreadStampedAccountUnitTest.java} | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) rename core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/atomicstampedreference/{SafeAccount.java => StampedAccount.java} (63%) rename core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/atomicstampedreference/{ThreadSafeAccountUnitTest.java => ThreadStampedAccountUnitTest.java} (68%) diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/atomicstampedreference/SafeAccount.java b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/atomicstampedreference/StampedAccount.java similarity index 63% rename from core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/atomicstampedreference/SafeAccount.java rename to core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/atomicstampedreference/StampedAccount.java index fe41429e22..1a46e1ba52 100644 --- a/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/atomicstampedreference/SafeAccount.java +++ b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/atomicstampedreference/StampedAccount.java @@ -3,32 +3,32 @@ package com.baeldung.atomicstampedreference; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicStampedReference; -public class SafeAccount { +public class StampedAccount { private AtomicInteger stamp = new AtomicInteger(0); - private AtomicStampedReference balance = new AtomicStampedReference<>(0, 0); + private AtomicStampedReference account = new AtomicStampedReference<>(0, 0); public int getBalance() { - return this.balance.get(new int[1]); + return this.account.get(new int[1]); } public int getStamp() { int[] stamps = new int[1]; - this.balance.get(stamps); + this.account.get(stamps); return stamps[0]; } public boolean deposit(int funds) { int[] stamps = new int[1]; - int current = this.balance.get(stamps); + int current = this.account.get(stamps); int newStamp = this.stamp.incrementAndGet(); - return this.balance.compareAndSet(current, current + funds, stamps[0], newStamp); + return this.account.compareAndSet(current, current + funds, stamps[0], newStamp); } public boolean withdrawal(int funds) { int[] stamps = new int[1]; - int current = this.balance.get(stamps); + int current = this.account.get(stamps); int newStamp = this.stamp.incrementAndGet(); - return this.balance.compareAndSet(current, current - funds, stamps[0], newStamp); + return this.account.compareAndSet(current, current - funds, stamps[0], newStamp); } } diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/atomicstampedreference/ThreadSafeAccountUnitTest.java b/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/atomicstampedreference/ThreadStampedAccountUnitTest.java similarity index 68% rename from core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/atomicstampedreference/ThreadSafeAccountUnitTest.java rename to core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/atomicstampedreference/ThreadStampedAccountUnitTest.java index bd33d5b4ec..ce83355073 100644 --- a/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/atomicstampedreference/ThreadSafeAccountUnitTest.java +++ b/core-java-modules/core-java-concurrency-advanced-3/src/test/java/com/baeldung/atomicstampedreference/ThreadStampedAccountUnitTest.java @@ -3,11 +3,11 @@ package com.baeldung.atomicstampedreference; import org.junit.Assert; import org.junit.Test; -public class ThreadSafeAccountUnitTest { +public class ThreadStampedAccountUnitTest { @Test - public void givenMultiThread_whenSafeAccount_thenSetBalance() throws InterruptedException { - SafeAccount account = new SafeAccount(); + public void givenMultiThread_whenStampedAccount_thenSetBalance() throws InterruptedException { + StampedAccount account = new StampedAccount(); Thread t = new Thread(() -> { while (!account.withdrawal(100)) Thread.yield(); From b14ab5ed7ac5ccaf3dd696f4eec9f97c499a2784 Mon Sep 17 00:00:00 2001 From: Tyrell Flurry Date: Tue, 14 Apr 2020 17:59:28 -0400 Subject: [PATCH 220/503] BAEL-3929: added another example per code review. --- .../src/main/java/com/baeldung/Main.java | 2 ++ .../main/java/com/baeldung/ReflectionMain.java | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 maven-all/maven-unused-dependencies/src/main/java/com/baeldung/ReflectionMain.java diff --git a/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/Main.java b/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/Main.java index abf6c7a03d..2626bb30a3 100644 --- a/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/Main.java +++ b/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/Main.java @@ -6,6 +6,7 @@ import java.util.Map; import org.slf4j.LoggerFactory; public class Main { + public static void main(String[] args) { Map map = new HashMap<>(); map.put("Dallas", "Texas"); @@ -15,4 +16,5 @@ public class Main { LoggerFactory.getLogger(Main.class) .info("Map: {}", map); } + } diff --git a/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/ReflectionMain.java b/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/ReflectionMain.java new file mode 100644 index 0000000000..48e42f7c66 --- /dev/null +++ b/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/ReflectionMain.java @@ -0,0 +1,15 @@ +package com.baeldung; + +public class ReflectionMain { + + public static void main(String[] args) { + ClassLoader classLoader = Main.class.getClassLoader(); + try { + System.out.println(classLoader.loadClass("org.apache.commons.collections.CollectionUtils") + .getSimpleName()); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + +} \ No newline at end of file From 78e180f35d3a6de9a05bd122df6614075332a6ac Mon Sep 17 00:00:00 2001 From: Gang Wu Date: Tue, 14 Apr 2020 19:23:11 -0600 Subject: [PATCH 221/503] BAEL-3961 Make the program more robust by only create the table when necessary and clean all data in the temp table. --- .../src/main/java/com/baeldung/jdbc/EmployeeDAO.java | 3 ++- .../src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java index dec88ee1f6..25d280ad12 100644 --- a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java +++ b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java @@ -45,7 +45,8 @@ public class EmployeeDAO { } public List getEmployeesFromLargeIdList(List ids) { - jdbcTemplate.execute("CREATE TEMPORARY TABLE employee_tmp (id INT NOT NULL)"); + jdbcTemplate.execute("CREATE TEMPORARY TABLE IF NOT EXISTS employee_tmp (id INT NOT NULL)"); + jdbcTemplate.update("DELETE FROM employee_tmp"); List employeeIds = new ArrayList<>(); for (Integer id : ids) { diff --git a/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java b/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java index f21704221b..369725bafd 100644 --- a/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java +++ b/persistence-modules/spring-persistence-simple-2/src/test/java/com/baeldung/jdbc/EmployeeDAOUnitTest.java @@ -98,5 +98,10 @@ public class EmployeeDAOUnitTest { assertEquals(1, employees.get(0).getId()); assertEquals(3, employees.get(1).getId()); assertEquals(4, employees.get(2).getId()); + + ids.clear(); + ids.add(2); + employees = employeeDAO.getEmployeesFromLargeIdList(ids); + assertEquals(1, employees.size()); } } From 7fdcf68ccb4ef95a7555095e5cccb46b25978f78 Mon Sep 17 00:00:00 2001 From: SippingCode <55111084+SippingCode@users.noreply.github.com> Date: Wed, 15 Apr 2020 07:26:52 +0200 Subject: [PATCH 222/503] BAEL 3970 - Manual logout with Spring Security (#9075) * Manual logout with Spring Security - Basic manual logout - logout with Clear Data Site Header * Add missing annotation for controller. Change mapping URL value. * Add intergration tests for manual logouts. * BAEL-3970 - Add asserts on test. Fix tests names. Remove unused imports. --- .../manuallogout/BasicAuthController.java | 32 +++++++++ .../manuallogout/ClearSiteDataController.java | 29 ++++++++ .../manuallogout/ManualLogoutApplication.java | 11 +++ .../SimpleSecurityConfiguration.java | 39 +++++++++++ .../ManualLogoutIntegrationTest.java | 70 +++++++++++++++++++ 5 files changed, 181 insertions(+) create mode 100644 spring-5-security/src/main/java/com/baeldung/manuallogout/BasicAuthController.java create mode 100644 spring-5-security/src/main/java/com/baeldung/manuallogout/ClearSiteDataController.java create mode 100644 spring-5-security/src/main/java/com/baeldung/manuallogout/ManualLogoutApplication.java create mode 100644 spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java create mode 100644 spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java diff --git a/spring-5-security/src/main/java/com/baeldung/manuallogout/BasicAuthController.java b/spring-5-security/src/main/java/com/baeldung/manuallogout/BasicAuthController.java new file mode 100644 index 0000000000..8f01940dce --- /dev/null +++ b/spring-5-security/src/main/java/com/baeldung/manuallogout/BasicAuthController.java @@ -0,0 +1,32 @@ +package com.baeldung.manuallogout; + +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +@Controller +public class BasicAuthController { + + @RequestMapping(value = {"/basiclogout"}, method = RequestMethod.POST) + public String logout(HttpServletRequest request, HttpServletResponse response) { + HttpSession session; + SecurityContextHolder.clearContext(); + session = request.getSession(false); + if (session != null) { + session.invalidate(); + } + for (Cookie cookie : request.getCookies()) { + String cookieName = cookie.getName(); + Cookie cookieToDelete = new Cookie(cookieName, null); + cookieToDelete.setMaxAge(0); + response.addCookie(cookieToDelete); + } + return "redirect:/login?logout"; + } +} diff --git a/spring-5-security/src/main/java/com/baeldung/manuallogout/ClearSiteDataController.java b/spring-5-security/src/main/java/com/baeldung/manuallogout/ClearSiteDataController.java new file mode 100644 index 0000000000..7eef397da3 --- /dev/null +++ b/spring-5-security/src/main/java/com/baeldung/manuallogout/ClearSiteDataController.java @@ -0,0 +1,29 @@ +package com.baeldung.manuallogout; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.web.authentication.logout.HeaderWriterLogoutHandler; +import org.springframework.security.web.header.writers.ClearSiteDataHeaderWriter; +import org.springframework.security.web.header.writers.ClearSiteDataHeaderWriter.Directive; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@Controller +public class ClearSiteDataController { + + Directive[] SOURCE = {Directive.COOKIES, Directive.STORAGE, Directive.EXECUTION_CONTEXTS, Directive.CACHE}; + + @RequestMapping(value = {"/csdlogout"}, method = RequestMethod.POST) + public String logout(HttpServletRequest request, HttpServletResponse response) { + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + if (auth != null) { + ClearSiteDataHeaderWriter csdHeaderWriter = new ClearSiteDataHeaderWriter(SOURCE); + new HeaderWriterLogoutHandler(csdHeaderWriter).logout(request, response, auth); + } + return "redirect:/login?logout"; + } +} diff --git a/spring-5-security/src/main/java/com/baeldung/manuallogout/ManualLogoutApplication.java b/spring-5-security/src/main/java/com/baeldung/manuallogout/ManualLogoutApplication.java new file mode 100644 index 0000000000..50ea356f03 --- /dev/null +++ b/spring-5-security/src/main/java/com/baeldung/manuallogout/ManualLogoutApplication.java @@ -0,0 +1,11 @@ +package com.baeldung.manuallogout; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ManualLogoutApplication { + public static void main(String[] args) { + SpringApplication.run(ManualLogoutApplication.class, args); + } +} diff --git a/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java b/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java new file mode 100644 index 0000000000..6f14f6fca2 --- /dev/null +++ b/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java @@ -0,0 +1,39 @@ +package com.baeldung.manuallogout; + +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; + +@Configuration +@EnableWebSecurity +public class SimpleSecurityConfiguration extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.formLogin() + .loginProcessingUrl("/login") + .loginPage("/login") + .usernameParameter("username") + .passwordParameter("password") + .defaultSuccessUrl("/") + .failureUrl("/login?error"); + } + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + auth.inMemoryAuthentication() + .withUser("user") + .password("password") + .roles("USER") + .and() + .withUser("manager") + .password("password") + .credentialsExpired(true) + .accountExpired(true) + .accountLocked(true) + .authorities("WRITE_PRIVILEGES", "READ_PRIVILEGES") + .roles("MANAGER"); + } +} diff --git a/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java b/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java new file mode 100644 index 0000000000..a64cb82910 --- /dev/null +++ b/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java @@ -0,0 +1,70 @@ +package com.baeldung.manuallogout; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpSession; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpSession; + +import static org.junit.Assert.assertNull; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.unauthenticated; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; + +@RunWith(SpringRunner.class) +@WebMvcTest() +public class ManualLogoutIntegrationTest { + + private static final String CLEAR_SITE_DATA_HEADER = "Clear-Site-Data"; + public static final int EXPIRY = 60 * 10; + public static final String COOKIE_NAME = "customerName"; + public static final String COOKIE_VALUE = "myName"; + public static final String ATTRIBUTE_NAME = "att"; + public static final String ATTRIBUTE_VALUE = "attvalue"; + + @Autowired + private MockMvc mockMvc; + + @WithMockUser(value = "spring") + @Test + public void givenLoggedUserWhenUserLogoutThenSessionCleared() throws Exception { + + MockHttpSession session = new MockHttpSession(); + session.setAttribute(ATTRIBUTE_NAME, ATTRIBUTE_VALUE); + + Cookie randomCookie = new Cookie(COOKIE_NAME, COOKIE_VALUE); + randomCookie.setMaxAge(EXPIRY); // 10 minutes + + MockHttpServletRequest requestStateAfterLogout = this.mockMvc.perform(post("/basiclogout").secure(true).with(csrf()).session(session).cookie(randomCookie)) + .andExpect(status().is3xxRedirection()) + .andExpect(unauthenticated()) + .andExpect(cookie().maxAge(COOKIE_NAME, 0)) + .andReturn() + .getRequest(); + + HttpSession sessionStateAfterLogout = requestStateAfterLogout.getSession(); + assertNull(sessionStateAfterLogout.getAttribute(ATTRIBUTE_NAME)); + + + } + + @WithMockUser(value = "spring") + @Test + public void givenLoggedUserWhenUserLogoutThenClearDataSiteHeaderPresent() throws Exception { + + this.mockMvc.perform(post("/csdlogout").secure(true).with(csrf())) + .andDo(print()) + .andExpect(status().is3xxRedirection()) + .andExpect(header().exists(CLEAR_SITE_DATA_HEADER)) + .andReturn(); + } +} \ No newline at end of file From 8c77609793091995b2bf77f4dd3e14ada27a7997 Mon Sep 17 00:00:00 2001 From: Aitor Cuesta Date: Wed, 15 Apr 2020 08:01:26 +0200 Subject: [PATCH 223/503] BAEL-3075 - Removing byte-buddy dependency --- persistence-modules/spring-boot-persistence-2/pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/persistence-modules/spring-boot-persistence-2/pom.xml b/persistence-modules/spring-boot-persistence-2/pom.xml index fd7cc467f9..9f456fa8af 100644 --- a/persistence-modules/spring-boot-persistence-2/pom.xml +++ b/persistence-modules/spring-boot-persistence-2/pom.xml @@ -51,11 +51,6 @@ spring-boot-starter-data-jpa - - net.bytebuddy - byte-buddy - - org.jdbi jdbi3-spring4 From 86c4eea3dd95a0e98e6bb882e482fe0702adbd20 Mon Sep 17 00:00:00 2001 From: Belma Jakupovic Date: Wed, 15 Apr 2020 21:15:59 +0200 Subject: [PATCH 224/503] additional answers mockito change repository method (#9082) --- .../mockito/additionalanswers/BookRepository.java | 15 +++++++++++---- .../mockito/additionalanswers/BookService.java | 4 ++-- .../additionalanswers/BookServiceUnitTest.java | 12 ++++++------ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookRepository.java b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookRepository.java index 78187e3f01..677ee502b4 100644 --- a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookRepository.java +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookRepository.java @@ -1,5 +1,9 @@ package com.baeldung.mockito.additionalanswers; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + public class BookRepository { public Book getByBookId(Long bookId) { return new Book(bookId, "To Kill a Mocking Bird", "Harper Lee", 256); @@ -9,9 +13,12 @@ public class BookRepository { return new Book(book.getBookId(), book.getTitle(), book.getAuthor(), book.getNumberOfPages()); } - public Book checkIfEquals(Book bookOne, Book bookTwo, Book bookThree) { - if (bookOne.equals(bookTwo) && bookTwo.equals(bookThree) && bookThree.equals(bookOne)) { - return bookOne; - } else return bookTwo; + public Book selectRandomBook(Book bookOne, Book bookTwo, Book bookThree) { + List selection = new ArrayList<>(); + selection.add(bookOne); + selection.add(bookTwo); + selection.add(bookThree); + Random random = new Random(); + return selection.get(random.nextInt(selection.size())); } } diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookService.java b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookService.java index 92c01f8a70..4499a6524b 100644 --- a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookService.java +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/additionalanswers/BookService.java @@ -15,8 +15,8 @@ public class BookService { return bookRepository.save(book); } - public Book checkifEquals(Book book1, Book book2, Book book3) { - return bookRepository.checkIfEquals(book1, book2, book3); + public Book selectRandomBook(Book book1, Book book2, Book book3) { + return bookRepository.selectRandomBook(book1, book2, book3); } } diff --git a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/additionalanswers/BookServiceUnitTest.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/additionalanswers/BookServiceUnitTest.java index c9527ec0ec..ee32bcf70c 100644 --- a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/additionalanswers/BookServiceUnitTest.java +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/additionalanswers/BookServiceUnitTest.java @@ -34,9 +34,9 @@ public class BookServiceUnitTest { Book book2 = new Book(2L, "Animal Farm", "George Orwell", 300); Book book3 = new Book(3L, "Romeo and Juliet", "William Shakespeare", 200); - Mockito.when(bookRepository.checkIfEquals(any(Book.class), any(Book.class), any(Book.class))).then(AdditionalAnswers.returnsSecondArg()); + Mockito.when(bookRepository.selectRandomBook(any(Book.class), any(Book.class), any(Book.class))).then(AdditionalAnswers.returnsSecondArg()); - Book secondBook = bookService.checkifEquals(book1, book2, book3); + Book secondBook = bookService.selectRandomBook(book1, book2, book3); assertEquals(secondBook, book2); } @@ -47,9 +47,9 @@ public class BookServiceUnitTest { Book book2 = new Book(2L, "Animal Farm", "George Orwell", 300); Book book3 = new Book(3L, "Romeo and Juliet", "William Shakespeare", 200); - Mockito.when(bookRepository.checkIfEquals(any(Book.class), any(Book.class), any(Book.class))).then(AdditionalAnswers.returnsLastArg()); + Mockito.when(bookRepository.selectRandomBook(any(Book.class), any(Book.class), any(Book.class))).then(AdditionalAnswers.returnsLastArg()); - Book lastBook = bookService.checkifEquals(book1, book2, book3); + Book lastBook = bookService.selectRandomBook(book1, book2, book3); assertEquals(lastBook, book3); } @@ -59,9 +59,9 @@ public class BookServiceUnitTest { Book book2 = new Book(2L, "Animal Farm", "George Orwell", 300); Book book3 = new Book(3L, "Romeo and Juliet", "William Shakespeare", 200); - Mockito.when(bookRepository.checkIfEquals(any(Book.class), any(Book.class), any(Book.class))).then(AdditionalAnswers.returnsArgAt(1)); + Mockito.when(bookRepository.selectRandomBook(any(Book.class), any(Book.class), any(Book.class))).then(AdditionalAnswers.returnsArgAt(1)); - Book bookOnIndex = bookService.checkifEquals(book1, book2, book3); + Book bookOnIndex = bookService.selectRandomBook(book1, book2, book3); assertEquals(bookOnIndex, book2); } From 23099cff16320fcd96c677b824c10b3caa723574 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Wed, 15 Apr 2020 21:19:02 +0200 Subject: [PATCH 225/503] BAEL-3994: Add example of chaining methods returning Optionals (#9102) * BAEL-3994: Add example of chaining methods returning Optionals * BAEL-3994: Update --- .../orelseoptional/ItemsProvider.java | 21 +++++++++++++++ .../OrElseOptionalUnitTest.java | 26 +++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 core-java-modules/core-java-optional/src/main/java/com/baeldung/orelseoptional/ItemsProvider.java diff --git a/core-java-modules/core-java-optional/src/main/java/com/baeldung/orelseoptional/ItemsProvider.java b/core-java-modules/core-java-optional/src/main/java/com/baeldung/orelseoptional/ItemsProvider.java new file mode 100644 index 0000000000..480dc782e4 --- /dev/null +++ b/core-java-modules/core-java-optional/src/main/java/com/baeldung/orelseoptional/ItemsProvider.java @@ -0,0 +1,21 @@ +package com.baeldung.orelseoptional; + +import java.util.Optional; + +public class ItemsProvider { + + Optional getEmptyItem() { + System.out.println("Returning an empty item"); + return Optional.empty(); + } + + Optional getNail() { + System.out.println("Returning a nail"); + return Optional.of("nail"); + } + + Optional getHammer() { + System.out.println("Returning a hammer"); + return Optional.of("hammer"); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-optional/src/test/java/com/baeldung/orelseoptional/OrElseOptionalUnitTest.java b/core-java-modules/core-java-optional/src/test/java/com/baeldung/orelseoptional/OrElseOptionalUnitTest.java index 91aebbeebd..e3bdedcd82 100644 --- a/core-java-modules/core-java-optional/src/test/java/com/baeldung/orelseoptional/OrElseOptionalUnitTest.java +++ b/core-java-modules/core-java-optional/src/test/java/com/baeldung/orelseoptional/OrElseOptionalUnitTest.java @@ -1,10 +1,10 @@ package com.baeldung.orelseoptional; -import static org.junit.Assert.assertEquals; +import org.junit.Test; import java.util.Optional; -import org.junit.Test; +import static org.junit.Assert.assertEquals; public class OrElseOptionalUnitTest { @@ -25,6 +25,28 @@ public class OrElseOptionalUnitTest { assertEquals(fallbackOptionalString, OptionalUtils.or(optionalString, fallbackOptionalString)); } + @Test + public void givenTwoOptionalMethods_whenFirstEmpty_thenSecondEvaluated() { + ItemsProvider itemsProvider = new ItemsProvider(); + + Optional item = itemsProvider.getEmptyItem() + .map(Optional::of) + .orElseGet(itemsProvider::getNail); + + assertEquals(Optional.of("nail"), item); + } + + @Test + public void givenTwoOptionalMethods_whenFirstNonEmpty_thenSecondNotEvaluated() { + ItemsProvider itemsProvider = new ItemsProvider(); + + Optional item = itemsProvider.getNail() + .map(Optional::of) + .orElseGet(itemsProvider::getHammer); + + assertEquals(Optional.of("nail"), item); + } + // Uncomment code when code base is compatible with Java 9 // @Test // public void givenOptional_whenEmptyValue_thenCustomMessage() { From ddf9da34bfcee9a28c3384a72967cd37b8073016 Mon Sep 17 00:00:00 2001 From: mikr Date: Wed, 15 Apr 2020 22:29:52 +0200 Subject: [PATCH 226/503] JAVA-617 Split or move core-java-datetime-java8 module --- .../core-java-datetime-java8-2/README.md | 2 ++ .../com/baeldung/random/LegacyRandomDateTimes.java | 0 .../java/com/baeldung/random/RandomDateTimes.java | 0 .../main/java/com/baeldung/random/RandomDates.java | 0 .../main/java/com/baeldung/random/RandomTimes.java | 0 .../baeldung/localdate/LocalDateExampleUnitTest.java | 12 ++++++------ .../random/LegacyRandomDateTimesUnitTest.java | 0 .../com/baeldung/random/RandomDateTimesUnitTest.java | 0 .../com/baeldung/random/RandomDatesUnitTest.java | 0 .../com/baeldung/random/RandomTimesUnitTest.java | 0 core-java-modules/core-java-datetime-java8/README.md | 2 +- 11 files changed, 9 insertions(+), 7 deletions(-) rename core-java-modules/{core-java-datetime-java8 => core-java-datetime-java8-2}/src/main/java/com/baeldung/random/LegacyRandomDateTimes.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-datetime-java8-2}/src/main/java/com/baeldung/random/RandomDateTimes.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-datetime-java8-2}/src/main/java/com/baeldung/random/RandomDates.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-datetime-java8-2}/src/main/java/com/baeldung/random/RandomTimes.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-datetime-java8-2}/src/test/java/com/baeldung/random/LegacyRandomDateTimesUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-datetime-java8-2}/src/test/java/com/baeldung/random/RandomDateTimesUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-datetime-java8-2}/src/test/java/com/baeldung/random/RandomDatesUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-datetime-java8-2}/src/test/java/com/baeldung/random/RandomTimesUnitTest.java (100%) diff --git a/core-java-modules/core-java-datetime-java8-2/README.md b/core-java-modules/core-java-datetime-java8-2/README.md index e53d0236c2..f16563aacc 100644 --- a/core-java-modules/core-java-datetime-java8-2/README.md +++ b/core-java-modules/core-java-datetime-java8-2/README.md @@ -1,3 +1,5 @@ ### Relevant Articles: +- [Generating Random Dates in Java](https://www.baeldung.com/java-random-dates) - [Creating a LocalDate with Values in Java](https://www.baeldung.com/java-creating-localdate-with-values) +- [[<-- Prev]](/core-java-modules/core-java-datetime-java8-1) \ No newline at end of file diff --git a/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/random/LegacyRandomDateTimes.java b/core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/random/LegacyRandomDateTimes.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/random/LegacyRandomDateTimes.java rename to core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/random/LegacyRandomDateTimes.java diff --git a/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/random/RandomDateTimes.java b/core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/random/RandomDateTimes.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/random/RandomDateTimes.java rename to core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/random/RandomDateTimes.java diff --git a/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/random/RandomDates.java b/core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/random/RandomDates.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/random/RandomDates.java rename to core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/random/RandomDates.java diff --git a/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/random/RandomTimes.java b/core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/random/RandomTimes.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/random/RandomTimes.java rename to core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/random/RandomTimes.java diff --git a/core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/localdate/LocalDateExampleUnitTest.java b/core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/localdate/LocalDateExampleUnitTest.java index dff15486a4..d65118ba3a 100644 --- a/core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/localdate/LocalDateExampleUnitTest.java +++ b/core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/localdate/LocalDateExampleUnitTest.java @@ -11,31 +11,31 @@ public class LocalDateExampleUnitTest { @Test public void givenValues_whenUsingOfMethod_thenLocalDate() { - assertEquals("2020-01-08", date.getCustomDateOne(2020, 1, 8)); + assertEquals("2020-01-08", date.getCustomDateOne(2020, 1, 8).toString()); } @Test public void givenValuesWithMonthEnum_whenUsingOfMethod_thenLocalDate() { - assertEquals("2020-01-08", date.getCustomDateTwo(2020, Month.JANUARY, 8)); + assertEquals("2020-01-08", date.getCustomDateTwo(2020, Month.JANUARY, 8).toString()); } @Test public void givenValues_whenUsingEpochDay_thenLocalDate() { - assertEquals("2020-01-08", date.getDateFromEpochDay(18269)); + assertEquals("2020-01-08", date.getDateFromEpochDay(18269).toString()); } @Test public void givenValues_whenUsingYearDay_thenLocalDate() { - assertEquals("2020-01-08", date.getDateFromYearAndDayOfYear(2020, 8)); + assertEquals("2020-01-08", date.getDateFromYearAndDayOfYear(2020, 8).toString()); } @Test public void givenValues_whenUsingParse_thenLocalDate() { - assertEquals("2020-01-08", date.getDateFromString("2020-01-08")); + assertEquals("2020-01-08", date.getDateFromString("2020-01-08").toString()); } @Test public void givenValuesWithFormatter_whenUsingParse_thenLocalDate() { - assertEquals("2020-01-08", date.getDateFromStringAndFormatter("8-Jan-2020", "d-MMM-yyyy")); + assertEquals("2020-01-08", date.getDateFromStringAndFormatter("8-Jan-2020", "d-MMM-yyyy").toString()); } } diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/random/LegacyRandomDateTimesUnitTest.java b/core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/random/LegacyRandomDateTimesUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/random/LegacyRandomDateTimesUnitTest.java rename to core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/random/LegacyRandomDateTimesUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/random/RandomDateTimesUnitTest.java b/core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/random/RandomDateTimesUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/random/RandomDateTimesUnitTest.java rename to core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/random/RandomDateTimesUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/random/RandomDatesUnitTest.java b/core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/random/RandomDatesUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/random/RandomDatesUnitTest.java rename to core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/random/RandomDatesUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/random/RandomTimesUnitTest.java b/core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/random/RandomTimesUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/random/RandomTimesUnitTest.java rename to core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/random/RandomTimesUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/README.md b/core-java-modules/core-java-datetime-java8/README.md index dfbe9c997f..c35683a589 100644 --- a/core-java-modules/core-java-datetime-java8/README.md +++ b/core-java-modules/core-java-datetime-java8/README.md @@ -13,4 +13,4 @@ This module contains articles about the Date and Time API introduced with Java 8 - [How to Get the Start and the End of a Day using Java](http://www.baeldung.com/java-day-start-end) - [Set the Time Zone of a Date in Java](https://www.baeldung.com/java-set-date-time-zone) - [Comparing Dates in Java](https://www.baeldung.com/java-comparing-dates) -- [Generating Random Dates in Java](https://www.baeldung.com/java-random-dates) +- [[Next -->]](/core-java-modules/core-java-datetime-java8-2) From 926614e12944c6a12aae61c6af1e9be8c32f5efa Mon Sep 17 00:00:00 2001 From: mikr Date: Wed, 15 Apr 2020 23:04:39 +0200 Subject: [PATCH 227/503] JAVA-615 Split or move algorithms-sorting module --- algorithms-sorting-2/README.md | 4 ++++ .../algorithms}/bynumber/NaturalOrderComparators.java | 2 +- .../java/com/baeldung/algorithms/inoutsort/InOutSort.java | 0 .../com/baeldung/algorithms/stringsort/AnagramValidator.java | 0 .../bynumber/NaturalOrderComparatorsUnitTest.java | 3 +-- .../com/baeldung/algorithms/inoutsort/InOutSortUnitTest.java | 0 .../algorithms/stringsort/AnagramValidatorUnitTest.java | 0 .../baeldung/algorithms/stringsort/SortStringUnitTest.java | 0 algorithms-sorting/README.md | 5 +---- 9 files changed, 7 insertions(+), 7 deletions(-) rename {algorithms-sorting/src/main/java/com/baeldung/algorithms/sort => algorithms-sorting-2/src/main/java/com/baeldung/algorithms}/bynumber/NaturalOrderComparators.java (94%) rename {algorithms-sorting => algorithms-sorting-2}/src/main/java/com/baeldung/algorithms/inoutsort/InOutSort.java (100%) rename {algorithms-sorting => algorithms-sorting-2}/src/main/java/com/baeldung/algorithms/stringsort/AnagramValidator.java (100%) rename {algorithms-sorting/src/test/java/com/baeldung/algorithms/sort => algorithms-sorting-2/src/test/java/com/baeldung/algorithms}/bynumber/NaturalOrderComparatorsUnitTest.java (95%) rename {algorithms-sorting => algorithms-sorting-2}/src/test/java/com/baeldung/algorithms/inoutsort/InOutSortUnitTest.java (100%) rename {algorithms-sorting => algorithms-sorting-2}/src/test/java/com/baeldung/algorithms/stringsort/AnagramValidatorUnitTest.java (100%) rename {algorithms-sorting => algorithms-sorting-2}/src/test/java/com/baeldung/algorithms/stringsort/SortStringUnitTest.java (100%) diff --git a/algorithms-sorting-2/README.md b/algorithms-sorting-2/README.md index 897621bc41..71c9b8f86c 100644 --- a/algorithms-sorting-2/README.md +++ b/algorithms-sorting-2/README.md @@ -1,3 +1,7 @@ ### Relevant Articles: +- [Sorting a String Alphabetically in Java](https://www.baeldung.com/java-sort-string-alphabetically) +- [Sorting Strings by Contained Numbers in Java](https://www.baeldung.com/java-sort-strings-contained-numbers) +- [How an In-Place Sorting Algorithm Works](https://www.baeldung.com/java-in-place-sorting) - [Partitioning and Sorting Arrays with Many Repeated Entries](https://www.baeldung.com/java-sorting-arrays-with-repeated-entries) +- More articles: [[<-- prev]](/algorithms-sorting) diff --git a/algorithms-sorting/src/main/java/com/baeldung/algorithms/sort/bynumber/NaturalOrderComparators.java b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/bynumber/NaturalOrderComparators.java similarity index 94% rename from algorithms-sorting/src/main/java/com/baeldung/algorithms/sort/bynumber/NaturalOrderComparators.java rename to algorithms-sorting-2/src/main/java/com/baeldung/algorithms/bynumber/NaturalOrderComparators.java index b177bd60fc..148a9a21f9 100644 --- a/algorithms-sorting/src/main/java/com/baeldung/algorithms/sort/bynumber/NaturalOrderComparators.java +++ b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/bynumber/NaturalOrderComparators.java @@ -1,4 +1,4 @@ -package com.baeldung.algorithms.sort.bynumber; +package com.baeldung.algorithms.bynumber; import java.util.Comparator; diff --git a/algorithms-sorting/src/main/java/com/baeldung/algorithms/inoutsort/InOutSort.java b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/inoutsort/InOutSort.java similarity index 100% rename from algorithms-sorting/src/main/java/com/baeldung/algorithms/inoutsort/InOutSort.java rename to algorithms-sorting-2/src/main/java/com/baeldung/algorithms/inoutsort/InOutSort.java diff --git a/algorithms-sorting/src/main/java/com/baeldung/algorithms/stringsort/AnagramValidator.java b/algorithms-sorting-2/src/main/java/com/baeldung/algorithms/stringsort/AnagramValidator.java similarity index 100% rename from algorithms-sorting/src/main/java/com/baeldung/algorithms/stringsort/AnagramValidator.java rename to algorithms-sorting-2/src/main/java/com/baeldung/algorithms/stringsort/AnagramValidator.java diff --git a/algorithms-sorting/src/test/java/com/baeldung/algorithms/sort/bynumber/NaturalOrderComparatorsUnitTest.java b/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/bynumber/NaturalOrderComparatorsUnitTest.java similarity index 95% rename from algorithms-sorting/src/test/java/com/baeldung/algorithms/sort/bynumber/NaturalOrderComparatorsUnitTest.java rename to algorithms-sorting-2/src/test/java/com/baeldung/algorithms/bynumber/NaturalOrderComparatorsUnitTest.java index 2f05f62147..aaa5de87e1 100644 --- a/algorithms-sorting/src/test/java/com/baeldung/algorithms/sort/bynumber/NaturalOrderComparatorsUnitTest.java +++ b/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/bynumber/NaturalOrderComparatorsUnitTest.java @@ -1,6 +1,5 @@ -package com.baeldung.algorithms.sort.bynumber; +package com.baeldung.algorithms.bynumber; -import com.baeldung.algorithms.sort.bynumber.NaturalOrderComparators; import org.junit.Test; import java.util.ArrayList; diff --git a/algorithms-sorting/src/test/java/com/baeldung/algorithms/inoutsort/InOutSortUnitTest.java b/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/inoutsort/InOutSortUnitTest.java similarity index 100% rename from algorithms-sorting/src/test/java/com/baeldung/algorithms/inoutsort/InOutSortUnitTest.java rename to algorithms-sorting-2/src/test/java/com/baeldung/algorithms/inoutsort/InOutSortUnitTest.java diff --git a/algorithms-sorting/src/test/java/com/baeldung/algorithms/stringsort/AnagramValidatorUnitTest.java b/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/stringsort/AnagramValidatorUnitTest.java similarity index 100% rename from algorithms-sorting/src/test/java/com/baeldung/algorithms/stringsort/AnagramValidatorUnitTest.java rename to algorithms-sorting-2/src/test/java/com/baeldung/algorithms/stringsort/AnagramValidatorUnitTest.java diff --git a/algorithms-sorting/src/test/java/com/baeldung/algorithms/stringsort/SortStringUnitTest.java b/algorithms-sorting-2/src/test/java/com/baeldung/algorithms/stringsort/SortStringUnitTest.java similarity index 100% rename from algorithms-sorting/src/test/java/com/baeldung/algorithms/stringsort/SortStringUnitTest.java rename to algorithms-sorting-2/src/test/java/com/baeldung/algorithms/stringsort/SortStringUnitTest.java diff --git a/algorithms-sorting/README.md b/algorithms-sorting/README.md index 15a5ec6e02..b4b90bf954 100644 --- a/algorithms-sorting/README.md +++ b/algorithms-sorting/README.md @@ -11,10 +11,7 @@ This module contains articles about sorting algorithms. - [Heap Sort in Java](https://www.baeldung.com/java-heap-sort) - [Shell Sort in Java](https://www.baeldung.com/java-shell-sort) - [Counting Sort in Java](https://www.baeldung.com/java-counting-sort) -- [Sorting Strings by Contained Numbers in Java](https://www.baeldung.com/java-sort-strings-contained-numbers) -- [How an In-Place Sorting Algorithm Works](https://www.baeldung.com/java-in-place-sorting) - [Selection Sort in Java](https://www.baeldung.com/java-selection-sort) -- [Sorting Strings by Contained Numbers in Java](https://www.baeldung.com/java-sort-strings-contained-numbers) - [Radix Sort in Java](https://www.baeldung.com/java-radix-sort) -- [Sorting a String Alphabetically in Java](https://www.baeldung.com/java-sort-string-alphabetically) - [Bucket Sort in Java](https://www.baeldung.com/java-bucket-sort) +- More articles: [[next -->]](/algorithms-sorintg-2) From 5b59902cb254becc9521689d8a01c3d184f941b2 Mon Sep 17 00:00:00 2001 From: Kyle Doyle Date: Thu, 16 Apr 2020 09:55:40 -0400 Subject: [PATCH 228/503] Removed rest of project --- aws-app-sync/pom.xml | 49 +++++++++++++++++++ .../awsappsync/AwsAppSyncApplication.java | 13 +++++ .../src/main/resources/application.properties | 1 + .../AwsAppSyncApplicationTests.java | 13 +++++ 4 files changed, 76 insertions(+) create mode 100644 aws-app-sync/pom.xml create mode 100644 aws-app-sync/src/main/java/com/baeldung/awsappsync/AwsAppSyncApplication.java create mode 100644 aws-app-sync/src/main/resources/application.properties create mode 100644 aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java diff --git a/aws-app-sync/pom.xml b/aws-app-sync/pom.xml new file mode 100644 index 0000000000..af02307e66 --- /dev/null +++ b/aws-app-sync/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.2.6.RELEASE + + + com.baeldung + aws-app-sync + 0.0.1-SNAPSHOT + aws-app-sync + Demo project for Spring Boot using AWS App Sync + + + 1.8 + + + + + 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/aws-app-sync/src/main/java/com/baeldung/awsappsync/AwsAppSyncApplication.java b/aws-app-sync/src/main/java/com/baeldung/awsappsync/AwsAppSyncApplication.java new file mode 100644 index 0000000000..ae012c91a5 --- /dev/null +++ b/aws-app-sync/src/main/java/com/baeldung/awsappsync/AwsAppSyncApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.awsappsync; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class AwsAppSyncApplication { + + public static void main(String[] args) { + SpringApplication.run(AwsAppSyncApplication.class, args); + } + +} diff --git a/aws-app-sync/src/main/resources/application.properties b/aws-app-sync/src/main/resources/application.properties new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/aws-app-sync/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java b/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java new file mode 100644 index 0000000000..7b82393865 --- /dev/null +++ b/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java @@ -0,0 +1,13 @@ +package com.baeldung.awsappsync; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class AwsAppSyncApplicationTests { + + @Test + void contextLoads() { + } + +} From 1239da8e6d88af335f060ae4f04e0ecade4a8fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20G=C5=82=C3=B3wka?= Date: Thu, 16 Apr 2020 21:23:23 +0200 Subject: [PATCH 229/503] BAEL-3505: Added util class to check server connection (#9013) * BAEL-3505: Added util class to check server connection * fixed formatting * removed unnecessary sout --- .../connectexception/ConnectionChecker.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 core-java-modules/core-java-networking-2/src/main/java/com/baeldung/connectexception/ConnectionChecker.java diff --git a/core-java-modules/core-java-networking-2/src/main/java/com/baeldung/connectexception/ConnectionChecker.java b/core-java-modules/core-java-networking-2/src/main/java/com/baeldung/connectexception/ConnectionChecker.java new file mode 100644 index 0000000000..360fb6ecaa --- /dev/null +++ b/core-java-modules/core-java-networking-2/src/main/java/com/baeldung/connectexception/ConnectionChecker.java @@ -0,0 +1,24 @@ +package com.baeldung.connectexception; + +import java.net.ConnectException; +import java.net.Socket; + +public class ConnectionChecker { + public static void main(String[] args) { + String host = "localhost"; + int port = 5000; + + try { + Socket clientSocket = new Socket(host, port); + + // successfully connected to host, do something with opened socket + + clientSocket.close(); + } catch (ConnectException e) { + // host and port combination not valid + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + } +} From 2815700ebffd2e4caf655aed04afb90dc7fffb44 Mon Sep 17 00:00:00 2001 From: vatsalgosar Date: Fri, 17 Apr 2020 01:10:04 +0530 Subject: [PATCH 230/503] BAEL-3919 (#9072) BAEL-3919 code --- .../ComputeIfAbsentUnitTest.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/computeifabsent/ComputeIfAbsentUnitTest.java diff --git a/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/computeifabsent/ComputeIfAbsentUnitTest.java b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/computeifabsent/ComputeIfAbsentUnitTest.java new file mode 100644 index 0000000000..391a059f05 --- /dev/null +++ b/core-java-modules/core-java-collections-maps-3/src/test/java/com/baeldung/map/computeifabsent/ComputeIfAbsentUnitTest.java @@ -0,0 +1,39 @@ +package com.baeldung.map.computeifabsent; + +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +public class ComputeIfAbsentUnitTest { + + @Test + public void whenKeyIsPresent_thenFetchTheValue() { + Map stringLength = new HashMap<>(); + stringLength.put("John", 5); + assertEquals((long)stringLength.computeIfAbsent("John", s -> s.length()), 5); + } + + @Test + public void whenKeyIsNotPresent_thenComputeTheValueUsingMappingFunctionAndStore() { + Map stringLength = new HashMap<>(); + assertEquals((long)stringLength.computeIfAbsent("John", s -> s.length()), 4); + assertEquals((long)stringLength.get("John"), 4); + } + + @Test + public void whenMappingFunctionReturnsNull_thenDoNotRecordMapping() { + Map stringLength = new HashMap<>(); + assertEquals(stringLength.computeIfAbsent("John", s -> null), null); + assertNull(stringLength.get("John")); + } + + @Test(expected = RuntimeException.class) + public void whenMappingFunctionThrowsException_thenExceptionIsRethrown() { + Map stringLength = new HashMap<>(); + stringLength.computeIfAbsent("John", s -> {throw new RuntimeException();}); + } +} From 6ceff529ad9ed33614e52198018d31ac38961050 Mon Sep 17 00:00:00 2001 From: Mona Mohamadinia Date: Fri, 17 Apr 2020 00:17:10 +0430 Subject: [PATCH 231/503] Added a few code snippets (#9084) --- .../closure/StreamClosureSnippets.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 core-java-modules/core-java-streams-3/src/main/java/com/baeldung/streams/closure/StreamClosureSnippets.java diff --git a/core-java-modules/core-java-streams-3/src/main/java/com/baeldung/streams/closure/StreamClosureSnippets.java b/core-java-modules/core-java-streams-3/src/main/java/com/baeldung/streams/closure/StreamClosureSnippets.java new file mode 100644 index 0000000000..10e5716e31 --- /dev/null +++ b/core-java-modules/core-java-streams-3/src/main/java/com/baeldung/streams/closure/StreamClosureSnippets.java @@ -0,0 +1,30 @@ +package com.baeldung.streams.closure; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * Contains a couple of simple stream API usages. + */ +public class StreamClosureSnippets { + + public static void main(String[] args) throws IOException { + // Collection based streams shouldn't be closed + Arrays.asList("Red", "Blue", "Green") + .stream() + .filter(c -> c.length() > 4) + .map(String::toUpperCase) + .forEach(System.out::print); + + String[] colors = {"Red", "Blue", "Green"}; + Arrays.stream(colors).map(String::toUpperCase).forEach(System.out::println); + + // IO-Based Streams Should be Closed via Try with Resources + try (Stream lines = Files.lines(Paths.get("/path/tp/file"))) { + // lines will be closed after exiting the try block + } + } +} From e41a34fc057d591a67276c566f2c9db579103797 Mon Sep 17 00:00:00 2001 From: Dhrubajyoti Bhattacharjee Date: Fri, 17 Apr 2020 08:15:36 +0200 Subject: [PATCH 232/503] Bael 2980 move c ra sh article to new module (#9103) --- pom.xml | 1 + spring-mvc-crash/.gitignore | 13 ++ spring-mvc-crash/README.md | 11 ++ spring-mvc-crash/pom.xml | 176 ++++++++++++++++++ .../com/baeldung/spring/ClientWebConfig.java | 16 ++ .../baeldung/spring/ClientWebConfigJava.java | 33 ++++ .../spring/controller/WelcomeController.java | 18 ++ .../contentManagementWebMvcConfig.xml | 42 +++++ .../src/main/resources/logback.xml | 19 ++ .../src/main/resources/messages.properties | 2 + .../src/main/resources/webMvcConfig.xml | 38 ++++ .../WEB-INF/crash/commands/message.groovy | 14 ++ .../WEB-INF/crash/commands/message2.java | 14 ++ .../webapp/WEB-INF/crash/crash.properties | 1 + .../webapp/WEB-INF/crash/telnet.properties | 65 +++++++ .../src/main/webapp/WEB-INF/mvc-servlet.xml | 52 ++++++ .../src/main/webapp/WEB-INF/view/error.jsp | 20 ++ .../main/webapp/WEB-INF/view/errorPage.jsp | 10 + .../src/main/webapp/WEB-INF/view/welcome.jsp | 15 ++ .../src/main/webapp/WEB-INF/web.xml | 70 +++++++ spring-mvc-crash/src/main/webapp/index.jsp | 20 ++ .../src/main/webapp/jsp/ExampleThree.jsp | 10 + .../src/main/webapp/jsp/ExampleTwo.jsp | 13 ++ .../src/main/webapp/jsp/index.jsp | 12 ++ .../java/com/baeldung/SpringContextTest.java | 19 ++ spring-mvc-xml/README.md | 1 - 26 files changed, 704 insertions(+), 1 deletion(-) create mode 100644 spring-mvc-crash/.gitignore create mode 100644 spring-mvc-crash/README.md create mode 100644 spring-mvc-crash/pom.xml create mode 100644 spring-mvc-crash/src/main/java/com/baeldung/spring/ClientWebConfig.java create mode 100644 spring-mvc-crash/src/main/java/com/baeldung/spring/ClientWebConfigJava.java create mode 100644 spring-mvc-crash/src/main/java/com/baeldung/spring/controller/WelcomeController.java create mode 100644 spring-mvc-crash/src/main/resources/contentManagementWebMvcConfig.xml create mode 100644 spring-mvc-crash/src/main/resources/logback.xml create mode 100644 spring-mvc-crash/src/main/resources/messages.properties create mode 100644 spring-mvc-crash/src/main/resources/webMvcConfig.xml create mode 100644 spring-mvc-crash/src/main/webapp/WEB-INF/crash/commands/message.groovy create mode 100644 spring-mvc-crash/src/main/webapp/WEB-INF/crash/commands/message2.java create mode 100644 spring-mvc-crash/src/main/webapp/WEB-INF/crash/crash.properties create mode 100644 spring-mvc-crash/src/main/webapp/WEB-INF/crash/telnet.properties create mode 100644 spring-mvc-crash/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-mvc-crash/src/main/webapp/WEB-INF/view/error.jsp create mode 100644 spring-mvc-crash/src/main/webapp/WEB-INF/view/errorPage.jsp create mode 100644 spring-mvc-crash/src/main/webapp/WEB-INF/view/welcome.jsp create mode 100644 spring-mvc-crash/src/main/webapp/WEB-INF/web.xml create mode 100644 spring-mvc-crash/src/main/webapp/index.jsp create mode 100644 spring-mvc-crash/src/main/webapp/jsp/ExampleThree.jsp create mode 100644 spring-mvc-crash/src/main/webapp/jsp/ExampleTwo.jsp create mode 100644 spring-mvc-crash/src/main/webapp/jsp/index.jsp create mode 100644 spring-mvc-crash/src/test/java/com/baeldung/SpringContextTest.java diff --git a/pom.xml b/pom.xml index 99d0943582..9e3b354d74 100644 --- a/pom.xml +++ b/pom.xml @@ -1202,6 +1202,7 @@ spring-mvc-views spring-mvc-webflow spring-mvc-xml + spring-mvc-crash spring-protobuf spring-quartz diff --git a/spring-mvc-crash/.gitignore b/spring-mvc-crash/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/spring-mvc-crash/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/spring-mvc-crash/README.md b/spring-mvc-crash/README.md new file mode 100644 index 0000000000..f158a947b6 --- /dev/null +++ b/spring-mvc-crash/README.md @@ -0,0 +1,11 @@ +## Spring MVC XML + +This module contains articles about Spring MVC with XML configuration + +### Relevant Articles: + +- [Getting Started with CRaSH](https://www.baeldung.com/jvm-crash-shell) + +## Spring MVC with XML Configuration Example Project + +- access a sample jsp page at: `http://localhost:8080/spring-mvc-crash/welcome.htm \ No newline at end of file diff --git a/spring-mvc-crash/pom.xml b/spring-mvc-crash/pom.xml new file mode 100644 index 0000000000..d23e18361b --- /dev/null +++ b/spring-mvc-crash/pom.xml @@ -0,0 +1,176 @@ + + + 4.0.0 + spring-mvc-crash + 0.1-SNAPSHOT + spring-mvc-xml + war + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + + + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + + + javax.servlet + javax.servlet-api + ${javax.servlet-api.version} + provided + + + + javax.servlet + jstl + ${jstl.version} + runtime + + + + org.hibernate.validator + hibernate-validator + ${hibernate-validator.version} + + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + + commons-io + commons-io + ${commons-io.version} + + + com.maxmind.geoip2 + geoip2 + ${geoip2.version} + + + com.fasterxml.jackson.core + jackson-databind + + + commons-logging + commons-logging + + + + + org.glassfish + javax.el + ${javax.el.version} + + + + org.springframework.boot + spring-boot-starter-test + ${spring-boot.version} + test + + + + + org.crashub + crash.embed.spring + ${crash.version} + + + org.crashub + crash.cli + ${crash.version} + + + org.crashub + crash.connectors.telnet + ${crash.version} + + + log4j + log4j + + + + + + + org.codehaus.groovy + groovy + ${groovy.version} + + + + + spring-mvc-xml + + + src/main/resources + true + + + + + + + org.apache.maven.plugins + maven-war-plugin + ${maven-war-plugin.version} + + + + + + + + + 5.0.2.RELEASE + 1.5.10.RELEASE + + + 5.1.40 + + + 4.4.5 + 4.5.2 + + + 6.0.10.Final + 3.0.1-b08 + + + 19.0 + 2.8.0 + + + 1.6.1 + + 1.3.2 + 3.0.0-rc-3 + + + + diff --git a/spring-mvc-crash/src/main/java/com/baeldung/spring/ClientWebConfig.java b/spring-mvc-crash/src/main/java/com/baeldung/spring/ClientWebConfig.java new file mode 100644 index 0000000000..cc60a1ff8f --- /dev/null +++ b/spring-mvc-crash/src/main/java/com/baeldung/spring/ClientWebConfig.java @@ -0,0 +1,16 @@ +package com.baeldung.spring; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.ImportResource; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@ImportResource("classpath:webMvcConfig.xml") +@Configuration +@ComponentScan +public class ClientWebConfig implements WebMvcConfigurer { + + public ClientWebConfig() { + super(); + } +} \ No newline at end of file diff --git a/spring-mvc-crash/src/main/java/com/baeldung/spring/ClientWebConfigJava.java b/spring-mvc-crash/src/main/java/com/baeldung/spring/ClientWebConfigJava.java new file mode 100644 index 0000000000..55af23034f --- /dev/null +++ b/spring-mvc-crash/src/main/java/com/baeldung/spring/ClientWebConfigJava.java @@ -0,0 +1,33 @@ +package com.baeldung.spring; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.validation.beanvalidation.MethodValidationPostProcessor; +import org.springframework.web.servlet.ViewResolver; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.JstlView; + +@ComponentScan("com.baeldung.spring") +public class ClientWebConfigJava implements WebMvcConfigurer { + + public ClientWebConfigJava() { + super(); + } + + @Bean + public ViewResolver viewResolver() { + final InternalResourceViewResolver bean = new InternalResourceViewResolver(); + + bean.setViewClass(JstlView.class); + bean.setPrefix("/WEB-INF/view/"); + bean.setSuffix(".jsp"); + + return bean; + } + + @Bean + public MethodValidationPostProcessor methodValidationPostProcessor() { + return new MethodValidationPostProcessor(); + } +} \ No newline at end of file diff --git a/spring-mvc-crash/src/main/java/com/baeldung/spring/controller/WelcomeController.java b/spring-mvc-crash/src/main/java/com/baeldung/spring/controller/WelcomeController.java new file mode 100644 index 0000000000..526833611b --- /dev/null +++ b/spring-mvc-crash/src/main/java/com/baeldung/spring/controller/WelcomeController.java @@ -0,0 +1,18 @@ +package com.baeldung.spring.controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.mvc.AbstractController; + +public class WelcomeController extends AbstractController { + @Override + protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { + + ModelAndView model = new ModelAndView("welcome"); + model.addObject("msg", "Welcome to Introduction to CRaSH article from Baeldung"); + + return model; + } +} \ No newline at end of file diff --git a/spring-mvc-crash/src/main/resources/contentManagementWebMvcConfig.xml b/spring-mvc-crash/src/main/resources/contentManagementWebMvcConfig.xml new file mode 100644 index 0000000000..8a0671ca87 --- /dev/null +++ b/spring-mvc-crash/src/main/resources/contentManagementWebMvcConfig.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-mvc-crash/src/main/resources/logback.xml b/spring-mvc-crash/src/main/resources/logback.xml new file mode 100644 index 0000000000..56af2d397e --- /dev/null +++ b/spring-mvc-crash/src/main/resources/logback.xml @@ -0,0 +1,19 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-mvc-crash/src/main/resources/messages.properties b/spring-mvc-crash/src/main/resources/messages.properties new file mode 100644 index 0000000000..2a3cccf76c --- /dev/null +++ b/spring-mvc-crash/src/main/resources/messages.properties @@ -0,0 +1,2 @@ +required.name = Name is required! +NotEmpty.person.password = Password is required! \ No newline at end of file diff --git a/spring-mvc-crash/src/main/resources/webMvcConfig.xml b/spring-mvc-crash/src/main/resources/webMvcConfig.xml new file mode 100644 index 0000000000..4bdb405237 --- /dev/null +++ b/spring-mvc-crash/src/main/resources/webMvcConfig.xml @@ -0,0 +1,38 @@ + + + + + + + + + image/jpeg + image/png + + + + + + + + + + + + + + + + + + + diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/crash/commands/message.groovy b/spring-mvc-crash/src/main/webapp/WEB-INF/crash/commands/message.groovy new file mode 100644 index 0000000000..d66ab13d96 --- /dev/null +++ b/spring-mvc-crash/src/main/webapp/WEB-INF/crash/commands/message.groovy @@ -0,0 +1,14 @@ +import org.crsh.cli.Command; +import org.crsh.cli.Usage; +import org.crsh.cli.Option; + +class message { + + @Usage("show my own message") + @Command + Object main(@Usage("custom message") @Option(names=["m","message"]) String message) { + if (message == null) + message = "No message given..."; + return message; + } +} \ No newline at end of file diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/crash/commands/message2.java b/spring-mvc-crash/src/main/webapp/WEB-INF/crash/commands/message2.java new file mode 100644 index 0000000000..d1ead88024 --- /dev/null +++ b/spring-mvc-crash/src/main/webapp/WEB-INF/crash/commands/message2.java @@ -0,0 +1,14 @@ +import org.crsh.command.BaseCommand; +import org.crsh.cli.Usage; +import org.crsh.cli.Command; +import org.crsh.cli.Option; + +public class message2 extends BaseCommand { + @Usage("show my own message using java") + @Command + public Object main(@Usage("custom message") @Option(names = { "m", "message" }) String message) { + if (message == null) + message = "No message given..."; + return message; + } +} \ No newline at end of file diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/crash/crash.properties b/spring-mvc-crash/src/main/webapp/WEB-INF/crash/crash.properties new file mode 100644 index 0000000000..f9ad0d7cf6 --- /dev/null +++ b/spring-mvc-crash/src/main/webapp/WEB-INF/crash/crash.properties @@ -0,0 +1 @@ +crash.telnet.port=50001 diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/crash/telnet.properties b/spring-mvc-crash/src/main/webapp/WEB-INF/crash/telnet.properties new file mode 100644 index 0000000000..99071d09ff --- /dev/null +++ b/spring-mvc-crash/src/main/webapp/WEB-INF/crash/telnet.properties @@ -0,0 +1,65 @@ +############################ +# Telnet daemon properties # +############################ + +##################### +# Terminals Section # +##################### + +# List of terminals available and defined below +terminals=vt100,ansi,windoof,xterm + +# vt100 implementation and aliases +term.vt100.class=net.wimpi.telnetd.io.terminal.vt100 +term.vt100.aliases=default,vt100-am,vt102,dec-vt100 + +# ansi implementation and aliases +term.ansi.class=net.wimpi.telnetd.io.terminal.ansi +term.ansi.aliases=color-xterm,xterm-color,vt320,vt220,linux,screen + +# windoof implementation and aliases +term.windoof.class=net.wimpi.telnetd.io.terminal.Windoof +term.windoof.aliases= + +# xterm implementation and aliases +term.xterm.class=net.wimpi.telnetd.io.terminal.xterm +term.xterm.aliases= + +################## +# Shells Section # +################## + +# List of shells available and defined below +shells=simple + +# shell implementations +shell.simple.class=org.crsh.telnet.term.TelnetHandler + +##################### +# Listeners Section # +##################### +listeners=std + + +# std listener specific properties + +#Basic listener and connection management settings (port is commented because CRaSH configures it) +# std.port=5000 +std.floodprotection=5 +std.maxcon=25 + + +# Timeout Settings for connections (ms) +std.time_to_warning=3600000 +std.time_to_timedout=60000 + +# Housekeeping thread active every 1 secs +std.housekeepinginterval=1000 + +std.inputmode=character + +# Login shell +std.loginshell=simple + +# Connection filter class +std.connectionfilter=none \ No newline at end of file diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-mvc-crash/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 0000000000..46b159d984 --- /dev/null +++ b/spring-mvc-crash/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + welcomeController + welcomeController + + + + + + + + + + + + + + 5000 + + + + diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/view/error.jsp b/spring-mvc-crash/src/main/webapp/WEB-INF/view/error.jsp new file mode 100644 index 0000000000..8f3d83af17 --- /dev/null +++ b/spring-mvc-crash/src/main/webapp/WEB-INF/view/error.jsp @@ -0,0 +1,20 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +SpringMVCExample + + + +

Pleas enter the correct details

+ + + + +
Retry
+ + + + \ No newline at end of file diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/view/errorPage.jsp b/spring-mvc-crash/src/main/webapp/WEB-INF/view/errorPage.jsp new file mode 100644 index 0000000000..ba8a836285 --- /dev/null +++ b/spring-mvc-crash/src/main/webapp/WEB-INF/view/errorPage.jsp @@ -0,0 +1,10 @@ +<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> +<%@ page session="false"%> + + + Home + + +

${errorMsg}

+ + diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/view/welcome.jsp b/spring-mvc-crash/src/main/webapp/WEB-INF/view/welcome.jsp new file mode 100644 index 0000000000..348ca652ff --- /dev/null +++ b/spring-mvc-crash/src/main/webapp/WEB-INF/view/welcome.jsp @@ -0,0 +1,15 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +Welcome Page + + +

Welcome to ${msg}

+
+

+ Go to spring handler mappings homepage + + \ No newline at end of file diff --git a/spring-mvc-crash/src/main/webapp/WEB-INF/web.xml b/spring-mvc-crash/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..4a3d6cb321 --- /dev/null +++ b/spring-mvc-crash/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,70 @@ + + + Spring MVC XML Application + + + + contextClass + + org.springframework.web.context.support.AnnotationConfigWebApplicationContext + + + + contextConfigLocation + com.baeldung.spring + + + + org.springframework.web.context.ContextLoaderListener + + + org.crsh.plugin.WebPluginLifeCycle + + + + + mvc + org.springframework.web.servlet.DispatcherServlet + 1 + + + mvc + / + + + + + + ExampleOne + com.baeldung.jsp.ExampleOne + + + ExampleOne + /jsp/ExampleOne + + + ExampleThree + com.baeldung.jsp.ExampleThree + + + ExampleThree + /jsp/ExampleThree + + + + + + 10 + + + index.jsp + + + + /errors + + diff --git a/spring-mvc-crash/src/main/webapp/index.jsp b/spring-mvc-crash/src/main/webapp/index.jsp new file mode 100644 index 0000000000..149fc5fe0b --- /dev/null +++ b/spring-mvc-crash/src/main/webapp/index.jsp @@ -0,0 +1,20 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +Spring MVC Examples + + + +

Spring MVC Examples

+ + + + \ No newline at end of file diff --git a/spring-mvc-crash/src/main/webapp/jsp/ExampleThree.jsp b/spring-mvc-crash/src/main/webapp/jsp/ExampleThree.jsp new file mode 100644 index 0000000000..665eb86a30 --- /dev/null +++ b/spring-mvc-crash/src/main/webapp/jsp/ExampleThree.jsp @@ -0,0 +1,10 @@ +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Java Binding Example + + +

Bound Value

+

You said: ${text}

+ + \ No newline at end of file diff --git a/spring-mvc-crash/src/main/webapp/jsp/ExampleTwo.jsp b/spring-mvc-crash/src/main/webapp/jsp/ExampleTwo.jsp new file mode 100644 index 0000000000..7b2247638d --- /dev/null +++ b/spring-mvc-crash/src/main/webapp/jsp/ExampleTwo.jsp @@ -0,0 +1,13 @@ +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Java in Static Page Example + + +

Java in Static Page Example

+ <% String[] arr = {"What's up?", "Hello", "It's a nice day today!"}; + String greetings = arr[(int)(Math.random() * arr.length)]; + %> +

<%= greetings %>

+ + \ No newline at end of file diff --git a/spring-mvc-crash/src/main/webapp/jsp/index.jsp b/spring-mvc-crash/src/main/webapp/jsp/index.jsp new file mode 100644 index 0000000000..58c464125d --- /dev/null +++ b/spring-mvc-crash/src/main/webapp/jsp/index.jsp @@ -0,0 +1,12 @@ +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + JSP Examples + + +

Simple JSP Examples

+

Invoke HTML rendered by Servlet: here

+

Java in static page: here

+

Java injected by Servlet: here

+ + \ No newline at end of file diff --git a/spring-mvc-crash/src/test/java/com/baeldung/SpringContextTest.java b/spring-mvc-crash/src/test/java/com/baeldung/SpringContextTest.java new file mode 100644 index 0000000000..62e34859ee --- /dev/null +++ b/spring-mvc-crash/src/test/java/com/baeldung/SpringContextTest.java @@ -0,0 +1,19 @@ +package com.baeldung; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; + +import com.baeldung.spring.ClientWebConfig; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = ClientWebConfig.class) +@WebAppConfiguration +public class SpringContextTest { + + @Test + public void whenSpringContextIsBootstrapped_thenNoExceptions() { + } +} diff --git a/spring-mvc-xml/README.md b/spring-mvc-xml/README.md index 685e7686b1..0adf127aaa 100644 --- a/spring-mvc-xml/README.md +++ b/spring-mvc-xml/README.md @@ -17,7 +17,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [A Java Web Application Without a web.xml](https://www.baeldung.com/java-web-app-without-web-xml) - [Validating RequestParams and PathVariables in Spring](https://www.baeldung.com/spring-validate-requestparam-pathvariable) - [Debugging the Spring MVC 404 “No mapping found for HTTP request” Error](https://www.baeldung.com/spring-mvc-404-error) -- [Getting Started with CRaSH](https://www.baeldung.com/jvm-crash-shell) ## Spring MVC with XML Configuration Example Project From c72b6ce0114d63180adfaa8f2b056032b5bd8144 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 17 Apr 2020 12:29:42 +0530 Subject: [PATCH 233/503] JAVA-916: Migrate jhipster to parent-boot-2 --- hystrix/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hystrix/pom.xml b/hystrix/pom.xml index 8c505c9104..1cf8713b91 100644 --- a/hystrix/pom.xml +++ b/hystrix/pom.xml @@ -8,9 +8,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 From dc0a41fd8ef0e6ad9c16c2267466416f0a87f195 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 17 Apr 2020 12:37:42 +0530 Subject: [PATCH 234/503] JAVA-915: Migrate hystrix to parent-boot-2 --- hystrix/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hystrix/pom.xml b/hystrix/pom.xml index 8c505c9104..1cf8713b91 100644 --- a/hystrix/pom.xml +++ b/hystrix/pom.xml @@ -8,9 +8,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 From 36d7572276e4ec5d142f496b92d954911e06951e Mon Sep 17 00:00:00 2001 From: Kostas Karavitis Date: Fri, 17 Apr 2020 19:24:01 +0300 Subject: [PATCH 235/503] [BAEL-3936] Fixed formatting --- .../java/com/baeldung/jpa/unrelated/entities/Cocktail.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java index fdccad6bd7..96310c1cc5 100644 --- a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java +++ b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Cocktail.java @@ -28,8 +28,7 @@ public class Cocktail { referencedColumnName = "cocktail", insertable = false, updatable = false, foreignKey = @javax.persistence - .ForeignKey(value = ConstraintMode.NO_CONSTRAINT) - ) + .ForeignKey(value = ConstraintMode.NO_CONSTRAINT)) private Recipe recipe; @OneToMany(fetch = FetchType.LAZY) @@ -40,7 +39,7 @@ public class Cocktail { insertable = false, updatable = false, foreignKey = @javax.persistence - .ForeignKey(value = ConstraintMode.NO_CONSTRAINT)) + .ForeignKey(value = ConstraintMode.NO_CONSTRAINT)) private List recipeList; public Cocktail() { From 29a2f0ece167b56f060bb7cbedc0cb73bbe07fb6 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Thu, 9 Apr 2020 08:24:04 +0200 Subject: [PATCH 236/503] [JAVA-616] core-java-arrays-sorting * Creation * Moved code from https://www.baeldung.com/java-sorting-arrays * Moved code from https://www.baeldung.com/java-check-sorted-array * Moved code from https://www.baeldung.com/java-invert-array * Moved code from https://www.baeldung.com/java-arrays-sort-vs-parallelsort --- .../core-java-arrays-2/README.md | 1 - .../core-java-arrays-sorting/README.md | 9 ++ .../core-java-arrays-sorting/pom.xml | 87 +++++++++++++++++++ .../com/baeldung/array/ArrayInverter.java | 0 .../baeldung/array/SortedArrayChecker.java | 2 - .../arraysort/ArraySortingBenchmark.java | 0 .../main/java/com/baeldung/sort/Employee.java | 48 ++++++++++ .../baeldung/array/ArrayInverterUnitTest.java | 0 .../array/SortedArrayCheckerUnitTest.java | 2 +- .../arraysort/SortComparisonUnitTest.java | 0 .../com/baeldung/sort/ArraySortUnitTest.java | 2 - core-java-modules/core-java-arrays/README.md | 3 - core-java-modules/pom.xml | 1 + 13 files changed, 146 insertions(+), 9 deletions(-) create mode 100644 core-java-modules/core-java-arrays-sorting/README.md create mode 100644 core-java-modules/core-java-arrays-sorting/pom.xml rename core-java-modules/{core-java-arrays => core-java-arrays-sorting}/src/main/java/com/baeldung/array/ArrayInverter.java (100%) rename core-java-modules/{core-java-arrays => core-java-arrays-sorting}/src/main/java/com/baeldung/array/SortedArrayChecker.java (97%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-sorting}/src/main/java/com/baeldung/arraysort/ArraySortingBenchmark.java (100%) create mode 100644 core-java-modules/core-java-arrays-sorting/src/main/java/com/baeldung/sort/Employee.java rename core-java-modules/{core-java-arrays => core-java-arrays-sorting}/src/test/java/com/baeldung/array/ArrayInverterUnitTest.java (100%) rename core-java-modules/{core-java-arrays => core-java-arrays-sorting}/src/test/java/com/baeldung/array/SortedArrayCheckerUnitTest.java (98%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-sorting}/src/test/java/com/baeldung/arraysort/SortComparisonUnitTest.java (100%) rename core-java-modules/{core-java-arrays => core-java-arrays-sorting}/src/test/java/com/baeldung/sort/ArraySortUnitTest.java (98%) diff --git a/core-java-modules/core-java-arrays-2/README.md b/core-java-modules/core-java-arrays-2/README.md index c4ae3f03f7..a78b3327b6 100644 --- a/core-java-modules/core-java-arrays-2/README.md +++ b/core-java-modules/core-java-arrays-2/README.md @@ -13,5 +13,4 @@ This module contains articles about Java arrays - [Removing an Element from an Array in Java](https://www.baeldung.com/java-array-remove-element) - [Removing the First Element of an Array](https://www.baeldung.com/java-array-remove-first-element) - [Adding an Element to a Java Array vs an ArrayList](https://www.baeldung.com/java-add-element-to-array-vs-list) -- [Arrays.sort vs Arrays.parallelSort](https://www.baeldung.com/java-arrays-sort-vs-parallelsort) - [[<-- Prev]](/core-java-modules/core-java-arrays) diff --git a/core-java-modules/core-java-arrays-sorting/README.md b/core-java-modules/core-java-arrays-sorting/README.md new file mode 100644 index 0000000000..f83dd43526 --- /dev/null +++ b/core-java-modules/core-java-arrays-sorting/README.md @@ -0,0 +1,9 @@ +## Core Java Arrays - Sorting + +This module contains articles about sorting arrays in Java + +### Relevant Articles: +- [Sorting Arrays in Java](https://www.baeldung.com/java-sorting-arrays) +- [Checking If an Array Is Sorted in Java](https://www.baeldung.com/java-check-sorted-array) +- [How to Reverse an Array in Java](http://www.baeldung.com/java-invert-array) +- [Arrays.sort vs Arrays.parallelSort](https://www.baeldung.com/java-arrays-sort-vs-parallelsort) diff --git a/core-java-modules/core-java-arrays-sorting/pom.xml b/core-java-modules/core-java-arrays-sorting/pom.xml new file mode 100644 index 0000000000..127d921b2a --- /dev/null +++ b/core-java-modules/core-java-arrays-sorting/pom.xml @@ -0,0 +1,87 @@ + + + + core-java-modules + com.baeldung.core-java-modules + 1.0.0-SNAPSHOT + ../pom.xml + + 4.0.0 + + core-java-arrays-sorting + core-java-arrays-sorting + jar + + + + + org.apache.maven.plugins + maven-shade-plugin + ${shade.plugin.version} + + + package + + shade + + + benchmarks + + + org.openjdk.jmh.Main + + + + + + + + + + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + com.google.guava + guava + ${guava.version} + + + + + org.openjdk.jmh + jmh-core + ${jmh.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh.version} + + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + + + 3.2.0 + + 3.9 + 28.2-jre + + 1.19 + + 3.10.0 + + \ No newline at end of file diff --git a/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayInverter.java b/core-java-modules/core-java-arrays-sorting/src/main/java/com/baeldung/array/ArrayInverter.java similarity index 100% rename from core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayInverter.java rename to core-java-modules/core-java-arrays-sorting/src/main/java/com/baeldung/array/ArrayInverter.java diff --git a/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/SortedArrayChecker.java b/core-java-modules/core-java-arrays-sorting/src/main/java/com/baeldung/array/SortedArrayChecker.java similarity index 97% rename from core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/SortedArrayChecker.java rename to core-java-modules/core-java-arrays-sorting/src/main/java/com/baeldung/array/SortedArrayChecker.java index 78a9a8f4d1..8fa64972f2 100644 --- a/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/SortedArrayChecker.java +++ b/core-java-modules/core-java-arrays-sorting/src/main/java/com/baeldung/array/SortedArrayChecker.java @@ -1,7 +1,5 @@ package com.baeldung.array; -import com.baeldung.arraycopy.model.Employee; - import java.util.Comparator; public class SortedArrayChecker { diff --git a/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/arraysort/ArraySortingBenchmark.java b/core-java-modules/core-java-arrays-sorting/src/main/java/com/baeldung/arraysort/ArraySortingBenchmark.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/arraysort/ArraySortingBenchmark.java rename to core-java-modules/core-java-arrays-sorting/src/main/java/com/baeldung/arraysort/ArraySortingBenchmark.java diff --git a/core-java-modules/core-java-arrays-sorting/src/main/java/com/baeldung/sort/Employee.java b/core-java-modules/core-java-arrays-sorting/src/main/java/com/baeldung/sort/Employee.java new file mode 100644 index 0000000000..e9c737b74b --- /dev/null +++ b/core-java-modules/core-java-arrays-sorting/src/main/java/com/baeldung/sort/Employee.java @@ -0,0 +1,48 @@ +package com.baeldung.sort; + +import java.io.Serializable; + +public class Employee implements Serializable { + private static final long serialVersionUID = -2454619097207585825L; + private int id; + private String name; + private int age; + + public Employee() { + } + + public Employee(int id, String name) { + this.id = id; + this.name = name; + } + + public Employee(int id, String name, int age) { + this.id = id; + this.name = name; + this.age = age; + } + + public int getAge() { + return age; + } + + public int getId() { + return id; + } + + public void setAge(int age) { + this.age = age; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/ArrayInverterUnitTest.java b/core-java-modules/core-java-arrays-sorting/src/test/java/com/baeldung/array/ArrayInverterUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/ArrayInverterUnitTest.java rename to core-java-modules/core-java-arrays-sorting/src/test/java/com/baeldung/array/ArrayInverterUnitTest.java diff --git a/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/SortedArrayCheckerUnitTest.java b/core-java-modules/core-java-arrays-sorting/src/test/java/com/baeldung/array/SortedArrayCheckerUnitTest.java similarity index 98% rename from core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/SortedArrayCheckerUnitTest.java rename to core-java-modules/core-java-arrays-sorting/src/test/java/com/baeldung/array/SortedArrayCheckerUnitTest.java index 7971e0eab7..5411dcba72 100644 --- a/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/SortedArrayCheckerUnitTest.java +++ b/core-java-modules/core-java-arrays-sorting/src/test/java/com/baeldung/array/SortedArrayCheckerUnitTest.java @@ -1,6 +1,6 @@ package com.baeldung.array; -import com.baeldung.arraycopy.model.Employee; +import com.baeldung.sort.Employee; import org.junit.Before; import org.junit.Test; diff --git a/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/arraysort/SortComparisonUnitTest.java b/core-java-modules/core-java-arrays-sorting/src/test/java/com/baeldung/arraysort/SortComparisonUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/arraysort/SortComparisonUnitTest.java rename to core-java-modules/core-java-arrays-sorting/src/test/java/com/baeldung/arraysort/SortComparisonUnitTest.java diff --git a/core-java-modules/core-java-arrays/src/test/java/com/baeldung/sort/ArraySortUnitTest.java b/core-java-modules/core-java-arrays-sorting/src/test/java/com/baeldung/sort/ArraySortUnitTest.java similarity index 98% rename from core-java-modules/core-java-arrays/src/test/java/com/baeldung/sort/ArraySortUnitTest.java rename to core-java-modules/core-java-arrays-sorting/src/test/java/com/baeldung/sort/ArraySortUnitTest.java index 59035738fe..b89a870c51 100644 --- a/core-java-modules/core-java-arrays/src/test/java/com/baeldung/sort/ArraySortUnitTest.java +++ b/core-java-modules/core-java-arrays-sorting/src/test/java/com/baeldung/sort/ArraySortUnitTest.java @@ -1,6 +1,5 @@ package com.baeldung.sort; -import com.baeldung.arraycopy.model.Employee; import org.junit.Before; import org.junit.Test; @@ -86,5 +85,4 @@ public class ArraySortUnitTest { assertArrayEquals(new Employee[]{david, john, mary}, employees); } - } diff --git a/core-java-modules/core-java-arrays/README.md b/core-java-modules/core-java-arrays/README.md index 9d9db9ab81..94351bbad6 100644 --- a/core-java-modules/core-java-arrays/README.md +++ b/core-java-modules/core-java-arrays/README.md @@ -10,7 +10,4 @@ This module contains articles about Java arrays - [Multi-Dimensional Arrays In Java](https://www.baeldung.com/java-jagged-arrays) - [Find Sum and Average in a Java Array](https://www.baeldung.com/java-array-sum-average) - [Arrays in Java: A Reference Guide](https://www.baeldung.com/java-arrays-guide) -- [How to Reverse an Array in Java](http://www.baeldung.com/java-invert-array) -- [Sorting Arrays in Java](https://www.baeldung.com/java-sorting-arrays) -- [Checking If an Array Is Sorted in Java](https://www.baeldung.com/java-check-sorted-array) - [[More -->]](/core-java-modules/core-java-arrays-2) diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 00ef24be92..aba97f4826 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -122,6 +122,7 @@ pre-jpms + core-java-arrays-sorting From 0593fce8a3def726abc84d91fec72f5941d66b86 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Fri, 10 Apr 2020 20:54:17 +0200 Subject: [PATCH 237/503] [JAVA-616] core-java-arrays-guides * Creation * Moved code from https://www.baeldung.com/java-arrays-guide * Moved code from https://www.baeldung.com/java-util-arrays --- .../core-java-arrays-guides/README.md | 7 ++++ .../core-java-arrays-guides/pom.xml | 32 +++++++++++++++++++ .../baeldung/array/ArrayReferenceGuide.java | 0 .../arrays/ParallelPrefixBenchmark.java | 0 .../com/baeldung/arrays/ArraysUnitTest.java | 0 core-java-modules/core-java-arrays/README.md | 2 -- core-java-modules/pom.xml | 1 + 7 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 core-java-modules/core-java-arrays-guides/README.md create mode 100644 core-java-modules/core-java-arrays-guides/pom.xml rename core-java-modules/{core-java-arrays => core-java-arrays-guides}/src/main/java/com/baeldung/array/ArrayReferenceGuide.java (100%) rename core-java-modules/{core-java-arrays => core-java-arrays-guides}/src/main/java/com/baeldung/arrays/ParallelPrefixBenchmark.java (100%) rename core-java-modules/{core-java-arrays => core-java-arrays-guides}/src/test/java/com/baeldung/arrays/ArraysUnitTest.java (100%) diff --git a/core-java-modules/core-java-arrays-guides/README.md b/core-java-modules/core-java-arrays-guides/README.md new file mode 100644 index 0000000000..2e66080002 --- /dev/null +++ b/core-java-modules/core-java-arrays-guides/README.md @@ -0,0 +1,7 @@ +## Core Java Arrays - Guides + +This module contains complete guides about arrays in Java + +### Relevant Articles: +- [Arrays in Java: A Reference Guide](https://www.baeldung.com/java-arrays-guide) +- [Guide to the java.util.Arrays Class](https://www.baeldung.com/java-util-arrays) \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-guides/pom.xml b/core-java-modules/core-java-arrays-guides/pom.xml new file mode 100644 index 0000000000..ef718d5117 --- /dev/null +++ b/core-java-modules/core-java-arrays-guides/pom.xml @@ -0,0 +1,32 @@ + + + + core-java-modules + com.baeldung.core-java-modules + 1.0.0-SNAPSHOT + + 4.0.0 + + core-java-arrays-guides + core-java-arrays-guides + jar + + + + org.openjdk.jmh + jmh-core + ${jmh.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh.version} + + + + + 1.19 + + \ No newline at end of file diff --git a/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayReferenceGuide.java b/core-java-modules/core-java-arrays-guides/src/main/java/com/baeldung/array/ArrayReferenceGuide.java similarity index 100% rename from core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayReferenceGuide.java rename to core-java-modules/core-java-arrays-guides/src/main/java/com/baeldung/array/ArrayReferenceGuide.java diff --git a/core-java-modules/core-java-arrays/src/main/java/com/baeldung/arrays/ParallelPrefixBenchmark.java b/core-java-modules/core-java-arrays-guides/src/main/java/com/baeldung/arrays/ParallelPrefixBenchmark.java similarity index 100% rename from core-java-modules/core-java-arrays/src/main/java/com/baeldung/arrays/ParallelPrefixBenchmark.java rename to core-java-modules/core-java-arrays-guides/src/main/java/com/baeldung/arrays/ParallelPrefixBenchmark.java diff --git a/core-java-modules/core-java-arrays/src/test/java/com/baeldung/arrays/ArraysUnitTest.java b/core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/arrays/ArraysUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays/src/test/java/com/baeldung/arrays/ArraysUnitTest.java rename to core-java-modules/core-java-arrays-guides/src/test/java/com/baeldung/arrays/ArraysUnitTest.java diff --git a/core-java-modules/core-java-arrays/README.md b/core-java-modules/core-java-arrays/README.md index 94351bbad6..05c316cf7e 100644 --- a/core-java-modules/core-java-arrays/README.md +++ b/core-java-modules/core-java-arrays/README.md @@ -6,8 +6,6 @@ This module contains articles about Java arrays - [How to Copy an Array in Java](https://www.baeldung.com/java-array-copy) - [Check if a Java Array Contains a Value](https://www.baeldung.com/java-array-contains-value) - [Initializing Arrays in Java](https://www.baeldung.com/java-initialize-array) -- [Guide to the java.util.Arrays Class](https://www.baeldung.com/java-util-arrays) - [Multi-Dimensional Arrays In Java](https://www.baeldung.com/java-jagged-arrays) - [Find Sum and Average in a Java Array](https://www.baeldung.com/java-array-sum-average) -- [Arrays in Java: A Reference Guide](https://www.baeldung.com/java-arrays-guide) - [[More -->]](/core-java-modules/core-java-arrays-2) diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index aba97f4826..b23b7ba8f4 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -123,6 +123,7 @@ pre-jpms core-java-arrays-sorting + core-java-arrays-guides From 6af4961a79bc5d493f8bf36b86718600b8908d0b Mon Sep 17 00:00:00 2001 From: dupirefr Date: Fri, 10 Apr 2020 21:01:14 +0200 Subject: [PATCH 238/503] [JAVA-616] core-java-arrays-multidimensional * Creation * Moved code from https://www.baeldung.com/java-jagged-arrays * Moved code from https://www.baeldung.com/java-loop-diagonal-array --- core-java-modules/core-java-arrays-2/README.md | 1 - .../core-java-arrays-multidimensional/README.md | 7 +++++++ .../core-java-arrays-multidimensional/pom.xml | 15 +++++++++++++++ .../com/baeldung/array/MultiDimensionalArray.java | 0 .../baeldung/array/looping/LoopDiagonally.java | 0 .../array/MultiDimensionalArrayUnitTest.java | 0 .../array/looping/LoopDiagonallyUnitTest.java | 0 core-java-modules/core-java-arrays/README.md | 1 - core-java-modules/pom.xml | 1 + 9 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 core-java-modules/core-java-arrays-multidimensional/README.md create mode 100644 core-java-modules/core-java-arrays-multidimensional/pom.xml rename core-java-modules/{core-java-arrays => core-java-arrays-multidimensional}/src/main/java/com/baeldung/array/MultiDimensionalArray.java (100%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-multidimensional}/src/main/java/com/baeldung/array/looping/LoopDiagonally.java (100%) rename core-java-modules/{core-java-arrays => core-java-arrays-multidimensional}/src/test/java/com/baeldung/array/MultiDimensionalArrayUnitTest.java (100%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-multidimensional}/src/test/java/com/baeldung/array/looping/LoopDiagonallyUnitTest.java (100%) diff --git a/core-java-modules/core-java-arrays-2/README.md b/core-java-modules/core-java-arrays-2/README.md index a78b3327b6..07c171dcd5 100644 --- a/core-java-modules/core-java-arrays-2/README.md +++ b/core-java-modules/core-java-arrays-2/README.md @@ -5,7 +5,6 @@ This module contains articles about Java arrays ## Relevant Articles - [Extending an Array’s Length](https://www.baeldung.com/java-array-add-element-at-the-end) -- [Looping Diagonally Through a 2d Java Array](https://www.baeldung.com/java-loop-diagonal-array) - [Converting Between Stream and Array in Java](https://www.baeldung.com/java-stream-to-array) - [Convert a Float to a Byte Array in Java](https://www.baeldung.com/java-convert-float-to-byte-array) - [Array Operations in Java](https://www.baeldung.com/java-common-array-operations) diff --git a/core-java-modules/core-java-arrays-multidimensional/README.md b/core-java-modules/core-java-arrays-multidimensional/README.md new file mode 100644 index 0000000000..d92747a4fb --- /dev/null +++ b/core-java-modules/core-java-arrays-multidimensional/README.md @@ -0,0 +1,7 @@ +## Core Java Arrays - Multidimensional + +This module contains articles about multidimensional arrays in Java + +### Relevant Articles: +- [Multi-Dimensional Arrays In Java](https://www.baeldung.com/java-jagged-arrays) +- [Looping Diagonally Through a 2d Java Array](https://www.baeldung.com/java-loop-diagonal-array) \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-multidimensional/pom.xml b/core-java-modules/core-java-arrays-multidimensional/pom.xml new file mode 100644 index 0000000000..6e49a20521 --- /dev/null +++ b/core-java-modules/core-java-arrays-multidimensional/pom.xml @@ -0,0 +1,15 @@ + + + + core-java-modules + com.baeldung.core-java-modules + 1.0.0-SNAPSHOT + + 4.0.0 + + core-java-arrays-multidimensional + core-java-arrays-multidimensional + jar + \ No newline at end of file diff --git a/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/MultiDimensionalArray.java b/core-java-modules/core-java-arrays-multidimensional/src/main/java/com/baeldung/array/MultiDimensionalArray.java similarity index 100% rename from core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/MultiDimensionalArray.java rename to core-java-modules/core-java-arrays-multidimensional/src/main/java/com/baeldung/array/MultiDimensionalArray.java diff --git a/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/looping/LoopDiagonally.java b/core-java-modules/core-java-arrays-multidimensional/src/main/java/com/baeldung/array/looping/LoopDiagonally.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/looping/LoopDiagonally.java rename to core-java-modules/core-java-arrays-multidimensional/src/main/java/com/baeldung/array/looping/LoopDiagonally.java diff --git a/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/MultiDimensionalArrayUnitTest.java b/core-java-modules/core-java-arrays-multidimensional/src/test/java/com/baeldung/array/MultiDimensionalArrayUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/MultiDimensionalArrayUnitTest.java rename to core-java-modules/core-java-arrays-multidimensional/src/test/java/com/baeldung/array/MultiDimensionalArrayUnitTest.java diff --git a/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/looping/LoopDiagonallyUnitTest.java b/core-java-modules/core-java-arrays-multidimensional/src/test/java/com/baeldung/array/looping/LoopDiagonallyUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/looping/LoopDiagonallyUnitTest.java rename to core-java-modules/core-java-arrays-multidimensional/src/test/java/com/baeldung/array/looping/LoopDiagonallyUnitTest.java diff --git a/core-java-modules/core-java-arrays/README.md b/core-java-modules/core-java-arrays/README.md index 05c316cf7e..7b5f21a1e6 100644 --- a/core-java-modules/core-java-arrays/README.md +++ b/core-java-modules/core-java-arrays/README.md @@ -6,6 +6,5 @@ This module contains articles about Java arrays - [How to Copy an Array in Java](https://www.baeldung.com/java-array-copy) - [Check if a Java Array Contains a Value](https://www.baeldung.com/java-array-contains-value) - [Initializing Arrays in Java](https://www.baeldung.com/java-initialize-array) -- [Multi-Dimensional Arrays In Java](https://www.baeldung.com/java-jagged-arrays) - [Find Sum and Average in a Java Array](https://www.baeldung.com/java-array-sum-average) - [[More -->]](/core-java-modules/core-java-arrays-2) diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index b23b7ba8f4..20a2add836 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -124,6 +124,7 @@ pre-jpms core-java-arrays-sorting core-java-arrays-guides + core-java-arrays-multidimensional From dcd863f5d67dea7c0533cbd04a234507ede70725 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Fri, 10 Apr 2020 21:08:02 +0200 Subject: [PATCH 239/503] [JAVA-616] core-java-arrays-convert * Creation * Moved code from https://www.baeldung.com/java-convert-float-to-byte-array * Moved code from https://www.baeldung.com/java-stream-to-array --- .../core-java-arrays-2/README.md | 2 -- .../core-java-arrays-convert/README.md | 7 +++++ .../core-java-arrays-convert/pom.xml | 27 +++++++++++++++++++ .../array/conversions/FloatToByteArray.java | 0 .../conversions/StreamArrayConversion.java | 0 .../conversions/FloatToByteArrayUnitTest.java | 0 .../StreamArrayConversionUnitTest.java | 0 core-java-modules/pom.xml | 1 + 8 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 core-java-modules/core-java-arrays-convert/README.md create mode 100644 core-java-modules/core-java-arrays-convert/pom.xml rename core-java-modules/{core-java-arrays-2 => core-java-arrays-convert}/src/main/java/com/baeldung/array/conversions/FloatToByteArray.java (100%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-convert}/src/main/java/com/baeldung/array/conversions/StreamArrayConversion.java (100%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-convert}/src/test/java/com/baeldung/array/conversions/FloatToByteArrayUnitTest.java (100%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-convert}/src/test/java/com/baeldung/array/conversions/StreamArrayConversionUnitTest.java (100%) diff --git a/core-java-modules/core-java-arrays-2/README.md b/core-java-modules/core-java-arrays-2/README.md index 07c171dcd5..eefc6aa787 100644 --- a/core-java-modules/core-java-arrays-2/README.md +++ b/core-java-modules/core-java-arrays-2/README.md @@ -5,8 +5,6 @@ This module contains articles about Java arrays ## Relevant Articles - [Extending an Array’s Length](https://www.baeldung.com/java-array-add-element-at-the-end) -- [Converting Between Stream and Array in Java](https://www.baeldung.com/java-stream-to-array) -- [Convert a Float to a Byte Array in Java](https://www.baeldung.com/java-convert-float-to-byte-array) - [Array Operations in Java](https://www.baeldung.com/java-common-array-operations) - [Intersection Between two Integer Arrays](https://www.baeldung.com/java-array-intersection) - [Removing an Element from an Array in Java](https://www.baeldung.com/java-array-remove-element) diff --git a/core-java-modules/core-java-arrays-convert/README.md b/core-java-modules/core-java-arrays-convert/README.md new file mode 100644 index 0000000000..4bd060a246 --- /dev/null +++ b/core-java-modules/core-java-arrays-convert/README.md @@ -0,0 +1,7 @@ +## Core Java Arrays - Conversions + +This module contains articles about arrays conversion in Java + +## Relevant Articles +- [Convert a Float to a Byte Array in Java](https://www.baeldung.com/java-convert-float-to-byte-array) +- [Converting Between Stream and Array in Java](https://www.baeldung.com/java-stream-to-array) diff --git a/core-java-modules/core-java-arrays-convert/pom.xml b/core-java-modules/core-java-arrays-convert/pom.xml new file mode 100644 index 0000000000..bd50289f47 --- /dev/null +++ b/core-java-modules/core-java-arrays-convert/pom.xml @@ -0,0 +1,27 @@ + + + + core-java-modules + com.baeldung.core-java-modules + 1.0.0-SNAPSHOT + + 4.0.0 + + core-java-arrays-convert + core-java-arrays-convert + jar + + + + com.google.guava + guava + ${guava.version} + + + + + 28.2-jre + + \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/conversions/FloatToByteArray.java b/core-java-modules/core-java-arrays-convert/src/main/java/com/baeldung/array/conversions/FloatToByteArray.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/conversions/FloatToByteArray.java rename to core-java-modules/core-java-arrays-convert/src/main/java/com/baeldung/array/conversions/FloatToByteArray.java diff --git a/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/conversions/StreamArrayConversion.java b/core-java-modules/core-java-arrays-convert/src/main/java/com/baeldung/array/conversions/StreamArrayConversion.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/conversions/StreamArrayConversion.java rename to core-java-modules/core-java-arrays-convert/src/main/java/com/baeldung/array/conversions/StreamArrayConversion.java diff --git a/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/conversions/FloatToByteArrayUnitTest.java b/core-java-modules/core-java-arrays-convert/src/test/java/com/baeldung/array/conversions/FloatToByteArrayUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/conversions/FloatToByteArrayUnitTest.java rename to core-java-modules/core-java-arrays-convert/src/test/java/com/baeldung/array/conversions/FloatToByteArrayUnitTest.java diff --git a/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/conversions/StreamArrayConversionUnitTest.java b/core-java-modules/core-java-arrays-convert/src/test/java/com/baeldung/array/conversions/StreamArrayConversionUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/conversions/StreamArrayConversionUnitTest.java rename to core-java-modules/core-java-arrays-convert/src/test/java/com/baeldung/array/conversions/StreamArrayConversionUnitTest.java diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 20a2add836..9926e7781a 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -125,6 +125,7 @@ core-java-arrays-sorting core-java-arrays-guides core-java-arrays-multidimensional + core-java-arrays-convert From e36771a76366ab2fcfcd19c0a5ce8cfb97446fc4 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Fri, 10 Apr 2020 21:16:30 +0200 Subject: [PATCH 240/503] [JAVA-616] core-java-arrays-operations-basic * Creation * Moved code from https://www.baeldung.com/java-initialize-array * Moved code from https://www.baeldung.com/java-common-array-operations * Moved code from https://www.baeldung.com/java-add-element-to-array-vs-list * Moved code from https://www.baeldung.com/java-array-contains-value * Moved code from https://www.baeldung.com/java-array-remove-element * Moved code from https://www.baeldung.com/java-array-remove-first-element * Moved code from https://www.baeldung.com/java-array-add-element-at-the-end --- .../core-java-arrays-2/README.md | 5 -- .../ArraysIntersectionOperations.java | 27 +++++++ .../operations/IntersectionUnitTest.java | 2 +- .../README.md | 19 +++++ .../core-java-arrays-operations-basic/pom.xml | 78 +++++++++++++++++++ .../array/AddElementToEndOfArray.java | 0 .../baeldung/array/ArrayBenchmarkRunner.java | 2 +- .../com/baeldung/array/ArrayInitializer.java | 0 .../array/RemoveElementFromAnArray.java | 0 .../baeldung/array/SearchArrayBenchmark.java} | 2 +- .../array/operations/ArrayOperations.java | 0 .../operations/ArrayListOperations.java | 0 .../array/AddElementToEndOfArrayUnitTest.java | 0 .../array/ArrayInitializerUnitTest.java | 0 .../RemoveElementFromAnArrayUnitTest.java | 0 .../operations/ArrayOperationsUnitTest.java | 0 .../RemoveFirstElementUnitTest.java | 0 .../ArrayListOperationsUnitTest.java | 0 core-java-modules/core-java-arrays/README.md | 2 - core-java-modules/pom.xml | 1 + 20 files changed, 128 insertions(+), 10 deletions(-) create mode 100644 core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/operations/ArraysIntersectionOperations.java create mode 100644 core-java-modules/core-java-arrays-operations-basic/README.md create mode 100644 core-java-modules/core-java-arrays-operations-basic/pom.xml rename core-java-modules/{core-java-arrays-2 => core-java-arrays-operations-basic}/src/main/java/com/baeldung/array/AddElementToEndOfArray.java (100%) rename core-java-modules/{core-java-arrays => core-java-arrays-operations-basic}/src/main/java/com/baeldung/array/ArrayBenchmarkRunner.java (86%) rename core-java-modules/{core-java-arrays => core-java-arrays-operations-basic}/src/main/java/com/baeldung/array/ArrayInitializer.java (100%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-operations-basic}/src/main/java/com/baeldung/array/RemoveElementFromAnArray.java (100%) rename core-java-modules/{core-java-arrays/src/main/java/com/baeldung/array/SearchArrayUnitTest.java => core-java-arrays-operations-basic/src/main/java/com/baeldung/array/SearchArrayBenchmark.java} (98%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-operations-basic}/src/main/java/com/baeldung/array/operations/ArrayOperations.java (100%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-operations-basic}/src/main/java/com/baeldung/arraylist/operations/ArrayListOperations.java (100%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-operations-basic}/src/test/java/com/baeldung/array/AddElementToEndOfArrayUnitTest.java (100%) rename core-java-modules/{core-java-arrays => core-java-arrays-operations-basic}/src/test/java/com/baeldung/array/ArrayInitializerUnitTest.java (100%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-operations-basic}/src/test/java/com/baeldung/array/RemoveElementFromAnArrayUnitTest.java (100%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-operations-basic}/src/test/java/com/baeldung/array/operations/ArrayOperationsUnitTest.java (100%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-operations-basic}/src/test/java/com/baeldung/array/removefirst/RemoveFirstElementUnitTest.java (100%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-operations-basic}/src/test/java/com/baeldung/arraylist/operations/ArrayListOperationsUnitTest.java (100%) diff --git a/core-java-modules/core-java-arrays-2/README.md b/core-java-modules/core-java-arrays-2/README.md index eefc6aa787..bde6c6cc1e 100644 --- a/core-java-modules/core-java-arrays-2/README.md +++ b/core-java-modules/core-java-arrays-2/README.md @@ -4,10 +4,5 @@ This module contains articles about Java arrays ## Relevant Articles -- [Extending an Array’s Length](https://www.baeldung.com/java-array-add-element-at-the-end) -- [Array Operations in Java](https://www.baeldung.com/java-common-array-operations) - [Intersection Between two Integer Arrays](https://www.baeldung.com/java-array-intersection) -- [Removing an Element from an Array in Java](https://www.baeldung.com/java-array-remove-element) -- [Removing the First Element of an Array](https://www.baeldung.com/java-array-remove-first-element) -- [Adding an Element to a Java Array vs an ArrayList](https://www.baeldung.com/java-add-element-to-array-vs-list) - [[<-- Prev]](/core-java-modules/core-java-arrays) diff --git a/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/operations/ArraysIntersectionOperations.java b/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/operations/ArraysIntersectionOperations.java new file mode 100644 index 0000000000..6c4ce837ad --- /dev/null +++ b/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/operations/ArraysIntersectionOperations.java @@ -0,0 +1,27 @@ +package com.baeldung.array.operations; + +import java.util.Arrays; +import java.util.LinkedList; +import java.util.stream.Stream; + +public class ArraysIntersectionOperations { + + public static Integer[] intersectionSimple(final Integer[] a, final Integer[] b) { + return Stream.of(a) + .filter(Arrays.asList(b)::contains) + .toArray(Integer[]::new); + } + + public static Integer[] intersectionSet(final Integer[] a, final Integer[] b) { + return Stream.of(a) + .filter(Arrays.asList(b)::contains) + .distinct() + .toArray(Integer[]::new); + } + + public static Integer[] intersectionMultiSet(final Integer[] a, final Integer[] b) { + return Stream.of(a) + .filter(new LinkedList<>(Arrays.asList(b))::remove) + .toArray(Integer[]::new); + } +} diff --git a/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/operations/IntersectionUnitTest.java b/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/operations/IntersectionUnitTest.java index 1560cc5701..b0d4a80b06 100644 --- a/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/operations/IntersectionUnitTest.java +++ b/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/operations/IntersectionUnitTest.java @@ -2,7 +2,7 @@ package com.baeldung.array.operations; import org.junit.jupiter.api.Test; -import static com.baeldung.array.operations.ArrayOperations.*; +import static com.baeldung.array.operations.ArraysIntersectionOperations.*; import static org.assertj.core.api.Assertions.assertThat; class IntersectionUnitTest { diff --git a/core-java-modules/core-java-arrays-operations-basic/README.md b/core-java-modules/core-java-arrays-operations-basic/README.md new file mode 100644 index 0000000000..914d5a71bd --- /dev/null +++ b/core-java-modules/core-java-arrays-operations-basic/README.md @@ -0,0 +1,19 @@ +## Core Java Arrays - Basic Operations + +This module contains articles about basic operations on arrays in Java + +Basic operations would cover anything elementary we should expect to be able to achieve on a collection type: + +- Adding/Removing elements +- Getting elements +- Iterating + +### Relevant Articles: +- [Initializing Arrays in Java](https://www.baeldung.com/java-initialize-array) +- [Array Operations in Java](https://www.baeldung.com/java-common-array-operations) +- [Adding an Element to a Java Array vs an ArrayList](https://www.baeldung.com/java-add-element-to-array-vs-list) +- [Check if a Java Array Contains a Value](https://www.baeldung.com/java-array-contains-value) +- [Removing an Element from an Array in Java](https://www.baeldung.com/java-array-remove-element) +- [Removing the First Element of an Array](https://www.baeldung.com/java-array-remove-first-element) +- [Extending an Array’s Length](https://www.baeldung.com/java-array-add-element-at-the-end) +- [[More advanced operations -->]](/core-java-modules/core-java-arrays-operations-advanced) diff --git a/core-java-modules/core-java-arrays-operations-basic/pom.xml b/core-java-modules/core-java-arrays-operations-basic/pom.xml new file mode 100644 index 0000000000..4480c14bb2 --- /dev/null +++ b/core-java-modules/core-java-arrays-operations-basic/pom.xml @@ -0,0 +1,78 @@ + + + + core-java-modules + com.baeldung.core-java-modules + 1.0.0-SNAPSHOT + + 4.0.0 + + core-java-arrays-operations-basic + 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 + commons-lang3 + ${commons-lang3.version} + + + + + org.openjdk.jmh + jmh-core + ${jmh.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh.version} + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + + + 3.2.0 + + 3.9 + + 1.19 + + 3.10.0 + + \ No newline at end of file diff --git a/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/AddElementToEndOfArray.java b/core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/array/AddElementToEndOfArray.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/AddElementToEndOfArray.java rename to core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/array/AddElementToEndOfArray.java diff --git a/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayBenchmarkRunner.java b/core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/array/ArrayBenchmarkRunner.java similarity index 86% rename from core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayBenchmarkRunner.java rename to core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/array/ArrayBenchmarkRunner.java index f35064b783..30c3978a3a 100644 --- a/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayBenchmarkRunner.java +++ b/core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/array/ArrayBenchmarkRunner.java @@ -9,7 +9,7 @@ public class ArrayBenchmarkRunner { public static void main(String[] args) throws Exception { Options options = new OptionsBuilder() - .include(SearchArrayUnitTest.class.getSimpleName()).threads(1) + .include(SearchArrayBenchmark.class.getSimpleName()).threads(1) .forks(1).shouldFailOnError(true).shouldDoGC(true) .jvmArgs("-server").build(); diff --git a/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayInitializer.java b/core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/array/ArrayInitializer.java similarity index 100% rename from core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/ArrayInitializer.java rename to core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/array/ArrayInitializer.java diff --git a/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/RemoveElementFromAnArray.java b/core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/array/RemoveElementFromAnArray.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/RemoveElementFromAnArray.java rename to core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/array/RemoveElementFromAnArray.java diff --git a/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/SearchArrayUnitTest.java b/core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/array/SearchArrayBenchmark.java similarity index 98% rename from core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/SearchArrayUnitTest.java rename to core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/array/SearchArrayBenchmark.java index bed58356cb..fc4b513250 100644 --- a/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/SearchArrayUnitTest.java +++ b/core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/array/SearchArrayBenchmark.java @@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.AverageTime) @Warmup(iterations = 5) @OutputTimeUnit(TimeUnit.MICROSECONDS) -public class SearchArrayUnitTest { +public class SearchArrayBenchmark { @State(Scope.Benchmark) public static class SearchData { diff --git a/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/operations/ArrayOperations.java b/core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/array/operations/ArrayOperations.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/operations/ArrayOperations.java rename to core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/array/operations/ArrayOperations.java diff --git a/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/arraylist/operations/ArrayListOperations.java b/core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/arraylist/operations/ArrayListOperations.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/arraylist/operations/ArrayListOperations.java rename to core-java-modules/core-java-arrays-operations-basic/src/main/java/com/baeldung/arraylist/operations/ArrayListOperations.java diff --git a/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/AddElementToEndOfArrayUnitTest.java b/core-java-modules/core-java-arrays-operations-basic/src/test/java/com/baeldung/array/AddElementToEndOfArrayUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/AddElementToEndOfArrayUnitTest.java rename to core-java-modules/core-java-arrays-operations-basic/src/test/java/com/baeldung/array/AddElementToEndOfArrayUnitTest.java diff --git a/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/ArrayInitializerUnitTest.java b/core-java-modules/core-java-arrays-operations-basic/src/test/java/com/baeldung/array/ArrayInitializerUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/ArrayInitializerUnitTest.java rename to core-java-modules/core-java-arrays-operations-basic/src/test/java/com/baeldung/array/ArrayInitializerUnitTest.java diff --git a/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/RemoveElementFromAnArrayUnitTest.java b/core-java-modules/core-java-arrays-operations-basic/src/test/java/com/baeldung/array/RemoveElementFromAnArrayUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/RemoveElementFromAnArrayUnitTest.java rename to core-java-modules/core-java-arrays-operations-basic/src/test/java/com/baeldung/array/RemoveElementFromAnArrayUnitTest.java diff --git a/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/operations/ArrayOperationsUnitTest.java b/core-java-modules/core-java-arrays-operations-basic/src/test/java/com/baeldung/array/operations/ArrayOperationsUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/operations/ArrayOperationsUnitTest.java rename to core-java-modules/core-java-arrays-operations-basic/src/test/java/com/baeldung/array/operations/ArrayOperationsUnitTest.java diff --git a/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/removefirst/RemoveFirstElementUnitTest.java b/core-java-modules/core-java-arrays-operations-basic/src/test/java/com/baeldung/array/removefirst/RemoveFirstElementUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/removefirst/RemoveFirstElementUnitTest.java rename to core-java-modules/core-java-arrays-operations-basic/src/test/java/com/baeldung/array/removefirst/RemoveFirstElementUnitTest.java diff --git a/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/arraylist/operations/ArrayListOperationsUnitTest.java b/core-java-modules/core-java-arrays-operations-basic/src/test/java/com/baeldung/arraylist/operations/ArrayListOperationsUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/arraylist/operations/ArrayListOperationsUnitTest.java rename to core-java-modules/core-java-arrays-operations-basic/src/test/java/com/baeldung/arraylist/operations/ArrayListOperationsUnitTest.java diff --git a/core-java-modules/core-java-arrays/README.md b/core-java-modules/core-java-arrays/README.md index 7b5f21a1e6..7c7e6d0add 100644 --- a/core-java-modules/core-java-arrays/README.md +++ b/core-java-modules/core-java-arrays/README.md @@ -4,7 +4,5 @@ This module contains articles about Java arrays ### Relevant Articles: - [How to Copy an Array in Java](https://www.baeldung.com/java-array-copy) -- [Check if a Java Array Contains a Value](https://www.baeldung.com/java-array-contains-value) -- [Initializing Arrays in Java](https://www.baeldung.com/java-initialize-array) - [Find Sum and Average in a Java Array](https://www.baeldung.com/java-array-sum-average) - [[More -->]](/core-java-modules/core-java-arrays-2) diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 9926e7781a..cf6e4c69cf 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -126,6 +126,7 @@ core-java-arrays-guides core-java-arrays-multidimensional core-java-arrays-convert + core-java-arrays-operations-basic From 50530b81b499cf4ed9248b0baed519230572c40f Mon Sep 17 00:00:00 2001 From: dupirefr Date: Fri, 10 Apr 2020 21:45:37 +0200 Subject: [PATCH 241/503] [JAVA-616] core-java-arrays-operations-advanced * Creation * Moved code from https://www.baeldung.com/java-array-copy * Moved code from https://www.baeldung.com/java-arrays-deepequals * Moved code from https://www.baeldung.com/java-array-sum-average * Moved code from https://www.baeldung.com/java-array-intersection --- .../core-java-arrays-2/README.md | 1 - .../core-java-arrays-3/README.md | 1 - .../README.md | 16 +++++++++ .../pom.xml | 36 +++++++++++++++++++ .../baeldung/array/SumAndAverageInArray.java | 0 .../ArraysIntersectionOperations.java | 0 .../com/baeldung/arraycopy/model/Address.java | 0 .../baeldung/arraycopy/model/Employee.java | 0 .../array/SumAndAverageInArrayUnitTest.java | 0 .../operations/IntersectionUnitTest.java | 0 .../arraycopy/ArrayCopyUtilUnitTest.java | 0 .../deepequals/ArraysDeepEqualsUnitTest.java | 0 core-java-modules/core-java-arrays/README.md | 2 -- core-java-modules/pom.xml | 1 + 14 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 core-java-modules/core-java-arrays-operations-advanced/README.md create mode 100644 core-java-modules/core-java-arrays-operations-advanced/pom.xml rename core-java-modules/{core-java-arrays => core-java-arrays-operations-advanced}/src/main/java/com/baeldung/array/SumAndAverageInArray.java (100%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-operations-advanced}/src/main/java/com/baeldung/array/operations/ArraysIntersectionOperations.java (100%) rename core-java-modules/{core-java-arrays => core-java-arrays-operations-advanced}/src/main/java/com/baeldung/arraycopy/model/Address.java (100%) rename core-java-modules/{core-java-arrays => core-java-arrays-operations-advanced}/src/main/java/com/baeldung/arraycopy/model/Employee.java (100%) rename core-java-modules/{core-java-arrays => core-java-arrays-operations-advanced}/src/test/java/com/baeldung/array/SumAndAverageInArrayUnitTest.java (100%) rename core-java-modules/{core-java-arrays-2 => core-java-arrays-operations-advanced}/src/test/java/com/baeldung/array/operations/IntersectionUnitTest.java (100%) rename core-java-modules/{core-java-arrays => core-java-arrays-operations-advanced}/src/test/java/com/baeldung/arraycopy/ArrayCopyUtilUnitTest.java (100%) rename core-java-modules/{core-java-arrays-3 => core-java-arrays-operations-advanced}/src/test/java/com/baeldung/arrays/deepequals/ArraysDeepEqualsUnitTest.java (100%) diff --git a/core-java-modules/core-java-arrays-2/README.md b/core-java-modules/core-java-arrays-2/README.md index bde6c6cc1e..20a2ddec9f 100644 --- a/core-java-modules/core-java-arrays-2/README.md +++ b/core-java-modules/core-java-arrays-2/README.md @@ -4,5 +4,4 @@ This module contains articles about Java arrays ## Relevant Articles -- [Intersection Between two Integer Arrays](https://www.baeldung.com/java-array-intersection) - [[<-- Prev]](/core-java-modules/core-java-arrays) diff --git a/core-java-modules/core-java-arrays-3/README.md b/core-java-modules/core-java-arrays-3/README.md index 255d3d097d..a96ddccabb 100644 --- a/core-java-modules/core-java-arrays-3/README.md +++ b/core-java-modules/core-java-arrays-3/README.md @@ -1,3 +1,2 @@ ### Relevant Articles: -- [Arrays.deepEquals](https://www.baeldung.com/java-arrays-deepequals) diff --git a/core-java-modules/core-java-arrays-operations-advanced/README.md b/core-java-modules/core-java-arrays-operations-advanced/README.md new file mode 100644 index 0000000000..71f9ce0ac6 --- /dev/null +++ b/core-java-modules/core-java-arrays-operations-advanced/README.md @@ -0,0 +1,16 @@ +## Core Java Arrays - Advanced Operations + +This module contains articles about advanced operations on arrays in Java + +Advanced operations would be much logic or interactions with other arrays, such as: + +- Sum, average of elements +- Intersections +- ... + +### Relevant Articles: +- [How to Copy an Array in Java](https://www.baeldung.com/java-array-copy) +- [Arrays.deepEquals](https://www.baeldung.com/java-arrays-deepequals) +- [Find Sum and Average in a Java Array](https://www.baeldung.com/java-array-sum-average) +- [Intersection Between two Integer Arrays](https://www.baeldung.com/java-array-intersection) +- [[More basic operations-->]](/core-java-modules/core-java-operations-basic) diff --git a/core-java-modules/core-java-arrays-operations-advanced/pom.xml b/core-java-modules/core-java-arrays-operations-advanced/pom.xml new file mode 100644 index 0000000000..8989e91189 --- /dev/null +++ b/core-java-modules/core-java-arrays-operations-advanced/pom.xml @@ -0,0 +1,36 @@ + + + + core-java-modules + com.baeldung.core-java-modules + 1.0.0-SNAPSHOT + + 4.0.0 + + core-java-arrays-operations-advanced + core-java-arrays-operations-advanced + jar + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + + + 3.9 + + 3.10.0 + + \ No newline at end of file diff --git a/core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/SumAndAverageInArray.java b/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/array/SumAndAverageInArray.java similarity index 100% rename from core-java-modules/core-java-arrays/src/main/java/com/baeldung/array/SumAndAverageInArray.java rename to core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/array/SumAndAverageInArray.java diff --git a/core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/operations/ArraysIntersectionOperations.java b/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/array/operations/ArraysIntersectionOperations.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/main/java/com/baeldung/array/operations/ArraysIntersectionOperations.java rename to core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/array/operations/ArraysIntersectionOperations.java diff --git a/core-java-modules/core-java-arrays/src/main/java/com/baeldung/arraycopy/model/Address.java b/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/arraycopy/model/Address.java similarity index 100% rename from core-java-modules/core-java-arrays/src/main/java/com/baeldung/arraycopy/model/Address.java rename to core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/arraycopy/model/Address.java diff --git a/core-java-modules/core-java-arrays/src/main/java/com/baeldung/arraycopy/model/Employee.java b/core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/arraycopy/model/Employee.java similarity index 100% rename from core-java-modules/core-java-arrays/src/main/java/com/baeldung/arraycopy/model/Employee.java rename to core-java-modules/core-java-arrays-operations-advanced/src/main/java/com/baeldung/arraycopy/model/Employee.java diff --git a/core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/SumAndAverageInArrayUnitTest.java b/core-java-modules/core-java-arrays-operations-advanced/src/test/java/com/baeldung/array/SumAndAverageInArrayUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays/src/test/java/com/baeldung/array/SumAndAverageInArrayUnitTest.java rename to core-java-modules/core-java-arrays-operations-advanced/src/test/java/com/baeldung/array/SumAndAverageInArrayUnitTest.java diff --git a/core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/operations/IntersectionUnitTest.java b/core-java-modules/core-java-arrays-operations-advanced/src/test/java/com/baeldung/array/operations/IntersectionUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays-2/src/test/java/com/baeldung/array/operations/IntersectionUnitTest.java rename to core-java-modules/core-java-arrays-operations-advanced/src/test/java/com/baeldung/array/operations/IntersectionUnitTest.java diff --git a/core-java-modules/core-java-arrays/src/test/java/com/baeldung/arraycopy/ArrayCopyUtilUnitTest.java b/core-java-modules/core-java-arrays-operations-advanced/src/test/java/com/baeldung/arraycopy/ArrayCopyUtilUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays/src/test/java/com/baeldung/arraycopy/ArrayCopyUtilUnitTest.java rename to core-java-modules/core-java-arrays-operations-advanced/src/test/java/com/baeldung/arraycopy/ArrayCopyUtilUnitTest.java diff --git a/core-java-modules/core-java-arrays-3/src/test/java/com/baeldung/arrays/deepequals/ArraysDeepEqualsUnitTest.java b/core-java-modules/core-java-arrays-operations-advanced/src/test/java/com/baeldung/arrays/deepequals/ArraysDeepEqualsUnitTest.java similarity index 100% rename from core-java-modules/core-java-arrays-3/src/test/java/com/baeldung/arrays/deepequals/ArraysDeepEqualsUnitTest.java rename to core-java-modules/core-java-arrays-operations-advanced/src/test/java/com/baeldung/arrays/deepequals/ArraysDeepEqualsUnitTest.java diff --git a/core-java-modules/core-java-arrays/README.md b/core-java-modules/core-java-arrays/README.md index 7c7e6d0add..efc6ab426d 100644 --- a/core-java-modules/core-java-arrays/README.md +++ b/core-java-modules/core-java-arrays/README.md @@ -3,6 +3,4 @@ This module contains articles about Java arrays ### Relevant Articles: -- [How to Copy an Array in Java](https://www.baeldung.com/java-array-copy) -- [Find Sum and Average in a Java Array](https://www.baeldung.com/java-array-sum-average) - [[More -->]](/core-java-modules/core-java-arrays-2) diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index cf6e4c69cf..414313f918 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -127,6 +127,7 @@ core-java-arrays-multidimensional core-java-arrays-convert core-java-arrays-operations-basic + core-java-arrays-operations-advanced From 91922d655394434ff244ad4d2a2d2a7699c53ee3 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Fri, 10 Apr 2020 22:02:20 +0200 Subject: [PATCH 242/503] [JAVA-616] Cleaning code * Removed core-java-arrays* modules * Updated core-java-module/pom.xml --- .../core-java-arrays-2/README.md | 7 - core-java-modules/core-java-arrays-2/pom.xml | 86 --------- .../core-java-arrays-3/README.md | 2 - core-java-modules/core-java-arrays-3/pom.xml | 32 ---- core-java-modules/core-java-arrays/README.md | 6 - core-java-modules/core-java-arrays/pom.xml | 180 ------------------ core-java-modules/pom.xml | 16 +- 7 files changed, 7 insertions(+), 322 deletions(-) delete mode 100644 core-java-modules/core-java-arrays-2/README.md delete mode 100644 core-java-modules/core-java-arrays-2/pom.xml delete mode 100644 core-java-modules/core-java-arrays-3/README.md delete mode 100644 core-java-modules/core-java-arrays-3/pom.xml delete mode 100644 core-java-modules/core-java-arrays/README.md delete mode 100644 core-java-modules/core-java-arrays/pom.xml diff --git a/core-java-modules/core-java-arrays-2/README.md b/core-java-modules/core-java-arrays-2/README.md deleted file mode 100644 index 20a2ddec9f..0000000000 --- a/core-java-modules/core-java-arrays-2/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## Core Java Arrays (Part 2) - -This module contains articles about Java arrays - -## Relevant Articles - -- [[<-- Prev]](/core-java-modules/core-java-arrays) diff --git a/core-java-modules/core-java-arrays-2/pom.xml b/core-java-modules/core-java-arrays-2/pom.xml deleted file mode 100644 index 1445a322d7..0000000000 --- a/core-java-modules/core-java-arrays-2/pom.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - 4.0.0 - core-java-arrays-2 - 0.1.0-SNAPSHOT - core-java-arrays-2 - jar - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../../parent-java - - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - org.openjdk.jmh - jmh-core - ${jmh.version} - - - org.openjdk.jmh - jmh-generator-annprocess - ${jmh.version} - - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - - - core-java-arrays-2 - - - src/main/resources - true - - - - - org.apache.maven.plugins - maven-shade-plugin - ${shade.plugin.version} - - - package - - shade - - - benchmarks - - - org.openjdk.jmh.Main - - - - - - - - - - - 1.19 - - 3.9 - - 3.10.0 - 3.2.0 - - - 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 a96ddccabb..0000000000 --- a/core-java-modules/core-java-arrays-3/README.md +++ /dev/null @@ -1,2 +0,0 @@ -### Relevant Articles: - diff --git a/core-java-modules/core-java-arrays-3/pom.xml b/core-java-modules/core-java-arrays-3/pom.xml deleted file mode 100644 index 210375b878..0000000000 --- a/core-java-modules/core-java-arrays-3/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - 4.0.0 - core-java-arrays-3 - 0.1.0-SNAPSHOT - core-java-arrays-3 - jar - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../../parent-java - - - - - org.assertj - assertj-core - ${assertj.version} - test - - - - - 3.14.0 - - - \ No newline at end of file diff --git a/core-java-modules/core-java-arrays/README.md b/core-java-modules/core-java-arrays/README.md deleted file mode 100644 index efc6ab426d..0000000000 --- a/core-java-modules/core-java-arrays/README.md +++ /dev/null @@ -1,6 +0,0 @@ -## Core Java Arrays - -This module contains articles about Java arrays - -### Relevant Articles: -- [[More -->]](/core-java-modules/core-java-arrays-2) diff --git a/core-java-modules/core-java-arrays/pom.xml b/core-java-modules/core-java-arrays/pom.xml deleted file mode 100644 index ea28eb25eb..0000000000 --- a/core-java-modules/core-java-arrays/pom.xml +++ /dev/null @@ -1,180 +0,0 @@ - - - 4.0.0 - core-java-arrays - 0.1.0-SNAPSHOT - core-java-arrays - jar - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../../parent-java - - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - org.openjdk.jmh - jmh-core - ${jmh-core.version} - - - org.openjdk.jmh - jmh-generator-annprocess - ${jmh-generator-annprocess.version} - - - - - core-java-arrays - - - src/main/resources - true - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - prepare-package - - copy-dependencies - - - ${project.build.directory}/libs - - - - - - - - org.codehaus.mojo - exec-maven-plugin - ${exec-maven-plugin.version} - - java - com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed - - -Xmx300m - -XX:+UseParallelGC - -classpath - - com.baeldung.outofmemoryerror.OutOfMemoryGCLimitExceed - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - ${maven-javadoc-plugin.version} - - ${source.version} - ${target.version} - - - - - - - - integration - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration-test - - test - - - - **/*ManualTest.java - - - **/*IntegrationTest.java - **/*IntTest.java - - - - - - - json - - - - - org.codehaus.mojo - exec-maven-plugin - ${exec-maven-plugin.version} - - - run-benchmarks - - none - - exec - - - test - java - - -classpath - - org.openjdk.jmh.Main - .* - - - - - - - - - - - - - - 3.9 - - 1.19 - 1.19 - - - 3.10.0 - - - 3.0.0-M1 - 1.6.0 - 1.8 - 1.8 - - - diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 414313f918..b7454cc737 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -31,10 +31,14 @@ core-java-annotations - core-java-arrays - core-java-arrays-2 - core-java-arrays-3 + core-java-arrays-sorting + core-java-arrays-guides + core-java-arrays-multidimensional + core-java-arrays-convert + core-java-arrays-operations-basic + core-java-arrays-operations-advanced + core-java-collections core-java-collections-2 core-java-collections-3 @@ -122,12 +126,6 @@ pre-jpms - core-java-arrays-sorting - core-java-arrays-guides - core-java-arrays-multidimensional - core-java-arrays-convert - core-java-arrays-operations-basic - core-java-arrays-operations-advanced From 40fb82606a7a00044781ed96acf6132a88c6ee10 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Fri, 17 Apr 2020 21:05:33 +0200 Subject: [PATCH 243/503] [JAVA-616] Reworded operations modules descriptions --- .../core-java-arrays-operations-advanced/README.md | 9 +-------- .../core-java-arrays-operations-basic/README.md | 9 +-------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/core-java-modules/core-java-arrays-operations-advanced/README.md b/core-java-modules/core-java-arrays-operations-advanced/README.md index 71f9ce0ac6..af0c00641a 100644 --- a/core-java-modules/core-java-arrays-operations-advanced/README.md +++ b/core-java-modules/core-java-arrays-operations-advanced/README.md @@ -1,16 +1,9 @@ ## Core Java Arrays - Advanced Operations -This module contains articles about advanced operations on arrays in Java - -Advanced operations would be much logic or interactions with other arrays, such as: - -- Sum, average of elements -- Intersections -- ... +This module contains articles about advanced operations on arrays in Java. They assume some background knowledge with arrays in Java. ### Relevant Articles: - [How to Copy an Array in Java](https://www.baeldung.com/java-array-copy) - [Arrays.deepEquals](https://www.baeldung.com/java-arrays-deepequals) - [Find Sum and Average in a Java Array](https://www.baeldung.com/java-array-sum-average) - [Intersection Between two Integer Arrays](https://www.baeldung.com/java-array-intersection) -- [[More basic operations-->]](/core-java-modules/core-java-operations-basic) diff --git a/core-java-modules/core-java-arrays-operations-basic/README.md b/core-java-modules/core-java-arrays-operations-basic/README.md index 914d5a71bd..ca81c23c98 100644 --- a/core-java-modules/core-java-arrays-operations-basic/README.md +++ b/core-java-modules/core-java-arrays-operations-basic/README.md @@ -1,12 +1,6 @@ ## Core Java Arrays - Basic Operations -This module contains articles about basic operations on arrays in Java - -Basic operations would cover anything elementary we should expect to be able to achieve on a collection type: - -- Adding/Removing elements -- Getting elements -- Iterating +This module contains articles about Java array fundamentals. They assume no previous background knowledge on working with arrays. ### Relevant Articles: - [Initializing Arrays in Java](https://www.baeldung.com/java-initialize-array) @@ -16,4 +10,3 @@ Basic operations would cover anything elementary we should expect to be able to - [Removing an Element from an Array in Java](https://www.baeldung.com/java-array-remove-element) - [Removing the First Element of an Array](https://www.baeldung.com/java-array-remove-first-element) - [Extending an Array’s Length](https://www.baeldung.com/java-array-add-element-at-the-end) -- [[More advanced operations -->]](/core-java-modules/core-java-arrays-operations-advanced) From 5e223df9d6468d2df6991974d63c9982f4b2f085 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Fri, 17 Apr 2020 22:11:57 +0200 Subject: [PATCH 244/503] BAEL-3992: Remove jnlp dependencies from the pom.xml --- jws/pom.xml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/jws/pom.xml b/jws/pom.xml index f867df8051..be42798fd1 100644 --- a/jws/pom.xml +++ b/jws/pom.xml @@ -14,21 +14,6 @@ 1.0.0-SNAPSHOT
- - - OpenNMS Repository - https://repo.opennms.org/maven2/ - - - - - - javax.samples.jnlp - jnlp-servlet - ${jnlp-servlet.version} - - - ${project.artifactId} @@ -79,7 +64,6 @@ 3.0.2 - 1.6.0 From 6bf0d97d62bdfe986fde782544d47ebba9cb9705 Mon Sep 17 00:00:00 2001 From: Kyle Doyle Date: Fri, 17 Apr 2020 19:50:36 -0400 Subject: [PATCH 245/503] Bael-3893 AWS AppSync with Spring Boot --- aws-app-sync/pom.xml | 15 +++- .../src/main/resources/application.properties | 1 - .../AwsAppSyncApplicationTests.java | 90 ++++++++++++++++++- 3 files changed, 102 insertions(+), 4 deletions(-) delete mode 100644 aws-app-sync/src/main/resources/application.properties diff --git a/aws-app-sync/pom.xml b/aws-app-sync/pom.xml index af02307e66..d30cfc96a4 100644 --- a/aws-app-sync/pom.xml +++ b/aws-app-sync/pom.xml @@ -8,17 +8,26 @@ 2.2.6.RELEASE + com.baeldung aws-app-sync 0.0.1-SNAPSHOT aws-app-sync - Demo project for Spring Boot using AWS App Sync + + Spring Boot using AWS App Sync 1.8 + + + com.amazonaws + aws-java-sdk-appsync + 1.11.762 + + org.springframework.boot spring-boot-starter-web @@ -35,6 +44,10 @@ + + org.springframework.boot + spring-boot-starter-webflux + diff --git a/aws-app-sync/src/main/resources/application.properties b/aws-app-sync/src/main/resources/application.properties deleted file mode 100644 index 8b13789179..0000000000 --- a/aws-app-sync/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java b/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java index 7b82393865..15bcc6e9c9 100644 --- a/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java +++ b/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java @@ -1,13 +1,99 @@ package com.baeldung.awsappsync; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.client.WebClient; + +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.*; @SpringBootTest class AwsAppSyncApplicationTests { - @Test - void contextLoads() { + static String apiUrl = "https://m4i3b6icrrb7livfbypfspiifi.appsync-api.us-east-2.amazonaws.com"; + static String apiKey = "da2-es2s6oj4mzhbxk5yu26ss2ruj4"; + static String API_KEY_HEADER = "x-api-key"; + + static WebClient.RequestBodySpec requestBodySpec; + + @BeforeAll + static void setUp() { + requestBodySpec = WebClient + .builder() + .baseUrl(apiUrl) + .defaultHeader(API_KEY_HEADER, apiKey) + .build() + .method(HttpMethod.POST) + .uri("/graphql"); } + @Test + void testGraphQuery() { + + Map requestBody = new HashMap<>(); + requestBody.put("query", "query ListEvents {\n" + + " listEvents {\n" + + " items {\n" + + " id\n" + + " name\n" + + " where\n" + + " when\n" + + " description\n" + + " }\n" + + " }\n" + + "}"); + requestBody.put("variables", ""); + requestBody.put("operationName", "ListEvents"); + + WebClient.ResponseSpec response = requestBodySpec + .body(BodyInserters.fromValue(requestBody)) + .accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML) + .acceptCharset(StandardCharsets.UTF_8) + .retrieve(); + + String bodyString = response.bodyToMono(String.class).block(); + + assertTrue(bodyString != null && bodyString.contains("My First Event")); + } + + @Test + void testGraphAdd() { + + String queryString = "mutation add {\n" + + " createEvent(\n" + + " name:\"My added GraphQL event\"\n" + + " where:\"Day 2\"\n" + + " when:\"Saturday night\"\n" + + " description:\"Studying GraphQL\"\n" + + " ){\n" + + " id\n" + + " name\n" + + " where\n" + + " when\n" + + " description\n" + + " }\n" + + "}"; + + + Map requestBody = new HashMap<>(); + requestBody.put("query", queryString); + requestBody.put("variables", ""); + requestBody.put("operationName", "add"); + + WebClient.ResponseSpec response = requestBodySpec + .body(BodyInserters.fromValue(requestBody)) + .accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML) + .acceptCharset(StandardCharsets.UTF_8) + .retrieve(); + + String bodyString = response.bodyToMono(String.class).block(); + assertTrue(bodyString != null && bodyString.contains("Day 2")); + } } From 9a1e98598f8c8015dff5dc2edc86446d28f606b6 Mon Sep 17 00:00:00 2001 From: Kyle Doyle Date: Fri, 17 Apr 2020 19:56:42 -0400 Subject: [PATCH 246/503] Bael-3893 AWS AppSync with Spring Boot --- .../awsappsync/AwsAppSyncApplicationTests.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java b/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java index 15bcc6e9c9..005d533cbf 100644 --- a/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java +++ b/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java @@ -35,7 +35,7 @@ class AwsAppSyncApplicationTests { } @Test - void testGraphQuery() { + void givenGraphQuery_whenListEvents_thenReturnAllEvents() { Map requestBody = new HashMap<>(); requestBody.put("query", "query ListEvents {\n" + @@ -60,11 +60,14 @@ class AwsAppSyncApplicationTests { String bodyString = response.bodyToMono(String.class).block(); - assertTrue(bodyString != null && bodyString.contains("My First Event")); + assertNotNull(bodyString); + assertTrue(bodyString.contains("My First Event")); + assertTrue(bodyString.contains("where")); + assertTrue(bodyString.contains("when")); } @Test - void testGraphAdd() { + void givenGraphAdd_whenMutation_thenReturnIdNameDesc() { String queryString = "mutation add {\n" + " createEvent(\n" + @@ -75,8 +78,6 @@ class AwsAppSyncApplicationTests { " ){\n" + " id\n" + " name\n" + - " where\n" + - " when\n" + " description\n" + " }\n" + "}"; @@ -94,6 +95,10 @@ class AwsAppSyncApplicationTests { .retrieve(); String bodyString = response.bodyToMono(String.class).block(); - assertTrue(bodyString != null && bodyString.contains("Day 2")); + + assertNotNull(bodyString); + assertTrue(bodyString.contains("My added GraphQL event")); + assertFalse(bodyString.contains("where")); + assertFalse(bodyString.contains("when")); } } From 3746a5328554b56ff614d5abf328f104e4b6c727 Mon Sep 17 00:00:00 2001 From: Kyle Doyle Date: Fri, 17 Apr 2020 20:16:59 -0400 Subject: [PATCH 247/503] Bael 3893 - Added to modules --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 71e5d21b02..22d73f3a9e 100644 --- a/pom.xml +++ b/pom.xml @@ -1015,6 +1015,7 @@ asm atomix aws + aws-app-sync aws-lambda axon azure From 7678f4a0cc7feb670715f7f3c3124bbdebc9bec5 Mon Sep 17 00:00:00 2001 From: Kirill Vlasov Date: Sat, 18 Apr 2020 08:00:52 +0500 Subject: [PATCH 248/503] Code review --- .../java/com/baeldung/customlogouthandler/MvcConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/MvcConfiguration.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/MvcConfiguration.java index 3e17a7c397..c363effb4e 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/MvcConfiguration.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/customlogouthandler/MvcConfiguration.java @@ -35,7 +35,7 @@ public class MvcConfiguration extends WebSecurityConfigurerAdapter { .logout() .logoutUrl("/user/logout") .addLogoutHandler(logoutHandler) - .logoutSuccessHandler((new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK))) + .logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK)) .permitAll() .and() .csrf() From 1ec2d9a4ed2b57380462ef06d710c90dc434b371 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 18 Apr 2020 11:43:52 +0530 Subject: [PATCH 249/503] JAVA-627: Moved 2 articles from libraries-2 --- libraries-2/README.md | 2 - libraries-2/pom.xml | 26 +---- .../okhttp/ResponseDecoderUnitTest.java | 102 ------------------ .../com/baeldung/okhttp/SimpleEntity.java | 22 ---- 4 files changed, 1 insertion(+), 151 deletions(-) delete mode 100644 libraries-2/src/test/java/com/baeldung/okhttp/ResponseDecoderUnitTest.java delete mode 100644 libraries-2/src/test/java/com/baeldung/okhttp/SimpleEntity.java diff --git a/libraries-2/README.md b/libraries-2/README.md index eb45a3e426..edf513c6ee 100644 --- a/libraries-2/README.md +++ b/libraries-2/README.md @@ -14,11 +14,9 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Guide to Java Parallel Collectors Library](https://www.baeldung.com/java-parallel-collectors) - [Templating with Handlebars](https://www.baeldung.com/handlebars) - [A Guide to Crawler4j](https://www.baeldung.com/crawler4j) -- [Decode an OkHttp JSON Response](https://www.baeldung.com/okhttp-json-response) - [Key Value Store with Chronicle Map](https://www.baeldung.com/java-chronicle-map) - [Guide to MapDB](https://www.baeldung.com/mapdb) - [A Guide to Apache Mesos](https://www.baeldung.com/apache-mesos) - [JasperReports with Spring](https://www.baeldung.com/spring-jasper) -- [Jetty ReactiveStreams HTTP Client](https://www.baeldung.com/jetty-reactivestreams-http-client) - More articles [[<-- prev]](/libraries) diff --git a/libraries-2/pom.xml b/libraries-2/pom.xml index 474ff563c2..3aa36c3f90 100644 --- a/libraries-2/pom.xml +++ b/libraries-2/pom.xml @@ -75,28 +75,7 @@ - - - com.squareup.okhttp3 - okhttp - ${okhttp.version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.google.code.gson - gson - ${gson.version} - - - com.squareup.okhttp3 - mockwebserver - ${mockwebserver.version} - test - + edu.uci.ics crawler4j @@ -151,9 +130,6 @@ 2.1.4.RELEASE 0.28.3 1.1.0 - 3.14.2 - 2.8.5 - 3.14.2 4.1.2 6.6.0 5.1.9.RELEASE diff --git a/libraries-2/src/test/java/com/baeldung/okhttp/ResponseDecoderUnitTest.java b/libraries-2/src/test/java/com/baeldung/okhttp/ResponseDecoderUnitTest.java deleted file mode 100644 index 11a295031a..0000000000 --- a/libraries-2/src/test/java/com/baeldung/okhttp/ResponseDecoderUnitTest.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.baeldung.okhttp; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.gson.Gson; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.ResponseBody; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.io.InputStreamReader; - -public class ResponseDecoderUnitTest { - - @Rule public ExpectedException exceptionRule = ExpectedException.none(); - - @Rule public MockWebServer server = new MockWebServer(); - - SimpleEntity sampleResponse; - - MockResponse mockResponse; - - OkHttpClient client; - - @Before - public void setUp() { - sampleResponse = new SimpleEntity("Baeldung"); - client = new OkHttpClient.Builder().build(); - mockResponse = new MockResponse() - .setResponseCode(200) - .setHeader("Content-Type", "application/json") - .setBody(new Gson().toJson(sampleResponse)); - } - - @Test - public void givenJacksonDecoder_whenGetStringOfResponse_thenExpectSimpleEntity() throws Exception { - server.enqueue(mockResponse); - Request request = new Request.Builder() - .url(server.url("")) - .build(); - ResponseBody responseBody = client - .newCall(request) - .execute() - .body(); - - Assert.assertNotNull(responseBody); - Assert.assertNotEquals(0, responseBody.contentLength()); - - ObjectMapper objectMapper = new ObjectMapper(); - SimpleEntity entity = objectMapper.readValue(responseBody.string(), SimpleEntity.class); - - Assert.assertNotNull(entity); - Assert.assertEquals(sampleResponse.getName(), entity.getName()); - } - - @Test - public void givenGsonDecoder_whenGetByteStreamOfResponse_thenExpectSimpleEntity() throws Exception { - server.enqueue(mockResponse); - Request request = new Request.Builder() - .url(server.url("")) - .build(); - ResponseBody responseBody = client - .newCall(request) - .execute() - .body(); - - Assert.assertNotNull(responseBody); - Assert.assertNotEquals(0, responseBody.contentLength()); - - Gson gson = new Gson(); - SimpleEntity entity = gson.fromJson(new InputStreamReader(responseBody.byteStream()), SimpleEntity.class); - - Assert.assertNotNull(entity); - Assert.assertEquals(sampleResponse.getName(), entity.getName()); - } - - @Test - public void givenGsonDecoder_whenGetStringOfResponse_thenExpectSimpleEntity() throws Exception { - server.enqueue(mockResponse); - Request request = new Request.Builder() - .url(server.url("")) - .build(); - ResponseBody responseBody = client - .newCall(request) - .execute() - .body(); - - Assert.assertNotNull(responseBody); - - Gson gson = new Gson(); - SimpleEntity entity = gson.fromJson(responseBody.string(), SimpleEntity.class); - - Assert.assertNotNull(entity); - Assert.assertEquals(sampleResponse.getName(), entity.getName()); - } - -} diff --git a/libraries-2/src/test/java/com/baeldung/okhttp/SimpleEntity.java b/libraries-2/src/test/java/com/baeldung/okhttp/SimpleEntity.java deleted file mode 100644 index 211e43e556..0000000000 --- a/libraries-2/src/test/java/com/baeldung/okhttp/SimpleEntity.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.okhttp; - -public class SimpleEntity { - protected String name; - - public SimpleEntity(String name) { - this.name = name; - } - - //no-arg constructor, getters and setters here - - public SimpleEntity() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} From c990a29bf76f956f4bfcbdbdc32d3eb843e1fea7 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 18 Apr 2020 11:44:19 +0530 Subject: [PATCH 250/503] JAVA-627: Moved 2 articles to libraries-http-2 --- libraries-http-2/README.md | 10 ++ libraries-http-2/pom.xml | 47 ++++++++ .../okhttp/ResponseDecoderUnitTest.java | 102 ++++++++++++++++++ .../com/baeldung/okhttp/SimpleEntity.java | 22 ++++ 4 files changed, 181 insertions(+) create mode 100644 libraries-http-2/README.md create mode 100644 libraries-http-2/pom.xml create mode 100644 libraries-http-2/src/test/java/com/baeldung/okhttp/ResponseDecoderUnitTest.java create mode 100644 libraries-http-2/src/test/java/com/baeldung/okhttp/SimpleEntity.java diff --git a/libraries-http-2/README.md b/libraries-http-2/README.md new file mode 100644 index 0000000000..5ba45eb4a9 --- /dev/null +++ b/libraries-http-2/README.md @@ -0,0 +1,10 @@ +## HTTP + +This module contains articles about HTTP libraries. + +### Relevant Articles: + +- [Jetty ReactiveStreams HTTP Client](https://www.baeldung.com/jetty-reactivestreams-http-client) +- [Decode an OkHttp JSON Response](https://www.baeldung.com/okhttp-json-response) +- More articles [[<-- prev]](/libraries-http) + diff --git a/libraries-http-2/pom.xml b/libraries-http-2/pom.xml new file mode 100644 index 0000000000..c0a4f6455d --- /dev/null +++ b/libraries-http-2/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + libraries-http-2 + libraries-http-2 + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + + com.squareup.okhttp3 + okhttp + ${okhttp.version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.google.code.gson + gson + ${gson.version} + + + com.squareup.okhttp3 + mockwebserver + ${mockwebserver.version} + test + + + + + 3.14.2 + 2.8.5 + 3.14.2 + 2.9.8 + + + diff --git a/libraries-http-2/src/test/java/com/baeldung/okhttp/ResponseDecoderUnitTest.java b/libraries-http-2/src/test/java/com/baeldung/okhttp/ResponseDecoderUnitTest.java new file mode 100644 index 0000000000..11a295031a --- /dev/null +++ b/libraries-http-2/src/test/java/com/baeldung/okhttp/ResponseDecoderUnitTest.java @@ -0,0 +1,102 @@ +package com.baeldung.okhttp; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.gson.Gson; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.ResponseBody; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import java.io.InputStreamReader; + +public class ResponseDecoderUnitTest { + + @Rule public ExpectedException exceptionRule = ExpectedException.none(); + + @Rule public MockWebServer server = new MockWebServer(); + + SimpleEntity sampleResponse; + + MockResponse mockResponse; + + OkHttpClient client; + + @Before + public void setUp() { + sampleResponse = new SimpleEntity("Baeldung"); + client = new OkHttpClient.Builder().build(); + mockResponse = new MockResponse() + .setResponseCode(200) + .setHeader("Content-Type", "application/json") + .setBody(new Gson().toJson(sampleResponse)); + } + + @Test + public void givenJacksonDecoder_whenGetStringOfResponse_thenExpectSimpleEntity() throws Exception { + server.enqueue(mockResponse); + Request request = new Request.Builder() + .url(server.url("")) + .build(); + ResponseBody responseBody = client + .newCall(request) + .execute() + .body(); + + Assert.assertNotNull(responseBody); + Assert.assertNotEquals(0, responseBody.contentLength()); + + ObjectMapper objectMapper = new ObjectMapper(); + SimpleEntity entity = objectMapper.readValue(responseBody.string(), SimpleEntity.class); + + Assert.assertNotNull(entity); + Assert.assertEquals(sampleResponse.getName(), entity.getName()); + } + + @Test + public void givenGsonDecoder_whenGetByteStreamOfResponse_thenExpectSimpleEntity() throws Exception { + server.enqueue(mockResponse); + Request request = new Request.Builder() + .url(server.url("")) + .build(); + ResponseBody responseBody = client + .newCall(request) + .execute() + .body(); + + Assert.assertNotNull(responseBody); + Assert.assertNotEquals(0, responseBody.contentLength()); + + Gson gson = new Gson(); + SimpleEntity entity = gson.fromJson(new InputStreamReader(responseBody.byteStream()), SimpleEntity.class); + + Assert.assertNotNull(entity); + Assert.assertEquals(sampleResponse.getName(), entity.getName()); + } + + @Test + public void givenGsonDecoder_whenGetStringOfResponse_thenExpectSimpleEntity() throws Exception { + server.enqueue(mockResponse); + Request request = new Request.Builder() + .url(server.url("")) + .build(); + ResponseBody responseBody = client + .newCall(request) + .execute() + .body(); + + Assert.assertNotNull(responseBody); + + Gson gson = new Gson(); + SimpleEntity entity = gson.fromJson(responseBody.string(), SimpleEntity.class); + + Assert.assertNotNull(entity); + Assert.assertEquals(sampleResponse.getName(), entity.getName()); + } + +} diff --git a/libraries-http-2/src/test/java/com/baeldung/okhttp/SimpleEntity.java b/libraries-http-2/src/test/java/com/baeldung/okhttp/SimpleEntity.java new file mode 100644 index 0000000000..211e43e556 --- /dev/null +++ b/libraries-http-2/src/test/java/com/baeldung/okhttp/SimpleEntity.java @@ -0,0 +1,22 @@ +package com.baeldung.okhttp; + +public class SimpleEntity { + protected String name; + + public SimpleEntity(String name) { + this.name = name; + } + + //no-arg constructor, getters and setters here + + public SimpleEntity() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} From c2ce41c539760ed954581e545db596b7a8270f4d Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 18 Apr 2020 11:44:56 +0530 Subject: [PATCH 251/503] JAVA-627: Added next link in README for libraries-http --- libraries-http/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries-http/README.md b/libraries-http/README.md index 1f065a9d4a..61b2904cee 100644 --- a/libraries-http/README.md +++ b/libraries-http/README.md @@ -14,3 +14,4 @@ This module contains articles about HTTP libraries. - [Creating REST Microservices with Javalin](https://www.baeldung.com/javalin-rest-microservices) - [A Quick Guide to Timeouts in OkHttp](https://www.baeldung.com/okhttp-timeouts) - [A Quick Guide to Post Requests with OkHttp](https://www.baeldung.com/okhttp-post) +- More articles [[next -->]](/libraries-http-2) From 24fb2dcccf1743fd8d800f4b25f50896373031d2 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 18 Apr 2020 11:45:39 +0530 Subject: [PATCH 252/503] JAVA-627: Added new module libraries-http-2 to main pom --- pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pom.xml b/pom.xml index 9e3b354d74..f6eabfa653 100644 --- a/pom.xml +++ b/pom.xml @@ -505,6 +505,7 @@ libraries-data-db libraries-data-io libraries-http + libraries-http-2 libraries-io libraries-primitive libraries-security @@ -1017,6 +1018,7 @@ libraries-data-db libraries-data-io libraries-http + libraries-http-2 libraries-io libraries-primitive libraries-security From 744d2b5733c7641da2f0f129e9d293ce58356efc Mon Sep 17 00:00:00 2001 From: mikr Date: Sat, 18 Apr 2020 14:22:10 +0200 Subject: [PATCH 253/503] JAVA-617 Rename core-java-datetime-java8 to core-java-8-datetime --- .../README.md | 0 .../pom.xml | 8 ++++---- .../java/com/baeldung/localdate/LocalDateExample.java | 0 .../java/com/baeldung/random/LegacyRandomDateTimes.java | 0 .../main/java/com/baeldung/random/RandomDateTimes.java | 0 .../src/main/java/com/baeldung/random/RandomDates.java | 0 .../src/main/java/com/baeldung/random/RandomTimes.java | 0 .../com/baeldung/localdate/LocalDateExampleUnitTest.java | 0 .../baeldung/random/LegacyRandomDateTimesUnitTest.java | 0 .../java/com/baeldung/random/RandomDateTimesUnitTest.java | 0 .../java/com/baeldung/random/RandomDatesUnitTest.java | 0 .../java/com/baeldung/random/RandomTimesUnitTest.java | 0 .../README.md | 0 .../pom.xml | 8 ++++---- .../baeldung/date/comparison/DateTimeComparisonUtils.java | 0 .../date/comparison/LegacyDateComparisonUtils.java | 0 .../java/com/baeldung/datetime/UseDateTimeFormatter.java | 0 .../src/main/java/com/baeldung/datetime/UseDuration.java | 0 .../src/main/java/com/baeldung/datetime/UseLocalDate.java | 0 .../main/java/com/baeldung/datetime/UseLocalDateTime.java | 0 .../src/main/java/com/baeldung/datetime/UseLocalTime.java | 0 .../java/com/baeldung/datetime/UseOffsetDateTime.java | 0 .../src/main/java/com/baeldung/datetime/UsePeriod.java | 0 .../src/main/java/com/baeldung/datetime/UseToInstant.java | 0 .../main/java/com/baeldung/datetime/UseZonedDateTime.java | 0 .../baeldung/temporaladjuster/CustomTemporalAdjuster.java | 0 .../date/comparison/DateTimeComparisonUtilsUnitTest.java | 0 .../Java8DateTimeApiGeneralComparisonsUnitTest.java | 0 .../comparison/LegacyDateComparisonUtilsUnitTest.java | 0 .../test/java/com/baeldung/dateapi/ConversionExample.java | 0 .../java/com/baeldung/dateapi/JavaDurationUnitTest.java | 0 .../java/com/baeldung/dateapi/JavaPeriodUnitTest.java | 0 .../java/com/baeldung/dateapi/JavaUtilTimeUnitTest.java | 0 .../baeldung/datetime/UseDateTimeFormatterUnitTest.java | 0 .../com/baeldung/datetime/UseLocalDateTimeUnitTest.java | 0 .../java/com/baeldung/datetime/UseLocalDateUnitTest.java | 0 .../java/com/baeldung/datetime/UseLocalTimeUnitTest.java | 0 .../com/baeldung/datetime/UseOffsetDateTimeUnitTest.java | 0 .../java/com/baeldung/datetime/UsePeriodUnitTest.java | 0 .../java/com/baeldung/datetime/UseTimeZoneUnitTest.java | 0 .../java/com/baeldung/datetime/UseToInstantUnitTest.java | 0 .../com/baeldung/datetime/UseZonedDateTimeUnitTest.java | 0 .../temporaladjusters/CustomTemporalAdjusterUnitTest.java | 0 .../temporaladjusters/TemporalAdjustersUnitTest.java | 0 44 files changed, 8 insertions(+), 8 deletions(-) rename core-java-modules/{core-java-datetime-java8-2 => core-java-8-datetime-2}/README.md (100%) rename core-java-modules/{core-java-datetime-java8-2 => core-java-8-datetime-2}/pom.xml (91%) rename core-java-modules/{core-java-datetime-java8-2 => core-java-8-datetime-2}/src/main/java/com/baeldung/localdate/LocalDateExample.java (100%) rename core-java-modules/{core-java-datetime-java8-2 => core-java-8-datetime-2}/src/main/java/com/baeldung/random/LegacyRandomDateTimes.java (100%) rename core-java-modules/{core-java-datetime-java8-2 => core-java-8-datetime-2}/src/main/java/com/baeldung/random/RandomDateTimes.java (100%) rename core-java-modules/{core-java-datetime-java8-2 => core-java-8-datetime-2}/src/main/java/com/baeldung/random/RandomDates.java (100%) rename core-java-modules/{core-java-datetime-java8-2 => core-java-8-datetime-2}/src/main/java/com/baeldung/random/RandomTimes.java (100%) rename core-java-modules/{core-java-datetime-java8-2 => core-java-8-datetime-2}/src/test/java/com/baeldung/localdate/LocalDateExampleUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8-2 => core-java-8-datetime-2}/src/test/java/com/baeldung/random/LegacyRandomDateTimesUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8-2 => core-java-8-datetime-2}/src/test/java/com/baeldung/random/RandomDateTimesUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8-2 => core-java-8-datetime-2}/src/test/java/com/baeldung/random/RandomDatesUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8-2 => core-java-8-datetime-2}/src/test/java/com/baeldung/random/RandomTimesUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/README.md (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/pom.xml (91%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/main/java/com/baeldung/date/comparison/DateTimeComparisonUtils.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/main/java/com/baeldung/date/comparison/LegacyDateComparisonUtils.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/main/java/com/baeldung/datetime/UseDateTimeFormatter.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/main/java/com/baeldung/datetime/UseDuration.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/main/java/com/baeldung/datetime/UseLocalDate.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/main/java/com/baeldung/datetime/UseLocalDateTime.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/main/java/com/baeldung/datetime/UseLocalTime.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/main/java/com/baeldung/datetime/UseOffsetDateTime.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/main/java/com/baeldung/datetime/UsePeriod.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/main/java/com/baeldung/datetime/UseToInstant.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/main/java/com/baeldung/datetime/UseZonedDateTime.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/main/java/com/baeldung/temporaladjuster/CustomTemporalAdjuster.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/date/comparison/DateTimeComparisonUtilsUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/date/comparison/Java8DateTimeApiGeneralComparisonsUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/date/comparison/LegacyDateComparisonUtilsUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/dateapi/ConversionExample.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/dateapi/JavaDurationUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/dateapi/JavaPeriodUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/dateapi/JavaUtilTimeUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/datetime/UseDateTimeFormatterUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/datetime/UseLocalDateTimeUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/datetime/UseLocalDateUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/datetime/UseLocalTimeUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/datetime/UseOffsetDateTimeUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/datetime/UsePeriodUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/datetime/UseTimeZoneUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/datetime/UseToInstantUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/datetime/UseZonedDateTimeUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/temporaladjusters/CustomTemporalAdjusterUnitTest.java (100%) rename core-java-modules/{core-java-datetime-java8 => core-java-8-datetime}/src/test/java/com/baeldung/temporaladjusters/TemporalAdjustersUnitTest.java (100%) diff --git a/core-java-modules/core-java-datetime-java8-2/README.md b/core-java-modules/core-java-8-datetime-2/README.md similarity index 100% rename from core-java-modules/core-java-datetime-java8-2/README.md rename to core-java-modules/core-java-8-datetime-2/README.md diff --git a/core-java-modules/core-java-datetime-java8-2/pom.xml b/core-java-modules/core-java-8-datetime-2/pom.xml similarity index 91% rename from core-java-modules/core-java-datetime-java8-2/pom.xml rename to core-java-modules/core-java-8-datetime-2/pom.xml index a15113bddc..ce98b72781 100644 --- a/core-java-modules/core-java-datetime-java8-2/pom.xml +++ b/core-java-modules/core-java-8-datetime-2/pom.xml @@ -4,9 +4,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - core-java-datetime-java8 + core-java-8-datetime ${project.parent.version} - core-java-datetime-java8 + core-java-8-datetime jar @@ -64,8 +64,8 @@ - 1.9 - 1.9 + 1.8 + 1.8 2.10 3.6.1 diff --git a/core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/localdate/LocalDateExample.java b/core-java-modules/core-java-8-datetime-2/src/main/java/com/baeldung/localdate/LocalDateExample.java similarity index 100% rename from core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/localdate/LocalDateExample.java rename to core-java-modules/core-java-8-datetime-2/src/main/java/com/baeldung/localdate/LocalDateExample.java diff --git a/core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/random/LegacyRandomDateTimes.java b/core-java-modules/core-java-8-datetime-2/src/main/java/com/baeldung/random/LegacyRandomDateTimes.java similarity index 100% rename from core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/random/LegacyRandomDateTimes.java rename to core-java-modules/core-java-8-datetime-2/src/main/java/com/baeldung/random/LegacyRandomDateTimes.java diff --git a/core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/random/RandomDateTimes.java b/core-java-modules/core-java-8-datetime-2/src/main/java/com/baeldung/random/RandomDateTimes.java similarity index 100% rename from core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/random/RandomDateTimes.java rename to core-java-modules/core-java-8-datetime-2/src/main/java/com/baeldung/random/RandomDateTimes.java diff --git a/core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/random/RandomDates.java b/core-java-modules/core-java-8-datetime-2/src/main/java/com/baeldung/random/RandomDates.java similarity index 100% rename from core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/random/RandomDates.java rename to core-java-modules/core-java-8-datetime-2/src/main/java/com/baeldung/random/RandomDates.java diff --git a/core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/random/RandomTimes.java b/core-java-modules/core-java-8-datetime-2/src/main/java/com/baeldung/random/RandomTimes.java similarity index 100% rename from core-java-modules/core-java-datetime-java8-2/src/main/java/com/baeldung/random/RandomTimes.java rename to core-java-modules/core-java-8-datetime-2/src/main/java/com/baeldung/random/RandomTimes.java diff --git a/core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/localdate/LocalDateExampleUnitTest.java b/core-java-modules/core-java-8-datetime-2/src/test/java/com/baeldung/localdate/LocalDateExampleUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/localdate/LocalDateExampleUnitTest.java rename to core-java-modules/core-java-8-datetime-2/src/test/java/com/baeldung/localdate/LocalDateExampleUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/random/LegacyRandomDateTimesUnitTest.java b/core-java-modules/core-java-8-datetime-2/src/test/java/com/baeldung/random/LegacyRandomDateTimesUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/random/LegacyRandomDateTimesUnitTest.java rename to core-java-modules/core-java-8-datetime-2/src/test/java/com/baeldung/random/LegacyRandomDateTimesUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/random/RandomDateTimesUnitTest.java b/core-java-modules/core-java-8-datetime-2/src/test/java/com/baeldung/random/RandomDateTimesUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/random/RandomDateTimesUnitTest.java rename to core-java-modules/core-java-8-datetime-2/src/test/java/com/baeldung/random/RandomDateTimesUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/random/RandomDatesUnitTest.java b/core-java-modules/core-java-8-datetime-2/src/test/java/com/baeldung/random/RandomDatesUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/random/RandomDatesUnitTest.java rename to core-java-modules/core-java-8-datetime-2/src/test/java/com/baeldung/random/RandomDatesUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/random/RandomTimesUnitTest.java b/core-java-modules/core-java-8-datetime-2/src/test/java/com/baeldung/random/RandomTimesUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8-2/src/test/java/com/baeldung/random/RandomTimesUnitTest.java rename to core-java-modules/core-java-8-datetime-2/src/test/java/com/baeldung/random/RandomTimesUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/README.md b/core-java-modules/core-java-8-datetime/README.md similarity index 100% rename from core-java-modules/core-java-datetime-java8/README.md rename to core-java-modules/core-java-8-datetime/README.md diff --git a/core-java-modules/core-java-datetime-java8/pom.xml b/core-java-modules/core-java-8-datetime/pom.xml similarity index 91% rename from core-java-modules/core-java-datetime-java8/pom.xml rename to core-java-modules/core-java-8-datetime/pom.xml index a15113bddc..ce98b72781 100644 --- a/core-java-modules/core-java-datetime-java8/pom.xml +++ b/core-java-modules/core-java-8-datetime/pom.xml @@ -4,9 +4,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - core-java-datetime-java8 + core-java-8-datetime ${project.parent.version} - core-java-datetime-java8 + core-java-8-datetime jar @@ -64,8 +64,8 @@ - 1.9 - 1.9 + 1.8 + 1.8 2.10 3.6.1 diff --git a/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/date/comparison/DateTimeComparisonUtils.java b/core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/date/comparison/DateTimeComparisonUtils.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/date/comparison/DateTimeComparisonUtils.java rename to core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/date/comparison/DateTimeComparisonUtils.java diff --git a/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/date/comparison/LegacyDateComparisonUtils.java b/core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/date/comparison/LegacyDateComparisonUtils.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/date/comparison/LegacyDateComparisonUtils.java rename to core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/date/comparison/LegacyDateComparisonUtils.java diff --git a/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseDateTimeFormatter.java b/core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UseDateTimeFormatter.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseDateTimeFormatter.java rename to core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UseDateTimeFormatter.java diff --git a/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseDuration.java b/core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UseDuration.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseDuration.java rename to core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UseDuration.java diff --git a/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseLocalDate.java b/core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UseLocalDate.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseLocalDate.java rename to core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UseLocalDate.java diff --git a/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseLocalDateTime.java b/core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UseLocalDateTime.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseLocalDateTime.java rename to core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UseLocalDateTime.java diff --git a/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseLocalTime.java b/core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UseLocalTime.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseLocalTime.java rename to core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UseLocalTime.java diff --git a/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseOffsetDateTime.java b/core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UseOffsetDateTime.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseOffsetDateTime.java rename to core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UseOffsetDateTime.java diff --git a/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UsePeriod.java b/core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UsePeriod.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UsePeriod.java rename to core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UsePeriod.java diff --git a/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseToInstant.java b/core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UseToInstant.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseToInstant.java rename to core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UseToInstant.java diff --git a/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseZonedDateTime.java b/core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UseZonedDateTime.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/datetime/UseZonedDateTime.java rename to core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/datetime/UseZonedDateTime.java diff --git a/core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/temporaladjuster/CustomTemporalAdjuster.java b/core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/temporaladjuster/CustomTemporalAdjuster.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/main/java/com/baeldung/temporaladjuster/CustomTemporalAdjuster.java rename to core-java-modules/core-java-8-datetime/src/main/java/com/baeldung/temporaladjuster/CustomTemporalAdjuster.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/date/comparison/DateTimeComparisonUtilsUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/date/comparison/DateTimeComparisonUtilsUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/date/comparison/DateTimeComparisonUtilsUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/date/comparison/DateTimeComparisonUtilsUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/date/comparison/Java8DateTimeApiGeneralComparisonsUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/date/comparison/Java8DateTimeApiGeneralComparisonsUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/date/comparison/Java8DateTimeApiGeneralComparisonsUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/date/comparison/Java8DateTimeApiGeneralComparisonsUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/date/comparison/LegacyDateComparisonUtilsUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/date/comparison/LegacyDateComparisonUtilsUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/date/comparison/LegacyDateComparisonUtilsUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/date/comparison/LegacyDateComparisonUtilsUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/dateapi/ConversionExample.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/dateapi/ConversionExample.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/dateapi/ConversionExample.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/dateapi/ConversionExample.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/dateapi/JavaDurationUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/dateapi/JavaDurationUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/dateapi/JavaDurationUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/dateapi/JavaDurationUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/dateapi/JavaPeriodUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/dateapi/JavaPeriodUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/dateapi/JavaPeriodUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/dateapi/JavaPeriodUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/dateapi/JavaUtilTimeUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/dateapi/JavaUtilTimeUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/dateapi/JavaUtilTimeUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/dateapi/JavaUtilTimeUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseDateTimeFormatterUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UseDateTimeFormatterUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseDateTimeFormatterUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UseDateTimeFormatterUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseLocalDateTimeUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UseLocalDateTimeUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseLocalDateTimeUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UseLocalDateTimeUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseLocalDateUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UseLocalDateUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseLocalDateUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UseLocalDateUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseLocalTimeUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UseLocalTimeUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseLocalTimeUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UseLocalTimeUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseOffsetDateTimeUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UseOffsetDateTimeUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseOffsetDateTimeUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UseOffsetDateTimeUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UsePeriodUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UsePeriodUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UsePeriodUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UsePeriodUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseTimeZoneUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UseTimeZoneUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseTimeZoneUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UseTimeZoneUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseToInstantUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UseToInstantUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseToInstantUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UseToInstantUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseZonedDateTimeUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UseZonedDateTimeUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/datetime/UseZonedDateTimeUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/datetime/UseZonedDateTimeUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/temporaladjusters/CustomTemporalAdjusterUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/temporaladjusters/CustomTemporalAdjusterUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/temporaladjusters/CustomTemporalAdjusterUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/temporaladjusters/CustomTemporalAdjusterUnitTest.java diff --git a/core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/temporaladjusters/TemporalAdjustersUnitTest.java b/core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/temporaladjusters/TemporalAdjustersUnitTest.java similarity index 100% rename from core-java-modules/core-java-datetime-java8/src/test/java/com/baeldung/temporaladjusters/TemporalAdjustersUnitTest.java rename to core-java-modules/core-java-8-datetime/src/test/java/com/baeldung/temporaladjusters/TemporalAdjustersUnitTest.java From 47595b7ccc555d5eee4b18fb192e4b4e9e1e3bcc Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 18 Apr 2020 19:11:47 +0530 Subject: [PATCH 254/503] JAVA-914: Removed empty pom files --- cas/cas-server/pom.xml | 0 cas/pom.xml | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 cas/cas-server/pom.xml delete mode 100644 cas/pom.xml diff --git a/cas/cas-server/pom.xml b/cas/cas-server/pom.xml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/cas/pom.xml b/cas/pom.xml deleted file mode 100644 index e69de29bb2..0000000000 From 576bf0290361f26d7df8ea78d394239e8ff80c72 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 18 Apr 2020 19:12:36 +0530 Subject: [PATCH 255/503] JAVA-914: Updated module README to include relevant info --- cas/README.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/cas/README.md b/cas/README.md index 16775a8a02..6ceeaea0c4 100644 --- a/cas/README.md +++ b/cas/README.md @@ -1,7 +1,18 @@ ## CAS -This module contains articles about the Central Authentication Service (CAS) +This module contains articles about the Central Authentication Service (CAS). + +The module consists of 2 submodules: +1. `cas-server` - it requires JDK11 and uses the Gradle War Overlay style to ease setup and deployment. To start the server, simply run: + +`./gradlew run + -Dorg.gradle.java.home=$JAVA11_HOME + -Pargs="-Dcas.standalone.configurationDirectory=/cas-server/src/main/resources/etc/cas/config"` + +The server starts at https://localhost:8443. `casuser`/`Mellon` are the username and password for logging in. + +2. `cas-secured-app` - A Maven based Springboot Application ### Relevant Articles: -- [CAS SSO With Spring Security](baeldung.com/spring-security-cas-sso) \ No newline at end of file +- [CAS SSO With Spring Security](https://www.baeldung.com/spring-security-cas-sso) \ No newline at end of file From e82bdc46d4c931cb14b03e8f69d433990d9df640 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 18 Apr 2020 19:13:22 +0530 Subject: [PATCH 256/503] JAVA-914: Updated main pom to include cas as commented module --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 9e3b354d74..394a566011 100644 --- a/pom.xml +++ b/pom.xml @@ -387,7 +387,7 @@ bazel blade bootique - + cdi checker-plugin @@ -900,7 +900,7 @@ bazel blade bootique - + cdi checker-plugin From 55c978c44aeac47437b28fe6850a695df9b8f5a6 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 18 Apr 2020 19:17:28 +0530 Subject: [PATCH 257/503] Revert "JAVA-916: Migrate jhipster to parent-boot-2" This reverts commit c72b6ce0114d63180adfaa8f2b056032b5bd8144. --- hystrix/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hystrix/pom.xml b/hystrix/pom.xml index 1cf8713b91..8c505c9104 100644 --- a/hystrix/pom.xml +++ b/hystrix/pom.xml @@ -8,9 +8,9 @@ com.baeldung - parent-boot-2 + parent-boot-1 0.0.1-SNAPSHOT - ../parent-boot-2 + ../parent-boot-1 From d3f01d251cf8d9d1a8577ec32f367a24f7fa59f7 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Sat, 18 Apr 2020 16:51:27 +0200 Subject: [PATCH 258/503] BAEL-3992: Enable jws in the main pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 9e3b354d74..3f16c4ddd0 100644 --- a/pom.xml +++ b/pom.xml @@ -806,7 +806,7 @@ jenkins/plugins jhipster - + jws libraries @@ -1303,7 +1303,7 @@ jenkins/plugins jhipster - + jws libraries From 95967877e946125d6ca13fd6df3f1a1f46240b8d Mon Sep 17 00:00:00 2001 From: Ankur Gupta Date: Sat, 18 Apr 2020 20:41:31 +0530 Subject: [PATCH 259/503] ankurguptajec@gmail.com (#9064) * Java Example of Hexagonal Architecture * removing unnecessary maven files from pull request and spaces in code * Removing unnecessary lines * Example code for using Multiple Cache Manager in SpringBoot * BAEL-3963:Using multiple cache managers in Spring * removing new module created in last pull request * Fixes as per editor Suggestions Co-authored-by: Ankur Gupta --- spring-caching/pom.xml | 106 ++++++++++-------- .../caching/boot/CacheApplication.java | 4 + .../bo/CustomerDetailBO.java | 28 +++++ .../bo/OrderDetailBO.java | 25 +++++ .../config/MultipleCacheManagerConfig.java | 40 +++++++ .../config/MultipleCacheResolver.java | 38 +++++++ .../MultipleCacheManagerController.java | 43 +++++++ .../multiplecachemanager/entity/Customer.java | 24 ++++ .../multiplecachemanager/entity/Item.java | 34 ++++++ .../multiplecachemanager/entity/Order.java | 44 ++++++++ .../repository/CustomerDetailRepository.java | 49 ++++++++ .../repository/OrderDetailRepository.java | 53 +++++++++ .../src/main/resources/application.properties | 8 ++ spring-caching/src/main/resources/data.sql | 7 ++ spring-caching/src/main/resources/schema.sql | 19 ++++ ...ltipleCacheManagerIntegrationUnitTest.java | 64 +++++++++++ 16 files changed, 542 insertions(+), 44 deletions(-) create mode 100644 spring-caching/src/main/java/com/baeldung/multiplecachemanager/bo/CustomerDetailBO.java create mode 100644 spring-caching/src/main/java/com/baeldung/multiplecachemanager/bo/OrderDetailBO.java create mode 100644 spring-caching/src/main/java/com/baeldung/multiplecachemanager/config/MultipleCacheManagerConfig.java create mode 100644 spring-caching/src/main/java/com/baeldung/multiplecachemanager/config/MultipleCacheResolver.java create mode 100644 spring-caching/src/main/java/com/baeldung/multiplecachemanager/controller/MultipleCacheManagerController.java create mode 100644 spring-caching/src/main/java/com/baeldung/multiplecachemanager/entity/Customer.java create mode 100644 spring-caching/src/main/java/com/baeldung/multiplecachemanager/entity/Item.java create mode 100644 spring-caching/src/main/java/com/baeldung/multiplecachemanager/entity/Order.java create mode 100644 spring-caching/src/main/java/com/baeldung/multiplecachemanager/repository/CustomerDetailRepository.java create mode 100644 spring-caching/src/main/java/com/baeldung/multiplecachemanager/repository/OrderDetailRepository.java create mode 100644 spring-caching/src/main/resources/application.properties create mode 100644 spring-caching/src/main/resources/data.sql create mode 100644 spring-caching/src/main/resources/schema.sql create mode 100644 spring-caching/src/test/java/com/baeldung/multiplecachemanager/MultipleCacheManagerIntegrationUnitTest.java diff --git a/spring-caching/pom.xml b/spring-caching/pom.xml index d33f24de1f..f56d3cf328 100644 --- a/spring-caching/pom.xml +++ b/spring-caching/pom.xml @@ -1,49 +1,67 @@ - - 4.0.0 - spring-caching - 0.1-SNAPSHOT - spring-caching - war + + 4.0.0 + spring-caching + 0.1-SNAPSHOT + spring-caching + war - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../parent-boot-2 - + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../parent-boot-2 + - - - org.springframework - spring-context - - - org.springframework.boot - spring-boot-starter-cache - - - org.springframework - spring-web - - - org.springframework - spring-webmvc - - - org.ehcache - ehcache - - - org.springframework - spring-test - test - - + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework + spring-context + + + org.springframework.boot + spring-boot-starter-cache + + + org.springframework + spring-web + + + org.springframework + spring-webmvc + + + org.ehcache + ehcache + + + org.springframework + spring-test + test + + + com.github.ben-manes.caffeine + caffeine + + + com.h2database + h2 + runtime + + + org.springframework.boot + spring-boot-starter-jdbc + + + + + 3.5.2 + - - 3.5.2 - - \ No newline at end of file diff --git a/spring-caching/src/main/java/com/baeldung/caching/boot/CacheApplication.java b/spring-caching/src/main/java/com/baeldung/caching/boot/CacheApplication.java index 714dc443e0..afa1d0ec99 100644 --- a/spring-caching/src/main/java/com/baeldung/caching/boot/CacheApplication.java +++ b/spring-caching/src/main/java/com/baeldung/caching/boot/CacheApplication.java @@ -3,9 +3,13 @@ package com.baeldung.caching.boot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cache.annotation.EnableCaching; +//import org.springframework.context.annotation.ComponentScan; @SpringBootApplication @EnableCaching +//to run any module like ehcache,caching or multiplecachemanager in local machine +//add it's package for ComponentScan like below +//@ComponentScan("com.baeldung.multiplecachemanager") public class CacheApplication { public static void main(String[] args) { diff --git a/spring-caching/src/main/java/com/baeldung/multiplecachemanager/bo/CustomerDetailBO.java b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/bo/CustomerDetailBO.java new file mode 100644 index 0000000000..3da4c23e28 --- /dev/null +++ b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/bo/CustomerDetailBO.java @@ -0,0 +1,28 @@ +package com.baeldung.multiplecachemanager.bo; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Component; + +import com.baeldung.multiplecachemanager.entity.Customer; +import com.baeldung.multiplecachemanager.entity.Order; +import com.baeldung.multiplecachemanager.repository.CustomerDetailRepository; + +@Component +public class CustomerDetailBO { + + @Autowired + private CustomerDetailRepository customerDetailRepository; + + @Cacheable(cacheNames = "customers") + public Customer getCustomerDetail(Integer customerId) { + return customerDetailRepository.getCustomerDetail(customerId); + } + + @Cacheable(cacheNames = "customerOrders", cacheManager = "alternateCacheManager") + public List getCustomerOrders(Integer customerId) { + return customerDetailRepository.getCustomerOrders(customerId); + } +} diff --git a/spring-caching/src/main/java/com/baeldung/multiplecachemanager/bo/OrderDetailBO.java b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/bo/OrderDetailBO.java new file mode 100644 index 0000000000..390881167f --- /dev/null +++ b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/bo/OrderDetailBO.java @@ -0,0 +1,25 @@ +package com.baeldung.multiplecachemanager.bo; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Component; + +import com.baeldung.multiplecachemanager.entity.Order; +import com.baeldung.multiplecachemanager.repository.OrderDetailRepository; + +@Component +public class OrderDetailBO { + + @Autowired + private OrderDetailRepository orderDetailRepository; + + @Cacheable(cacheNames = "orders", cacheResolver = "cacheResolver") + public Order getOrderDetail(Integer orderId) { + return orderDetailRepository.getOrderDetail(orderId); + } + + @Cacheable(cacheNames = "orderprice", cacheResolver = "cacheResolver") + public double getOrderPrice(Integer orderId) { + return orderDetailRepository.getOrderPrice(orderId); + } +} diff --git a/spring-caching/src/main/java/com/baeldung/multiplecachemanager/config/MultipleCacheManagerConfig.java b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/config/MultipleCacheManagerConfig.java new file mode 100644 index 0000000000..247a9b596b --- /dev/null +++ b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/config/MultipleCacheManagerConfig.java @@ -0,0 +1,40 @@ +package com.baeldung.multiplecachemanager.config; + +import org.springframework.cache.CacheManager; +import org.springframework.cache.annotation.CachingConfigurerSupport; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.cache.caffeine.CaffeineCacheManager; +import org.springframework.cache.concurrent.ConcurrentMapCacheManager; +import org.springframework.cache.interceptor.CacheResolver; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +//import org.springframework.context.annotation.Primary; + +import com.github.benmanes.caffeine.cache.Caffeine; + +@Configuration +@EnableCaching +public class MultipleCacheManagerConfig extends CachingConfigurerSupport { + + @Bean + //@Primary + public CacheManager cacheManager() { + CaffeineCacheManager cacheManager = new CaffeineCacheManager("customers", "orders"); + cacheManager.setCaffeine(Caffeine.newBuilder() + .initialCapacity(200) + .maximumSize(500) + .weakKeys() + .recordStats()); + return cacheManager; + } + + @Bean + public CacheManager alternateCacheManager() { + return new ConcurrentMapCacheManager("customerOrders", "orderprice"); + } + + @Bean + public CacheResolver cacheResolver() { + return new MultipleCacheResolver(alternateCacheManager(), cacheManager()); + } +} diff --git a/spring-caching/src/main/java/com/baeldung/multiplecachemanager/config/MultipleCacheResolver.java b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/config/MultipleCacheResolver.java new file mode 100644 index 0000000000..1bd869d98e --- /dev/null +++ b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/config/MultipleCacheResolver.java @@ -0,0 +1,38 @@ +package com.baeldung.multiplecachemanager.config; + +import java.util.ArrayList; +import java.util.Collection; + +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.cache.interceptor.CacheOperationInvocationContext; +import org.springframework.cache.interceptor.CacheResolver; + +public class MultipleCacheResolver implements CacheResolver { + + private final CacheManager simpleCacheManager; + + private final CacheManager caffeineCacheManager; + + private static final String ORDER_CACHE = "orders"; + + private static final String ORDER_PRICE_CACHE = "orderprice"; + + public MultipleCacheResolver(CacheManager simpleCacheManager, CacheManager caffeineCacheManager) { + this.simpleCacheManager = simpleCacheManager; + this.caffeineCacheManager = caffeineCacheManager; + + } + + @Override + public Collection resolveCaches(CacheOperationInvocationContext context) { + Collection caches = new ArrayList(); + if ("getOrderDetail".equals(context.getMethod() + .getName())) { + caches.add(caffeineCacheManager.getCache(ORDER_CACHE)); + } else { + caches.add(simpleCacheManager.getCache(ORDER_PRICE_CACHE)); + } + return caches; + } +} diff --git a/spring-caching/src/main/java/com/baeldung/multiplecachemanager/controller/MultipleCacheManagerController.java b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/controller/MultipleCacheManagerController.java new file mode 100644 index 0000000000..17a73bb27a --- /dev/null +++ b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/controller/MultipleCacheManagerController.java @@ -0,0 +1,43 @@ +package com.baeldung.multiplecachemanager.controller; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.multiplecachemanager.bo.CustomerDetailBO; +import com.baeldung.multiplecachemanager.bo.OrderDetailBO; +import com.baeldung.multiplecachemanager.entity.Customer; +import com.baeldung.multiplecachemanager.entity.Order; + +@RestController +public class MultipleCacheManagerController { + + @Autowired + private CustomerDetailBO customerDetailBO; + + @Autowired + private OrderDetailBO orderDetailBO; + + @GetMapping(value = "/getCustomer/{customerid}") + public Customer getCustomer(@PathVariable Integer customerid) { + return customerDetailBO.getCustomerDetail(customerid); + } + + @GetMapping(value = "/getCustomerOrders/{customerid}") + public List getCustomerOrders(@PathVariable Integer customerid) { + return customerDetailBO.getCustomerOrders(customerid); + } + + @GetMapping(value = "/getOrder/{orderid}") + public Order getOrder(@PathVariable Integer orderid) { + return orderDetailBO.getOrderDetail(orderid); + } + + @GetMapping(value = "/getOrderPrice/{orderid}") + public double getOrderPrice(@PathVariable Integer orderid) { + return orderDetailBO.getOrderPrice(orderid); + } +} diff --git a/spring-caching/src/main/java/com/baeldung/multiplecachemanager/entity/Customer.java b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/entity/Customer.java new file mode 100644 index 0000000000..cfae15f4e9 --- /dev/null +++ b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/entity/Customer.java @@ -0,0 +1,24 @@ +package com.baeldung.multiplecachemanager.entity; + +public class Customer { + + private int customerId; + + private String customerName; + + public int getCustomerId() { + return customerId; + } + + public void setCustomerId(int customerId) { + this.customerId = customerId; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } +} diff --git a/spring-caching/src/main/java/com/baeldung/multiplecachemanager/entity/Item.java b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/entity/Item.java new file mode 100644 index 0000000000..4131464981 --- /dev/null +++ b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/entity/Item.java @@ -0,0 +1,34 @@ +package com.baeldung.multiplecachemanager.entity; + +public class Item { + + private int itemId; + + private String itemDesc; + + private double itemPrice; + + public int getItemId() { + return itemId; + } + + public void setItemId(int itemId) { + this.itemId = itemId; + } + + public String getItemDesc() { + return itemDesc; + } + + public void setItemDesc(String itemDesc) { + this.itemDesc = itemDesc; + } + + public double getItemPrice() { + return itemPrice; + } + + public void setItemPrice(double itemPrice) { + this.itemPrice = itemPrice; + } +} diff --git a/spring-caching/src/main/java/com/baeldung/multiplecachemanager/entity/Order.java b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/entity/Order.java new file mode 100644 index 0000000000..15da60d6ea --- /dev/null +++ b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/entity/Order.java @@ -0,0 +1,44 @@ +package com.baeldung.multiplecachemanager.entity; + +public class Order { + + private int orderId; + + private int itemId; + + private int quantity; + + private int customerId; + + public int getOrderId() { + return orderId; + } + + public void setOrderId(int orderId) { + this.orderId = orderId; + } + + public int getItemId() { + return itemId; + } + + public void setItemId(int itemId) { + this.itemId = itemId; + } + + public int getQuantity() { + return quantity; + } + + public void setQuantity(int quantity) { + this.quantity = quantity; + } + + public int getCustomerId() { + return customerId; + } + + public void setCustomerId(int customerId) { + this.customerId = customerId; + } +} diff --git a/spring-caching/src/main/java/com/baeldung/multiplecachemanager/repository/CustomerDetailRepository.java b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/repository/CustomerDetailRepository.java new file mode 100644 index 0000000000..aab011427d --- /dev/null +++ b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/repository/CustomerDetailRepository.java @@ -0,0 +1,49 @@ +package com.baeldung.multiplecachemanager.repository; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowCallbackHandler; +import org.springframework.stereotype.Repository; + +import com.baeldung.multiplecachemanager.entity.Customer; +import com.baeldung.multiplecachemanager.entity.Order; + +@Repository +public class CustomerDetailRepository { + + @Autowired + private JdbcTemplate jdbcTemplate; + + public Customer getCustomerDetail(Integer customerId) { + String customerQuery = "select * from customer where customerid = ? "; + Customer customer = new Customer(); + jdbcTemplate.query(customerQuery, new Object[] { customerId }, new RowCallbackHandler() { + public void processRow(ResultSet rs) throws SQLException { + customer.setCustomerId(rs.getInt("customerid")); + customer.setCustomerName(rs.getString("customername")); + } + }); + return customer; + } + + public List getCustomerOrders(Integer customerId) { + String customerOrderQuery = "select * from orderdetail where customerid = ? "; + List orders = new ArrayList(); + jdbcTemplate.query(customerOrderQuery, new Object[] { customerId }, new RowCallbackHandler() { + public void processRow(ResultSet rs) throws SQLException { + Order order = new Order(); + order.setCustomerId(rs.getInt("customerid")); + order.setItemId(rs.getInt("orderid")); + order.setOrderId(rs.getInt("orderid")); + order.setQuantity(rs.getInt("quantity")); + orders.add(order); + } + }); + return orders; + } +} diff --git a/spring-caching/src/main/java/com/baeldung/multiplecachemanager/repository/OrderDetailRepository.java b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/repository/OrderDetailRepository.java new file mode 100644 index 0000000000..58c0968e48 --- /dev/null +++ b/spring-caching/src/main/java/com/baeldung/multiplecachemanager/repository/OrderDetailRepository.java @@ -0,0 +1,53 @@ +package com.baeldung.multiplecachemanager.repository; + +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.RowCallbackHandler; +import org.springframework.stereotype.Repository; + +import com.baeldung.multiplecachemanager.entity.Item; +import com.baeldung.multiplecachemanager.entity.Order; + +@Repository +public class OrderDetailRepository { + + @Autowired + private JdbcTemplate jdbcTemplate; + + public Order getOrderDetail(Integer orderId) { + String orderDetailQuery = "select * from orderdetail where orderid = ? "; + Order order = new Order(); + jdbcTemplate.query(orderDetailQuery, new Object[] { orderId }, new RowCallbackHandler() { + public void processRow(ResultSet rs) throws SQLException { + order.setCustomerId(rs.getInt("customerid")); + order.setOrderId(rs.getInt("orderid")); + order.setItemId(rs.getInt("itemid")); + order.setQuantity(rs.getInt("quantity")); + } + }); + return order; + } + + public double getOrderPrice(Integer orderId) { + + String orderItemJoinQuery = "select * from ( select * from orderdetail where orderid = ? ) o left join item on o.itemid = ITEM.itemid"; + Order order = new Order(); + Item item = new Item(); + + jdbcTemplate.query(orderItemJoinQuery, new Object[] { orderId }, new RowCallbackHandler() { + public void processRow(ResultSet rs) throws SQLException { + order.setCustomerId(rs.getInt("customerid")); + order.setOrderId(rs.getInt("orderid")); + order.setItemId(rs.getInt("itemid")); + order.setQuantity(rs.getInt("quantity")); + item.setItemDesc("itemdesc"); + item.setItemId(rs.getInt("itemid")); + item.setItemPrice(rs.getDouble("price")); + } + }); + return order.getQuantity() * item.getItemPrice(); + } +} diff --git a/spring-caching/src/main/resources/application.properties b/spring-caching/src/main/resources/application.properties new file mode 100644 index 0000000000..ee7b5e62c0 --- /dev/null +++ b/spring-caching/src/main/resources/application.properties @@ -0,0 +1,8 @@ +spring.datasource.url=jdbc:h2:mem:testdb +spring.datasource.driverClassName=org.h2.Driver +spring.datasource.username=sa +spring.datasource.password= + +# Enabling H2 Console +spring.h2.console.enabled=true +spring.h2.console.path=/h2 diff --git a/spring-caching/src/main/resources/data.sql b/spring-caching/src/main/resources/data.sql new file mode 100644 index 0000000000..e4165ae71f --- /dev/null +++ b/spring-caching/src/main/resources/data.sql @@ -0,0 +1,7 @@ +INSERT INTO CUSTOMER VALUES(1001,'BAELDUNG'); + +INSERT INTO ITEM VALUES(10001,'ITEM1',50.0); +INSERT INTO ITEM VALUES(10002,'ITEM2',100.0); + +INSERT INTO ORDERDETAIL VALUES(300001,1001,10001,2); +INSERT INTO ORDERDETAIL VALUES(300002,1001,10002,5); \ No newline at end of file diff --git a/spring-caching/src/main/resources/schema.sql b/spring-caching/src/main/resources/schema.sql new file mode 100644 index 0000000000..5862499bc0 --- /dev/null +++ b/spring-caching/src/main/resources/schema.sql @@ -0,0 +1,19 @@ +CREATE TABLE CUSTOMER( + CUSTOMERID INT PRIMARY KEY, + CUSTOMERNAME VARCHAR(250) NOT NULL +); + +CREATE TABLE ITEM( +ITEMID INT PRIMARY KEY, +ITEMDESC VARCHAR(250), +PRICE DOUBLE +); + +CREATE TABLE ORDERDETAIL( +ORDERID INT PRIMARY KEY, +CUSTOMERID INT NOT NULL, +ITEMID INT NOT NULL, +QUANTITY INT, +FOREIGN KEY (customerid) references CUSTOMER(customerid), +FOREIGN KEY (itemid) references ITEM(itemid) +); \ No newline at end of file diff --git a/spring-caching/src/test/java/com/baeldung/multiplecachemanager/MultipleCacheManagerIntegrationUnitTest.java b/spring-caching/src/test/java/com/baeldung/multiplecachemanager/MultipleCacheManagerIntegrationUnitTest.java new file mode 100644 index 0000000000..e02e5da246 --- /dev/null +++ b/spring-caching/src/test/java/com/baeldung/multiplecachemanager/MultipleCacheManagerIntegrationUnitTest.java @@ -0,0 +1,64 @@ +package com.baeldung.multiplecachemanager; + +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.cache.Cache; +import org.springframework.cache.CacheManager; +import org.springframework.cache.caffeine.CaffeineCache; +import org.springframework.util.Assert; + +import com.baeldung.multiplecachemanager.bo.OrderDetailBO; +import com.baeldung.multiplecachemanager.entity.Order; +import com.baeldung.multiplecachemanager.repository.OrderDetailRepository; + +@SpringBootApplication +@SpringBootTest +public class MultipleCacheManagerIntegrationUnitTest { + + @MockBean + private OrderDetailRepository orderDetailRepository; + + @Autowired + private OrderDetailBO orderDetailBO; + + @Autowired + private CacheManager cacheManager; + + @Autowired + private CacheManager alternateCacheManager; + + @Test + public void givenCacheResolverIsConfigured_whenCallGetOrderDetail_thenDataShouldBeInCaffieneCacheManager() { + Integer key = 30001; + cacheManager.getCache("orders") + .evict(key); + Order order = new Order(); + order.setCustomerId(1001); + order.setItemId(10001); + order.setOrderId(30001); + order.setQuantity(2); + Mockito.when(orderDetailRepository.getOrderDetail(key)) + .thenReturn(order); + orderDetailBO.getOrderDetail(key); + org.springframework.cache.caffeine.CaffeineCache cache = (CaffeineCache) cacheManager.getCache("orders"); + Assert.notNull(cache.get(key) + .get(), "caffieneCache should have had the data"); + } + + @Test + public void givenCacheResolverIsConfigured_whenCallGetOrderPrice_thenDataShouldBeInAlternateCacheManager() { + Integer key = 30001; + alternateCacheManager.getCache("orderprice") + .evict(key); + Mockito.when(orderDetailRepository.getOrderPrice(key)) + .thenReturn(500.0); + orderDetailBO.getOrderPrice(key); + Cache cache = alternateCacheManager.getCache("orderprice"); + Assert.notNull(cache.get(key) + .get(), "alternateCache should have had the data"); + } +} From 0f851a1d84ed31d8bf4f047d61f420ab7dfc1382 Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sat, 18 Apr 2020 20:57:13 +0530 Subject: [PATCH 260/503] update source code to sync with article --- .../baeldung/optional/OptionalUnitTest.java | 9 ++++ .../spring-boot-runtime/pom.xml | 4 +- .../com/baeldung/web/log/app/Application.java | 23 +--------- .../log/config/CustomWebAppInitializer.java | 25 ++++++++++ ....java => MyWebApplicationInitializer.java} | 7 +-- ...lesWithMavenPropertiesIntegrationTest.java | 2 +- .../mockito/MockitoAnnotationUnitTest.java | 46 +++++++++++++++++++ 7 files changed, 86 insertions(+), 30 deletions(-) create mode 100644 spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/config/CustomWebAppInitializer.java rename spring-core-2/src/main/java/com/baeldung/spring/config/{MainWebAppInitializer.java => MyWebApplicationInitializer.java} (81%) diff --git a/core-java-modules/core-java-optional/src/test/java/com/baeldung/optional/OptionalUnitTest.java b/core-java-modules/core-java-optional/src/test/java/com/baeldung/optional/OptionalUnitTest.java index e5c4319bf7..de16e9b635 100644 --- a/core-java-modules/core-java-optional/src/test/java/com/baeldung/optional/OptionalUnitTest.java +++ b/core-java-modules/core-java-optional/src/test/java/com/baeldung/optional/OptionalUnitTest.java @@ -86,6 +86,15 @@ public class OptionalUnitTest { Optional opt = Optional.ofNullable(null); String name = opt.get(); } + + @Test + public void givenAnEmptyOptional_thenIsEmptyBehavesAsExpected() { + Optional opt = Optional.of("Baeldung"); + assertTrue(opt.isPresent()); + + opt = Optional.ofNullable(null); + assertFalse(opt.isPresent()); + } // Conditional Return With filter() @Test diff --git a/spring-boot-modules/spring-boot-runtime/pom.xml b/spring-boot-modules/spring-boot-runtime/pom.xml index df45537940..4de604f664 100644 --- a/spring-boot-modules/spring-boot-runtime/pom.xml +++ b/spring-boot-modules/spring-boot-runtime/pom.xml @@ -14,11 +14,11 @@ ../../parent-boot-2 - + diff --git a/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/app/Application.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/app/Application.java index f20fba737a..40f5341e29 100644 --- a/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/app/Application.java +++ b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/app/Application.java @@ -1,43 +1,22 @@ package com.baeldung.web.log.app; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; import javax.servlet.ServletRegistration; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ComponentScan; -import org.springframework.web.context.ContextLoaderListener; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import org.springframework.web.servlet.DispatcherServlet; import org.springframework.context.annotation.PropertySource; import com.baeldung.web.log.config.CustomeRequestLoggingFilter; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; - @EnableAutoConfiguration @ComponentScan("com.baeldung.web.log") @PropertySource("application-log.properties") @SpringBootApplication -public class Application extends SpringBootServletInitializer { +public class Application { public static void main(final String[] args) { SpringApplication.run(Application.class, args); } - - @Override - public void onStartup(ServletContext container) throws ServletException { - - AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); - context.setConfigLocation("com.baeldung.web.log"); - container.addListener(new ContextLoaderListener(context)); - - ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(context)); - dispatcher.setLoadOnStartup(1); - dispatcher.addMapping("/"); - - container.addFilter("customRequestLoggingFilter", CustomeRequestLoggingFilter.class).addMappingForServletNames(null, false, "dispatcher"); - } } \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/config/CustomWebAppInitializer.java b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/config/CustomWebAppInitializer.java new file mode 100644 index 0000000000..f51bb52990 --- /dev/null +++ b/spring-boot-modules/spring-boot-runtime/src/main/java/com/baeldung/web/log/config/CustomWebAppInitializer.java @@ -0,0 +1,25 @@ +package com.baeldung.web.log.config; + +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import org.springframework.web.context.ContextLoaderListener; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import org.springframework.web.servlet.DispatcherServlet; +import org.springframework.web.WebApplicationInitializer; + +public class CustomWebAppInitializer implements WebApplicationInitializer { + + @Override + public void onStartup(ServletContext container) throws ServletException { + + AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); + context.setConfigLocation("com.baeldung.web.log"); + container.addListener(new ContextLoaderListener(context)); + + ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(context)); + dispatcher.setLoadOnStartup(1); + dispatcher.addMapping("/"); + + container.addFilter("customRequestLoggingFilter", CustomeRequestLoggingFilter.class).addMappingForServletNames(null, false, "dispatcher"); + } +} \ No newline at end of file diff --git a/spring-core-2/src/main/java/com/baeldung/spring/config/MainWebAppInitializer.java b/spring-core-2/src/main/java/com/baeldung/spring/config/MyWebApplicationInitializer.java similarity index 81% rename from spring-core-2/src/main/java/com/baeldung/spring/config/MainWebAppInitializer.java rename to spring-core-2/src/main/java/com/baeldung/spring/config/MyWebApplicationInitializer.java index dd396a653f..034386ade9 100644 --- a/spring-core-2/src/main/java/com/baeldung/spring/config/MainWebAppInitializer.java +++ b/spring-core-2/src/main/java/com/baeldung/spring/config/MyWebApplicationInitializer.java @@ -6,15 +6,12 @@ import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRegistration; -import org.springframework.context.support.GenericApplicationContext; import org.springframework.web.WebApplicationInitializer; import org.springframework.web.context.ContextLoaderListener; -import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import org.springframework.web.context.support.GenericWebApplicationContext; import org.springframework.web.servlet.DispatcherServlet; -public class MainWebAppInitializer implements WebApplicationInitializer +public class MyWebApplicationInitializer implements WebApplicationInitializer { /** @@ -22,7 +19,7 @@ public class MainWebAppInitializer implements WebApplicationInitializer */ @Override public void onStartup(final ServletContext sc) throws ServletException { - System.out.println("MainWebAppInitializer.onStartup()"); + System.out.println("MyWebApplicationInitializer.onStartup()"); // Create the 'root' Spring application context final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext(); diff --git a/spring-core-2/src/test/java/com/baeldung/profiles/SpringProfilesWithMavenPropertiesIntegrationTest.java b/spring-core-2/src/test/java/com/baeldung/profiles/SpringProfilesWithMavenPropertiesIntegrationTest.java index 60e9499d4b..1380e34ebd 100644 --- a/spring-core-2/src/test/java/com/baeldung/profiles/SpringProfilesWithMavenPropertiesIntegrationTest.java +++ b/spring-core-2/src/test/java/com/baeldung/profiles/SpringProfilesWithMavenPropertiesIntegrationTest.java @@ -16,7 +16,7 @@ public class SpringProfilesWithMavenPropertiesIntegrationTest { DatasourceConfig datasourceConfig; @Test - public void testSpringProfiles() { + public void setupDatasource() { Assert.assertTrue(datasourceConfig instanceof DevDatasourceConfig); } } \ No newline at end of file diff --git a/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoAnnotationUnitTest.java b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoAnnotationUnitTest.java index 731183bae2..27e3258efb 100644 --- a/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoAnnotationUnitTest.java +++ b/testing-modules/mockito/src/test/java/com/baeldung/mockito/MockitoAnnotationUnitTest.java @@ -75,7 +75,53 @@ public class MockitoAnnotationUnitTest { Mockito.doReturn(100).when(spiedList).size(); assertEquals(100, spiedList.size()); } + + @Test + public void whenSpyingOnList_thenCorrect() { + List list = new ArrayList(); + List spyList = Mockito.spy(list); + + spyList.add("one"); + spyList.add("two"); + + Mockito.verify(spyList).add("one"); + Mockito.verify(spyList).add("two"); + + assertEquals(2, spyList.size()); + } + @Test + public void whenUsingTheSpyAnnotation_thenObjectIsSpied() { + spiedList.add("one"); + spiedList.add("two"); + + Mockito.verify(spiedList).add("one"); + Mockito.verify(spiedList).add("two"); + + assertEquals(2, spiedList.size()); + } + + @Test + public void whenStubASpy_thenStubbed() { + List list = new ArrayList(); + List spyList = Mockito.spy(list); + + assertEquals(0, spyList.size()); + + Mockito.doReturn(100).when(spyList).size(); + assertEquals(100, spyList.size()); + } + + @Test + public void whenCreateSpy_thenCreate() { + List spyList = Mockito.spy(new ArrayList<>()); + + spyList.add("one"); + Mockito.verify(spyList).add("one"); + + assertEquals(1, spyList.size()); + } + @Test public void whenNotUseCaptorAnnotation_thenCorrect() { final List mockList = Mockito.mock(List.class); From c540674c1845b569b6675e167bced64944f04c2d Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sat, 18 Apr 2020 21:00:01 +0530 Subject: [PATCH 261/503] update source code to sync with article --- spring-boot-modules/spring-boot-runtime/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-modules/spring-boot-runtime/pom.xml b/spring-boot-modules/spring-boot-runtime/pom.xml index 4de604f664..df45537940 100644 --- a/spring-boot-modules/spring-boot-runtime/pom.xml +++ b/spring-boot-modules/spring-boot-runtime/pom.xml @@ -14,11 +14,11 @@ ../../parent-boot-2 - + From 374905467e7ed9769c9cd6d834652a7198a22350 Mon Sep 17 00:00:00 2001 From: Justin Albano Date: Sat, 18 Apr 2020 11:48:26 -0400 Subject: [PATCH 262/503] BAEL-3965: Created examples for instance and static factory methods. --- .../java/com/baeldung/factorymethod/Bar.java | 18 ++++++++++++++ .../java/com/baeldung/factorymethod/Foo.java | 5 ++++ .../factorymethod/InstanceBarFactory.java | 8 +++++++ .../factorymethod/InstanceFooFactory.java | 8 +++++++ .../factorymethod/SingletonBarFactory.java | 11 +++++++++ .../factorymethod/SingletonFooFactory.java | 10 ++++++++ .../InstanceBarFactoryIntegrationTest.java | 24 +++++++++++++++++++ .../InstanceFooFactoryIntegrationTest.java | 22 +++++++++++++++++ .../SingletonBarFactoryIntegrationTest.java | 24 +++++++++++++++++++ .../SingletonFooFactoryIntegrationTest.java | 22 +++++++++++++++++ .../factorymethod/instance-bar-config.xml | 20 ++++++++++++++++ .../factorymethod/instance-foo-config.xml | 18 ++++++++++++++ .../factorymethod/static-bar-config.xml | 20 ++++++++++++++++ .../factorymethod/static-foo-config.xml | 18 ++++++++++++++ 14 files changed, 228 insertions(+) create mode 100644 spring-core-3/src/main/java/com/baeldung/factorymethod/Bar.java create mode 100644 spring-core-3/src/main/java/com/baeldung/factorymethod/Foo.java create mode 100644 spring-core-3/src/main/java/com/baeldung/factorymethod/InstanceBarFactory.java create mode 100644 spring-core-3/src/main/java/com/baeldung/factorymethod/InstanceFooFactory.java create mode 100644 spring-core-3/src/main/java/com/baeldung/factorymethod/SingletonBarFactory.java create mode 100644 spring-core-3/src/main/java/com/baeldung/factorymethod/SingletonFooFactory.java create mode 100644 spring-core-3/src/test/java/com/baeldung/factorymethod/InstanceBarFactoryIntegrationTest.java create mode 100644 spring-core-3/src/test/java/com/baeldung/factorymethod/InstanceFooFactoryIntegrationTest.java create mode 100644 spring-core-3/src/test/java/com/baeldung/factorymethod/SingletonBarFactoryIntegrationTest.java create mode 100644 spring-core-3/src/test/java/com/baeldung/factorymethod/SingletonFooFactoryIntegrationTest.java create mode 100644 spring-core-3/src/test/resources/factorymethod/instance-bar-config.xml create mode 100644 spring-core-3/src/test/resources/factorymethod/instance-foo-config.xml create mode 100644 spring-core-3/src/test/resources/factorymethod/static-bar-config.xml create mode 100644 spring-core-3/src/test/resources/factorymethod/static-foo-config.xml diff --git a/spring-core-3/src/main/java/com/baeldung/factorymethod/Bar.java b/spring-core-3/src/main/java/com/baeldung/factorymethod/Bar.java new file mode 100644 index 0000000000..22ef5b3429 --- /dev/null +++ b/spring-core-3/src/main/java/com/baeldung/factorymethod/Bar.java @@ -0,0 +1,18 @@ +package com.baeldung.factorymethod; + +public class Bar { + + private String name; + + public Bar(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/spring-core-3/src/main/java/com/baeldung/factorymethod/Foo.java b/spring-core-3/src/main/java/com/baeldung/factorymethod/Foo.java new file mode 100644 index 0000000000..54bd0c9ff4 --- /dev/null +++ b/spring-core-3/src/main/java/com/baeldung/factorymethod/Foo.java @@ -0,0 +1,5 @@ +package com.baeldung.factorymethod; + +public class Foo { + +} diff --git a/spring-core-3/src/main/java/com/baeldung/factorymethod/InstanceBarFactory.java b/spring-core-3/src/main/java/com/baeldung/factorymethod/InstanceBarFactory.java new file mode 100644 index 0000000000..f834b82aee --- /dev/null +++ b/spring-core-3/src/main/java/com/baeldung/factorymethod/InstanceBarFactory.java @@ -0,0 +1,8 @@ +package com.baeldung.factorymethod; + +public class InstanceBarFactory { + + public Bar createInstance(String name) { + return new Bar(name); + } +} diff --git a/spring-core-3/src/main/java/com/baeldung/factorymethod/InstanceFooFactory.java b/spring-core-3/src/main/java/com/baeldung/factorymethod/InstanceFooFactory.java new file mode 100644 index 0000000000..c3125d3339 --- /dev/null +++ b/spring-core-3/src/main/java/com/baeldung/factorymethod/InstanceFooFactory.java @@ -0,0 +1,8 @@ +package com.baeldung.factorymethod; + +public class InstanceFooFactory { + + public Foo createInstance() { + return new Foo(); + } +} diff --git a/spring-core-3/src/main/java/com/baeldung/factorymethod/SingletonBarFactory.java b/spring-core-3/src/main/java/com/baeldung/factorymethod/SingletonBarFactory.java new file mode 100644 index 0000000000..93802819b1 --- /dev/null +++ b/spring-core-3/src/main/java/com/baeldung/factorymethod/SingletonBarFactory.java @@ -0,0 +1,11 @@ +package com.baeldung.factorymethod; + +public class SingletonBarFactory { + + private static final Bar INSTANCE = new Bar("unnamed"); + + public static Bar createInstance(String name) { + INSTANCE.setName(name); + return INSTANCE; + } +} diff --git a/spring-core-3/src/main/java/com/baeldung/factorymethod/SingletonFooFactory.java b/spring-core-3/src/main/java/com/baeldung/factorymethod/SingletonFooFactory.java new file mode 100644 index 0000000000..77d56cc7f6 --- /dev/null +++ b/spring-core-3/src/main/java/com/baeldung/factorymethod/SingletonFooFactory.java @@ -0,0 +1,10 @@ +package com.baeldung.factorymethod; + +public class SingletonFooFactory { + + private static final Foo INSTANCE = new Foo(); + + public static Foo createInstance() { + return INSTANCE; + } +} diff --git a/spring-core-3/src/test/java/com/baeldung/factorymethod/InstanceBarFactoryIntegrationTest.java b/spring-core-3/src/test/java/com/baeldung/factorymethod/InstanceBarFactoryIntegrationTest.java new file mode 100644 index 0000000000..b5728316e7 --- /dev/null +++ b/spring-core-3/src/test/java/com/baeldung/factorymethod/InstanceBarFactoryIntegrationTest.java @@ -0,0 +1,24 @@ +package com.baeldung.factorymethod; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("/factorymethod/instance-bar-config.xml") +public class InstanceBarFactoryIntegrationTest { + + @Autowired + private Bar instance; + + @Test + public void givenValidInstanceFactoryConfig_whenCreateInstance_thenNameIsCorrect() { + assertNotNull(instance); + assertEquals("someName", instance.getName()); + } +} diff --git a/spring-core-3/src/test/java/com/baeldung/factorymethod/InstanceFooFactoryIntegrationTest.java b/spring-core-3/src/test/java/com/baeldung/factorymethod/InstanceFooFactoryIntegrationTest.java new file mode 100644 index 0000000000..6b1857c2f2 --- /dev/null +++ b/spring-core-3/src/test/java/com/baeldung/factorymethod/InstanceFooFactoryIntegrationTest.java @@ -0,0 +1,22 @@ +package com.baeldung.factorymethod; + +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("/factorymethod/instance-foo-config.xml") +public class InstanceFooFactoryIntegrationTest { + + @Autowired + private Foo foo; + + @Test + public void givenValidInstanceFactoryConfig_whenCreateFooInstance_thenInstanceIsNotNull() { + assertNotNull(foo); + } +} diff --git a/spring-core-3/src/test/java/com/baeldung/factorymethod/SingletonBarFactoryIntegrationTest.java b/spring-core-3/src/test/java/com/baeldung/factorymethod/SingletonBarFactoryIntegrationTest.java new file mode 100644 index 0000000000..403b46156b --- /dev/null +++ b/spring-core-3/src/test/java/com/baeldung/factorymethod/SingletonBarFactoryIntegrationTest.java @@ -0,0 +1,24 @@ +package com.baeldung.factorymethod; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("/factorymethod/static-bar-config.xml") +public class SingletonBarFactoryIntegrationTest { + + @Autowired + private Bar instance; + + @Test + public void givenValidStaticFactoryConfig_whenCreateInstance_thenNameIsCorrect() { + assertNotNull(instance); + assertEquals("someName", instance.getName()); + } +} diff --git a/spring-core-3/src/test/java/com/baeldung/factorymethod/SingletonFooFactoryIntegrationTest.java b/spring-core-3/src/test/java/com/baeldung/factorymethod/SingletonFooFactoryIntegrationTest.java new file mode 100644 index 0000000000..52154b81ab --- /dev/null +++ b/spring-core-3/src/test/java/com/baeldung/factorymethod/SingletonFooFactoryIntegrationTest.java @@ -0,0 +1,22 @@ +package com.baeldung.factorymethod; + +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration("/factorymethod/static-foo-config.xml") +public class SingletonFooFactoryIntegrationTest { + + @Autowired + private Foo singleton; + + @Test + public void givenValidStaticFactoryConfig_whenCreateInstance_thenInstanceIsNotNull() { + assertNotNull(singleton); + } +} diff --git a/spring-core-3/src/test/resources/factorymethod/instance-bar-config.xml b/spring-core-3/src/test/resources/factorymethod/instance-bar-config.xml new file mode 100644 index 0000000000..40d2f33683 --- /dev/null +++ b/spring-core-3/src/test/resources/factorymethod/instance-bar-config.xml @@ -0,0 +1,20 @@ + + + + + + + + + + \ No newline at end of file diff --git a/spring-core-3/src/test/resources/factorymethod/instance-foo-config.xml b/spring-core-3/src/test/resources/factorymethod/instance-foo-config.xml new file mode 100644 index 0000000000..c45bef6a85 --- /dev/null +++ b/spring-core-3/src/test/resources/factorymethod/instance-foo-config.xml @@ -0,0 +1,18 @@ + + + + + + + + \ No newline at end of file diff --git a/spring-core-3/src/test/resources/factorymethod/static-bar-config.xml b/spring-core-3/src/test/resources/factorymethod/static-bar-config.xml new file mode 100644 index 0000000000..4d1befc645 --- /dev/null +++ b/spring-core-3/src/test/resources/factorymethod/static-bar-config.xml @@ -0,0 +1,20 @@ + + + + + + + + \ No newline at end of file diff --git a/spring-core-3/src/test/resources/factorymethod/static-foo-config.xml b/spring-core-3/src/test/resources/factorymethod/static-foo-config.xml new file mode 100644 index 0000000000..83e61a656c --- /dev/null +++ b/spring-core-3/src/test/resources/factorymethod/static-foo-config.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file From 7186e90e46ea4c65d3a26f4c4b9ead06586a913d Mon Sep 17 00:00:00 2001 From: kwoyke Date: Sat, 18 Apr 2020 18:04:17 +0200 Subject: [PATCH 263/503] BAEL-4003: Add byte-buddy dependency (#9134) --- spring-boot-rest/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spring-boot-rest/pom.xml b/spring-boot-rest/pom.xml index 10dacf99e8..a8500d50f2 100644 --- a/spring-boot-rest/pom.xml +++ b/spring-boot-rest/pom.xml @@ -79,6 +79,11 @@ modelmapper ${modelmapper.version} + + net.bytebuddy + byte-buddy + ${byte-buddy.version} + From 32461d70ed11d3f4249f933fe0a2983069c244d5 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 18 Apr 2020 22:26:54 +0530 Subject: [PATCH 264/503] JAVA-918: Migrate jjwt to parent-boot-2 --- jjwt/pom.xml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/jjwt/pom.xml b/jjwt/pom.xml index 073f12a922..aa238fafb5 100644 --- a/jjwt/pom.xml +++ b/jjwt/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 @@ -30,6 +30,11 @@ org.springframework.boot spring-boot-starter-security + + + org.springframework.boot + spring-boot-starter-web + io.jsonwebtoken From 591c168f247d80ce0c128e22161dd8b2e89cb96b Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Sat, 18 Apr 2020 21:08:53 +0300 Subject: [PATCH 265/503] BAEL-3908_http2_client_in_jetty (#8981) * BAEL-3908 http2 in jetty - initial commit * BAEL-3908 - HTTP2 client in jetty * BAEL-3908 - http2 in jetty - code cleanup * BAEL-3908 - fixed indentation --- libraries-server/pom.xml | 42 +++++++++- libraries-server/src/main/config/jetty.xml | 79 ++++++++++++++++++ .../jetty/http2/Http2JettyServlet.java | 29 +++++++ .../src/main/resources/keystore.jks | Bin 0 -> 2206 bytes .../src/main/resources/truststore.jks | Bin 0 -> 916 bytes .../src/main/webapp/WEB-INF/web.xml | 33 ++++++++ libraries-server/src/main/webapp/http2.html | 14 ++++ .../images/homepage-latest_articles.jpg | Bin 0 -> 18501 bytes .../images/homepage-rest_with_spring.jpg | Bin 0 -> 18891 bytes .../webapp/images/homepage-weekly_reviews.jpg | Bin 0 -> 20814 bytes libraries-server/src/main/webapp/index.html | 12 +++ 11 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 libraries-server/src/main/config/jetty.xml create mode 100644 libraries-server/src/main/java/com/baeldung/jetty/http2/Http2JettyServlet.java create mode 100644 libraries-server/src/main/resources/keystore.jks create mode 100644 libraries-server/src/main/resources/truststore.jks create mode 100644 libraries-server/src/main/webapp/WEB-INF/web.xml create mode 100644 libraries-server/src/main/webapp/http2.html create mode 100644 libraries-server/src/main/webapp/images/homepage-latest_articles.jpg create mode 100644 libraries-server/src/main/webapp/images/homepage-rest_with_spring.jpg create mode 100644 libraries-server/src/main/webapp/images/homepage-weekly_reviews.jpg create mode 100644 libraries-server/src/main/webapp/index.html diff --git a/libraries-server/pom.xml b/libraries-server/pom.xml index a849708cd8..eb9cb61e56 100644 --- a/libraries-server/pom.xml +++ b/libraries-server/pom.xml @@ -5,6 +5,7 @@ libraries-server 0.0.1-SNAPSHOT libraries-server + war com.baeldung @@ -105,12 +106,51 @@ + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.version} + + 8888 + quit + + -Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/alpn/alpn-boot/${alpn.version}/alpn-boot-${alpn.version}.jar + + ${basedir}/src/main/config/jetty.xml + + / + + + + + org.eclipse.jetty.http2 + http2-server + ${jetty.version} + + + org.eclipse.jetty + jetty-alpn-openjdk8-server + ${jetty.version} + + + org.eclipse.jetty + jetty-servlets + ${jetty.version} + + + + + 3.6.2 4.5.3 - 9.4.8.v20171121 + 9.4.27.v20200227 4.1.20.Final + 8.1.11.v20170118 8.5.24 4.3.1 1.2.0 diff --git a/libraries-server/src/main/config/jetty.xml b/libraries-server/src/main/config/jetty.xml new file mode 100644 index 0000000000..fd4a50382b --- /dev/null +++ b/libraries-server/src/main/config/jetty.xml @@ -0,0 +1,79 @@ + + + + + + + src/main/resources/keystore.jks + storepwd + src/main/resources/truststore.jks + storepwd + TLSv1.2 + + + + + + + + + + + + + + + + + http/1.1 + + + + + + + + + + + + 8443 + + + + + + + + + + + + + + + + + + alpn + + + + + h2,h2-17 + + + + + + + + + + + + 8444 + + + + \ No newline at end of file diff --git a/libraries-server/src/main/java/com/baeldung/jetty/http2/Http2JettyServlet.java b/libraries-server/src/main/java/com/baeldung/jetty/http2/Http2JettyServlet.java new file mode 100644 index 0000000000..56b75c45d3 --- /dev/null +++ b/libraries-server/src/main/java/com/baeldung/jetty/http2/Http2JettyServlet.java @@ -0,0 +1,29 @@ +package com.baeldung.jetty.http2; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class Http2JettyServlet extends HttpServlet { + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.addHeader("Cache-control", "no-store, no-cache, must-revalidate"); + response.addDateHeader("Last-Modified", 0); + response.addDateHeader("Expires", 0); + + String requestPath = request.getRequestURI(); + InputStream input = getServletContext().getResourceAsStream(requestPath); + OutputStream output = response.getOutputStream(); + byte[] buffer = new byte[1024]; + int read; + while ((read = input.read(buffer)) >= 0) { + output.write(buffer, 0, read); + } + } + +} diff --git a/libraries-server/src/main/resources/keystore.jks b/libraries-server/src/main/resources/keystore.jks new file mode 100644 index 0000000000000000000000000000000000000000..428ba54776ede2fdcdeedd879edb927c2abd9953 GIT binary patch literal 2206 zcmcgt`9Bkm8{cNkoMUp6gmShKn!AQX*(l6Nj(i=TnQPOKYtv{*Wg>ItE=Q!pRYH8a z$Sp#S#2lYw#aw;$y9u4T}83H*%lp zAKZay0sy=q1Qoo85aAQh;$ zD(c2EIN#D7WwYDLKUg!CotQPD@dp;5FR#bgaace(^x$6g5frD~(_b(MI^J&*A2DRp zf5Q2onfE(zvUb9|9C`66)YFRNM6~xrz4;iVbU=P|*YT2eWHFJJtr+M@zt2qPm)K~rRcqcs=LM12)PX0TT%QO zlf*xkqD3}7l)1J`5W(>=9nR0e6j-<79<11v3ZuXXcQpoCsqY~n`$FN+S}hcVm5Y>G zXnD{@DYs1@{S0z(lW+?86LWKtku$$-(khsh>0qRUXn=84`GRn?77M^_JY`durnN;KE zW#OJ`h<6xcB{I))ekGpc*Ylt}0cx4|OMBDPQvx4`r`}4Ze5_ipdObGMTi3bZHd5PC zcY0;?uBWu$PSvjJeb87nY7ghNv?%M@SoDl6IWt`bQCosfSh$#D6$ea~QhKM^ud2Ut z+9PYJuVpoELmN-A`F$BicO{BSYg@#tS%avVfb}DxL)|NanJ)#zB!2~?#Ot%H7--9N zU$bs0fS5G!m5M4&WK3#a|H|Tgw*?X-;H+Lu@kwA>qSR~7UC7b)7MJXTn6PG>n@8jP zW+}F^X$$c;U~4ryqRF; z>`j!tbLMK4ZGyY643|~?%Mu#fm!l%wAKjBDmd+VYmp3S#$scD$~bxbf|z#)hShN0*AhRaPDcmqrftGlHq4^54MM$Xfy(2> zH8QYVMzmn_oHbvJCB`IN~E&{1*h&0gEM{e zKvWvzp(!BqMX8`t#)~0nq}Wa zr6>FRPyp;AAB&)1$5@;r$23J{K&~>TWjZf7V$wFzmGM95CXhFG1cJNVAXks}C+&2- zbf9Qn*D8N}Afd2kpwDxns3%1uaFhAqDV8ksWiWY|quuLGZ0)SqrJ!Y8yX}@}IyC$C zQ3rCUsn}#>F#D8%D?q~ySy4j&he%Bs{{7V%rl!ui`@KQP?NTi+_iN{cwom&9RaMRR zB~z!hz|0HAgB9_Ijvpe-zr#jLbckJsc>vmo{+im?t8lA;N#fD4?{lb&J0V8Gocq%; f1ihv=QIDh{M_<9V+45Z2{KE4_qW}V3B0uV%GgrOJ literal 0 HcmV?d00001 diff --git a/libraries-server/src/main/resources/truststore.jks b/libraries-server/src/main/resources/truststore.jks new file mode 100644 index 0000000000000000000000000000000000000000..839cb8c35151c2b7c64afca24b6b72caad070a05 GIT binary patch literal 916 zcmezO_TO6u1_mY|W(3o$xs} zE~X|%Muz1J{3AIFGbaABoD&*5saD@gH|APIn|qhRGl}gsUzm=o9G*UXZaLfkb^*)o zjA*-gTf)`m_MQJYE&gJ}p^PHkrj!4^W|XX5a=N7A{;n#yaON&k_bHloe-^*hm?Z91 zlB>xeD=<(C>yn{9D54u}krkl}HQ(Uscha(++qf!T9y+xaEfnXd1O zi0)T?voO%;QH9LK;*_O3mBblqm)!31vU@hm;^%>mh5U@y3R%l0gzi`2yxH!+?kPOi zt!Tnsz1x9B3U2~8STZp)GB6^C5HPs_Lx_=~O<3xi>MmQ;D_g$D<_pdct`+TyzWTQ= zW5Finm(sGEe;ty^>vg$!cV)t>;H#Mev23$*WWBpyJ}Ir;RW+Htrt6{Pk&qz&-XG2@ z8@{&Lu%DX7m47Uny+-3w`=4V611q#Ub(U`xZCtSK^2LO^3(s|HW&N14dV4@A&(kX% z*S_eUPs-bSWRp>avt;CP@7K+G&3=b&1eO-s3f`;Cf91p#$)FW&xME3L8sEBQQDVCvfG>mdwqnk+GXd2ihXqpv z;usF(WoYYmu8DZZa4%1z=+hI+*gpkUykAy5tj#grb*gH!M6TqIcifYBGVe^&T#-2O K*=+x>r_BKeJV|!| literal 0 HcmV?d00001 diff --git a/libraries-server/src/main/webapp/WEB-INF/web.xml b/libraries-server/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..75d7e11c64 --- /dev/null +++ b/libraries-server/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,33 @@ + + + + + http2Jetty + com.baeldung.jetty.http2.Http2JettyServlet + + + http2Jetty + /images/* + + + + push + org.eclipse.jetty.servlets.PushCacheFilter + + ports + 8444 + + + maxAssociations + 32 + + + + push + /* + + + \ No newline at end of file diff --git a/libraries-server/src/main/webapp/http2.html b/libraries-server/src/main/webapp/http2.html new file mode 100644 index 0000000000..4563945a5e --- /dev/null +++ b/libraries-server/src/main/webapp/http2.html @@ -0,0 +1,14 @@ + + + + Baeldung HTTP/2 Client in Jetty + + +

HTTP/2 Demo

+
+ latest articles + rest with spring + weekly reviews +
+ + \ No newline at end of file diff --git a/libraries-server/src/main/webapp/images/homepage-latest_articles.jpg b/libraries-server/src/main/webapp/images/homepage-latest_articles.jpg new file mode 100644 index 0000000000000000000000000000000000000000..59e78e456022f41f7f6167157d4a4dc08e944e27 GIT binary patch literal 18501 zcma&N1yEc~(?7bn%i> zy;WzYe?4dSoHKoTx~F^ouKwKyph}BNi37mE001!12k>_T5Den}OW>deI5_ACI{b$q zz#%{cIzWC91k^tS^FgrxLmy{@dP6}#K*2ykLj7No|LO9-H~#hmfUscTV9gLP_S?iknrGOf7b!9{}H_WSNQ+_=9dnf4c@P>#s30h z>Hi@l8n;r&iGz)5d#WnZnxX!HFdvL%_Mvkxu3i_G-Bdpi8t+{2yp~`ABkk$>4<5?X z(6^Ts-y`qw=_lMz-XYEp@UGS=4o7#^nKtMgvCltT%O8Z%;(K2!^_FnqeqRdboQ%-6 zX9d~}i-H806wPx;6Uz$xUA7!L+U{OEF&Zf;im*|wAQ>O`h76+=6ppY<=6rn`5ei88Ptqii{77qu4dMP#6nctcst+b z|7`Q=9vos9-n`*@Id6jo7c<#Q;EJD?s;@TNu!j4(l5lv+>a3}Sp&E1!O=OOC5tpI$ z(tV9LA)e!CYDSIs*ljfKY4`hq5C8zpL{r|3IrE0cWjSdF0XHs(NZ@>2GRai55Z&4h zl0&IjTl1PjsL;L#BvIj?qCPxSC}+uRj>Um~I#7P~)nDkVfC2XBr=a7+vqTM%dX1rO zkc5AWPQ@|8K1aJ#uIWNEk5if0Q2l!v8dYPC+U*|1`mA zRYMN+B3=GraGYUyLrybZ2m{AX z9DB+RsCPc52Om8 z{#Awl#{vSNVIZMkA^tUh5dVL4Vf{aU0$$Pdp9aV_AgM3@(*|dtA<->c-N^liGdBCq z`-P|GpCLs_?M`&2XQ9)J4kN|S`bQrys+#oPq>JF^yIPAp@Ng+VtP=n_6uo^;d#fDN z!%WnHleO>rWOGR6hrr0}4fS+f$D+w`P2C7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yvRx`kI)X_qG9mtyw8|7y;9IK&1L8k!-~=gA6td;}F(tv0 zkQ)ZGUV@~o6QYBM!tiwS+5#t{Lj>LlP%2_n0+=bo21$D;q9PJa#e$VPNHMGEO}_D4 z>iCs1{2jS$C?x`<+0hFXQA*+Lk29qjwNpej|{RRVJ zqDTIe@j2)@k!2Mq`Dg_I&~1lWzu6|il+P)G4kOOS>_@yjh&+@S=tYAqC5Y5@hfBJ? z5i{dXea@hi3X^9_K3&n%Pz4vo2mFkPc!oF zV|pQ?1$pE(Jb|&@6iDok-%~zYMU;{VIT0~n(cpu4XeOb<)=x2?R4auf5=%*e43@%r zQkz)Rd>`IhoNtr!Kys!yp0l>-G&Xu=Ei~j&c zewK!$KeUoQV__zDhdP=P?uvWx1E202~m&& zrorM>DZx6N&O(EYJDnj&I3JkE>MZeLROEM6=Of}cS{jgb1b7-ATR@U<6E;VqPHUH!Ys$pNUb0VyJj-cd z02Bg4yMu#h2y>9T=9aKhcqsi|%ZuWl?6HV=sC^PG1QV%I@+G{igrIw%50~@X|Jhg4 BH~s(s literal 0 HcmV?d00001 diff --git a/libraries-server/src/main/webapp/images/homepage-rest_with_spring.jpg b/libraries-server/src/main/webapp/images/homepage-rest_with_spring.jpg new file mode 100644 index 0000000000000000000000000000000000000000..43d9221e85f9186b8bbf9e12e5924421462ed04c GIT binary patch literal 18891 zcma&O1y~%x(>J(_EKYEDcZcBa1b24`?(XjHPH?v%!2-cugA+Uu+}&=I_y2x!_uV~L z+fPr|uey78rfX_yYHId<`F#t3A}c8)2>=2C03i4ScwYmAg1P@D2yg=e0$hWu{~|~T zNHBpbsJ{dW{f}V&672t=zoWsup&=omVW6R){};*s=<@&Fc<%$C!U7?Ht&l)e00b%! z5*7G903ZVYKnMs(@Z^C1CJ+oXEF=^h1U&G46#)BRg4e+Rmi~`z|Lxv?wLu_Cnx_PF z7hD5m$G^yj%rg3e1RlC47S9RGO{fCFzaSKvST-bn6?$A0sWX4%U&MsvD<*kJqQ1DP zw$p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%!i|a#=KTSSt{^!m;PJZ>B?T*H^gzHZv-A_mmcGBP-}-E*B>m>9WQj+ zj0-&~jQNYHx*U*k4#a(Ihr z1JIHjyYnci=S##;5U$oo1s|3yp(T@NBn9M1!3PCGH!q&x0~$ZRWgX4Zeh|3a$PR6Sfa5pcX2xZTo=1=KU?9G18vdE+P6bLGOBH0c?*wD&(ZQB)wk_Wv<9uUn=4uP-p;=#9(AYT@i5i({D^<_snypSA~CBqYTPy_&dtH;wZE#^J}po{63JjPxJatK3g)jaukr~m z_y<;o&;gXUY_IJ{uecrou+K}4V0fCi8eL1Lu4aata*=A2^F-bQsj_A^L6Dj7zQGAY zZ#eEsinHglK_ntcos0+pW%n%4r>>qPUE>BF>Zz;AX?$Z2$3*8o>pK|+ezQLq0yJ;?xoeM^7`(js}c^&7krz6I?AK zU+~JsEr)8=rd@An7^C8k7sd#wmny+cV^*ud6a;nQLkVafzrrV$ZadFMR>*g&UkT!p zEo9qkre%o`xj4;v{b-xS1G8NV(Vp2|V;-v_U`#}+{o54*^Ju1*K-{D~<4~Z^r_DL9 zVJ$Wwo61~D7ElZAGU&XD@J(P_V{jsS4`rxnTfx}cn(VRS3$ToK@y*?;oQcmD!XRI-Zz literal 0 HcmV?d00001 diff --git a/libraries-server/src/main/webapp/index.html b/libraries-server/src/main/webapp/index.html new file mode 100644 index 0000000000..2497893d82 --- /dev/null +++ b/libraries-server/src/main/webapp/index.html @@ -0,0 +1,12 @@ + + + + Baeldung: HTTP2 Client in Jetty + + +

    HTTP/1.1

    +
    +

    HTTP/2 Push

    +
    + + \ No newline at end of file From c68c7648a3361ee26f35356e618ddc9ab189d3f0 Mon Sep 17 00:00:00 2001 From: Gang Wu Date: Sat, 18 Apr 2020 12:48:37 -0600 Subject: [PATCH 266/503] BAEL-3961 Remove address field of Employee class. --- .../main/java/com/baeldung/jdbc/Employee.java | 17 ++++------------- .../java/com/baeldung/jdbc/EmployeeDAO.java | 11 ++++++----- .../src/main/resources/jdbc/schema.sql | 3 +-- .../src/main/resources/jdbc/test-data.sql | 8 ++++---- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/Employee.java b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/Employee.java index d5f87ca3df..bd6fe0fb15 100644 --- a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/Employee.java +++ b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/Employee.java @@ -7,13 +7,11 @@ public class Employee { private String lastName; - private String address; - public Employee(int id, String firstName, String lastName, String address) { - setId(id); - setFirstName(firstName); - setLastName(lastName); - setAddress(address); + public Employee(int id, String firstName, String lastName) { + this.id = id; + this.firstName = firstName; + this.lastName = lastName; } public int getId() { @@ -40,12 +38,5 @@ public class Employee { this.lastName = lastName; } - public String getAddress() { - return address; - } - - public void setAddress(final String address) { - this.address = address; - } } diff --git a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java index 25d280ad12..8637f6f851 100644 --- a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java +++ b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java @@ -30,23 +30,22 @@ public class EmployeeDAO { SqlParameterSource parameters = new MapSqlParameterSource("ids", ids); List employees = namedJdbcTemplate.query("SELECT * FROM EMPLOYEE WHERE id IN (:ids)", parameters, - (rs, rowNum) -> new Employee(rs.getInt("id"), rs.getString("first_name"), rs.getString("last_name"), rs.getString("address"))); + (rs, rowNum) -> new Employee(rs.getInt("id"), rs.getString("first_name"), rs.getString("last_name"))); return employees; } public List getEmployeesFromIdList(List ids) { String inSql = String.join(",", Collections.nCopies(ids.size(), "?")); - List employees = jdbcTemplate.query("SELECT * FROM EMPLOYEE WHERE id IN (" + inSql +")", + List employees = jdbcTemplate.query(String.format("SELECT * FROM EMPLOYEE WHERE id IN (%s)", inSql), ids.toArray(), - (rs, rowNum) -> new Employee(rs.getInt("id"), rs.getString("first_name"), rs.getString("last_name"), rs.getString("address"))); + (rs, rowNum) -> new Employee(rs.getInt("id"), rs.getString("first_name"), rs.getString("last_name"))); return employees; } public List getEmployeesFromLargeIdList(List ids) { jdbcTemplate.execute("CREATE TEMPORARY TABLE IF NOT EXISTS employee_tmp (id INT NOT NULL)"); - jdbcTemplate.update("DELETE FROM employee_tmp"); List employeeIds = new ArrayList<>(); for (Integer id : ids) { @@ -55,7 +54,9 @@ public class EmployeeDAO { jdbcTemplate.batchUpdate("INSERT INTO employee_tmp VALUES(?)", employeeIds); List employees = jdbcTemplate.query("SELECT * FROM EMPLOYEE WHERE id IN (SELECT id FROM employee_tmp)", - (rs, rowNum) -> new Employee(rs.getInt("id"), rs.getString("first_name"), rs.getString("last_name"), rs.getString("address"))); + (rs, rowNum) -> new Employee(rs.getInt("id"), rs.getString("first_name"), rs.getString("last_name"))); + + jdbcTemplate.update("DELETE FROM employee_tmp"); return employees; } diff --git a/persistence-modules/spring-persistence-simple-2/src/main/resources/jdbc/schema.sql b/persistence-modules/spring-persistence-simple-2/src/main/resources/jdbc/schema.sql index 3401c5d963..be102431ca 100644 --- a/persistence-modules/spring-persistence-simple-2/src/main/resources/jdbc/schema.sql +++ b/persistence-modules/spring-persistence-simple-2/src/main/resources/jdbc/schema.sql @@ -2,6 +2,5 @@ CREATE TABLE EMPLOYEE ( ID int NOT NULL PRIMARY KEY, FIRST_NAME varchar(255), - LAST_NAME varchar(255), - ADDRESS varchar(255) + LAST_NAME varchar(255) ); \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple-2/src/main/resources/jdbc/test-data.sql b/persistence-modules/spring-persistence-simple-2/src/main/resources/jdbc/test-data.sql index c1669c156d..5421c09849 100644 --- a/persistence-modules/spring-persistence-simple-2/src/main/resources/jdbc/test-data.sql +++ b/persistence-modules/spring-persistence-simple-2/src/main/resources/jdbc/test-data.sql @@ -1,4 +1,4 @@ -INSERT INTO EMPLOYEE VALUES (1, 'James', 'Gosling', 'Canada'); -INSERT INTO EMPLOYEE VALUES (2, 'Donald', 'Knuth', 'USA'); -INSERT INTO EMPLOYEE VALUES (3, 'Linus', 'Torvalds', 'Finland'); -INSERT INTO EMPLOYEE VALUES (4, 'Dennis', 'Ritchie', 'USA'); \ No newline at end of file +INSERT INTO EMPLOYEE VALUES (1, 'James', 'Gosling'); +INSERT INTO EMPLOYEE VALUES (2, 'Donald', 'Knuth'); +INSERT INTO EMPLOYEE VALUES (3, 'Linus', 'Torvalds'); +INSERT INTO EMPLOYEE VALUES (4, 'Dennis', 'Ritchie'); \ No newline at end of file From ffe8422ca234cbfac5c019137723f9dca643be89 Mon Sep 17 00:00:00 2001 From: KevinGilmore Date: Sat, 18 Apr 2020 21:15:05 -0500 Subject: [PATCH 267/503] BAEL-3908: Update README file (#9141) * BAEL-3336 BAEL-3058 add links * BAEL-3319: add link * BAEL-3284: add link * BAEL-3198: add link to article * BAEL-3479: add link to article * BAEL-3485: add article link * SCALA-38: move to new package and add link back to article * SCALA-38: add imports back into unit test * BAEL-3908: add link back to article --- libraries-server/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries-server/README.md b/libraries-server/README.md index d9e6b8b206..7e41f33a0c 100644 --- a/libraries-server/README.md +++ b/libraries-server/README.md @@ -13,3 +13,4 @@ This module contains articles about server libraries. - [MQTT Client in Java](https://www.baeldung.com/java-mqtt-client) - [Guide to XMPP Smack Client](https://www.baeldung.com/xmpp-smack-chat-client) - [A Guide to NanoHTTPD](https://www.baeldung.com/nanohttpd) +- [HTTP/2 in Jetty](https://www.baeldung.com/jetty-http-2) From 95578f92ea2e77deca0d76a08be98675943df8db Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sun, 19 Apr 2020 18:09:24 +0530 Subject: [PATCH 268/503] update pom version from RC to GA --- core-java-modules/core-java-time-measurements/pom.xml | 2 +- jhipster/jhipster-uaa/gateway/pom.xml | 2 +- jhipster/jhipster-uaa/quotes/pom.xml | 2 +- jhipster/jhipster-uaa/uaa/pom.xml | 2 +- persistence-modules/java-jpa-2/pom.xml | 2 +- persistence-modules/java-jpa/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core-java-modules/core-java-time-measurements/pom.xml b/core-java-modules/core-java-time-measurements/pom.xml index 71a012ca2b..b751cc0d74 100644 --- a/core-java-modules/core-java-time-measurements/pom.xml +++ b/core-java-modules/core-java-time-measurements/pom.xml @@ -96,7 +96,7 @@ 3.6.1 1.8.9 - 2.0.0-RC.4 + 2.0.0 1.44 2.22.1 diff --git a/jhipster/jhipster-uaa/gateway/pom.xml b/jhipster/jhipster-uaa/gateway/pom.xml index 1b85877a9b..b417bd7b57 100644 --- a/jhipster/jhipster-uaa/gateway/pom.xml +++ b/jhipster/jhipster-uaa/gateway/pom.xml @@ -1013,7 +1013,7 @@ 1.0.0 - 0.24.0-RC.0 + 0.24.0 3.0.0 1.8 diff --git a/jhipster/jhipster-uaa/quotes/pom.xml b/jhipster/jhipster-uaa/quotes/pom.xml index aacc6f8e36..f088ad2fd1 100644 --- a/jhipster/jhipster-uaa/quotes/pom.xml +++ b/jhipster/jhipster-uaa/quotes/pom.xml @@ -910,6 +910,6 @@ ${project.basedir}/src/test/ - 0.24.0-RC.0 + 0.24.0 diff --git a/jhipster/jhipster-uaa/uaa/pom.xml b/jhipster/jhipster-uaa/uaa/pom.xml index 27a056820d..f9c1f226bb 100644 --- a/jhipster/jhipster-uaa/uaa/pom.xml +++ b/jhipster/jhipster-uaa/uaa/pom.xml @@ -835,7 +835,7 @@ 1.0.0 - 0.24.0-RC.0 + 0.24.0 3.0.0 1.8 diff --git a/persistence-modules/java-jpa-2/pom.xml b/persistence-modules/java-jpa-2/pom.xml index f79f6f1633..76b1033dac 100644 --- a/persistence-modules/java-jpa-2/pom.xml +++ b/persistence-modules/java-jpa-2/pom.xml @@ -111,7 +111,7 @@ 5.4.0.Final - 2.7.4-RC1 + 2.7.4 42.2.5 2.2 3.11.1 diff --git a/persistence-modules/java-jpa/pom.xml b/persistence-modules/java-jpa/pom.xml index 762c541d96..3601721dac 100644 --- a/persistence-modules/java-jpa/pom.xml +++ b/persistence-modules/java-jpa/pom.xml @@ -106,7 +106,7 @@ 5.4.0.Final - 2.7.4-RC1 + 2.7.4 42.2.5 2.2 3.3.3 From 87ac7a74bedb559899383bea777a59670389f45d Mon Sep 17 00:00:00 2001 From: Yavuz Tas <12643010+yavuztas@users.noreply.github.com> Date: Sun, 19 Apr 2020 16:18:58 +0200 Subject: [PATCH 269/503] Update code base for BAEL-3872 (#9032) * resolve an sql syntax error for H2 version 1.4.200 * update spring and spring-data-jpa version to latest migrate spring-data-jpa Sort initializations to Sort.by static factory methods to fix compile errors * update hibernate version to latest * cleanup code * show how to get a bean object from factory bean as shown in the section 4 * update mysql version and fix tests under persistence.service * clean up code --- .../spring-persistence-simple/pom.xml | 15 +++++--- .../baeldung/config/PersistenceConfig.java | 24 +++++-------- .../baeldung/config/PersistenceJPAConfig.java | 15 ++++---- .../com/baeldung/jpa/dao/AbstractJpaDAO.java | 7 ++-- .../src/main/resources/hibernate5Config.xml | 2 +- .../src/main/resources/jdbc/schema.sql | 2 +- .../resources/persistence-mysql.properties | 4 +-- .../jpaquery/UserRepositoryCommon.java | 35 ++++++++----------- 8 files changed, 46 insertions(+), 58 deletions(-) diff --git a/persistence-modules/spring-persistence-simple/pom.xml b/persistence-modules/spring-persistence-simple/pom.xml index 8a03310048..878c4592f9 100644 --- a/persistence-modules/spring-persistence-simple/pom.xml +++ b/persistence-modules/spring-persistence-simple/pom.xml @@ -24,7 +24,11 @@ spring-context ${org.springframework.version} - + + org.springframework + spring-aspects + ${org.springframework.version} + org.hibernate @@ -128,12 +132,13 @@ - 5.1.6.RELEASE + 5.2.5.RELEASE - 5.4.2.Final - 6.0.6 - 2.1.6.RELEASE + 5.4.13.Final + 8.0.19 + 1.4.200 + 2.2.6.RELEASE 9.0.0.M26 1.1 4.2.1 diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceConfig.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceConfig.java index 569971e311..80f3ff14c5 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceConfig.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceConfig.java @@ -1,9 +1,7 @@ package com.baeldung.config; -import java.util.Properties; - -import javax.sql.DataSource; - +import com.baeldung.persistence.service.FooService; +import com.google.common.base.Preconditions; import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -23,16 +21,15 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; -import com.baeldung.hibernate.dao.FooDao; -import com.baeldung.jpa.dao.IFooDao; -import com.google.common.base.Preconditions; +import javax.sql.DataSource; +import java.util.Properties; @Configuration @EnableTransactionManagement @EnableJpaRepositories(basePackages = { "com.baeldung.hibernate.dao" }, transactionManagerRef = "jpaTransactionManager") @EnableJpaAuditing @PropertySource({ "classpath:persistence-mysql.properties" }) -@ComponentScan({ "com.baeldung.persistence", "com.baeldung.hibernate.dao" }) +@ComponentScan(basePackages = { "com.baeldung.persistence.dao", "com.baeldung.jpa.dao" }) public class PersistenceConfig { @Autowired @@ -46,7 +43,7 @@ public class PersistenceConfig { public LocalSessionFactoryBean sessionFactory() { final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean(); sessionFactory.setDataSource(restDataSource()); - sessionFactory.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); + sessionFactory.setPackagesToScan("com.baeldung.persistence.model"); sessionFactory.setHibernateProperties(hibernateProperties()); return sessionFactory; @@ -56,7 +53,7 @@ public class PersistenceConfig { public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean emf = new LocalContainerEntityManagerFactoryBean(); emf.setDataSource(restDataSource()); - emf.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); + emf.setPackagesToScan("com.baeldung.persistence.model"); final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); emf.setJpaVendorAdapter(vendorAdapter); @@ -96,18 +93,15 @@ public class PersistenceConfig { } @Bean - public IFooDao fooHibernateDao() { - return new FooDao(); + public FooService fooService() { + return new FooService(); } private final Properties hibernateProperties() { final Properties hibernateProperties = new Properties(); hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - hibernateProperties.setProperty("hibernate.show_sql", "true"); - // hibernateProperties.setProperty("hibernate.format_sql", "true"); - // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); // Envers properties hibernateProperties.setProperty("org.hibernate.envers.audit_table_suffix", env.getProperty("envers.audit_table_suffix")); diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java index 7d3a881827..06cae493c9 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java @@ -1,10 +1,6 @@ package com.baeldung.config; -import java.util.Properties; - -import javax.persistence.EntityManagerFactory; -import javax.sql.DataSource; - +import com.google.common.base.Preconditions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -21,7 +17,8 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; -import com.google.common.base.Preconditions; +import javax.sql.DataSource; +import java.util.Properties; @Configuration @EnableTransactionManagement @@ -43,7 +40,7 @@ public class PersistenceJPAConfig { public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); - em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); + em.setPackagesToScan("com.baeldung.persistence.model"); final JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); em.setJpaVendorAdapter(vendorAdapter); @@ -64,9 +61,9 @@ public class PersistenceJPAConfig { } @Bean - public PlatformTransactionManager transactionManager(final EntityManagerFactory emf) { + public PlatformTransactionManager transactionManager() { final JpaTransactionManager transactionManager = new JpaTransactionManager(); - transactionManager.setEntityManagerFactory(emf); + transactionManager.setEntityManagerFactory(entityManagerFactory().getObject()); return transactionManager; } diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jpa/dao/AbstractJpaDAO.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jpa/dao/AbstractJpaDAO.java index 4fbc8464bb..a6542c5cb1 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jpa/dao/AbstractJpaDAO.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jpa/dao/AbstractJpaDAO.java @@ -1,16 +1,15 @@ package com.baeldung.jpa.dao; -import java.io.Serializable; -import java.util.List; - import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; +import java.io.Serializable; +import java.util.List; public abstract class AbstractJpaDAO { private Class clazz; - @PersistenceContext + @PersistenceContext(unitName = "entityManagerFactory") private EntityManager entityManager; public final void setClazz(final Class clazzToSet) { diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/hibernate5Config.xml b/persistence-modules/spring-persistence-simple/src/main/resources/hibernate5Config.xml index bbb61cb3e0..55546a862a 100644 --- a/persistence-modules/spring-persistence-simple/src/main/resources/hibernate5Config.xml +++ b/persistence-modules/spring-persistence-simple/src/main/resources/hibernate5Config.xml @@ -21,7 +21,7 @@ - + diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/jdbc/schema.sql b/persistence-modules/spring-persistence-simple/src/main/resources/jdbc/schema.sql index c86d35cdae..ef4460e267 100644 --- a/persistence-modules/spring-persistence-simple/src/main/resources/jdbc/schema.sql +++ b/persistence-modules/spring-persistence-simple/src/main/resources/jdbc/schema.sql @@ -3,5 +3,5 @@ CREATE TABLE EMPLOYEE ID int NOT NULL PRIMARY KEY, FIRST_NAME varchar(255), LAST_NAME varchar(255), - ADDRESS varchar(255), + ADDRESS varchar(255) ); \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/persistence-mysql.properties b/persistence-modules/spring-persistence-simple/src/main/resources/persistence-mysql.properties index b3cfd31f46..9ba4f7602a 100644 --- a/persistence-modules/spring-persistence-simple/src/main/resources/persistence-mysql.properties +++ b/persistence-modules/spring-persistence-simple/src/main/resources/persistence-mysql.properties @@ -1,7 +1,7 @@ # jdbc.X jdbc.driverClassName=com.mysql.cj.jdbc.Driver -jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate5_01?createDatabaseIfNotExist=true -jdbc.eventGeneratedId=tutorialuser +jdbc.url=jdbc:mysql://localhost:3306/spring_hibernate5_01?createDatabaseIfNotExist=true&serverTimezone=UTC +jdbc.user=tutorialuser jdbc.pass=tutorialmy5ql # hibernate.X diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCommon.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCommon.java index 69ddbb9b9f..5874b3c643 100644 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCommon.java +++ b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCommon.java @@ -1,25 +1,6 @@ package com.baeldung.spring.data.persistence.jpaquery; -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.time.LocalDate; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.function.Predicate; -import java.util.stream.Stream; - -import javax.persistence.EntityManager; -import javax.persistence.Query; - import com.baeldung.spring.data.persistence.config.PersistenceConfig; -import com.baeldung.spring.data.persistence.jpaquery.UserRepository; import com.baeldung.spring.data.persistence.model.User; import org.junit.After; import org.junit.Test; @@ -36,6 +17,16 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; import org.springframework.transaction.annotation.Transactional; +import javax.persistence.EntityManager; +import javax.persistence.Query; +import java.time.LocalDate; +import java.util.*; +import java.util.function.Predicate; +import java.util.stream.Stream; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.*; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) @@ -283,7 +274,7 @@ public class UserRepositoryCommon { userRepository.save(new User(USER_NAME_PETER, LocalDate.now(), USER_EMAIL2, ACTIVE_STATUS)); userRepository.save(new User("SAMPLE", LocalDate.now(), USER_EMAIL3, INACTIVE_STATUS)); - List usersSortByName = userRepository.findAll(new Sort(Sort.Direction.ASC, "name")); + List usersSortByName = userRepository.findAll(Sort.by(Sort.Direction.ASC, "name")); assertThat(usersSortByName.get(0) .getName()).isEqualTo(USER_NAME_ADAM); @@ -295,7 +286,7 @@ public class UserRepositoryCommon { userRepository.save(new User(USER_NAME_PETER, LocalDate.now(), USER_EMAIL2, ACTIVE_STATUS)); userRepository.save(new User("SAMPLE", LocalDate.now(), USER_EMAIL3, INACTIVE_STATUS)); - userRepository.findAll(new Sort(Sort.Direction.ASC, "name")); + userRepository.findAll(Sort.by(Sort.Direction.ASC, "name")); List usersSortByNameLength = userRepository.findAll(Sort.by("LENGTH(name)")); @@ -459,6 +450,8 @@ public class UserRepositoryCommon { userRepository.save(usr01); userRepository.save(usr02); + System.out.println(TimeZone.getDefault()); + List users = userRepository.findUsersWithGmailAddress(); assertEquals(1, users.size()); assertEquals(usr02, users.get(0)); From ffc79e7edd3d9825ce3f9ab3aaedd73efb15564b Mon Sep 17 00:00:00 2001 From: dupirefr Date: Fri, 17 Apr 2020 21:25:03 +0200 Subject: [PATCH 270/503] [JAVA-630] vavr-2 module * Creation * Moved https://www.baeldung.com/vavr-either code * Moved https://www.baeldung.com/java-vavr code --- pom.xml | 6 +++-- vavr-2/README.md | 8 ++++++ vavr-2/pom.xml | 27 +++++++++++++++++++ .../com/baeldung/vavr/either/EitherDemo.java | 0 .../baeldung/vavr/either/EitherUnitTest.java | 0 .../CollectionsInteroperabilityUnitTest.java | 0 vavr/README.md | 3 +-- 7 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 vavr-2/README.md create mode 100644 vavr-2/pom.xml rename {vavr => vavr-2}/src/main/java/com/baeldung/vavr/either/EitherDemo.java (100%) rename {vavr => vavr-2}/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java (100%) rename {vavr => vavr-2}/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java (100%) diff --git a/pom.xml b/pom.xml index 02d1ab6cd2..1b3c98994f 100644 --- a/pom.xml +++ b/pom.xml @@ -812,7 +812,8 @@ libraries vaadin - vavr + vavr + vavr-2 @@ -1310,7 +1311,8 @@ libraries vaadin - vavr + vavr + vavr-2 diff --git a/vavr-2/README.md b/vavr-2/README.md new file mode 100644 index 0000000000..71814a08fd --- /dev/null +++ b/vavr-2/README.md @@ -0,0 +1,8 @@ +## Vavr + +This module contains articles about Vavr. + +### Relevant Articles: +- [Introduction to Vavr’s Either](https://www.baeldung.com/vavr-either) +- [Interoperability Between Java and Vavr](https://www.baeldung.com/java-vavr) +- [[<-- prev]](/vavr) diff --git a/vavr-2/pom.xml b/vavr-2/pom.xml new file mode 100644 index 0000000000..d20dd9afef --- /dev/null +++ b/vavr-2/pom.xml @@ -0,0 +1,27 @@ + + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + 4.0.0 + + vavr-2 + vavr-2 + jar + + + + io.vavr + vavr-test + ${vavr.version} + + + + + 0.9.1 + + \ No newline at end of file diff --git a/vavr/src/main/java/com/baeldung/vavr/either/EitherDemo.java b/vavr-2/src/main/java/com/baeldung/vavr/either/EitherDemo.java similarity index 100% rename from vavr/src/main/java/com/baeldung/vavr/either/EitherDemo.java rename to vavr-2/src/main/java/com/baeldung/vavr/either/EitherDemo.java diff --git a/vavr/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java b/vavr-2/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java rename to vavr-2/src/test/java/com/baeldung/vavr/either/EitherUnitTest.java diff --git a/vavr/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java b/vavr-2/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java similarity index 100% rename from vavr/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java rename to vavr-2/src/test/java/com/baeldung/vavr/interoperability/CollectionsInteroperabilityUnitTest.java diff --git a/vavr/README.md b/vavr/README.md index 2b8bb25356..e04e02069f 100644 --- a/vavr/README.md +++ b/vavr/README.md @@ -13,5 +13,4 @@ This module contains articles about Vavr. - [Guide to Collections API in Vavr](https://www.baeldung.com/vavr-collections) - [Collection Factory Methods for Vavr](https://www.baeldung.com/vavr-collection-factory-methods) - [Introduction to Future in Vavr](https://www.baeldung.com/vavr-future) -- [Introduction to Vavr’s Either](https://www.baeldung.com/vavr-either) -- [Interoperability Between Java and Vavr](https://www.baeldung.com/java-vavr) +- [[next -->]](/vavr-2) From c4ed1770e266a0b9395a05fd47a2b04f82d47215 Mon Sep 17 00:00:00 2001 From: Arindum Roy Date: Sun, 19 Apr 2020 21:46:19 +0530 Subject: [PATCH 271/503] "first commit in new fork" --- .../baeldung/composite/BookApplication.java | 12 ++++ .../com/baeldung/composite/entity/Book.java | 47 ++++++++++++++ .../com/baeldung/composite/entity/BookId.java | 51 +++++++++++++++ .../composite/repository/BookRepository.java | 16 +++++ .../repository/BookRepositoryTest.java | 63 +++++++++++++++++++ 5 files changed, 189 insertions(+) create mode 100644 persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/BookApplication.java create mode 100644 persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/entity/Book.java create mode 100644 persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/entity/BookId.java create mode 100644 persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/repository/BookRepository.java create mode 100644 persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/composite/repository/BookRepositoryTest.java diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/BookApplication.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/BookApplication.java new file mode 100644 index 0000000000..52f06058aa --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/BookApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.composite; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class BookApplication { + + public static void main(String[] args) { + SpringApplication.run(BookApplication.class); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/entity/Book.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/entity/Book.java new file mode 100644 index 0000000000..e4f1727654 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/entity/Book.java @@ -0,0 +1,47 @@ +package com.baeldung.composite.entity; + +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; + +@Entity +public class Book { + + @EmbeddedId + private BookId id; + private String genre; + private Integer price; + + public Book() { + } + + public Book(String author, String name, String genre, Integer price) { + BookId id = new BookId(author, name); + this.id = id; + this.genre = genre; + this.price = price; + } + + public BookId getId() { + return id; + } + + public void setId(BookId id) { + this.id = id; + } + + public String getGenre() { + return genre; + } + + public void setGenre(String genre) { + this.genre = genre; + } + + public Integer getPrice() { + return price; + } + + public void setPrice(Integer price) { + this.price = price; + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/entity/BookId.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/entity/BookId.java new file mode 100644 index 0000000000..1524452412 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/entity/BookId.java @@ -0,0 +1,51 @@ +package com.baeldung.composite.entity; + +import javax.persistence.Embeddable; +import java.io.Serializable; +import java.util.Objects; + +@Embeddable +public class BookId implements Serializable { + + private String author; + private String name; + + public BookId() { + } + + public BookId(String author, String name) { + this.author = author; + this.name = name; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + BookId bookId = (BookId) o; + return Objects.equals(author, bookId.author) && Objects.equals(name, bookId.name); + } + + @Override + public int hashCode() { + return Objects.hash(author, name); + } +} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/repository/BookRepository.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/repository/BookRepository.java new file mode 100644 index 0000000000..3c09f909f0 --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/repository/BookRepository.java @@ -0,0 +1,16 @@ +package com.baeldung.composite.repository; + +import com.baeldung.composite.entity.Book; +import com.baeldung.composite.entity.BookId; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface BookRepository extends JpaRepository { + + List findByIdName(String name); + + List findByIdAuthor(String author); +} diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/composite/repository/BookRepositoryTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/composite/repository/BookRepositoryTest.java new file mode 100644 index 0000000000..590593982d --- /dev/null +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/composite/repository/BookRepositoryTest.java @@ -0,0 +1,63 @@ +package com.baeldung.composite.repository; + +import com.baeldung.composite.BookApplication; +import com.baeldung.composite.entity.Book; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +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.util.Arrays; +import java.util.List; + +import static org.junit.Assert.assertEquals; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = BookApplication.class) +public class BookRepositoryTest { + + public static final String JAVA_101 = "Java101"; + public static final String JANE = "Jane"; + @Autowired + BookRepository repository; + + @Before + public void setUp() { + Book book1 = new Book("John", JAVA_101, "Tech", 20); + Book book2 = new Book(JANE, JAVA_101, "Arch", 25); + Book book3 = new Book(JANE, "Scala101", "Tech", 23); + + repository.saveAll(Arrays.asList(book1, book2, book3)); + } + + @After + public void tearDown() { + repository.deleteAll(); + } + + @Test + public void testFindByName() { + List books = repository.findByIdName(JAVA_101); + + assertEquals(2, books.size()); + } + + @Test + public void testFindByAuthor() { + List books = repository.findByIdAuthor(JANE); + + assertEquals(2, books.size()); + } + + @Test + public void testFindByGenre() { + List books = repository.findByIdAuthor(JANE); + + assertEquals(2, books.size()); + } +} \ No newline at end of file From 647a6dc798f3674e6072e88ad158d41534cba232 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Sun, 19 Apr 2020 18:54:43 +0200 Subject: [PATCH 272/503] JAVA-1130: Update the x509 mutual authentication codebase --- .../spring-security-x509/keystore/Makefile | 92 ------------------ .../keystore/keystore.jks | Bin 9310 -> 0 bytes .../src/main/resources/application.properties | 2 +- .../x509/X509AuthenticationServer.java | 8 +- .../src/main/resources/application.properties | 4 +- .../src/main/resources/keystore.jks | Bin 9310 -> 0 bytes .../spring-security-x509/store/clientBob.p12 | Bin 0 -> 4024 bytes .../spring-security-x509/store/keystore.jks | Bin 0 -> 3718 bytes .../spring-security-x509/store/rootCA.crt | 30 ++++++ .../spring-security-x509/store/truststore.jks | Bin 0 -> 1358 bytes 10 files changed, 39 insertions(+), 97 deletions(-) delete mode 100644 spring-security-modules/spring-security-x509/keystore/Makefile delete mode 100644 spring-security-modules/spring-security-x509/keystore/keystore.jks delete mode 100644 spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/keystore.jks create mode 100644 spring-security-modules/spring-security-x509/store/clientBob.p12 create mode 100644 spring-security-modules/spring-security-x509/store/keystore.jks create mode 100644 spring-security-modules/spring-security-x509/store/rootCA.crt create mode 100644 spring-security-modules/spring-security-x509/store/truststore.jks diff --git a/spring-security-modules/spring-security-x509/keystore/Makefile b/spring-security-modules/spring-security-x509/keystore/Makefile deleted file mode 100644 index 2cd7c55c5b..0000000000 --- a/spring-security-modules/spring-security-x509/keystore/Makefile +++ /dev/null @@ -1,92 +0,0 @@ -PASSWORD=changeit -KEYSTORE=keystore.jks -HOSTNAME=localhost -CLIENTNAME=cid -CLIENT_PRIVATE_KEY="${CLIENTNAME}_pk" - -# CN = Common Name -# OU = Organization Unit -# O = Organization Name -# L = Locality Name -# ST = State Name -# C = Country (2-letter Country Code) -# E = Email -DNAME_CA='CN=Baeldung CA,OU=baeldung.com,O=Baeldung,L=SomeCity,ST=SomeState,C=CC' -# For server certificates, the Common Name (CN) must be the hostname -DNAME_HOST='CN=$(HOSTNAME),OU=baeldung.com,O=Baeldung,L=SomeCity,ST=SomeState,C=CC' -DNAME_CLIENT='CN=$(CLIENTNAME),OU=baeldung.com,O=Baeldung,L=SomeCity,ST=SomeState,C=CC' -TRUSTSTORE=truststore.jks - -all: clean create-keystore add-host create-truststore add-client - -create-keystore: - # Generate a certificate authority (CA) - keytool -genkey -alias ca -ext san=dns:localhost,ip:127.0.0.1 -ext BC=ca:true \ - -keyalg RSA -keysize 4096 -sigalg SHA512withRSA -keypass $(PASSWORD) \ - -validity 3650 -dname $(DNAME_CA) \ - -keystore $(KEYSTORE) -storepass $(PASSWORD) - -add-host: - # Generate a host certificate - keytool -genkey -alias $(HOSTNAME) -ext san=dns:localhost,ip:127.0.0.1 \ - -keyalg RSA -keysize 4096 -sigalg SHA512withRSA -keypass $(PASSWORD) \ - -validity 3650 -dname $(DNAME_HOST) \ - -keystore $(KEYSTORE) -storepass $(PASSWORD) - # Generate a host certificate signing request - keytool -certreq -alias $(HOSTNAME) -ext san=dns:localhost,ip:127.0.0.1 -ext BC=ca:true \ - -keyalg RSA -keysize 4096 -sigalg SHA512withRSA \ - -validity 3650 -file "$(HOSTNAME).csr" \ - -keystore $(KEYSTORE) -storepass $(PASSWORD) - # Generate signed certificate with the certificate authority - keytool -gencert -alias ca -ext san=dns:localhost,ip:127.0.0.1 \ - -validity 3650 -sigalg SHA512withRSA \ - -infile "$(HOSTNAME).csr" -outfile "$(HOSTNAME).crt" -rfc \ - -keystore $(KEYSTORE) -storepass $(PASSWORD) - # Import signed certificate into the keystore - keytool -import -trustcacerts -alias $(HOSTNAME) -ext san=dns:localhost,ip:127.0.0.1 \ - -file "$(HOSTNAME).crt" \ - -keystore $(KEYSTORE) -storepass $(PASSWORD) - -export-authority: - # Export certificate authority - keytool -export -alias ca -ext san=dns:localhost,ip:127.0.0.1 -file ca.crt -rfc \ - -keystore $(KEYSTORE) -storepass $(PASSWORD) - - -create-truststore: export-authority - # Import certificate authority into a new truststore - keytool -import -trustcacerts -noprompt -alias ca -ext san=dns:localhost,ip:127.0.0.1 -file ca.crt \ - -keystore $(TRUSTSTORE) -storepass $(PASSWORD) - -add-client: - # Generate client certificate - keytool -genkey -alias $(CLIENT_PRIVATE_KEY) -ext san=dns:localhost,ip:127.0.0.1 \ - -keyalg RSA -keysize 4096 -sigalg SHA512withRSA -keypass $(PASSWORD) \ - -validity 3650 -dname $(DNAME_CLIENT) \ - -keystore $(TRUSTSTORE) -storepass $(PASSWORD) - # Generate a host certificate signing request - keytool -certreq -alias $(CLIENT_PRIVATE_KEY) -ext san=dns:localhost,ip:127.0.0.1 -ext BC=ca:true \ - -keyalg RSA -keysize 4096 -sigalg SHA512withRSA \ - -validity 3650 -file "$(CLIENTNAME).csr" \ - -keystore $(TRUSTSTORE) -storepass $(PASSWORD) - # Generate signed certificate with the certificate authority - keytool -gencert -alias ca -ext san=dns:localhost,ip:127.0.0.1 \ - -validity 3650 -sigalg SHA512withRSA \ - -infile "$(CLIENTNAME).csr" -outfile "$(CLIENTNAME).crt" -rfc \ - -keystore $(KEYSTORE) -storepass $(PASSWORD) - # Import signed certificate into the truststore - keytool -import -trustcacerts -alias $(CLIENTNAME) -ext san=dns:localhost,ip:127.0.0.1 \ - -file "$(CLIENTNAME).crt" \ - -keystore $(TRUSTSTORE) -storepass $(PASSWORD) - # Export private certificate for importing into a browser - keytool -importkeystore -srcalias $(CLIENT_PRIVATE_KEY) -ext san=dns:localhost,ip:127.0.0.1 \ - -srckeystore $(TRUSTSTORE) -srcstorepass $(PASSWORD) \ - -destkeystore "$(CLIENTNAME).p12" -deststorepass $(PASSWORD) \ - -deststoretype PKCS12 - # Delete client private key as truststore should not contain any private keys - keytool -delete -alias $(CLIENT_PRIVATE_KEY) \ - -keystore $(TRUSTSTORE) -storepass $(PASSWORD) - -clean: - # Remove generated artifacts - find . \( -name "$(CLIENTNAME)*" -o -name "$(HOSTNAME)*" -o -name "$(KEYSTORE)" -o -name "$(TRUSTSTORE)" -o -name ca.crt \) -type f -exec rm -f {} \; diff --git a/spring-security-modules/spring-security-x509/keystore/keystore.jks b/spring-security-modules/spring-security-x509/keystore/keystore.jks de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zPDzZ(^UW8M6CbJ(R^Tzf9B}F zCCK&vGu{6qE`S66$1M97E&taP9R?2mZsUn+VPZ#cSW`j*r;hF5i|Bb|?4;A~c4)4T zj2qet?GJP>j6eE$JT0PRdaLS(1{J(%GV|S&I~fc@u?vZ|9KW#k%%qfP^($%{fZStf zsMnrs{$|$W9uLtmLfnwO6M`IU&>68`btUSnllXex4w}m4FsJ00dDNy1U#$OFy(z*E z9&geOIM9EGQpjux*0fS!zqN?()owHtMAWxPl>n$wzFKV>*V>rSix-6Fc5SZ0SAua#`-OET=yF>{7{$!Msu&NMw`&sHsD z2*V1<5&eZ{9m0QdoWR={8Dc{~*{3IOk_daNh;UlEqd(CNLVD%vGSh@DW-y2;iu;tM z=a^TMHd12gg>bYLD>v8v9xEqf?D{nNvycKZC7kgA&lz~4qH0R%<307C_oNku(1;GJ zANwIXlv!h*Y_eky)cF6Cq9s6LAj-eF`8_-lh#=^HPtN}V)^qhpa7B1iOanjcm59unb?)R5X_WbYc;rZdc73S$SsLBTU*t+bsZiisntJ> zI_?&W7Z{u_yP6r!+x+Jk#UKkCGKFgc*Se-%LjSSaiJ>Fvt|AuS$uvzDchY#+)Pf%2H_=Q_H`0AWk=PC5c2*p9TFy;` z?D9Kkh-`zhfmCJC-9ffm6BA`4GPM~WIr5Yt;(OJd2w3cNrQwXlXs!5r+fr&D02;;x z2r}02ukiE#Hj@26J=^~ZKmQee{ww_aSNQq=9)2DfHK&Tkcnh2)wqc~JTkbW0v3>ss DeRHq; diff --git a/spring-security-modules/spring-security-x509/spring-security-x509-basic-auth/src/main/resources/application.properties b/spring-security-modules/spring-security-x509/spring-security-x509-basic-auth/src/main/resources/application.properties index 53dfe9976a..208cc90b47 100644 --- a/spring-security-modules/spring-security-x509/spring-security-x509-basic-auth/src/main/resources/application.properties +++ b/spring-security-modules/spring-security-x509/spring-security-x509-basic-auth/src/main/resources/application.properties @@ -1,4 +1,4 @@ -server.ssl.key-store=keystore/keystore.jks +server.ssl.key-store=store/keystore.jks server.ssl.key-store-password=changeit server.ssl.key-alias=localhost server.ssl.key-password=changeit diff --git a/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/java/com/baeldung/spring/security/x509/X509AuthenticationServer.java b/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/java/com/baeldung/spring/security/x509/X509AuthenticationServer.java index 050423238e..18bbfba835 100644 --- a/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/java/com/baeldung/spring/security/x509/X509AuthenticationServer.java +++ b/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/java/com/baeldung/spring/security/x509/X509AuthenticationServer.java @@ -23,7 +23,11 @@ public class X509AuthenticationServer extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests().anyRequest().authenticated().and().x509().subjectPrincipalRegex("CN=(.*?)(?:,|$)").userDetailsService(userDetailsService()); + http.authorizeRequests().anyRequest().authenticated() + .and() + .x509() + .subjectPrincipalRegex("CN=(.*?)(?:,|$)") + .userDetailsService(userDetailsService()); } @Bean @@ -31,7 +35,7 @@ public class X509AuthenticationServer extends WebSecurityConfigurerAdapter { return new UserDetailsService() { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { - if (username.equals("cid")) { + if (username.equals("Bob")) { return new User(username, "", AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER")); } throw new UsernameNotFoundException("User not found!"); diff --git a/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/application.properties b/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/application.properties index 743c9c4582..b841a37916 100644 --- a/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/application.properties +++ b/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/application.properties @@ -1,4 +1,4 @@ -server.ssl.key-store=../keystore/keystore.jks +server.ssl.key-store=store/keystore.jks server.ssl.key-store-password=changeit server.ssl.key-alias=localhost server.ssl.key-password=changeit @@ -6,6 +6,6 @@ server.ssl.enabled=true server.port=8443 spring.security.user.name=Admin spring.security.user.password=admin -server.ssl.trust-store=../keystore/truststore.jks +server.ssl.trust-store=store/truststore.jks server.ssl.trust-store-password=changeit server.ssl.client-auth=need \ No newline at end of file diff --git a/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/keystore.jks b/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/keystore.jks deleted file mode 100644 index 044a820c39524f1ef3c470105dbaa82b63af0493..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9310 zcmeI1RZtz=wxu`jx^XALb#L6=g1fs0f=h6BhXf~Ba7%)_ySqbh3(iJ2*8hL|+`gx7 zb=|J&uCDuX9@fJcwH{Wjnse3s#(F(_Jp%v$u>V*v09Xq%002hY^G%Hw06+-`g`fn3 zFcDFi5n~TfheNF7*@(} zH7ckof*b8f@)k|FZ6p-N|4wIKUn}N@&LnT9SPu4ZFhj)BY{*gFM89DUQTzz~=I$%o zQl7$RjqC3<{go^{D~Slhe4)ZctgnBJoF@Sqlbu|0t}(%cmFTLcGOhx;ceYmOBR7VvKpsm?58(!!9L6)13xt9P8L@5S?WIOo(93 ze{B7l-IVcROzwbHk3cbMhm|}lc`cy8lF&I6t|g7q=9eMOr;^76I;>x}ltzro=~?ZW zp$Qh$4c;&_J(5gz{hq}^H}F0oZ3+Znc-GNDmDu-C1CyiKbjTS87T0W+*?mJC?L4Bj z%{&k%BckHf=b?Tx=74L4wr?uw533spZuWN*rFZ?Xm@g;kD9JV_cQGFN9{>a(kMQ-! zXJwmdY&mdB$E&?r@cLFKm--Rr7&lp<7WVY?}9WwGmP!{OJB}0`%k_LYC$p zV8yw$ZWh~fr^(b)BXOqam(WQYWH;4))bz}CA#DTAu3_0&r0qO!BtX(Qt}r29b7CtC zwe8^Bi^w73)$QPawVl@w&vjr~Unw1;FDCs)VfC&Oh-uBezK*YYhTxaiA-G_?q5!Ie z)V>6Yn3N_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store/clientBob.p12 b/spring-security-modules/spring-security-x509/store/clientBob.p12 new file mode 100644 index 0000000000000000000000000000000000000000..e5d6dbcefbfaffa2502b1ed9613bc1cb2f9ce573 GIT binary patch literal 4024 zcmY+GWmFW5v&MIqZh-}s7H}zvr9qICkdS6+q@+>cl?GwSrBgz>Te<`!q@`hLWC7`J z$?JR0z4w3bhdFc3^UTc0-#jn`Nj(UN0Yi{@W8-m#DurGV0dasi2oeWO1c}XG*%F4p z^7xO1orA!#{VQ34fPlZv-MCSZy*pZAOL{{Bb*WK z+Q7<^IQ0>{dto8^GS#!m3iTTR@sErIAjrY_ZaD&Xt9_WL>)htDtg>Y6i~!Q_bZTmEa}l>d})jt@Dbhav#Be0ycXDcBFecnmQuV&%6NFb+V1* z^;0ZEheC>1x$N9e>YrUX^z*}mW9f;g%!%YkYrF}^`i$6HvgwaD#kht=&FSMX*(PLu zUX}j3X@&-Y9uNC^I#iMEner`-6qB8^4_~qqP3Eexx=)fjW=^(JV=K>!Bv@ykMkCQd zmFfP$!t-{d4b~H`A?;lz!}my*%(?oFS5-emg3s0R{HSWyvvKrd-xGBY#Hzq^3TLj> z2i4b1Pb>ftI%T=j&?}bx&`vFVO!p>znntW0<)vMexnSQU%rdWH_+g?%s<0q8?B*R$ zK1>((*+%)q;75B?llfXlzi43L+bu~OJ7;Jzy4BEALQ0Q^v)l%{=kkxC7h%MW@I-E+ zas7bTC&Eo86o!PKDJ^8Lg=pR}B_)SaaX@opyQ|Zn78LX?GrXv_03T!HUUSrKK(EDg zNpfJT8Q0{LvAtmUXSj>GCJEPWY?9k1iARi#Hqr*Pw2TieWwyd@Vsd$*mZTIiBOCfV zR!+_Q8ay58pv+qHq1SQGTuHpj4GrKP1jL_>wJmF$WV_}!!yK%((lQlcCtmqU4s(Tk zyTtMF^VjbnY_p$?JheGW;tI3hr@PW)!u_4-$^0DL3Ih8Se-JX7YR9$@AJ~=X{z~p{ z?dM#}<~xJiD|VgmX_+N!5K|)6ejpGKZLszEp_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is7bGnbrpf3r=K>MxRVCtG4xh-M1YSWS+PuXl|5K5HP@^ z@1Kf-e$3_x@K?T6-L)J=`5lTA$0yJNbYyE$nlSfd3IXhJXU~cRT#VcK*e&4)YczYKNkox) zb?O4~`{d|?5e6T{nCNG`B`t%Y$MHQaOuW(tBiUG-iPeny$DOi)I1l5Fgiz*~;Y(s0 z45NkdVCQnV5X%bV*8U+(-;uK_t+j`x+X%NJbrUjddB#>Fv7{^S zM36(oNsVphOg}ykVgPeAKW(@w-;wwZ6?(o3Ja}}i7>P!`JpQ`Fa;YY*s?ex+Crk<) z5nc^!KyA~i9#s_19;bCJvC&mELU;!|}ImmJ8#ohgG`+9>T;Nm5|6`9fs SChlA@P5Y@C!_vP&?!N$UlZxN~ literal 0 HcmV?d00001 diff --git a/spring-security-modules/spring-security-x509/store/keystore.jks b/spring-security-modules/spring-security-x509/store/keystore.jks new file mode 100644 index 0000000000000000000000000000000000000000..8650651a1e0a884555a4219049340ce2314315cb GIT binary patch literal 3718 zcmV;14teqZ?f&fm00062000310003132bj;VQgq`b94Xz0dbQ&M@0Yt35GC&34$;V z1_~<%0R#am0uccL1pows32rNAa~=30@#)sPusNSPpYM9DPy23*4-aHo04-h{jCIs} z7)=iUt%sNL(Jennb!D8myQV8`R&KL-`G2egVkL28!Pm1P7YSl=_!7Uk1poWrfI_uV zCu7&o(+c?m(O)JJO3W-=P8*-piXbaPNP})&2Kc7}aZyAf2&KW|BiJTE#2hmCG zl_F+~G2CIjSc4?oH*H)PaHv+Y+YHiwbWY&>nR{^o!0AGezfnQ2%sNxIEMv#J|{(bTdb2vJx>&iKkWs7fAmB^c~ z+vT-`E@^;tw9)3<(S77S+sKNr!L!NKEfYP4UDL{t5|9xo^BlWoE|_P#ex8V_L_h)# zUqTIN4Ch%3FCjcYs!qVsA?iECq9<4#mNyaBmGm08Eo2V04=JurlX{?Kj?xu0(up!3 zy>GPcV8Ib-7McRnaJEn+N~SN}zRPGD_At;*u|`G{8cbL{vE;MR(dtR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3>k!3Kc_vcPmF%f}+dBJxQvl(Soo z=TPMDBWBa5xaB_Hp0vY29we>IB4HrbfL#GUNP#dT<9`-b17;wFoa}&U8<^}E8Pay; zebn#TwpV0c<<~9w^A_inu9@Bce!`dTz>_cDuzh;BWJe-bVHkJR^}E^gmn&{;WLWoL z=YyY9->QqOczDVCG3(*_sdj%nxGxn4#EB?QJhkkWuNxZ!|D1)ozi%GBU%N~2gvZ;M zYSlOf>+?yq*YDh&_v*{xX~Nw~>-svkta}=n{{GD#;jiq@(O);bXJxQh?wJ(Icy6(T zJR{?r4qs#K)+&R~#fi%%&gkfg+L^P8S8TSjj3&Q)!(BcRu5z}ms?ullcl}Xv&C)N< z@S3}Rf~>WXOOo6b?x(W*5A{kO-**E-gD3D1RFrm1-CeZKbAvKgL{4}&FC*7<$6{b(+^U$i;;V4Pmt zv=YHOzmC{4^Q{*|w<&tR_Lz90PnLUW66Z^n8$VZW(21SmsiDp~hdeXV-epP%lLX{{Pt~YuAkgeTRL%j-Pav1UuxNS z9G07G_!P#)_@z?sMs=5H(tpdsH0#^(y3D_O{F^7Y9jblszw$@S4hKVfYpsuWzDC@Z zySMI8(u4W>yZHG%nwAAWDG8X{u^;1It literal 0 HcmV?d00001 From 60b00e38b6c5e1940bdbb7bae6baf38925765f1b Mon Sep 17 00:00:00 2001 From: Arindum Roy Date: Sun, 19 Apr 2020 23:03:39 +0530 Subject: [PATCH 273/503] "first commit in new fork" --- ...okRepositoryTest.java => BookRepositoryIntegrationTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/composite/repository/{BookRepositoryTest.java => BookRepositoryIntegrationTest.java} (97%) diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/composite/repository/BookRepositoryTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/composite/repository/BookRepositoryIntegrationTest.java similarity index 97% rename from persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/composite/repository/BookRepositoryTest.java rename to persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/composite/repository/BookRepositoryIntegrationTest.java index 590593982d..362950bea9 100644 --- a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/composite/repository/BookRepositoryTest.java +++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/composite/repository/BookRepositoryIntegrationTest.java @@ -19,7 +19,7 @@ import static org.junit.Assert.assertEquals; @RunWith(SpringRunner.class) @SpringBootTest(classes = BookApplication.class) -public class BookRepositoryTest { +public class BookRepositoryIntegrationTest { public static final String JAVA_101 = "Java101"; public static final String JANE = "Jane"; From 0a42d945f85a0418e7e8de9980ff601f5ecb3ccf Mon Sep 17 00:00:00 2001 From: Sasa M Date: Sun, 19 Apr 2020 21:02:17 +0200 Subject: [PATCH 274/503] Source project for the draft article --- model-mapper/src/Main.java | 58 +++++++++++++++ model-mapper/src/com/baeldung/model/User.java | 70 +++++++++++++++++++ .../src/com/baeldung/model/UserDTO.java | 49 +++++++++++++ .../src/com/baeldung/model/UserList.java | 21 ++++++ .../src/com/baeldung/util/MapperUtil.java | 47 +++++++++++++ .../com/baeldung/util/UserPropertyMap.java | 36 ++++++++++ 6 files changed, 281 insertions(+) create mode 100644 model-mapper/src/Main.java create mode 100644 model-mapper/src/com/baeldung/model/User.java create mode 100644 model-mapper/src/com/baeldung/model/UserDTO.java create mode 100644 model-mapper/src/com/baeldung/model/UserList.java create mode 100644 model-mapper/src/com/baeldung/util/MapperUtil.java create mode 100644 model-mapper/src/com/baeldung/util/UserPropertyMap.java diff --git a/model-mapper/src/Main.java b/model-mapper/src/Main.java new file mode 100644 index 0000000000..a6deb49168 --- /dev/null +++ b/model-mapper/src/Main.java @@ -0,0 +1,58 @@ +import com.baeldung.model.User; +import com.baeldung.model.UserDTO; +import com.baeldung.model.UserList; +import com.baeldung.util.MapperUtil; +import com.baeldung.util.UserPropertyMap; +import org.modelmapper.ModelMapper; +import org.modelmapper.TypeToken; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author sasam0320 + * @date 4/18/2020 + */ + +public class Main { + + public static void main(String[] args) { + + //Instantiate ModelMapper + + ModelMapper mapper = new ModelMapper(); + mapper.addMappings(new UserPropertyMap()); + + // Mapping lists using TypeToken generic class + + List integers = new ArrayList(); + + integers.add(1); + integers.add(2); + integers.add(3); + + List characters = mapper.map(integers, new TypeToken>() {}.getType()); + + System.out.println("Character list: " + characters); + + // Mapping lists using generic type methods + + List users = new ArrayList(); + users.add(new User("b100", "user1", "user1@baeldung.com", "111-222", "USER")); + users.add(new User("b101", "user2", "user2@baeldung.com", "111-333", "USER")); + users.add(new User("b102", "user3", "user3@baeldung.com", "111-444", "ADMIN")); + + List userDtoList = MapperUtil.mapList(users, UserDTO.class); + userDtoList.stream().map(userDto -> userDto.getEmail()).forEachOrdered(System.out::println); + + // Mapping lists using PropertyMap and Converter + + UserList userList = new UserList(); + userList.setUsers(users); + UserDTO dto = new UserDTO(); + + mapper.map(userList, dto); + dto.getUsernames().forEach(System.out::println); + + } +} diff --git a/model-mapper/src/com/baeldung/model/User.java b/model-mapper/src/com/baeldung/model/User.java new file mode 100644 index 0000000000..73e4baafb5 --- /dev/null +++ b/model-mapper/src/com/baeldung/model/User.java @@ -0,0 +1,70 @@ +package com.baeldung.model; + +import java.util.List; + +/** + * @author sasam0320 + * @date 4/18/2020 + */ +public class User { + + private String userId; + private String userName; + private String email; + private String contactNumber; + private String userType; + + // Standard constructors, getters and setters + + public User(){} + + public User(String userId, String userName, String email, String contactNumber, String userType) { + this.userId = userId; + this.userName = userName; + this.email = email; + this.contactNumber = contactNumber; + this.userType = userType; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getContactNumber() { + return contactNumber; + } + + public void setContactNumber(String contactNumber) { + this.contactNumber = contactNumber; + } + + public String getUserType() { + return userType; + } + + public void setUserType(String userType) { + this.userType = userType; + } + + +} diff --git a/model-mapper/src/com/baeldung/model/UserDTO.java b/model-mapper/src/com/baeldung/model/UserDTO.java new file mode 100644 index 0000000000..ed056ace8c --- /dev/null +++ b/model-mapper/src/com/baeldung/model/UserDTO.java @@ -0,0 +1,49 @@ +package com.baeldung.model; + +import java.util.List; + +/** + * @author sasam0320 + * @date 4/18/2020 + */ +public class UserDTO { + + private String userId; + private String userName; + private String email; + private List usernames; + + // getters and setters + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public List getUsernames() { + return usernames; + } + + public void setUsernames(List usernames) { + this.usernames = usernames; + } +} diff --git a/model-mapper/src/com/baeldung/model/UserList.java b/model-mapper/src/com/baeldung/model/UserList.java new file mode 100644 index 0000000000..b30d5507d5 --- /dev/null +++ b/model-mapper/src/com/baeldung/model/UserList.java @@ -0,0 +1,21 @@ +package com.baeldung.model; + +import java.util.Collection; + +/** + * @author sasam0320 + * @date 4/18/2020 + */ + +public class UserList { + + private Collection users; + + public Collection getUsers() { + return users; + } + + public void setUsers(Collection users) { + this.users = users; + } +} diff --git a/model-mapper/src/com/baeldung/util/MapperUtil.java b/model-mapper/src/com/baeldung/util/MapperUtil.java new file mode 100644 index 0000000000..fe10b7777d --- /dev/null +++ b/model-mapper/src/com/baeldung/util/MapperUtil.java @@ -0,0 +1,47 @@ +package com.baeldung.util; + +import org.modelmapper.ModelMapper; +import org.modelmapper.convention.MatchingStrategies; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author sasam0320 + * @date 4/18/2020 + */ +public class MapperUtil { + + + private static ModelMapper modelMapper = new ModelMapper(); + + + static { + + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + + } + + private MapperUtil() { + + + } + + public static T mapTo(final S source, final Class target) { + + return modelMapper.map(source, target); + } + + public static List mapList(final List sourceList, final Class target) { + + List targetList = new ArrayList(); + + for (S source : sourceList) { + + targetList.add(modelMapper.map(source, target)); + } + + return targetList; + } + +} diff --git a/model-mapper/src/com/baeldung/util/UserPropertyMap.java b/model-mapper/src/com/baeldung/util/UserPropertyMap.java new file mode 100644 index 0000000000..4346174440 --- /dev/null +++ b/model-mapper/src/com/baeldung/util/UserPropertyMap.java @@ -0,0 +1,36 @@ +package com.baeldung.util; + +import com.baeldung.model.User; +import com.baeldung.model.UserDTO; +import com.baeldung.model.UserList; +import org.modelmapper.AbstractConverter; +import org.modelmapper.Converter; +import org.modelmapper.PropertyMap; +import java.util.ArrayList; +import java.util.List; + +/** + * @author sasam0320 + * @date 4/18/2020 + */ + +public class UserPropertyMap extends PropertyMap { + + + Converter, List> converter = new AbstractConverter, List>() { + + List usernames = new ArrayList<>(); + + protected List convert(List users) { + + users.forEach(user -> usernames.add(user.getUserName())); + return usernames; + } + + }; + + @Override + protected void configure() { + using(converter).map(source.getUsers(), destination.getUsernames()); + } +} From 3233f80c5b0df473890982e561c41cea53e06a28 Mon Sep 17 00:00:00 2001 From: sergio41 Date: Sun, 19 Apr 2020 22:37:21 +0200 Subject: [PATCH 275/503] [BAEL-3944] Code Upload --- .../com/baeldung/regex/RegexUnitTest.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/RegexUnitTest.java b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/RegexUnitTest.java index b3c3a91a09..909894ec55 100644 --- a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/RegexUnitTest.java +++ b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/RegexUnitTest.java @@ -481,6 +481,50 @@ public class RegexUnitTest { } + @Test + public void whenMatchesTenDigitsNumber_thenCorrect() { + Pattern pattern = Pattern.compile("^\\d{10}$"); + Matcher matcher = pattern.matcher("1234567890"); + assertTrue(matcher.matches()); + } + + @Test + public void whenMatchesTenDigitsNumberWhitespacesHyphen_thenCorrect() { + Pattern pattern = Pattern.compile("^(\\d{3}[- ]?){2}\\d{4}$"); + Matcher matcher = pattern.matcher("123 456 7890"); + assertTrue(matcher.matches()); + } + + @Test + public void whenMatchesTenDigitsNumberParenthesis_thenCorrect() { + Pattern pattern = Pattern.compile("^\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$"); + Matcher matcher = pattern.matcher("(123)-456-7890"); + assertTrue(matcher.matches()); + } + + @Test + public void whenMatchesTenDigitsNumberPrefix_thenCorrect() { + Pattern pattern = Pattern.compile("^(\\+\\d{1,3}( )?)?\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$"); + Matcher matcher = pattern.matcher("+111 (123)-456-7890"); + assertTrue(matcher.matches()); + } + + @Test + public void whenMatchesPhoneNumber_thenCorrect() { + String patterns = "^(\\+\\d{1,3}( )?)?\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$" + + "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?){2}\\d{3}$" + + "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?)(\\d{2}[ ]?){2}\\d{2}$"; + + String[] validPhoneNumbers = {"1234567890","123 456 7890", "(123)-456-7890", "+111 (123)-456-7890", + "123 456 789", "+111 123 456 789", "123 45 67 89", "+111 123 45 67 89"}; + + Pattern pattern = Pattern.compile(patterns); + for(String phoneNumber : validPhoneNumbers) { + Matcher matcher = pattern.matcher(phoneNumber); + assertTrue(matcher.matches()); + } + } + public synchronized static int runTest(String regex, String text) { pattern = Pattern.compile(regex); matcher = pattern.matcher(text); From 9d993fc5bbf4ac4ce22b042b0104aa8affb3ea0f Mon Sep 17 00:00:00 2001 From: Kostas Karavitis Date: Mon, 20 Apr 2020 00:29:56 +0300 Subject: [PATCH 276/503] [BAEL-3936] Changed test methods names to follow BDD naming conventions --- .../unrelated/entities/UnrelatedEntitiesUnitTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java index 8733b3e7da..569b093db6 100644 --- a/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java +++ b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java @@ -40,7 +40,7 @@ public class UnrelatedEntitiesUnitTest { @Test - public void whenQueryingForCocktailThatHasRecipe_thenTheExpectedCocktailReturned() { + public void givenCocktailsWithRecipe_whenQuerying_thenTheExpectedCocktailsReturned() { // JPA Cocktail cocktail = entityManager.createQuery("select c " + "from Cocktail c join c.recipe", Cocktail.class) @@ -67,7 +67,7 @@ public class UnrelatedEntitiesUnitTest { } @Test - public void whenQueryingForCocktailThatHasNotARecipe_thenTheExpectedCocktailReturned() { + public void givenCocktailsWithoutRecipe_whenQuerying_thenTheExpectedCocktailsReturned() { Cocktail cocktail = entityManager.createQuery("select c " + "from Cocktail c left join c.recipe r " + "where r is null", Cocktail.class) @@ -97,7 +97,7 @@ public class UnrelatedEntitiesUnitTest { } @Test - public void whenQueringForCocktailThatHasRecipes_thenTheExpectedCocktailReturned() { + public void givenCocktailsWithMultipleRecipes_whenQuerying_thenTheExpectedCocktailsReturned() { // JPQL Cocktail cocktail = entityManager.createQuery("select c " + "from Cocktail c join c.recipeList", Cocktail.class) @@ -124,7 +124,7 @@ public class UnrelatedEntitiesUnitTest { } @Test - public void whenQueryingForCocktailThatHasNotRecipes_thenTheExpectedCocktailReturned() { + public void givenCocktailsWithoutMultipleRecipes_whenQuerying_thenTheExpectedCocktailsReturned() { // JPQL Cocktail cocktail = entityManager.createQuery("select c " + "from Cocktail c left join c.recipeList r " @@ -156,7 +156,7 @@ public class UnrelatedEntitiesUnitTest { } @Test - public void whenQueryingForMultipleRecipes_thenTheExpectedRecipesReturned() { + public void givenMultipleRecipesWithCocktails_whenQuerying_thenTheExpectedMultipleRecipesReturned() { Consumer> verifyResult = recipes -> { assertEquals(2, recipes.size()); recipes.forEach(r -> assertEquals(mojito.getName(), r.getCocktail())); From 7b0c9d508f38ceb812bae691606755c53b897870 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Mon, 20 Apr 2020 12:00:03 +0300 Subject: [PATCH 277/503] Update README.md --- libraries-data-2/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries-data-2/README.md b/libraries-data-2/README.md index 24618b5e37..f96fab5120 100644 --- a/libraries-data-2/README.md +++ b/libraries-data-2/README.md @@ -11,4 +11,7 @@ This module contains articles about libraries for data processing in Java. - [Guide to JMapper](https://www.baeldung.com/jmapper) - [An Introduction to SuanShu](https://www.baeldung.com/suanshu) - [Intro to Derive4J](https://www.baeldung.com/derive4j) -More articles: [[<-- prev]](/../libraries-data) \ No newline at end of file +More articles: [[<-- prev]](/../libraries-data) + +#Building the project +You can build the project from the command line using: mvn clean install, or in an IDE. If you have issues with the derive4j imports in your IDE, you have to add the folder: target/generated-sources/annotations to the project build path in your IDE. From f55d344629d3a148ed5fce139bf3fc688cf8962c Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Mon, 20 Apr 2020 12:01:27 +0300 Subject: [PATCH 278/503] Update README.md --- libraries-data-2/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries-data-2/README.md b/libraries-data-2/README.md index f96fab5120..f992186bd9 100644 --- a/libraries-data-2/README.md +++ b/libraries-data-2/README.md @@ -13,5 +13,5 @@ This module contains articles about libraries for data processing in Java. - [Intro to Derive4J](https://www.baeldung.com/derive4j) More articles: [[<-- prev]](/../libraries-data) -#Building the project -You can build the project from the command line using: mvn clean install, or in an IDE. If you have issues with the derive4j imports in your IDE, you have to add the folder: target/generated-sources/annotations to the project build path in your IDE. +##### Building the project +You can build the project from the command line using: *mvn clean install*, or in an IDE. If you have issues with the derive4j imports in your IDE, you have to add the folder: *target/generated-sources/annotations* to the project build path in your IDE. From 8da24b4abe906ab8dae62e007a0f13b1d097c50b Mon Sep 17 00:00:00 2001 From: Vikas Rajput Date: Mon, 20 Apr 2020 19:01:55 +0300 Subject: [PATCH 279/503] BAEL-3557: Completed a simple web application in spring boot and groovy (#9152) Co-authored-by: Vikas Ramsingh Rajput --- spring-boot-groovy/pom.xml | 83 ++++++++++++++++ .../app/SpringBootGroovyApplication.groovy | 13 +++ .../app/controller/TodoController.groovy | 48 +++++++++ .../com/baeldung/app/entity/Todo.groovy | 23 +++++ .../app/repository/TodoRepository.groovy | 9 ++ .../baeldung/app/service/TodoService.groovy | 16 +++ .../app/service/impl/TodoServiceImpl.groovy | 40 ++++++++ .../src/main/resources/application.properties | 5 + .../com/baeldung/app/TodoAppUnitTest.groovy | 97 +++++++++++++++++++ 9 files changed, 334 insertions(+) create mode 100644 spring-boot-groovy/pom.xml create mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/app/SpringBootGroovyApplication.groovy create mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/app/controller/TodoController.groovy create mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/app/entity/Todo.groovy create mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/app/repository/TodoRepository.groovy create mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/app/service/TodoService.groovy create mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/app/service/impl/TodoServiceImpl.groovy create mode 100644 spring-boot-groovy/src/main/resources/application.properties create mode 100644 spring-boot-groovy/src/test/groovy/com/baeldung/app/TodoAppUnitTest.groovy diff --git a/spring-boot-groovy/pom.xml b/spring-boot-groovy/pom.xml new file mode 100644 index 0000000000..f61398c5d6 --- /dev/null +++ b/spring-boot-groovy/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + com.baeldung.app + spring-boot-groovy + spring-boot-groovy + war + Spring Boot Todo Application with Groovy + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + org.codehaus.groovy + groovy + + + + org.springframework.boot + spring-boot-starter-test + test + + + com.h2database + h2 + runtime + + + net.bytebuddy + byte-buddy-dep + 1.10.9 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.codehaus.gmavenplus + gmavenplus-plugin + 1.9.0 + + + + addSources + addTestSources + generateStubs + compile + generateTestStubs + compileTests + removeStubs + removeTestStubs + + + + + + + + + com.baeldung.app.SpringBootGroovyApplication + + + diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/SpringBootGroovyApplication.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/app/SpringBootGroovyApplication.groovy new file mode 100644 index 0000000000..226a2ff53d --- /dev/null +++ b/spring-boot-groovy/src/main/groovy/com/baeldung/app/SpringBootGroovyApplication.groovy @@ -0,0 +1,13 @@ +package com.baeldung.app + +import org.springframework.boot.SpringApplication +import org.springframework.boot.autoconfigure.SpringBootApplication + +import com.baeldung.app.SpringBootGroovyApplication + +@SpringBootApplication +class SpringBootGroovyApplication { + static void main(String[] args) { + SpringApplication.run SpringBootGroovyApplication, args + } +} diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/controller/TodoController.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/app/controller/TodoController.groovy new file mode 100644 index 0000000000..02f6d0223b --- /dev/null +++ b/spring-boot-groovy/src/main/groovy/com/baeldung/app/controller/TodoController.groovy @@ -0,0 +1,48 @@ +package com.baeldung.app.controller + +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.web.bind.annotation.DeleteMapping +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.PutMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestMethod +import org.springframework.web.bind.annotation.RestController + +import com.baeldung.app.entity.Todo +import com.baeldung.app.service.TodoService + +@RestController +@RequestMapping('todo') +public class TodoController { + + @Autowired + TodoService todoService + + @GetMapping + List getAllTodoList(){ + todoService.findAll() + } + + @PostMapping + Todo saveTodo(@RequestBody Todo todo){ + todoService.saveTodo todo + } + + @PutMapping + Todo updateTodo(@RequestBody Todo todo){ + todoService.updateTodo todo + } + + @DeleteMapping('/{todoId}') + deleteTodo(@PathVariable Integer todoId){ + todoService.deleteTodo todoId + } + + @GetMapping('/{todoId}') + Todo getTodoById(@PathVariable Integer todoId){ + todoService.findById todoId + } +} \ No newline at end of file diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/entity/Todo.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/app/entity/Todo.groovy new file mode 100644 index 0000000000..9f1253c5b3 --- /dev/null +++ b/spring-boot-groovy/src/main/groovy/com/baeldung/app/entity/Todo.groovy @@ -0,0 +1,23 @@ +package com.baeldung.app.entity + +import javax.persistence.Column +import javax.persistence.Entity +import javax.persistence.GeneratedValue +import javax.persistence.GenerationType +import javax.persistence.Id +import javax.persistence.Table + +@Entity +@Table(name = 'todo') +class Todo { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + Integer id + + @Column + String task + + @Column + Boolean isCompleted + +} diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/repository/TodoRepository.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/app/repository/TodoRepository.groovy new file mode 100644 index 0000000000..c0b35cc37d --- /dev/null +++ b/spring-boot-groovy/src/main/groovy/com/baeldung/app/repository/TodoRepository.groovy @@ -0,0 +1,9 @@ +package com.baeldung.app.repository + +import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.stereotype.Repository + +import com.baeldung.app.entity.Todo + +@Repository +interface TodoRepository extends JpaRepository {} \ No newline at end of file diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/service/TodoService.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/app/service/TodoService.groovy new file mode 100644 index 0000000000..0a59d93330 --- /dev/null +++ b/spring-boot-groovy/src/main/groovy/com/baeldung/app/service/TodoService.groovy @@ -0,0 +1,16 @@ +package com.baeldung.app.service + +import com.baeldung.app.entity.Todo + +interface TodoService { + + List findAll() + + Todo findById(Integer todoId) + + Todo saveTodo(Todo todo) + + Todo updateTodo(Todo todo) + + Todo deleteTodo(Integer todoId) +} diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/service/impl/TodoServiceImpl.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/app/service/impl/TodoServiceImpl.groovy new file mode 100644 index 0000000000..6d0ee03a9f --- /dev/null +++ b/spring-boot-groovy/src/main/groovy/com/baeldung/app/service/impl/TodoServiceImpl.groovy @@ -0,0 +1,40 @@ +package com.baeldung.app.service.impl + +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.stereotype.Service + +import com.baeldung.app.entity.Todo +import com.baeldung.app.repository.TodoRepository +import com.baeldung.app.service.TodoService + +@Service +class TodoServiceImpl implements TodoService { + + @Autowired + TodoRepository todoRepository + + @Override + List findAll() { + todoRepository.findAll() + } + + @Override + Todo findById(Integer todoId) { + todoRepository.findById todoId get() + } + + @Override + Todo saveTodo(Todo todo){ + todoRepository.save todo + } + + @Override + Todo updateTodo(Todo todo){ + todoRepository.save todo + } + + @Override + Todo deleteTodo(Integer todoId){ + todoRepository.deleteById todoId + } +} diff --git a/spring-boot-groovy/src/main/resources/application.properties b/spring-boot-groovy/src/main/resources/application.properties new file mode 100644 index 0000000000..8d53a190bb --- /dev/null +++ b/spring-boot-groovy/src/main/resources/application.properties @@ -0,0 +1,5 @@ +spring.datasource.url=jdbc:h2:mem:todo +spring.datasource.driverClassName=org.h2.Driver +spring.datasource.username=sa +spring.datasource.password=sa +spring.jpa.database-platform=org.hibernate.dialect.H2Dialect \ No newline at end of file diff --git a/spring-boot-groovy/src/test/groovy/com/baeldung/app/TodoAppUnitTest.groovy b/spring-boot-groovy/src/test/groovy/com/baeldung/app/TodoAppUnitTest.groovy new file mode 100644 index 0000000000..faf2d64ba7 --- /dev/null +++ b/spring-boot-groovy/src/test/groovy/com/baeldung/app/TodoAppUnitTest.groovy @@ -0,0 +1,97 @@ +package com.baeldung.app + +import static org.junit.jupiter.api.Assertions.assertEquals +import static org.junit.jupiter.api.Assertions.assertTrue + +import org.junit.BeforeClass +import org.junit.Test +import org.junit.runner.RunWith +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.test.context.event.annotation.BeforeTestClass +import org.springframework.test.context.junit4.SpringRunner + +import com.baeldung.app.entity.Todo + +import io.restassured.RestAssured +import io.restassured.response.Response + +class TodoAppUnitTest { + static API_ROOT = 'http://localhost:8081/todo' + static readingTodoId + static writingTodoId + + @BeforeClass + static void populateDummyData() { + Todo readingTodo = new Todo(task: 'Reading', isCompleted: false) + Todo writingTodo = new Todo(task: 'Writing', isCompleted: false) + + final Response readingResponse = + RestAssured.given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(readingTodo).post(API_ROOT) + + Todo cookingTodoResponse = readingResponse.as Todo.class + readingTodoId = cookingTodoResponse.getId() + + final Response writingResponse = + RestAssured.given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(writingTodo).post(API_ROOT) + + Todo writingTodoResponse = writingResponse.as Todo.class + writingTodoId = writingTodoResponse.getId() + } + + @Test + void whenGetAllTodoList_thenOk(){ + final Response response = RestAssured.get(API_ROOT) + + assertEquals HttpStatus.OK.value(),response.getStatusCode() + assertTrue response.as(List.class).size() > 0 + } + + @Test + void whenGetTodoById_thenOk(){ + final Response response = + RestAssured.get("$API_ROOT/$readingTodoId") + + assertEquals HttpStatus.OK.value(),response.getStatusCode() + Todo todoResponse = response.as Todo.class + assertEquals readingTodoId,todoResponse.getId() + } + + @Test + void whenUpdateTodoById_thenOk(){ + Todo todo = new Todo(id:readingTodoId, isCompleted: true) + final Response response = + RestAssured.given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(todo).put(API_ROOT) + + assertEquals HttpStatus.OK.value(),response.getStatusCode() + Todo todoResponse = response.as Todo.class + assertTrue todoResponse.getIsCompleted() + } + + @Test + void whenDeleteTodoById_thenOk(){ + final Response response = + RestAssured.given() + .delete("$API_ROOT/$writingTodoId") + + assertEquals HttpStatus.OK.value(),response.getStatusCode() + } + + @Test + void whenSaveTodo_thenOk(){ + Todo todo = new Todo(task: 'Blogging', isCompleted: false) + final Response response = + RestAssured.given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(todo).post(API_ROOT) + + assertEquals HttpStatus.OK.value(),response.getStatusCode() + } +} \ No newline at end of file From 6dcb364fe7ca11aab44ddb190227fb5a9cc0946a Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 20 Apr 2020 22:42:22 +0530 Subject: [PATCH 280/503] JAVA-917: Migrate jhipster-5 to parent-boot-2 --- jhipster-5/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jhipster-5/pom.xml b/jhipster-5/pom.xml index cebbe25d8b..2a5132e50e 100644 --- a/jhipster-5/pom.xml +++ b/jhipster-5/pom.xml @@ -9,10 +9,10 @@ pom - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 From 1639ead274ffbb256016ec36f6fa6f7a1c08cd58 Mon Sep 17 00:00:00 2001 From: Donato Rimenti Date: Mon, 20 Apr 2020 19:36:51 +0200 Subject: [PATCH 281/503] [BAEL-3489] Added Java-R integration examples. --- libraries-data-2/pom.xml | 43 +++++++++++++++++++ .../main/java/com/baeldung/r/FastRMean.java | 28 ++++++++++++ .../main/java/com/baeldung/r/RCallerMean.java | 36 ++++++++++++++++ .../src/main/java/com/baeldung/r/RUtils.java | 30 +++++++++++++ .../main/java/com/baeldung/r/RenjinMean.java | 36 ++++++++++++++++ .../main/java/com/baeldung/r/RserveMean.java | 29 +++++++++++++ .../com/baeldung/r/FastRMeanUnitTest.java | 29 +++++++++++++ .../r/RCallerMeanIntegrationTest.java | 37 ++++++++++++++++ .../com/baeldung/r/RenjinMeanUnitTest.java | 37 ++++++++++++++++ libraries-data-2/src/test/resources/script.R | 3 ++ 10 files changed, 308 insertions(+) create mode 100644 libraries-data-2/src/main/java/com/baeldung/r/FastRMean.java create mode 100644 libraries-data-2/src/main/java/com/baeldung/r/RCallerMean.java create mode 100644 libraries-data-2/src/main/java/com/baeldung/r/RUtils.java create mode 100644 libraries-data-2/src/main/java/com/baeldung/r/RenjinMean.java create mode 100644 libraries-data-2/src/main/java/com/baeldung/r/RserveMean.java create mode 100644 libraries-data-2/src/test/java/com/baeldung/r/FastRMeanUnitTest.java create mode 100644 libraries-data-2/src/test/java/com/baeldung/r/RCallerMeanIntegrationTest.java create mode 100644 libraries-data-2/src/test/java/com/baeldung/r/RenjinMeanUnitTest.java create mode 100644 libraries-data-2/src/test/resources/script.R diff --git a/libraries-data-2/pom.xml b/libraries-data-2/pom.xml index e6106c0fe3..ce15ef6c07 100644 --- a/libraries-data-2/pom.xml +++ b/libraries-data-2/pom.xml @@ -128,6 +128,24 @@ ${awaitility.version} test + + + org.rosuda.REngine + Rserve + ${rserve.version} + + + + com.github.jbytecode + RCaller + ${rcaller.version} + + + + org.renjin + renjin-script-engine + ${renjin.version} + @@ -137,6 +155,13 @@ http://repo.numericalmethod.com/maven/ default + + + + bedatadriven + bedatadriven public repo + https://nexus.bedatadriven.com/content/groups/public/ + @@ -153,6 +178,24 @@ 3.6.2 1.7.25 3.0.0 + RELEASE + 3.0 + 1.8.1 + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + com/baeldung/r/FastRMean.java + + + + + + \ No newline at end of file diff --git a/libraries-data-2/src/main/java/com/baeldung/r/FastRMean.java b/libraries-data-2/src/main/java/com/baeldung/r/FastRMean.java new file mode 100644 index 0000000000..52fb2d1506 --- /dev/null +++ b/libraries-data-2/src/main/java/com/baeldung/r/FastRMean.java @@ -0,0 +1,28 @@ +package com.baeldung.r; + +import java.io.IOException; +import java.net.URISyntaxException; + +/** + * FastR showcase. + * + * @author Donato Rimenti + */ +public class FastRMean { + + /** + * Invokes the customMean R function passing the given values as arguments. + * + * @param values the input to the mean script + * @return the result of the R script + */ + public double mean(int[] values) { + Context polyglot = Context.newBuilder().allowAllAccess(true).build(); + String meanScriptContent = RUtils.getMeanScriptContent(); + polyglot.eval("R", meanScriptContent); + Value rBindings = polyglot.getBindings("R"); + Value rInput = rBindings.getMember("c").execute(values); + return rBindings.getMember("customMean").execute(rInput).asDouble(); + } + +} \ No newline at end of file diff --git a/libraries-data-2/src/main/java/com/baeldung/r/RCallerMean.java b/libraries-data-2/src/main/java/com/baeldung/r/RCallerMean.java new file mode 100644 index 0000000000..53e0ab9e31 --- /dev/null +++ b/libraries-data-2/src/main/java/com/baeldung/r/RCallerMean.java @@ -0,0 +1,36 @@ +package com.baeldung.r; + +import java.io.IOException; +import java.net.URISyntaxException; + +import com.github.rcaller.rstuff.RCaller; +import com.github.rcaller.rstuff.RCallerOptions; +import com.github.rcaller.rstuff.RCode; + +/** + * RCaller showcase. + * + * @author Donato Rimenti + */ +public class RCallerMean { + + /** + * Invokes the customMean R function passing the given values as arguments. + * + * @param values the input to the mean script + * @return the result of the R script + * @throws IOException if any error occurs + * @throws URISyntaxException if any error occurs + */ + public double mean(int[] values) throws IOException, URISyntaxException { + String fileContent = RUtils.getMeanScriptContent(); + RCode code = RCode.create(); + code.addRCode(fileContent); + code.addIntArray("input", values); + code.addRCode("result <- customMean(input)"); + RCaller caller = RCaller.create(code, RCallerOptions.create()); + caller.runAndReturnResult("result"); + return caller.getParser().getAsDoubleArray("result")[0]; + } + +} \ No newline at end of file diff --git a/libraries-data-2/src/main/java/com/baeldung/r/RUtils.java b/libraries-data-2/src/main/java/com/baeldung/r/RUtils.java new file mode 100644 index 0000000000..ad16fd5602 --- /dev/null +++ b/libraries-data-2/src/main/java/com/baeldung/r/RUtils.java @@ -0,0 +1,30 @@ +package com.baeldung.r; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.stream.Collectors; + +/** + * Utility class for loading the script.R content. + * + * @author Donato Rimenti + */ +public class RUtils { + + /** + * Loads the script.R and returns its content as a string. + * + * @return the script.R content as a string + * @throws IOException if any error occurs + * @throws URISyntaxException if any error occurs + */ + static String getMeanScriptContent() throws IOException, URISyntaxException { + URI rScriptUri = RUtils.class.getClassLoader().getResource("script.R").toURI(); + Path inputScript = Paths.get(rScriptUri); + return Files.lines(inputScript).collect(Collectors.joining()); + } +} \ No newline at end of file diff --git a/libraries-data-2/src/main/java/com/baeldung/r/RenjinMean.java b/libraries-data-2/src/main/java/com/baeldung/r/RenjinMean.java new file mode 100644 index 0000000000..befb7d522f --- /dev/null +++ b/libraries-data-2/src/main/java/com/baeldung/r/RenjinMean.java @@ -0,0 +1,36 @@ +package com.baeldung.r; + +import java.io.IOException; +import java.net.URISyntaxException; + +import javax.script.ScriptException; + +import org.renjin.script.RenjinScriptEngine; +import org.renjin.sexp.DoubleArrayVector; + +/** + * Renjin showcase. + * + * @author Donato Rimenti + */ +public class RenjinMean { + + /** + * Invokes the customMean R function passing the given values as arguments. + * + * @param values the input to the mean script + * @return the result of the R script + * @throws IOException if any error occurs + * @throws URISyntaxException if any error occurs + * @throws ScriptException if any error occurs + */ + public double mean(int[] values) throws IOException, URISyntaxException, ScriptException { + RenjinScriptEngine engine = new RenjinScriptEngine(); + String meanScriptContent = RUtils.getMeanScriptContent(); + engine.put("input", values); + engine.eval(meanScriptContent); + DoubleArrayVector result = (DoubleArrayVector) engine.eval("customMean(input)"); + return result.asReal(); + } + +} \ No newline at end of file diff --git a/libraries-data-2/src/main/java/com/baeldung/r/RserveMean.java b/libraries-data-2/src/main/java/com/baeldung/r/RserveMean.java new file mode 100644 index 0000000000..51aaa90648 --- /dev/null +++ b/libraries-data-2/src/main/java/com/baeldung/r/RserveMean.java @@ -0,0 +1,29 @@ +package com.baeldung.r; + +import org.rosuda.REngine.REXPMismatchException; +import org.rosuda.REngine.REngineException; +import org.rosuda.REngine.Rserve.RConnection; + +/** + * Rserve showcase. + * + * @author Donato Rimenti + */ +public class RserveMean { + + /** + * Connects to the Rserve istance listening on 127.0.0.1:6311 and invokes the + * customMean R function passing the given values as arguments. + * + * @param values the input to the mean script + * @return the result of the R script + * @throws REngineException if any error occurs + * @throws REXPMismatchException if any error occurs + */ + public double mean(int[] values) throws REngineException, REXPMismatchException { + RConnection c = new RConnection(); + c.assign("input", values); + return c.eval("customMean(input)").asDouble(); + } + +} \ No newline at end of file diff --git a/libraries-data-2/src/test/java/com/baeldung/r/FastRMeanUnitTest.java b/libraries-data-2/src/test/java/com/baeldung/r/FastRMeanUnitTest.java new file mode 100644 index 0000000000..5cf8c63a56 --- /dev/null +++ b/libraries-data-2/src/test/java/com/baeldung/r/FastRMeanUnitTest.java @@ -0,0 +1,29 @@ +package com.baeldung.r; + +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Test for {@link FastRMean}. + * + * @author Donato Rimenti + */ +@Ignore +public class FastRMeanUnitTest { + + /** + * Object to test. + */ + private FastRMean fastrMean = new FastRMean(); + + /** + * Test for {@link FastRMeanUnitTest#mean(int[])}. + */ + @Test + public void givenValues_whenMean_thenCorrect() { + int[] input = { 1, 2, 3, 4, 5 }; + double result = fastrMean.mean(input); + Assert.assertEquals(3.0, result, 0.000001); + } +} \ No newline at end of file diff --git a/libraries-data-2/src/test/java/com/baeldung/r/RCallerMeanIntegrationTest.java b/libraries-data-2/src/test/java/com/baeldung/r/RCallerMeanIntegrationTest.java new file mode 100644 index 0000000000..b68f259edd --- /dev/null +++ b/libraries-data-2/src/test/java/com/baeldung/r/RCallerMeanIntegrationTest.java @@ -0,0 +1,37 @@ +package com.baeldung.r; + +import java.io.IOException; +import java.net.URISyntaxException; + +import javax.script.ScriptException; + +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Test for {@link RCallerMean}. + * + * @author Donato Rimenti + */ +@Ignore +public class RCallerMeanIntegrationTest { + + /** + * Object to test. + */ + private RCallerMean rcallerMean = new RCallerMean(); + + /** + * Test for {@link RCallerMeanIntegrationTest#mean(int[])}. + * + * @throws ScriptException if an error occurs + * @throws URISyntaxException if an error occurs + */ + @Test + public void givenValues_whenMean_thenCorrect() throws IOException, URISyntaxException { + int[] input = { 1, 2, 3, 4, 5 }; + double result = rcallerMean.mean(input); + Assert.assertEquals(3.0, result, 0.000001); + } +} \ No newline at end of file diff --git a/libraries-data-2/src/test/java/com/baeldung/r/RenjinMeanUnitTest.java b/libraries-data-2/src/test/java/com/baeldung/r/RenjinMeanUnitTest.java new file mode 100644 index 0000000000..e364d54632 --- /dev/null +++ b/libraries-data-2/src/test/java/com/baeldung/r/RenjinMeanUnitTest.java @@ -0,0 +1,37 @@ +package com.baeldung.r; + +import java.io.IOException; +import java.net.URISyntaxException; + +import javax.script.ScriptException; + +import org.junit.Test; + +import org.junit.Assert; + +/** + * Test for {@link RenjinMean}. + * + * @author Donato Rimenti + */ +public class RenjinMeanUnitTest { + + /** + * Object to test. + */ + private RenjinMean renjinMean = new RenjinMean(); + + /** + * Test for {@link RenjinMeanUnitTest#mean(int[])}. + * + * @throws ScriptException if an error occurs + * @throws URISyntaxException if an error occurs + * @throws IOException if an error occurs + */ + @Test + public void givenValues_whenMean_thenCorrect() throws IOException, URISyntaxException, ScriptException { + int[] input = { 1, 2, 3, 4, 5 }; + double result = renjinMean.mean(input); + Assert.assertEquals(3.0, result, 0.000001); + } +} \ No newline at end of file diff --git a/libraries-data-2/src/test/resources/script.R b/libraries-data-2/src/test/resources/script.R new file mode 100644 index 0000000000..08f859cc3d --- /dev/null +++ b/libraries-data-2/src/test/resources/script.R @@ -0,0 +1,3 @@ +customMean <- function(vector) { + mean(vector) +} \ No newline at end of file From fd318eb47615796d28901386aa158b51212db0fb Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 20 Apr 2020 23:15:30 +0530 Subject: [PATCH 282/503] JAVA-919: Migrate jmeter to parent-boot-2 --- jmeter/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jmeter/pom.xml b/jmeter/pom.xml index 64642695ff..945210edd7 100644 --- a/jmeter/pom.xml +++ b/jmeter/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 From 16ca52363cef9a05a32113654ae290854cb27866 Mon Sep 17 00:00:00 2001 From: Donato Rimenti Date: Mon, 20 Apr 2020 20:11:06 +0200 Subject: [PATCH 283/503] Fixed test exclusions and added missing tests. --- libraries-data-2/pom.xml | 5 ++- .../baeldung/r/RserveMeanIntegrationTest.java | 34 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 libraries-data-2/src/test/java/com/baeldung/r/RserveMeanIntegrationTest.java diff --git a/libraries-data-2/pom.xml b/libraries-data-2/pom.xml index ce15ef6c07..0dadcbd8d4 100644 --- a/libraries-data-2/pom.xml +++ b/libraries-data-2/pom.xml @@ -189,10 +189,13 @@ org.apache.maven.plugins maven-compiler-plugin - + com/baeldung/r/FastRMean.java + + com/baeldung/r/FastRMeanUnitTest.java + diff --git a/libraries-data-2/src/test/java/com/baeldung/r/RserveMeanIntegrationTest.java b/libraries-data-2/src/test/java/com/baeldung/r/RserveMeanIntegrationTest.java new file mode 100644 index 0000000000..95b344cb02 --- /dev/null +++ b/libraries-data-2/src/test/java/com/baeldung/r/RserveMeanIntegrationTest.java @@ -0,0 +1,34 @@ +package com.baeldung.r; + +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; +import org.rosuda.REngine.REXPMismatchException; +import org.rosuda.REngine.REngineException; + +/** + * Test for {@link RserveMean}. + * + * @author Donato Rimenti + */ +@Ignore +public class RserveMeanIntegrationTest { + + /** + * Object to test. + */ + private RserveMean rserveMean = new RserveMean(); + + /** + * Test for {@link RserveMeanIntegrationTest#mean(int[])}. + * + * @throws REXPMismatchException if an error occurs + * @throws REngineException if an error occurs + */ + @Test + public void givenValues_whenMean_thenCorrect() throws REngineException, REXPMismatchException { + int[] input = { 1, 2, 3, 4, 5 }; + double result = rserveMean.mean(input); + Assert.assertEquals(3.0, result, 0.000001); + } +} \ No newline at end of file From 4fe86bb104b27cbb2601b0aac5f81a295fba0402 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 20 Apr 2020 23:42:21 +0530 Subject: [PATCH 284/503] JAVA-920: Migrate libraries-security to parent-boot-2 --- libraries-security/pom.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries-security/pom.xml b/libraries-security/pom.xml index e287de4527..e02f766141 100644 --- a/libraries-security/pom.xml +++ b/libraries-security/pom.xml @@ -8,9 +8,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 @@ -23,7 +23,9 @@ org.springframework.security.oauth spring-security-oauth2 + ${spring-boot.version} + org.springframework spring-web From fdce9657e353378c627c5effde51c5cc36380ad2 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 21 Apr 2020 12:15:56 +0800 Subject: [PATCH 285/503] Update README.md --- netty/README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/netty/README.md b/netty/README.md index b006c1c686..8b13789179 100644 --- a/netty/README.md +++ b/netty/README.md @@ -1,6 +1 @@ -## Netty - -This module contains articles about Netty. - -### Relevant Articles: From c367c05c53fdcc1c45642ae053143d5e91df961c Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 21 Apr 2020 12:16:07 +0800 Subject: [PATCH 286/503] Delete README.md --- netty/README.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 netty/README.md diff --git a/netty/README.md b/netty/README.md deleted file mode 100644 index 8b13789179..0000000000 --- a/netty/README.md +++ /dev/null @@ -1 +0,0 @@ - From b5603f9fce1721bafb94d3442360ede620e68d62 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 21 Apr 2020 12:17:56 +0800 Subject: [PATCH 287/503] Update README.md --- java-collections-maps-3/README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/java-collections-maps-3/README.md b/java-collections-maps-3/README.md index ed68eb00a0..8b13789179 100644 --- a/java-collections-maps-3/README.md +++ b/java-collections-maps-3/README.md @@ -1,8 +1 @@ -## Java Collections Cookbooks and Examples -This module contains articles about Map data structures in Java. - -### Relevant Articles: - -- More articles: [[<-- prev>]](/../java-collections-maps) -- More articles: [[<-- prev>]](/../java-collections-maps-2) From c9c48fda086801eb260c4e92facca1c6b7ad08a0 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 21 Apr 2020 12:18:04 +0800 Subject: [PATCH 288/503] Delete README.md --- java-collections-maps-3/README.md | 1 - 1 file changed, 1 deletion(-) delete mode 100644 java-collections-maps-3/README.md diff --git a/java-collections-maps-3/README.md b/java-collections-maps-3/README.md deleted file mode 100644 index 8b13789179..0000000000 --- a/java-collections-maps-3/README.md +++ /dev/null @@ -1 +0,0 @@ - From 6a41016938929ad22c46c9c1708d4dc1f9524aea Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 21 Apr 2020 12:30:05 +0800 Subject: [PATCH 289/503] Update README.md --- guava/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/guava/README.md b/guava/README.md index 71f76c1360..9c650dbc1d 100644 --- a/guava/README.md +++ b/guava/README.md @@ -13,3 +13,4 @@ This module contains articles a Google Guava - [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) From 458c4d8505fe12160769b5208eb5b5e4c68b0b51 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 21 Apr 2020 12:33:38 +0800 Subject: [PATCH 290/503] Update README.md --- core-kotlin-modules/core-kotlin/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-kotlin-modules/core-kotlin/README.md b/core-kotlin-modules/core-kotlin/README.md index 151da607ac..90caccf5c8 100644 --- a/core-kotlin-modules/core-kotlin/README.md +++ b/core-kotlin-modules/core-kotlin/README.md @@ -3,7 +3,7 @@ This module contains articles about Kotlin core features. ### Relevant articles: -- [Introduction to the Kotlin Language](https://www.baeldung.com/kotlin/tutorial) +- [Introduction to the Kotlin Language](https://www.baeldung.com/kotlin-intro) - [Kotlin Java Interoperability](https://www.baeldung.com/kotlin-java-interoperability) - [Get a Random Number in Kotlin](https://www.baeldung.com/kotlin-random-number) - [Create a Java and Kotlin Project with Maven](https://www.baeldung.com/kotlin-maven-java-project) From 8c151edb1e887572eb77d05ae55f7f5766f65f87 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 21 Apr 2020 12:36:40 +0800 Subject: [PATCH 291/503] Update README.md --- spring-boot-modules/spring-boot-testing/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-testing/README.md b/spring-boot-modules/spring-boot-testing/README.md index 9bbaf337d7..192f5cee99 100644 --- a/spring-boot-modules/spring-boot-testing/README.md +++ b/spring-boot-modules/spring-boot-testing/README.md @@ -13,4 +13,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Setting the Log Level in Spring Boot when Testing](https://www.baeldung.com/spring-boot-testing-log-level) - [Embedded Redis Server with Spring Boot Test](https://www.baeldung.com/spring-embedded-redis) - [Testing Spring Boot @ConfigurationProperties](https://www.baeldung.com/spring-boot-testing-configurationproperties) -- [Prevent ApplicationRunner or CommandLineRunner Beans From Executing During Junit Testing]() +- [Prevent ApplicationRunner or CommandLineRunner Beans From Executing During Junit Testing](https://www.baeldung.com/spring-junit-prevent-runner-beans-testing-execution) From 34d94a78f0639095029abfc7acd3a85b0c6dabc7 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 21 Apr 2020 11:33:15 +0530 Subject: [PATCH 292/503] JAVA-920: Copied missing artifact so that live test runs ok --- .../src/main/resources/Baeldung.p12 | Bin 0 -> 2502 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 libraries-security/src/main/resources/Baeldung.p12 diff --git a/libraries-security/src/main/resources/Baeldung.p12 b/libraries-security/src/main/resources/Baeldung.p12 new file mode 100644 index 0000000000000000000000000000000000000000..65ec8bc8fec33120b2c11276883dde5dad7a3ea6 GIT binary patch literal 2502 zcmY+Ec{CJ^8pg-W7-KiSAxm~&AvE}qeFbou@HKRX#MCzW*R!0LL7Y% z7)Sr`m+g30_7yeFjs-&~fCI+{-yx;|%9MeT2(tgQ10!G4XA2 zkG>wSErwX=^nQsIu&jb*uF4fhJf{o`c{-h8IOQJ-3P1FiZj0wRF6K9 z8mc&Zv?tvBj9P!Y^4uoj2G=6#18%wBeI!8jBRU|{P+P>0Aj=k375X=>QV+%oS!bk}+lJ+=1;z2pF||>sP$r3Brd~; zK)4%I2x>Ka+<;kKSK~)>L|uxGz&8_NxTGL2SC%Ui58tY=@-RCRhmrcaiO=Kg3VLao zL4POxN4d@n*d5|D3|P>OiNs!L2y3}V91S9g=+MPm2z2B)8SfIlps2SxADFc?et7bp zX$NVVRh<~4WzxjUvYD%W)wYw9O8Brp^L0RcbZ~X#P4;$ zj@d^cTmNv5A?VBUvx?k4kPIs2@lgJ*dzk-y`e;r~_tMcguyihj(WZx;W7st6eU1^p zA%3;BP+|V=UsgnMaP2xR9K?kLwyMXM~nWS!589aEx|ZivtPE+FCig}|Cv7n z4X_Xg-u#7*)&HXc=rv2DY6l{514xv{C2smp+M* z0HVF+G4qecX9^nOQ_20k2BM02$9dQ593Rq`jJUz%jTp%B$M|BdRc91;W`+2m}mmXL+cwS z-&0lg5an|f6il`kXk#vPZhK2Z{$$;;@;0;b_10a*B5Rf5vKBR^@uJW`WS*}TZ=JLU zrj7F9)-nOh*HW4C!Otz_FqYnEa!4nC@x0Wy?`_DN=c%fjkhTs@U^UB&)l0w$4n{K* zxd;D}W@$I_F{l@h(sB)s*Iz+sw{FOEa8& z#EfydGU+EgJ3m#S4b&`TTCBfC)eJ1M>U(%yKc+7F3lI-0X##xff#=dtmj;cWs@*(1 zZXS(tbGXP@?braN#P>=GxwN^xFqQBRSvZbJniMWr*lo`MXc=JWLQ&?yr)-$(Q$h^t zmmrKH?`t%wDk~pX1aJ^CbU%HXCAh@rR6?f`m^|7yVOF)+`(Y=4B-tto(B<>E=#QYq z&@RDn^M$lUwdx-1I4h;lvzUX6)HqThjqi4SlgM#nYG;nAtd-nO%TPn)KA9c{jep;9 zv79sQ{V`P{aJuEBb+8(|yi8}R z6hXIAFE*35l(toZR?k^d;kDRbp0Bi3D0P+;?`sW)yZdU2IS(8r-PlbgD6J2GLhODl zx^Ea$kiSoZQ1qd#$ zrw<*y{e#y|n++B0#ujM&wp!KoH<8hT7JB{RiW`47kpL%2BP;hRkV5E^;HN+5b za*HI=nMx7`*nucDb(iCuuCi`KplQ=xzr^Ya{l%oz=!5s?{M_rv@Zq3;FGnmok06!C z!iZ>7b}M(R4R=#t|6J8 Date: Tue, 21 Apr 2020 14:11:41 +0800 Subject: [PATCH 293/503] Update README.md --- core-java-modules/core-java-string-operations-2/README.md | 1 - 1 file changed, 1 deletion(-) 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 bc00c6a915..45b02a3e10 100644 --- a/core-java-modules/core-java-string-operations-2/README.md +++ b/core-java-modules/core-java-string-operations-2/README.md @@ -9,7 +9,6 @@ This module contains articles about string operations. - [String toLowerCase and toUpperCase Methods in Java](https://www.baeldung.com/java-string-convert-case) - [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 in Java](https://www.baeldung.com/l-trim-and-r-trim-in-java) - [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) - More articles: [[<-- prev]](../core-java-string-operations) From b58db90f3bc2333a1b34ddbac2024f30bb358b84 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 21 Apr 2020 14:13:43 +0800 Subject: [PATCH 294/503] Delete README.md --- maven-all/versions-maven-plugin/original/README.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 maven-all/versions-maven-plugin/original/README.md diff --git a/maven-all/versions-maven-plugin/original/README.md b/maven-all/versions-maven-plugin/original/README.md deleted file mode 100644 index 5652a9b7e4..0000000000 --- a/maven-all/versions-maven-plugin/original/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: - -- [Use the Latest Version of a Dependency in Maven](https://www.baeldung.com/maven-dependency-latest-version) From 4a75b130579bd8e5641ed9b71f8d7aa13eb8c338 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 21 Apr 2020 14:15:57 +0800 Subject: [PATCH 295/503] Update README.md --- persistence-modules/spring-jpa/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/spring-jpa/README.md b/persistence-modules/spring-jpa/README.md index 27a2fe8368..599a667a13 100644 --- a/persistence-modules/spring-jpa/README.md +++ b/persistence-modules/spring-jpa/README.md @@ -10,7 +10,7 @@ - [Self-Contained Testing Using an In-Memory Database](https://www.baeldung.com/spring-jpa-test-in-memory-database) - [A Guide to Spring AbstractRoutingDatasource](https://www.baeldung.com/spring-abstract-routing-data-source) - [Obtaining Auto-generated Keys in Spring JDBC](https://www.baeldung.com/spring-jdbc-autogenerated-keys) -- [Transactions with Spring 4 and JPA](https://www.baeldung.com/transaction-configuration-with-jpa-and-spring) +- [Transactions with Spring and JPA](https://www.baeldung.com/transaction-configuration-with-jpa-and-spring) - [Use Criteria Queries in a Spring Data Application](https://www.baeldung.com/spring-data-criteria-queries) - [Many-To-Many Relationship in JPA](https://www.baeldung.com/jpa-many-to-many) - [Spring Persistence (Hibernate and JPA) with a JNDI datasource](https://www.baeldung.com/spring-persistence-hibernate-and-jpa-with-a-jndi-datasource/) From d17e2b5b93c5b6b1e247c894088d1027a760ebbe Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 21 Apr 2020 14:18:12 +0800 Subject: [PATCH 296/503] Delete README.md --- spring-core-3/src/main/java/com/baeldung/factorybean/README.md | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 spring-core-3/src/main/java/com/baeldung/factorybean/README.md diff --git a/spring-core-3/src/main/java/com/baeldung/factorybean/README.md b/spring-core-3/src/main/java/com/baeldung/factorybean/README.md deleted file mode 100644 index 13f9f379e0..0000000000 --- a/spring-core-3/src/main/java/com/baeldung/factorybean/README.md +++ /dev/null @@ -1,2 +0,0 @@ -### Relevant Articles: -- [How to use the Spring FactoryBean?](http://www.baeldung.com/spring-factorybean) From 62ccb01325e5c44a0de557ac071e157c491b8235 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 21 Apr 2020 14:19:47 +0800 Subject: [PATCH 297/503] Delete README.md --- maven-all/maven/custom-rule/README.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 maven-all/maven/custom-rule/README.md diff --git a/maven-all/maven/custom-rule/README.md b/maven-all/maven/custom-rule/README.md deleted file mode 100644 index 44d43050e7..0000000000 --- a/maven-all/maven/custom-rule/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: - -- [Maven Enforcer Plugin](https://www.baeldung.com/maven-enforcer-plugin) From b2af10c98ba1934ce0c6fda08b03e34cb4e97284 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 21 Apr 2020 14:26:20 +0800 Subject: [PATCH 298/503] Delete README.md --- ddd-modules/README.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 ddd-modules/README.md diff --git a/ddd-modules/README.md b/ddd-modules/README.md deleted file mode 100644 index ba6b8d5016..0000000000 --- a/ddd-modules/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: - -- [DDD Bounded Contexts and Java Modules](https://www.baeldung.com/java-modules-ddd-bounded-contexts) From 3266970b400419ed5967b64f141e67038c51c061 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 21 Apr 2020 14:27:38 +0800 Subject: [PATCH 299/503] Create README.md --- ddd-modules/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 ddd-modules/README.md diff --git a/ddd-modules/README.md b/ddd-modules/README.md new file mode 100644 index 0000000000..ba6b8d5016 --- /dev/null +++ b/ddd-modules/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [DDD Bounded Contexts and Java Modules](https://www.baeldung.com/java-modules-ddd-bounded-contexts) From bbb0511669cf61ef04b5dd1d4593f53dfa277137 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 21 Apr 2020 14:29:19 +0800 Subject: [PATCH 300/503] Update README.md --- maven-all/maven/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/maven-all/maven/README.md b/maven-all/maven/README.md index ced4a52703..c5f46ca184 100644 --- a/maven-all/maven/README.md +++ b/maven-all/maven/README.md @@ -7,7 +7,6 @@ have their own dedicated modules. - [Guide to the Core Maven Plugins](https://www.baeldung.com/core-maven-plugins) - [Maven Resources Plugin](https://www.baeldung.com/maven-resources-plugin) -- [Maven Compiler Plugin](https://www.baeldung.com/maven-compiler-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) From b37ee5f26d08e8e24d2eae2b1aa101f6c9b62b8c Mon Sep 17 00:00:00 2001 From: Cavero Barca Date: Tue, 21 Apr 2020 15:29:47 +0200 Subject: [PATCH 301/503] Add WebFilter Factories examples configured through yaml and Java DSL --- spring-cloud/spring-cloud-gateway/pom.xml | 12 ++- .../WebFilterGatewayApplication.java | 15 +++ .../config/ModifyBodyRouteConfig.java | 49 ++++++++++ .../main/resources/application-webfilters.yml | 93 +++++++++++++++++++ 4 files changed, 165 insertions(+), 4 deletions(-) create mode 100644 spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/WebFilterGatewayApplication.java create mode 100644 spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/ModifyBodyRouteConfig.java create mode 100644 spring-cloud/spring-cloud-gateway/src/main/resources/application-webfilters.yml diff --git a/spring-cloud/spring-cloud-gateway/pom.xml b/spring-cloud/spring-cloud-gateway/pom.xml index 0f62c031cf..ada32ae85f 100644 --- a/spring-cloud/spring-cloud-gateway/pom.xml +++ b/spring-cloud/spring-cloud-gateway/pom.xml @@ -49,6 +49,12 @@ spring-cloud-starter-gateway + + + org.springframework.cloud + spring-cloud-starter-circuitbreaker-reactor-resilience4j + + org.hibernate hibernate-validator-cdi @@ -84,10 +90,8 @@ - Greenwich.SR3 - - - 2.1.9.RELEASE + Hoxton.SR3 + 2.2.6.RELEASE 6.0.2.Final diff --git a/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/WebFilterGatewayApplication.java b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/WebFilterGatewayApplication.java new file mode 100644 index 0000000000..3b45e9013f --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/WebFilterGatewayApplication.java @@ -0,0 +1,15 @@ +package com.baeldung.springcloudgateway.webfilters; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; + +@SpringBootApplication +public class WebFilterGatewayApplication { + + public static void main(String[] args) { + new SpringApplicationBuilder(WebFilterGatewayApplication.class) + .profiles("webfilters") + .run(args); + } + +} \ No newline at end of file diff --git a/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/ModifyBodyRouteConfig.java b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/ModifyBodyRouteConfig.java new file mode 100644 index 0000000000..ccc789f287 --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/ModifyBodyRouteConfig.java @@ -0,0 +1,49 @@ +package com.baeldung.springcloudgateway.webfilters.config; + +import org.springframework.cloud.gateway.route.RouteLocator; +import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; + +import reactor.core.publisher.Mono; + +@Configuration +public class ModifyBodyRouteConfig { + + @Bean + public RouteLocator routes(RouteLocatorBuilder builder) { + return builder.routes() + .route("modify_request_body", r -> r.path("/post") + .filters(f -> f.modifyRequestBody(String.class, Hello.class, MediaType.APPLICATION_JSON_VALUE, + (exchange, s) -> Mono.just(new Hello(s.toUpperCase())))).uri("https://httpbin.org")) + .build(); + } + + @Bean + public RouteLocator responseRoutes(RouteLocatorBuilder builder) { + return builder.routes() + .route("modify_response_body", r -> r.path("/put/**") + .filters(f -> f.modifyResponseBody(String.class, Hello.class, MediaType.APPLICATION_JSON_VALUE, + (exchange, s) -> Mono.just(new Hello("New Body")))).uri("https://httpbin.org")) + .build(); + } + + static class Hello { + String message; + + public Hello() { } + + public Hello(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + } +} diff --git a/spring-cloud/spring-cloud-gateway/src/main/resources/application-webfilters.yml b/spring-cloud/spring-cloud-gateway/src/main/resources/application-webfilters.yml new file mode 100644 index 0000000000..9b3ec64f96 --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/src/main/resources/application-webfilters.yml @@ -0,0 +1,93 @@ +spring: + cloud: + gateway: + routes: + - id: request_header_route + uri: https://httpbin.org + predicates: + - Path=/get/** + filters: + - AddRequestHeader=My-Header-Good,Good + - AddRequestHeader=My-Header-Remove,Remove + - AddRequestParameter=var, good + - AddRequestParameter=var2, remove + - MapRequestHeader=My-Header-Good, My-Header-Bad + - MapRequestHeader=My-Header-Set, My-Header-Bad + - SetRequestHeader=My-Header-Set, Set + - RemoveRequestHeader=My-Header-Remove + - RemoveRequestParameter=var2 + - PreserveHostHeader + + - id: response_header_route + uri: https://httpbin.org + predicates: + - Path=/header/post/** + filters: + - AddResponseHeader=My-Header-Good,Good + - AddResponseHeader=My-Header-Set,Good + - AddResponseHeader=My-Header-Rewrite, password=12345678 + - DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin + - AddResponseHeader=My-Header-Remove,Remove + - SetResponseHeader=My-Header-Set, Set + - RemoveResponseHeader=My-Header-Remove + - RewriteResponseHeader=My-Header-Rewrite, password=[^&]+, password=*** + - RewriteLocationResponseHeader=AS_IN_REQUEST, Location, , + - StripPrefix=1 + + - id: path_route + uri: https://httpbin.org + predicates: + - Path=/new/post/** + filters: + - RewritePath=/new(?/?.*), $\{segment} + - SetPath=/post + + - id: redirect_route + uri: https://httpbin.org + predicates: + - Path=/fake/post/** + filters: + - RedirectTo=302, https://httpbin.org + + - id: status_route + uri: https://httpbin.org + predicates: + - Path=/delete/** + filters: + - SetStatus=401 + + - id: size_route + uri: https://httpbin.org + predicates: + - Path=/anything + filters: + - name: RequestSize + args: + maxSize: 5000000 + + - id: retry_test + uri: https://httpbin.org + predicates: + - Path=/status/502 + filters: + - name: Retry + args: + retries: 3 + statuses: BAD_GATEWAY + methods: GET,POST + backoff: + firstBackoff: 10ms + maxBackoff: 50ms + factor: 2 + basedOnPreviousValue: false + + - id: circuitbreaker_route + uri: https://httpbin.org + predicates: + - Path=/status/504 + filters: + - name: CircuitBreaker + args: + name: myCircuitBreaker + fallbackUri: forward:/anything + - RewritePath=/status/504, /anything \ No newline at end of file From b25323afb2891c5cdb19ac26161cb5b67558b2b6 Mon Sep 17 00:00:00 2001 From: Cavero Barca Date: Tue, 21 Apr 2020 15:33:39 +0200 Subject: [PATCH 302/503] Add testing to the WebFilter Factories Spring Boot project --- .../WebFilterFactoriesLiveTest.java | 139 ++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/WebFilterFactoriesLiveTest.java diff --git a/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/WebFilterFactoriesLiveTest.java b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/WebFilterFactoriesLiveTest.java new file mode 100644 index 0000000000..3efd60fb27 --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/WebFilterFactoriesLiveTest.java @@ -0,0 +1,139 @@ +package com.baeldung.springcloudgateway.webfilters; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.assertj.core.api.Condition; +import org.json.JSONException; +import org.json.JSONObject; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.web.reactive.server.WebTestClient; +import org.springframework.test.web.reactive.server.WebTestClient.ResponseSpec; + +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@ActiveProfiles("webfilters") +public class WebFilterFactoriesLiveTest { + + @LocalServerPort + String port; + + @Autowired + private WebTestClient client; + + @Autowired + private TestRestTemplate restTemplate; + + @BeforeEach + public void configureClient() { + client = WebTestClient.bindToServer() + .baseUrl("http://localhost:" + port) + .build(); + } + + @Test + public void whenCallGetThroughGateway_thenAllHTTPRequestHeadersParametersAreSet() throws JSONException { + String url = "http://localhost:" + port + "/get"; + ResponseEntity response = restTemplate.getForEntity(url, String.class); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + + JSONObject json = new JSONObject(response.getBody()); + JSONObject headers = json.getJSONObject("headers"); + assertThat(headers.getString("My-Header-Good")).isEqualTo("Good"); + assertThat(headers.getString("My-Header-Bad")).isEqualTo("Good"); + assertThat(headers.getString("My-Header-Set")).isEqualTo("Set"); + assertTrue(headers.isNull("My-Header-Remove")); + JSONObject vars = json.getJSONObject("args"); + assertThat(vars.getString("var")).isEqualTo("good"); + } + + @Test + public void whenCallHeaderPostThroughGateway_thenAllHTTPResponseHeadersAreSet() { + ResponseSpec response = client.post() + .uri("/header/post") + .exchange(); + + response.expectStatus() + .isOk() + .expectHeader() + .valueEquals("My-Header-Rewrite", "password=***") + .expectHeader() + .valueEquals("My-Header-Set", "Set") + .expectHeader() + .valueEquals("My-Header-Good", "Good") + .expectHeader() + .doesNotExist("My-Header-Remove"); + } + + @Test + public void whenCallPostThroughGateway_thenBodyIsRetrieved() throws JSONException { + String url = "http://localhost:" + port + "/post"; + + HttpEntity entity = new HttpEntity<>("content", new HttpHeaders()); + + ResponseEntity response = restTemplate.exchange(url, + HttpMethod.POST, entity, String.class); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + + JSONObject json = new JSONObject(response.getBody()); + JSONObject data = json.getJSONObject("json"); + assertThat(data.getString("message")).isEqualTo("CONTENT"); + } + + + @Test + public void whenCallPutThroughGateway_thenBodyIsRetrieved() throws JSONException { + String url = "http://localhost:" + port + "/put"; + + HttpEntity entity = new HttpEntity<>("CONTENT", new HttpHeaders()); + + ResponseEntity response = restTemplate.exchange(url, + HttpMethod.PUT, entity, String.class); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + + JSONObject json = new JSONObject(response.getBody()); + assertThat(json.getString("message")).isEqualTo("New Body"); + } + + @Test + public void whenCallDeleteThroughGateway_thenIsUnauthorizedCodeIsSet() { + ResponseSpec response = client.delete() + .uri("/delete") + .exchange(); + + response.expectStatus() + .isUnauthorized(); + } + + @Test + public void whenCallFakePostThroughGateway_thenIsUnauthorizedCodeIsSet() { + ResponseSpec response = client.post() + .uri("/fake/post") + .exchange(); + + response.expectStatus() + .is3xxRedirection(); + } + + @Test + public void whenCallStatus504ThroughGateway_thenCircuitBreakerIsExecuted() throws JSONException { + String url = "http://localhost:" + port + "/status/504"; + ResponseEntity response = restTemplate.getForEntity(url, String.class); + + JSONObject json = new JSONObject(response.getBody()); + assertThat(json.getString("url")).contains("anything"); + } +} From 64e47e7f77a887e29da95cc1443d66cddc9c73c6 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Tue, 21 Apr 2020 10:25:27 -0600 Subject: [PATCH 303/503] BAEL-3972: check user roles in Java --- .../app/controller/TaskController.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java index a084f14eca..95f855c1e5 100644 --- a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java @@ -1,8 +1,15 @@ package com.baeldung.app.controller; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -10,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestMethod; import com.baeldung.app.entity.Task; import com.baeldung.app.service.TaskService; +import javax.servlet.http.HttpServletRequest; + @Controller @RequestMapping("api/tasks") public class TaskController { @@ -17,6 +26,9 @@ public class TaskController { @Autowired private TaskService taskService; + @Autowired(required = false) + private UserDetailsService userDetailsService; + @RequestMapping(method = RequestMethod.GET) public ResponseEntity> findAllTasks() { Iterable tasks = taskService.findAll(); @@ -30,4 +42,66 @@ public class TaskController { return ResponseEntity.ok().body(tasks); } + + /** + * Example of restricting specific endpoints to specific roles using @PreAuthorize. + */ + @GetMapping("/manager") + @PreAuthorize("hasRole('ROLE_MANAGER')") + public ResponseEntity> getAlManagerTasks() + { + Iterable tasks = taskService.findAll(); + + return ResponseEntity.ok().body(tasks); + } + + /** + * Example of restricting specific endpoints to specific roles using SecurityContext. + */ + @GetMapping("/actuator") + public ResponseEntity> getAlActuatorTasks() + { + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + if (auth != null && auth.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ACTUATOR"))) + { + return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); + } + + Iterable tasks = taskService.findAll(); + + return ResponseEntity.ok().body(tasks); + } + + /** + * Example of restricting specific endpoints to specific roles using UserDetailsService. + */ + @GetMapping("/admin") + public ResponseEntity> getAlAdminTasks() + { + if(userDetailsService != null) { + UserDetails details = userDetailsService.loadUserByUsername("pam"); + if (details != null && details.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ADMIN"))) { + return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); + } + } + + Iterable tasks = taskService.findAll(); + + return ResponseEntity.ok().body(tasks); + } + + /** + * Example of restricting specific endpoints to specific roles using HttpServletRequest. + */ + @GetMapping("/admin2") + public ResponseEntity> getAlAdminTasksUsingServlet(HttpServletRequest request) + { + if (!request.isUserInRole("ROLE_ADMIN")) { + return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); + } + + Iterable tasks = taskService.findAll(); + + return ResponseEntity.ok().body(tasks); + } } From 43852c4303b90e0ee4e11f15c7a52a1de1e7f8d8 Mon Sep 17 00:00:00 2001 From: Sasa M Date: Tue, 21 Apr 2020 18:46:45 +0200 Subject: [PATCH 304/503] Moving com.baeldung.modelmmaper package to java-collections-conversations module --- java-collections-conversions-2/pom.xml | 17 ++++ .../com/baeldung/modelmapper}/MapperUtil.java | 9 +- .../java/com/baeldung/modelmapper}/User.java | 6 +- .../com/baeldung/modelmapper}/UserDTO.java | 13 +-- .../com/baeldung/modelmapper}/UserList.java | 5 +- .../com/baeldung/modelmapper/UserListDTO.java | 20 +++++ .../modelmapper}/UserPropertyMap.java | 12 ++- .../baeldung/modelmapper/UserMappingTest.java | 85 +++++++++++++++++++ model-mapper/src/Main.java | 58 ------------- parent-java/pom.xml | 3 + 10 files changed, 140 insertions(+), 88 deletions(-) rename {model-mapper/src/com/baeldung/util => java-collections-conversions-2/src/main/java/com/baeldung/modelmapper}/MapperUtil.java (76%) rename {model-mapper/src/com/baeldung/model => java-collections-conversions-2/src/main/java/com/baeldung/modelmapper}/User.java (94%) rename {model-mapper/src/com/baeldung/model => java-collections-conversions-2/src/main/java/com/baeldung/modelmapper}/UserDTO.java (68%) rename {model-mapper/src/com/baeldung/model => java-collections-conversions-2/src/main/java/com/baeldung/modelmapper}/UserList.java (74%) create mode 100644 java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserListDTO.java rename {model-mapper/src/com/baeldung/util => java-collections-conversions-2/src/main/java/com/baeldung/modelmapper}/UserPropertyMap.java (68%) create mode 100644 java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UserMappingTest.java delete mode 100644 model-mapper/src/Main.java diff --git a/java-collections-conversions-2/pom.xml b/java-collections-conversions-2/pom.xml index b04d764719..ca4ed882dd 100644 --- a/java-collections-conversions-2/pom.xml +++ b/java-collections-conversions-2/pom.xml @@ -20,6 +20,23 @@ commons-lang3 ${commons-lang3.version} + + org.modelmapper + modelmapper + ${modelmapper.version} + + + junit + junit + ${junit.version} + test + + + org.hamcrest + hamcrest-all + ${hamcrest.version} + test + diff --git a/model-mapper/src/com/baeldung/util/MapperUtil.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java similarity index 76% rename from model-mapper/src/com/baeldung/util/MapperUtil.java rename to java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java index fe10b7777d..c02f012126 100644 --- a/model-mapper/src/com/baeldung/util/MapperUtil.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java @@ -1,4 +1,4 @@ -package com.baeldung.util; +package com.baeldung.modelmapper; import org.modelmapper.ModelMapper; import org.modelmapper.convention.MatchingStrategies; @@ -8,7 +8,9 @@ import java.util.List; /** * @author sasam0320 - * @date 4/18/2020 + * @description + * This is a helper class that contains methods for generic mapping of the users list. + * Initially, an instance of ModelMapper was created. In the static block we set the matching configuration to STRICT. */ public class MapperUtil { @@ -28,16 +30,13 @@ public class MapperUtil { } public static T mapTo(final S source, final Class target) { - return modelMapper.map(source, target); } public static List mapList(final List sourceList, final Class target) { - List targetList = new ArrayList(); for (S source : sourceList) { - targetList.add(modelMapper.map(source, target)); } diff --git a/model-mapper/src/com/baeldung/model/User.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java similarity index 94% rename from model-mapper/src/com/baeldung/model/User.java rename to java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java index 73e4baafb5..8f13b44894 100644 --- a/model-mapper/src/com/baeldung/model/User.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java @@ -1,10 +1,8 @@ -package com.baeldung.model; - -import java.util.List; +package com.baeldung.modelmapper; /** * @author sasam0320 - * @date 4/18/2020 + * @description User model entity class */ public class User { diff --git a/model-mapper/src/com/baeldung/model/UserDTO.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java similarity index 68% rename from model-mapper/src/com/baeldung/model/UserDTO.java rename to java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java index ed056ace8c..ce75eecefc 100644 --- a/model-mapper/src/com/baeldung/model/UserDTO.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java @@ -1,17 +1,14 @@ -package com.baeldung.model; - -import java.util.List; +package com.baeldung.modelmapper; /** * @author sasam0320 - * @date 4/18/2020 + * @description UserDTO model class */ public class UserDTO { private String userId; private String userName; private String email; - private List usernames; // getters and setters @@ -39,11 +36,5 @@ public class UserDTO { this.email = email; } - public List getUsernames() { - return usernames; - } - public void setUsernames(List usernames) { - this.usernames = usernames; - } } diff --git a/model-mapper/src/com/baeldung/model/UserList.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserList.java similarity index 74% rename from model-mapper/src/com/baeldung/model/UserList.java rename to java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserList.java index b30d5507d5..02361da469 100644 --- a/model-mapper/src/com/baeldung/model/UserList.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserList.java @@ -1,12 +1,11 @@ -package com.baeldung.model; +package com.baeldung.modelmapper; import java.util.Collection; /** * @author sasam0320 - * @date 4/18/2020 + * @description UserList class that contain collection of users */ - public class UserList { private Collection users; diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserListDTO.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserListDTO.java new file mode 100644 index 0000000000..fba311c1a3 --- /dev/null +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserListDTO.java @@ -0,0 +1,20 @@ +package com.baeldung.modelmapper; + +import java.util.List; + +/** + * @author sasam0320 + * @description UserListDTO class that contain list of username properties + */ +public class UserListDTO { + + private List usernames; + + public List getUsernames() { + return usernames; + } + + public void setUsernames(List usernames) { + this.usernames = usernames; + } +} diff --git a/model-mapper/src/com/baeldung/util/UserPropertyMap.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java similarity index 68% rename from model-mapper/src/com/baeldung/util/UserPropertyMap.java rename to java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java index 4346174440..9fa945ce32 100644 --- a/model-mapper/src/com/baeldung/util/UserPropertyMap.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java @@ -1,8 +1,5 @@ -package com.baeldung.util; +package com.baeldung.modelmapper; -import com.baeldung.model.User; -import com.baeldung.model.UserDTO; -import com.baeldung.model.UserList; import org.modelmapper.AbstractConverter; import org.modelmapper.Converter; import org.modelmapper.PropertyMap; @@ -11,10 +8,11 @@ import java.util.List; /** * @author sasam0320 - * @date 4/18/2020 + * @description + * UserPropertyMap class instantiates the converter to map the data from the user list to the user name list. + * In the configuration method, we call a converter to do the mapping. */ - -public class UserPropertyMap extends PropertyMap { +public class UserPropertyMap extends PropertyMap { Converter, List> converter = new AbstractConverter, List>() { diff --git a/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UserMappingTest.java b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UserMappingTest.java new file mode 100644 index 0000000000..44a929621b --- /dev/null +++ b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UserMappingTest.java @@ -0,0 +1,85 @@ +package com.baeldung.modelmapper; + +import org.hamcrest.Matchers; +import org.junit.Before; +import org.junit.Test; +import org.modelmapper.ModelMapper; +import org.modelmapper.TypeToken; + +import java.util.ArrayList; +import java.util.List; + +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.hasProperty; +import static org.hamcrest.collection.IsCollectionWithSize.hasSize; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; + + +/** + * @sasam0320 + * @description + * This class has test methods of mapping Integer to Character list, + * mapping user list to DTO list using MapperUtil generic methods and Converter + */ +public class UserMappingTest { + + private ModelMapper mapper; + private List users; + + @Before + public void init() { + + mapper = new ModelMapper(); + mapper.addMappings(new UserPropertyMap()); + users = new ArrayList(); + users.add(new User("b100", "user1", "user1@baeldung.com", "111-222", "USER")); + users.add(new User("b101", "user2", "user2@baeldung.com", "111-333", "USER")); + users.add(new User("b102", "user3", "user3@baeldung.com", "111-444", "ADMIN")); + + } + + @Test + public void testMapIntegerList() { + + List integers = new ArrayList(); + + integers.add(1); + integers.add(2); + integers.add(3); + + List characters = mapper.map(integers, new TypeToken>() { + }.getType()); + + assertThat(characters, hasItems('1','2','3')); + + } + + @Test + public void testMapGenericTypeLists() { + + // Mapping lists using generic type methods + + List userDtoList = MapperUtil.mapList(users, UserDTO.class); + + assertThat(userDtoList, Matchers.hasItem( + Matchers.both(hasProperty("userId", equalTo("b100"))) + .and(hasProperty("email", equalTo("user1@baeldung.com"))) + .and(hasProperty("userName", equalTo("user1"))))); + + // Mapping lists using PropertyMap and Converter + + UserList userList = new UserList(); + userList.setUsers(users); + UserListDTO dto = new UserListDTO(); + mapper.map(userList, dto); + + assertNotNull(dto); + assertThat(dto, Matchers.hasProperty("usernames")); + assertThat(dto.getUsernames(), hasSize(3)); + + } + +} \ No newline at end of file diff --git a/model-mapper/src/Main.java b/model-mapper/src/Main.java deleted file mode 100644 index a6deb49168..0000000000 --- a/model-mapper/src/Main.java +++ /dev/null @@ -1,58 +0,0 @@ -import com.baeldung.model.User; -import com.baeldung.model.UserDTO; -import com.baeldung.model.UserList; -import com.baeldung.util.MapperUtil; -import com.baeldung.util.UserPropertyMap; -import org.modelmapper.ModelMapper; -import org.modelmapper.TypeToken; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author sasam0320 - * @date 4/18/2020 - */ - -public class Main { - - public static void main(String[] args) { - - //Instantiate ModelMapper - - ModelMapper mapper = new ModelMapper(); - mapper.addMappings(new UserPropertyMap()); - - // Mapping lists using TypeToken generic class - - List integers = new ArrayList(); - - integers.add(1); - integers.add(2); - integers.add(3); - - List characters = mapper.map(integers, new TypeToken>() {}.getType()); - - System.out.println("Character list: " + characters); - - // Mapping lists using generic type methods - - List users = new ArrayList(); - users.add(new User("b100", "user1", "user1@baeldung.com", "111-222", "USER")); - users.add(new User("b101", "user2", "user2@baeldung.com", "111-333", "USER")); - users.add(new User("b102", "user3", "user3@baeldung.com", "111-444", "ADMIN")); - - List userDtoList = MapperUtil.mapList(users, UserDTO.class); - userDtoList.stream().map(userDto -> userDto.getEmail()).forEachOrdered(System.out::println); - - // Mapping lists using PropertyMap and Converter - - UserList userList = new UserList(); - userList.setUsers(users); - UserDTO dto = new UserDTO(); - - mapper.map(userList, dto); - dto.getUsernames().forEach(System.out::println); - - } -} diff --git a/parent-java/pom.xml b/parent-java/pom.xml index 4828bc2abb..ba786d912c 100644 --- a/parent-java/pom.xml +++ b/parent-java/pom.xml @@ -45,6 +45,9 @@ 23.0 2.6 1.19 + 2.3.6 + 4.12 + 1.3 From 553e4f1a0454f64390e5aeec4de6347a7a354ab7 Mon Sep 17 00:00:00 2001 From: Justin Albano Date: Tue, 21 Apr 2020 14:27:42 -0400 Subject: [PATCH 305/503] BAEL-3965: Moved examples to new spring-core module --- pom.xml | 2 + spring-core-4/README.md | 7 ++ spring-core-4/pom.xml | 88 +++++++++++++++++++ .../java/com/baeldung/factorymethod/Bar.java | 0 .../java/com/baeldung/factorymethod/Foo.java | 0 .../factorymethod/InstanceBarFactory.java | 0 .../factorymethod/InstanceFooFactory.java | 0 .../factorymethod/SingletonBarFactory.java | 0 .../factorymethod/SingletonFooFactory.java | 0 .../InstanceBarFactoryIntegrationTest.java | 0 .../InstanceFooFactoryIntegrationTest.java | 0 .../SingletonBarFactoryIntegrationTest.java | 0 .../SingletonFooFactoryIntegrationTest.java | 0 .../factorymethod/instance-bar-config.xml | 0 .../factorymethod/instance-foo-config.xml | 0 .../factorymethod/static-bar-config.xml | 18 ++-- .../factorymethod/static-foo-config.xml | 0 17 files changed, 106 insertions(+), 9 deletions(-) create mode 100644 spring-core-4/README.md create mode 100644 spring-core-4/pom.xml rename {spring-core-3 => spring-core-4}/src/main/java/com/baeldung/factorymethod/Bar.java (100%) rename {spring-core-3 => spring-core-4}/src/main/java/com/baeldung/factorymethod/Foo.java (100%) rename {spring-core-3 => spring-core-4}/src/main/java/com/baeldung/factorymethod/InstanceBarFactory.java (100%) rename {spring-core-3 => spring-core-4}/src/main/java/com/baeldung/factorymethod/InstanceFooFactory.java (100%) rename {spring-core-3 => spring-core-4}/src/main/java/com/baeldung/factorymethod/SingletonBarFactory.java (100%) rename {spring-core-3 => spring-core-4}/src/main/java/com/baeldung/factorymethod/SingletonFooFactory.java (100%) rename {spring-core-3 => spring-core-4}/src/test/java/com/baeldung/factorymethod/InstanceBarFactoryIntegrationTest.java (100%) rename {spring-core-3 => spring-core-4}/src/test/java/com/baeldung/factorymethod/InstanceFooFactoryIntegrationTest.java (100%) rename {spring-core-3 => spring-core-4}/src/test/java/com/baeldung/factorymethod/SingletonBarFactoryIntegrationTest.java (100%) rename {spring-core-3 => spring-core-4}/src/test/java/com/baeldung/factorymethod/SingletonFooFactoryIntegrationTest.java (100%) rename {spring-core-3 => spring-core-4}/src/test/resources/factorymethod/instance-bar-config.xml (100%) rename {spring-core-3 => spring-core-4}/src/test/resources/factorymethod/instance-foo-config.xml (100%) rename {spring-core-3 => spring-core-4}/src/test/resources/factorymethod/static-bar-config.xml (54%) rename {spring-core-3 => spring-core-4}/src/test/resources/factorymethod/static-foo-config.xml (100%) diff --git a/pom.xml b/pom.xml index 9e3b354d74..ab6870c780 100644 --- a/pom.xml +++ b/pom.xml @@ -651,6 +651,7 @@ spring-core spring-core-2 spring-core-3 + spring-core-4 spring-cucumber spring-data-rest @@ -1155,6 +1156,7 @@ spring-core spring-core-2 spring-core-3 + spring-core-4 spring-cucumber spring-data-rest diff --git a/spring-core-4/README.md b/spring-core-4/README.md new file mode 100644 index 0000000000..f882c77179 --- /dev/null +++ b/spring-core-4/README.md @@ -0,0 +1,7 @@ +## Spring Core + +This module contains articles about core Spring functionality + +## Relevant Articles: + +- More articles: [[<-- prev]](/spring-core-3) diff --git a/spring-core-4/pom.xml b/spring-core-4/pom.xml new file mode 100644 index 0000000000..06598fb41e --- /dev/null +++ b/spring-core-4/pom.xml @@ -0,0 +1,88 @@ + + + 4.0.0 + spring-core-4 + spring-core-4 + + + com.baeldung + parent-spring-5 + 0.0.1-SNAPSHOT + ../parent-spring-5 + + + + + org.springframework + spring-beans + ${spring.version} + + + org.springframework + spring-tx + ${spring.version} + + + org.springframework + spring-jdbc + ${spring.version} + + + org.springframework.boot + spring-boot-starter-web + ${spring.boot.version} + + + org.springframework + spring-context + ${spring.version} + + + org.springframework + spring-core + ${spring.version} + + + javax.annotation + javax.annotation-api + ${annotation-api.version} + + + org.springframework + spring-test + ${spring.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit-jupiter.version} + test + + + org.junit.jupiter + junit-jupiter-api + ${junit-jupiter.version} + test + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven.surefire.version} + + + + + + 2.22.1 + 1.3.2 + 2.2.2.RELEASE + + + \ No newline at end of file diff --git a/spring-core-3/src/main/java/com/baeldung/factorymethod/Bar.java b/spring-core-4/src/main/java/com/baeldung/factorymethod/Bar.java similarity index 100% rename from spring-core-3/src/main/java/com/baeldung/factorymethod/Bar.java rename to spring-core-4/src/main/java/com/baeldung/factorymethod/Bar.java diff --git a/spring-core-3/src/main/java/com/baeldung/factorymethod/Foo.java b/spring-core-4/src/main/java/com/baeldung/factorymethod/Foo.java similarity index 100% rename from spring-core-3/src/main/java/com/baeldung/factorymethod/Foo.java rename to spring-core-4/src/main/java/com/baeldung/factorymethod/Foo.java diff --git a/spring-core-3/src/main/java/com/baeldung/factorymethod/InstanceBarFactory.java b/spring-core-4/src/main/java/com/baeldung/factorymethod/InstanceBarFactory.java similarity index 100% rename from spring-core-3/src/main/java/com/baeldung/factorymethod/InstanceBarFactory.java rename to spring-core-4/src/main/java/com/baeldung/factorymethod/InstanceBarFactory.java diff --git a/spring-core-3/src/main/java/com/baeldung/factorymethod/InstanceFooFactory.java b/spring-core-4/src/main/java/com/baeldung/factorymethod/InstanceFooFactory.java similarity index 100% rename from spring-core-3/src/main/java/com/baeldung/factorymethod/InstanceFooFactory.java rename to spring-core-4/src/main/java/com/baeldung/factorymethod/InstanceFooFactory.java diff --git a/spring-core-3/src/main/java/com/baeldung/factorymethod/SingletonBarFactory.java b/spring-core-4/src/main/java/com/baeldung/factorymethod/SingletonBarFactory.java similarity index 100% rename from spring-core-3/src/main/java/com/baeldung/factorymethod/SingletonBarFactory.java rename to spring-core-4/src/main/java/com/baeldung/factorymethod/SingletonBarFactory.java diff --git a/spring-core-3/src/main/java/com/baeldung/factorymethod/SingletonFooFactory.java b/spring-core-4/src/main/java/com/baeldung/factorymethod/SingletonFooFactory.java similarity index 100% rename from spring-core-3/src/main/java/com/baeldung/factorymethod/SingletonFooFactory.java rename to spring-core-4/src/main/java/com/baeldung/factorymethod/SingletonFooFactory.java diff --git a/spring-core-3/src/test/java/com/baeldung/factorymethod/InstanceBarFactoryIntegrationTest.java b/spring-core-4/src/test/java/com/baeldung/factorymethod/InstanceBarFactoryIntegrationTest.java similarity index 100% rename from spring-core-3/src/test/java/com/baeldung/factorymethod/InstanceBarFactoryIntegrationTest.java rename to spring-core-4/src/test/java/com/baeldung/factorymethod/InstanceBarFactoryIntegrationTest.java diff --git a/spring-core-3/src/test/java/com/baeldung/factorymethod/InstanceFooFactoryIntegrationTest.java b/spring-core-4/src/test/java/com/baeldung/factorymethod/InstanceFooFactoryIntegrationTest.java similarity index 100% rename from spring-core-3/src/test/java/com/baeldung/factorymethod/InstanceFooFactoryIntegrationTest.java rename to spring-core-4/src/test/java/com/baeldung/factorymethod/InstanceFooFactoryIntegrationTest.java diff --git a/spring-core-3/src/test/java/com/baeldung/factorymethod/SingletonBarFactoryIntegrationTest.java b/spring-core-4/src/test/java/com/baeldung/factorymethod/SingletonBarFactoryIntegrationTest.java similarity index 100% rename from spring-core-3/src/test/java/com/baeldung/factorymethod/SingletonBarFactoryIntegrationTest.java rename to spring-core-4/src/test/java/com/baeldung/factorymethod/SingletonBarFactoryIntegrationTest.java diff --git a/spring-core-3/src/test/java/com/baeldung/factorymethod/SingletonFooFactoryIntegrationTest.java b/spring-core-4/src/test/java/com/baeldung/factorymethod/SingletonFooFactoryIntegrationTest.java similarity index 100% rename from spring-core-3/src/test/java/com/baeldung/factorymethod/SingletonFooFactoryIntegrationTest.java rename to spring-core-4/src/test/java/com/baeldung/factorymethod/SingletonFooFactoryIntegrationTest.java diff --git a/spring-core-3/src/test/resources/factorymethod/instance-bar-config.xml b/spring-core-4/src/test/resources/factorymethod/instance-bar-config.xml similarity index 100% rename from spring-core-3/src/test/resources/factorymethod/instance-bar-config.xml rename to spring-core-4/src/test/resources/factorymethod/instance-bar-config.xml diff --git a/spring-core-3/src/test/resources/factorymethod/instance-foo-config.xml b/spring-core-4/src/test/resources/factorymethod/instance-foo-config.xml similarity index 100% rename from spring-core-3/src/test/resources/factorymethod/instance-foo-config.xml rename to spring-core-4/src/test/resources/factorymethod/instance-foo-config.xml diff --git a/spring-core-3/src/test/resources/factorymethod/static-bar-config.xml b/spring-core-4/src/test/resources/factorymethod/static-bar-config.xml similarity index 54% rename from spring-core-3/src/test/resources/factorymethod/static-bar-config.xml rename to spring-core-4/src/test/resources/factorymethod/static-bar-config.xml index 4d1befc645..e709da36a1 100644 --- a/spring-core-3/src/test/resources/factorymethod/static-bar-config.xml +++ b/spring-core-4/src/test/resources/factorymethod/static-bar-config.xml @@ -1,9 +1,9 @@ - - - + + + \ No newline at end of file diff --git a/spring-core-3/src/test/resources/factorymethod/static-foo-config.xml b/spring-core-4/src/test/resources/factorymethod/static-foo-config.xml similarity index 100% rename from spring-core-3/src/test/resources/factorymethod/static-foo-config.xml rename to spring-core-4/src/test/resources/factorymethod/static-foo-config.xml From d1b282220d4c4671343424b5737312a25dd2e2b1 Mon Sep 17 00:00:00 2001 From: Sasa M Date: Tue, 21 Apr 2020 21:29:38 +0200 Subject: [PATCH 306/503] Renaming test methods and formatting --- java-collections-conversions-2/pom.xml | 14 +++++++------- .../java/com/baeldung/modelmapper/MapperUtil.java | 4 ++-- .../main/java/com/baeldung/modelmapper/User.java | 2 +- .../java/com/baeldung/modelmapper/UserDTO.java | 2 +- .../java/com/baeldung/modelmapper/UserList.java | 2 +- .../java/com/baeldung/modelmapper/UserListDTO.java | 2 +- .../com/baeldung/modelmapper/UserPropertyMap.java | 3 +-- ...pingTest.java => UsersListMappingUnitTest.java} | 13 ++++++------- parent-java/pom.xml | 12 ++++++------ 9 files changed, 26 insertions(+), 28 deletions(-) rename java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/{UserMappingTest.java => UsersListMappingUnitTest.java} (90%) diff --git a/java-collections-conversions-2/pom.xml b/java-collections-conversions-2/pom.xml index ca4ed882dd..892d73cb2b 100644 --- a/java-collections-conversions-2/pom.xml +++ b/java-collections-conversions-2/pom.xml @@ -20,23 +20,23 @@ commons-lang3 ${commons-lang3.version} - + org.modelmapper modelmapper ${modelmapper.version} - - + + junit junit ${junit.version} - test - - + test + + org.hamcrest hamcrest-all ${hamcrest.version} test - + diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java index c02f012126..bbc2153c63 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java @@ -7,10 +7,10 @@ import java.util.ArrayList; import java.util.List; /** - * @author sasam0320 - * @description * This is a helper class that contains methods for generic mapping of the users list. * Initially, an instance of ModelMapper was created. In the static block we set the matching configuration to STRICT. + * + * @author sasam0320 */ public class MapperUtil { diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java index 8f13b44894..7fe22fb262 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java @@ -1,8 +1,8 @@ package com.baeldung.modelmapper; /** + * User model entity class * @author sasam0320 - * @description User model entity class */ public class User { diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java index ce75eecefc..d36b829232 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java @@ -1,8 +1,8 @@ package com.baeldung.modelmapper; /** + * UserDTO model class * @author sasam0320 - * @description UserDTO model class */ public class UserDTO { diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserList.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserList.java index 02361da469..7c410727fd 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserList.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserList.java @@ -3,8 +3,8 @@ package com.baeldung.modelmapper; import java.util.Collection; /** + * UserList class that contain collection of users * @author sasam0320 - * @description UserList class that contain collection of users */ public class UserList { diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserListDTO.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserListDTO.java index fba311c1a3..ac25185635 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserListDTO.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserListDTO.java @@ -3,8 +3,8 @@ package com.baeldung.modelmapper; import java.util.List; /** + * UserListDTO class that contain list of username properties * @author sasam0320 - * @description UserListDTO class that contain list of username properties */ public class UserListDTO { diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java index 9fa945ce32..3d9059c520 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java @@ -7,10 +7,9 @@ import java.util.ArrayList; import java.util.List; /** - * @author sasam0320 - * @description * UserPropertyMap class instantiates the converter to map the data from the user list to the user name list. * In the configuration method, we call a converter to do the mapping. + * @author sasam0320 */ public class UserPropertyMap extends PropertyMap { diff --git a/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UserMappingTest.java b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java similarity index 90% rename from java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UserMappingTest.java rename to java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java index 44a929621b..e03ddf81cf 100644 --- a/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UserMappingTest.java +++ b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java @@ -13,18 +13,17 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.collection.IsCollectionWithSize.hasSize; - import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; /** - * @sasam0320 - * @description * This class has test methods of mapping Integer to Character list, * mapping user list to DTO list using MapperUtil generic methods and Converter + * + * @author sasam0320 */ -public class UserMappingTest { +public class UsersListMappingUnitTest { private ModelMapper mapper; private List users; @@ -42,7 +41,7 @@ public class UserMappingTest { } @Test - public void testMapIntegerList() { + public void whenMapIntegerToCharList() { List integers = new ArrayList(); @@ -53,12 +52,12 @@ public class UserMappingTest { List characters = mapper.map(integers, new TypeToken>() { }.getType()); - assertThat(characters, hasItems('1','2','3')); + assertThat(characters, hasItems('1', '2', '3')); } @Test - public void testMapGenericTypeLists() { + public void givenUsersList_whenUseGenericType_thenMapToDto() { // Mapping lists using generic type methods diff --git a/parent-java/pom.xml b/parent-java/pom.xml index ba786d912c..5c347ef176 100644 --- a/parent-java/pom.xml +++ b/parent-java/pom.xml @@ -1,8 +1,8 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 parent-java 0.0.1-SNAPSHOT @@ -45,9 +45,9 @@ 23.0 2.6 1.19 - 2.3.6 - 4.12 - 1.3 + 2.3.6 + 4.12 + 1.3 From 32d1cc8a13f87217f906dabcc68afbf47fe466fe Mon Sep 17 00:00:00 2001 From: Sasa M Date: Tue, 21 Apr 2020 22:26:22 +0200 Subject: [PATCH 307/503] changes in build pom.xml --- .../src/main/java/com/baeldung/modelmapper/MapperUtil.java | 2 +- .../src/main/java/com/baeldung/modelmapper/User.java | 6 ++++-- .../src/main/java/com/baeldung/modelmapper/UserDTO.java | 3 ++- .../src/main/java/com/baeldung/modelmapper/UserList.java | 3 ++- .../src/main/java/com/baeldung/modelmapper/UserListDTO.java | 3 ++- .../main/java/com/baeldung/modelmapper/UserPropertyMap.java | 4 +++- .../com/baeldung/modelmapper/UsersListMappingUnitTest.java | 2 +- parent-java/pom.xml | 2 +- 8 files changed, 16 insertions(+), 9 deletions(-) diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java index bbc2153c63..546e415755 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java @@ -10,7 +10,7 @@ import java.util.List; * This is a helper class that contains methods for generic mapping of the users list. * Initially, an instance of ModelMapper was created. In the static block we set the matching configuration to STRICT. * - * @author sasam0320 + * @author Sasa Milenkovic */ public class MapperUtil { diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java index 7fe22fb262..23a424dedd 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java @@ -2,7 +2,8 @@ package com.baeldung.modelmapper; /** * User model entity class - * @author sasam0320 + * + * @author Sasa Milenkovic */ public class User { @@ -14,7 +15,8 @@ public class User { // Standard constructors, getters and setters - public User(){} + public User() { + } public User(String userId, String userName, String email, String contactNumber, String userType) { this.userId = userId; diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java index d36b829232..e31414b629 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java @@ -2,7 +2,8 @@ package com.baeldung.modelmapper; /** * UserDTO model class - * @author sasam0320 + * + * @author Sasa Milenkovic */ public class UserDTO { diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserList.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserList.java index 7c410727fd..7b6bed807b 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserList.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserList.java @@ -4,7 +4,8 @@ import java.util.Collection; /** * UserList class that contain collection of users - * @author sasam0320 + * + * @author Sasa Milenkovic */ public class UserList { diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserListDTO.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserListDTO.java index ac25185635..c001cbbc3c 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserListDTO.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserListDTO.java @@ -4,7 +4,8 @@ import java.util.List; /** * UserListDTO class that contain list of username properties - * @author sasam0320 + * + * @author Sasa Milenkovic */ public class UserListDTO { diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java index 3d9059c520..d2c32a307d 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java @@ -3,13 +3,15 @@ package com.baeldung.modelmapper; import org.modelmapper.AbstractConverter; import org.modelmapper.Converter; import org.modelmapper.PropertyMap; + import java.util.ArrayList; import java.util.List; /** * UserPropertyMap class instantiates the converter to map the data from the user list to the user name list. * In the configuration method, we call a converter to do the mapping. - * @author sasam0320 + * + * @author Sasa Milenkovic */ public class UserPropertyMap extends PropertyMap { diff --git a/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java index e03ddf81cf..05792fda38 100644 --- a/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java +++ b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java @@ -21,7 +21,7 @@ import static org.junit.Assert.assertThat; * This class has test methods of mapping Integer to Character list, * mapping user list to DTO list using MapperUtil generic methods and Converter * - * @author sasam0320 + * @author Sasa Milenkovic */ public class UsersListMappingUnitTest { diff --git a/parent-java/pom.xml b/parent-java/pom.xml index 5c347ef176..3b2b5f59de 100644 --- a/parent-java/pom.xml +++ b/parent-java/pom.xml @@ -45,7 +45,7 @@ 23.0 2.6 1.19 - 2.3.6 + 2.3.7 4.12 1.3 From e01bab2ac0a217994918439b750858cf83889ce1 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Wed, 22 Apr 2020 15:42:16 +0530 Subject: [PATCH 308/503] JAVA-921: Migrate mesos-marathon to parent-boot-2 --- mesos-marathon/README.md | 2 +- mesos-marathon/pom.xml | 4 ++-- .../java/com/baeldung/DemoApplicationIntegrationTest.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mesos-marathon/README.md b/mesos-marathon/README.md index 65b2361698..8e5b8e4974 100644 --- a/mesos-marathon/README.md +++ b/mesos-marathon/README.md @@ -6,4 +6,4 @@ This module contains articles about Marathon and Mesos. - [Simple Jenkins Pipeline with Marathon and Mesos](https://www.baeldung.com/jenkins-pipeline-with-marathon-mesos) - To run the pipeline, please modify the dockerise.sh file with your own useranema and password for docker login. + To run the pipeline, please modify the dockerise.sh file with your own username and password for docker login. diff --git a/mesos-marathon/pom.xml b/mesos-marathon/pom.xml index 4fb819c434..42798bb209 100644 --- a/mesos-marathon/pom.xml +++ b/mesos-marathon/pom.xml @@ -7,9 +7,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/mesos-marathon/src/test/java/com/baeldung/DemoApplicationIntegrationTest.java b/mesos-marathon/src/test/java/com/baeldung/DemoApplicationIntegrationTest.java index 85331516f9..dfe944a316 100644 --- a/mesos-marathon/src/test/java/com/baeldung/DemoApplicationIntegrationTest.java +++ b/mesos-marathon/src/test/java/com/baeldung/DemoApplicationIntegrationTest.java @@ -3,8 +3,8 @@ package com.baeldung; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.boot.context.embedded.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.web.client.RestTemplate; From 56153d65d8134d26ef0f6a2a2759b822b3c6ca9f Mon Sep 17 00:00:00 2001 From: Justin Albano Date: Wed, 22 Apr 2020 06:18:31 -0400 Subject: [PATCH 309/503] BAEL-3965: Corrected XML formatting in code examples --- .../factorymethod/instance-bar-config.xml | 20 +++++++++--------- .../factorymethod/instance-foo-config.xml | 20 +++++++++--------- .../factorymethod/static-bar-config.xml | 21 ++++++++----------- .../factorymethod/static-foo-config.xml | 21 ++++++++----------- 4 files changed, 38 insertions(+), 44 deletions(-) diff --git a/spring-core-4/src/test/resources/factorymethod/instance-bar-config.xml b/spring-core-4/src/test/resources/factorymethod/instance-bar-config.xml index 40d2f33683..a4281aee4e 100644 --- a/spring-core-4/src/test/resources/factorymethod/instance-bar-config.xml +++ b/spring-core-4/src/test/resources/factorymethod/instance-bar-config.xml @@ -1,19 +1,19 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util + http://www.springframework.org/schema/util/spring-util.xsd"> + class="com.baeldung.factorymethod.InstanceBarFactory" /> + factory-bean="instanceBarFactory" + factory-method="createInstance"> diff --git a/spring-core-4/src/test/resources/factorymethod/instance-foo-config.xml b/spring-core-4/src/test/resources/factorymethod/instance-foo-config.xml index c45bef6a85..0f21f06f5a 100644 --- a/spring-core-4/src/test/resources/factorymethod/instance-foo-config.xml +++ b/spring-core-4/src/test/resources/factorymethod/instance-foo-config.xml @@ -1,18 +1,18 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util + http://www.springframework.org/schema/util/spring-util.xsd"> + class="com.baeldung.factorymethod.InstanceFooFactory" /> + factory-bean="instanceFooFactory" + factory-method="createInstance" /> \ No newline at end of file diff --git a/spring-core-4/src/test/resources/factorymethod/static-bar-config.xml b/spring-core-4/src/test/resources/factorymethod/static-bar-config.xml index e709da36a1..2cacc293bc 100644 --- a/spring-core-4/src/test/resources/factorymethod/static-bar-config.xml +++ b/spring-core-4/src/test/resources/factorymethod/static-bar-config.xml @@ -1,19 +1,16 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util + http://www.springframework.org/schema/util/spring-util.xsd"> + class="com.baeldung.factorymethod.SingletonBarFactory" + factory-method="createInstance"> diff --git a/spring-core-4/src/test/resources/factorymethod/static-foo-config.xml b/spring-core-4/src/test/resources/factorymethod/static-foo-config.xml index 83e61a656c..ffe1480638 100644 --- a/spring-core-4/src/test/resources/factorymethod/static-foo-config.xml +++ b/spring-core-4/src/test/resources/factorymethod/static-foo-config.xml @@ -1,18 +1,15 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:util="http://www.springframework.org/schema/util" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/util + http://www.springframework.org/schema/util/spring-util.xsd"> + class="com.baeldung.factorymethod.SingletonFooFactory" + factory-method="createInstance" /> \ No newline at end of file From 0cf5e3662336102b3ce4a3ef045c27dadcdace76 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Wed, 22 Apr 2020 17:44:28 +0530 Subject: [PATCH 310/503] JAVA-922: Migrate flyway to parent-boot-2 --- persistence-modules/flyway/pom.xml | 6 +++--- .../flyway/src/main/resources/application.properties | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/persistence-modules/flyway/pom.xml b/persistence-modules/flyway/pom.xml index 01b3dab6ee..f2e393abbf 100644 --- a/persistence-modules/flyway/pom.xml +++ b/persistence-modules/flyway/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../../parent-boot-1 + ../../parent-boot-2 @@ -63,7 +63,7 @@ - 5.0.2 + 5.2.3 5.0.2 diff --git a/persistence-modules/flyway/src/main/resources/application.properties b/persistence-modules/flyway/src/main/resources/application.properties index 4d339eca5c..cee75fa4d9 100644 --- a/persistence-modules/flyway/src/main/resources/application.properties +++ b/persistence-modules/flyway/src/main/resources/application.properties @@ -1 +1 @@ -#flyway.enabled=false \ No newline at end of file +#spring.flyway.enabled=false \ No newline at end of file From 17d9e00dc3dd1cd6d6fb1a03d376a4c6c6e7e6b1 Mon Sep 17 00:00:00 2001 From: Sampada <46674082+sampada07@users.noreply.github.com> Date: Wed, 22 Apr 2020 20:21:36 +0530 Subject: [PATCH 311/503] BAEL-3988: Calling a SOAP web service in Java (#9166) --- jee-7/pom.xml | 23 ++++ .../soap/ws/client/generated/Country.java | 129 ++++++++++++++++++ .../ws/client/generated/CountryService.java | 34 +++++ .../generated/CountryServiceImplService.java | 91 ++++++++++++ .../soap/ws/client/generated/Currency.java | 37 +++++ .../ws/client/generated/ObjectFactory.java | 38 ++++++ .../ws/client/generated/package-info.java | 2 + .../com/baeldung/soap/ws/server/Country.java | 41 ++++++ .../soap/ws/server/CountryRepository.java | 43 ++++++ .../soap/ws/server/CountryService.java | 15 ++ .../soap/ws/server/CountryServiceImpl.java | 15 ++ .../ws/server/CountryServicePublisher.java | 19 +++ .../com/baeldung/soap/ws/server/Currency.java | 15 ++ jee-7/src/main/resources/country.wsdl | 40 ++++++ jee-7/src/main/resources/country.xsd | 21 +++ .../soap/ws/client/CountryClientLiveTest.java | 39 ++++++ 16 files changed, 602 insertions(+) create mode 100644 jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Country.java create mode 100644 jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryService.java create mode 100644 jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java create mode 100644 jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Currency.java create mode 100644 jee-7/src/main/java/com/baeldung/soap/ws/client/generated/ObjectFactory.java create mode 100644 jee-7/src/main/java/com/baeldung/soap/ws/client/generated/package-info.java create mode 100644 jee-7/src/main/java/com/baeldung/soap/ws/server/Country.java create mode 100644 jee-7/src/main/java/com/baeldung/soap/ws/server/CountryRepository.java create mode 100644 jee-7/src/main/java/com/baeldung/soap/ws/server/CountryService.java create mode 100644 jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServiceImpl.java create mode 100644 jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServicePublisher.java create mode 100644 jee-7/src/main/java/com/baeldung/soap/ws/server/Currency.java create mode 100644 jee-7/src/main/resources/country.wsdl create mode 100644 jee-7/src/main/resources/country.xsd create mode 100644 jee-7/src/test/java/com/baeldung/soap/ws/client/CountryClientLiveTest.java diff --git a/jee-7/pom.xml b/jee-7/pom.xml index a2593e46a5..7352c6550a 100644 --- a/jee-7/pom.xml +++ b/jee-7/pom.xml @@ -242,6 +242,29 @@ + + + org.codehaus.mojo + jaxws-maven-plugin + 2.6 + + + wsimport-from-jdk + + wsimport + + + + + src/main/resources + + country.wsdl + + true + com.baeldung.soap.ws.client.generated + src/main/java + + diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Country.java b/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Country.java new file mode 100644 index 0000000000..6a810b9afa --- /dev/null +++ b/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Country.java @@ -0,0 +1,129 @@ + +package com.baeldung.soap.ws.client.generated; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; + +/** + *

    Java class for country complex type. + * + *

    The following schema fragment specifies the expected content contained within this class. + * + *

    + * <complexType name="country">
    + *   <complexContent>
    + *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
    + *       <sequence>
    + *         <element name="capital" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
    + *         <element name="currency" type="{http://server.ws.soap.baeldung.com/}currency" minOccurs="0"/>
    + *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
    + *         <element name="population" type="{http://www.w3.org/2001/XMLSchema}int"/>
    + *       </sequence>
    + *     </restriction>
    + *   </complexContent>
    + * </complexType>
    + * 
    + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "country", propOrder = { "capital", "currency", "name", "population" }) +public class Country { + + protected String capital; + @XmlSchemaType(name = "string") + protected Currency currency; + protected String name; + protected int population; + + /** + * Gets the value of the capital property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCapital() { + return capital; + } + + /** + * Sets the value of the capital property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCapital(String value) { + this.capital = value; + } + + /** + * Gets the value of the currency property. + * + * @return + * possible object is + * {@link Currency } + * + */ + public Currency getCurrency() { + return currency; + } + + /** + * Sets the value of the currency property. + * + * @param value + * allowed object is + * {@link Currency } + * + */ + public void setCurrency(Currency value) { + this.currency = value; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the value of the population property. + * + */ + public int getPopulation() { + return population; + } + + /** + * Sets the value of the population property. + * + */ + public void setPopulation(int value) { + this.population = value; + } + +} diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryService.java b/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryService.java new file mode 100644 index 0000000000..bda4a305a5 --- /dev/null +++ b/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryService.java @@ -0,0 +1,34 @@ + +package com.baeldung.soap.ws.client.generated; + +import javax.jws.WebMethod; +import javax.jws.WebParam; +import javax.jws.WebResult; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; +import javax.xml.bind.annotation.XmlSeeAlso; +import javax.xml.ws.Action; + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.3.2 + * Generated source version: 2.2 + * + */ +@WebService(name = "CountryService", targetNamespace = "http://server.ws.soap.baeldung.com/") +@SOAPBinding(style = SOAPBinding.Style.RPC) +@XmlSeeAlso({ ObjectFactory.class }) +public interface CountryService { + + /** + * + * @param arg0 + * @return + * returns com.baeldung.soap.ws.client.generated.Country + */ + @WebMethod + @WebResult(partName = "return") + @Action(input = "http://server.ws.soap.baeldung.com/CountryService/findByNameRequest", output = "http://server.ws.soap.baeldung.com/CountryService/findByNameResponse") + public Country findByName(@WebParam(name = "arg0", partName = "arg0") String arg0); + +} diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java b/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java new file mode 100644 index 0000000000..09f4c29202 --- /dev/null +++ b/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java @@ -0,0 +1,91 @@ + +package com.baeldung.soap.ws.client.generated; + +import java.net.MalformedURLException; +import java.net.URL; +import javax.xml.namespace.QName; +import javax.xml.ws.Service; +import javax.xml.ws.WebEndpoint; +import javax.xml.ws.WebServiceClient; +import javax.xml.ws.WebServiceException; +import javax.xml.ws.WebServiceFeature; + +/** + * This class was generated by the JAX-WS RI. + * JAX-WS RI 2.3.2 + * Generated source version: 2.2 + * + */ +@WebServiceClient(name = "CountryServiceImplService", targetNamespace = "http://server.ws.soap.baeldung.com/", wsdlLocation = "file:src/main/resources/country.wsdl") +public class CountryServiceImplService extends Service { + + private final static URL COUNTRYSERVICEIMPLSERVICE_WSDL_LOCATION; + private final static WebServiceException COUNTRYSERVICEIMPLSERVICE_EXCEPTION; + private final static QName COUNTRYSERVICEIMPLSERVICE_QNAME = new QName("http://server.ws.soap.baeldung.com/", "CountryServiceImplService"); + + static { + URL url = null; + WebServiceException e = null; + try { + url = new URL("file:src/main/resources/country.wsdl"); + } catch (MalformedURLException ex) { + e = new WebServiceException(ex); + } + COUNTRYSERVICEIMPLSERVICE_WSDL_LOCATION = url; + COUNTRYSERVICEIMPLSERVICE_EXCEPTION = e; + } + + public CountryServiceImplService() { + super(__getWsdlLocation(), COUNTRYSERVICEIMPLSERVICE_QNAME); + } + + public CountryServiceImplService(WebServiceFeature... features) { + super(__getWsdlLocation(), COUNTRYSERVICEIMPLSERVICE_QNAME, features); + } + + public CountryServiceImplService(URL wsdlLocation) { + super(wsdlLocation, COUNTRYSERVICEIMPLSERVICE_QNAME); + } + + public CountryServiceImplService(URL wsdlLocation, WebServiceFeature... features) { + super(wsdlLocation, COUNTRYSERVICEIMPLSERVICE_QNAME, features); + } + + public CountryServiceImplService(URL wsdlLocation, QName serviceName) { + super(wsdlLocation, serviceName); + } + + public CountryServiceImplService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { + super(wsdlLocation, serviceName, features); + } + + /** + * + * @return + * returns CountryService + */ + @WebEndpoint(name = "CountryServiceImplPort") + public CountryService getCountryServiceImplPort() { + return super.getPort(new QName("http://server.ws.soap.baeldung.com/", "CountryServiceImplPort"), CountryService.class); + } + + /** + * + * @param features + * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the features parameter will have their default values. + * @return + * returns CountryService + */ + @WebEndpoint(name = "CountryServiceImplPort") + public CountryService getCountryServiceImplPort(WebServiceFeature... features) { + return super.getPort(new QName("http://server.ws.soap.baeldung.com/", "CountryServiceImplPort"), CountryService.class, features); + } + + private static URL __getWsdlLocation() { + if (COUNTRYSERVICEIMPLSERVICE_EXCEPTION != null) { + throw COUNTRYSERVICEIMPLSERVICE_EXCEPTION; + } + return COUNTRYSERVICEIMPLSERVICE_WSDL_LOCATION; + } + +} diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Currency.java b/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Currency.java new file mode 100644 index 0000000000..8b9355edc5 --- /dev/null +++ b/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/Currency.java @@ -0,0 +1,37 @@ + +package com.baeldung.soap.ws.client.generated; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + +/** + *

    Java class for currency. + * + *

    The following schema fragment specifies the expected content contained within this class. + *

    + *

    + * <simpleType name="currency">
    + *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
    + *     <enumeration value="EUR"/>
    + *     <enumeration value="INR"/>
    + *     <enumeration value="USD"/>
    + *   </restriction>
    + * </simpleType>
    + * 
    + * + */ +@XmlType(name = "currency") +@XmlEnum +public enum Currency { + + EUR, INR, USD; + + public String value() { + return name(); + } + + public static Currency fromValue(String v) { + return valueOf(v); + } + +} diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/ObjectFactory.java b/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/ObjectFactory.java new file mode 100644 index 0000000000..241debe758 --- /dev/null +++ b/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/ObjectFactory.java @@ -0,0 +1,38 @@ + +package com.baeldung.soap.ws.client.generated; + +import javax.xml.bind.annotation.XmlRegistry; + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.baeldung.soap.ws.client.generated package. + *

    An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.soap.ws.client.generated + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link Country } + * + */ + public Country createCountry() { + return new Country(); + } + +} diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/package-info.java b/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/package-info.java new file mode 100644 index 0000000000..6df70b70f1 --- /dev/null +++ b/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/package-info.java @@ -0,0 +1,2 @@ +@javax.xml.bind.annotation.XmlSchema(namespace = "http://server.ws.soap.baeldung.com/", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package com.baeldung.soap.ws.client.generated; diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/server/Country.java b/jee-7/src/main/java/com/baeldung/soap/ws/server/Country.java new file mode 100644 index 0000000000..62ea4a22ed --- /dev/null +++ b/jee-7/src/main/java/com/baeldung/soap/ws/server/Country.java @@ -0,0 +1,41 @@ +package com.baeldung.soap.ws.server; + +public class Country { + protected String name; + protected int population; + protected String capital; + protected Currency currency; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getPopulation() { + return population; + } + + public void setPopulation(int population) { + this.population = population; + } + + public String getCapital() { + return capital; + } + + public void setCapital(String capital) { + this.capital = capital; + } + + public Currency getCurrency() { + return currency; + } + + public void setCurrency(Currency currency) { + this.currency = currency; + } + +} \ No newline at end of file diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryRepository.java b/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryRepository.java new file mode 100644 index 0000000000..558f7c1293 --- /dev/null +++ b/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryRepository.java @@ -0,0 +1,43 @@ +package com.baeldung.soap.ws.server; + +import java.util.HashMap; +import java.util.Map; + +public class CountryRepository { + + private static final Map countries = new HashMap<>(); + + { + initData(); + } + + private final static void initData() { + Country usa = new Country(); + usa.setName("USA"); + usa.setCapital("Washington D.C."); + usa.setCurrency(Currency.USD); + usa.setPopulation(323947000); + + countries.put(usa.getName(), usa); + + Country india = new Country(); + india.setName("India"); + india.setCapital("New Delhi"); + india.setCurrency(Currency.INR); + india.setPopulation(1295210000); + + countries.put(india.getName(), india); + + Country france = new Country(); + france.setName("France"); + france.setCapital("Paris"); + france.setCurrency(Currency.EUR); + france.setPopulation(66710000); + + countries.put(france.getName(), france); + } + + public Country findCountry(String name) { + return countries.get(name); + } +} diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryService.java b/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryService.java new file mode 100644 index 0000000000..e3f68a4e59 --- /dev/null +++ b/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryService.java @@ -0,0 +1,15 @@ +package com.baeldung.soap.ws.server; + +import javax.jws.WebMethod; +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; +import javax.jws.soap.SOAPBinding.Style; + +@WebService +@SOAPBinding(style=Style.RPC) +public interface CountryService { + + @WebMethod + Country findByName(String name); + +} diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServiceImpl.java b/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServiceImpl.java new file mode 100644 index 0000000000..a8c6250354 --- /dev/null +++ b/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServiceImpl.java @@ -0,0 +1,15 @@ +package com.baeldung.soap.ws.server; + +import javax.jws.WebService; + +@WebService(endpointInterface = "com.baeldung.soap.ws.server.CountryService") +public class CountryServiceImpl implements CountryService { + + private CountryRepository countryRepository = new CountryRepository(); + + @Override + public Country findByName(String name) { + return countryRepository.findCountry(name); + } + +} diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServicePublisher.java b/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServicePublisher.java new file mode 100644 index 0000000000..e7c1c480f4 --- /dev/null +++ b/jee-7/src/main/java/com/baeldung/soap/ws/server/CountryServicePublisher.java @@ -0,0 +1,19 @@ +package com.baeldung.soap.ws.server; + +import javax.xml.ws.Endpoint; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class CountryServicePublisher { + + private static final Logger logger = LoggerFactory.getLogger(CountryServicePublisher.class); + + public static void main(String[] args) { + Endpoint endpoint = Endpoint.create(new CountryServiceImpl()); + endpoint.publish("http://localhost:8888/ws/country"); + + logger.info("Country web service ready to consume requests!"); + } +} \ No newline at end of file diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/server/Currency.java b/jee-7/src/main/java/com/baeldung/soap/ws/server/Currency.java new file mode 100644 index 0000000000..d1b25a26c6 --- /dev/null +++ b/jee-7/src/main/java/com/baeldung/soap/ws/server/Currency.java @@ -0,0 +1,15 @@ +package com.baeldung.soap.ws.server; + +public enum Currency { + + EUR, INR, USD; + + public String value() { + return name(); + } + + public static Currency fromValue(String v) { + return valueOf(v); + } + +} diff --git a/jee-7/src/main/resources/country.wsdl b/jee-7/src/main/resources/country.wsdl new file mode 100644 index 0000000000..4d41fce322 --- /dev/null +++ b/jee-7/src/main/resources/country.wsdl @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jee-7/src/main/resources/country.xsd b/jee-7/src/main/resources/country.xsd new file mode 100644 index 0000000000..c94b6047f9 --- /dev/null +++ b/jee-7/src/main/resources/country.xsd @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/jee-7/src/test/java/com/baeldung/soap/ws/client/CountryClientLiveTest.java b/jee-7/src/test/java/com/baeldung/soap/ws/client/CountryClientLiveTest.java new file mode 100644 index 0000000000..ae423f9bdd --- /dev/null +++ b/jee-7/src/test/java/com/baeldung/soap/ws/client/CountryClientLiveTest.java @@ -0,0 +1,39 @@ +package com.baeldung.soap.ws.client; + +import static org.junit.Assert.assertEquals; + +import org.junit.BeforeClass; +import org.junit.Test; + +import com.baeldung.soap.ws.client.generated.CountryService; +import com.baeldung.soap.ws.client.generated.CountryServiceImplService; +import com.baeldung.soap.ws.client.generated.Currency; + +//Ensure that com.baeldung.soap.ws.server.CountryServicePublisher is running before executing this test +public class CountryClientLiveTest { + + private static CountryService countryService; + + @BeforeClass + public static void setup() { + CountryServiceImplService service = new CountryServiceImplService(); + countryService = service.getCountryServiceImplPort(); + } + + @Test + public void givenCountryService_whenCountryIndia_thenCapitalIsNewDelhi() { + assertEquals("New Delhi", countryService.findByName("India").getCapital()); + } + + @Test + public void givenCountryService_whenCountryFrance_thenPopulationCorrect() { + assertEquals(66710000, countryService.findByName("France").getPopulation()); + } + + @Test + public void givenCountryService_whenCountryUSA_thenCurrencyUSD() { + assertEquals(Currency.USD, countryService.findByName("USA").getCurrency()); + } + + +} From 28de9f499781531a65d71041ebd5101f1401793c Mon Sep 17 00:00:00 2001 From: Mona Mohamadinia Date: Wed, 22 Apr 2020 20:37:18 +0430 Subject: [PATCH 312/503] Added Log Group Sample (#9112) --- .../baeldung/group/LogGroupApplication.java | 26 +++++++++++++++++++ .../application-log-group.properties | 1 + 2 files changed, 27 insertions(+) create mode 100644 spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/group/LogGroupApplication.java create mode 100644 spring-boot-modules/spring-boot-logging-log4j2/src/main/resources/application-log-group.properties diff --git a/spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/group/LogGroupApplication.java b/spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/group/LogGroupApplication.java new file mode 100644 index 0000000000..021f27bd98 --- /dev/null +++ b/spring-boot-modules/spring-boot-logging-log4j2/src/main/java/com/baeldung/group/LogGroupApplication.java @@ -0,0 +1,26 @@ +package com.baeldung.group; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@SpringBootApplication +@ActiveProfiles("log-group") +public class LogGroupApplication { + + private static final Logger LOGGER = LoggerFactory.getLogger(LogGroupApplication.class); + + @RequestMapping("/log-group") + public void justLog() { + LOGGER.debug("Received a request"); + } + + public static void main(String[] args) { + SpringApplication.run(LogGroupApplication.class, args); + } +} diff --git a/spring-boot-modules/spring-boot-logging-log4j2/src/main/resources/application-log-group.properties b/spring-boot-modules/spring-boot-logging-log4j2/src/main/resources/application-log-group.properties new file mode 100644 index 0000000000..6dfe11724e --- /dev/null +++ b/spring-boot-modules/spring-boot-logging-log4j2/src/main/resources/application-log-group.properties @@ -0,0 +1 @@ +logging.level.web=debug \ No newline at end of file From b2af9262a218ada40a62a3abeddfe0ae0a763a50 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Wed, 22 Apr 2020 18:15:29 +0200 Subject: [PATCH 313/503] JAVA-1130: Improvements after review --- .../spring-security-x509/README.md | 7 +++ .../src/main/resources/application.properties | 2 +- .../src/main/resources/application.properties | 4 +- .../spring-security-x509/store/clientBob.p12 | Bin 4024 -> 4024 bytes .../spring-security-x509/store/keystore.jks | Bin 3718 -> 3793 bytes .../spring-security-x509/store/localhost.ext | 5 ++ .../spring-security-x509/store/rootCA.crt | 56 +++++++++--------- .../spring-security-x509/store/truststore.jks | Bin 1358 -> 1358 bytes 8 files changed, 43 insertions(+), 31 deletions(-) create mode 100644 spring-security-modules/spring-security-x509/store/localhost.ext diff --git a/spring-security-modules/spring-security-x509/README.md b/spring-security-modules/spring-security-x509/README.md index b1eb0debf5..da431d862c 100644 --- a/spring-security-modules/spring-security-x509/README.md +++ b/spring-security-modules/spring-security-x509/README.md @@ -4,3 +4,10 @@ This module contains articles about X.509 authentication with Spring Security ### Relevant Articles: - [X.509 Authentication in Spring Security](https://www.baeldung.com/x-509-authentication-in-spring-security) + +###### Note for the [X.509 Authentication in Spring Security](https://www.baeldung.com/x-509-authentication-in-spring-security): +All the ready to use certificates are located in the [store](store) directory. The application is already configured to use these files. +This means the app works out of the box. + +However, it's highly recommended that you follow the article step by step and generate all the needed files by yourself. +This will let you understand the topic more deeply. \ No newline at end of file diff --git a/spring-security-modules/spring-security-x509/spring-security-x509-basic-auth/src/main/resources/application.properties b/spring-security-modules/spring-security-x509/spring-security-x509-basic-auth/src/main/resources/application.properties index 208cc90b47..0ba5fa1b8c 100644 --- a/spring-security-modules/spring-security-x509/spring-security-x509-basic-auth/src/main/resources/application.properties +++ b/spring-security-modules/spring-security-x509/spring-security-x509-basic-auth/src/main/resources/application.properties @@ -1,4 +1,4 @@ -server.ssl.key-store=store/keystore.jks +server.ssl.key-store=../store/keystore.jks server.ssl.key-store-password=changeit server.ssl.key-alias=localhost server.ssl.key-password=changeit diff --git a/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/application.properties b/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/application.properties index b841a37916..fc2fc89396 100644 --- a/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/application.properties +++ b/spring-security-modules/spring-security-x509/spring-security-x509-client-auth/src/main/resources/application.properties @@ -1,4 +1,4 @@ -server.ssl.key-store=store/keystore.jks +server.ssl.key-store=../store/keystore.jks server.ssl.key-store-password=changeit server.ssl.key-alias=localhost server.ssl.key-password=changeit @@ -6,6 +6,6 @@ server.ssl.enabled=true server.port=8443 spring.security.user.name=Admin spring.security.user.password=admin -server.ssl.trust-store=store/truststore.jks +server.ssl.trust-store=../store/truststore.jks server.ssl.trust-store-password=changeit server.ssl.client-auth=need \ No newline at end of file diff --git a/spring-security-modules/spring-security-x509/store/clientBob.p12 b/spring-security-modules/spring-security-x509/store/clientBob.p12 index e5d6dbcefbfaffa2502b1ed9613bc1cb2f9ce573..b5de8ab129d23828273dd98f929290facba95900 100644 GIT binary patch delta 3873 zcmV++58m*&AGjZoU4Q2&VG(;`5vl?L2mpYB1u*))0w&KpMQ*&;D4eU zRy+CLM1On8D*BZnlb3MI6AR^(1Hq8#AD9L0n^9KS?+LD2_$!s4X}{+ahn)(1N-d^1 z=z3mhLx38L`G9Q(kr}kgax+hi@U`+D{O+G!^y78eHk z8gMKz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30YdF+uzR0HU_MT#p$SN(5qW7H}zx8-`Z{%r6}%_Qdiz%o|CPr zTW4ilMvjD(!y_oXVABKh2hyf{f5u=g=Y%evxv{bf@rVLk%L|Cm*}sCtuszMc!;L z>%5(6ZPmw_6}hmR(Dq2Of2N)kp$r5RMLVU0d6>5#=*V{LP!rJ~iOvp#X#i_a z=zXq$he4A1A+kAA*p74b&-)B;W#K5cU5chpu$bBoZ(1dQQLxp3xINI7{@g9(~lrjoe zHOosPScHXqtJ+Khm5lda%2(06C7+iPQHJK$2TpsC5ejRkem;psYhvR%mYnZ)UC{wK zL5Ren02fXW9N{_(X2^SwGz{X(T^EmTM~{QIWGVY9SAjt@f0NfXf=o)T!#Df&{WghQ zNcMBRaEDlIDz2Hj!z0352&|aq7|UbxC$T)-RYh$JpbaV+248L+(AfeW6e+kMwfC#( zJijG1E8qd`|8lI&jn+NzujwQ9O+ZXWwpRQ$5dqCN9==CM?C%jVNH8G=2`Yw2hW8Bt z2^29D9ufd!lTZ&KM{`1OWXoUbYsdtlRu{zfTPRWhp)fHpAutIB1uG5%0vZJX1Qei& j&_LVj?80iaS?>Yc_6lSYNZtep*ryu3@?Rd@0s;sCfbed! diff --git a/spring-security-modules/spring-security-x509/store/keystore.jks b/spring-security-modules/spring-security-x509/store/keystore.jks index 8650651a1e0a884555a4219049340ce2314315cb..c317c1d5ba5ba67fe18af77ec98ce6085616a2f6 100644 GIT binary patch delta 3702 zcmV-+4vF!G9nl?-AAh2S4%Ywx35GC&34$;V1_~<%0R#am0uccL1pows32q45b)2B9 z{nOAXELhkqR{S7)Xfm1pgMI<&gX_`6Ee7hGdK00sMCxpCR{rC^V%B4p=q9hp%*pRd zy(-kChTC=RRgY_C%-j_u+A=R9ZuW`X9p(81-P%5wHo`&A5`XL~W?ZgUiix!;U&HN} z5QqjHKDvLzb(GmNYC9{w?TxBG-gm^R`*y-r1sI9-BEOd<7Q11`?lF)dL45#G$`X9K zC||$q?-C7yVG3yW9LQhKJS$$S*v|rsH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O%&6SJalr<&F~QMl!Yg5ENXIxiw#>tLP?9J)dzOP5yxC_|hzNpRD} zft3W1O*c6GzF6SK?kcMqjo}W#FC9G*8Y#iVSfMo?E@bNZyGKcQLlh{F?gP?PzblKc zEb@4kJ%SiSXwRcXB~<(kBp#AP-^88=e>V;We>rp3FM$C>bvY5*vz;H|h?E(V<00A%!1_>&LNQUCp3a__9Nr`(L#2(<1y8T4AT8h8;eth~Df z#Mg%2^(`lwi6?~LzXr8bIUj>vwz+@oymr-Ci(0x_7VFJMQ}U2m(?zy@+B2dkYlcz} z(1(_8>&T$ZG2{eMB*eLXE8z zHrJtqCzCX^8n}1_PVPWVeznXBMwrC%Lw;<(4*j5H*rR~bhcvFy)mvr^1|P5Y!YnsG z*W*6X$OWGZzqwyPD~}nYLzcg0nTltAPy#Saauwp5Y|JynmSOI1rBUJ}HHni+$+eQ- xXq=dge{@X+ok({7p1I8BgvfmAtjW4EI5v&5?&En6N+7MDmg91K}-DNGm*vtR` diff --git a/spring-security-modules/spring-security-x509/store/localhost.ext b/spring-security-modules/spring-security-x509/store/localhost.ext new file mode 100644 index 0000000000..45324cc75a --- /dev/null +++ b/spring-security-modules/spring-security-x509/store/localhost.ext @@ -0,0 +1,5 @@ +authorityKeyIdentifier=keyid,issuer +basicConstraints=CA:FALSE +subjectAltName = @alt_names +[alt_names] +DNS.1 = localhost diff --git a/spring-security-modules/spring-security-x509/store/rootCA.crt b/spring-security-modules/spring-security-x509/store/rootCA.crt index 12677eb99f..b2ab681744 100644 --- a/spring-security-modules/spring-security-x509/store/rootCA.crt +++ b/spring-security-modules/spring-security-x509/store/rootCA.crt @@ -1,30 +1,30 @@ -----BEGIN CERTIFICATE----- -MIIFDzCCAvegAwIBAgIUHBIbl/8i0uLnPD8BuNHninzcqEMwDQYJKoZIhvcNAQEL -BQAwFzEVMBMGA1UEAwwMQmFlbGR1bmcuY29tMB4XDTIwMDQxOTE2MTYyOFoXDTMw -MDQxNzE2MTYyOFowFzEVMBMGA1UE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KwLPLyozScwnFQE9SZR9d2cu6sC +yxQtcd68vdvAIEDTk4DcSldeT44HIJ7RYQuBNZ5NU3SngMLDleec/3AZSUXTExFW +TrbMTb+djM+XcTkRyO0wO0MYpjKGqN3sAGfppx0G9kgmJ9HB38nZfvqj3G1L9YFQ +6kSA -----END CERTIFICATE----- diff --git a/spring-security-modules/spring-security-x509/store/truststore.jks b/spring-security-modules/spring-security-x509/store/truststore.jks index 56654d8894466a86807235b65167f49f0a4b5a1d..1d0d20058040144717dadcfbc0560b85a0e9a284 100644 GIT binary patch delta 1196 zcmV;d1XKIY3eF0U7zCn`0jiN48Wav_M%Nf4Kpw>G%_$TH8U|XFp-fvf0{#*c?3`e2WTcLJ2~04_Cl4LhBc1ubFsmUEESO8 zWjuFwIRYb<%zIc-va%-mrcoviANiPd4+Z9OifMRL&)th4$4Bia z?012s_E}?!lx=kPT~N<2D>O+Mrojf83mjR7m`53I|DTsU?*h>sFTJc2k1h5mL(94hCS4OP-)7 zndx}3Vd#nvJ=zy10v8~iZNMe1D?8=BT-y#q1IpA@lVaG89>~7X7Ck)qLWj|H-Je^i zfLQldZwDue;mcuRZ&`Xj<0CpEDSy?9>|UNg!muufOhVs?rWSyYV`l|B>?7$<@RceN2O6czs= zsARS+7|H>XyU^zabiAF{%Nn!s7m(K7_{v~v*1yc}PRsq_`xZFcr1@;{E&ByG^CJ{! zPqX9{yy9(!I@^$(O)c8|cLDUqf$GfIM8@#m=L@}>!_fjixvt@dw8gMEskx~?Hi43foCRFB#o1jl z2UE$4OOo4@O`*GYwzVJhL@dYQFoF+v!zHD^j0SR3dJneu0%<9a!Y0P;E5lyZFG(x{ zTf?S)0uGbLXl1mdkLd%&}*lt?kmt|D}hv@G^oP7+xwhn58vXJ zqUK(Z7iaz^Io%H>l)n~G!-q!!`bDO?316>rK&^#DsU^@rfMa;!3uFUGi~Xn7xK7o% zI;@-^K%KL*{>vFS{S#4EFrgTOH=Q6Q(0m}H2WIb2$7#EKn}&aZp3n{MdivL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8b6c667ce058c09870c0784627fdf831a2dfe912 Mon Sep 17 00:00:00 2001 From: Kyle Doyle Date: Wed, 22 Apr 2020 21:10:52 -0400 Subject: [PATCH 314/503] Bael-3893 AWS AppSync with Spring Boot --- aws-app-sync/pom.xml | 6 -- .../awsappsync/AppSyncClientHelper.java | 32 ++++++++++ .../AwsAppSyncApplicationTests.java | 63 ++----------------- 3 files changed, 38 insertions(+), 63 deletions(-) create mode 100644 aws-app-sync/src/main/java/com/baeldung/awsappsync/AppSyncClientHelper.java diff --git a/aws-app-sync/pom.xml b/aws-app-sync/pom.xml index d30cfc96a4..ef2085ff35 100644 --- a/aws-app-sync/pom.xml +++ b/aws-app-sync/pom.xml @@ -22,12 +22,6 @@ - - com.amazonaws - aws-java-sdk-appsync - 1.11.762 - - org.springframework.boot spring-boot-starter-web diff --git a/aws-app-sync/src/main/java/com/baeldung/awsappsync/AppSyncClientHelper.java b/aws-app-sync/src/main/java/com/baeldung/awsappsync/AppSyncClientHelper.java new file mode 100644 index 0000000000..fcbc0aa275 --- /dev/null +++ b/aws-app-sync/src/main/java/com/baeldung/awsappsync/AppSyncClientHelper.java @@ -0,0 +1,32 @@ +package com.baeldung.awsappsync; + +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.client.WebClient; + +import java.nio.charset.StandardCharsets; +import java.util.Map; + +public class AppSyncClientHelper { + + static String apiUrl = "https://m4i3b6icrrb7livfbypfspiifi.appsync-api.us-east-2.amazonaws.com"; + static String apiKey = "da2-es2s6oj4mzhbxk5yu26ss2ruj4"; + static String API_KEY_HEADER = "x-api-key"; + + public static WebClient.ResponseSpec getResponseBodySpec(Map requestBody) { + return WebClient + .builder() + .baseUrl(apiUrl) + .defaultHeader(API_KEY_HEADER, apiKey) + .defaultHeader("Content-Type", "application/json") + .build() + .method(HttpMethod.POST) + .uri("/graphql") + .body(BodyInserters.fromValue(requestBody)) + .accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML) + .acceptCharset(StandardCharsets.UTF_8) + .retrieve(); + } + +} diff --git a/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java b/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java index 005d533cbf..cd14bcd5b2 100644 --- a/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java +++ b/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java @@ -1,14 +1,9 @@ package com.baeldung.awsappsync; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.http.HttpMethod; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.BodyInserters; import org.springframework.web.reactive.function.client.WebClient; -import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -17,48 +12,16 @@ import static org.junit.jupiter.api.Assertions.*; @SpringBootTest class AwsAppSyncApplicationTests { - static String apiUrl = "https://m4i3b6icrrb7livfbypfspiifi.appsync-api.us-east-2.amazonaws.com"; - static String apiKey = "da2-es2s6oj4mzhbxk5yu26ss2ruj4"; - static String API_KEY_HEADER = "x-api-key"; - - static WebClient.RequestBodySpec requestBodySpec; - - @BeforeAll - static void setUp() { - requestBodySpec = WebClient - .builder() - .baseUrl(apiUrl) - .defaultHeader(API_KEY_HEADER, apiKey) - .build() - .method(HttpMethod.POST) - .uri("/graphql"); - } - @Test void givenGraphQuery_whenListEvents_thenReturnAllEvents() { Map requestBody = new HashMap<>(); - requestBody.put("query", "query ListEvents {\n" + - " listEvents {\n" + - " items {\n" + - " id\n" + - " name\n" + - " where\n" + - " when\n" + - " description\n" + - " }\n" + - " }\n" + - "}"); + requestBody.put("query", "query ListEvents { listEvents { items { id name where when description } } }"); requestBody.put("variables", ""); requestBody.put("operationName", "ListEvents"); - WebClient.ResponseSpec response = requestBodySpec - .body(BodyInserters.fromValue(requestBody)) - .accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML) - .acceptCharset(StandardCharsets.UTF_8) - .retrieve(); - - String bodyString = response.bodyToMono(String.class).block(); + String bodyString = AppSyncClientHelper.getResponseBodySpec(requestBody) + .bodyToMono(String.class).block(); assertNotNull(bodyString); assertTrue(bodyString.contains("My First Event")); @@ -69,18 +32,8 @@ class AwsAppSyncApplicationTests { @Test void givenGraphAdd_whenMutation_thenReturnIdNameDesc() { - String queryString = "mutation add {\n" + - " createEvent(\n" + - " name:\"My added GraphQL event\"\n" + - " where:\"Day 2\"\n" + - " when:\"Saturday night\"\n" + - " description:\"Studying GraphQL\"\n" + - " ){\n" + - " id\n" + - " name\n" + - " description\n" + - " }\n" + - "}"; + String queryString = "mutation add { createEvent( name:\"My added GraphQL event\" where:\"Day 2\"" + + " when:\"Saturday night\" description:\"Studying GraphQL\" ){ id name description } }"; Map requestBody = new HashMap<>(); @@ -88,11 +41,7 @@ class AwsAppSyncApplicationTests { requestBody.put("variables", ""); requestBody.put("operationName", "add"); - WebClient.ResponseSpec response = requestBodySpec - .body(BodyInserters.fromValue(requestBody)) - .accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML) - .acceptCharset(StandardCharsets.UTF_8) - .retrieve(); + WebClient.ResponseSpec response = AppSyncClientHelper.getResponseBodySpec(requestBody); String bodyString = response.bodyToMono(String.class).block(); From 8985f601a7c9b32951f2fb369092f8ab89ca0741 Mon Sep 17 00:00:00 2001 From: Gang Wu Date: Wed, 22 Apr 2020 22:15:54 -0600 Subject: [PATCH 315/503] BAEL-3961 move the sql string into a new line to improve readability. --- .../src/main/java/com/baeldung/jdbc/EmployeeDAO.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java index 8637f6f851..45f206a2b9 100644 --- a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java +++ b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java @@ -37,7 +37,8 @@ public class EmployeeDAO { public List getEmployeesFromIdList(List ids) { String inSql = String.join(",", Collections.nCopies(ids.size(), "?")); - List employees = jdbcTemplate.query(String.format("SELECT * FROM EMPLOYEE WHERE id IN (%s)", inSql), + List employees = jdbcTemplate.query( + String.format("SELECT * FROM EMPLOYEE WHERE id IN (%s)", inSql), ids.toArray(), (rs, rowNum) -> new Employee(rs.getInt("id"), rs.getString("first_name"), rs.getString("last_name"))); @@ -53,7 +54,8 @@ public class EmployeeDAO { } jdbcTemplate.batchUpdate("INSERT INTO employee_tmp VALUES(?)", employeeIds); - List employees = jdbcTemplate.query("SELECT * FROM EMPLOYEE WHERE id IN (SELECT id FROM employee_tmp)", + List employees = jdbcTemplate.query( + "SELECT * FROM EMPLOYEE WHERE id IN (SELECT id FROM employee_tmp)", (rs, rowNum) -> new Employee(rs.getInt("id"), rs.getString("first_name"), rs.getString("last_name"))); jdbcTemplate.update("DELETE FROM employee_tmp"); From 38f62ad24d646f18d66019eb808861462868ad80 Mon Sep 17 00:00:00 2001 From: Gang Wu Date: Wed, 22 Apr 2020 22:36:18 -0600 Subject: [PATCH 316/503] BAEL-3961 move the sql string into a new line to improve readability. --- .../src/main/java/com/baeldung/jdbc/EmployeeDAO.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java index 45f206a2b9..2ea42381eb 100644 --- a/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java +++ b/persistence-modules/spring-persistence-simple-2/src/main/java/com/baeldung/jdbc/EmployeeDAO.java @@ -28,7 +28,8 @@ public class EmployeeDAO { public List getEmployeesFromIdListNamed(List ids) { SqlParameterSource parameters = new MapSqlParameterSource("ids", ids); - List employees = namedJdbcTemplate.query("SELECT * FROM EMPLOYEE WHERE id IN (:ids)", + List employees = namedJdbcTemplate.query( + "SELECT * FROM EMPLOYEE WHERE id IN (:ids)", parameters, (rs, rowNum) -> new Employee(rs.getInt("id"), rs.getString("first_name"), rs.getString("last_name"))); From 8bd69814b04b55c54fb7da0c80682b5b84d2e742 Mon Sep 17 00:00:00 2001 From: Benjamin Caure Date: Thu, 23 Apr 2020 07:23:11 +0200 Subject: [PATCH 317/503] BAEL-3964 HTML emails with Thymeleaf and FreeMarker (#9119) --- spring-mvc-basics-2/README.md | 1 + .../ApplicationConfiguration.java | 30 +----- .../configuration/EmailConfiguration.java | 89 ++++++++++++++++++ .../spring/configuration/WebInitializer.java | 1 + .../spring/controller/MailController.java | 80 ++++++++++++---- .../baeldung/spring/domain/MailObject.java | 29 ++++++ .../baeldung/spring/mail/EmailService.java | 20 +++- .../spring/mail/EmailServiceImpl.java | 84 ++++++++++++++--- .../src/main/resources/mail-logo.png | Bin 0 -> 7391 bytes .../main/resources/mailMessages.properties | 5 + .../resources/mailMessages_fr_FR.properties | 5 + .../src/main/webapp/WEB-INF/views/emails.jsp | 7 +- .../webapp/WEB-INF/views/mail/sendHtml.jsp | 73 ++++++++++++++ .../views/mail/template-freemarker.ftl | 15 +++ .../views/mail/template-thymeleaf.html | 15 +++ .../java/com/baeldung/SpringContextTest.java | 3 +- .../rss/ArticleRssIntegrationTest.java | 4 +- 17 files changed, 396 insertions(+), 65 deletions(-) create mode 100644 spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/EmailConfiguration.java create mode 100644 spring-mvc-basics-2/src/main/resources/mail-logo.png create mode 100644 spring-mvc-basics-2/src/main/resources/mailMessages.properties create mode 100644 spring-mvc-basics-2/src/main/resources/mailMessages_fr_FR.properties create mode 100644 spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/sendHtml.jsp create mode 100644 spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/template-freemarker.ftl create mode 100644 spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/template-thymeleaf.html diff --git a/spring-mvc-basics-2/README.md b/spring-mvc-basics-2/README.md index 9d1402a210..e52459bd6e 100644 --- a/spring-mvc-basics-2/README.md +++ b/spring-mvc-basics-2/README.md @@ -9,6 +9,7 @@ This module contains articles about Spring MVC - [Servlet Redirect vs Forward](https://www.baeldung.com/servlet-redirect-forward) - [Apache Tiles Integration with Spring MVC](https://www.baeldung.com/spring-mvc-apache-tiles) - [Guide to Spring Email](https://www.baeldung.com/spring-email) +- [Using ThymeLeaf and FreeMarker Emails Templates with Spring](https://www.baeldung.com/thymeleaf-freemarker-email) - [Request Method Not Supported (405) in Spring](https://www.baeldung.com/spring-request-method-not-supported-405) - [Spring @RequestParam Annotation](https://www.baeldung.com/spring-request-param) - More articles: [[more -->]](/spring-mvc-basics-3) diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ApplicationConfiguration.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ApplicationConfiguration.java index 941a984684..e70e801577 100644 --- a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ApplicationConfiguration.java +++ b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/ApplicationConfiguration.java @@ -2,7 +2,6 @@ package com.baeldung.spring.configuration; import java.util.ArrayList; import java.util.List; -import java.util.Properties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -10,9 +9,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.StringHttpMessageConverter; import org.springframework.http.converter.feed.RssChannelHttpMessageConverter; -import org.springframework.mail.SimpleMailMessage; -import org.springframework.mail.javamail.JavaMailSender; -import org.springframework.mail.javamail.JavaMailSenderImpl; import org.springframework.web.accept.ContentNegotiationManager; import org.springframework.web.multipart.MultipartResolver; import org.springframework.web.multipart.commons.CommonsMultipartResolver; @@ -65,29 +61,5 @@ public class ApplicationConfiguration implements WebMvcConfigurer { converters.add(new RssChannelHttpMessageConverter()); converters.add(new JsonChannelHttpMessageConverter()); } - - @Bean - public SimpleMailMessage templateSimpleMessage() { - SimpleMailMessage message = new SimpleMailMessage(); - message.setText("This is the test email template for your email:\n%s\n"); - return message; - } - - @Bean - public JavaMailSender getJavaMailSender() { - JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); - mailSender.setHost("smtp.gmail.com"); - mailSender.setPort(587); - - mailSender.setUsername("my.gmail@gmail.com"); - mailSender.setPassword("password"); - - Properties props = mailSender.getJavaMailProperties(); - props.put("mail.transport.protocol", "smtp"); - props.put("mail.smtp.auth", "true"); - props.put("mail.smtp.starttls.enable", "true"); - props.put("mail.debug", "true"); - - return mailSender; - } + } diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/EmailConfiguration.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/EmailConfiguration.java new file mode 100644 index 0000000000..1bbbc51304 --- /dev/null +++ b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/EmailConfiguration.java @@ -0,0 +1,89 @@ +package com.baeldung.spring.configuration; + +import java.util.Properties; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.support.ResourceBundleMessageSource; +import org.springframework.mail.SimpleMailMessage; +import org.springframework.mail.javamail.JavaMailSender; +import org.springframework.mail.javamail.JavaMailSenderImpl; +import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; +import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; +import org.thymeleaf.spring4.SpringTemplateEngine; +import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver; + +@Configuration +@ComponentScan(basePackages = { "com.baeldung.spring.mail" }) +public class EmailConfiguration { + + @Bean + public JavaMailSender getJavaMailSender() { + JavaMailSenderImpl mailSender = new JavaMailSenderImpl(); + + mailSender.setHost("smtp.gmail.com"); + mailSender.setPort(587); + + mailSender.setUsername("my.gmail@gmail.com"); + mailSender.setPassword("password"); + + Properties props = mailSender.getJavaMailProperties(); + props.put("mail.transport.protocol", "smtp"); + props.put("mail.smtp.auth", "true"); + props.put("mail.smtp.starttls.enable", "false"); + props.put("mail.debug", "true"); + + return mailSender; + } + + @Bean + public SimpleMailMessage templateSimpleMessage() { + SimpleMailMessage message = new SimpleMailMessage(); + message.setText("This is the test email template for your email:\n%s\n"); + return message; + } + + @Bean + public SpringTemplateEngine thymeleafTemplateEngine() { + SpringTemplateEngine templateEngine = new SpringTemplateEngine(); + templateEngine.setTemplateResolver(thymeleafTemplateResolver()); + templateEngine.setTemplateEngineMessageSource(emailMessageSource()); + return templateEngine; + } + + @Bean + public SpringResourceTemplateResolver thymeleafTemplateResolver() { + SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver(); + templateResolver.setPrefix("/WEB-INF/views/mail/"); + templateResolver.setSuffix(".html"); + templateResolver.setTemplateMode("HTML"); + templateResolver.setCharacterEncoding("UTF-8"); + return templateResolver; + } + + @Bean + public FreeMarkerConfigurer freemarkerConfig() { + FreeMarkerConfigurer freeMarkerConfigurer = new FreeMarkerConfigurer(); + freeMarkerConfigurer.setTemplateLoaderPath("/WEB-INF/views/mail"); + return freeMarkerConfigurer; + } + + @Bean + public FreeMarkerViewResolver freemarkerViewResolver() { + FreeMarkerViewResolver resolver = new FreeMarkerViewResolver(); + resolver.setCache(true); + resolver.setPrefix(""); + resolver.setSuffix(".ftl"); + return resolver; + } + + + @Bean + public ResourceBundleMessageSource emailMessageSource() { + final ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); + messageSource.setBasename("/mailMessages"); + return messageSource; + } + +} diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/WebInitializer.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/WebInitializer.java index 74094a11c7..4d43549440 100644 --- a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/WebInitializer.java +++ b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/configuration/WebInitializer.java @@ -20,6 +20,7 @@ public class WebInitializer implements WebApplicationInitializer { // ctx.register(GroovyConfiguration.class); // ctx.register(JadeTemplateConfiguration.class); // ctx.register(PushConfiguration.class); + ctx.register(EmailConfiguration.class); // ctx.setServletContext(container); //ctx.register(TilesApplicationConfiguration.class); diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/MailController.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/MailController.java index 16d1202eef..b6e19a4c39 100644 --- a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/MailController.java +++ b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/controller/MailController.java @@ -1,10 +1,17 @@ package com.baeldung.spring.controller; -import com.baeldung.spring.mail.EmailServiceImpl; -import com.baeldung.spring.domain.MailObject; +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import javax.mail.MessagingException; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.mail.SimpleMailMessage; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.Errors; @@ -12,26 +19,21 @@ import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; +import com.baeldung.spring.domain.MailObject; +import com.baeldung.spring.mail.EmailService; + +import freemarker.template.TemplateException; @Controller @RequestMapping("/mail") public class MailController { @Autowired - public EmailServiceImpl emailService; + public EmailService emailService; @Value("${attachment.invoice}") private String attachmentPath; - @Autowired - public SimpleMailMessage template; - private static final Map> labels; static { @@ -46,7 +48,7 @@ public class MailController { //Email with template props = new HashMap<>(); - props.put("headerText", "Send Email Using Template"); + props.put("headerText", "Send Email Using Text Template"); props.put("messageLabel", "Template Parameter"); props.put("additionalInfo", "The parameter value will be added to the following message template:
    " + @@ -60,6 +62,7 @@ public class MailController { props.put("messageLabel", "Message"); props.put("additionalInfo", "To make sure that you send an attachment with this email, change the value for the 'attachment.invoice' in the application.properties file to the path to the attachment."); labels.put("sendAttachment", props); + } @RequestMapping(method = RequestMethod.GET) @@ -85,6 +88,7 @@ public class MailController { return "mail/send"; } + @RequestMapping(value = "/send", method = RequestMethod.POST) public String createMail(Model model, @ModelAttribute("mailObject") @Valid MailObject mailObject, @@ -95,7 +99,7 @@ public class MailController { emailService.sendSimpleMessage(mailObject.getTo(), mailObject.getSubject(), mailObject.getText()); - return "redirect:/home"; + return "emails"; } @RequestMapping(value = "/sendTemplate", method = RequestMethod.POST) @@ -107,10 +111,9 @@ public class MailController { } emailService.sendSimpleMessageUsingTemplate(mailObject.getTo(), mailObject.getSubject(), - template, mailObject.getText()); - return "redirect:/home"; + return "redirect:/mail"; } @RequestMapping(value = "/sendAttachment", method = RequestMethod.POST) @@ -127,6 +130,47 @@ public class MailController { attachmentPath ); - return "redirect:/home"; + return "redirect:/mail"; + } + + + @RequestMapping(value = {"/sendHtml"}, method = RequestMethod.GET) + public String getHtmlMailView(Model model, + HttpServletRequest request) { + + Map templateEngines = new HashMap<>(); + templateEngines.put("Thymeleaf", "Thymeleaf"); + templateEngines.put("Freemarker", "Freemarker"); + model.addAttribute("mailObject", new MailObject()); + model.addAttribute("templateEngines", templateEngines); + return "mail/sendHtml"; + } + + @RequestMapping(value = "/sendHtml", method = RequestMethod.POST) + public String createHtmlMail(Model model, + @ModelAttribute("mailObject") @Valid MailObject mailObject, + Errors errors) throws IOException, MessagingException, TemplateException { + if (errors.hasErrors()) { + return "mail/send"; + } + + Map templateModel = new HashMap<>(); + templateModel.put("recipientName", mailObject.getRecipientName()); + templateModel.put("text", mailObject.getText()); + templateModel.put("senderName", mailObject.getSenderName()); + + if (mailObject.getTemplateEngine().equalsIgnoreCase("thymeleaf")) { + emailService.sendMessageUsingThymeleafTemplate( + mailObject.getTo(), + mailObject.getSubject(), + templateModel); + } else { + emailService.sendMessageUsingFreemarkerTemplate( + mailObject.getTo(), + mailObject.getSubject(), + templateModel); + } + + return "redirect:/mail"; } } diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/MailObject.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/MailObject.java index aceaf685fa..d425ca9a26 100644 --- a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/MailObject.java +++ b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/domain/MailObject.java @@ -12,8 +12,11 @@ public class MailObject { @NotNull @Size(min = 1, message = "Please, set an email address to send the message to it") private String to; + private String recipientName; private String subject; private String text; + private String senderName; + private String templateEngine; public String getTo() { return to; @@ -38,4 +41,30 @@ public class MailObject { public void setText(String text) { this.text = text; } + + public String getRecipientName() { + return recipientName; + } + + public void setRecipientName(String recipientName) { + this.recipientName = recipientName; + } + + public String getSenderName() { + return senderName; + } + + public void setSenderName(String senderName) { + this.senderName = senderName; + } + + public String getTemplateEngine() { + return templateEngine; + } + + public void setTemplateEngine(String templateEngine) { + this.templateEngine = templateEngine; + } + + } diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailService.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailService.java index 43d7378227..b7d5be09c8 100644 --- a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailService.java +++ b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailService.java @@ -1,6 +1,11 @@ package com.baeldung.spring.mail; -import org.springframework.mail.SimpleMailMessage; +import java.io.IOException; +import java.util.Map; + +import javax.mail.MessagingException; + +import freemarker.template.TemplateException; /** * Created by Olga on 8/22/2016. @@ -11,10 +16,19 @@ public interface EmailService { String text); void sendSimpleMessageUsingTemplate(String to, String subject, - SimpleMailMessage template, - String ...templateArgs); + String ...templateModel); void sendMessageWithAttachment(String to, String subject, String text, String pathToAttachment); + + void sendMessageUsingThymeleafTemplate(String to, + String subject, + Map templateModel) + throws IOException, MessagingException; + + void sendMessageUsingFreemarkerTemplate(String to, + String subject, + Map templateModel) + throws IOException, TemplateException, MessagingException; } diff --git a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java index 039b970d8e..0592415ab5 100644 --- a/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java +++ b/spring-mvc-basics-2/src/main/java/com/baeldung/spring/mail/EmailServiceImpl.java @@ -1,26 +1,49 @@ package com.baeldung.spring.mail; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.FileSystemResource; -import org.springframework.mail.MailException; -import org.springframework.mail.SimpleMailMessage; -import org.springframework.mail.javamail.JavaMailSender; -import org.springframework.mail.javamail.MimeMessageHelper; -import org.springframework.stereotype.Component; - import java.io.File; +import java.io.IOException; +import java.util.Map; import javax.mail.MessagingException; import javax.mail.internet.MimeMessage; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.io.FileSystemResource; +import org.springframework.core.io.Resource; +import org.springframework.mail.MailException; +import org.springframework.mail.SimpleMailMessage; +import org.springframework.mail.javamail.JavaMailSender; +import org.springframework.mail.javamail.MimeMessageHelper; +import org.springframework.stereotype.Service; +import org.springframework.ui.freemarker.FreeMarkerTemplateUtils; +import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; +import org.thymeleaf.context.Context; +import org.thymeleaf.spring4.SpringTemplateEngine; + +import freemarker.template.Template; +import freemarker.template.TemplateException; + /** * Created by Olga on 7/15/2016. */ -@Component +@Service("EmailService") public class EmailServiceImpl implements EmailService { @Autowired public JavaMailSender emailSender; + + @Autowired + public SimpleMailMessage template; + + @Autowired + private SpringTemplateEngine thymeleafTemplateEngine; + + @Autowired + private FreeMarkerConfigurer freemarkerConfigurer; + + @Value("classpath:/mail-logo.png") + Resource resourceFile; public void sendSimpleMessage(String to, String subject, String text) { try { @@ -38,9 +61,8 @@ public class EmailServiceImpl implements EmailService { @Override public void sendSimpleMessageUsingTemplate(String to, String subject, - SimpleMailMessage template, - String ...templateArgs) { - String text = String.format(template.getText(), templateArgs); + String ...templateModel) { + String text = String.format(template.getText(), templateModel); sendSimpleMessage(to, subject, text); } @@ -66,4 +88,42 @@ public class EmailServiceImpl implements EmailService { e.printStackTrace(); } } + + + @Override + public void sendMessageUsingThymeleafTemplate( + String to, String subject, Map templateModel) + throws MessagingException { + + Context thymeleafContext = new Context(); + thymeleafContext.setVariables(templateModel); + + String htmlBody = thymeleafTemplateEngine.process("template-thymeleaf.html", thymeleafContext); + + sendHtmlMessage(to, subject, htmlBody); + } + + @Override + public void sendMessageUsingFreemarkerTemplate( + String to, String subject, Map templateModel) + throws IOException, TemplateException, MessagingException { + + Template freemarkerTemplate = freemarkerConfigurer.createConfiguration().getTemplate("template-freemarker.ftl"); + String htmlBody = FreeMarkerTemplateUtils.processTemplateIntoString(freemarkerTemplate, templateModel); + + sendHtmlMessage(to, subject, htmlBody); + } + + private void sendHtmlMessage(String to, String subject, String htmlBody) throws MessagingException { + + MimeMessage message = emailSender.createMimeMessage(); + MimeMessageHelper helper = new MimeMessageHelper(message, true, "UTF-8"); + helper.setTo(to); + helper.setSubject(subject); + helper.setText(htmlBody, true); + helper.addInline("attachment.png", resourceFile); + emailSender.send(message); + + } + } diff --git a/spring-mvc-basics-2/src/main/resources/mail-logo.png b/spring-mvc-basics-2/src/main/resources/mail-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..edb83efbe3d4f083363fea616d5c0e2df6e1fe03 GIT binary patch literal 7391 zcmc(E=?>`{LP{DWMH&Vi zfp`1-2k(dHdgjBKGuN5D&))m4wbmV{rKv=SPlJzvfkCLEte}H|a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!Sy3mk~ z8R%5KgZCGSsHnPU#j<}V^YxzhD*D&bq5;Uo3f|Jkn+tU1F0y?fx9XC)3F!V$Z!76D zKV{hT9@(W*MTWl_A=Fqh3G}%5L*Q6E&tp_FW^IA$9yv<%f87-O|8Kvw+~Edlh`bM1 TggyZsN(>c6O@%LVmf`;o*#$Af literal 0 HcmV?d00001 diff --git a/spring-mvc-basics-2/src/main/resources/mailMessages.properties b/spring-mvc-basics-2/src/main/resources/mailMessages.properties new file mode 100644 index 0000000000..46f7a80ed3 --- /dev/null +++ b/spring-mvc-basics-2/src/main/resources/mailMessages.properties @@ -0,0 +1,5 @@ +greetings=Hi {0}, +subscriptions=Please find below your current subscriptions to our forum: +regards=Regards, +unsubscribe=Unsubscribe from these emails here +signature={0} at Baeldung \ No newline at end of file diff --git a/spring-mvc-basics-2/src/main/resources/mailMessages_fr_FR.properties b/spring-mvc-basics-2/src/main/resources/mailMessages_fr_FR.properties new file mode 100644 index 0000000000..6f300a9ab7 --- /dev/null +++ b/spring-mvc-basics-2/src/main/resources/mailMessages_fr_FR.properties @@ -0,0 +1,5 @@ +greetings=Bonjour {0}, +subscriptions=Voici vos différentes souscriptions sur notre forum : +regards=Cordialement, +unsubscribe=Se désinscrire de ces emails ici +signature={0} à Baeldung \ No newline at end of file diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/emails.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/emails.jsp index 63351bbf3a..dafa71cbb0 100644 --- a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/emails.jsp +++ b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/emails.jsp @@ -26,7 +26,7 @@ - + @@ -34,6 +34,11 @@ + + + + + diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/sendHtml.jsp b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/sendHtml.jsp new file mode 100644 index 0000000000..f91a8826d1 --- /dev/null +++ b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/sendHtml.jsp @@ -0,0 +1,73 @@ +<%-- + User: Benjamin CAURE + Date: 4/14/2020 +--%> +<%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> + + + Send HTML Email + + +

    +

    Send Email Using Text Template

    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Enter email address
    + +
    + Enter the recipient name
    + +
    + Enter the subject
    + +
    + +
    + Enter the sender name
    + +
    + Select the template engine
    + +
    + +
    +
    +
    +
    +
    + + diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/template-freemarker.ftl b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/template-freemarker.ftl new file mode 100644 index 0000000000..066fc0302c --- /dev/null +++ b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/template-freemarker.ftl @@ -0,0 +1,15 @@ + + + + + + +

    Hi ${recipientName}

    +

    ${text}

    +

    Regards,

    +

    + ${senderName} at Baeldung
    + +

    + + diff --git a/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/template-thymeleaf.html b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/template-thymeleaf.html new file mode 100644 index 0000000000..b255b5dee5 --- /dev/null +++ b/spring-mvc-basics-2/src/main/webapp/WEB-INF/views/mail/template-thymeleaf.html @@ -0,0 +1,15 @@ + + + + + + +

    +

    +

    +

    +
    + +

    + + diff --git a/spring-mvc-basics-2/src/test/java/com/baeldung/SpringContextTest.java b/spring-mvc-basics-2/src/test/java/com/baeldung/SpringContextTest.java index ab0b23c4a5..5c276254d3 100644 --- a/spring-mvc-basics-2/src/test/java/com/baeldung/SpringContextTest.java +++ b/spring-mvc-basics-2/src/test/java/com/baeldung/SpringContextTest.java @@ -7,10 +7,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import com.baeldung.spring.configuration.ApplicationConfiguration; +import com.baeldung.spring.configuration.EmailConfiguration; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes={ApplicationConfiguration.class}) +@ContextConfiguration(classes={ApplicationConfiguration.class, EmailConfiguration.class}) @WebAppConfiguration public class SpringContextTest { diff --git a/spring-mvc-basics-2/src/test/java/com/baeldung/controller/rss/ArticleRssIntegrationTest.java b/spring-mvc-basics-2/src/test/java/com/baeldung/controller/rss/ArticleRssIntegrationTest.java index fe7aeeb570..2ed70489c0 100644 --- a/spring-mvc-basics-2/src/test/java/com/baeldung/controller/rss/ArticleRssIntegrationTest.java +++ b/spring-mvc-basics-2/src/test/java/com/baeldung/controller/rss/ArticleRssIntegrationTest.java @@ -1,6 +1,8 @@ package com.baeldung.controller.rss; import com.baeldung.spring.configuration.ApplicationConfiguration; +import com.baeldung.spring.configuration.EmailConfiguration; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -13,7 +15,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -@SpringJUnitWebConfig(ApplicationConfiguration.class) +@SpringJUnitWebConfig(classes={ApplicationConfiguration.class, EmailConfiguration.class}) public class ArticleRssIntegrationTest { public static final String APPLICATION_RSS_XML = "application/rss+xml"; public static final String APPLICATION_RSS_JSON = "application/rss+json"; From 62842f97cf2c1e1ce1ba94c5505d769acb0632a6 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Thu, 23 Apr 2020 13:10:29 +0530 Subject: [PATCH 318/503] JAVA-923: Migrate spring-data-dynamodb to parent-boot-2 --- persistence-modules/spring-data-dynamodb/pom.xml | 8 ++++---- .../spring/data/dynamodb/config/DynamoDBConfig.java | 4 ++-- .../data/dynamodb/repositories/ProductInfoRepository.java | 7 ++++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/persistence-modules/spring-data-dynamodb/pom.xml b/persistence-modules/spring-data-dynamodb/pom.xml index fceceb40ba..377e35b635 100644 --- a/persistence-modules/spring-data-dynamodb/pom.xml +++ b/persistence-modules/spring-data-dynamodb/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../../parent-boot-1 + ../../parent-boot-2 @@ -19,7 +19,7 @@ org.springframework.data spring-data-releasetrain - Hopper-SR10 + Lovelace-SR16 pom import @@ -174,7 +174,7 @@ com.baeldung.Application 4.3.4.RELEASE 4.5.2 - 4.4.1 + 5.1.0 1.11.64 3.3.7-1 1.0.392 diff --git a/persistence-modules/spring-data-dynamodb/src/main/java/com/baeldung/spring/data/dynamodb/config/DynamoDBConfig.java b/persistence-modules/spring-data-dynamodb/src/main/java/com/baeldung/spring/data/dynamodb/config/DynamoDBConfig.java index 9278c0a12e..7e97e6b383 100644 --- a/persistence-modules/spring-data-dynamodb/src/main/java/com/baeldung/spring/data/dynamodb/config/DynamoDBConfig.java +++ b/persistence-modules/spring-data-dynamodb/src/main/java/com/baeldung/spring/data/dynamodb/config/DynamoDBConfig.java @@ -44,8 +44,8 @@ public class DynamoDBConfig { return new BasicAWSCredentials(amazonAWSAccessKey, amazonAWSSecretKey); } - @Bean(name = "mvcHandlerMappingIntrospector") - public HandlerMappingIntrospector mvcHandlerMappingIntrospector() { + @Bean(name = "mvcHandlerMappingIntrospectorCustom") + public HandlerMappingIntrospector mvcHandlerMappingIntrospectorCustom() { return new HandlerMappingIntrospector(context); } } diff --git a/persistence-modules/spring-data-dynamodb/src/main/java/com/baeldung/spring/data/dynamodb/repositories/ProductInfoRepository.java b/persistence-modules/spring-data-dynamodb/src/main/java/com/baeldung/spring/data/dynamodb/repositories/ProductInfoRepository.java index da47f033b6..6e8b493c3b 100644 --- a/persistence-modules/spring-data-dynamodb/src/main/java/com/baeldung/spring/data/dynamodb/repositories/ProductInfoRepository.java +++ b/persistence-modules/spring-data-dynamodb/src/main/java/com/baeldung/spring/data/dynamodb/repositories/ProductInfoRepository.java @@ -1,12 +1,13 @@ package com.baeldung.spring.data.dynamodb.repositories; -import com.baeldung.spring.data.dynamodb.model.ProductInfo; +import java.util.Optional; + import org.socialsignin.spring.data.dynamodb.repository.EnableScan; import org.springframework.data.repository.CrudRepository; -import java.util.List; +import com.baeldung.spring.data.dynamodb.model.ProductInfo; @EnableScan public interface ProductInfoRepository extends CrudRepository { - List findById(String id); + Optional findById(String id); } From 7367f3b0ba099d02f98b78599ca6c860047595b8 Mon Sep 17 00:00:00 2001 From: Usman Mohyuddin Date: Thu, 23 Apr 2020 22:54:55 +0500 Subject: [PATCH 319/503] add code files for "How to determine the data type in Groovy" (#9123) * add code files for "How to groovy data types" add code files for "How to groovy data types" * added Tests in example * Update pom.xml change tab into spaces --- core-groovy-2/determine-datatype/pom.xml | 40 ++++++++++++++ .../groovy/determine/datatype/Person.groovy | 14 +++++ .../determine/datatype/PersonTest.groovy | 55 +++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 core-groovy-2/determine-datatype/pom.xml create mode 100644 core-groovy-2/determine-datatype/src/com/baeldung/groovy/determine/datatype/Person.groovy create mode 100644 core-groovy-2/determine-datatype/src/com/baeldung/groovy/determine/datatype/PersonTest.groovy diff --git a/core-groovy-2/determine-datatype/pom.xml b/core-groovy-2/determine-datatype/pom.xml new file mode 100644 index 0000000000..0bcef4e5d8 --- /dev/null +++ b/core-groovy-2/determine-datatype/pom.xml @@ -0,0 +1,40 @@ + + 4.0.0 + com.baeldung.groovy + determine-datatype + 0.0.1-SNAPSHOT + + src + + + maven-compiler-plugin + 3.8.0 + + 1.8 + 1.8 + + + + org.codehaus.gmaven + groovy-maven-plugin + + + org.codehaus.groovy + groovy-all + 2.0.6 + + + + + + + + + org.junit + junit5-engine + 5.0.0-ALPHA + + + \ No newline at end of file diff --git a/core-groovy-2/determine-datatype/src/com/baeldung/groovy/determine/datatype/Person.groovy b/core-groovy-2/determine-datatype/src/com/baeldung/groovy/determine/datatype/Person.groovy new file mode 100644 index 0000000000..1a89dce435 --- /dev/null +++ b/core-groovy-2/determine-datatype/src/com/baeldung/groovy/determine/datatype/Person.groovy @@ -0,0 +1,14 @@ +package com.baeldung.groovy.determine.datatype + +class Person { + + private int ageAsInt + private Double ageAsDouble + private String ageAsString + + Person() {} + Person(int ageAsInt) { this.ageAsInt = ageAsInt} + Person(Double ageAsDouble) { this.ageAsDouble = ageAsDouble} + Person(String ageAsString) { this.ageAsString = ageAsString} +} +class Student extends Person {} diff --git a/core-groovy-2/determine-datatype/src/com/baeldung/groovy/determine/datatype/PersonTest.groovy b/core-groovy-2/determine-datatype/src/com/baeldung/groovy/determine/datatype/PersonTest.groovy new file mode 100644 index 0000000000..56095a3f1b --- /dev/null +++ b/core-groovy-2/determine-datatype/src/com/baeldung/groovy/determine/datatype/PersonTest.groovy @@ -0,0 +1,55 @@ +package com.baeldung.groovy.determine.datatype; + +import org.junit.Assert +import org.junit.Test; + +public class PersonTest { + + @Test + public void givenWhenParameterTypeIsInteger_thenReturnTrue() { + Person personObj = new Person(10) + Assert.assertTrue(personObj.ageAsInt instanceof Integer); + } + + @Test + public void givenWhenParameterTypeIsDouble_thenReturnTrue() { + Person personObj = new Person(10.0) + Assert.assertTrue((personObj.ageAsDouble).getClass() == Double) + } + + @Test + public void givenWhenParameterTypeIsString_thenReturnTrue() { + Person personObj = new Person("10 years") + Assert.assertTrue(personObj.ageAsString.class == String) + } + + @Test + public void givenClassName_WhenParameterIsInteger_thenReturnTrue() { + Assert.assertTrue(Person.class.getDeclaredField('ageAsInt').type == int.class) + } + + @Test + public void givenWhenObjectIsInstanceOfType_thenReturnTrue() { + Person personObj = new Person() + Assert.assertTrue(personObj instanceof Person) + } + + @Test + public void givenWhenInstanceIsOfSubtype_thenReturnTrue() { + Student studentObj = new Student() + Assert.assertTrue(studentObj in Person) + } + + @Test + public void givenGroovyList_WhenFindClassName_thenReturnTrue() { + def ageList = ['ageAsString','ageAsDouble', 10] + Assert.assertTrue(ageList.class == ArrayList) + Assert.assertTrue(ageList.getClass() == ArrayList) + } + + @Test + public void givenGrooyMap_WhenFindClassName_thenReturnTrue() { + def ageMap = [ageAsString: '10 years', ageAsDouble: 10.0] + Assert.assertFalse(ageMap.class == LinkedHashMap) + } +} \ No newline at end of file From acf4fa5af9ad36f7273c11ee4be36dbe95434056 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 23 Apr 2020 22:18:45 +0200 Subject: [PATCH 320/503] JAVA-73: Move scripts under live-test-resources --- persistence-modules/spring-data-mongodb/LIVE-TEST.md | 9 --------- persistence-modules/spring-data-mongodb/README.md | 9 +++++++++ .../{ => src/live-test/resources}/live-test-setup.sh | 2 +- .../{ => src/live-test/resources}/live-test-teardown.sh | 0 .../{ => src/live-test/resources}/live-test.sh | 0 5 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 persistence-modules/spring-data-mongodb/LIVE-TEST.md rename persistence-modules/spring-data-mongodb/{ => src/live-test/resources}/live-test-setup.sh (58%) rename persistence-modules/spring-data-mongodb/{ => src/live-test/resources}/live-test-teardown.sh (100%) rename persistence-modules/spring-data-mongodb/{ => src/live-test/resources}/live-test.sh (100%) mode change 100755 => 100644 diff --git a/persistence-modules/spring-data-mongodb/LIVE-TEST.md b/persistence-modules/spring-data-mongodb/LIVE-TEST.md deleted file mode 100644 index 9da1ea249e..0000000000 --- a/persistence-modules/spring-data-mongodb/LIVE-TEST.md +++ /dev/null @@ -1,9 +0,0 @@ -========= - -## Spring Data MongoDB Live Testing - - -There are 3 scripts to simplify running live tests: -1. `live-test-setup.sh` builds a docker image with the necessary setup and runs it. The environment is ready, when the log stops - it takes approximately 30 seconds. -2. `live-test.sh` runs the live tests (but no other tests). -3. `live-test-setup.sh` stops and removes the docker image. diff --git a/persistence-modules/spring-data-mongodb/README.md b/persistence-modules/spring-data-mongodb/README.md index c4f21dffc0..381bf83fa8 100644 --- a/persistence-modules/spring-data-mongodb/README.md +++ b/persistence-modules/spring-data-mongodb/README.md @@ -13,3 +13,12 @@ - [Spring Data Annotations](http://www.baeldung.com/spring-data-annotations) - [Spring Data MongoDB Transactions](https://www.baeldung.com/spring-data-mongodb-transactions ) - [ZonedDateTime with Spring Data MongoDB](https://www.baeldung.com/spring-data-mongodb-zoneddatetime) + + +## Spring Data MongoDB Live Testing + + +There are 3 scripts to simplify running live tests: +1. [`live-test-setup.sh`](src/live-test/resources/live-test-setup.sh) builds a docker image with the necessary setup and runs it. The environment is ready, when the log stops - it takes approximately 30 seconds. +2. [`live-test.sh`](src/live-test/resources/live-test.sh) runs the live tests (but no other tests). +3. [`live-test-teardown.sh`](src/live-test/resources/live-test-teardown.sh) stops and removes the docker image. diff --git a/persistence-modules/spring-data-mongodb/live-test-setup.sh b/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test-setup.sh similarity index 58% rename from persistence-modules/spring-data-mongodb/live-test-setup.sh rename to persistence-modules/spring-data-mongodb/src/live-test/resources/live-test-setup.sh index e8e0437083..78968d51aa 100644 --- a/persistence-modules/spring-data-mongodb/live-test-setup.sh +++ b/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test-setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -docker image build -t spring-data-mongodb:live-test src/live-test/resources/ +docker image build -t spring-data-mongodb:live-test . docker run -p 27017:27017 --name spring-data-mongodb-live-test spring-data-mongodb:live-test diff --git a/persistence-modules/spring-data-mongodb/live-test-teardown.sh b/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test-teardown.sh similarity index 100% rename from persistence-modules/spring-data-mongodb/live-test-teardown.sh rename to persistence-modules/spring-data-mongodb/src/live-test/resources/live-test-teardown.sh diff --git a/persistence-modules/spring-data-mongodb/live-test.sh b/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test.sh old mode 100755 new mode 100644 similarity index 100% rename from persistence-modules/spring-data-mongodb/live-test.sh rename to persistence-modules/spring-data-mongodb/src/live-test/resources/live-test.sh From ffa8e0839df894019e1b3cc501728c9c0f5d9aa6 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Thu, 23 Apr 2020 22:38:10 +0200 Subject: [PATCH 321/503] JAVA-73: Fix live-test.sh and cleanup pom.xml --- .../spring-data-mongodb/src/live-test/resources/live-test.sh | 2 +- pom.xml | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test.sh b/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test.sh index 5a079bdac8..307a68a3bd 100644 --- a/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test.sh +++ b/persistence-modules/spring-data-mongodb/src/live-test/resources/live-test.sh @@ -1,3 +1,3 @@ #!/bin/bash -mvn clean compile test -P live-all +mvn clean compile test -P live-all -f ../../../pom.xml diff --git a/pom.xml b/pom.xml index f94c89a5c0..314a6a9f43 100644 --- a/pom.xml +++ b/pom.xml @@ -1341,10 +1341,7 @@ - - - - + From 5bb2977eb063a73c81dd7fc99cc2c6ecefdc1c32 Mon Sep 17 00:00:00 2001 From: sergio41 Date: Fri, 24 Apr 2020 13:03:41 +0200 Subject: [PATCH 322/503] [BAEL-3944] Move to a separate test class and fix other issues --- .../regex/PhoneNumbersRegexUnitTest.java | 55 +++++++++++++++++++ .../com/baeldung/regex/RegexUnitTest.java | 49 ----------------- 2 files changed, 55 insertions(+), 49 deletions(-) create mode 100644 core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/PhoneNumbersRegexUnitTest.java diff --git a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/PhoneNumbersRegexUnitTest.java b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/PhoneNumbersRegexUnitTest.java new file mode 100644 index 0000000000..edfa7a2c5e --- /dev/null +++ b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/PhoneNumbersRegexUnitTest.java @@ -0,0 +1,55 @@ +package com.baeldung.regex; + +import static org.junit.Assert.*; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.junit.Test; + +public class PhoneNumbersRegexUnitTest { + + @Test + public void whenMatchesTenDigitsNumber_thenCorrect() { + Pattern pattern = Pattern.compile("^\\d{10}$"); + Matcher matcher = pattern.matcher("1234567890"); + assertTrue(matcher.matches()); + } + + @Test + public void whenMatchesTenDigitsNumberWhitespacesHyphen_thenCorrect() { + Pattern pattern = Pattern.compile("^(\\d{3}[- ]?){2}\\d{4}$"); + Matcher matcher = pattern.matcher("123 456 7890"); + assertTrue(matcher.matches()); + } + + @Test + public void whenMatchesTenDigitsNumberParenthesis_thenCorrect() { + Pattern pattern = Pattern.compile("^\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$"); + Matcher matcher = pattern.matcher("(123)-456-7890"); + assertTrue(matcher.matches()); + } + + @Test + public void whenMatchesTenDigitsNumberPrefix_thenCorrect() { + Pattern pattern = Pattern.compile("^(\\+\\d{1,3}( )?)?\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$"); + Matcher matcher = pattern.matcher("+111 (123)-456-7890"); + assertTrue(matcher.matches()); + } + + @Test + public void whenMatchesPhoneNumber_thenCorrect() { + String patterns = "^(\\+\\d{1,3}( )?)?\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$" + + "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?){2}\\d{3}$" + + "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?)(\\d{2}[ ]?){2}\\d{2}$"; + + String[] validPhoneNumbers = {"1234567890","123 456 7890", "(123)-456-7890", "+111 (123)-456-7890", + "123 456 789", "+111 123 456 789", "123 45 67 89", "+111 123 45 67 89"}; + + Pattern pattern = Pattern.compile(patterns); + for(String phoneNumber : validPhoneNumbers) { + Matcher matcher = pattern.matcher(phoneNumber); + assertTrue(matcher.matches()); + } + } +} diff --git a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/RegexUnitTest.java b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/RegexUnitTest.java index 909894ec55..77052b79ac 100644 --- a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/RegexUnitTest.java +++ b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/RegexUnitTest.java @@ -26,7 +26,6 @@ public class RegexUnitTest { while (matcher.find()) matches++; assertEquals(matches, 2); - } @Test @@ -452,7 +451,6 @@ public class RegexUnitTest { Matcher matcher = pattern.matcher("dogs are friendly"); assertTrue(matcher.lookingAt()); assertFalse(matcher.matches()); - } @Test @@ -460,7 +458,6 @@ public class RegexUnitTest { Pattern pattern = Pattern.compile("dog"); Matcher matcher = pattern.matcher("dog"); assertTrue(matcher.matches()); - } @Test @@ -469,7 +466,6 @@ public class RegexUnitTest { Matcher matcher = pattern.matcher("dogs are domestic animals, dogs are friendly"); String newStr = matcher.replaceFirst("cat"); assertEquals("cats are domestic animals, dogs are friendly", newStr); - } @Test @@ -478,51 +474,6 @@ public class RegexUnitTest { Matcher matcher = pattern.matcher("dogs are domestic animals, dogs are friendly"); String newStr = matcher.replaceAll("cat"); assertEquals("cats are domestic animals, cats are friendly", newStr); - - } - - @Test - public void whenMatchesTenDigitsNumber_thenCorrect() { - Pattern pattern = Pattern.compile("^\\d{10}$"); - Matcher matcher = pattern.matcher("1234567890"); - assertTrue(matcher.matches()); - } - - @Test - public void whenMatchesTenDigitsNumberWhitespacesHyphen_thenCorrect() { - Pattern pattern = Pattern.compile("^(\\d{3}[- ]?){2}\\d{4}$"); - Matcher matcher = pattern.matcher("123 456 7890"); - assertTrue(matcher.matches()); - } - - @Test - public void whenMatchesTenDigitsNumberParenthesis_thenCorrect() { - Pattern pattern = Pattern.compile("^\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$"); - Matcher matcher = pattern.matcher("(123)-456-7890"); - assertTrue(matcher.matches()); - } - - @Test - public void whenMatchesTenDigitsNumberPrefix_thenCorrect() { - Pattern pattern = Pattern.compile("^(\\+\\d{1,3}( )?)?\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$"); - Matcher matcher = pattern.matcher("+111 (123)-456-7890"); - assertTrue(matcher.matches()); - } - - @Test - public void whenMatchesPhoneNumber_thenCorrect() { - String patterns = "^(\\+\\d{1,3}( )?)?\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$" + - "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?){2}\\d{3}$" + - "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?)(\\d{2}[ ]?){2}\\d{2}$"; - - String[] validPhoneNumbers = {"1234567890","123 456 7890", "(123)-456-7890", "+111 (123)-456-7890", - "123 456 789", "+111 123 456 789", "123 45 67 89", "+111 123 45 67 89"}; - - Pattern pattern = Pattern.compile(patterns); - for(String phoneNumber : validPhoneNumbers) { - Matcher matcher = pattern.matcher(phoneNumber); - assertTrue(matcher.matches()); - } } public synchronized static int runTest(String regex, String text) { From 953b8d4640900045433599e8148d92990b8835a0 Mon Sep 17 00:00:00 2001 From: sergio41 Date: Fri, 24 Apr 2020 13:07:05 +0200 Subject: [PATCH 323/503] [BAEL-3944] Real like phone numbers --- .../baeldung/regex/PhoneNumbersRegexUnitTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/PhoneNumbersRegexUnitTest.java b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/PhoneNumbersRegexUnitTest.java index edfa7a2c5e..620b7a9bae 100644 --- a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/PhoneNumbersRegexUnitTest.java +++ b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/PhoneNumbersRegexUnitTest.java @@ -12,28 +12,28 @@ public class PhoneNumbersRegexUnitTest { @Test public void whenMatchesTenDigitsNumber_thenCorrect() { Pattern pattern = Pattern.compile("^\\d{10}$"); - Matcher matcher = pattern.matcher("1234567890"); + Matcher matcher = pattern.matcher("2055550125"); assertTrue(matcher.matches()); } @Test public void whenMatchesTenDigitsNumberWhitespacesHyphen_thenCorrect() { Pattern pattern = Pattern.compile("^(\\d{3}[- ]?){2}\\d{4}$"); - Matcher matcher = pattern.matcher("123 456 7890"); + Matcher matcher = pattern.matcher("202 555 0125"); assertTrue(matcher.matches()); } @Test public void whenMatchesTenDigitsNumberParenthesis_thenCorrect() { Pattern pattern = Pattern.compile("^\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$"); - Matcher matcher = pattern.matcher("(123)-456-7890"); + Matcher matcher = pattern.matcher("(202)-555-0125"); assertTrue(matcher.matches()); } @Test public void whenMatchesTenDigitsNumberPrefix_thenCorrect() { Pattern pattern = Pattern.compile("^(\\+\\d{1,3}( )?)?\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$"); - Matcher matcher = pattern.matcher("+111 (123)-456-7890"); + Matcher matcher = pattern.matcher("+111 (202)-555-0125"); assertTrue(matcher.matches()); } @@ -43,8 +43,8 @@ public class PhoneNumbersRegexUnitTest { "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?){2}\\d{3}$" + "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?)(\\d{2}[ ]?){2}\\d{2}$"; - String[] validPhoneNumbers = {"1234567890","123 456 7890", "(123)-456-7890", "+111 (123)-456-7890", - "123 456 789", "+111 123 456 789", "123 45 67 89", "+111 123 45 67 89"}; + String[] validPhoneNumbers = {"2055550125","202 555 0125", "(202)-555-0125", "+111 (202)-555-0125", + "636 856 789", "+111 636 856 789", "636 85 67 89", "+111 636 85 67 89"}; Pattern pattern = Pattern.compile(patterns); for(String phoneNumber : validPhoneNumbers) { From 6a08fca7aae349c4219809e8caa25e7ec42ca64a Mon Sep 17 00:00:00 2001 From: kkaravitis Date: Fri, 24 Apr 2020 15:04:44 +0300 Subject: [PATCH 324/503] [BAEL-3936] Fixed format to use 2-space indenting for line continuations. --- .../unrelated/entities/MultipleRecipe.java | 9 +- .../jpa/unrelated/entities/Recipe.java | 10 +- .../entities/UnrelatedEntitiesUnitTest.java | 117 +++++++++--------- 3 files changed, 70 insertions(+), 66 deletions(-) diff --git a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/MultipleRecipe.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/MultipleRecipe.java index d628af1eaf..8664d6fd7f 100644 --- a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/MultipleRecipe.java +++ b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/MultipleRecipe.java @@ -56,15 +56,16 @@ public class MultipleRecipe { if (o == null || getClass() != o.getClass()) return false; MultipleRecipe that = (MultipleRecipe) o; + return Objects.equals(id, that.id) && - Objects.equals(cocktail, that.cocktail) && - Objects.equals(instructions, that.instructions) && - Objects.equals(baseIngredient, that.baseIngredient); + Objects.equals(cocktail, that.cocktail) && + Objects.equals(instructions, that.instructions) && + Objects.equals(baseIngredient, that.baseIngredient); } @Override public int hashCode() { return Objects.hash(id, cocktail, - instructions, baseIngredient); + instructions, baseIngredient); } } diff --git a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Recipe.java b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Recipe.java index 585c6abec3..4b3d200b60 100644 --- a/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Recipe.java +++ b/persistence-modules/java-jpa-2/src/main/java/com/baeldung/jpa/unrelated/entities/Recipe.java @@ -34,11 +34,13 @@ public class Recipe { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; Recipe recipe = (Recipe) o; - return Objects.equals(cocktail, recipe.cocktail) && - Objects.equals(instructions, recipe.instructions); + return Objects.equals(cocktail, recipe.cocktail) + && Objects.equals(instructions, recipe.instructions); } @Override diff --git a/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java index 569b093db6..044e59b16e 100644 --- a/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java +++ b/persistence-modules/java-jpa-2/src/test/java/com/baeldung/jpa/unrelated/entities/UnrelatedEntitiesUnitTest.java @@ -27,9 +27,9 @@ public class UnrelatedEntitiesUnitTest { entityManager.persist(ginTonic); entityManager.persist(new Recipe(mojito.getName(), "Some instructions")); entityManager.persist(new MultipleRecipe(1L, mojito.getName(), - "some instructions", mojito.getCategory())); + "some instructions", mojito.getCategory())); entityManager.persist(new MultipleRecipe(2L, mojito.getName(), - "some other instructions", mojito.getCategory())); + "some other instructions", mojito.getCategory())); entityManager.getTransaction().commit(); } @@ -43,56 +43,56 @@ public class UnrelatedEntitiesUnitTest { public void givenCocktailsWithRecipe_whenQuerying_thenTheExpectedCocktailsReturned() { // JPA Cocktail cocktail = entityManager.createQuery("select c " - + "from Cocktail c join c.recipe", Cocktail.class) - .getSingleResult(); + + "from Cocktail c join c.recipe", Cocktail.class) + .getSingleResult(); verifyResult(mojito, cocktail); cocktail = entityManager.createQuery("select c " - + "from Cocktail c join Recipe r " - + "on c.name = r.cocktail", Cocktail.class) - .getSingleResult(); + + "from Cocktail c join Recipe r " + + "on c.name = r.cocktail", Cocktail.class) + .getSingleResult(); verifyResult(mojito, cocktail); // QueryDSL cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) - .join(QCocktail.cocktail.recipe) - .fetchOne(); + .join(QCocktail.cocktail.recipe) + .fetchOne(); verifyResult(mojito, cocktail); cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) - .join(QRecipe.recipe) - .on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail)) - .fetchOne(); + .join(QRecipe.recipe) + .on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail)) + .fetchOne(); verifyResult(mojito, cocktail); } @Test public void givenCocktailsWithoutRecipe_whenQuerying_thenTheExpectedCocktailsReturned() { Cocktail cocktail = entityManager.createQuery("select c " - + "from Cocktail c left join c.recipe r " - + "where r is null", Cocktail.class) - .getSingleResult(); + + "from Cocktail c left join c.recipe r " + + "where r is null", Cocktail.class) + .getSingleResult(); verifyResult(ginTonic, cocktail); cocktail = entityManager.createQuery("select c " - + "from Cocktail c left join Recipe r " - + "on c.name = r.cocktail " - + "where r is null", Cocktail.class) - .getSingleResult(); + + "from Cocktail c left join Recipe r " + + "on c.name = r.cocktail " + + "where r is null", Cocktail.class) + .getSingleResult(); verifyResult(ginTonic, cocktail); QRecipe recipe = new QRecipe("alias"); cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) - .leftJoin(QCocktail.cocktail.recipe, recipe) - .where(recipe.isNull()) - .fetchOne(); + .leftJoin(QCocktail.cocktail.recipe, recipe) + .where(recipe.isNull()) + .fetchOne(); verifyResult(ginTonic, cocktail); cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) - .leftJoin(QRecipe.recipe) - .on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail)) - .where(QRecipe.recipe.isNull()) - .fetchOne(); + .leftJoin(QRecipe.recipe) + .on(QCocktail.cocktail.name.eq(QRecipe.recipe.cocktail)) + .where(QRecipe.recipe.isNull()) + .fetchOne(); verifyResult(ginTonic, cocktail); } @@ -100,26 +100,26 @@ public class UnrelatedEntitiesUnitTest { public void givenCocktailsWithMultipleRecipes_whenQuerying_thenTheExpectedCocktailsReturned() { // JPQL Cocktail cocktail = entityManager.createQuery("select c " - + "from Cocktail c join c.recipeList", Cocktail.class) - .getSingleResult(); + + "from Cocktail c join c.recipeList", Cocktail.class) + .getSingleResult(); verifyResult(mojito, cocktail); cocktail = entityManager.createQuery("select c " - + "from Cocktail c join MultipleRecipe mr " - + "on mr.cocktail = c.name", Cocktail.class) - .getSingleResult(); + + "from Cocktail c join MultipleRecipe mr " + + "on mr.cocktail = c.name", Cocktail.class) + .getSingleResult(); verifyResult(mojito, cocktail); // QueryDSL cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) - .join(QCocktail.cocktail.recipeList) - .fetchOne(); + .join(QCocktail.cocktail.recipeList) + .fetchOne(); verifyResult(mojito, cocktail); cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) - .join(QMultipleRecipe.multipleRecipe) - .on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail)) - .fetchOne(); + .join(QMultipleRecipe.multipleRecipe) + .on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail)) + .fetchOne(); verifyResult(mojito, cocktail); } @@ -127,31 +127,31 @@ public class UnrelatedEntitiesUnitTest { public void givenCocktailsWithoutMultipleRecipes_whenQuerying_thenTheExpectedCocktailsReturned() { // JPQL Cocktail cocktail = entityManager.createQuery("select c " - + "from Cocktail c left join c.recipeList r " - + "where r is null", Cocktail.class) - .getSingleResult(); + + "from Cocktail c left join c.recipeList r " + + "where r is null", Cocktail.class) + .getSingleResult(); verifyResult(ginTonic, cocktail); cocktail = entityManager.createQuery("select c " - + "from Cocktail c left join MultipleRecipe r " - + "on c.name = r.cocktail " - + "where r is null", Cocktail.class) - .getSingleResult(); + + "from Cocktail c left join MultipleRecipe r " + + "on c.name = r.cocktail " + + "where r is null", Cocktail.class) + .getSingleResult(); verifyResult(ginTonic, cocktail); // QueryDSL QMultipleRecipe multipleRecipe = new QMultipleRecipe("alias"); cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) - .leftJoin(QCocktail.cocktail.recipeList, multipleRecipe) - .where(multipleRecipe.isNull()) - .fetchOne(); + .leftJoin(QCocktail.cocktail.recipeList, multipleRecipe) + .where(multipleRecipe.isNull()) + .fetchOne(); verifyResult(ginTonic, cocktail); cocktail = new JPAQuery(entityManager).from(QCocktail.cocktail) - .leftJoin(QMultipleRecipe.multipleRecipe) - .on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail)) - .where(QMultipleRecipe.multipleRecipe.isNull()) - .fetchOne(); + .leftJoin(QMultipleRecipe.multipleRecipe) + .on(QCocktail.cocktail.name.eq(QMultipleRecipe.multipleRecipe.cocktail)) + .where(QMultipleRecipe.multipleRecipe.isNull()) + .fetchOne(); verifyResult(ginTonic, cocktail); } @@ -164,20 +164,21 @@ public class UnrelatedEntitiesUnitTest { // JPQL List recipes = entityManager.createQuery("select distinct r " - + "from MultipleRecipe r " - + "join Cocktail c " - + "on r.baseIngredient = c.category", - MultipleRecipe.class) - .getResultList(); + + "from MultipleRecipe r " + + "join Cocktail c " + + "on r.baseIngredient = c.category", + MultipleRecipe.class).getResultList(); + verifyResult.accept(recipes); // QueryDSL QCocktail cocktail = QCocktail.cocktail; QMultipleRecipe multipleRecipe = QMultipleRecipe.multipleRecipe; recipes = new JPAQuery(entityManager).from(multipleRecipe) - .join(cocktail) - .on(multipleRecipe.baseIngredient.eq(cocktail.category)) - .fetch(); + .join(cocktail) + .on(multipleRecipe.baseIngredient.eq(cocktail.category)) + .fetch(); + verifyResult.accept(recipes); } From 1278f63d03fd9e761e33f1ee0d4366596320016a Mon Sep 17 00:00:00 2001 From: Kostas Karavitis Date: Fri, 24 Apr 2020 15:38:39 +0300 Subject: [PATCH 325/503] [BAEL-3936] Upgrade hibernate and querydsl to the latest stable versions --- persistence-modules/java-jpa-2/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/persistence-modules/java-jpa-2/pom.xml b/persistence-modules/java-jpa-2/pom.xml index b41cdccb07..d4532c32b8 100644 --- a/persistence-modules/java-jpa-2/pom.xml +++ b/persistence-modules/java-jpa-2/pom.xml @@ -138,7 +138,7 @@ - 5.4.0.Final + 5.4.14.Final 2.7.4-RC1 42.2.5 2.2 @@ -146,7 +146,7 @@ 3.5.1 3.3.3 3.0.0 - 4.2.2 + 4.3.1 From b31b84d475f77972c2fb512707489e0354c4169a Mon Sep 17 00:00:00 2001 From: Gergo Petrik Date: Fri, 24 Apr 2020 16:00:30 +0200 Subject: [PATCH 326/503] Mockint objectmapper with mockito (#9017) * Mockint objectmapper with mockito * enforcing naming convention for test classes * removed Spring * removed unattended changes * modified example * simplified call stack in flower validator --- spring-mockito/pom.xml | 2 +- testing-modules/mockito-2/pom.xml | 15 ++++++ .../baeldung/mockito/objectmapper/Flower.java | 32 +++++++++++ .../FlowerJsonStringValidator.java | 17 ++++++ .../FlowerJsonStringValidatorUnitTest.java | 53 +++++++++++++++++++ 5 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 testing-modules/mockito-2/src/main/java/com/baeldung/mockito/objectmapper/Flower.java create mode 100644 testing-modules/mockito-2/src/main/java/com/baeldung/mockito/objectmapper/FlowerJsonStringValidator.java create mode 100644 testing-modules/mockito-2/src/test/java/com/baeldung/mockito/objectmapper/FlowerJsonStringValidatorUnitTest.java diff --git a/spring-mockito/pom.xml b/spring-mockito/pom.xml index f3e0b04808..5d2cd7c445 100644 --- a/spring-mockito/pom.xml +++ b/spring-mockito/pom.xml @@ -28,7 +28,7 @@
    - 2.21.0 + 2.24.0 diff --git a/testing-modules/mockito-2/pom.xml b/testing-modules/mockito-2/pom.xml index 76608a3039..340af89c82 100644 --- a/testing-modules/mockito-2/pom.xml +++ b/testing-modules/mockito-2/pom.xml @@ -14,8 +14,23 @@ ../../ + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + org.mockito + mockito-junit-jupiter + ${mockito.version} + test + + + 2.21.0 + 2.10.3 diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/objectmapper/Flower.java b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/objectmapper/Flower.java new file mode 100644 index 0000000000..bc366a39f9 --- /dev/null +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/objectmapper/Flower.java @@ -0,0 +1,32 @@ +package com.baeldung.mockito.objectmapper; + +public class Flower { + + private String name; + private Integer petals; + + public Flower(String name, Integer petals) { + this.name = name; + this.petals = petals; + } + + public Flower() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getPetals() { + return petals; + } + + public void setPetals(Integer petals) { + this.petals = petals; + } + +} diff --git a/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/objectmapper/FlowerJsonStringValidator.java b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/objectmapper/FlowerJsonStringValidator.java new file mode 100644 index 0000000000..91bad66e6d --- /dev/null +++ b/testing-modules/mockito-2/src/main/java/com/baeldung/mockito/objectmapper/FlowerJsonStringValidator.java @@ -0,0 +1,17 @@ +package com.baeldung.mockito.objectmapper; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +public class FlowerJsonStringValidator { + private ObjectMapper objectMapper; + + public FlowerJsonStringValidator(ObjectMapper objectMapper) { + this.objectMapper = objectMapper; + } + + public boolean flowerHasPetals(String jsonFlowerAsString) throws JsonProcessingException { + Flower flower = objectMapper.readValue(jsonFlowerAsString, Flower.class); + return flower.getPetals() > 0; + } +} diff --git a/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/objectmapper/FlowerJsonStringValidatorUnitTest.java b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/objectmapper/FlowerJsonStringValidatorUnitTest.java new file mode 100644 index 0000000000..31c3f0d01d --- /dev/null +++ b/testing-modules/mockito-2/src/test/java/com/baeldung/mockito/objectmapper/FlowerJsonStringValidatorUnitTest.java @@ -0,0 +1,53 @@ +package com.baeldung.mockito.objectmapper; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.anyString; +import static org.mockito.Mockito.eq; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +public class FlowerJsonStringValidatorUnitTest { + + @Mock + private ObjectMapper objectMapper; + + private FlowerJsonStringValidator flowerJsonStringValidator; + + @BeforeEach + public void setUp() { + flowerJsonStringValidator = new FlowerJsonStringValidator(objectMapper); + } + + @Test + public void whenCallingHasPetalsWithPetals_thenReturnsTrue() throws JsonProcessingException { + Flower rose = new Flower("testFlower", 100); + + when(objectMapper.readValue(anyString(), eq(Flower.class))).thenReturn(rose); + + assertTrue(flowerJsonStringValidator.flowerHasPetals("this can be a very long json flower")); + + verify(objectMapper, times(1)).readValue(anyString(), eq(Flower.class)); + } + + @Test + public void whenCallingHasPetalsWithZeroPetal_thenReturnsFalse() throws JsonProcessingException { + Flower rose = new Flower("testFlowerWithoutPetal", 0); + + when(objectMapper.readValue(anyString(), eq(Flower.class))).thenReturn(rose); + + assertFalse(flowerJsonStringValidator.flowerHasPetals("this can be a very long json flower")); + + verify(objectMapper, times(1)).readValue(anyString(), eq(Flower.class)); + } +} From 35f1a3eba55288d0141e6394a616691a6ed1c124 Mon Sep 17 00:00:00 2001 From: Roque Santos Date: Fri, 24 Apr 2020 11:10:44 -0300 Subject: [PATCH 327/503] BAEL-3927 : Encode a String to UTF-8 in Java (#8954) * BAEL-3927 : Encode a String to UTF-8 in Java * Update core-java-modules/core-java-string-operations-2/src/test/java/com/baeldung/encode/StringEncodeUnitTest.java Co-Authored-By: KevinGilmore * BAEL-3927 : Applying suggested adjustments * BAEL-3927 : Simplifying the code snippets * BAEL-3927 : Coding styles adjustements * BAEL-3927 : Test adjustements to fit changes in article Co-authored-by: KevinGilmore --- .../encodetoutf8/StringEncodeUnitTest.java | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 core-java-modules/core-java-string-operations-2/src/test/java/com/baeldung/encodetoutf8/StringEncodeUnitTest.java diff --git a/core-java-modules/core-java-string-operations-2/src/test/java/com/baeldung/encodetoutf8/StringEncodeUnitTest.java b/core-java-modules/core-java-string-operations-2/src/test/java/com/baeldung/encodetoutf8/StringEncodeUnitTest.java new file mode 100644 index 0000000000..a73104b234 --- /dev/null +++ b/core-java-modules/core-java-string-operations-2/src/test/java/com/baeldung/encodetoutf8/StringEncodeUnitTest.java @@ -0,0 +1,73 @@ +package com.baeldung.encodetoutf8; + +import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; + +import org.apache.commons.codec.binary.StringUtils; +import org.junit.Test; + +public class StringEncodeUnitTest { + + @Test + public void givenGermanAsciiString_whenComparing_thenCompareNotEquals() { + String germanString = "Entwickeln Sie mit Vergnügen"; + byte[] germanBytes = germanString.getBytes(); + + String asciiEncodedString = new String(germanBytes, StandardCharsets.US_ASCII); + + assertNotEquals(germanString, asciiEncodedString); + } + + @Test + public void givenUsAsciiString_whenComparing_thenCompareNotEquals() { + String englishString = "Develop with pleasure"; + byte[] englishBytes = englishString.getBytes(); + + String asciiEncondedEnglishString = new String(englishBytes, StandardCharsets.US_ASCII); + + assertEquals(englishString, asciiEncondedEnglishString); + } + + /* + * ApacheCommonsCodecEncode + */ + @Test + public void givenSomeUnencodedString_whenApacheCommonsCodecEncode_thenCompareEquals() { + String rawString = "Entwickeln Sie mit Vergnügen"; + byte[] bytes = StringUtils.getBytesUtf8(rawString); + + String utf8EncodedString = StringUtils.newStringUtf8(bytes); + + assertEquals(rawString, utf8EncodedString); + } + + /* + * CoreJavaEncode + */ + @Test + public void givenSomeUnencodedString_whenCoreJavaEncode_thenCompareEquals() { + String rawString = "Entwickeln Sie mit Vergnügen"; + byte[] bytes = rawString.getBytes(StandardCharsets.UTF_8); + + String utf8EncodedString = new String(bytes, StandardCharsets.UTF_8); + + assertEquals(rawString, utf8EncodedString); + } + + /* + * Java7StandardCharsetsEncode + */ + @Test + public void givenSomeUnencodedString_whenJava7StandardCharsetsEncode_thenCompareEquals() { + String rawString = "Entwickeln Sie mit Vergnügen"; + ByteBuffer buffer = StandardCharsets.UTF_8.encode(rawString); + + String utf8EncodedString = StandardCharsets.UTF_8.decode(buffer) + .toString(); + + assertEquals(rawString, utf8EncodedString); + } +} From 7d6e096d28e9c1585f52bb464e9150ebbd2ca3b1 Mon Sep 17 00:00:00 2001 From: Donato Rimenti Date: Fri, 24 Apr 2020 16:51:50 +0200 Subject: [PATCH 328/503] Fixed whitespace formatting. --- libraries-data-2/pom.xml | 77 +++++++++---------- .../main/java/com/baeldung/r/FastRMean.java | 33 ++++---- .../main/java/com/baeldung/r/RCallerMean.java | 37 ++++----- .../src/main/java/com/baeldung/r/RUtils.java | 27 ++++--- .../main/java/com/baeldung/r/RenjinMean.java | 34 ++++---- .../main/java/com/baeldung/r/RserveMean.java | 29 +++---- .../com/baeldung/r/FastRMeanUnitTest.java | 26 +++---- .../r/RCallerMeanIntegrationTest.java | 32 ++++---- .../com/baeldung/r/RenjinMeanUnitTest.java | 34 ++++---- .../baeldung/r/RserveMeanIntegrationTest.java | 32 ++++---- 10 files changed, 184 insertions(+), 177 deletions(-) diff --git a/libraries-data-2/pom.xml b/libraries-data-2/pom.xml index 0dadcbd8d4..73c5452f77 100644 --- a/libraries-data-2/pom.xml +++ b/libraries-data-2/pom.xml @@ -128,24 +128,21 @@ ${awaitility.version} test - - - org.rosuda.REngine - Rserve - ${rserve.version} - - - - com.github.jbytecode - RCaller - ${rcaller.version} - - - - org.renjin - renjin-script-engine - ${renjin.version} - + + org.rosuda.REngine + Rserve + ${rserve.version} + + + com.github.jbytecode + RCaller + ${rcaller.version} + + + org.renjin + renjin-script-engine + ${renjin.version} +
    @@ -157,11 +154,11 @@ - - bedatadriven - bedatadriven public repo - https://nexus.bedatadriven.com/content/groups/public/ - + + bedatadriven + bedatadriven public repo + https://nexus.bedatadriven.com/content/groups/public/ + @@ -183,22 +180,22 @@ 1.8.1 - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - com/baeldung/r/FastRMean.java - - - com/baeldung/r/FastRMeanUnitTest.java - - - - - + + + + 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/main/java/com/baeldung/r/FastRMean.java b/libraries-data-2/src/main/java/com/baeldung/r/FastRMean.java index 52fb2d1506..8348bfa403 100644 --- a/libraries-data-2/src/main/java/com/baeldung/r/FastRMean.java +++ b/libraries-data-2/src/main/java/com/baeldung/r/FastRMean.java @@ -10,19 +10,24 @@ import java.net.URISyntaxException; */ public class FastRMean { - /** - * Invokes the customMean R function passing the given values as arguments. - * - * @param values the input to the mean script - * @return the result of the R script - */ - public double mean(int[] values) { - Context polyglot = Context.newBuilder().allowAllAccess(true).build(); - String meanScriptContent = RUtils.getMeanScriptContent(); - polyglot.eval("R", meanScriptContent); - Value rBindings = polyglot.getBindings("R"); - Value rInput = rBindings.getMember("c").execute(values); - return rBindings.getMember("customMean").execute(rInput).asDouble(); - } + /** + * Invokes the customMean R function passing the given values as arguments. + * + * @param values the input to the mean script + * @return the result of the R script + */ + public double mean(int[] values) { + Context polyglot = Context.newBuilder() + .allowAllAccess(true) + .build(); + String meanScriptContent = RUtils.getMeanScriptContent(); + polyglot.eval("R", meanScriptContent); + Value rBindings = polyglot.getBindings("R"); + Value rInput = rBindings.getMember("c") + .execute(values); + return rBindings.getMember("customMean") + .execute(rInput) + .asDouble(); + } } \ No newline at end of file diff --git a/libraries-data-2/src/main/java/com/baeldung/r/RCallerMean.java b/libraries-data-2/src/main/java/com/baeldung/r/RCallerMean.java index 53e0ab9e31..99edb8c043 100644 --- a/libraries-data-2/src/main/java/com/baeldung/r/RCallerMean.java +++ b/libraries-data-2/src/main/java/com/baeldung/r/RCallerMean.java @@ -14,23 +14,24 @@ import com.github.rcaller.rstuff.RCode; */ public class RCallerMean { - /** - * Invokes the customMean R function passing the given values as arguments. - * - * @param values the input to the mean script - * @return the result of the R script - * @throws IOException if any error occurs - * @throws URISyntaxException if any error occurs - */ - public double mean(int[] values) throws IOException, URISyntaxException { - String fileContent = RUtils.getMeanScriptContent(); - RCode code = RCode.create(); - code.addRCode(fileContent); - code.addIntArray("input", values); - code.addRCode("result <- customMean(input)"); - RCaller caller = RCaller.create(code, RCallerOptions.create()); - caller.runAndReturnResult("result"); - return caller.getParser().getAsDoubleArray("result")[0]; - } + /** + * Invokes the customMean R function passing the given values as arguments. + * + * @param values the input to the mean script + * @return the result of the R script + * @throws IOException if any error occurs + * @throws URISyntaxException if any error occurs + */ + public double mean(int[] values) throws IOException, URISyntaxException { + String fileContent = RUtils.getMeanScriptContent(); + RCode code = RCode.create(); + code.addRCode(fileContent); + code.addIntArray("input", values); + code.addRCode("result <- customMean(input)"); + RCaller caller = RCaller.create(code, RCallerOptions.create()); + caller.runAndReturnResult("result"); + return caller.getParser() + .getAsDoubleArray("result")[0]; + } } \ No newline at end of file diff --git a/libraries-data-2/src/main/java/com/baeldung/r/RUtils.java b/libraries-data-2/src/main/java/com/baeldung/r/RUtils.java index ad16fd5602..a9393cdcc2 100644 --- a/libraries-data-2/src/main/java/com/baeldung/r/RUtils.java +++ b/libraries-data-2/src/main/java/com/baeldung/r/RUtils.java @@ -15,16 +15,19 @@ import java.util.stream.Collectors; */ public class RUtils { - /** - * Loads the script.R and returns its content as a string. - * - * @return the script.R content as a string - * @throws IOException if any error occurs - * @throws URISyntaxException if any error occurs - */ - static String getMeanScriptContent() throws IOException, URISyntaxException { - URI rScriptUri = RUtils.class.getClassLoader().getResource("script.R").toURI(); - Path inputScript = Paths.get(rScriptUri); - return Files.lines(inputScript).collect(Collectors.joining()); - } + /** + * Loads the script.R and returns its content as a string. + * + * @return the script.R content as a string + * @throws IOException if any error occurs + * @throws URISyntaxException if any error occurs + */ + static String getMeanScriptContent() throws IOException, URISyntaxException { + URI rScriptUri = RUtils.class.getClassLoader() + .getResource("script.R") + .toURI(); + Path inputScript = Paths.get(rScriptUri); + return Files.lines(inputScript) + .collect(Collectors.joining()); + } } \ No newline at end of file diff --git a/libraries-data-2/src/main/java/com/baeldung/r/RenjinMean.java b/libraries-data-2/src/main/java/com/baeldung/r/RenjinMean.java index befb7d522f..4576ec5fb4 100644 --- a/libraries-data-2/src/main/java/com/baeldung/r/RenjinMean.java +++ b/libraries-data-2/src/main/java/com/baeldung/r/RenjinMean.java @@ -15,22 +15,22 @@ import org.renjin.sexp.DoubleArrayVector; */ public class RenjinMean { - /** - * Invokes the customMean R function passing the given values as arguments. - * - * @param values the input to the mean script - * @return the result of the R script - * @throws IOException if any error occurs - * @throws URISyntaxException if any error occurs - * @throws ScriptException if any error occurs - */ - public double mean(int[] values) throws IOException, URISyntaxException, ScriptException { - RenjinScriptEngine engine = new RenjinScriptEngine(); - String meanScriptContent = RUtils.getMeanScriptContent(); - engine.put("input", values); - engine.eval(meanScriptContent); - DoubleArrayVector result = (DoubleArrayVector) engine.eval("customMean(input)"); - return result.asReal(); - } + /** + * Invokes the customMean R function passing the given values as arguments. + * + * @param values the input to the mean script + * @return the result of the R script + * @throws IOException if any error occurs + * @throws URISyntaxException if any error occurs + * @throws ScriptException if any error occurs + */ + public double mean(int[] values) throws IOException, URISyntaxException, ScriptException { + RenjinScriptEngine engine = new RenjinScriptEngine(); + String meanScriptContent = RUtils.getMeanScriptContent(); + engine.put("input", values); + engine.eval(meanScriptContent); + DoubleArrayVector result = (DoubleArrayVector) engine.eval("customMean(input)"); + return result.asReal(); + } } \ No newline at end of file diff --git a/libraries-data-2/src/main/java/com/baeldung/r/RserveMean.java b/libraries-data-2/src/main/java/com/baeldung/r/RserveMean.java index 51aaa90648..1aaa7fa847 100644 --- a/libraries-data-2/src/main/java/com/baeldung/r/RserveMean.java +++ b/libraries-data-2/src/main/java/com/baeldung/r/RserveMean.java @@ -11,19 +11,20 @@ import org.rosuda.REngine.Rserve.RConnection; */ public class RserveMean { - /** - * Connects to the Rserve istance listening on 127.0.0.1:6311 and invokes the - * customMean R function passing the given values as arguments. - * - * @param values the input to the mean script - * @return the result of the R script - * @throws REngineException if any error occurs - * @throws REXPMismatchException if any error occurs - */ - public double mean(int[] values) throws REngineException, REXPMismatchException { - RConnection c = new RConnection(); - c.assign("input", values); - return c.eval("customMean(input)").asDouble(); - } + /** + * Connects to the Rserve istance listening on 127.0.0.1:6311 and invokes the + * customMean R function passing the given values as arguments. + * + * @param values the input to the mean script + * @return the result of the R script + * @throws REngineException if any error occurs + * @throws REXPMismatchException if any error occurs + */ + public double mean(int[] values) throws REngineException, REXPMismatchException { + RConnection c = new RConnection(); + c.assign("input", values); + return c.eval("customMean(input)") + .asDouble(); + } } \ No newline at end of file diff --git a/libraries-data-2/src/test/java/com/baeldung/r/FastRMeanUnitTest.java b/libraries-data-2/src/test/java/com/baeldung/r/FastRMeanUnitTest.java index 5cf8c63a56..4e7426b75a 100644 --- a/libraries-data-2/src/test/java/com/baeldung/r/FastRMeanUnitTest.java +++ b/libraries-data-2/src/test/java/com/baeldung/r/FastRMeanUnitTest.java @@ -12,18 +12,18 @@ import org.junit.Test; @Ignore public class FastRMeanUnitTest { - /** - * Object to test. - */ - private FastRMean fastrMean = new FastRMean(); + /** + * Object to test. + */ + private FastRMean fastrMean = new FastRMean(); - /** - * Test for {@link FastRMeanUnitTest#mean(int[])}. - */ - @Test - public void givenValues_whenMean_thenCorrect() { - int[] input = { 1, 2, 3, 4, 5 }; - double result = fastrMean.mean(input); - Assert.assertEquals(3.0, result, 0.000001); - } + /** + * Test for {@link FastRMeanUnitTest#mean(int[])}. + */ + @Test + public void givenValues_whenMean_thenCorrect() { + int[] input = { 1, 2, 3, 4, 5 }; + double result = fastrMean.mean(input); + Assert.assertEquals(3.0, result, 0.000001); + } } \ No newline at end of file diff --git a/libraries-data-2/src/test/java/com/baeldung/r/RCallerMeanIntegrationTest.java b/libraries-data-2/src/test/java/com/baeldung/r/RCallerMeanIntegrationTest.java index b68f259edd..ce6b3a4332 100644 --- a/libraries-data-2/src/test/java/com/baeldung/r/RCallerMeanIntegrationTest.java +++ b/libraries-data-2/src/test/java/com/baeldung/r/RCallerMeanIntegrationTest.java @@ -17,21 +17,21 @@ import org.junit.Test; @Ignore public class RCallerMeanIntegrationTest { - /** - * Object to test. - */ - private RCallerMean rcallerMean = new RCallerMean(); + /** + * Object to test. + */ + private RCallerMean rcallerMean = new RCallerMean(); - /** - * Test for {@link RCallerMeanIntegrationTest#mean(int[])}. - * - * @throws ScriptException if an error occurs - * @throws URISyntaxException if an error occurs - */ - @Test - public void givenValues_whenMean_thenCorrect() throws IOException, URISyntaxException { - int[] input = { 1, 2, 3, 4, 5 }; - double result = rcallerMean.mean(input); - Assert.assertEquals(3.0, result, 0.000001); - } + /** + * Test for {@link RCallerMeanIntegrationTest#mean(int[])}. + * + * @throws ScriptException if an error occurs + * @throws URISyntaxException if an error occurs + */ + @Test + public void givenValues_whenMean_thenCorrect() throws IOException, URISyntaxException { + int[] input = { 1, 2, 3, 4, 5 }; + double result = rcallerMean.mean(input); + Assert.assertEquals(3.0, result, 0.000001); + } } \ No newline at end of file diff --git a/libraries-data-2/src/test/java/com/baeldung/r/RenjinMeanUnitTest.java b/libraries-data-2/src/test/java/com/baeldung/r/RenjinMeanUnitTest.java index e364d54632..f52d37d614 100644 --- a/libraries-data-2/src/test/java/com/baeldung/r/RenjinMeanUnitTest.java +++ b/libraries-data-2/src/test/java/com/baeldung/r/RenjinMeanUnitTest.java @@ -16,22 +16,22 @@ import org.junit.Assert; */ public class RenjinMeanUnitTest { - /** - * Object to test. - */ - private RenjinMean renjinMean = new RenjinMean(); + /** + * Object to test. + */ + private RenjinMean renjinMean = new RenjinMean(); - /** - * Test for {@link RenjinMeanUnitTest#mean(int[])}. - * - * @throws ScriptException if an error occurs - * @throws URISyntaxException if an error occurs - * @throws IOException if an error occurs - */ - @Test - public void givenValues_whenMean_thenCorrect() throws IOException, URISyntaxException, ScriptException { - int[] input = { 1, 2, 3, 4, 5 }; - double result = renjinMean.mean(input); - Assert.assertEquals(3.0, result, 0.000001); - } + /** + * Test for {@link RenjinMeanUnitTest#mean(int[])}. + * + * @throws ScriptException if an error occurs + * @throws URISyntaxException if an error occurs + * @throws IOException if an error occurs + */ + @Test + public void givenValues_whenMean_thenCorrect() throws IOException, URISyntaxException, ScriptException { + int[] input = { 1, 2, 3, 4, 5 }; + double result = renjinMean.mean(input); + Assert.assertEquals(3.0, result, 0.000001); + } } \ No newline at end of file diff --git a/libraries-data-2/src/test/java/com/baeldung/r/RserveMeanIntegrationTest.java b/libraries-data-2/src/test/java/com/baeldung/r/RserveMeanIntegrationTest.java index 95b344cb02..23d42bd8e9 100644 --- a/libraries-data-2/src/test/java/com/baeldung/r/RserveMeanIntegrationTest.java +++ b/libraries-data-2/src/test/java/com/baeldung/r/RserveMeanIntegrationTest.java @@ -14,21 +14,21 @@ import org.rosuda.REngine.REngineException; @Ignore public class RserveMeanIntegrationTest { - /** - * Object to test. - */ - private RserveMean rserveMean = new RserveMean(); + /** + * Object to test. + */ + private RserveMean rserveMean = new RserveMean(); - /** - * Test for {@link RserveMeanIntegrationTest#mean(int[])}. - * - * @throws REXPMismatchException if an error occurs - * @throws REngineException if an error occurs - */ - @Test - public void givenValues_whenMean_thenCorrect() throws REngineException, REXPMismatchException { - int[] input = { 1, 2, 3, 4, 5 }; - double result = rserveMean.mean(input); - Assert.assertEquals(3.0, result, 0.000001); - } + /** + * Test for {@link RserveMeanIntegrationTest#mean(int[])}. + * + * @throws REXPMismatchException if an error occurs + * @throws REngineException if an error occurs + */ + @Test + public void givenValues_whenMean_thenCorrect() throws REngineException, REXPMismatchException { + int[] input = { 1, 2, 3, 4, 5 }; + double result = rserveMean.mean(input); + Assert.assertEquals(3.0, result, 0.000001); + } } \ No newline at end of file From 73f96969da098b873415b475f3ad1463dc4f45cd Mon Sep 17 00:00:00 2001 From: Paturi Radhe Sravan Date: Sat, 25 Apr 2020 03:06:41 +0530 Subject: [PATCH 329/503] BAEL-3567 An Introduction to Kaniko (#9150) * BAEL-3597 Cactoos * BAEL-3597 Cactoos * BAEL-3597 Cactoos * BAEL-3597 Cactoos * BAEL-3567 An Introduction to Kaniko * BAEL-3597 Cactoos * BAEL-3597 Cactoos * BAEL-3597 Cactoos * BAEL-3597 Cactoos * BAEL-3567 An Introduction to Kaniko * BAEL-3567 An Introduction to Kaniko --- kaniko/dockerfile | 2 ++ kaniko/pod.yaml | 19 +++++++++++++++++++ kaniko/volume-claim.yaml | 11 +++++++++++ kaniko/volume.yaml | 14 ++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 kaniko/dockerfile create mode 100644 kaniko/pod.yaml create mode 100644 kaniko/volume-claim.yaml create mode 100644 kaniko/volume.yaml diff --git a/kaniko/dockerfile b/kaniko/dockerfile new file mode 100644 index 0000000000..0290bf16ed --- /dev/null +++ b/kaniko/dockerfile @@ -0,0 +1,2 @@ +FROM ubuntu +ENTRYPOINT ["/bin/bash", "-c", "echo hello"] diff --git a/kaniko/pod.yaml b/kaniko/pod.yaml new file mode 100644 index 0000000000..17f9a81b6d --- /dev/null +++ b/kaniko/pod.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Pod +metadata: + name: kaniko +spec: + containers: + - name: kaniko + image: gcr.io/kaniko-project/executor:latest + args: ["--dockerfile=/workspace/dockerfile", + "--context=dir://workspace", + "--no-push"] + volumeMounts: + - name: dockerfile-storage + mountPath: /workspace + restartPolicy: Never + volumes: + - name: dockerfile-storage + persistentVolumeClaim: + claimName: dockerfile-claim diff --git a/kaniko/volume-claim.yaml b/kaniko/volume-claim.yaml new file mode 100644 index 0000000000..7a1abbf05c --- /dev/null +++ b/kaniko/volume-claim.yaml @@ -0,0 +1,11 @@ +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: dockerfile-claim +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 8Gi + storageClassName: local-storage diff --git a/kaniko/volume.yaml b/kaniko/volume.yaml new file mode 100644 index 0000000000..e44663ec5a --- /dev/null +++ b/kaniko/volume.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: dockerfile + labels: + type: local +spec: + capacity: + storage: 10Gi + accessModes: + - ReadWriteOnce + storageClassName: local-storage + hostPath: + path: /home/docker/kaniko # Path to the local mount directory that was setup From 44485bcc48a090a6fd2850047065ce8a7677276c Mon Sep 17 00:00:00 2001 From: Cavero Barca Date: Sat, 25 Apr 2020 01:49:20 +0200 Subject: [PATCH 330/503] Use a two-space indent when continuing a line --- .../WebFilterGatewayApplication.java | 4 +- .../config/ModifyBodyRouteConfig.java | 16 ++--- .../WebFilterFactoriesLiveTest.java | 69 +++++++++---------- 3 files changed, 43 insertions(+), 46 deletions(-) diff --git a/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/WebFilterGatewayApplication.java b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/WebFilterGatewayApplication.java index 3b45e9013f..852e5cadba 100644 --- a/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/WebFilterGatewayApplication.java +++ b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/WebFilterGatewayApplication.java @@ -8,8 +8,8 @@ public class WebFilterGatewayApplication { public static void main(String[] args) { new SpringApplicationBuilder(WebFilterGatewayApplication.class) - .profiles("webfilters") - .run(args); + .profiles("webfilters") + .run(args); } } \ No newline at end of file diff --git a/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/ModifyBodyRouteConfig.java b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/ModifyBodyRouteConfig.java index ccc789f287..7b6188b66a 100644 --- a/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/ModifyBodyRouteConfig.java +++ b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/ModifyBodyRouteConfig.java @@ -14,19 +14,19 @@ public class ModifyBodyRouteConfig { @Bean public RouteLocator routes(RouteLocatorBuilder builder) { return builder.routes() - .route("modify_request_body", r -> r.path("/post") - .filters(f -> f.modifyRequestBody(String.class, Hello.class, MediaType.APPLICATION_JSON_VALUE, - (exchange, s) -> Mono.just(new Hello(s.toUpperCase())))).uri("https://httpbin.org")) - .build(); + .route("modify_request_body", r -> r.path("/post") + .filters(f -> f.modifyRequestBody(String.class, Hello.class, MediaType.APPLICATION_JSON_VALUE, + (exchange, s) -> Mono.just(new Hello(s.toUpperCase())))).uri("https://httpbin.org")) + .build(); } @Bean public RouteLocator responseRoutes(RouteLocatorBuilder builder) { return builder.routes() - .route("modify_response_body", r -> r.path("/put/**") - .filters(f -> f.modifyResponseBody(String.class, Hello.class, MediaType.APPLICATION_JSON_VALUE, - (exchange, s) -> Mono.just(new Hello("New Body")))).uri("https://httpbin.org")) - .build(); + .route("modify_response_body", r -> r.path("/put/**") + .filters(f -> f.modifyResponseBody(String.class, Hello.class, MediaType.APPLICATION_JSON_VALUE, + (exchange, s) -> Mono.just(new Hello("New Body")))).uri("https://httpbin.org")) + .build(); } static class Hello { diff --git a/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/WebFilterFactoriesLiveTest.java b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/WebFilterFactoriesLiveTest.java index 3efd60fb27..67e00a42fc 100644 --- a/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/WebFilterFactoriesLiveTest.java +++ b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/WebFilterFactoriesLiveTest.java @@ -33,23 +33,23 @@ public class WebFilterFactoriesLiveTest { @Autowired private WebTestClient client; - + @Autowired private TestRestTemplate restTemplate; @BeforeEach public void configureClient() { client = WebTestClient.bindToServer() - .baseUrl("http://localhost:" + port) - .build(); + .baseUrl("http://localhost:" + port) + .build(); } @Test public void whenCallGetThroughGateway_thenAllHTTPRequestHeadersParametersAreSet() throws JSONException { - String url = "http://localhost:" + port + "/get"; + String url = "http://localhost:" + port + "/get"; ResponseEntity response = restTemplate.getForEntity(url, String.class); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - + JSONObject json = new JSONObject(response.getBody()); JSONObject headers = json.getJSONObject("headers"); assertThat(headers.getString("My-Header-Good")).isEqualTo("Good"); @@ -63,76 +63,73 @@ public class WebFilterFactoriesLiveTest { @Test public void whenCallHeaderPostThroughGateway_thenAllHTTPResponseHeadersAreSet() { ResponseSpec response = client.post() - .uri("/header/post") - .exchange(); + .uri("/header/post") + .exchange(); response.expectStatus() - .isOk() - .expectHeader() - .valueEquals("My-Header-Rewrite", "password=***") - .expectHeader() - .valueEquals("My-Header-Set", "Set") - .expectHeader() - .valueEquals("My-Header-Good", "Good") - .expectHeader() - .doesNotExist("My-Header-Remove"); + .isOk() + .expectHeader() + .valueEquals("My-Header-Rewrite", "password=***") + .expectHeader() + .valueEquals("My-Header-Set", "Set") + .expectHeader() + .valueEquals("My-Header-Good", "Good") + .expectHeader() + .doesNotExist("My-Header-Remove"); } @Test public void whenCallPostThroughGateway_thenBodyIsRetrieved() throws JSONException { - String url = "http://localhost:" + port + "/post"; + String url = "http://localhost:" + port + "/post"; HttpEntity entity = new HttpEntity<>("content", new HttpHeaders()); - - ResponseEntity response = restTemplate.exchange(url, - HttpMethod.POST, entity, String.class); + + ResponseEntity response = restTemplate.exchange(url, HttpMethod.POST, entity, String.class); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - + JSONObject json = new JSONObject(response.getBody()); JSONObject data = json.getJSONObject("json"); assertThat(data.getString("message")).isEqualTo("CONTENT"); } - @Test public void whenCallPutThroughGateway_thenBodyIsRetrieved() throws JSONException { - String url = "http://localhost:" + port + "/put"; + String url = "http://localhost:" + port + "/put"; HttpEntity entity = new HttpEntity<>("CONTENT", new HttpHeaders()); - - ResponseEntity response = restTemplate.exchange(url, - HttpMethod.PUT, entity, String.class); + + ResponseEntity response = restTemplate.exchange(url, HttpMethod.PUT, entity, String.class); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); - + JSONObject json = new JSONObject(response.getBody()); assertThat(json.getString("message")).isEqualTo("New Body"); } - + @Test public void whenCallDeleteThroughGateway_thenIsUnauthorizedCodeIsSet() { ResponseSpec response = client.delete() - .uri("/delete") - .exchange(); + .uri("/delete") + .exchange(); response.expectStatus() - .isUnauthorized(); + .isUnauthorized(); } @Test public void whenCallFakePostThroughGateway_thenIsUnauthorizedCodeIsSet() { ResponseSpec response = client.post() - .uri("/fake/post") - .exchange(); + .uri("/fake/post") + .exchange(); response.expectStatus() - .is3xxRedirection(); + .is3xxRedirection(); } @Test public void whenCallStatus504ThroughGateway_thenCircuitBreakerIsExecuted() throws JSONException { - String url = "http://localhost:" + port + "/status/504"; + String url = "http://localhost:" + port + "/status/504"; ResponseEntity response = restTemplate.getForEntity(url, String.class); - + JSONObject json = new JSONObject(response.getBody()); assertThat(json.getString("url")).contains("anything"); } From d090c9b059c5e3d2752a6d7422fe344cca8b1dd5 Mon Sep 17 00:00:00 2001 From: KevinGilmore Date: Fri, 24 Apr 2020 22:28:04 -0500 Subject: [PATCH 331/503] BAEL-2893 BAEL-3927 update README files (#9171) * BAEL-3336 BAEL-3058 add links * BAEL-3319: add link * BAEL-3284: add link * BAEL-3198: add link to article * BAEL-3479: add link to article * BAEL-3485: add article link * SCALA-38: move to new package and add link back to article * SCALA-38: add imports back into unit test * BAEL-3908: add link back to article * BAEL-2893 BAEL-3927 add link back to article --- core-java-modules/core-java-string-operations-2/README.md | 1 + testing-modules/mockito-2/README.md | 1 + 2 files changed, 2 insertions(+) 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 45b02a3e10..2f54aa9467 100644 --- a/core-java-modules/core-java-string-operations-2/README.md +++ b/core-java-modules/core-java-string-operations-2/README.md @@ -11,4 +11,5 @@ This module contains articles about string operations. - [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) - More articles: [[<-- prev]](../core-java-string-operations) diff --git a/testing-modules/mockito-2/README.md b/testing-modules/mockito-2/README.md index 064366dfd5..6c9ddee01d 100644 --- a/testing-modules/mockito-2/README.md +++ b/testing-modules/mockito-2/README.md @@ -4,3 +4,4 @@ - [Lazy Verification with Mockito 2](https://www.baeldung.com/mockito-2-lazy-verification) - [Mockito Strict Stubbing and The UnnecessaryStubbingException](https://www.baeldung.com/mockito-unnecessary-stubbing-exception) - [Mockito and Fluent APIs](https://www.baeldung.com/mockito-fluent-apis) +- [Mocking the ObjectMapper readValue() Method](https://www.baeldung.com/mockito-mock-jackson-read-value) From 89fd7872c476c05a1a362f502910f31b59c4a916 Mon Sep 17 00:00:00 2001 From: sasam0320 <63002713+sasam0320@users.noreply.github.com> Date: Sat, 25 Apr 2020 07:32:20 +0200 Subject: [PATCH 332/503] BAEL-3973 (#9061) --- gradle/gradle-employee-app/.gitignore | 3 ++ gradle/gradle-employee-app/build.gradle | 38 +++++++++++++++++++ .../src/main/java/employee/Employee.java | 9 +++++ .../src/main/java/employee/EmployeeApp.java | 16 ++++++++ .../test/java/employee/EmployeeAppTest.java | 31 +++++++++++++++ gradle/settings.gradle | 2 +- 6 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 gradle/gradle-employee-app/.gitignore create mode 100644 gradle/gradle-employee-app/build.gradle create mode 100644 gradle/gradle-employee-app/src/main/java/employee/Employee.java create mode 100644 gradle/gradle-employee-app/src/main/java/employee/EmployeeApp.java create mode 100644 gradle/gradle-employee-app/src/test/java/employee/EmployeeAppTest.java diff --git a/gradle/gradle-employee-app/.gitignore b/gradle/gradle-employee-app/.gitignore new file mode 100644 index 0000000000..d347f664af --- /dev/null +++ b/gradle/gradle-employee-app/.gitignore @@ -0,0 +1,3 @@ +/.idea +/.gradle +/build diff --git a/gradle/gradle-employee-app/build.gradle b/gradle/gradle-employee-app/build.gradle new file mode 100644 index 0000000000..19b80c0c4a --- /dev/null +++ b/gradle/gradle-employee-app/build.gradle @@ -0,0 +1,38 @@ + +plugins { + id 'java-library' + id 'application' +} + +apply plugin: 'application' +mainClassName = 'employee.EmployeeApp' + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +println 'This is executed during configuration phase' + +task configured { + println 'The project is configured' +} + +task wrapper(type: Wrapper){ + gradleVersion = '5.3.1' +} + +repositories { + jcenter() +} + +dependencies { + + compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.10' + testImplementation('junit:junit:4.13') + testRuntime('junit:junit:4.13') +} +test { + useJUnit() +} + diff --git a/gradle/gradle-employee-app/src/main/java/employee/Employee.java b/gradle/gradle-employee-app/src/main/java/employee/Employee.java new file mode 100644 index 0000000000..6940c8c28c --- /dev/null +++ b/gradle/gradle-employee-app/src/main/java/employee/Employee.java @@ -0,0 +1,9 @@ +package employee; + +public class Employee { + + String name; + String emailAddress; + int yearOfBirth; + +} \ No newline at end of file diff --git a/gradle/gradle-employee-app/src/main/java/employee/EmployeeApp.java b/gradle/gradle-employee-app/src/main/java/employee/EmployeeApp.java new file mode 100644 index 0000000000..48ef9f5d61 --- /dev/null +++ b/gradle/gradle-employee-app/src/main/java/employee/EmployeeApp.java @@ -0,0 +1,16 @@ +package employee; + +public class EmployeeApp { + + public static void main(String[] args){ + + Employee employee = new Employee(); + employee.name = "John"; + employee.emailAddress = "john@baeldung.com"; + employee.yearOfBirth = 1978; + System.out.println("Name: " + employee.name); + System.out.println("Email Address: " + employee.emailAddress); + System.out.println("Year Of Birth:" + employee.yearOfBirth); + } + +} diff --git a/gradle/gradle-employee-app/src/test/java/employee/EmployeeAppTest.java b/gradle/gradle-employee-app/src/test/java/employee/EmployeeAppTest.java new file mode 100644 index 0000000000..013bcc35b6 --- /dev/null +++ b/gradle/gradle-employee-app/src/test/java/employee/EmployeeAppTest.java @@ -0,0 +1,31 @@ +package employee; + +import employee.Employee; +import org.junit.*; +import static org.junit.Assert.*; + +public class EmployeeAppTest { + + @Test + public void testData(){ + + Employee testEmp = this.getEmployeeTest(); + + assertEquals(testEmp.name, "John"); + assertEquals(testEmp.emailAddress, "john@baeldung.com"); + assertEquals(testEmp.yearOfBirth, 1978); + + + } + + private Employee getEmployeeTest(){ + + Employee employee = new Employee(); + employee.name = "John"; + employee.emailAddress = "john@baeldung.com"; + employee.yearOfBirth = 1978; + + return employee; + } + +} \ No newline at end of file diff --git a/gradle/settings.gradle b/gradle/settings.gradle index f1d64de58a..59300f9281 100644 --- a/gradle/settings.gradle +++ b/gradle/settings.gradle @@ -1,10 +1,10 @@ rootProject.name = 'gradletutorial' - include 'greeting-library' include 'greeting-library-java' include 'greeter' include 'gradletaskdemo' include 'junit5' +include 'gradle-employee-app' println 'This will be executed during the initialization phase.' From a73fb8483a036103945b5934f1b40c70e7020f99 Mon Sep 17 00:00:00 2001 From: sergio41 Date: Sat, 25 Apr 2020 14:19:28 +0200 Subject: [PATCH 333/503] [BAEL-3944] Package move --- .../regex/{ => phonenumbers}/PhoneNumbersRegexUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/{ => phonenumbers}/PhoneNumbersRegexUnitTest.java (98%) diff --git a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/PhoneNumbersRegexUnitTest.java b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/phonenumbers/PhoneNumbersRegexUnitTest.java similarity index 98% rename from core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/PhoneNumbersRegexUnitTest.java rename to core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/phonenumbers/PhoneNumbersRegexUnitTest.java index 620b7a9bae..f7a9d70850 100644 --- a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/PhoneNumbersRegexUnitTest.java +++ b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/phonenumbers/PhoneNumbersRegexUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.regex; +package com.baeldung.regex.phonenumbers; import static org.junit.Assert.*; From fab18f2126b26d0dbe8f0e492e4d075f5a49bd57 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sat, 25 Apr 2020 18:12:08 +0530 Subject: [PATCH 334/503] JAVA-926: Migrate spring-boot-custom-starter to parent-boot-2 --- .../test/java/{org => com}/baeldung/SpringContextTest.java | 0 .../greeter-spring-boot-sample-app/pom.xml | 4 ++-- .../test/java/{org => com}/baeldung/SpringContextTest.java | 0 .../spring-boot-custom-starter/greeter/pom.xml | 4 ++-- 4 files changed, 4 insertions(+), 4 deletions(-) rename spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/{org => com}/baeldung/SpringContextTest.java (100%) rename spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/{org => com}/baeldung/SpringContextTest.java (100%) diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/com/baeldung/SpringContextTest.java 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 818ce5c107..8d328b88be 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 @@ -8,9 +8,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../../../parent-boot-1 + ../../../parent-boot-2 diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter/pom.xml index 89119e2e99..47296990aa 100644 --- a/spring-boot-modules/spring-boot-custom-starter/greeter/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/greeter/pom.xml @@ -8,9 +8,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../../../parent-boot-1 + ../../../parent-boot-2 \ No newline at end of file From b7588a7a3335ade294b463b98c6775269701a885 Mon Sep 17 00:00:00 2001 From: Sampada <46674082+sampada07@users.noreply.github.com> Date: Sat, 25 Apr 2020 22:14:35 +0530 Subject: [PATCH 335/503] BAEL-3989: Calling a SOAP web service from Spring (#9174) --- spring-soap/pom.xml | 22 +++ .../springsoap/client/CountryClient.java | 26 ++++ .../client/CountryClientConfig.java | 25 +++ .../springsoap/client/gen/Country.java | 146 ++++++++++++++++++ .../springsoap/client/gen/Currency.java | 47 ++++++ .../client/gen/GetCountryRequest.java | 71 +++++++++ .../client/gen/GetCountryResponse.java | 71 +++++++++ .../springsoap/client/gen/ObjectFactory.java | 63 ++++++++ .../springsoap/client/gen/package-info.java | 9 ++ spring-soap/src/main/resources/countries.wsdl | 74 +++++++++ .../client/CountryClientLiveTest.java | 36 +++++ 11 files changed, 590 insertions(+) create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/client/CountryClient.java create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/client/CountryClientConfig.java create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/client/gen/Country.java create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/client/gen/Currency.java create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/client/gen/GetCountryRequest.java create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/client/gen/GetCountryResponse.java create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/client/gen/ObjectFactory.java create mode 100644 spring-soap/src/main/java/com/baeldung/springsoap/client/gen/package-info.java create mode 100644 spring-soap/src/main/resources/countries.wsdl create mode 100644 spring-soap/src/test/java/com/baeldung/springsoap/client/CountryClientLiveTest.java diff --git a/spring-soap/pom.xml b/spring-soap/pom.xml index 9403b70636..d0987329c0 100644 --- a/spring-soap/pom.xml +++ b/spring-soap/pom.xml @@ -58,6 +58,28 @@ + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + 0.14.0 + + + + generate + + + + + WSDL + ${project.basedir}/src/main/java + com.baeldung.springsoap.client.gen + ${project.basedir}/src/main/resources + + countries.wsdl + + + diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/client/CountryClient.java b/spring-soap/src/main/java/com/baeldung/springsoap/client/CountryClient.java new file mode 100644 index 0000000000..e0b9172ece --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/client/CountryClient.java @@ -0,0 +1,26 @@ +package com.baeldung.springsoap.client; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.ws.client.core.support.WebServiceGatewaySupport; + +import com.baeldung.springsoap.client.gen.GetCountryRequest; +import com.baeldung.springsoap.client.gen.GetCountryResponse; + +public class CountryClient extends WebServiceGatewaySupport { + + private static final Logger logger = LoggerFactory.getLogger(CountryClient.class); + + public GetCountryResponse getCountry(String country) { + + GetCountryRequest request = new GetCountryRequest(); + request.setName(country); + + logger.info("Requesting information for " + country); + + GetCountryResponse response = (GetCountryResponse) getWebServiceTemplate().marshalSendAndReceive(request); + + return response; + } + +} \ No newline at end of file diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/client/CountryClientConfig.java b/spring-soap/src/main/java/com/baeldung/springsoap/client/CountryClientConfig.java new file mode 100644 index 0000000000..8dabdbc00d --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/client/CountryClientConfig.java @@ -0,0 +1,25 @@ +package com.baeldung.springsoap.client; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.oxm.jaxb.Jaxb2Marshaller; + +@Configuration +public class CountryClientConfig { + + @Bean + public Jaxb2Marshaller marshaller() { + Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); + marshaller.setContextPath("com.baeldung.springsoap.client.gen"); + return marshaller; + } + + @Bean + public CountryClient countryClient(Jaxb2Marshaller marshaller) { + CountryClient client = new CountryClient(); + client.setDefaultUri("http://localhost:8080/ws"); + client.setMarshaller(marshaller); + client.setUnmarshaller(marshaller); + return client; + } +} \ No newline at end of file diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/Country.java b/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/Country.java new file mode 100644 index 0000000000..e17dce55f9 --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/Country.java @@ -0,0 +1,146 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.3.0 +// See https://javaee.github.io/jaxb-v2/ +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2020.04.25 at 03:18:49 PM IST +// + + +package com.baeldung.springsoap.client.gen; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; + + +/** + *

    Java class for country complex type. + * + *

    The following schema fragment specifies the expected content contained within this class. + * + *

    + * <complexType name="country">
    + *   <complexContent>
    + *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
    + *       <sequence>
    + *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
    + *         <element name="population" type="{http://www.w3.org/2001/XMLSchema}int"/>
    + *         <element name="capital" type="{http://www.w3.org/2001/XMLSchema}string"/>
    + *         <element name="currency" type="{http://www.baeldung.com/springsoap/gen}currency"/>
    + *       </sequence>
    + *     </restriction>
    + *   </complexContent>
    + * </complexType>
    + * 
    + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "country", propOrder = { + "name", + "population", + "capital", + "currency" +}) +public class Country { + + @XmlElement(required = true) + protected String name; + protected int population; + @XmlElement(required = true) + protected String capital; + @XmlElement(required = true) + @XmlSchemaType(name = "string") + protected Currency currency; + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the value of the population property. + * + */ + public int getPopulation() { + return population; + } + + /** + * Sets the value of the population property. + * + */ + public void setPopulation(int value) { + this.population = value; + } + + /** + * Gets the value of the capital property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getCapital() { + return capital; + } + + /** + * Sets the value of the capital property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setCapital(String value) { + this.capital = value; + } + + /** + * Gets the value of the currency property. + * + * @return + * possible object is + * {@link Currency } + * + */ + public Currency getCurrency() { + return currency; + } + + /** + * Sets the value of the currency property. + * + * @param value + * allowed object is + * {@link Currency } + * + */ + public void setCurrency(Currency value) { + this.currency = value; + } + +} diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/Currency.java b/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/Currency.java new file mode 100644 index 0000000000..12fdef58c2 --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/Currency.java @@ -0,0 +1,47 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.3.0 +// See https://javaee.github.io/jaxb-v2/ +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2020.04.25 at 03:18:49 PM IST +// + + +package com.baeldung.springsoap.client.gen; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + + +/** + *

    Java class for currency. + * + *

    The following schema fragment specifies the expected content contained within this class. + *

    + *

    + * <simpleType name="currency">
    + *   <restriction base="{http://www.w3.org/2001/XMLSchema}string">
    + *     <enumeration value="GBP"/>
    + *     <enumeration value="EUR"/>
    + *     <enumeration value="PLN"/>
    + *   </restriction>
    + * </simpleType>
    + * 
    + * + */ +@XmlType(name = "currency") +@XmlEnum +public enum Currency { + + GBP, + EUR, + PLN; + + public String value() { + return name(); + } + + public static Currency fromValue(String v) { + return valueOf(v); + } + +} diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/GetCountryRequest.java b/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/GetCountryRequest.java new file mode 100644 index 0000000000..5739ee3b96 --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/GetCountryRequest.java @@ -0,0 +1,71 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.3.0 +// See https://javaee.github.io/jaxb-v2/ +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2020.04.25 at 03:18:49 PM IST +// + + +package com.baeldung.springsoap.client.gen; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

    Java class for anonymous complex type. + * + *

    The following schema fragment specifies the expected content contained within this class. + * + *

    + * <complexType>
    + *   <complexContent>
    + *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
    + *       <sequence>
    + *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
    + *       </sequence>
    + *     </restriction>
    + *   </complexContent>
    + * </complexType>
    + * 
    + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "name" +}) +@XmlRootElement(name = "getCountryRequest") +public class GetCountryRequest { + + @XmlElement(required = true) + protected String name; + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + +} diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/GetCountryResponse.java b/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/GetCountryResponse.java new file mode 100644 index 0000000000..ba1ab56cf8 --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/GetCountryResponse.java @@ -0,0 +1,71 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.3.0 +// See https://javaee.github.io/jaxb-v2/ +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2020.04.25 at 03:18:49 PM IST +// + + +package com.baeldung.springsoap.client.gen; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

    Java class for anonymous complex type. + * + *

    The following schema fragment specifies the expected content contained within this class. + * + *

    + * <complexType>
    + *   <complexContent>
    + *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
    + *       <sequence>
    + *         <element name="country" type="{http://www.baeldung.com/springsoap/gen}country"/>
    + *       </sequence>
    + *     </restriction>
    + *   </complexContent>
    + * </complexType>
    + * 
    + * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "country" +}) +@XmlRootElement(name = "getCountryResponse") +public class GetCountryResponse { + + @XmlElement(required = true) + protected Country country; + + /** + * Gets the value of the country property. + * + * @return + * possible object is + * {@link Country } + * + */ + public Country getCountry() { + return country; + } + + /** + * Sets the value of the country property. + * + * @param value + * allowed object is + * {@link Country } + * + */ + public void setCountry(Country value) { + this.country = value; + } + +} diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/ObjectFactory.java b/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/ObjectFactory.java new file mode 100644 index 0000000000..88b27245be --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/ObjectFactory.java @@ -0,0 +1,63 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.3.0 +// See https://javaee.github.io/jaxb-v2/ +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2020.04.25 at 03:18:49 PM IST +// + + +package com.baeldung.springsoap.client.gen; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.baeldung.springsoap.client.gen package. + *

    An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.baeldung.springsoap.client.gen + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link GetCountryRequest } + * + */ + public GetCountryRequest createGetCountryRequest() { + return new GetCountryRequest(); + } + + /** + * Create an instance of {@link GetCountryResponse } + * + */ + public GetCountryResponse createGetCountryResponse() { + return new GetCountryResponse(); + } + + /** + * Create an instance of {@link Country } + * + */ + public Country createCountry() { + return new Country(); + } + +} diff --git a/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/package-info.java b/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/package-info.java new file mode 100644 index 0000000000..eefed169a8 --- /dev/null +++ b/spring-soap/src/main/java/com/baeldung/springsoap/client/gen/package-info.java @@ -0,0 +1,9 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.3.0 +// See https://javaee.github.io/jaxb-v2/ +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2020.04.25 at 03:18:49 PM IST +// + +@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.baeldung.com/springsoap/gen", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) +package com.baeldung.springsoap.client.gen; diff --git a/spring-soap/src/main/resources/countries.wsdl b/spring-soap/src/main/resources/countries.wsdl new file mode 100644 index 0000000000..2a2eaf05bb --- /dev/null +++ b/spring-soap/src/main/resources/countries.wsdl @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-soap/src/test/java/com/baeldung/springsoap/client/CountryClientLiveTest.java b/spring-soap/src/test/java/com/baeldung/springsoap/client/CountryClientLiveTest.java new file mode 100644 index 0000000000..63dbe2a5cf --- /dev/null +++ b/spring-soap/src/test/java/com/baeldung/springsoap/client/CountryClientLiveTest.java @@ -0,0 +1,36 @@ +package com.baeldung.springsoap.client; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.support.AnnotationConfigContextLoader; + +import com.baeldung.springsoap.client.gen.Currency; +import com.baeldung.springsoap.client.gen.GetCountryResponse; + +//Ensure that the server - com.baeldung.springsoap.Application - is running before executing this test +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = CountryClientConfig.class, loader = AnnotationConfigContextLoader.class) +public class CountryClientLiveTest { + + @Autowired + CountryClient client; + + @Test + public void givenCountryService_whenCountryPoland_thenCapitalIsWarsaw() { + GetCountryResponse response = client.getCountry("Poland"); + assertEquals("Warsaw", response.getCountry() + .getCapital()); + } + + @Test + public void givenCountryService_whenCountrySpain_thenCurrencyEUR() { + GetCountryResponse response = client.getCountry("Spain"); + assertEquals(Currency.EUR, response.getCountry() + .getCurrency()); + } +} From bd9c4945f7c1e96a64c944414f23b055f8e49482 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Sat, 25 Apr 2020 11:37:01 -0600 Subject: [PATCH 336/503] BAEL-3972: Fix formatting --- .../com/baeldung/app/controller/TaskController.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java index 95f855c1e5..67072b5d61 100644 --- a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java @@ -48,8 +48,7 @@ public class TaskController { */ @GetMapping("/manager") @PreAuthorize("hasRole('ROLE_MANAGER')") - public ResponseEntity> getAlManagerTasks() - { + public ResponseEntity> getAlManagerTasks() { Iterable tasks = taskService.findAll(); return ResponseEntity.ok().body(tasks); @@ -59,8 +58,7 @@ public class TaskController { * Example of restricting specific endpoints to specific roles using SecurityContext. */ @GetMapping("/actuator") - public ResponseEntity> getAlActuatorTasks() - { + public ResponseEntity> getAlActuatorTasks() { Authentication auth = SecurityContextHolder.getContext().getAuthentication(); if (auth != null && auth.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ACTUATOR"))) { @@ -76,8 +74,7 @@ public class TaskController { * Example of restricting specific endpoints to specific roles using UserDetailsService. */ @GetMapping("/admin") - public ResponseEntity> getAlAdminTasks() - { + public ResponseEntity> getAlAdminTasks() { if(userDetailsService != null) { UserDetails details = userDetailsService.loadUserByUsername("pam"); if (details != null && details.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ADMIN"))) { @@ -94,8 +91,7 @@ public class TaskController { * Example of restricting specific endpoints to specific roles using HttpServletRequest. */ @GetMapping("/admin2") - public ResponseEntity> getAlAdminTasksUsingServlet(HttpServletRequest request) - { + public ResponseEntity> getAlAdminTasksUsingServlet(HttpServletRequest request) { if (!request.isUserInRole("ROLE_ADMIN")) { return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); } From b6996fbc05d4102b2da9f78796821fa78b5288e5 Mon Sep 17 00:00:00 2001 From: Ali Dehghani Date: Sat, 25 Apr 2020 22:55:00 +0430 Subject: [PATCH 337/503] Added Trailing slash to Fix the Relative Path Bug --- .../java/com/baeldung/favicon/config/FaviconConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/favicon/config/FaviconConfiguration.java b/spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/favicon/config/FaviconConfiguration.java index d1809199d6..f2a173caf3 100644 --- a/spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/favicon/config/FaviconConfiguration.java +++ b/spring-boot-modules/spring-boot-basic-customization/src/main/java/com/baeldung/favicon/config/FaviconConfiguration.java @@ -28,7 +28,7 @@ public class FaviconConfiguration { @Bean protected ResourceHttpRequestHandler faviconRequestHandler() { ResourceHttpRequestHandler requestHandler = new ResourceHttpRequestHandler(); - ClassPathResource classPathResource = new ClassPathResource("com/baeldung/images"); + ClassPathResource classPathResource = new ClassPathResource("com/baeldung/images/"); List locations = Arrays.asList(classPathResource); requestHandler.setLocations(locations); return requestHandler; From a5264182cd0faed8a9cae5368ea84d1372ad3be2 Mon Sep 17 00:00:00 2001 From: Sasa M Date: Sat, 25 Apr 2020 21:57:43 +0200 Subject: [PATCH 338/503] Refactoring code in com.baeldung.modelmapper package --- .../com/baeldung/modelmapper/MapperUtil.java | 16 ++-------------- .../main/java/com/baeldung/modelmapper/User.java | 14 +++++++------- .../java/com/baeldung/modelmapper/UserDTO.java | 10 +++++----- .../baeldung/modelmapper/UserPropertyMap.java | 7 ++++--- .../modelmapper/UsersListMappingUnitTest.java | 12 ++++++------ 5 files changed, 24 insertions(+), 35 deletions(-) diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java index 546e415755..60af44cc76 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java @@ -1,39 +1,27 @@ package com.baeldung.modelmapper; import org.modelmapper.ModelMapper; -import org.modelmapper.convention.MatchingStrategies; import java.util.ArrayList; import java.util.List; /** * This is a helper class that contains methods for generic mapping of the users list. - * Initially, an instance of ModelMapper was created. In the static block we set the matching configuration to STRICT. + * Initially, an instance of ModelMapper was created. * * @author Sasa Milenkovic */ public class MapperUtil { - private static ModelMapper modelMapper = new ModelMapper(); - static { - - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - - } - private MapperUtil() { } - public static T mapTo(final S source, final Class target) { - return modelMapper.map(source, target); - } - - public static List mapList(final List sourceList, final Class target) { + public static List mapList(List sourceList, Class target) { List targetList = new ArrayList(); for (S source : sourceList) { diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java index 23a424dedd..8ed674d86a 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/User.java @@ -8,7 +8,7 @@ package com.baeldung.modelmapper; public class User { private String userId; - private String userName; + private String username; private String email; private String contactNumber; private String userType; @@ -18,9 +18,9 @@ public class User { public User() { } - public User(String userId, String userName, String email, String contactNumber, String userType) { + public User(String userId, String username, String email, String contactNumber, String userType) { this.userId = userId; - this.userName = userName; + this.username = username; this.email = email; this.contactNumber = contactNumber; this.userType = userType; @@ -34,12 +34,12 @@ public class User { this.userId = userId; } - public String getUserName() { - return userName; + public String getUsername() { + return username; } - public void setUserName(String userName) { - this.userName = userName; + public void setUsername(String userName) { + this.username = userName; } public String getEmail() { diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java index e31414b629..b67bb58ef4 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserDTO.java @@ -8,7 +8,7 @@ package com.baeldung.modelmapper; public class UserDTO { private String userId; - private String userName; + private String username; private String email; // getters and setters @@ -21,12 +21,12 @@ public class UserDTO { this.userId = userId; } - public String getUserName() { - return userName; + public String getUsername() { + return username; } - public void setUserName(String userName) { - this.userName = userName; + public void setUsername(String username) { + this.username = username; } public String getEmail() { diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java index d2c32a307d..0d2ebf7b4c 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java @@ -18,14 +18,15 @@ public class UserPropertyMap extends PropertyMap { Converter, List> converter = new AbstractConverter, List>() { - List usernames = new ArrayList<>(); + protected List usernames; + @Override protected List convert(List users) { - users.forEach(user -> usernames.add(user.getUserName())); + usernames = new ArrayList(); + users.forEach(user -> usernames.add(user.getUsername())); return usernames; } - }; @Override diff --git a/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java index 05792fda38..aaeb8711a8 100644 --- a/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java +++ b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java @@ -25,14 +25,14 @@ import static org.junit.Assert.assertThat; */ public class UsersListMappingUnitTest { - private ModelMapper mapper; + private ModelMapper modelMapper; private List users; @Before public void init() { - mapper = new ModelMapper(); - mapper.addMappings(new UserPropertyMap()); + modelMapper = new ModelMapper(); + modelMapper.addMappings(new UserPropertyMap()); users = new ArrayList(); users.add(new User("b100", "user1", "user1@baeldung.com", "111-222", "USER")); users.add(new User("b101", "user2", "user2@baeldung.com", "111-333", "USER")); @@ -49,7 +49,7 @@ public class UsersListMappingUnitTest { integers.add(2); integers.add(3); - List characters = mapper.map(integers, new TypeToken>() { + List characters = modelMapper.map(integers, new TypeToken>() { }.getType()); assertThat(characters, hasItems('1', '2', '3')); @@ -66,14 +66,14 @@ public class UsersListMappingUnitTest { assertThat(userDtoList, Matchers.hasItem( Matchers.both(hasProperty("userId", equalTo("b100"))) .and(hasProperty("email", equalTo("user1@baeldung.com"))) - .and(hasProperty("userName", equalTo("user1"))))); + .and(hasProperty("username", equalTo("user1"))))); // Mapping lists using PropertyMap and Converter UserList userList = new UserList(); userList.setUsers(users); UserListDTO dto = new UserListDTO(); - mapper.map(userList, dto); + modelMapper.map(userList, dto); assertNotNull(dto); assertThat(dto, Matchers.hasProperty("usernames")); From fd5fcf29c55e234cb26262edf42b2c55ea55e7ef Mon Sep 17 00:00:00 2001 From: Justin Albano Date: Sat, 25 Apr 2020 16:05:50 -0400 Subject: [PATCH 339/503] BAEL-3965: Removed unneeded dependencies --- spring-core-4/pom.xml | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/spring-core-4/pom.xml b/spring-core-4/pom.xml index 06598fb41e..53f7ca6912 100644 --- a/spring-core-4/pom.xml +++ b/spring-core-4/pom.xml @@ -14,26 +14,6 @@ - - org.springframework - spring-beans - ${spring.version} - - - org.springframework - spring-tx - ${spring.version} - - - org.springframework - spring-jdbc - ${spring.version} - - - org.springframework.boot - spring-boot-starter-web - ${spring.boot.version} - org.springframework spring-context @@ -44,11 +24,6 @@ spring-core ${spring.version} - - javax.annotation - javax.annotation-api - ${annotation-api.version} - org.springframework spring-test From ee898632d354bfeb972ba3a01217910834517535 Mon Sep 17 00:00:00 2001 From: Aaron Juarez Date: Sat, 25 Apr 2020 16:23:13 -0400 Subject: [PATCH 340/503] BAEL-3966: find object's class in Java (#9118) --- .../com/baeldung/objectclass/Borrower.java | 23 ++++++ .../java/com/baeldung/objectclass/Lender.java | 20 +++++ .../java/com/baeldung/objectclass/User.java | 12 +++ .../objectclass/CreditAppUnitTest.java | 74 +++++++++++++++++++ 4 files changed, 129 insertions(+) create mode 100644 core-java-modules/core-java/src/main/java/com/baeldung/objectclass/Borrower.java create mode 100644 core-java-modules/core-java/src/main/java/com/baeldung/objectclass/Lender.java create mode 100644 core-java-modules/core-java/src/main/java/com/baeldung/objectclass/User.java create mode 100644 core-java-modules/core-java/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/objectclass/Borrower.java b/core-java-modules/core-java/src/main/java/com/baeldung/objectclass/Borrower.java new file mode 100644 index 0000000000..62062aa7fc --- /dev/null +++ b/core-java-modules/core-java/src/main/java/com/baeldung/objectclass/Borrower.java @@ -0,0 +1,23 @@ +package com.baeldung.objectclass; + +import lombok.Data; + +@Data +public class Borrower extends User { + + private double totalLoanAmount; + + public double requestLoan(double amount) { + totalLoanAmount = amount; + return totalLoanAmount; + } + + public double increaseLoan(double increaseBy) { + return totalLoanAmount + increaseBy; + } + + public double payLoan(double amount) { + return totalLoanAmount - amount; + } + +} diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/objectclass/Lender.java b/core-java-modules/core-java/src/main/java/com/baeldung/objectclass/Lender.java new file mode 100644 index 0000000000..b45272cbb1 --- /dev/null +++ b/core-java-modules/core-java/src/main/java/com/baeldung/objectclass/Lender.java @@ -0,0 +1,20 @@ +package com.baeldung.objectclass; + +public class Lender extends User { + + private double totalInvestmentAmount; + + public double invest(double amount) { + totalInvestmentAmount = amount; + return totalInvestmentAmount; + } + + public double increaseInvestment(double increaseBy) { + return totalInvestmentAmount + increaseBy; + } + + public double collectDividends() { + return totalInvestmentAmount * 0.07; + } + +} diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/objectclass/User.java b/core-java-modules/core-java/src/main/java/com/baeldung/objectclass/User.java new file mode 100644 index 0000000000..b1f3887f2f --- /dev/null +++ b/core-java-modules/core-java/src/main/java/com/baeldung/objectclass/User.java @@ -0,0 +1,12 @@ +package com.baeldung.objectclass; + +import lombok.Data; + +@Data +public class User { + + private String firstName; + private String lastName; + + +} diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java new file mode 100644 index 0000000000..8330ddbac5 --- /dev/null +++ b/core-java-modules/core-java/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java @@ -0,0 +1,74 @@ +package com.baeldung.objectclass; + +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.Test; + +public class CreditAppUnitTest { + + @Test + public void givenLender_whenInstanceOf_thenReturnTrue() { + User lender = new Lender(); + assertTrue(lender instanceof Lender); + assertTrue(lender instanceof User); + } + + @Test + public void givenUser_whenInstanceOfLender_thenDowncast() { + User user = new Lender(); + Lender lender = null; + + if(user instanceof Lender) { + lender = (Lender) user; + } + + assertNotNull(lender); + } + + @Test + public void givenUser_whenIsInstanceOfLender_thenDowncast() { + User user = new Lender(); + Lender lender = null; + + if(Lender.class.isInstance(user)) { + lender = (Lender) user; + } + + assertNotNull(lender); + } + + @Test + public void givenBorrower_whenLoanAmountIsDouble_thenRequestLoan() { + Borrower borrower = new Borrower(); + double amount = 100.0; + + //if(amount instanceof Double) // Compilation error, no autoboxing + if(Double.class.isInstance(amount)) { + borrower.requestLoan(amount); + } + assertEquals(100, borrower.getTotalLoanAmount()); + } + + @Test + public void givenBorrower_whenLoanAmountIsNotString_thenRequestLoan() { + Borrower borrower = new Borrower(); + Double amount = 100.0; + + //if(amount instanceof String) // Compilation error, incompatible operands + if(!String.class.isInstance(amount)) { + borrower.requestLoan(amount); + } + assertEquals(100, borrower.getTotalLoanAmount()); + } + + @Test + public void givenLender_whenGetClass_thenEqualsLenderType() { + User lender = new Lender(); + assertEquals(Lender.class, lender.getClass()); + assertNotEquals(User.class, lender.getClass()); + } + +} From 0223584fee0d7d6661696a194e63032d6a37acd8 Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sun, 26 Apr 2020 06:41:14 +0530 Subject: [PATCH 341/503] removed duplicate module --- maven-java-11/README.md | 6 -- .../daomodule/pom.xml | 17 ----- .../src/main/java/com/baeldung/dao/Dao.java | 12 ---- .../daomodule/src/main/java/module-info.java | 3 - .../entitiymodule/pom.xml | 22 ------- .../main/java/com/baeldung/entity/User.java | 19 ------ .../src/main/java/module-info.java | 3 - .../mainppmodule/pom.xml | 38 ----------- .../com/baeldung/mainapp/Application.java | 19 ------ .../src/main/java/module-info.java | 6 -- .../multimodule-maven-project/pom.xml | 66 ------------------- .../userdaomodule/pom.xml | 42 ------------ .../java/com/baeldung/userdao/UserDao.java | 32 --------- .../src/main/java/module-info.java | 6 -- .../userdao/test/UserDaoUnitTest.java | 36 ---------- maven-java-11/pom.xml | 27 -------- 16 files changed, 354 deletions(-) delete mode 100644 maven-java-11/README.md delete mode 100644 maven-java-11/multimodule-maven-project/daomodule/pom.xml delete mode 100644 maven-java-11/multimodule-maven-project/daomodule/src/main/java/com/baeldung/dao/Dao.java delete mode 100644 maven-java-11/multimodule-maven-project/daomodule/src/main/java/module-info.java delete mode 100644 maven-java-11/multimodule-maven-project/entitiymodule/pom.xml delete mode 100644 maven-java-11/multimodule-maven-project/entitiymodule/src/main/java/com/baeldung/entity/User.java delete mode 100644 maven-java-11/multimodule-maven-project/entitiymodule/src/main/java/module-info.java delete mode 100644 maven-java-11/multimodule-maven-project/mainppmodule/pom.xml delete mode 100644 maven-java-11/multimodule-maven-project/mainppmodule/src/main/java/com/baeldung/mainapp/Application.java delete mode 100644 maven-java-11/multimodule-maven-project/mainppmodule/src/main/java/module-info.java delete mode 100644 maven-java-11/multimodule-maven-project/pom.xml delete mode 100644 maven-java-11/multimodule-maven-project/userdaomodule/pom.xml delete mode 100644 maven-java-11/multimodule-maven-project/userdaomodule/src/main/java/com/baeldung/userdao/UserDao.java delete mode 100644 maven-java-11/multimodule-maven-project/userdaomodule/src/main/java/module-info.java delete mode 100644 maven-java-11/multimodule-maven-project/userdaomodule/src/test/java/com/baeldung/userdao/test/UserDaoUnitTest.java delete mode 100644 maven-java-11/pom.xml diff --git a/maven-java-11/README.md b/maven-java-11/README.md deleted file mode 100644 index b923518825..0000000000 --- a/maven-java-11/README.md +++ /dev/null @@ -1,6 +0,0 @@ -## Maven and Java 11 - -This module contains articles about Maven with Java 11+. - -### Relevant Articles: - diff --git a/maven-java-11/multimodule-maven-project/daomodule/pom.xml b/maven-java-11/multimodule-maven-project/daomodule/pom.xml deleted file mode 100644 index cbe0b4cb95..0000000000 --- a/maven-java-11/multimodule-maven-project/daomodule/pom.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - 4.0.0 - com.baeldung.daomodule - daomodule - 1.0 - daomodule - jar - - - com.baeldung.multimodule-maven-project - multimodule-maven-project - 1.0 - - - diff --git a/maven-java-11/multimodule-maven-project/daomodule/src/main/java/com/baeldung/dao/Dao.java b/maven-java-11/multimodule-maven-project/daomodule/src/main/java/com/baeldung/dao/Dao.java deleted file mode 100644 index f86ae8abb3..0000000000 --- a/maven-java-11/multimodule-maven-project/daomodule/src/main/java/com/baeldung/dao/Dao.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.baeldung.dao; - -import java.util.List; -import java.util.Optional; - -public interface Dao { - - Optional findById(int id); - - List findAll(); - -} diff --git a/maven-java-11/multimodule-maven-project/daomodule/src/main/java/module-info.java b/maven-java-11/multimodule-maven-project/daomodule/src/main/java/module-info.java deleted file mode 100644 index 072d7ad007..0000000000 --- a/maven-java-11/multimodule-maven-project/daomodule/src/main/java/module-info.java +++ /dev/null @@ -1,3 +0,0 @@ -module com.baeldung.dao { - exports com.baeldung.dao; -} diff --git a/maven-java-11/multimodule-maven-project/entitiymodule/pom.xml b/maven-java-11/multimodule-maven-project/entitiymodule/pom.xml deleted file mode 100644 index 228619ed74..0000000000 --- a/maven-java-11/multimodule-maven-project/entitiymodule/pom.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - 4.0.0 - com.baeldung.entitymodule - entitymodule - 1.0 - entitymodule - jar - - - com.baeldung.multimodule-maven-project - multimodule-maven-project - 1.0 - - - - 11 - 11 - - - diff --git a/maven-java-11/multimodule-maven-project/entitiymodule/src/main/java/com/baeldung/entity/User.java b/maven-java-11/multimodule-maven-project/entitiymodule/src/main/java/com/baeldung/entity/User.java deleted file mode 100644 index 22022a2e6d..0000000000 --- a/maven-java-11/multimodule-maven-project/entitiymodule/src/main/java/com/baeldung/entity/User.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.entity; - -public class User { - - private final String name; - - public User(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - @Override - public String toString() { - return "User{" + "name=" + name + '}'; - } -} diff --git a/maven-java-11/multimodule-maven-project/entitiymodule/src/main/java/module-info.java b/maven-java-11/multimodule-maven-project/entitiymodule/src/main/java/module-info.java deleted file mode 100644 index 67a3097352..0000000000 --- a/maven-java-11/multimodule-maven-project/entitiymodule/src/main/java/module-info.java +++ /dev/null @@ -1,3 +0,0 @@ -module com.baeldung.entity { - exports com.baeldung.entity; -} diff --git a/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml b/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml deleted file mode 100644 index a4a6575906..0000000000 --- a/maven-java-11/multimodule-maven-project/mainppmodule/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - 4.0.0 - com.baeldung.mainappmodule - mainappmodule - 1.0 - mainappmodule - jar - - - com.baeldung.multimodule-maven-project - multimodule-maven-project - 1.0 - 1.0 - 1.0 - 1.0 - - - - - com.baeldung.entitymodule - entitymodule - ${entitymodule.version} - - - com.baeldung.daomodule - daomodule - ${daomodule.version} - - - com.baeldung.userdaomodule - userdaomodule - ${userdaomodule.version} - - - - diff --git a/maven-java-11/multimodule-maven-project/mainppmodule/src/main/java/com/baeldung/mainapp/Application.java b/maven-java-11/multimodule-maven-project/mainppmodule/src/main/java/com/baeldung/mainapp/Application.java deleted file mode 100644 index 0c0df7461b..0000000000 --- a/maven-java-11/multimodule-maven-project/mainppmodule/src/main/java/com/baeldung/mainapp/Application.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.baeldung.mainapp; - -import com.baeldung.dao.Dao; -import com.baeldung.entity.User; -import com.baeldung.userdao.UserDao; -import java.util.HashMap; -import java.util.Map; - -public class Application { - - public static void main(String[] args) { - Map users = new HashMap<>(); - users.put(1, new User("Julie")); - users.put(2, new User("David")); - Dao userDao = new UserDao(users); - userDao.findAll().forEach(System.out::println); - } - -} diff --git a/maven-java-11/multimodule-maven-project/mainppmodule/src/main/java/module-info.java b/maven-java-11/multimodule-maven-project/mainppmodule/src/main/java/module-info.java deleted file mode 100644 index c688fcf7de..0000000000 --- a/maven-java-11/multimodule-maven-project/mainppmodule/src/main/java/module-info.java +++ /dev/null @@ -1,6 +0,0 @@ -module com.baeldung.mainapp { - requires com.baeldung.entity; - requires com.baeldung.userdao; - requires com.baeldung.dao; - uses com.baeldung.dao.Dao; -} diff --git a/maven-java-11/multimodule-maven-project/pom.xml b/maven-java-11/multimodule-maven-project/pom.xml deleted file mode 100644 index 65f5b7a814..0000000000 --- a/maven-java-11/multimodule-maven-project/pom.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - 4.0.0 - com.baeldung.multimodule-maven-project - multimodule-maven-project - 1.0 - multimodule-maven-project - pom - - - com.baeldung.maven-java-11 - maven-java-11 - 1.0 - - - - entitymodule - daomodule - userdaomodule - mainappmodule - - - - - - junit - junit - ${junit.version} - test - - - org.assertj - assertj-core - ${assertj.version} - test - - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${compiler.plugin.version} - - ${source.version} - ${target.version} - - - - - - - - UTF-8 - 4.12 - 3.12.2 - 3.8.0 - 11 - 11 - - - diff --git a/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml b/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml deleted file mode 100644 index cf6ea85cb5..0000000000 --- a/maven-java-11/multimodule-maven-project/userdaomodule/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - 4.0.0 - com.baeldung.userdaomodule - userdaomodule - 1.0 - userdaomodule - jar - - - com.baeldung.multimodule-maven-project - multimodule-maven-project - 1.0 - - - - - com.baeldung.entitymodule - entitymodule - ${entitymodule.version}1.0 - - - com.baeldung.daomodule - daomodule - ${daomodule.version} - - - junit - junit - test - - - - - 1.0 - 1.0 - - - diff --git a/maven-java-11/multimodule-maven-project/userdaomodule/src/main/java/com/baeldung/userdao/UserDao.java b/maven-java-11/multimodule-maven-project/userdaomodule/src/main/java/com/baeldung/userdao/UserDao.java deleted file mode 100644 index 1f1ea38a60..0000000000 --- a/maven-java-11/multimodule-maven-project/userdaomodule/src/main/java/com/baeldung/userdao/UserDao.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.userdao; - -import com.baeldung.dao.Dao; -import com.baeldung.entity.User; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; - -public class UserDao implements Dao { - - private final Map users; - - public UserDao() { - users = new HashMap<>(); - } - - public UserDao(Map users) { - this.users = users; - } - - @Override - public List findAll() { - return new ArrayList<>(users.values()); - } - - @Override - public Optional findById(int id) { - return Optional.ofNullable(users.get(id)); - } -} \ No newline at end of file diff --git a/maven-java-11/multimodule-maven-project/userdaomodule/src/main/java/module-info.java b/maven-java-11/multimodule-maven-project/userdaomodule/src/main/java/module-info.java deleted file mode 100644 index f1cb217e23..0000000000 --- a/maven-java-11/multimodule-maven-project/userdaomodule/src/main/java/module-info.java +++ /dev/null @@ -1,6 +0,0 @@ -module com.baeldung.userdao { - requires com.baeldung.entity; - requires com.baeldung.dao; - provides com.baeldung.dao.Dao with com.baeldung.userdao.UserDao; - exports com.baeldung.userdao; -} diff --git a/maven-java-11/multimodule-maven-project/userdaomodule/src/test/java/com/baeldung/userdao/test/UserDaoUnitTest.java b/maven-java-11/multimodule-maven-project/userdaomodule/src/test/java/com/baeldung/userdao/test/UserDaoUnitTest.java deleted file mode 100644 index 191d17ff32..0000000000 --- a/maven-java-11/multimodule-maven-project/userdaomodule/src/test/java/com/baeldung/userdao/test/UserDaoUnitTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.userdao.test; - -import com.baeldung.dao.Dao; -import com.baeldung.entity.User; -import com.baeldung.userdao.UserDao; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import static org.junit.Assert.*; -import static org.hamcrest.CoreMatchers.*; -import org.junit.Before; -import org.junit.Test; - -public class UserDaoUnitTest { - - private Dao userDao; - - @Before - public void setUpUserDaoInstance() { - Map users = new HashMap<>(); - users.put(1, new User("Julie")); - users.put(2, new User("David")); - userDao = new UserDao(users); - } - - @Test - public void givenUserDaoIntance_whenCalledFindById_thenCorrect() { - assertThat(userDao.findById(1), isA(Optional.class)); - } - - @Test - public void givenUserDaoIntance_whenCalledFindAll_thenCorrect() { - assertThat(userDao.findAll(), isA(List.class)); - } -} diff --git a/maven-java-11/pom.xml b/maven-java-11/pom.xml deleted file mode 100644 index 10e80365c8..0000000000 --- a/maven-java-11/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - 4.0.0 - com.baeldung.maven-java-11 - maven-java-11 - 1.0 - maven-java-11 - pom - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - - - - multimodule-maven-project - - - - UTF-8 - 11 - 11 - - - From b8d41e5613457b185324cc39630816d83ac1cf4f Mon Sep 17 00:00:00 2001 From: Vikas Rajput Date: Sun, 26 Apr 2020 11:51:21 +0530 Subject: [PATCH 342/503] Bael 3557 : renamed package name to more unique name - springwithgroovy (#9172) * BAEL-3557: Completed a simple web application in spring boot and groovy * BAEL-3557: renamed packagename from com.baeldung.app to more unique name - com.baeldung.springwithgroovy Co-authored-by: Vikas Ramsingh Rajput --- .../SpringBootGroovyApplication.groovy | 13 +++ .../controller/TodoController.groovy | 48 +++++++++ .../springwithgroovy/entity/Todo.groovy | 23 +++++ .../repository/TodoRepository.groovy | 9 ++ .../service/TodoService.groovy | 16 +++ .../service/impl/TodoServiceImpl.groovy | 40 ++++++++ .../springwithgroovy/TodoAppUnitTest.groovy | 97 +++++++++++++++++++ 7 files changed, 246 insertions(+) create mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/SpringBootGroovyApplication.groovy create mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/controller/TodoController.groovy create mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/entity/Todo.groovy create mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/repository/TodoRepository.groovy create mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/TodoService.groovy create mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/impl/TodoServiceImpl.groovy create mode 100644 spring-boot-groovy/src/test/groovy/com/baeldung/springwithgroovy/TodoAppUnitTest.groovy diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/SpringBootGroovyApplication.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/SpringBootGroovyApplication.groovy new file mode 100644 index 0000000000..4912b75a66 --- /dev/null +++ b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/SpringBootGroovyApplication.groovy @@ -0,0 +1,13 @@ +package com.baeldung.springwithgroovy + +import org.springframework.boot.SpringApplication +import org.springframework.boot.autoconfigure.SpringBootApplication + +import com.baeldung.springwithgroovy.SpringBootGroovyApplication + +@SpringBootApplication +class SpringBootGroovyApplication { + static void main(String[] args) { + SpringApplication.run SpringBootGroovyApplication, args + } +} diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/controller/TodoController.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/controller/TodoController.groovy new file mode 100644 index 0000000000..9c6aee20d3 --- /dev/null +++ b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/controller/TodoController.groovy @@ -0,0 +1,48 @@ +package com.baeldung.springwithgroovy.controller + +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.web.bind.annotation.DeleteMapping +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.PutMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestMethod +import org.springframework.web.bind.annotation.RestController + +import com.baeldung.springwithgroovy.entity.Todo +import com.baeldung.springwithgroovy.service.TodoService + +@RestController +@RequestMapping('todo') +public class TodoController { + + @Autowired + TodoService todoService + + @GetMapping + List getAllTodoList(){ + todoService.findAll() + } + + @PostMapping + Todo saveTodo(@RequestBody Todo todo){ + todoService.saveTodo todo + } + + @PutMapping + Todo updateTodo(@RequestBody Todo todo){ + todoService.updateTodo todo + } + + @DeleteMapping('/{todoId}') + deleteTodo(@PathVariable Integer todoId){ + todoService.deleteTodo todoId + } + + @GetMapping('/{todoId}') + Todo getTodoById(@PathVariable Integer todoId){ + todoService.findById todoId + } +} \ No newline at end of file diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/entity/Todo.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/entity/Todo.groovy new file mode 100644 index 0000000000..000d981701 --- /dev/null +++ b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/entity/Todo.groovy @@ -0,0 +1,23 @@ +package com.baeldung.springwithgroovy.entity + +import javax.persistence.Column +import javax.persistence.Entity +import javax.persistence.GeneratedValue +import javax.persistence.GenerationType +import javax.persistence.Id +import javax.persistence.Table + +@Entity +@Table(name = 'todo') +class Todo { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + Integer id + + @Column + String task + + @Column + Boolean isCompleted + +} diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/repository/TodoRepository.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/repository/TodoRepository.groovy new file mode 100644 index 0000000000..eb58cc0791 --- /dev/null +++ b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/repository/TodoRepository.groovy @@ -0,0 +1,9 @@ +package com.baeldung.springwithgroovy.repository + +import org.springframework.data.jpa.repository.JpaRepository +import org.springframework.stereotype.Repository + +import com.baeldung.springwithgroovy.entity.Todo + +@Repository +interface TodoRepository extends JpaRepository {} \ No newline at end of file diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/TodoService.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/TodoService.groovy new file mode 100644 index 0000000000..c57af34cde --- /dev/null +++ b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/TodoService.groovy @@ -0,0 +1,16 @@ +package com.baeldung.springwithgroovy.service + +import com.baeldung.springwithgroovy.entity.Todo + +interface TodoService { + + List findAll() + + Todo findById(Integer todoId) + + Todo saveTodo(Todo todo) + + Todo updateTodo(Todo todo) + + Todo deleteTodo(Integer todoId) +} diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/impl/TodoServiceImpl.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/impl/TodoServiceImpl.groovy new file mode 100644 index 0000000000..943c1c6944 --- /dev/null +++ b/spring-boot-groovy/src/main/groovy/com/baeldung/springwithgroovy/service/impl/TodoServiceImpl.groovy @@ -0,0 +1,40 @@ +package com.baeldung.springwithgroovy.service.impl + +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.stereotype.Service + +import com.baeldung.springwithgroovy.entity.Todo +import com.baeldung.springwithgroovy.repository.TodoRepository +import com.baeldung.springwithgroovy.service.TodoService + +@Service +class TodoServiceImpl implements TodoService { + + @Autowired + TodoRepository todoRepository + + @Override + List findAll() { + todoRepository.findAll() + } + + @Override + Todo findById(Integer todoId) { + todoRepository.findById todoId get() + } + + @Override + Todo saveTodo(Todo todo){ + todoRepository.save todo + } + + @Override + Todo updateTodo(Todo todo){ + todoRepository.save todo + } + + @Override + Todo deleteTodo(Integer todoId){ + todoRepository.deleteById todoId + } +} diff --git a/spring-boot-groovy/src/test/groovy/com/baeldung/springwithgroovy/TodoAppUnitTest.groovy b/spring-boot-groovy/src/test/groovy/com/baeldung/springwithgroovy/TodoAppUnitTest.groovy new file mode 100644 index 0000000000..bf8b0ff27f --- /dev/null +++ b/spring-boot-groovy/src/test/groovy/com/baeldung/springwithgroovy/TodoAppUnitTest.groovy @@ -0,0 +1,97 @@ +package com.baeldung.springwithgroovy + +import static org.junit.jupiter.api.Assertions.assertEquals +import static org.junit.jupiter.api.Assertions.assertTrue + +import org.junit.BeforeClass +import org.junit.Test +import org.junit.runner.RunWith +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.http.HttpStatus +import org.springframework.http.MediaType +import org.springframework.test.context.event.annotation.BeforeTestClass +import org.springframework.test.context.junit4.SpringRunner + +import com.baeldung.springwithgroovy.entity.Todo + +import io.restassured.RestAssured +import io.restassured.response.Response + +class TodoAppUnitTest { + static API_ROOT = 'http://localhost:8081/todo' + static readingTodoId + static writingTodoId + + @BeforeClass + static void populateDummyData() { + Todo readingTodo = new Todo(task: 'Reading', isCompleted: false) + Todo writingTodo = new Todo(task: 'Writing', isCompleted: false) + + final Response readingResponse = + RestAssured.given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(readingTodo).post(API_ROOT) + + Todo cookingTodoResponse = readingResponse.as Todo.class + readingTodoId = cookingTodoResponse.getId() + + final Response writingResponse = + RestAssured.given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(writingTodo).post(API_ROOT) + + Todo writingTodoResponse = writingResponse.as Todo.class + writingTodoId = writingTodoResponse.getId() + } + + @Test + void whenGetAllTodoList_thenOk(){ + final Response response = RestAssured.get(API_ROOT) + + assertEquals HttpStatus.OK.value(),response.getStatusCode() + assertTrue response.as(List.class).size() > 0 + } + + @Test + void whenGetTodoById_thenOk(){ + final Response response = + RestAssured.get("$API_ROOT/$readingTodoId") + + assertEquals HttpStatus.OK.value(),response.getStatusCode() + Todo todoResponse = response.as Todo.class + assertEquals readingTodoId,todoResponse.getId() + } + + @Test + void whenUpdateTodoById_thenOk(){ + Todo todo = new Todo(id:readingTodoId, isCompleted: true) + final Response response = + RestAssured.given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(todo).put(API_ROOT) + + assertEquals HttpStatus.OK.value(),response.getStatusCode() + Todo todoResponse = response.as Todo.class + assertTrue todoResponse.getIsCompleted() + } + + @Test + void whenDeleteTodoById_thenOk(){ + final Response response = + RestAssured.given() + .delete("$API_ROOT/$writingTodoId") + + assertEquals HttpStatus.OK.value(),response.getStatusCode() + } + + @Test + void whenSaveTodo_thenOk(){ + Todo todo = new Todo(task: 'Blogging', isCompleted: false) + final Response response = + RestAssured.given() + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(todo).post(API_ROOT) + + assertEquals HttpStatus.OK.value(),response.getStatusCode() + } +} \ No newline at end of file From d2f60283b8eb3d8633f2bcb5eda3fc69fbff330c Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Sun, 26 Apr 2020 15:46:04 +0200 Subject: [PATCH 343/503] JAVA-73: Remove unused test methods --- .../MongoTransactionalLiveTest.java | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java index bafcd770ec..6cd9657006 100644 --- a/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java +++ b/persistence-modules/spring-data-mongodb/src/test/java/com/baeldung/transaction/MongoTransactionalLiveTest.java @@ -62,24 +62,6 @@ public class MongoTransactionalLiveTest { } } - @Test(expected = MongoCommandException.class) - @Transactional - public void whenCountDuringMongoTransaction_thenException() { - userRepository.save(new User("John", 30)); - userRepository.save(new User("Ringo", 35)); - userRepository.count(); - } - - @Test - @Transactional - public void whenQueryDuringMongoTransaction_thenSuccess() { - userRepository.save(new User("Jane", 20)); - userRepository.save(new User("Nick", 33)); - List users = mongoTemplate.find(new Query(), User.class); - - assertTrue(users.size() > 1); - } - // ==== Using test instead of before and after due to @transactional doesn't allow list collection @Test From df179d642e3fef9da586f8fe2582fa6719d2fe53 Mon Sep 17 00:00:00 2001 From: Sampada <46674082+sampada07@users.noreply.github.com> Date: Sun, 26 Apr 2020 21:25:43 +0530 Subject: [PATCH 344/503] BAEL-3988: Calling a SOAP web service in Java (#9184) * BAEL-3988: Calling a SOAP web service in Java * BAEL-3988: modified generated class as per wsdl location change --- jee-7/pom.xml | 7 ++-- .../generated/CountryServiceImplService.java | 6 +-- jee-7/src/main/resources/country.wsdl | 40 ------------------- 3 files changed, 6 insertions(+), 47 deletions(-) delete mode 100644 jee-7/src/main/resources/country.wsdl diff --git a/jee-7/pom.xml b/jee-7/pom.xml index 7352c6550a..9077aae1a6 100644 --- a/jee-7/pom.xml +++ b/jee-7/pom.xml @@ -256,10 +256,9 @@ - src/main/resources - - country.wsdl - + + http://localhost:8888/ws/country?wsdl + true com.baeldung.soap.ws.client.generated src/main/java diff --git a/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java b/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java index 09f4c29202..a6983938f5 100644 --- a/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java +++ b/jee-7/src/main/java/com/baeldung/soap/ws/client/generated/CountryServiceImplService.java @@ -12,11 +12,11 @@ import javax.xml.ws.WebServiceFeature; /** * This class was generated by the JAX-WS RI. - * JAX-WS RI 2.3.2 + * JAX-WS RI 2.2.9-b130926.1035 * Generated source version: 2.2 * */ -@WebServiceClient(name = "CountryServiceImplService", targetNamespace = "http://server.ws.soap.baeldung.com/", wsdlLocation = "file:src/main/resources/country.wsdl") +@WebServiceClient(name = "CountryServiceImplService", targetNamespace = "http://server.ws.soap.baeldung.com/", wsdlLocation = "http://localhost:8888/ws/country?wsdl") public class CountryServiceImplService extends Service { private final static URL COUNTRYSERVICEIMPLSERVICE_WSDL_LOCATION; @@ -27,7 +27,7 @@ public class CountryServiceImplService extends Service { URL url = null; WebServiceException e = null; try { - url = new URL("file:src/main/resources/country.wsdl"); + url = new URL("http://localhost:8888/ws/country?wsdl"); } catch (MalformedURLException ex) { e = new WebServiceException(ex); } diff --git a/jee-7/src/main/resources/country.wsdl b/jee-7/src/main/resources/country.wsdl deleted file mode 100644 index 4d41fce322..0000000000 --- a/jee-7/src/main/resources/country.wsdl +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 8d7d98a144b2af7038efa1a266a284df92b9b7d9 Mon Sep 17 00:00:00 2001 From: Sasa M Date: Sun, 26 Apr 2020 18:37:31 +0200 Subject: [PATCH 345/503] Customizing Java 8 code in modemmapper package --- .../com/baeldung/modelmapper/MapperUtil.java | 16 +++++++--------- .../baeldung/modelmapper/UserPropertyMap.java | 13 +++++++------ .../modelmapper/UsersListMappingUnitTest.java | 12 ++++++------ 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java index 60af44cc76..9c6a5a0320 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java @@ -2,11 +2,11 @@ package com.baeldung.modelmapper; import org.modelmapper.ModelMapper; -import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** - * This is a helper class that contains methods for generic mapping of the users list. + * This is a helper class that contains method for generic mapping of the users list. * Initially, an instance of ModelMapper was created. * * @author Sasa Milenkovic @@ -21,14 +21,12 @@ public class MapperUtil { } - public static List mapList(List sourceList, Class target) { - List targetList = new ArrayList(); + public static List mapList(List source, Class targetClass) { - for (S source : sourceList) { - targetList.add(modelMapper.map(source, target)); - } - - return targetList; + return source + .stream() + .map(element -> modelMapper.map(element, targetClass)) + .collect(Collectors.toList()); } } diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java index 0d2ebf7b4c..5b2942b158 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java @@ -4,11 +4,11 @@ import org.modelmapper.AbstractConverter; import org.modelmapper.Converter; import org.modelmapper.PropertyMap; -import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** - * UserPropertyMap class instantiates the converter to map the data from the user list to the user name list. + * UserPropertyMap class instantiates the converter to map the data from the UserList to the UsersLisDTO. * In the configuration method, we call a converter to do the mapping. * * @author Sasa Milenkovic @@ -18,19 +18,20 @@ public class UserPropertyMap extends PropertyMap { Converter, List> converter = new AbstractConverter, List>() { - protected List usernames; @Override protected List convert(List users) { - usernames = new ArrayList(); - users.forEach(user -> usernames.add(user.getUsername())); - return usernames; + return users + .stream() + .map(User::getUsername) + .collect(Collectors.toList()); } }; @Override protected void configure() { + using(converter).map(source.getUsers(), destination.getUsernames()); } } diff --git a/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java index aaeb8711a8..982622e1f5 100644 --- a/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java +++ b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java @@ -59,7 +59,7 @@ public class UsersListMappingUnitTest { @Test public void givenUsersList_whenUseGenericType_thenMapToDto() { - // Mapping lists using generic type methods + // Mapping lists using custom type methods List userDtoList = MapperUtil.mapList(users, UserDTO.class); @@ -72,12 +72,12 @@ public class UsersListMappingUnitTest { UserList userList = new UserList(); userList.setUsers(users); - UserListDTO dto = new UserListDTO(); - modelMapper.map(userList, dto); + UserListDTO dtos = new UserListDTO(); + modelMapper.map(userList, dtos); - assertNotNull(dto); - assertThat(dto, Matchers.hasProperty("usernames")); - assertThat(dto.getUsernames(), hasSize(3)); + assertNotNull(dtos); + assertThat(dtos, Matchers.hasProperty("usernames")); + assertThat(dtos.getUsernames(), hasSize(3)); } From c7acf47138c929c59a35e545a3fe66d3225365eb Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sun, 26 Apr 2020 22:24:14 +0530 Subject: [PATCH 346/503] fix junit test cases --- .../batch/understanding/CustomCheckPointUnitTest.java | 9 +++------ .../batch/understanding/JobSequenceUnitTest.java | 6 +++--- .../batch/understanding/SimpleBatchLetUnitTest.java | 9 ++++----- .../batch/understanding/SimpleChunkUnitTest.java | 5 ++--- .../batch/understanding/SimpleErrorChunkUnitTest.java | 11 +++++------ jee-7/src/test/resources/jberet.properties | 1 + 6 files changed, 18 insertions(+), 23 deletions(-) create mode 100644 jee-7/src/test/resources/jberet.properties diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/CustomCheckPointUnitTest.java b/jee-7/src/test/java/com/baeldung/batch/understanding/CustomCheckPointUnitTest.java index 744bdfc8f5..c607efeb24 100644 --- a/jee-7/src/test/java/com/baeldung/batch/understanding/CustomCheckPointUnitTest.java +++ b/jee-7/src/test/java/com/baeldung/batch/understanding/CustomCheckPointUnitTest.java @@ -1,20 +1,17 @@ package com.baeldung.batch.understanding; -import static org.junit.jupiter.api.Assertions.*; -import java.util.Map; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.Properties; + import javax.batch.operations.JobOperator; import javax.batch.runtime.BatchRuntime; import javax.batch.runtime.BatchStatus; import javax.batch.runtime.JobExecution; -import javax.batch.runtime.Metric; import javax.batch.runtime.StepExecution; -import com.baeldung.batch.understanding.BatchTestHelper; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Disabled; -@Disabled("Should be fixed in BAEL-3812") class CustomCheckPointUnitTest { @Test public void givenChunk_whenCustomCheckPoint_thenCommitCountIsThree() throws Exception { diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/JobSequenceUnitTest.java b/jee-7/src/test/java/com/baeldung/batch/understanding/JobSequenceUnitTest.java index 88b981df92..4b27e5f5ec 100644 --- a/jee-7/src/test/java/com/baeldung/batch/understanding/JobSequenceUnitTest.java +++ b/jee-7/src/test/java/com/baeldung/batch/understanding/JobSequenceUnitTest.java @@ -1,6 +1,8 @@ package com.baeldung.batch.understanding; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.ArrayList; import java.util.List; @@ -13,9 +15,7 @@ import javax.batch.runtime.JobExecution; import javax.batch.runtime.StepExecution; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Disabled; -@Disabled("Should be fixed in BAEL-3812") class JobSequenceUnitTest { @Test public void givenTwoSteps_thenBatch_CompleteWithSuccess() throws Exception { diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetUnitTest.java b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetUnitTest.java index 3babf9b5aa..788b75eb3e 100644 --- a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetUnitTest.java +++ b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleBatchLetUnitTest.java @@ -1,17 +1,16 @@ package com.baeldung.batch.understanding; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Properties; import javax.batch.operations.JobOperator; import javax.batch.runtime.BatchRuntime; import javax.batch.runtime.BatchStatus; import javax.batch.runtime.JobExecution; -import java.util.Properties; -import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; -@Disabled("Should be fixed in BAEL-3812") class SimpleBatchLetUnitTest { @Test public void givenBatchLet_thenBatch_CompleteWithSuccess() throws Exception { diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleChunkUnitTest.java b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleChunkUnitTest.java index 5871143fa3..9010c365a2 100644 --- a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleChunkUnitTest.java +++ b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleChunkUnitTest.java @@ -1,6 +1,7 @@ package com.baeldung.batch.understanding; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.List; import java.util.Map; @@ -14,9 +15,7 @@ import javax.batch.runtime.Metric; import javax.batch.runtime.StepExecution; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Disabled; -@Disabled("Should be fixed in BAEL-3812") class SimpleChunkUnitTest { @Test public void givenChunk_thenBatch_CompletesWithSucess() throws Exception { diff --git a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkUnitTest.java b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkUnitTest.java index c53561a0c0..bc410aec8d 100644 --- a/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkUnitTest.java +++ b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleErrorChunkUnitTest.java @@ -1,19 +1,18 @@ package com.baeldung.batch.understanding; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; +import static org.junit.Assert.assertEquals; + +import java.util.List; +import java.util.Properties; import javax.batch.operations.JobOperator; import javax.batch.runtime.BatchRuntime; import javax.batch.runtime.BatchStatus; import javax.batch.runtime.JobExecution; import javax.batch.runtime.StepExecution; -import java.util.List; -import java.util.Properties; -import static org.junit.Assert.assertEquals; +import org.junit.jupiter.api.Test; -@Disabled("Should be fixed in BAEL-3812") class SimpleErrorChunkUnitTest { @Test diff --git a/jee-7/src/test/resources/jberet.properties b/jee-7/src/test/resources/jberet.properties new file mode 100644 index 0000000000..e8b9907de5 --- /dev/null +++ b/jee-7/src/test/resources/jberet.properties @@ -0,0 +1 @@ +db-url=jdbc:h2:mem:jberet-repo;DB_CLOSE_DELAY=-1 \ No newline at end of file From da174392ed63097a64d6a095eb71f442b563a356 Mon Sep 17 00:00:00 2001 From: mikr Date: Sun, 26 Apr 2020 22:34:22 +0200 Subject: [PATCH 347/503] JAVA-1470 Move 10 articles to libraries-4 module --- libraries-4/README.md | 43 +++ libraries-4/pom.xml | 111 +++++++ .../distinct/DistinctWithJavaFunction.java | 0 .../java/com/baeldung/distinct/Person.java | 0 .../ConvertContainerToAnother.java | 0 .../baeldung/eclipsecollections/Student.java | 0 .../com/baeldung/jdeffered/FilterDemo.java | 0 .../java/com/baeldung/jdeffered/PipeDemo.java | 0 .../com/baeldung/jdeffered/PromiseDemo.java | 0 .../baeldung/jdeffered/ThreadSafeDemo.java | 0 .../manager/DeferredManagerDemo.java | 0 .../DeferredManagerWithExecutorDemo.java | 0 .../manager/SimpleDeferredManagerDemo.java | 0 .../com/baeldung/mbassador/AckMessage.java | 0 .../java/com/baeldung/mbassador/Message.java | 0 .../com/baeldung/mbassador/RejectMessage.java | 0 .../noexception/CustomExceptionHandler.java | 0 .../java/com/baeldung/pairs/CustomPair.java | 0 .../com/baeldung/rome/RSSRomeExample.java | 0 .../com/baeldung/yarg/DocumentController.java | 0 ...istinctWithEclipseCollectionsUnitTest.java | 0 .../DistinctWithJavaFunctionUnitTest.java | 0 .../DistinctWithStreamexUnitTest.java | 0 .../distinct/DistinctWithVavrUnitTest.java | 0 .../distinct/PersonDataGenerator.java | 0 .../AllSatisfyPatternUnitTest.java | 0 .../AnySatisfyPatternUnitTest.java | 0 .../CollectPatternUnitTest.java | 0 .../ConvertContainerToAnotherUnitTest.java | 0 .../DetectPatternUnitTest.java | 0 .../FlatCollectUnitTest.java | 0 .../ForEachPatternUnitTest.java | 3 +- .../InjectIntoPatternUnitTest.java | 0 .../LazyIterationUnitTest.java | 0 .../PartitionPatternUnitTest.java | 0 .../RejectPatternUnitTest.java | 0 .../SelectPatternUnitTest.java | 0 .../eclipsecollections/ZipUnitTest.java | 0 .../ZipWithIndexUnitTest.java | 0 .../io/JavaDirectoryDeleteUnitTest.java | 276 +++++++++--------- .../baeldung/jdeffered/JDeferredUnitTest.java | 0 .../MBassadorAsyncDispatchUnitTest.java | 0 .../MBassadorAsyncInvocationUnitTest.java | 0 .../mbassador/MBassadorBasicUnitTest.java | 0 .../MBassadorConfigurationUnitTest.java | 0 .../mbassador/MBassadorFilterUnitTest.java | 0 .../mbassador/MBassadorHierarchyUnitTest.java | 0 .../noexception/NoExceptionUnitTest.java | 0 .../pairs/ApacheCommonsPairUnitTest.java | 0 .../baeldung/pairs/CoreJavaPairUnitTest.java | 0 .../pairs/CoreJavaSimpleEntryUnitTest.java | 0 .../com/baeldung/pairs/VavrPairsUnitTest.java | 0 .../pcollections/PCollectionsUnitTest.java | 0 libraries-5/pom.xml | 15 + libraries-6/pom.xml | 15 + libraries/README.md | 9 +- libraries/pom.xml | 134 ++++----- pom.xml | 4 + 58 files changed, 403 insertions(+), 207 deletions(-) create mode 100644 libraries-4/README.md create mode 100644 libraries-4/pom.xml rename {libraries => libraries-4}/src/main/java/com/baeldung/distinct/DistinctWithJavaFunction.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/distinct/Person.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/eclipsecollections/ConvertContainerToAnother.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/eclipsecollections/Student.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/jdeffered/FilterDemo.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/jdeffered/PipeDemo.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/jdeffered/PromiseDemo.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/jdeffered/ThreadSafeDemo.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerDemo.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerWithExecutorDemo.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/jdeffered/manager/SimpleDeferredManagerDemo.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/mbassador/AckMessage.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/mbassador/Message.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/mbassador/RejectMessage.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/noexception/CustomExceptionHandler.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/pairs/CustomPair.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/rome/RSSRomeExample.java (100%) rename {libraries => libraries-4}/src/main/java/com/baeldung/yarg/DocumentController.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/distinct/DistinctWithEclipseCollectionsUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/distinct/DistinctWithJavaFunctionUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/distinct/DistinctWithStreamexUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/distinct/DistinctWithVavrUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/distinct/PersonDataGenerator.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/eclipsecollections/AllSatisfyPatternUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/eclipsecollections/AnySatisfyPatternUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/eclipsecollections/CollectPatternUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/eclipsecollections/ConvertContainerToAnotherUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/eclipsecollections/DetectPatternUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/eclipsecollections/FlatCollectUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/eclipsecollections/ForEachPatternUnitTest.java (90%) rename {libraries => libraries-4}/src/test/java/com/baeldung/eclipsecollections/InjectIntoPatternUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/eclipsecollections/LazyIterationUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/eclipsecollections/PartitionPatternUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/eclipsecollections/RejectPatternUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/eclipsecollections/SelectPatternUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/eclipsecollections/ZipUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/eclipsecollections/ZipWithIndexUnitTest.java (100%) rename {libraries/src/test/java/com/baeldung/java => libraries-4/src/test/java/com/baeldung}/io/JavaDirectoryDeleteUnitTest.java (96%) rename {libraries => libraries-4}/src/test/java/com/baeldung/jdeffered/JDeferredUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/mbassador/MBassadorAsyncDispatchUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/mbassador/MBassadorAsyncInvocationUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/mbassador/MBassadorBasicUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/mbassador/MBassadorConfigurationUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/mbassador/MBassadorFilterUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/mbassador/MBassadorHierarchyUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/noexception/NoExceptionUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/pairs/ApacheCommonsPairUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/pairs/CoreJavaPairUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/pairs/CoreJavaSimpleEntryUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/pairs/VavrPairsUnitTest.java (100%) rename {libraries => libraries-4}/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java (100%) create mode 100644 libraries-5/pom.xml create mode 100644 libraries-6/pom.xml diff --git a/libraries-4/README.md b/libraries-4/README.md new file mode 100644 index 0000000000..f650c073a7 --- /dev/null +++ b/libraries-4/README.md @@ -0,0 +1,43 @@ +## Libraries + +This module contains articles about various Java libraries. +These are small libraries that are relatively easy to use and do not require any separate module of their own. + +The code examples related to different libraries are each in their own module. + +Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-modules) we already have separate modules. Please make sure to have a look at the existing modules in such cases. + +### Relevant articles + +- [Introduction to Javatuples](https://www.baeldung.com/java-tuples) +- [Introduction to Javassist](https://www.baeldung.com/javassist) +- [Introduction to Apache Flink with Java](https://www.baeldung.com/apache-flink) +- [Intro to JaVers](https://www.baeldung.com/javers) +- [Merging Streams in Java](https://www.baeldung.com/java-merge-streams) +- [Introduction to Quartz](https://www.baeldung.com/quartz) +- [How to Warm Up the JVM](https://www.baeldung.com/java-jvm-warmup) +- [Software Transactional Memory in Java Using Multiverse](https://www.baeldung.com/java-multiverse-stm) +- [Locality-Sensitive Hashing in Java Using Java-LSH](https://www.baeldung.com/locality-sensitive-hashing) +- [Introduction to Neuroph](https://www.baeldung.com/neuroph) + +#5 +- [Introduction to Caffeine](https://www.baeldung.com/java-caching-caffeine) +- [Introduction to StreamEx](https://www.baeldung.com/streamex) +- [A Docker Guide for Java](https://www.baeldung.com/docker-java-api) +- [Introduction to Akka Actors in Java](https://www.baeldung.com/akka-actors-java) +- [A Guide to Byte Buddy](https://www.baeldung.com/byte-buddy) +- [Introduction to jOOL](https://www.baeldung.com/jool) +- [Consumer Driven Contracts with Pact](https://www.baeldung.com/pact-junit-consumer-driven-contracts) +- [Introduction to Atlassian Fugue](https://www.baeldung.com/java-fugue) +- [Publish and Receive Messages with Nats Java Client](https://www.baeldung.com/nats-java-client) +- [Java Concurrency Utility with JCTools](https://www.baeldung.com/java-concurrency-jc-tools) + +#6 +- [Introduction to JavaPoet](https://www.baeldung.com/java-poet) +- [Guide to Resilience4j](https://www.baeldung.com/resilience4j) +- [Implementing a FTP-Client in Java](https://www.baeldung.com/java-ftp-client) +- [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) +- More articles [[next -->]](/libraries-2) diff --git a/libraries-4/pom.xml b/libraries-4/pom.xml new file mode 100644 index 0000000000..1b2db27861 --- /dev/null +++ b/libraries-4/pom.xml @@ -0,0 +1,111 @@ + + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + 4.0.0 + + libraries-4 + + + + org.jdeferred + jdeferred-core + ${jdeferred.version} + + + org.eclipse.collections + eclipse-collections + ${eclipse-collections.version} + + + com.haulmont.yarg + yarg + ${yarg.version} + + + net.engio + mbassador + ${mbassador.version} + + + com.machinezoo.noexception + noexception + ${noexception.version} + + + rome + rome + ${rome.version} + + + org.springframework + spring-web + ${spring.version} + + + org.datanucleus + javax.jdo + ${javax.jdo.version} + + + javax.servlet + servlet-api + ${javax.servlet.version} + + + io.vavr + vavr + ${vavr.version} + + + org.assertj + assertj-core + ${assertj.version} + + + org.pcollections + pcollections + ${pcollections.version} + + + org.awaitility + awaitility + ${awaitility.version} + test + + + one.util + streamex + ${streamex.version} + + + javax.el + javax.el-api + ${javax.el.version} + + + + + 1.2.6 + 8.2.0 + 1.1.0 + 2.0.12 + 1.3.1 + 1.0 + 4.3.8.RELEASE + 2.5 + 3.2.0-m7 + 0.9.0 + 3.6.2 + 2.1.2 + 3.0.0 + 0.6.5 + 3.0.0 + + + \ No newline at end of file diff --git a/libraries/src/main/java/com/baeldung/distinct/DistinctWithJavaFunction.java b/libraries-4/src/main/java/com/baeldung/distinct/DistinctWithJavaFunction.java similarity index 100% rename from libraries/src/main/java/com/baeldung/distinct/DistinctWithJavaFunction.java rename to libraries-4/src/main/java/com/baeldung/distinct/DistinctWithJavaFunction.java diff --git a/libraries/src/main/java/com/baeldung/distinct/Person.java b/libraries-4/src/main/java/com/baeldung/distinct/Person.java similarity index 100% rename from libraries/src/main/java/com/baeldung/distinct/Person.java rename to libraries-4/src/main/java/com/baeldung/distinct/Person.java diff --git a/libraries/src/main/java/com/baeldung/eclipsecollections/ConvertContainerToAnother.java b/libraries-4/src/main/java/com/baeldung/eclipsecollections/ConvertContainerToAnother.java similarity index 100% rename from libraries/src/main/java/com/baeldung/eclipsecollections/ConvertContainerToAnother.java rename to libraries-4/src/main/java/com/baeldung/eclipsecollections/ConvertContainerToAnother.java diff --git a/libraries/src/main/java/com/baeldung/eclipsecollections/Student.java b/libraries-4/src/main/java/com/baeldung/eclipsecollections/Student.java similarity index 100% rename from libraries/src/main/java/com/baeldung/eclipsecollections/Student.java rename to libraries-4/src/main/java/com/baeldung/eclipsecollections/Student.java diff --git a/libraries/src/main/java/com/baeldung/jdeffered/FilterDemo.java b/libraries-4/src/main/java/com/baeldung/jdeffered/FilterDemo.java similarity index 100% rename from libraries/src/main/java/com/baeldung/jdeffered/FilterDemo.java rename to libraries-4/src/main/java/com/baeldung/jdeffered/FilterDemo.java diff --git a/libraries/src/main/java/com/baeldung/jdeffered/PipeDemo.java b/libraries-4/src/main/java/com/baeldung/jdeffered/PipeDemo.java similarity index 100% rename from libraries/src/main/java/com/baeldung/jdeffered/PipeDemo.java rename to libraries-4/src/main/java/com/baeldung/jdeffered/PipeDemo.java diff --git a/libraries/src/main/java/com/baeldung/jdeffered/PromiseDemo.java b/libraries-4/src/main/java/com/baeldung/jdeffered/PromiseDemo.java similarity index 100% rename from libraries/src/main/java/com/baeldung/jdeffered/PromiseDemo.java rename to libraries-4/src/main/java/com/baeldung/jdeffered/PromiseDemo.java diff --git a/libraries/src/main/java/com/baeldung/jdeffered/ThreadSafeDemo.java b/libraries-4/src/main/java/com/baeldung/jdeffered/ThreadSafeDemo.java similarity index 100% rename from libraries/src/main/java/com/baeldung/jdeffered/ThreadSafeDemo.java rename to libraries-4/src/main/java/com/baeldung/jdeffered/ThreadSafeDemo.java diff --git a/libraries/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerDemo.java b/libraries-4/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerDemo.java similarity index 100% rename from libraries/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerDemo.java rename to libraries-4/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerDemo.java diff --git a/libraries/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerWithExecutorDemo.java b/libraries-4/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerWithExecutorDemo.java similarity index 100% rename from libraries/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerWithExecutorDemo.java rename to libraries-4/src/main/java/com/baeldung/jdeffered/manager/DeferredManagerWithExecutorDemo.java diff --git a/libraries/src/main/java/com/baeldung/jdeffered/manager/SimpleDeferredManagerDemo.java b/libraries-4/src/main/java/com/baeldung/jdeffered/manager/SimpleDeferredManagerDemo.java similarity index 100% rename from libraries/src/main/java/com/baeldung/jdeffered/manager/SimpleDeferredManagerDemo.java rename to libraries-4/src/main/java/com/baeldung/jdeffered/manager/SimpleDeferredManagerDemo.java diff --git a/libraries/src/main/java/com/baeldung/mbassador/AckMessage.java b/libraries-4/src/main/java/com/baeldung/mbassador/AckMessage.java similarity index 100% rename from libraries/src/main/java/com/baeldung/mbassador/AckMessage.java rename to libraries-4/src/main/java/com/baeldung/mbassador/AckMessage.java diff --git a/libraries/src/main/java/com/baeldung/mbassador/Message.java b/libraries-4/src/main/java/com/baeldung/mbassador/Message.java similarity index 100% rename from libraries/src/main/java/com/baeldung/mbassador/Message.java rename to libraries-4/src/main/java/com/baeldung/mbassador/Message.java diff --git a/libraries/src/main/java/com/baeldung/mbassador/RejectMessage.java b/libraries-4/src/main/java/com/baeldung/mbassador/RejectMessage.java similarity index 100% rename from libraries/src/main/java/com/baeldung/mbassador/RejectMessage.java rename to libraries-4/src/main/java/com/baeldung/mbassador/RejectMessage.java diff --git a/libraries/src/main/java/com/baeldung/noexception/CustomExceptionHandler.java b/libraries-4/src/main/java/com/baeldung/noexception/CustomExceptionHandler.java similarity index 100% rename from libraries/src/main/java/com/baeldung/noexception/CustomExceptionHandler.java rename to libraries-4/src/main/java/com/baeldung/noexception/CustomExceptionHandler.java diff --git a/libraries/src/main/java/com/baeldung/pairs/CustomPair.java b/libraries-4/src/main/java/com/baeldung/pairs/CustomPair.java similarity index 100% rename from libraries/src/main/java/com/baeldung/pairs/CustomPair.java rename to libraries-4/src/main/java/com/baeldung/pairs/CustomPair.java diff --git a/libraries/src/main/java/com/baeldung/rome/RSSRomeExample.java b/libraries-4/src/main/java/com/baeldung/rome/RSSRomeExample.java similarity index 100% rename from libraries/src/main/java/com/baeldung/rome/RSSRomeExample.java rename to libraries-4/src/main/java/com/baeldung/rome/RSSRomeExample.java diff --git a/libraries/src/main/java/com/baeldung/yarg/DocumentController.java b/libraries-4/src/main/java/com/baeldung/yarg/DocumentController.java similarity index 100% rename from libraries/src/main/java/com/baeldung/yarg/DocumentController.java rename to libraries-4/src/main/java/com/baeldung/yarg/DocumentController.java diff --git a/libraries/src/test/java/com/baeldung/distinct/DistinctWithEclipseCollectionsUnitTest.java b/libraries-4/src/test/java/com/baeldung/distinct/DistinctWithEclipseCollectionsUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/distinct/DistinctWithEclipseCollectionsUnitTest.java rename to libraries-4/src/test/java/com/baeldung/distinct/DistinctWithEclipseCollectionsUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/distinct/DistinctWithJavaFunctionUnitTest.java b/libraries-4/src/test/java/com/baeldung/distinct/DistinctWithJavaFunctionUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/distinct/DistinctWithJavaFunctionUnitTest.java rename to libraries-4/src/test/java/com/baeldung/distinct/DistinctWithJavaFunctionUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/distinct/DistinctWithStreamexUnitTest.java b/libraries-4/src/test/java/com/baeldung/distinct/DistinctWithStreamexUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/distinct/DistinctWithStreamexUnitTest.java rename to libraries-4/src/test/java/com/baeldung/distinct/DistinctWithStreamexUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/distinct/DistinctWithVavrUnitTest.java b/libraries-4/src/test/java/com/baeldung/distinct/DistinctWithVavrUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/distinct/DistinctWithVavrUnitTest.java rename to libraries-4/src/test/java/com/baeldung/distinct/DistinctWithVavrUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/distinct/PersonDataGenerator.java b/libraries-4/src/test/java/com/baeldung/distinct/PersonDataGenerator.java similarity index 100% rename from libraries/src/test/java/com/baeldung/distinct/PersonDataGenerator.java rename to libraries-4/src/test/java/com/baeldung/distinct/PersonDataGenerator.java diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/AllSatisfyPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/AllSatisfyPatternUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/eclipsecollections/AllSatisfyPatternUnitTest.java rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/AllSatisfyPatternUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/AnySatisfyPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/AnySatisfyPatternUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/eclipsecollections/AnySatisfyPatternUnitTest.java rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/AnySatisfyPatternUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/CollectPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/CollectPatternUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/eclipsecollections/CollectPatternUnitTest.java rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/CollectPatternUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/ConvertContainerToAnotherUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/ConvertContainerToAnotherUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/eclipsecollections/ConvertContainerToAnotherUnitTest.java rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/ConvertContainerToAnotherUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/DetectPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/DetectPatternUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/eclipsecollections/DetectPatternUnitTest.java rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/DetectPatternUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/FlatCollectUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/FlatCollectUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/eclipsecollections/FlatCollectUnitTest.java rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/FlatCollectUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/ForEachPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/ForEachPatternUnitTest.java similarity index 90% rename from libraries/src/test/java/com/baeldung/eclipsecollections/ForEachPatternUnitTest.java rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/ForEachPatternUnitTest.java index 38d95047ed..a1bd280658 100644 --- a/libraries/src/test/java/com/baeldung/eclipsecollections/ForEachPatternUnitTest.java +++ b/libraries-4/src/test/java/com/baeldung/eclipsecollections/ForEachPatternUnitTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertEquals; import org.eclipse.collections.api.tuple.Pair; import org.eclipse.collections.impl.map.mutable.UnifiedMap; import org.eclipse.collections.impl.tuple.Tuples; +import org.junit.Assert; import org.junit.Test; public class ForEachPatternUnitTest { @@ -23,7 +24,7 @@ public class ForEachPatternUnitTest { } for (int i = 0; i < map.size(); i++) { - assertEquals("New Value", map.get(i + 1)); + Assert.assertEquals("New Value", map.get(i + 1)); } } } diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/InjectIntoPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/InjectIntoPatternUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/eclipsecollections/InjectIntoPatternUnitTest.java rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/InjectIntoPatternUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/LazyIterationUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/LazyIterationUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/eclipsecollections/LazyIterationUnitTest.java rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/LazyIterationUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/PartitionPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/PartitionPatternUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/eclipsecollections/PartitionPatternUnitTest.java rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/PartitionPatternUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/RejectPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/RejectPatternUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/eclipsecollections/RejectPatternUnitTest.java rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/RejectPatternUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/SelectPatternUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/SelectPatternUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/eclipsecollections/SelectPatternUnitTest.java rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/SelectPatternUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/ZipUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/ZipUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/eclipsecollections/ZipUnitTest.java rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/ZipUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/ZipWithIndexUnitTest.java b/libraries-4/src/test/java/com/baeldung/eclipsecollections/ZipWithIndexUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/eclipsecollections/ZipWithIndexUnitTest.java rename to libraries-4/src/test/java/com/baeldung/eclipsecollections/ZipWithIndexUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/java/io/JavaDirectoryDeleteUnitTest.java b/libraries-4/src/test/java/com/baeldung/io/JavaDirectoryDeleteUnitTest.java similarity index 96% rename from libraries/src/test/java/com/baeldung/java/io/JavaDirectoryDeleteUnitTest.java rename to libraries-4/src/test/java/com/baeldung/io/JavaDirectoryDeleteUnitTest.java index 53d9d11bbb..c9c8242cd5 100644 --- a/libraries/src/test/java/com/baeldung/java/io/JavaDirectoryDeleteUnitTest.java +++ b/libraries-4/src/test/java/com/baeldung/io/JavaDirectoryDeleteUnitTest.java @@ -1,138 +1,138 @@ -package com.baeldung.java.io; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.io.IOException; -import java.nio.file.FileVisitResult; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; - -import org.apache.commons.io.FileUtils; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.springframework.util.FileSystemUtils; - -public class JavaDirectoryDeleteUnitTest { - private static Path TEMP_DIRECTORY; - private static final String DIRECTORY_NAME = "toBeDeleted"; - - private static final List ALL_LINES = Arrays.asList("This is line 1", "This is line 2", "This is line 3", "This is line 4", "This is line 5", "This is line 6"); - - @BeforeClass - public static void initializeTempDirectory() throws IOException { - TEMP_DIRECTORY = Files.createTempDirectory("tmpForJUnit"); - } - - @AfterClass - public static void cleanTempDirectory() throws IOException { - FileUtils.deleteDirectory(TEMP_DIRECTORY.toFile()); - } - - @Before - public void setupDirectory() throws IOException { - Path tempPathForEachTest = Files.createDirectory(TEMP_DIRECTORY.resolve(DIRECTORY_NAME)); - - // Create a directory structure - Files.write(tempPathForEachTest.resolve("file1.txt"), ALL_LINES.subList(0, 2)); - Files.write(tempPathForEachTest.resolve("file2.txt"), ALL_LINES.subList(2, 4)); - - Files.createDirectories(tempPathForEachTest.resolve("Empty")); - - Path aSubDir = Files.createDirectories(tempPathForEachTest.resolve("notEmpty")); - Files.write(aSubDir.resolve("file3.txt"), ALL_LINES.subList(3, 5)); - Files.write(aSubDir.resolve("file4.txt"), ALL_LINES.subList(0, 3)); - - aSubDir = Files.createDirectories(aSubDir.resolve("anotherSubDirectory")); - Files.write(aSubDir.resolve("file5.txt"), ALL_LINES.subList(4, 5)); - Files.write(aSubDir.resolve("file6.txt"), ALL_LINES.subList(0, 2)); - } - - @After - public void checkAndCleanupIfRequired() throws IOException { - Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME); - if (Files.exists(pathToBeDeleted)) { - FileUtils.deleteDirectory(pathToBeDeleted.toFile()); - } - } - - private boolean deleteDirectory(File directoryToBeDeleted) { - File[] allContents = directoryToBeDeleted.listFiles(); - - if (allContents != null) { - for (File file : allContents) { - deleteDirectory(file); - } - } - - return directoryToBeDeleted.delete(); - } - - @Test - public void givenDirectory_whenDeletedWithRecursion_thenIsGone() throws IOException { - Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME); - - boolean result = deleteDirectory(pathToBeDeleted.toFile()); - - assertTrue("Could not delete directory", result); - assertFalse("Directory still exists", Files.exists(pathToBeDeleted)); - } - - @Test - public void givenDirectory_whenDeletedWithCommonsIOFileUtils_thenIsGone() throws IOException { - Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME); - - FileUtils.deleteDirectory(pathToBeDeleted.toFile()); - - assertFalse("Directory still exists", Files.exists(pathToBeDeleted)); - } - - @Test - public void givenDirectory_whenDeletedWithSpringFileSystemUtils_thenIsGone() throws IOException { - Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME); - - boolean result = FileSystemUtils.deleteRecursively(pathToBeDeleted.toFile()); - - assertTrue("Could not delete directory", result); - assertFalse("Directory still exists", Files.exists(pathToBeDeleted)); - } - - @Test - public void givenDirectory_whenDeletedWithFilesWalk_thenIsGone() throws IOException { - Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME); - - Files.walk(pathToBeDeleted).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); - - assertFalse("Directory still exists", Files.exists(pathToBeDeleted)); - } - - @Test - public void givenDirectory_whenDeletedWithNIO2WalkFileTree_thenIsGone() throws IOException { - Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME); - - Files.walkFileTree(pathToBeDeleted, new SimpleFileVisitor() { - @Override - public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { - Files.delete(dir); - return FileVisitResult.CONTINUE; - } - - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - Files.delete(file); - return FileVisitResult.CONTINUE; - } - }); - - assertFalse("Directory still exists", Files.exists(pathToBeDeleted)); - } -} +package com.baeldung.io; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.io.File; +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + +import org.apache.commons.io.FileUtils; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.springframework.util.FileSystemUtils; + +public class JavaDirectoryDeleteUnitTest { + private static Path TEMP_DIRECTORY; + private static final String DIRECTORY_NAME = "toBeDeleted"; + + private static final List ALL_LINES = Arrays.asList("This is line 1", "This is line 2", "This is line 3", "This is line 4", "This is line 5", "This is line 6"); + + @BeforeClass + public static void initializeTempDirectory() throws IOException { + TEMP_DIRECTORY = Files.createTempDirectory("tmpForJUnit"); + } + + @AfterClass + public static void cleanTempDirectory() throws IOException { + FileUtils.deleteDirectory(TEMP_DIRECTORY.toFile()); + } + + @Before + public void setupDirectory() throws IOException { + Path tempPathForEachTest = Files.createDirectory(TEMP_DIRECTORY.resolve(DIRECTORY_NAME)); + + // Create a directory structure + Files.write(tempPathForEachTest.resolve("file1.txt"), ALL_LINES.subList(0, 2)); + Files.write(tempPathForEachTest.resolve("file2.txt"), ALL_LINES.subList(2, 4)); + + Files.createDirectories(tempPathForEachTest.resolve("Empty")); + + Path aSubDir = Files.createDirectories(tempPathForEachTest.resolve("notEmpty")); + Files.write(aSubDir.resolve("file3.txt"), ALL_LINES.subList(3, 5)); + Files.write(aSubDir.resolve("file4.txt"), ALL_LINES.subList(0, 3)); + + aSubDir = Files.createDirectories(aSubDir.resolve("anotherSubDirectory")); + Files.write(aSubDir.resolve("file5.txt"), ALL_LINES.subList(4, 5)); + Files.write(aSubDir.resolve("file6.txt"), ALL_LINES.subList(0, 2)); + } + + @After + public void checkAndCleanupIfRequired() throws IOException { + Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME); + if (Files.exists(pathToBeDeleted)) { + FileUtils.deleteDirectory(pathToBeDeleted.toFile()); + } + } + + private boolean deleteDirectory(File directoryToBeDeleted) { + File[] allContents = directoryToBeDeleted.listFiles(); + + if (allContents != null) { + for (File file : allContents) { + deleteDirectory(file); + } + } + + return directoryToBeDeleted.delete(); + } + + @Test + public void givenDirectory_whenDeletedWithRecursion_thenIsGone() throws IOException { + Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME); + + boolean result = deleteDirectory(pathToBeDeleted.toFile()); + + assertTrue("Could not delete directory", result); + assertFalse("Directory still exists", Files.exists(pathToBeDeleted)); + } + + @Test + public void givenDirectory_whenDeletedWithCommonsIOFileUtils_thenIsGone() throws IOException { + Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME); + + FileUtils.deleteDirectory(pathToBeDeleted.toFile()); + + assertFalse("Directory still exists", Files.exists(pathToBeDeleted)); + } + + @Test + public void givenDirectory_whenDeletedWithSpringFileSystemUtils_thenIsGone() throws IOException { + Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME); + + boolean result = FileSystemUtils.deleteRecursively(pathToBeDeleted.toFile()); + + assertTrue("Could not delete directory", result); + assertFalse("Directory still exists", Files.exists(pathToBeDeleted)); + } + + @Test + public void givenDirectory_whenDeletedWithFilesWalk_thenIsGone() throws IOException { + Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME); + + Files.walk(pathToBeDeleted).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); + + assertFalse("Directory still exists", Files.exists(pathToBeDeleted)); + } + + @Test + public void givenDirectory_whenDeletedWithNIO2WalkFileTree_thenIsGone() throws IOException { + Path pathToBeDeleted = TEMP_DIRECTORY.resolve(DIRECTORY_NAME); + + Files.walkFileTree(pathToBeDeleted, new SimpleFileVisitor() { + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + Files.delete(dir); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } + }); + + assertFalse("Directory still exists", Files.exists(pathToBeDeleted)); + } +} diff --git a/libraries/src/test/java/com/baeldung/jdeffered/JDeferredUnitTest.java b/libraries-4/src/test/java/com/baeldung/jdeffered/JDeferredUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/jdeffered/JDeferredUnitTest.java rename to libraries-4/src/test/java/com/baeldung/jdeffered/JDeferredUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/mbassador/MBassadorAsyncDispatchUnitTest.java b/libraries-4/src/test/java/com/baeldung/mbassador/MBassadorAsyncDispatchUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/mbassador/MBassadorAsyncDispatchUnitTest.java rename to libraries-4/src/test/java/com/baeldung/mbassador/MBassadorAsyncDispatchUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/mbassador/MBassadorAsyncInvocationUnitTest.java b/libraries-4/src/test/java/com/baeldung/mbassador/MBassadorAsyncInvocationUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/mbassador/MBassadorAsyncInvocationUnitTest.java rename to libraries-4/src/test/java/com/baeldung/mbassador/MBassadorAsyncInvocationUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/mbassador/MBassadorBasicUnitTest.java b/libraries-4/src/test/java/com/baeldung/mbassador/MBassadorBasicUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/mbassador/MBassadorBasicUnitTest.java rename to libraries-4/src/test/java/com/baeldung/mbassador/MBassadorBasicUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/mbassador/MBassadorConfigurationUnitTest.java b/libraries-4/src/test/java/com/baeldung/mbassador/MBassadorConfigurationUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/mbassador/MBassadorConfigurationUnitTest.java rename to libraries-4/src/test/java/com/baeldung/mbassador/MBassadorConfigurationUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/mbassador/MBassadorFilterUnitTest.java b/libraries-4/src/test/java/com/baeldung/mbassador/MBassadorFilterUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/mbassador/MBassadorFilterUnitTest.java rename to libraries-4/src/test/java/com/baeldung/mbassador/MBassadorFilterUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/mbassador/MBassadorHierarchyUnitTest.java b/libraries-4/src/test/java/com/baeldung/mbassador/MBassadorHierarchyUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/mbassador/MBassadorHierarchyUnitTest.java rename to libraries-4/src/test/java/com/baeldung/mbassador/MBassadorHierarchyUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/noexception/NoExceptionUnitTest.java b/libraries-4/src/test/java/com/baeldung/noexception/NoExceptionUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/noexception/NoExceptionUnitTest.java rename to libraries-4/src/test/java/com/baeldung/noexception/NoExceptionUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/pairs/ApacheCommonsPairUnitTest.java b/libraries-4/src/test/java/com/baeldung/pairs/ApacheCommonsPairUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/pairs/ApacheCommonsPairUnitTest.java rename to libraries-4/src/test/java/com/baeldung/pairs/ApacheCommonsPairUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/pairs/CoreJavaPairUnitTest.java b/libraries-4/src/test/java/com/baeldung/pairs/CoreJavaPairUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/pairs/CoreJavaPairUnitTest.java rename to libraries-4/src/test/java/com/baeldung/pairs/CoreJavaPairUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/pairs/CoreJavaSimpleEntryUnitTest.java b/libraries-4/src/test/java/com/baeldung/pairs/CoreJavaSimpleEntryUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/pairs/CoreJavaSimpleEntryUnitTest.java rename to libraries-4/src/test/java/com/baeldung/pairs/CoreJavaSimpleEntryUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/pairs/VavrPairsUnitTest.java b/libraries-4/src/test/java/com/baeldung/pairs/VavrPairsUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/pairs/VavrPairsUnitTest.java rename to libraries-4/src/test/java/com/baeldung/pairs/VavrPairsUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java b/libraries-4/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java rename to libraries-4/src/test/java/com/baeldung/pcollections/PCollectionsUnitTest.java diff --git a/libraries-5/pom.xml b/libraries-5/pom.xml new file mode 100644 index 0000000000..b5a1ecd49c --- /dev/null +++ b/libraries-5/pom.xml @@ -0,0 +1,15 @@ + + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + 4.0.0 + + libraries-5 + + + \ No newline at end of file diff --git a/libraries-6/pom.xml b/libraries-6/pom.xml new file mode 100644 index 0000000000..be74ff9ef0 --- /dev/null +++ b/libraries-6/pom.xml @@ -0,0 +1,15 @@ + + + + parent-modules + com.baeldung + 1.0.0-SNAPSHOT + + 4.0.0 + + libraries-6 + + + \ No newline at end of file diff --git a/libraries/README.md b/libraries/README.md index 79ba8fe55d..3f259e4222 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -19,6 +19,8 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Software Transactional Memory in Java Using Multiverse](https://www.baeldung.com/java-multiverse-stm) - [Locality-Sensitive Hashing in Java Using Java-LSH](https://www.baeldung.com/locality-sensitive-hashing) - [Introduction to Neuroph](https://www.baeldung.com/neuroph) + +#4 - [Quick Guide to RSS with Rome](https://www.baeldung.com/rome-rss) - [Introduction to PCollections](https://www.baeldung.com/java-pcollections) - [Introduction to Eclipse Collections](https://www.baeldung.com/eclipse-collections) @@ -29,6 +31,8 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Guide to JDeferred](https://www.baeldung.com/jdeferred) - [Introduction to MBassador](https://www.baeldung.com/mbassador) - [Using Pairs in Java](https://www.baeldung.com/java-pairs) + +#5 - [Introduction to Caffeine](https://www.baeldung.com/java-caching-caffeine) - [Introduction to StreamEx](https://www.baeldung.com/streamex) - [A Docker Guide for Java](https://www.baeldung.com/docker-java-api) @@ -39,10 +43,13 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Introduction to Atlassian Fugue](https://www.baeldung.com/java-fugue) - [Publish and Receive Messages with Nats Java Client](https://www.baeldung.com/nats-java-client) - [Java Concurrency Utility with JCTools](https://www.baeldung.com/java-concurrency-jc-tools) + +#6 - [Introduction to JavaPoet](https://www.baeldung.com/java-poet) - [Guide to Resilience4j](https://www.baeldung.com/resilience4j) -- [Exactly Once Processing in Kafka](https://www.baeldung.com/kafka-exactly-once) - [Implementing a FTP-Client in Java](https://www.baeldung.com/java-ftp-client) - [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) - More articles [[next -->]](/libraries-2) diff --git a/libraries/pom.xml b/libraries/pom.xml index 41bc2b9311..5d540f0d90 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -70,11 +70,11 @@ ${jnats.version} - - rome - rome - ${rome.version} - + + + + + net.serenity-bdd serenity-core @@ -218,11 +218,11 @@ quartz ${quartz.version} - - one.util - streamex - ${streamex.version} - + + + + + org.jooq jool @@ -256,18 +256,18 @@ - - org.awaitility - awaitility - ${awaitility.version} - test - - - org.awaitility - awaitility-proxy - ${awaitility.version} - test - + + + + + + + + + + + + org.hamcrest java-hamcrest @@ -284,42 +284,42 @@ byte-buddy-agent ${bytebuddy.version} - - org.pcollections - pcollections - ${pcollections.version} - - - com.machinezoo.noexception - noexception - ${noexception.version} - - - org.eclipse.collections - eclipse-collections - ${eclipse-collections.version} - - - io.vavr - vavr - ${vavr.version} - + + + + + + + + + + + + + + + + + + + + - - com.haulmont.yarg - yarg - ${yarg.version} - - - net.engio - mbassador - ${mbassador.version} - - - org.jdeferred - jdeferred-core - ${jdeferred.version} - + + + + + + + + + + + + + + + com.codepoetics protonpack @@ -572,14 +572,14 @@ 1.1.0 0.10 3.5.0 - 3.0.0 + 2.0.0.0 1.7.1 - 2.1.2 - 1.0 - 8.2.0 - 0.6.5 - 0.9.0 + + + + + 1.15 2.5.5 @@ -604,10 +604,10 @@ 2.3.0 0.9.12 1.19 - 1.1.0 - 2.0.4 - 1.3.1 - 1.2.6 + + + + 4.8.1 4.5.1 3.0.2 diff --git a/pom.xml b/pom.xml index 44a94095b3..d481f95042 100644 --- a/pom.xml +++ b/pom.xml @@ -1011,6 +1011,10 @@ libraries-2 libraries-3 + libraries-4 + + + libraries-apache-commons libraries-apache-commons-collections libraries-apache-commons-io From ec8d2244a3118ca3854feac34ef60ae3391acb59 Mon Sep 17 00:00:00 2001 From: Cavero Barca Date: Mon, 27 Apr 2020 01:22:33 +0200 Subject: [PATCH 348/503] Add RedisRateLimiter to webfilter package --- spring-cloud/spring-cloud-gateway/pom.xml | 25 ++++++-- .../RequestRateLimiterResolverConfig.java | 16 +++++ .../main/resources/application-webfilters.yml | 21 ++++-- .../RedisWebFilterFactoriesLiveTest.java | 64 +++++++++++++++++++ .../src/test/resources/logback-test.xml | 8 +++ 5 files changed, 123 insertions(+), 11 deletions(-) create mode 100644 spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/RequestRateLimiterResolverConfig.java create mode 100644 spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/RedisWebFilterFactoriesLiveTest.java diff --git a/spring-cloud/spring-cloud-gateway/pom.xml b/spring-cloud/spring-cloud-gateway/pom.xml index ada32ae85f..c692eed7ec 100644 --- a/spring-cloud/spring-cloud-gateway/pom.xml +++ b/spring-cloud/spring-cloud-gateway/pom.xml @@ -1,7 +1,7 @@ + xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-cloud-gateway spring-cloud-gateway @@ -54,7 +54,21 @@ org.springframework.cloud spring-cloud-starter-circuitbreaker-reactor-resilience4j - + + + + org.springframework.boot + spring-boot-starter-data-redis-reactive + + + + + it.ozimov + embedded-redis + ${redis.version} + test + + org.hibernate hibernate-validator-cdi @@ -75,8 +89,8 @@ test - org.springframework.boot - spring-boot-devtools + org.springframework.boot + spring-boot-devtools @@ -93,6 +107,7 @@ Hoxton.SR3 2.2.6.RELEASE 6.0.2.Final + 0.7.2 diff --git a/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/RequestRateLimiterResolverConfig.java b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/RequestRateLimiterResolverConfig.java new file mode 100644 index 0000000000..f80a742fa6 --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/src/main/java/com/baeldung/springcloudgateway/webfilters/config/RequestRateLimiterResolverConfig.java @@ -0,0 +1,16 @@ +package com.baeldung.springcloudgateway.webfilters.config; + +import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import reactor.core.publisher.Mono; + +@Configuration +public class RequestRateLimiterResolverConfig { + + @Bean + KeyResolver userKeyResolver() { + return exchange -> Mono.just("1"); + } +} diff --git a/spring-cloud/spring-cloud-gateway/src/main/resources/application-webfilters.yml b/spring-cloud/spring-cloud-gateway/src/main/resources/application-webfilters.yml index 9b3ec64f96..3348cbbba0 100644 --- a/spring-cloud/spring-cloud-gateway/src/main/resources/application-webfilters.yml +++ b/spring-cloud/spring-cloud-gateway/src/main/resources/application-webfilters.yml @@ -1,4 +1,12 @@ +logging: + level: + org.springframework.cloud.gateway: INFO + reactor.netty.http.client: INFO + spring: + redis: + host: localhost + port: 6379 cloud: gateway: routes: @@ -81,13 +89,14 @@ spring: factor: 2 basedOnPreviousValue: false - - id: circuitbreaker_route + - id: request_rate_limiter uri: https://httpbin.org predicates: - - Path=/status/504 + - Path=/redis/get/** filters: - - name: CircuitBreaker + - StripPrefix=1 + - name: RequestRateLimiter args: - name: myCircuitBreaker - fallbackUri: forward:/anything - - RewritePath=/status/504, /anything \ No newline at end of file + redis-rate-limiter.replenishRate: 10 + redis-rate-limiter.burstCapacity: 5 + key-resolver: "#{@userKeyResolver}" \ No newline at end of file diff --git a/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/RedisWebFilterFactoriesLiveTest.java b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/RedisWebFilterFactoriesLiveTest.java new file mode 100644 index 0000000000..a28eb68775 --- /dev/null +++ b/spring-cloud/spring-cloud-gateway/src/test/java/com/baeldung/springcloudgateway/webfilters/RedisWebFilterFactoriesLiveTest.java @@ -0,0 +1,64 @@ +package com.baeldung.springcloudgateway.webfilters; + +import org.junit.After; +import org.junit.Before; +import org.junit.jupiter.api.RepeatedTest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; + +import redis.embedded.RedisServer; + +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@ActiveProfiles("webfilters") +@TestConfiguration +public class RedisWebFilterFactoriesLiveTest { + + private static final Logger LOGGER = LoggerFactory.getLogger(RedisWebFilterFactoriesLiveTest.class); + + private RedisServer redisServer; + + public RedisWebFilterFactoriesLiveTest() { + } + + @Before + public void postConstruct() { + this.redisServer = new RedisServer(6379); + redisServer.start(); + } + + @LocalServerPort + String port; + + @Autowired + private TestRestTemplate restTemplate; + + @Autowired + TestRestTemplate template; + + @RepeatedTest(25) + public void whenCallRedisGetThroughGateway_thenOKStatusOrIsReceived() { + String url = "http://localhost:" + port + "/redis/get"; + + ResponseEntity r = restTemplate.getForEntity(url, String.class); + // assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + + LOGGER.info("Received: status->{}, reason->{}, remaining->{}", + r.getStatusCodeValue(), r.getStatusCode().getReasonPhrase(), + r.getHeaders().get("X-RateLimit-Remaining")); + } + + @After + public void preDestroy() { + redisServer.stop(); + } + +} diff --git a/spring-cloud/spring-cloud-gateway/src/test/resources/logback-test.xml b/spring-cloud/spring-cloud-gateway/src/test/resources/logback-test.xml index 6fcdb6317f..6980d119b1 100644 --- a/spring-cloud/spring-cloud-gateway/src/test/resources/logback-test.xml +++ b/spring-cloud/spring-cloud-gateway/src/test/resources/logback-test.xml @@ -3,7 +3,15 @@ + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + \ No newline at end of file From f1283f2424cc85aa6459898767c3f62be816d01b Mon Sep 17 00:00:00 2001 From: Belma Jakupovic Date: Mon, 27 Apr 2020 06:57:38 +0200 Subject: [PATCH 349/503] bjakupovic - single responsibility principle example (#9191) --- .../java/com/baeldung/s/TextManipulator.java | 35 +++++++++++++++++++ .../main/java/com/baeldung/s/TextPrinter.java | 23 ++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 patterns/solid/src/main/java/com/baeldung/s/TextManipulator.java create mode 100644 patterns/solid/src/main/java/com/baeldung/s/TextPrinter.java diff --git a/patterns/solid/src/main/java/com/baeldung/s/TextManipulator.java b/patterns/solid/src/main/java/com/baeldung/s/TextManipulator.java new file mode 100644 index 0000000000..a6b32a0ff9 --- /dev/null +++ b/patterns/solid/src/main/java/com/baeldung/s/TextManipulator.java @@ -0,0 +1,35 @@ +package com.baeldung.s; + +public class TextManipulator { + private String text; + + public TextManipulator(String text) { + this.text = text; + } + + public String getText() { + return text; + } + + public void appendText(String newText) { + text = text.concat(newText); + } + + public void findWordAndReplace(String word, String replacementWord) { + if (text.contains(word)) { + text = text.replace(word, replacementWord); + } else System.out.println("Word you want to replace is not found in the text"); + } + + public void findWordAndDelete(String word) { + if (text.contains(word)) { + text = text.replace(word, ""); + } else System.out.println("Word you want to delete is not found in the text"); + } + + /* + * Bad practice when implementing SRP principle, not in the scope of this class + public void printText() { + System.out.println(textManipulator.getText()); + }*/ +} diff --git a/patterns/solid/src/main/java/com/baeldung/s/TextPrinter.java b/patterns/solid/src/main/java/com/baeldung/s/TextPrinter.java new file mode 100644 index 0000000000..d6a413e7ac --- /dev/null +++ b/patterns/solid/src/main/java/com/baeldung/s/TextPrinter.java @@ -0,0 +1,23 @@ +package com.baeldung.s; + +import java.util.Arrays; + +public class TextPrinter { + TextManipulator textManipulator; + + public TextPrinter(TextManipulator textManipulator) { + this.textManipulator = textManipulator; + } + + public void printText() { + System.out.println(textManipulator.getText()); + } + + public void printOutEachWordOfText() { + System.out.println(Arrays.toString(textManipulator.getText().split(" "))); + } + + public void printRangeOfCharacters(int startingIndex, int endIndex) { + System.out.println(textManipulator.getText().substring(startingIndex, endIndex)); + } +} From e24cc4d7b0a9d34c0c091512f875df24b947b134 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 27 Apr 2020 11:34:36 +0530 Subject: [PATCH 350/503] JAVA-926: Upgraded spring boot version --- .../greeter-spring-boot-autoconfigure/pom.xml | 2 +- .../greeter-spring-boot-starter/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml index 0bba2936a7..532f45cf3e 100644 --- a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/pom.xml @@ -63,7 +63,7 @@ UTF-8 - 1.5.2.RELEASE + 2.2.6.RELEASE 0.0.1-SNAPSHOT diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml index ba2b4101e8..0e8fb4cbc9 100644 --- a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-starter/pom.xml @@ -51,7 +51,7 @@ UTF-8 0.0.1-SNAPSHOT - 1.5.2.RELEASE + 2.2.6.RELEASE \ No newline at end of file From f3ce1554c9dbdbcc8aef2d09665ca115ede478e6 Mon Sep 17 00:00:00 2001 From: Tyrell Flurry Date: Mon, 27 Apr 2020 10:47:52 -0400 Subject: [PATCH 351/503] BAEL-3929: made changes per code/article review. --- maven-all/maven-unused-dependencies/pom.xml | 14 ++++++------- .../src/main/java/com/baeldung/Main.java | 20 ------------------- .../java/com/baeldung/ReflectionMain.java | 15 -------------- .../UnusedDependenciesExample.java | 17 ++++++++++++++++ 4 files changed, 24 insertions(+), 42 deletions(-) delete mode 100644 maven-all/maven-unused-dependencies/src/main/java/com/baeldung/Main.java delete mode 100644 maven-all/maven-unused-dependencies/src/main/java/com/baeldung/ReflectionMain.java create mode 100644 maven-all/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java diff --git a/maven-all/maven-unused-dependencies/pom.xml b/maven-all/maven-unused-dependencies/pom.xml index 19a06fc605..c8f6c1f04b 100644 --- a/maven-all/maven-unused-dependencies/pom.xml +++ b/maven-all/maven-unused-dependencies/pom.xml @@ -6,6 +6,13 @@ maven-unused-dependencies 0.0.1-SNAPSHOT + + 3.2.2 + 1.7.25 + 3.1.1 + 3.1 + + commons-collections @@ -37,11 +44,4 @@ - - 3.2.2 - 1.7.25 - 3.1.1 - 3.1 - - \ No newline at end of file diff --git a/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/Main.java b/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/Main.java deleted file mode 100644 index 2626bb30a3..0000000000 --- a/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/Main.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung; - -import java.util.HashMap; -import java.util.Map; - -import org.slf4j.LoggerFactory; - -public class Main { - - public static void main(String[] args) { - Map map = new HashMap<>(); - map.put("Dallas", "Texas"); - map.put("Green Bay", "Wisconsin"); - map.put("Seattle", "Washington"); - - LoggerFactory.getLogger(Main.class) - .info("Map: {}", map); - } - -} diff --git a/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/ReflectionMain.java b/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/ReflectionMain.java deleted file mode 100644 index 48e42f7c66..0000000000 --- a/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/ReflectionMain.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung; - -public class ReflectionMain { - - public static void main(String[] args) { - ClassLoader classLoader = Main.class.getClassLoader(); - try { - System.out.println(classLoader.loadClass("org.apache.commons.collections.CollectionUtils") - .getSimpleName()); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } - -} \ No newline at end of file diff --git a/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java b/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java new file mode 100644 index 0000000000..c9390880ed --- /dev/null +++ b/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java @@ -0,0 +1,17 @@ +package com.baeldung.mavendependencyplugin; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class UnusedDependenciesExample { + + /** + * When the Maven dependency analyzer analyzes the code, it will see that the slf4j dependency is being used in this method. + * + * @return the slf4j {@link Logger}. + */ + public Logger getLogger() { + return LoggerFactory.getLogger(UnusedDependenciesExample.class); + } + +} From debb7dace50ee0ebe67e41872c132eafe83d8cbe Mon Sep 17 00:00:00 2001 From: Yevgen Pikus <4037842+gindex@users.noreply.github.com> Date: Mon, 27 Apr 2020 23:25:33 +0200 Subject: [PATCH 352/503] Add fold and reduce examples (#9188) Co-authored-by: Yevgen Pikus --- .../foldvsreduce/FoldAndReduceTest.kt | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/foldvsreduce/FoldAndReduceTest.kt diff --git a/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/foldvsreduce/FoldAndReduceTest.kt b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/foldvsreduce/FoldAndReduceTest.kt new file mode 100644 index 0000000000..7b263914c6 --- /dev/null +++ b/core-kotlin-modules/core-kotlin-collections/src/test/kotlin/com/baeldung/foldvsreduce/FoldAndReduceTest.kt @@ -0,0 +1,59 @@ +package com.baeldung.foldvsreduce + +import org.junit.Test +import org.junit.jupiter.api.assertThrows +import java.lang.RuntimeException +import kotlin.test.assertEquals + +class FoldAndReduceTest { + + @Test + fun testReduceLimitations() { + val numbers: List = listOf(1, 2, 3) + val sum: Number = numbers.reduce { acc, next -> acc + next } + assertEquals(6, sum) + + val emptyList = listOf() + assertThrows { emptyList.reduce { acc, next -> acc + next } } + + // doesn't compile + // val sum = numbers.reduce { acc, next -> acc.toLong() + next.toLong()} + } + + @Test + fun testFold() { + + val numbers: List = listOf(1, 2, 3) + val sum: Int = numbers.fold(0, { acc, next -> acc + next }) + assertEquals(6, sum) + + //change result type + val sumLong: Long = numbers.fold(0L, { acc, next -> acc + next.toLong() }) + assertEquals(6L, sumLong) + + val emptyList = listOf() + val emptySum = emptyList.fold(0, { acc, next -> acc + next }) + assertEquals(0, emptySum) + + //power of changing result type + val (even, odd) = numbers.fold(Pair(listOf(), listOf()), { acc, next -> + if (next % 2 == 0) Pair(acc.first + next, acc.second) + else Pair(acc.first, acc.second + next) + }) + + assertEquals(listOf(2), even) + assertEquals(listOf(1, 3), odd) + } + + @Test + fun testVariationsOfFold() { + val numbers = listOf(1, 2, 3) + val reversed = numbers.foldRight(listOf(), { next, acc -> acc + next}) + assertEquals(listOf(3,2,1), reversed) + + val reversedIndexes = numbers.foldRightIndexed(listOf(), { i, _, acc -> acc + i }) + assertEquals(listOf(2,1,0), reversedIndexes) + } + + +} \ No newline at end of file From ac794a722f32fbb1252e84f9b75d28586d2ef42a Mon Sep 17 00:00:00 2001 From: Greg Martin Date: Mon, 27 Apr 2020 18:58:15 -0400 Subject: [PATCH 353/503] Resolved Conflicts with master --- libraries-3/pom.xml | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/libraries-3/pom.xml b/libraries-3/pom.xml index a72dbcba50..5334bfba70 100644 --- a/libraries-3/pom.xml +++ b/libraries-3/pom.xml @@ -70,25 +70,6 @@ velocity-engine-core ${velocity-engine-core.version} -<<<<<<< HEAD - - 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 - -======= com.uber.nullaway nullaway @@ -106,7 +87,6 @@ error_prone_core 2.1.3 ->>>>>>> upstream/master @@ -143,20 +123,11 @@ -<<<<<<< HEAD - - - org.apache.maven.plugins - maven-compiler-plugin - 3.5 - -======= org.apache.maven.plugins maven-compiler-plugin 3.5 ->>>>>>> upstream/master javac-with-errorprone true 1.8 @@ -172,11 +143,7 @@ -<<<<<<< HEAD - -XepExcludedPaths:(.*)/test/.*|(.*)/streamex/.*|(.*)/jcabi/.* -======= -XepExcludedPaths:(.*)/test/.*|(.*)/jcabi/.* ->>>>>>> upstream/master -XepOpt:NullAway:AnnotatedPackages=com.baeldung.nullaway From 491e2d84933ee0c876e38c956edd5e888f1398fc Mon Sep 17 00:00:00 2001 From: Greg Martin Date: Mon, 27 Apr 2020 19:02:40 -0400 Subject: [PATCH 354/503] Synced with master --- libraries-3/README.md | 1 - .../java/com/baeldung/distinct/Person.java | 65 ------------------- 2 files changed, 66 deletions(-) delete mode 100644 libraries-3/src/main/java/com/baeldung/distinct/Person.java diff --git a/libraries-3/README.md b/libraries-3/README.md index 922ce1bd1a..ec433960ef 100644 --- a/libraries-3/README.md +++ b/libraries-3/README.md @@ -12,7 +12,6 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Guide to the Cactoos Library](https://www.baeldung.com/java-cactoos) - [Parsing Command-Line Parameters with Airline](https://www.baeldung.com/java-airline) - [Introduction to cache2k](https://www.baeldung.com/java-cache2k) -- [Using NullAway to Avoid NullPointerExceptions](https://www.baeldung.com/java-nullaway) - [Introduction to the jcabi-aspects AOP Annotations Library](https://www.baeldung.com/java-jcabi-aspects) - [Introduction to Takes](https://www.baeldung.com/java-takes) - [Using NullAway to Avoid NullPointerExceptions](https://www.baeldung.com/java-nullaway) diff --git a/libraries-3/src/main/java/com/baeldung/distinct/Person.java b/libraries-3/src/main/java/com/baeldung/distinct/Person.java deleted file mode 100644 index 8a2a5f7a45..0000000000 --- a/libraries-3/src/main/java/com/baeldung/distinct/Person.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.baeldung.distinct; - -public class Person { - int age; - String name; - String email; - - public Person(int age, String name, String email) { - super(); - this.age = age; - this.name = name; - this.email = email; - } - - public int getAge() { - return age; - } - - public String getName() { - return name; - } - - public String getEmail() { - return email; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("Person [age="); - builder.append(age); - builder.append(", name="); - builder.append(name); - builder.append(", email="); - builder.append(email); - builder.append("]"); - return builder.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((email == null) ? 0 : email.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Person other = (Person) obj; - if (email == null) { - if (other.email != null) - return false; - } else if (!email.equals(other.email)) - return false; - return true; - } - -} From 57519b9daebdbb82d6ca96c3f7af87f304c0dbd6 Mon Sep 17 00:00:00 2001 From: Kumar Chandrakant Date: Tue, 28 Apr 2020 09:48:00 +0530 Subject: [PATCH 355/503] Testing multithreading (#9193) --- .../core-java-concurrency-2/README.md | 1 + .../core-java-concurrency-2/pom.xml | 77 +++++++++++++++ .../com/baeldung/concurrent/MyCounter.java | 0 .../concurrent/MyCounterJCStressUnitTest.java | 0 .../MyCounterMultithreadedTCUnitTest.java | 4 +- .../concurrent/MyCounterSimpleUnitTest.java | 7 +- .../MyCounterTempusFugitUnitTest.java | 2 + .../MyCounterThreadWeaverUnitTest.java | 2 + .../core-java-concurrency-testing/README.md | 7 -- .../core-java-concurrency-testing/pom.xml | 93 ------------------- .../src/main/resources/logback.xml | 19 ---- .../src/test/resources/.gitignore | 13 --- 12 files changed, 90 insertions(+), 135 deletions(-) rename core-java-modules/{core-java-concurrency-testing => core-java-concurrency-2}/src/main/java/com/baeldung/concurrent/MyCounter.java (100%) rename core-java-modules/{core-java-concurrency-testing => core-java-concurrency-2}/src/test/java/com/baeldung/concurrent/MyCounterJCStressUnitTest.java (100%) rename core-java-modules/{core-java-concurrency-testing => core-java-concurrency-2}/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCUnitTest.java (90%) rename core-java-modules/{core-java-concurrency-testing => core-java-concurrency-2}/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java (96%) rename core-java-modules/{core-java-concurrency-testing => core-java-concurrency-2}/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java (96%) rename core-java-modules/{core-java-concurrency-testing => core-java-concurrency-2}/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java (96%) delete mode 100644 core-java-modules/core-java-concurrency-testing/README.md delete mode 100644 core-java-modules/core-java-concurrency-testing/pom.xml delete mode 100644 core-java-modules/core-java-concurrency-testing/src/main/resources/logback.xml delete mode 100644 core-java-modules/core-java-concurrency-testing/src/test/resources/.gitignore diff --git a/core-java-modules/core-java-concurrency-2/README.md b/core-java-modules/core-java-concurrency-2/README.md index 749d174968..ab7eebc26a 100644 --- a/core-java-modules/core-java-concurrency-2/README.md +++ b/core-java-modules/core-java-concurrency-2/README.md @@ -4,4 +4,5 @@ ### Relevant Articles: - [Using a Mutex Object in Java](https://www.baeldung.com/java-mutex) +- [Testing Multi-Threaded Code in Java] (https://www.baeldung.com/java-testing-multithreaded) diff --git a/core-java-modules/core-java-concurrency-2/pom.xml b/core-java-modules/core-java-concurrency-2/pom.xml index a9a01b70f3..dfb5674c8e 100644 --- a/core-java-modules/core-java-concurrency-2/pom.xml +++ b/core-java-modules/core-java-concurrency-2/pom.xml @@ -15,6 +15,38 @@ 0.0.1-SNAPSHOT ../../parent-java + + + + junit + junit + 4.13 + test + + + com.googlecode.thread-weaver + threadweaver + 0.2 + test + + + com.google.code.tempus-fugit + tempus-fugit + 1.1 + test + + + com.googlecode.multithreadedtc + multithreadedtc + 1.01 + test + + + org.openjdk.jcstress + jcstress-core + 0.5 + + core-java-concurrency-2 @@ -24,6 +56,51 @@ true + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + ${javac.target} + ${javac.target} + ${javac.target} + + + + + org.apache.maven.plugins + maven-shade-plugin + 2.2 + + + main + package + + shade + + + jcstress + + + org.openjdk.jcstress.Main + + + META-INF/TestList + + + + + + + + + + 1.8 + diff --git a/core-java-modules/core-java-concurrency-testing/src/main/java/com/baeldung/concurrent/MyCounter.java b/core-java-modules/core-java-concurrency-2/src/main/java/com/baeldung/concurrent/MyCounter.java similarity index 100% rename from core-java-modules/core-java-concurrency-testing/src/main/java/com/baeldung/concurrent/MyCounter.java rename to core-java-modules/core-java-concurrency-2/src/main/java/com/baeldung/concurrent/MyCounter.java diff --git a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterJCStressUnitTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterJCStressUnitTest.java similarity index 100% rename from core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterJCStressUnitTest.java rename to core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterJCStressUnitTest.java diff --git a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCUnitTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCUnitTest.java similarity index 90% rename from core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCUnitTest.java rename to core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCUnitTest.java index eb4e77cae9..8a0bedf6c2 100644 --- a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCUnitTest.java +++ b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterMultithreadedTCUnitTest.java @@ -1,5 +1,6 @@ package com.baeldung.concurrent; +import org.junit.Ignore; import org.junit.Test; import edu.umd.cs.mtc.MultithreadedTestCase; @@ -25,9 +26,10 @@ public class MyCounterMultithreadedTCUnitTest extends MultithreadedTestCase { @SuppressWarnings("deprecation") @Override public void finish() { - assertEquals(2, counter.getCount()); + assertEquals(2, counter.getCount()); } + @Ignore @Test public void testCounter() throws Throwable { TestFramework.runManyTimes(new MyCounterMultithreadedTCUnitTest(), 1000); diff --git a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java similarity index 96% rename from core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java rename to core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java index 4f3409b923..9a405e7e24 100644 --- a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java +++ b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterSimpleUnitTest.java @@ -6,6 +6,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import org.junit.Ignore; import org.junit.Test; public class MyCounterSimpleUnitTest { @@ -18,7 +19,8 @@ public class MyCounterSimpleUnitTest { assertEquals(500, counter.getCount()); } - // @Test + @Ignore + @Test public void testCounterWithConcurrency() throws InterruptedException { int numberOfThreads = 100; ExecutorService service = Executors.newFixedThreadPool(10); @@ -34,7 +36,8 @@ public class MyCounterSimpleUnitTest { assertEquals(numberOfThreads, counter.getCount()); } - // @Test + @Ignore + @Test public void testSummationWithConcurrencyAndWait() throws InterruptedException { int numberOfThreads = 2; ExecutorService service = Executors.newFixedThreadPool(10); diff --git a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java similarity index 96% rename from core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java rename to core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java index 360c61b4f4..36a2031e78 100644 --- a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java +++ b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterTempusFugitUnitTest.java @@ -3,6 +3,7 @@ package com.baeldung.concurrent; import static org.junit.Assert.assertEquals; import org.junit.AfterClass; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; @@ -20,6 +21,7 @@ public class MyCounterTempusFugitUnitTest { private static MyCounter counter = new MyCounter(); + @Ignore @Test @Concurrent(count = 2) @Repeating(repetition = 10) diff --git a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java similarity index 96% rename from core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java rename to core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java index 29b08996cd..e65a963584 100644 --- a/core-java-modules/core-java-concurrency-testing/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java +++ b/core-java-modules/core-java-concurrency-2/src/test/java/com/baeldung/concurrent/MyCounterThreadWeaverUnitTest.java @@ -2,6 +2,7 @@ package com.baeldung.concurrent; import static org.junit.Assert.assertEquals; +import org.junit.Ignore; import org.junit.Test; import com.google.testing.threadtester.AnnotatedTestRunner; @@ -34,6 +35,7 @@ public class MyCounterThreadWeaverUnitTest { assertEquals(2, counter.getCount()); } + @Ignore @Test public void testCounter() { new AnnotatedTestRunner().runTests(this.getClass(), MyCounter.class); diff --git a/core-java-modules/core-java-concurrency-testing/README.md b/core-java-modules/core-java-concurrency-testing/README.md deleted file mode 100644 index fef74a6750..0000000000 --- a/core-java-modules/core-java-concurrency-testing/README.md +++ /dev/null @@ -1,7 +0,0 @@ -========= - -## Core Java Concurrency Testing Examples - -### Relevant Articles: -- [Testing Multi-Threaded Code in Java](https://www.baeldung.com/java-testing-multithreaded) - diff --git a/core-java-modules/core-java-concurrency-testing/pom.xml b/core-java-modules/core-java-concurrency-testing/pom.xml deleted file mode 100644 index 51de83f67c..0000000000 --- a/core-java-modules/core-java-concurrency-testing/pom.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - 4.0.0 - core-java-concurrency-testing - 0.1.0-SNAPSHOT - core-java-concurrency-testing - jar - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../../parent-java - - - - - junit - junit - 4.13 - test - - - com.googlecode.thread-weaver - threadweaver - 0.2 - test - - - com.google.code.tempus-fugit - tempus-fugit - 1.1 - test - - - com.googlecode.multithreadedtc - multithreadedtc - 1.01 - test - - - org.openjdk.jcstress - jcstress-core - 0.5 - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - ${javac.target} - ${javac.target} - ${javac.target} - - - - - org.apache.maven.plugins - maven-shade-plugin - 2.2 - - - main - package - - shade - - - jcstress - - - org.openjdk.jcstress.Main - - - META-INF/TestList - - - - - - - - - - diff --git a/core-java-modules/core-java-concurrency-testing/src/main/resources/logback.xml b/core-java-modules/core-java-concurrency-testing/src/main/resources/logback.xml deleted file mode 100644 index 56af2d397e..0000000000 --- a/core-java-modules/core-java-concurrency-testing/src/main/resources/logback.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - - - - - \ No newline at end of file diff --git a/core-java-modules/core-java-concurrency-testing/src/test/resources/.gitignore b/core-java-modules/core-java-concurrency-testing/src/test/resources/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/core-java-modules/core-java-concurrency-testing/src/test/resources/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file From 41a9f46cad51b12d57b8ecd815cc5dcb769f23b7 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Tue, 28 Apr 2020 07:49:49 +0200 Subject: [PATCH 356/503] [JAVA-616] Fixed link to article by using HTTPS --- core-java-modules/core-java-arrays-sorting/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-arrays-sorting/README.md b/core-java-modules/core-java-arrays-sorting/README.md index f83dd43526..dedc0340c0 100644 --- a/core-java-modules/core-java-arrays-sorting/README.md +++ b/core-java-modules/core-java-arrays-sorting/README.md @@ -5,5 +5,5 @@ This module contains articles about sorting arrays in Java ### Relevant Articles: - [Sorting Arrays in Java](https://www.baeldung.com/java-sorting-arrays) - [Checking If an Array Is Sorted in Java](https://www.baeldung.com/java-check-sorted-array) -- [How to Reverse an Array in Java](http://www.baeldung.com/java-invert-array) +- [How to Reverse an Array in Java](https://www.baeldung.com/java-invert-array) - [Arrays.sort vs Arrays.parallelSort](https://www.baeldung.com/java-arrays-sort-vs-parallelsort) From 5e1b86e79e2f6ad3898198b5ced790eb054e7d5b Mon Sep 17 00:00:00 2001 From: dupirefr Date: Tue, 28 Apr 2020 07:55:51 +0200 Subject: [PATCH 357/503] [JAVA-630] Fixing indent of vavr* modules --- pom.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index f2c23a94ae..2f4579c999 100644 --- a/pom.xml +++ b/pom.xml @@ -813,8 +813,8 @@ libraries vaadin - vavr - vavr-2 + vavr + vavr-2 @@ -1313,12 +1313,12 @@ libraries vaadin - vavr - vavr-2 + vavr + vavr-2 - + live-all @@ -1342,7 +1342,7 @@ - + From e25ce92d5ed5a00e32f136a6f5f7b575495484cd Mon Sep 17 00:00:00 2001 From: dupirefr Date: Thu, 2 Apr 2020 20:51:41 +0200 Subject: [PATCH 358/503] [JAVA-621] Creating core-java-lang-oop-modules module --- .../core-java-lang-oop-modules/pom.xml | 15 +++++++++++++++ core-java-modules/pom.xml | 1 + 2 files changed, 16 insertions(+) create mode 100644 core-java-modules/core-java-lang-oop-modules/pom.xml diff --git a/core-java-modules/core-java-lang-oop-modules/pom.xml b/core-java-modules/core-java-lang-oop-modules/pom.xml new file mode 100644 index 0000000000..0e7e474258 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/pom.xml @@ -0,0 +1,15 @@ + + + + core-java-modules + com.baeldung.core-java-modules + 1.0.0-SNAPSHOT + + 4.0.0 + + core-java-oop-modules + + + \ No newline at end of file diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index b7454cc737..4d64f7e6ba 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -85,6 +85,7 @@ core-java-lang-2 core-java-lang-math core-java-lang-math-2 + core-java-lang-oop-modules core-java-lang-oop core-java-lang-oop-2 core-java-lang-oop-3 From 117cb9ce46e33a664bc383f757b9208274527875 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Thu, 2 Apr 2020 21:04:24 +0200 Subject: [PATCH 359/503] [JAVA-621] core-java-lang-oop-constructors module * Creation * Moved code from https://www.baeldung.com/java-constructors * Moved code from https://www.baeldung.com/java-copy-constructor * Moved code from https://www.baeldung.com/java-cannot-reference-x-before-supertype-constructor-error * Moved article references to the new README.md --- .../core-java-lang-oop-2/README.md | 3 -- .../core-java-lang-oop-constructors/README.md | 8 ++++++ .../core-java-lang-oop-constructors/pom.xml | 28 +++++++++++++++++++ .../baeldung/constructors/BankAccount.java | 7 ++--- .../baeldung/constructors/Transaction.java | 0 .../baeldung/copyconstructor/Employee.java | 0 .../com/baeldung/copyconstructor/Manager.java | 0 .../supertypecompilerexception/MyClass.java | 0 .../MyClassSolution1.java | 0 .../MyClassSolution2.java | 0 .../MyClassSolution3.java | 0 .../MyException.java | 0 .../constructors/ConstructorUnitTest.java | 13 ++++----- .../copyconstructor/EmployeeUnitTest.java | 0 .../copyconstructor/ManagerUnitTest.java | 0 .../core-java-lang-oop-modules/pom.xml | 9 ++++-- 16 files changed, 52 insertions(+), 16 deletions(-) create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/README.md create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/pom.xml rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-constructors}/src/main/java/com/baeldung/constructors/BankAccount.java (99%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-constructors}/src/main/java/com/baeldung/constructors/Transaction.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-constructors}/src/main/java/com/baeldung/copyconstructor/Employee.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-constructors}/src/main/java/com/baeldung/copyconstructor/Manager.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-constructors}/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-constructors}/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-constructors}/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-constructors}/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-constructors}/src/main/java/com/baeldung/supertypecompilerexception/MyException.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-constructors}/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java (88%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-constructors}/src/test/java/com/baeldung/copyconstructor/EmployeeUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-constructors}/src/test/java/com/baeldung/copyconstructor/ManagerUnitTest.java (100%) diff --git a/core-java-modules/core-java-lang-oop-2/README.md b/core-java-modules/core-java-lang-oop-2/README.md index c48a3f5cd9..fc5b5944f8 100644 --- a/core-java-modules/core-java-lang-oop-2/README.md +++ b/core-java-modules/core-java-lang-oop-2/README.md @@ -4,15 +4,12 @@ This module contains articles about Object-oriented programming (OOP) in Java ### Relevant Articles: - [Generic Constructors in Java](https://www.baeldung.com/java-generic-constructors) -- [Cannot Reference “X” Before Supertype Constructor Has Been Called](https://www.baeldung.com/java-cannot-reference-x-before-supertype-constructor-error) - [Anonymous Classes in Java](https://www.baeldung.com/java-anonymous-classes) - [Raw Types in Java](https://www.baeldung.com/raw-types-java) - [Marker Interfaces in Java](https://www.baeldung.com/java-marker-interfaces) - [Java equals() and hashCode() Contracts](https://www.baeldung.com/java-equals-hashcode-contracts) - [Immutable Objects in Java](https://www.baeldung.com/java-immutable-object) - [Inheritance and Composition (Is-a vs Has-a relationship) in Java](https://www.baeldung.com/java-inheritance-composition) -- [A Guide to Constructors in Java](https://www.baeldung.com/java-constructors) - [Static and Default Methods in Interfaces in Java](https://www.baeldung.com/java-static-default-methods) -- [Java Copy Constructor](https://www.baeldung.com/java-copy-constructor) - [Abstract Classes in Java](https://www.baeldung.com/java-abstract-class) - [[<-- Prev]](/core-java-modules/core-java-lang-oop)[[More -->]](/core-java-modules/core-java-lang-oop-3) diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/README.md b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/README.md new file mode 100644 index 0000000000..0082969807 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/README.md @@ -0,0 +1,8 @@ +## Core Java Lang OOP - Constructors + +This module contains article about constructors in Java + +### Relevant Articles: +- [A Guide to Constructors in Java](https://www.baeldung.com/java-constructors) +- [Java Copy Constructor](https://www.baeldung.com/java-copy-constructor) +- [Cannot Reference “X” Before Supertype Constructor Has Been Called](https://www.baeldung.com/java-cannot-reference-x-before-supertype-constructor-error) \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/pom.xml b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/pom.xml new file mode 100644 index 0000000000..e961d68f11 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/pom.xml @@ -0,0 +1,28 @@ + + + + core-java-lang-oop-modules + com.baeldung.core-java-lang-oop-modules + 1.0.0-SNAPSHOT + + 4.0.0 + + core-java-lang-oop-constructors + core-java-lang-oop-constructors + jar + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + + + 3.10.0 + + \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/constructors/BankAccount.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/BankAccount.java similarity index 99% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/constructors/BankAccount.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/BankAccount.java index b78b5937e1..b198492129 100644 --- a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/constructors/BankAccount.java +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/BankAccount.java @@ -6,7 +6,7 @@ class BankAccount { String name; LocalDateTime opened; double balance; - + @Override public String toString() { return String.format("%s, %s, %f", this.name, this.opened.toString(), this.balance); @@ -47,14 +47,13 @@ class BankAccountCopyConstructor extends BankAccount { this.opened = opened; this.balance = balance; } - + public BankAccountCopyConstructor(BankAccount other) { this.name = other.name; this.opened = LocalDateTime.now(); this.balance = 0.0f; } } - class BankAccountChainedConstructors extends BankAccount { public BankAccountChainedConstructors(String name, LocalDateTime opened, double balance) { this.name = name; @@ -65,4 +64,4 @@ class BankAccountChainedConstructors extends BankAccount { public BankAccountChainedConstructors(String name) { this(name, LocalDateTime.now(), 0.0f); } -} +} \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/constructors/Transaction.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/Transaction.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/constructors/Transaction.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/Transaction.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/copyconstructor/Employee.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Employee.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/copyconstructor/Employee.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Employee.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/copyconstructor/Manager.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Manager.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/copyconstructor/Manager.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Manager.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyException.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyException.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/supertypecompilerexception/MyException.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyException.java diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java similarity index 88% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java index 274fe77764..e207afec57 100644 --- a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java @@ -1,20 +1,19 @@ package com.baeldung.constructors; +import org.assertj.core.api.Assertions; import org.junit.Test; import java.time.LocalDateTime; import java.time.Month; -import java.util.logging.Logger; -import static org.assertj.core.api.Assertions.*; +import static org.assertj.core.api.Assertions.assertThat; public class ConstructorUnitTest { - final static Logger LOGGER = Logger.getLogger(ConstructorUnitTest.class.getName()); - + @Test public void givenNoExplicitContructor_whenUsed_thenFails() { BankAccount account = new BankAccount(); - assertThatThrownBy(() -> { + Assertions.assertThatThrownBy(() -> { account.toString(); }).isInstanceOf(Exception.class); } @@ -22,7 +21,7 @@ public class ConstructorUnitTest { @Test public void givenNoArgumentConstructor_whenUsed_thenSucceeds() { BankAccountEmptyConstructor account = new BankAccountEmptyConstructor(); - assertThatCode(() -> { + Assertions.assertThatCode(() -> { account.toString(); }).doesNotThrowAnyException(); } @@ -33,7 +32,7 @@ public class ConstructorUnitTest { BankAccountParameterizedConstructor account = new BankAccountParameterizedConstructor("Tom", opened, 1000.0f); - assertThatCode(() -> { + Assertions.assertThatCode(() -> { account.toString(); }).doesNotThrowAnyException(); } diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/copyconstructor/EmployeeUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/EmployeeUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/copyconstructor/EmployeeUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/EmployeeUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/copyconstructor/ManagerUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/ManagerUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/copyconstructor/ManagerUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/ManagerUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/pom.xml b/core-java-modules/core-java-lang-oop-modules/pom.xml index 0e7e474258..c8bad11b13 100644 --- a/core-java-modules/core-java-lang-oop-modules/pom.xml +++ b/core-java-modules/core-java-lang-oop-modules/pom.xml @@ -9,7 +9,12 @@ 4.0.0 - core-java-oop-modules - + com.baeldung.core-java-lang-oop-modules + core-java-lang-oop-modules + core-java-lang-oop-modules + pom + + core-java-lang-oop-constructors + \ No newline at end of file From c0169519adf7520da194b19b224beca25430e84e Mon Sep 17 00:00:00 2001 From: dupirefr Date: Thu, 2 Apr 2020 21:24:31 +0200 Subject: [PATCH 360/503] [JAVA-621] core-java-lang-oop-patterns module * Creation * Moved code from https://www.baeldung.com/java-composition-aggregation-association * Moved code from https://www.baeldung.com/java-inheritance-composition * Moved code from https://www.baeldung.com/java-immutable-object * Moved code from https://www.baeldung.com/java-deep-copy * Moved article references to the new README.md --- .../core-java-lang-oop-2/README.md | 2 - .../core-java-lang-oop-3/README.md | 1 - .../core-java-lang-oop-patterns/README.md | 9 ++++ .../core-java-lang-oop-patterns/pom.xml | 45 +++++++++++++++++++ .../java/com/baeldung/deepcopy/Address.java | 0 .../main/java/com/baeldung/deepcopy/User.java | 0 .../baeldung/immutableobjects/Currency.java | 0 .../com/baeldung/immutableobjects/Money.java | 0 .../application/Application.java | 0 .../inheritancecomposition/model/Actress.java | 0 .../model/Computer.java | 0 .../inheritancecomposition/model/Memory.java | 0 .../inheritancecomposition/model/Person.java | 0 .../model/Processor.java | 0 .../model/SoundCard.java | 0 .../model/StandardMemory.java | 0 .../model/StandardProcessor.java | 0 .../model/StandardSoundCard.java | 0 .../model/Waitress.java | 0 .../relationships/aggregation/Car.java | 0 .../aggregation/CarWithStaticInnerWheel.java | 0 .../relationships/aggregation/Wheel.java | 0 .../relationships/association/Child.java | 0 .../relationships/association/Mother.java | 0 .../relationships/composition/Building.java | 0 .../BuildingWithDefinitionRoomInMethod.java | 0 .../relationships/university/Department.java | 0 .../relationships/university/Professor.java | 0 .../relationships/university/University.java | 0 .../baeldung/deepcopy/DeepCopyUnitTest.java | 0 .../deepcopy/ShallowCopyUnitTest.java | 0 .../ImmutableObjectsUnitTest.java | 0 .../ActressUnitTest.java | 0 .../CompositionUnitTest.java | 0 .../InheritanceUnitTest.java | 0 .../PersonUnitTest.java | 0 .../WaitressUnitTest.java | 0 .../core-java-lang-oop-modules/pom.xml | 1 + 38 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/README.md create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/pom.xml rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/deepcopy/Address.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/deepcopy/User.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/immutableobjects/Currency.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/immutableobjects/Money.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/inheritancecomposition/application/Application.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/inheritancecomposition/model/Person.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/relationships/aggregation/Car.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/relationships/aggregation/CarWithStaticInnerWheel.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/relationships/aggregation/Wheel.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/relationships/association/Child.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/relationships/association/Mother.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/relationships/composition/Building.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/relationships/composition/BuildingWithDefinitionRoomInMethod.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/relationships/university/Department.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/relationships/university/Professor.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/main/java/com/baeldung/relationships/university/University.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/test/java/com/baeldung/inheritancecomposition/ActressUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/test/java/com/baeldung/inheritancecomposition/CompositionUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/test/java/com/baeldung/inheritancecomposition/InheritanceUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/test/java/com/baeldung/inheritancecomposition/PersonUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-patterns}/src/test/java/com/baeldung/inheritancecomposition/WaitressUnitTest.java (100%) diff --git a/core-java-modules/core-java-lang-oop-2/README.md b/core-java-modules/core-java-lang-oop-2/README.md index fc5b5944f8..d482b0a78d 100644 --- a/core-java-modules/core-java-lang-oop-2/README.md +++ b/core-java-modules/core-java-lang-oop-2/README.md @@ -8,8 +8,6 @@ This module contains articles about Object-oriented programming (OOP) in Java - [Raw Types in Java](https://www.baeldung.com/raw-types-java) - [Marker Interfaces in Java](https://www.baeldung.com/java-marker-interfaces) - [Java equals() and hashCode() Contracts](https://www.baeldung.com/java-equals-hashcode-contracts) -- [Immutable Objects in Java](https://www.baeldung.com/java-immutable-object) -- [Inheritance and Composition (Is-a vs Has-a relationship) in Java](https://www.baeldung.com/java-inheritance-composition) - [Static and Default Methods in Interfaces in Java](https://www.baeldung.com/java-static-default-methods) - [Abstract Classes in Java](https://www.baeldung.com/java-abstract-class) - [[<-- Prev]](/core-java-modules/core-java-lang-oop)[[More -->]](/core-java-modules/core-java-lang-oop-3) diff --git a/core-java-modules/core-java-lang-oop-3/README.md b/core-java-modules/core-java-lang-oop-3/README.md index 3a0e588ad4..78725b0f02 100644 --- a/core-java-modules/core-java-lang-oop-3/README.md +++ b/core-java-modules/core-java-lang-oop-3/README.md @@ -8,7 +8,6 @@ This module contains articles about Object-oriented programming (OOP) in Java - [Guide to the super Java Keyword](https://www.baeldung.com/java-super) - [Guide to the this Java Keyword](https://www.baeldung.com/java-this) - [Java ‘public’ Access Modifier](https://www.baeldung.com/java-public-keyword) -- [Composition, Aggregation, and Association in Java](https://www.baeldung.com/java-composition-aggregation-association) - [Nested Classes in Java](https://www.baeldung.com/java-nested-classes) - [A Guide to Inner Interfaces in Java](https://www.baeldung.com/java-inner-interfaces) - [Java Classes and Objects](https://www.baeldung.com/java-classes-objects) diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/README.md b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/README.md new file mode 100644 index 0000000000..178a556a96 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/README.md @@ -0,0 +1,9 @@ +## Core Java Lang OOP - Patterns + +This module contains articles about Object-oriented programming (OOP) patterns in Java + +### Relevant Articles: +- [Composition, Aggregation, and Association in Java](https://www.baeldung.com/java-composition-aggregation-association) +- [Inheritance and Composition (Is-a vs Has-a relationship) in Java](https://www.baeldung.com/java-inheritance-composition) +- [Immutable Objects in Java](https://www.baeldung.com/java-immutable-object) +- [How to Make a Deep Copy of an Object in Java](https://www.baeldung.com/java-deep-copy) diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/pom.xml b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/pom.xml new file mode 100644 index 0000000000..5bd3c70542 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/pom.xml @@ -0,0 +1,45 @@ + + + + core-java-lang-oop-modules + com.baeldung.core-java-lang-oop-modules + 1.0.0-SNAPSHOT + + 4.0.0 + + core-java-lang-oop-patterns + core-java-lang-oop-patterns + jar + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.google.code.gson + gson + ${gson.version} + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + + + 2.8.2 + 3.10.0 + + \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/deepcopy/Address.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/Address.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/deepcopy/Address.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/Address.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/deepcopy/User.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/User.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/deepcopy/User.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/User.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/immutableobjects/Currency.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Currency.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/immutableobjects/Currency.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Currency.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/immutableobjects/Money.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Money.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/immutableobjects/Money.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Money.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/application/Application.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/application/Application.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/application/Application.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/application/Application.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Person.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Person.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Person.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Person.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/aggregation/Car.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Car.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/aggregation/Car.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Car.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/aggregation/CarWithStaticInnerWheel.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/CarWithStaticInnerWheel.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/aggregation/CarWithStaticInnerWheel.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/CarWithStaticInnerWheel.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/aggregation/Wheel.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Wheel.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/aggregation/Wheel.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Wheel.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/association/Child.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Child.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/association/Child.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Child.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/association/Mother.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Mother.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/association/Mother.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Mother.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/composition/Building.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/Building.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/composition/Building.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/Building.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/composition/BuildingWithDefinitionRoomInMethod.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/BuildingWithDefinitionRoomInMethod.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/composition/BuildingWithDefinitionRoomInMethod.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/BuildingWithDefinitionRoomInMethod.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/university/Department.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Department.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/university/Department.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Department.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/university/Professor.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Professor.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/university/Professor.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Professor.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/university/University.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/University.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/relationships/university/University.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/University.java diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/ActressUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/ActressUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/ActressUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/ActressUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/CompositionUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/CompositionUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/CompositionUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/CompositionUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/InheritanceUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/InheritanceUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/InheritanceUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/InheritanceUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/PersonUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/PersonUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/PersonUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/PersonUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/WaitressUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/WaitressUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/inheritancecomposition/WaitressUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/WaitressUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/pom.xml b/core-java-modules/core-java-lang-oop-modules/pom.xml index c8bad11b13..ad86c1ef3c 100644 --- a/core-java-modules/core-java-lang-oop-modules/pom.xml +++ b/core-java-modules/core-java-lang-oop-modules/pom.xml @@ -16,5 +16,6 @@ core-java-lang-oop-constructors + core-java-lang-oop-patterns \ No newline at end of file From f23c60568c93f773dfa4d23cf86e218244b05217 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sat, 4 Apr 2020 09:29:47 +0200 Subject: [PATCH 361/503] [JAVA-621] core-java-lang-oop-generics module * Creation * Moved code from https://www.baeldung.com/raw-types-java * Moved code from https://www.baeldung.com/java-generic-constructors * Moved code from https://www.baeldung.com/java-type-erasure * Moved article references to the new README.md --- core-java-modules/core-java-lang-oop-2/README.md | 2 -- .../core-java-lang-oop-generics/README.md | 8 ++++++++ .../core-java-lang-oop-generics/pom.xml | 16 ++++++++++++++++ .../main/java/com/baeldung/generics/Entry.java | 0 .../java/com/baeldung/generics/GenericEntry.java | 0 .../java/com/baeldung/generics/MapEntry.java | 0 .../main/java/com/baeldung/generics/Product.java | 0 .../java/com/baeldung/generics/Rankable.java | 0 .../java/com/baeldung/rawtype/RawTypeDemo.java | 0 .../typeerasure/ArrayContentPrintUtil.java | 0 .../com/baeldung/typeerasure/BoundStack.java | 0 .../com/baeldung/typeerasure/IntegerStack.java | 0 .../java/com/baeldung/typeerasure/Stack.java | 0 .../generics/GenericConstructorUnitTest.java | 0 .../typeerasure/TypeErasureUnitTest.java | 0 .../core-java-lang-oop-modules/pom.xml | 1 + 16 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/README.md create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/pom.xml rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-generics}/src/main/java/com/baeldung/generics/Entry.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-generics}/src/main/java/com/baeldung/generics/GenericEntry.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-generics}/src/main/java/com/baeldung/generics/MapEntry.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-generics}/src/main/java/com/baeldung/generics/Product.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-generics}/src/main/java/com/baeldung/generics/Rankable.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-generics}/src/main/java/com/baeldung/rawtype/RawTypeDemo.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-generics}/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-generics}/src/main/java/com/baeldung/typeerasure/BoundStack.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-generics}/src/main/java/com/baeldung/typeerasure/IntegerStack.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-generics}/src/main/java/com/baeldung/typeerasure/Stack.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-generics}/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-generics}/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java (100%) diff --git a/core-java-modules/core-java-lang-oop-2/README.md b/core-java-modules/core-java-lang-oop-2/README.md index d482b0a78d..8417c89c7a 100644 --- a/core-java-modules/core-java-lang-oop-2/README.md +++ b/core-java-modules/core-java-lang-oop-2/README.md @@ -3,9 +3,7 @@ This module contains articles about Object-oriented programming (OOP) in Java ### Relevant Articles: -- [Generic Constructors in Java](https://www.baeldung.com/java-generic-constructors) - [Anonymous Classes in Java](https://www.baeldung.com/java-anonymous-classes) -- [Raw Types in Java](https://www.baeldung.com/raw-types-java) - [Marker Interfaces in Java](https://www.baeldung.com/java-marker-interfaces) - [Java equals() and hashCode() Contracts](https://www.baeldung.com/java-equals-hashcode-contracts) - [Static and Default Methods in Interfaces in Java](https://www.baeldung.com/java-static-default-methods) diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/README.md b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/README.md new file mode 100644 index 0000000000..f0213c5659 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/README.md @@ -0,0 +1,8 @@ +## Core Java Lang OOP - Generics + +This module contains articles about generics in Java + +### Relevant Articles: +- [Generic Constructors in Java](https://www.baeldung.com/java-generic-constructors) +- [Type Erasure in Java Explained](https://www.baeldung.com/java-type-erasure) +- [Raw Types in Java](https://www.baeldung.com/raw-types-java) diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/pom.xml b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/pom.xml new file mode 100644 index 0000000000..167aa695e0 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/pom.xml @@ -0,0 +1,16 @@ + + + + core-java-lang-oop-modules + com.baeldung.core-java-lang-oop-modules + 1.0.0-SNAPSHOT + + 4.0.0 + + core-java-lang-oop-generics + core-java-lang-oop-generics + jar + + \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Entry.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Entry.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Entry.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Entry.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/GenericEntry.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/GenericEntry.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/GenericEntry.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/GenericEntry.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/MapEntry.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/MapEntry.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/MapEntry.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/MapEntry.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Product.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Product.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Product.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Product.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Rankable.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Rankable.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/generics/Rankable.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Rankable.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/rawtype/RawTypeDemo.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/rawtype/RawTypeDemo.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/rawtype/RawTypeDemo.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/rawtype/RawTypeDemo.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/BoundStack.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/BoundStack.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/BoundStack.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/BoundStack.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/IntegerStack.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/IntegerStack.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/IntegerStack.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/IntegerStack.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/Stack.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/Stack.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/typeerasure/Stack.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/Stack.java diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/pom.xml b/core-java-modules/core-java-lang-oop-modules/pom.xml index ad86c1ef3c..c32e276a89 100644 --- a/core-java-modules/core-java-lang-oop-modules/pom.xml +++ b/core-java-modules/core-java-lang-oop-modules/pom.xml @@ -17,5 +17,6 @@ core-java-lang-oop-constructors core-java-lang-oop-patterns + core-java-lang-oop-generics \ No newline at end of file From 1ddd56978bb4af967f2b0c5d6e1bcb0e1146179e Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sat, 4 Apr 2020 09:42:08 +0200 Subject: [PATCH 362/503] [JAVA-621] core-java-lang-oop-modifiers module * Creation * Moved code from https://www.baeldung.com/java-static * Moved code from https://www.baeldung.com/java-final * Moved code from https://www.baeldung.com/java-public-keyword * Moved code from https://www.baeldung.com/java-access-modifiers * Moved code from https://www.baeldung.com/java-private-keyword * Moved code from https://www.baeldung.com/java-static-default-methods * Moved code from https://www.baeldung.com/java-strictfp * Moved article references to the new README.md --- .../core-java-lang-oop-2/README.md | 3 -- .../core-java-lang-oop-3/README.md | 2 -- .../core-java-lang-oop-modifiers/README.md | 12 +++++++ .../core-java-lang-oop-modifiers/pom.xml | 34 +++++++++++++++++++ .../com/baeldung/accessmodifiers/Public.java | 0 .../baeldung/accessmodifiers/SubClass.java | 0 .../baeldung/accessmodifiers/SuperPublic.java | 0 .../another/AnotherPublic.java | 0 .../another/AnotherSubClass.java | 0 .../another/AnotherSuperPublic.java | 0 .../publicmodifier/ListOfThree.java | 0 .../publicmodifier/SpecialCharacters.java | 0 .../publicmodifier/Student.java | 0 .../core/privatemodifier/Employee.java | 0 .../core/privatemodifier/ExampleClass.java | 0 .../privatemodifier/PublicOuterClass.java | 0 .../application/Application.java | 0 .../model/Alarm.java | 0 .../model/Car.java | 0 .../model/Motorbike.java | 0 .../model/MultiAlarmCar.java | 0 .../model/Vehicle.java | 0 .../com/baeldung/finalkeyword/BlackCat.java | 0 .../com/baeldung/finalkeyword/BlackDog.java | 0 .../java/com/baeldung/finalkeyword/Cat.java | 0 .../java/com/baeldung/finalkeyword/Dog.java | 0 .../java/com/baeldung/staticdemo/Car.java | 0 .../com/baeldung/staticdemo/Singleton.java | 0 .../com/baeldung/staticdemo/StaticBlock.java | 0 .../com/baeldung/strictfpUsage/Circle.java | 0 .../strictfpUsage/ScientificCalculator.java | 0 .../PublicAccessModifierUnitTest.java | 2 +- .../StaticDefaulInterfaceMethodUnitTest.java | 2 +- .../baeldung/finalkeyword/FinalUnitTest.java | 0 .../com/baeldung/staticdemo/CarUnitTest.java} | 2 +- .../staticdemo/SingletonUnitTest.java} | 2 +- .../staticdemo/StaticBlockUnitTest.java} | 2 +- .../ScientificCalculatorUnitTest.java | 0 .../core-java-lang-oop-modules/pom.xml | 1 + .../core-java-lang-oop/README.md | 2 -- 40 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/README.md create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/pom.xml rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/accessmodifiers/Public.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/accessmodifiers/SubClass.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/accessmodifiers/publicmodifier/ListOfThree.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/accessmodifiers/publicmodifier/SpecialCharacters.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/accessmodifiers/publicmodifier/Student.java (100%) rename core-java-modules/{core-java-lang-oop-4 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/core/privatemodifier/Employee.java (100%) rename core-java-modules/{core-java-lang-oop-4 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/core/privatemodifier/ExampleClass.java (100%) rename core-java-modules/{core-java-lang-oop-4 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/core/privatemodifier/PublicOuterClass.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/finalkeyword/BlackCat.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/finalkeyword/BlackDog.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/finalkeyword/Cat.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/finalkeyword/Dog.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/staticdemo/Car.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/staticdemo/Singleton.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/staticdemo/StaticBlock.java (100%) rename core-java-modules/{core-java-lang-oop-4 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/strictfpUsage/Circle.java (100%) rename core-java-modules/{core-java-lang-oop-4 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/main/java/com/baeldung/strictfpUsage/ScientificCalculator.java (100%) rename core-java-modules/{core-java-lang-oop-3/src/test/java/com/baeldung/accessmodifiers => core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/accessmodifiers/publicmodifier}/PublicAccessModifierUnitTest.java (98%) rename core-java-modules/{core-java-lang-oop-2/src/test/java/com/baeldung/defaultistaticinterfacemethods => core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods}/test/StaticDefaulInterfaceMethodUnitTest.java (97%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java => core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/CarUnitTest.java} (89%) rename core-java-modules/{core-java-lang-oop/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java => core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/SingletonUnitTest.java} (90%) rename core-java-modules/{core-java-lang-oop/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java => core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/StaticBlockUnitTest.java} (91%) rename core-java-modules/{core-java-lang-oop-4 => core-java-lang-oop-modules/core-java-lang-oop-modifiers}/src/test/java/com/baeldung/strictfpUsage/ScientificCalculatorUnitTest.java (100%) diff --git a/core-java-modules/core-java-lang-oop-2/README.md b/core-java-modules/core-java-lang-oop-2/README.md index 8417c89c7a..76da66c7ab 100644 --- a/core-java-modules/core-java-lang-oop-2/README.md +++ b/core-java-modules/core-java-lang-oop-2/README.md @@ -4,8 +4,5 @@ This module contains articles about Object-oriented programming (OOP) in Java ### Relevant Articles: - [Anonymous Classes in Java](https://www.baeldung.com/java-anonymous-classes) -- [Marker Interfaces in Java](https://www.baeldung.com/java-marker-interfaces) - [Java equals() and hashCode() Contracts](https://www.baeldung.com/java-equals-hashcode-contracts) -- [Static and Default Methods in Interfaces in Java](https://www.baeldung.com/java-static-default-methods) -- [Abstract Classes in Java](https://www.baeldung.com/java-abstract-class) - [[<-- Prev]](/core-java-modules/core-java-lang-oop)[[More -->]](/core-java-modules/core-java-lang-oop-3) diff --git a/core-java-modules/core-java-lang-oop-3/README.md b/core-java-modules/core-java-lang-oop-3/README.md index 78725b0f02..3b57ece635 100644 --- a/core-java-modules/core-java-lang-oop-3/README.md +++ b/core-java-modules/core-java-lang-oop-3/README.md @@ -4,10 +4,8 @@ This module contains articles about Object-oriented programming (OOP) in Java ### Relevant Articles: - [Pass-By-Value as a Parameter Passing Mechanism in Java](https://www.baeldung.com/java-pass-by-value-or-pass-by-reference) -- [Access Modifiers in Java](https://www.baeldung.com/java-access-modifiers) - [Guide to the super Java Keyword](https://www.baeldung.com/java-super) - [Guide to the this Java Keyword](https://www.baeldung.com/java-this) -- [Java ‘public’ Access Modifier](https://www.baeldung.com/java-public-keyword) - [Nested Classes in Java](https://www.baeldung.com/java-nested-classes) - [A Guide to Inner Interfaces in Java](https://www.baeldung.com/java-inner-interfaces) - [Java Classes and Objects](https://www.baeldung.com/java-classes-objects) diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/README.md b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/README.md new file mode 100644 index 0000000000..eef905fa0e --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/README.md @@ -0,0 +1,12 @@ +## Core Java Lang OOP - Modifiers + +This module contains articles about modifiers in Java + +### Relevant Articles: +- [Access Modifiers in Java](https://www.baeldung.com/java-access-modifiers) +- [Java ‘public’ Access Modifier](https://www.baeldung.com/java-public-keyword) +- [Java ‘private’ Access Modifier](https://www.baeldung.com/java-private-keyword) +- [The “final” Keyword in Java](https://www.baeldung.com/java-final) +- [A Guide to the Static Keyword in Java](https://www.baeldung.com/java-static) +- [Static and Default Methods in Interfaces in Java](https://www.baeldung.com/java-static-default-methods) +- [The strictfp Keyword in Java](https://www.baeldung.com/java-strictfp) \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/pom.xml b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/pom.xml new file mode 100644 index 0000000000..11e0296266 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/pom.xml @@ -0,0 +1,34 @@ + + + + core-java-lang-oop-modules + com.baeldung.core-java-lang-oop-modules + 1.0.0-SNAPSHOT + + 4.0.0 + + core-java-lang-oop-modifiers + core-java-lang-oop-modifiers + jar + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + com.h2database + h2 + ${h2.version} + test + + + + + 3.10.0 + + \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/Public.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/Public.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/Public.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/Public.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/SubClass.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SubClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/SubClass.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SubClass.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/publicmodifier/ListOfThree.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/ListOfThree.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/publicmodifier/ListOfThree.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/ListOfThree.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/publicmodifier/SpecialCharacters.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/SpecialCharacters.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/publicmodifier/SpecialCharacters.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/SpecialCharacters.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/publicmodifier/Student.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/Student.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/accessmodifiers/publicmodifier/Student.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/Student.java diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/core/privatemodifier/Employee.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/Employee.java similarity index 100% rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/core/privatemodifier/Employee.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/Employee.java diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/core/privatemodifier/ExampleClass.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/ExampleClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/core/privatemodifier/ExampleClass.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/ExampleClass.java diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/core/privatemodifier/PublicOuterClass.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/PublicOuterClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/core/privatemodifier/PublicOuterClass.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/PublicOuterClass.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackCat.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackCat.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackCat.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackCat.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackDog.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackDog.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/BlackDog.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackDog.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Cat.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Cat.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Cat.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Cat.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Dog.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Dog.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/finalkeyword/Dog.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Dog.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Car.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Car.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Car.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Car.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Singleton.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Singleton.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/Singleton.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Singleton.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/StaticBlock.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/StaticBlock.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/staticdemo/StaticBlock.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/StaticBlock.java diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/strictfpUsage/Circle.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/Circle.java similarity index 100% rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/strictfpUsage/Circle.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/Circle.java diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/strictfpUsage/ScientificCalculator.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/ScientificCalculator.java similarity index 100% rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/strictfpUsage/ScientificCalculator.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/ScientificCalculator.java diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/accessmodifiers/PublicAccessModifierUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/accessmodifiers/publicmodifier/PublicAccessModifierUnitTest.java similarity index 98% rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/accessmodifiers/PublicAccessModifierUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/accessmodifiers/publicmodifier/PublicAccessModifierUnitTest.java index ed8fb4f45a..c2897e7434 100644 --- a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/accessmodifiers/PublicAccessModifierUnitTest.java +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/accessmodifiers/publicmodifier/PublicAccessModifierUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.accessmodifiers; +package com.baeldung.accessmodifiers.publicmodifier; import com.baeldung.accessmodifiers.publicmodifier.ListOfThree; import com.baeldung.accessmodifiers.publicmodifier.Student; diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/defaultistaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java similarity index 97% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/defaultistaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java index 7d4b06908a..e90f239756 100644 --- a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/defaultistaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.defaultistaticinterfacemethods.test; +package com.baeldung.defaultstaticinterfacemethods.test; import com.baeldung.defaultstaticinterfacemethods.model.Car; import com.baeldung.defaultstaticinterfacemethods.model.Motorbike; diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/CarUnitTest.java similarity index 89% rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/CarUnitTest.java index 3150627269..3deec6f41c 100644 --- a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/CarIntegrationTest.java +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/CarUnitTest.java @@ -4,7 +4,7 @@ import static org.junit.Assert.*; import org.junit.Test; -public class CarIntegrationTest { +public class CarUnitTest { @Test public void whenNumberOfCarObjectsInitialized_thenStaticCounterIncreases() { new Car("Jaguar", "V8"); diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/SingletonUnitTest.java similarity index 90% rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/SingletonUnitTest.java index 28d864073a..c1a1e1abe4 100644 --- a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/SingletonIntegrationTest.java +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/SingletonUnitTest.java @@ -3,7 +3,7 @@ package com.baeldung.staticdemo; import org.junit.Assert; import org.junit.Test; -public class SingletonIntegrationTest { +public class SingletonUnitTest { @Test public void givenStaticInnerClass_whenMultipleTimesInstanceCalled_thenOnlyOneTimeInitialized() { diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/StaticBlockUnitTest.java similarity index 91% rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/StaticBlockUnitTest.java index f98e3e14db..79ba4427bf 100644 --- a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/staticdemo/StaticBlockIntegrationTest.java +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/StaticBlockUnitTest.java @@ -7,7 +7,7 @@ import java.util.List; import org.junit.Test; -public class StaticBlockIntegrationTest { +public class StaticBlockUnitTest { @Test public void whenAddedListElementsThroughStaticBlock_thenEnsureCorrectOrder() { diff --git a/core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/strictfpUsage/ScientificCalculatorUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/strictfpUsage/ScientificCalculatorUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/strictfpUsage/ScientificCalculatorUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/strictfpUsage/ScientificCalculatorUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/pom.xml b/core-java-modules/core-java-lang-oop-modules/pom.xml index c32e276a89..a77079bc06 100644 --- a/core-java-modules/core-java-lang-oop-modules/pom.xml +++ b/core-java-modules/core-java-lang-oop-modules/pom.xml @@ -18,5 +18,6 @@ core-java-lang-oop-constructors core-java-lang-oop-patterns core-java-lang-oop-generics + core-java-lang-oop-modifiers \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop/README.md b/core-java-modules/core-java-lang-oop/README.md index 2be3d0cab1..c09ed6048d 100644 --- a/core-java-modules/core-java-lang-oop/README.md +++ b/core-java-modules/core-java-lang-oop/README.md @@ -4,13 +4,11 @@ This module contains articles about Object-oriented programming (OOP) in Java ### Relevant Articles: - [Guide to hashCode() in Java](https://www.baeldung.com/java-hashcode) -- [A Guide to the Static Keyword in Java](https://www.baeldung.com/java-static) - [Polymorphism in Java](https://www.baeldung.com/java-polymorphism) - [Method Overloading and Overriding in Java](https://www.baeldung.com/java-method-overload-override) - [How to Make a Deep Copy of an Object in Java](https://www.baeldung.com/java-deep-copy) - [Guide to Inheritance in Java](https://www.baeldung.com/java-inheritance) - [Object Type Casting in Java](https://www.baeldung.com/java-type-casting) -- [The “final” Keyword in Java](https://www.baeldung.com/java-final) - [Type Erasure in Java Explained](https://www.baeldung.com/java-type-erasure) - [Variable and Method Hiding in Java](https://www.baeldung.com/java-variable-method-hiding) - [Object-Oriented-Programming Concepts in Java](https://www.baeldung.com/java-oop) From a6846bb1caa9f52e80141ca778c7561c5965ba35 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sat, 4 Apr 2020 10:18:15 +0200 Subject: [PATCH 363/503] [JAVA-621] core-java-lang-oop-types module * Creation * Moved code from https://www.baeldung.com/java-marker-interfaces * Moved code from https://www.baeldung.com/java-abstract-class * Moved code from https://www.baeldung.com/java-this * Moved code from https://www.baeldung.com/java-nested-classes * Moved code from https://www.baeldung.com/java-inner-interfaces * Moved code from https://www.baeldung.com/java-classes-objects * Moved article references to the new README.md --- .../core-java-lang-oop-3/README.md | 4 --- .../com/baeldung/keyword/KeywordDemo.java | 3 -- .../core-java-lang-oop-types/README.md | 11 ++++++++ .../core-java-lang-oop-types/pom.xml | 28 +++++++++++++++++++ .../application/Application.java | 0 .../filereaders/BaseFileReader.java | 0 .../filereaders/LowercaseFileReader.java | 0 .../filereaders/UppercaseFileReader.java | 0 .../CommaSeparatedCustomers.java | 0 .../baeldung/innerinterfaces/Customer.java | 0 .../keyword/thiskeyword/KeywordUnitTest.java | 0 .../markerinterface/DeletableShape.java | 0 .../baeldung/markerinterface/Rectangle.java | 0 .../com/baeldung/markerinterface/Shape.java | 0 .../baeldung/markerinterface/ShapeDao.java | 0 .../main/java/com/baeldung/objects/Car.java | 0 .../src/main/resources/files/test.txt | 10 +++++++ .../test/LowercaseFileReaderUnitTest.java | 0 .../test/UppercaseFileReaderUnitTest.java | 0 .../InnerInterfaceUnitTest.java | 0 .../MarkerInterfaceUnitTest.java | 0 .../baeldung/nestedclass/AnonymousInner.java | 0 .../com/baeldung/nestedclass/Enclosing.java | 0 .../baeldung/nestedclass/NewEnclosing.java | 0 .../com/baeldung/nestedclass/NewOuter.java | 0 .../java/com/baeldung/nestedclass/Outer.java | 0 .../com/baeldung/objects/ObjectsUnitTest.java | 0 .../core-java-lang-oop-modules/pom.xml | 1 + 28 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/README.md create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/pom.xml rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/main/java/com/baeldung/abstractclasses/application/Application.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/main/java/com/baeldung/innerinterfaces/Customer.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/main/java/com/baeldung/markerinterface/DeletableShape.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/main/java/com/baeldung/markerinterface/Rectangle.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/main/java/com/baeldung/markerinterface/Shape.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/main/java/com/baeldung/markerinterface/ShapeDao.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/main/java/com/baeldung/objects/Car.java (100%) create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/resources/files/test.txt rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/test/java/com/baeldung/nestedclass/AnonymousInner.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/test/java/com/baeldung/nestedclass/Enclosing.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/test/java/com/baeldung/nestedclass/NewEnclosing.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/test/java/com/baeldung/nestedclass/NewOuter.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/test/java/com/baeldung/nestedclass/Outer.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-types}/src/test/java/com/baeldung/objects/ObjectsUnitTest.java (100%) diff --git a/core-java-modules/core-java-lang-oop-3/README.md b/core-java-modules/core-java-lang-oop-3/README.md index 3b57ece635..0c9faf9a6d 100644 --- a/core-java-modules/core-java-lang-oop-3/README.md +++ b/core-java-modules/core-java-lang-oop-3/README.md @@ -5,9 +5,5 @@ This module contains articles about Object-oriented programming (OOP) in Java ### Relevant Articles: - [Pass-By-Value as a Parameter Passing Mechanism in Java](https://www.baeldung.com/java-pass-by-value-or-pass-by-reference) - [Guide to the super Java Keyword](https://www.baeldung.com/java-super) -- [Guide to the this Java Keyword](https://www.baeldung.com/java-this) -- [Nested Classes in Java](https://www.baeldung.com/java-nested-classes) -- [A Guide to Inner Interfaces in Java](https://www.baeldung.com/java-inner-interfaces) -- [Java Classes and Objects](https://www.baeldung.com/java-classes-objects) - [Java Interfaces](https://www.baeldung.com/java-interfaces) - [[<-- Prev]](/core-java-modules/core-java-lang-oop-2)[[More -->]](/core-java-modules/core-java-lang-oop-4) diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/KeywordDemo.java b/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/KeywordDemo.java index fd608b424c..ed421a9089 100644 --- a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/KeywordDemo.java +++ b/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/KeywordDemo.java @@ -1,7 +1,6 @@ package com.baeldung.keyword; import com.baeldung.keyword.superkeyword.SuperSub; -import com.baeldung.keyword.thiskeyword.KeywordUnitTest; /** * Created by Gebruiker on 5/14/2018. @@ -9,8 +8,6 @@ import com.baeldung.keyword.thiskeyword.KeywordUnitTest; public class KeywordDemo { public static void main(String[] args) { - KeywordUnitTest keyword = new KeywordUnitTest(); - SuperSub child = new SuperSub("message from the child class"); } } diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/README.md b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/README.md new file mode 100644 index 0000000000..330a74be9b --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/README.md @@ -0,0 +1,11 @@ +## Core Java Lang OOP - Types + +This module contains articles about types in Java + +### Relevant Articles: +- [Java Classes and Objects](https://www.baeldung.com/java-classes-objects) +- [Guide to the this Java Keyword](https://www.baeldung.com/java-this) +- [Abstract Classes in Java](https://www.baeldung.com/java-abstract-class) +- [Nested Classes in Java](https://www.baeldung.com/java-nested-classes) +- [A Guide to Inner Interfaces in Java](https://www.baeldung.com/java-inner-interfaces) +- [Marker Interfaces in Java](https://www.baeldung.com/java-marker-interfaces) diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/pom.xml b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/pom.xml new file mode 100644 index 0000000000..ce6b74bd3e --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/pom.xml @@ -0,0 +1,28 @@ + + + + core-java-lang-oop-modules + com.baeldung.core-java-lang-oop-modules + 1.0.0-SNAPSHOT + + 4.0.0 + + core-java-lang-oop-types + core-java-lang-oop-types + jar + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + + + 3.10.0 + + \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/abstractclasses/application/Application.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/abstractclasses/application/Application.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/abstractclasses/application/Application.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/abstractclasses/application/Application.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/innerinterfaces/Customer.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/innerinterfaces/Customer.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/innerinterfaces/Customer.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/innerinterfaces/Customer.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/markerinterface/DeletableShape.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/DeletableShape.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/markerinterface/DeletableShape.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/DeletableShape.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/markerinterface/Rectangle.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Rectangle.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/markerinterface/Rectangle.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Rectangle.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/markerinterface/Shape.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Shape.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/markerinterface/Shape.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Shape.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/markerinterface/ShapeDao.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/ShapeDao.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/markerinterface/ShapeDao.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/ShapeDao.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/objects/Car.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/objects/Car.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/objects/Car.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/objects/Car.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/resources/files/test.txt b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/resources/files/test.txt new file mode 100644 index 0000000000..08e53af69d --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/resources/files/test.txt @@ -0,0 +1,10 @@ +This is line 1 +This is line 2 +This is line 3 +This is line 4 +This is line 5 +This is line 6 +This is line 7 +This is line 8 +This is line 9 +This is line 10 \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/AnonymousInner.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInner.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/AnonymousInner.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInner.java diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/Enclosing.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Enclosing.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/Enclosing.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Enclosing.java diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/NewEnclosing.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewEnclosing.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/NewEnclosing.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewEnclosing.java diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/NewOuter.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewOuter.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/NewOuter.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewOuter.java diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/Outer.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Outer.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/nestedclass/Outer.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Outer.java diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/objects/ObjectsUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/objects/ObjectsUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/objects/ObjectsUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/objects/ObjectsUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/pom.xml b/core-java-modules/core-java-lang-oop-modules/pom.xml index a77079bc06..a443c0cb29 100644 --- a/core-java-modules/core-java-lang-oop-modules/pom.xml +++ b/core-java-modules/core-java-lang-oop-modules/pom.xml @@ -19,5 +19,6 @@ core-java-lang-oop-patterns core-java-lang-oop-generics core-java-lang-oop-modifiers + core-java-lang-oop-types \ No newline at end of file From 654de59bbf3dfb84961991882826bf150429fc55 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sat, 4 Apr 2020 11:09:04 +0200 Subject: [PATCH 364/503] [JAVA-621] core-java-lang-oop-inheritance module * Creation * Moved code from https://www.baeldung.com/java-anonymous-classes * Moved code from www.baeldung.com/java-polymorphism * Moved code from www.baeldung.com/java-inheritance * Moved code from www.baeldung.com/java-variable-method-hiding * Moved code from https://www.baeldung.com/java-type-casting * Moved code from https://www.baeldung.com/java-super * Moved code from www.baeldung.com/java-interfaces * Moved code from www.baeldung.com/java-abstract-class * Moved code from www.baeldung.com/java-inner-interfaces * Moved article references to the new README.md --- .../core-java-lang-oop-2/README.md | 1 - .../core-java-lang-oop-3/README.md | 2 -- .../core-java-lang-oop-inheritance/README.md | 14 ++++++++++ .../core-java-lang-oop-inheritance/pom.xml | 28 +++++++++++++++++++ .../application/Application.java | 0 .../filereaders/BaseFileReader.java | 0 .../filereaders/LowercaseFileReader.java | 0 .../filereaders/UppercaseFileReader.java | 0 .../java/com/baeldung/anonymous/Book.java | 0 .../java/com/baeldung/anonymous/Main.java | 0 .../java/com/baeldung/casting/Animal.java | 0 .../com/baeldung/casting/AnimalFeeder.java | 0 .../baeldung/casting/AnimalFeederGeneric.java | 0 .../main/java/com/baeldung/casting/Cat.java | 0 .../main/java/com/baeldung/casting/Dog.java | 0 .../main/java/com/baeldung/casting/Mew.java | 0 .../com/baeldung/inheritance/ArmoredCar.java | 0 .../java/com/baeldung/inheritance/BMW.java | 0 .../java/com/baeldung/inheritance/Car.java | 0 .../com/baeldung/inheritance/Employee.java | 0 .../com/baeldung/inheritance/Floatable.java | 0 .../com/baeldung/inheritance/Flyable.java | 0 .../com/baeldung/inheritance/SpaceCar.java | 0 .../baeldung/inheritance/SpaceTraveller.java | 0 .../CommaSeparatedCustomers.java | 0 .../baeldung/innerinterfaces/Customer.java | 0 .../java/com/baeldung/interfaces/Box.java | 0 .../com/baeldung/interfaces/Employee.java | 0 .../interfaces/EmployeeSalaryComparator.java | 0 .../com/baeldung/interfaces/HasColor.java | 0 .../interfaces/multiinheritance/Car.java | 0 .../interfaces/multiinheritance/Fly.java | 0 .../multiinheritance/Transform.java | 0 .../interfaces/multiinheritance/Vehicle.java | 0 .../interfaces/polymorphysim/Circle.java | 0 .../polymorphysim/MainTestClass.java | 0 .../interfaces/polymorphysim/Shape.java | 0 .../interfaces/polymorphysim/Square.java | 0 .../keyword/superkeyword}/KeywordDemo.java | 4 +-- .../keyword/superkeyword/SuperBase.java | 0 .../keyword/superkeyword/SuperSub.java | 0 .../baeldung/polymorphism/FileManager.java | 0 .../baeldung/polymorphism/GenericFile.java | 0 .../com/baeldung/polymorphism/ImageFile.java | 0 .../com/baeldung/polymorphism/TextFile.java | 0 .../scope/method/BaseMethodClass.java | 0 .../scope/method/ChildMethodClass.java | 0 .../scope/method/MethodHidingDemo.java | 0 .../scope/variable/ChildVariable.java | 0 .../baeldung/scope/variable/HideVariable.java | 0 .../scope/variable/ParentVariable.java | 0 .../scope/variable/VariableHidingDemo.java | 0 .../src/main/resources/files/test.txt | 0 .../test/LowercaseFileReaderUnitTest.java | 0 .../test/UppercaseFileReaderUnitTest.java | 0 .../com/baeldung/casting/CastingUnitTest.java | 0 .../com/baeldung/inheritance/AppUnitTest.java | 0 .../InnerInterfaceUnitTest.java | 0 .../polymorphism/PolymorphismUnitTest.java | 0 .../core-java-lang-oop-types/README.md | 2 -- .../core-java-lang-oop-types/pom.xml | 13 --------- .../core-java-lang-oop-modules/pom.xml | 1 + .../core-java-lang-oop/README.md | 4 --- 63 files changed, 44 insertions(+), 25 deletions(-) create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/README.md create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/pom.xml rename core-java-modules/core-java-lang-oop-modules/{core-java-lang-oop-types => core-java-lang-oop-inheritance}/src/main/java/com/baeldung/abstractclasses/application/Application.java (100%) rename core-java-modules/core-java-lang-oop-modules/{core-java-lang-oop-types => core-java-lang-oop-inheritance}/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java (100%) rename core-java-modules/core-java-lang-oop-modules/{core-java-lang-oop-types => core-java-lang-oop-inheritance}/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java (100%) rename core-java-modules/core-java-lang-oop-modules/{core-java-lang-oop-types => core-java-lang-oop-inheritance}/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/anonymous/Book.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/anonymous/Main.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/casting/Animal.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/casting/AnimalFeeder.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/casting/Cat.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/casting/Dog.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/casting/Mew.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/inheritance/ArmoredCar.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/inheritance/BMW.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/inheritance/Car.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/inheritance/Employee.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/inheritance/Floatable.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/inheritance/Flyable.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/inheritance/SpaceCar.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/inheritance/SpaceTraveller.java (100%) rename core-java-modules/core-java-lang-oop-modules/{core-java-lang-oop-types => core-java-lang-oop-inheritance}/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java (100%) rename core-java-modules/core-java-lang-oop-modules/{core-java-lang-oop-types => core-java-lang-oop-inheritance}/src/main/java/com/baeldung/innerinterfaces/Customer.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/interfaces/Box.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/interfaces/Employee.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/interfaces/HasColor.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java (100%) rename core-java-modules/{core-java-lang-oop-3/src/main/java/com/baeldung/keyword => core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword}/KeywordDemo.java (70%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/polymorphism/FileManager.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/polymorphism/GenericFile.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/polymorphism/ImageFile.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/polymorphism/TextFile.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/scope/method/BaseMethodClass.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/scope/method/ChildMethodClass.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/scope/variable/ChildVariable.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/scope/variable/HideVariable.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/scope/variable/ParentVariable.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java (100%) rename core-java-modules/core-java-lang-oop-modules/{core-java-lang-oop-types => core-java-lang-oop-inheritance}/src/main/resources/files/test.txt (100%) rename core-java-modules/core-java-lang-oop-modules/{core-java-lang-oop-types => core-java-lang-oop-inheritance}/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java (100%) rename core-java-modules/core-java-lang-oop-modules/{core-java-lang-oop-types => core-java-lang-oop-inheritance}/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/test/java/com/baeldung/casting/CastingUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/test/java/com/baeldung/inheritance/AppUnitTest.java (100%) rename core-java-modules/core-java-lang-oop-modules/{core-java-lang-oop-types => core-java-lang-oop-inheritance}/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-inheritance}/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java (100%) diff --git a/core-java-modules/core-java-lang-oop-2/README.md b/core-java-modules/core-java-lang-oop-2/README.md index 76da66c7ab..2f122ab624 100644 --- a/core-java-modules/core-java-lang-oop-2/README.md +++ b/core-java-modules/core-java-lang-oop-2/README.md @@ -3,6 +3,5 @@ This module contains articles about Object-oriented programming (OOP) in Java ### Relevant Articles: -- [Anonymous Classes in Java](https://www.baeldung.com/java-anonymous-classes) - [Java equals() and hashCode() Contracts](https://www.baeldung.com/java-equals-hashcode-contracts) - [[<-- Prev]](/core-java-modules/core-java-lang-oop)[[More -->]](/core-java-modules/core-java-lang-oop-3) diff --git a/core-java-modules/core-java-lang-oop-3/README.md b/core-java-modules/core-java-lang-oop-3/README.md index 0c9faf9a6d..2d9085c036 100644 --- a/core-java-modules/core-java-lang-oop-3/README.md +++ b/core-java-modules/core-java-lang-oop-3/README.md @@ -4,6 +4,4 @@ This module contains articles about Object-oriented programming (OOP) in Java ### Relevant Articles: - [Pass-By-Value as a Parameter Passing Mechanism in Java](https://www.baeldung.com/java-pass-by-value-or-pass-by-reference) -- [Guide to the super Java Keyword](https://www.baeldung.com/java-super) -- [Java Interfaces](https://www.baeldung.com/java-interfaces) - [[<-- Prev]](/core-java-modules/core-java-lang-oop-2)[[More -->]](/core-java-modules/core-java-lang-oop-4) diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/README.md b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/README.md new file mode 100644 index 0000000000..e264f9fae4 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/README.md @@ -0,0 +1,14 @@ +## Core Java Lang OOP - Types + +This module contains articles about types in Java + +### Relevant Articles: +- [Java Interfaces](https://www.baeldung.com/java-interfaces) +- [Abstract Classes in Java](https://www.baeldung.com/java-abstract-class) +- [A Guide to Inner Interfaces in Java](https://www.baeldung.com/java-inner-interfaces) +- [Guide to the super Java Keyword](https://www.baeldung.com/java-super) +- [Anonymous Classes in Java](https://www.baeldung.com/java-anonymous-classes) +- [Polymorphism in Java](https://www.baeldung.com/java-polymorphism) +- [Guide to Inheritance in Java](https://www.baeldung.com/java-inheritance) +- [Object Type Casting in Java](https://www.baeldung.com/java-type-casting) +- [Variable and Method Hiding in Java](https://www.baeldung.com/java-variable-method-hiding) diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/pom.xml b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/pom.xml new file mode 100644 index 0000000000..8e7e8e374d --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/pom.xml @@ -0,0 +1,28 @@ + + + + core-java-lang-oop-modules + com.baeldung.core-java-lang-oop-modules + 1.0.0-SNAPSHOT + + 4.0.0 + + core-java-lang-oop-inheritance + core-java-lang-oop-inheritance + jar + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + + + 3.10.0 + + \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/abstractclasses/application/Application.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/application/Application.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/abstractclasses/application/Application.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/application/Application.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Book.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Book.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Book.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Book.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Main.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Main.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/anonymous/Main.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Main.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Animal.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Animal.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Animal.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Animal.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeeder.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeeder.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeeder.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeeder.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Cat.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Cat.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Cat.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Cat.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Dog.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Dog.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Dog.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Dog.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Mew.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Mew.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/casting/Mew.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Mew.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/ArmoredCar.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/ArmoredCar.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/ArmoredCar.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/ArmoredCar.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/BMW.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/BMW.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/BMW.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/BMW.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Car.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Car.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Car.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Car.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Employee.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Employee.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Employee.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Employee.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Floatable.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Floatable.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Floatable.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Floatable.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Flyable.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Flyable.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/Flyable.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Flyable.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceCar.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceCar.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceCar.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceCar.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceTraveller.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceTraveller.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/inheritance/SpaceTraveller.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceTraveller.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/innerinterfaces/Customer.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/Customer.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/innerinterfaces/Customer.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/Customer.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/Box.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Box.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/Box.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Box.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/Employee.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Employee.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/Employee.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Employee.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/HasColor.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/HasColor.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/HasColor.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/HasColor.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/KeywordDemo.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/KeywordDemo.java similarity index 70% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/KeywordDemo.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/KeywordDemo.java index ed421a9089..7414e52b1c 100644 --- a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/KeywordDemo.java +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/KeywordDemo.java @@ -1,6 +1,4 @@ -package com.baeldung.keyword; - -import com.baeldung.keyword.superkeyword.SuperSub; +package com.baeldung.keyword.superkeyword; /** * Created by Gebruiker on 5/14/2018. diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/FileManager.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/FileManager.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/FileManager.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/FileManager.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/GenericFile.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/GenericFile.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/GenericFile.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/GenericFile.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/ImageFile.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/ImageFile.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/ImageFile.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/ImageFile.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/TextFile.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/TextFile.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/polymorphism/TextFile.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/TextFile.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/BaseMethodClass.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/BaseMethodClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/BaseMethodClass.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/BaseMethodClass.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/ChildMethodClass.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/ChildMethodClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/ChildMethodClass.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/ChildMethodClass.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ChildVariable.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ChildVariable.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ChildVariable.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ChildVariable.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/HideVariable.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/HideVariable.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/HideVariable.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/HideVariable.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ParentVariable.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ParentVariable.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/ParentVariable.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ParentVariable.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/resources/files/test.txt b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/resources/files/test.txt similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/resources/files/test.txt rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/resources/files/test.txt diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/casting/CastingUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/casting/CastingUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/casting/CastingUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/casting/CastingUnitTest.java diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritance/AppUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/inheritance/AppUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/inheritance/AppUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/inheritance/AppUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/README.md b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/README.md index 330a74be9b..80344c70fa 100644 --- a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/README.md +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/README.md @@ -5,7 +5,5 @@ This module contains articles about types in Java ### Relevant Articles: - [Java Classes and Objects](https://www.baeldung.com/java-classes-objects) - [Guide to the this Java Keyword](https://www.baeldung.com/java-this) -- [Abstract Classes in Java](https://www.baeldung.com/java-abstract-class) - [Nested Classes in Java](https://www.baeldung.com/java-nested-classes) -- [A Guide to Inner Interfaces in Java](https://www.baeldung.com/java-inner-interfaces) - [Marker Interfaces in Java](https://www.baeldung.com/java-marker-interfaces) diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/pom.xml b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/pom.xml index ce6b74bd3e..156ff89ccd 100644 --- a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/pom.xml +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/pom.xml @@ -12,17 +12,4 @@ core-java-lang-oop-types core-java-lang-oop-types jar - - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - - - 3.10.0 - \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-modules/pom.xml b/core-java-modules/core-java-lang-oop-modules/pom.xml index a443c0cb29..3f33150424 100644 --- a/core-java-modules/core-java-lang-oop-modules/pom.xml +++ b/core-java-modules/core-java-lang-oop-modules/pom.xml @@ -20,5 +20,6 @@ core-java-lang-oop-generics core-java-lang-oop-modifiers core-java-lang-oop-types + core-java-lang-oop-inheritance \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop/README.md b/core-java-modules/core-java-lang-oop/README.md index c09ed6048d..7855fb7b7e 100644 --- a/core-java-modules/core-java-lang-oop/README.md +++ b/core-java-modules/core-java-lang-oop/README.md @@ -4,12 +4,8 @@ This module contains articles about Object-oriented programming (OOP) in Java ### Relevant Articles: - [Guide to hashCode() in Java](https://www.baeldung.com/java-hashcode) -- [Polymorphism in Java](https://www.baeldung.com/java-polymorphism) - [Method Overloading and Overriding in Java](https://www.baeldung.com/java-method-overload-override) - [How to Make a Deep Copy of an Object in Java](https://www.baeldung.com/java-deep-copy) -- [Guide to Inheritance in Java](https://www.baeldung.com/java-inheritance) -- [Object Type Casting in Java](https://www.baeldung.com/java-type-casting) - [Type Erasure in Java Explained](https://www.baeldung.com/java-type-erasure) -- [Variable and Method Hiding in Java](https://www.baeldung.com/java-variable-method-hiding) - [Object-Oriented-Programming Concepts in Java](https://www.baeldung.com/java-oop) - [[More -->]](/core-java-modules/core-java-lang-oop-2) From b1e507d44c3c44d2b1625d27a75dc4726926b38e Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sat, 4 Apr 2020 11:38:22 +0200 Subject: [PATCH 365/503] [JAVA-621] core-java-lang-oop-methods module * Creation * Moved code from https://www.baeldung.com/java-equals-hashcode-contracts * Moved code from www.baeldung.com/java-hashcode * Moved code from https://www.baeldung.com/java-method-overload-override * Moved code from www.baeldung.com/java-methods * Moved article references to the new README.md --- .../core-java-lang-oop-2/README.md | 1 - .../core-java-lang-oop-4/README.md | 1 - .../core-java-lang-oop-methods/README.md | 9 +++++ .../core-java-lang-oop-methods/pom.xml | 35 +++++++++++++++++++ .../com/baeldung/basicmethods/PersonName.java | 0 .../com/baeldung/equalshashcode/Money.java | 0 .../com/baeldung/equalshashcode/Team.java | 0 .../com/baeldung/equalshashcode/Voucher.java | 0 .../baeldung/equalshashcode/WrongTeam.java | 0 .../baeldung/equalshashcode/WrongVoucher.java | 0 .../com/baeldung/hashcode/entities/User.java | 0 .../application/Application.java | 0 .../model/Car.java | 0 .../model/Vehicle.java | 0 .../util/Multiplier.java | 0 .../equalshashcode/MoneyUnitTest.java | 0 .../baeldung/equalshashcode/TeamUnitTest.java | 0 .../application/ApplicationUnitTest.java | 0 .../hashcode/entities/UserUnitTest.java | 0 .../test/MethodOverloadingUnitTest.java | 0 .../test/MethodOverridingUnitTest.java | 0 .../core-java-lang-oop-modules/pom.xml | 1 + .../core-java-lang-oop/README.md | 2 -- 23 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/README.md create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/pom.xml rename core-java-modules/{core-java-lang-oop-4 => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/main/java/com/baeldung/basicmethods/PersonName.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/main/java/com/baeldung/equalshashcode/Money.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/main/java/com/baeldung/equalshashcode/Team.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/main/java/com/baeldung/equalshashcode/Voucher.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/main/java/com/baeldung/equalshashcode/WrongTeam.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/main/java/com/baeldung/hashcode/entities/User.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop => core-java-lang-oop-modules/core-java-lang-oop-methods}/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java (100%) diff --git a/core-java-modules/core-java-lang-oop-2/README.md b/core-java-modules/core-java-lang-oop-2/README.md index 2f122ab624..5385977ef0 100644 --- a/core-java-modules/core-java-lang-oop-2/README.md +++ b/core-java-modules/core-java-lang-oop-2/README.md @@ -3,5 +3,4 @@ This module contains articles about Object-oriented programming (OOP) in Java ### Relevant Articles: -- [Java equals() and hashCode() Contracts](https://www.baeldung.com/java-equals-hashcode-contracts) - [[<-- Prev]](/core-java-modules/core-java-lang-oop)[[More -->]](/core-java-modules/core-java-lang-oop-3) diff --git a/core-java-modules/core-java-lang-oop-4/README.md b/core-java-modules/core-java-lang-oop-4/README.md index 51650dc1f6..efddf9df8a 100644 --- a/core-java-modules/core-java-lang-oop-4/README.md +++ b/core-java-modules/core-java-lang-oop-4/README.md @@ -4,6 +4,5 @@ This module contains articles about Object-oriented programming (OOP) in Java ### Relevant Articles: - [Static and Dynamic Binding in Java](https://www.baeldung.com/java-static-dynamic-binding) -- [Methods in Java](https://www.baeldung.com/java-methods) - [Java ‘private’ Access Modifier](https://www.baeldung.com/java-private-keyword) - [[<-- Prev]](/core-java-modules/core-java-lang-oop-3) \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/README.md b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/README.md new file mode 100644 index 0000000000..fa474c9795 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/README.md @@ -0,0 +1,9 @@ +## Core Java Lang OOP - Methods + +This module contains articles about methods in Java + +### Relevant Articles: +- [Methods in Java](https://www.baeldung.com/java-methods) +- [Method Overloading and Overriding in Java](https://www.baeldung.com/java-method-overload-override) +- [Java equals() and hashCode() Contracts](https://www.baeldung.com/java-equals-hashcode-contracts) +- [Guide to hashCode() in Java](https://www.baeldung.com/java-hashcode) diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/pom.xml b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/pom.xml new file mode 100644 index 0000000000..062af9c3cd --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/pom.xml @@ -0,0 +1,35 @@ + + + + core-java-lang-oop-modules + com.baeldung.core-java-lang-oop-modules + 1.0.0-SNAPSHOT + + 4.0.0 + + core-java-lang-oop-methods + core-java-lang-oop-methods + jar + + + + org.assertj + assertj-core + ${assertj-core.version} + test + + + nl.jqno.equalsverifier + equalsverifier + ${equalsverifier.version} + test + + + + + 3.10.0 + 3.0.3 + + \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/basicmethods/PersonName.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/basicmethods/PersonName.java similarity index 100% rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/basicmethods/PersonName.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/basicmethods/PersonName.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/Money.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Money.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/Money.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Money.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/Team.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Team.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/Team.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Team.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/Voucher.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Voucher.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/Voucher.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Voucher.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/WrongTeam.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongTeam.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/WrongTeam.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongTeam.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/hashcode/entities/User.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/entities/User.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/hashcode/entities/User.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/entities/User.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/pom.xml b/core-java-modules/core-java-lang-oop-modules/pom.xml index 3f33150424..369195d477 100644 --- a/core-java-modules/core-java-lang-oop-modules/pom.xml +++ b/core-java-modules/core-java-lang-oop-modules/pom.xml @@ -21,5 +21,6 @@ core-java-lang-oop-modifiers core-java-lang-oop-types core-java-lang-oop-inheritance + core-java-lang-oop-methods \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop/README.md b/core-java-modules/core-java-lang-oop/README.md index 7855fb7b7e..f7e00e44eb 100644 --- a/core-java-modules/core-java-lang-oop/README.md +++ b/core-java-modules/core-java-lang-oop/README.md @@ -3,8 +3,6 @@ This module contains articles about Object-oriented programming (OOP) in Java ### Relevant Articles: -- [Guide to hashCode() in Java](https://www.baeldung.com/java-hashcode) -- [Method Overloading and Overriding in Java](https://www.baeldung.com/java-method-overload-override) - [How to Make a Deep Copy of an Object in Java](https://www.baeldung.com/java-deep-copy) - [Type Erasure in Java Explained](https://www.baeldung.com/java-type-erasure) - [Object-Oriented-Programming Concepts in Java](https://www.baeldung.com/java-oop) From f6d3dc711fde92b6f05bc2aaad029baf8e7c0b6f Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sat, 4 Apr 2020 12:05:22 +0200 Subject: [PATCH 366/503] [JAVA-621] core-java-lang-oop-others module * Creation * Moved code from www.baeldung.com/java-static-dynamic-binding * Recreated code for https://www.baeldung.com/java-oop as none was matching anymore * Moved code from https://www.baeldung.com/java-pass-by-value-or-pass-by-reference * Moved article references to the new README.md --- .../core-java-lang-oop-others/README.md | 8 +++ .../core-java-lang-oop-others/pom.xml | 16 +++++ .../java/com/baeldung/binding/Animal.java | 0 .../com/baeldung/binding/AnimalActivity.java | 4 +- .../main/java/com/baeldung/binding/Dog.java} | 4 +- .../java/com/baeldung/oop/ArmoredCar.java | 13 ++++ .../src/main/java/com/baeldung/oop/Car.java | 58 +++++++++++++++++ .../java/com/baeldung/oop/GenericFile.java | 63 +++++++++++++++++++ .../main/java/com/baeldung/oop/ImageFile.java | 41 ++++++++++++ .../main/java/com/baeldung/oop/TextFile.java | 44 +++++++++++++ .../main/java/com/baeldung/oop/Vehicle.java | 23 +++++++ .../parameterpassing/NonPrimitives.java | 0 .../baeldung/parameterpassing/Primitives.java | 0 .../binding/AnimalActivityUnitTest.java | 6 +- .../com/baeldung/binding/AnimalUnitTest.java | 0 .../com/baeldung/binding/DogUnitTest.java} | 6 +- .../NonPrimitivesUnitTest.java | 0 .../parameterpassing/PrimitivesUnitTest.java | 0 .../core-java-lang-oop-modules/pom.xml | 1 + .../core-java-lang-oop/README.md | 1 - 20 files changed, 277 insertions(+), 11 deletions(-) create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/README.md create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/pom.xml rename core-java-modules/{core-java-lang-oop-4 => core-java-lang-oop-modules/core-java-lang-oop-others}/src/main/java/com/baeldung/binding/Animal.java (100%) rename core-java-modules/{core-java-lang-oop-4 => core-java-lang-oop-modules/core-java-lang-oop-others}/src/main/java/com/baeldung/binding/AnimalActivity.java (90%) rename core-java-modules/{core-java-lang-oop-4/src/main/java/com/baeldung/binding/Cat.java => core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Dog.java} (68%) create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ArmoredCar.java create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Car.java create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/GenericFile.java create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ImageFile.java create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/TextFile.java create mode 100644 core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Vehicle.java rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-others}/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-others}/src/main/java/com/baeldung/parameterpassing/Primitives.java (100%) rename core-java-modules/{core-java-lang-oop-4 => core-java-lang-oop-modules/core-java-lang-oop-others}/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java (96%) rename core-java-modules/{core-java-lang-oop-4 => core-java-lang-oop-modules/core-java-lang-oop-others}/src/test/java/com/baeldung/binding/AnimalUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-4/src/test/java/com/baeldung/binding/CatUnitTest.java => core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/DogUnitTest.java} (94%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-others}/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-3 => core-java-lang-oop-modules/core-java-lang-oop-others}/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java (100%) diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/README.md b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/README.md new file mode 100644 index 0000000000..d3909c0014 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/README.md @@ -0,0 +1,8 @@ +## Core Java Lang OOP - Others + +This module contains articles about Object Oriented Programming (OOP) in Java + +### Relevant Articles: +- [Object-Oriented-Programming Concepts in Java](https://www.baeldung.com/java-oop) +- [Static and Dynamic Binding in Java](https://www.baeldung.com/java-static-dynamic-binding) +- [Pass-By-Value as a Parameter Passing Mechanism in Java](https://www.baeldung.com/java-pass-by-value-or-pass-by-reference) diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/pom.xml b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/pom.xml new file mode 100644 index 0000000000..21699cd582 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/pom.xml @@ -0,0 +1,16 @@ + + + + core-java-lang-oop-modules + com.baeldung.core-java-lang-oop-modules + 1.0.0-SNAPSHOT + + 4.0.0 + + core-java-lang-oop-others + core-java-lang-oop-others + jar + + \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/binding/Animal.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Animal.java similarity index 100% rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/binding/Animal.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Animal.java diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/binding/AnimalActivity.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/AnimalActivity.java similarity index 90% rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/binding/AnimalActivity.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/AnimalActivity.java index 1bd36123e3..a30c3acd00 100644 --- a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/binding/AnimalActivity.java +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/AnimalActivity.java @@ -15,7 +15,7 @@ public class AnimalActivity { logger.info("Animal is sleeping"); } - public static void sleep(Cat cat) { + public static void sleep(Dog dog) { logger.info("Cat is sleeping"); } @@ -30,7 +30,7 @@ public class AnimalActivity { //assigning a dog object to reference of type Animal - Animal catAnimal = new Cat(); + Animal catAnimal = new Dog(); catAnimal.makeNoise(); diff --git a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/binding/Cat.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Dog.java similarity index 68% rename from core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/binding/Cat.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Dog.java index bbe740e412..b6924569d0 100644 --- a/core-java-modules/core-java-lang-oop-4/src/main/java/com/baeldung/binding/Cat.java +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Dog.java @@ -6,9 +6,9 @@ import org.slf4j.LoggerFactory; /** * Created by madhumita.g on 25-07-2018. */ -public class Cat extends Animal { +public class Dog extends Animal { - final static Logger logger = LoggerFactory.getLogger(Cat.class); + final static Logger logger = LoggerFactory.getLogger(Dog.class); public void makeNoise() { diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ArmoredCar.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ArmoredCar.java new file mode 100644 index 0000000000..29cba3702a --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ArmoredCar.java @@ -0,0 +1,13 @@ +package com.baeldung.oop; + +public class ArmoredCar extends Car { + private int bulletProofWindows; + + public ArmoredCar(String type, String model, String color) { + super(type, model, color); + } + + public void remoteStartCar() { + // this vehicle can be started by using a remote control + } +} diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Car.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Car.java new file mode 100644 index 0000000000..8ea4d779b6 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Car.java @@ -0,0 +1,58 @@ +package com.baeldung.oop; + +public class Car extends Vehicle { + + private String type; + private String color; + private int speed; + private int numberOfGears; + + public Car(String type, String model, String color) { + super(4, model); + this.type = type; + this.color = color; + } + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } + + public int getSpeed() { + return speed; + } + + public void setSpeed(int speed) { + this.speed = speed; + } + + public int increaseSpeed(int increment) { + if (increment > 0) { + this.speed += increment; + } else { + System.out.println("Increment can't be negative."); + } + return this.speed; + } + + public int decreaseSpeed(int decrement) { + if (decrement > 0 && decrement <= this.speed) { + this.speed -= decrement; + } else { + System.out.println("Decrement can't be negative or greater than current speed."); + } + return this.speed; + } + + public void openDoors() { + // process to open the doors + } + + @Override + public void honk() { + // produces car-specific honk + } +} diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/GenericFile.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/GenericFile.java new file mode 100644 index 0000000000..812a3f1d63 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/GenericFile.java @@ -0,0 +1,63 @@ +package com.baeldung.oop; + +import java.util.Date; + +public class GenericFile { + private String name; + private String extension; + private Date dateCreated; + private String version; + private byte[] content; + + public GenericFile() { + this.setDateCreated(new Date()); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getExtension() { + return extension; + } + + public void setExtension(String extension) { + this.extension = extension; + } + + public Date getDateCreated() { + return dateCreated; + } + + public void setDateCreated(Date dateCreated) { + this.dateCreated = dateCreated; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public byte[] getContent() { + return content; + } + + public void setContent(byte[] content) { + this.content = content; + } + + public String getFileInfo() { + return "Generic File Impl"; + } + + public Object read() { + return content; + } +} diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ImageFile.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ImageFile.java new file mode 100644 index 0000000000..2e2b9b4129 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ImageFile.java @@ -0,0 +1,41 @@ +package com.baeldung.oop; + +public class ImageFile extends GenericFile { + private int height; + private int width; + + public ImageFile(String name, int height, int width, byte[] content, String version) { + this.setHeight(height); + this.setWidth(width); + this.setContent(content); + this.setName(name); + this.setVersion(version); + this.setExtension(".jpg"); + } + + public int getHeight() { + return height; + } + + public void setHeight(int height) { + this.height = height; + } + + public int getWidth() { + return width; + } + + public void setWidth(int width) { + this.width = width; + } + + public String getFileInfo() { + return "Image File Impl"; + } + + public String read() { + return this.getContent() + .toString(); + } + +} diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/TextFile.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/TextFile.java new file mode 100644 index 0000000000..0d7b8e4192 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/TextFile.java @@ -0,0 +1,44 @@ +package com.baeldung.oop; + +public class TextFile extends GenericFile { + private int wordCount; + + public TextFile(String name, String content, String version) { + String[] words = content.split(" "); + this.setWordCount(words.length > 0 ? words.length : 1); + this.setContent(content.getBytes()); + this.setName(name); + this.setVersion(version); + this.setExtension(".txt"); + } + + public int getWordCount() { + return wordCount; + } + + public void setWordCount(int wordCount) { + this.wordCount = wordCount; + } + + public String getFileInfo() { + return "Text File Impl"; + } + + public String read() { + return this.getContent() + .toString(); + } + + public String read(int limit) { + return this.getContent() + .toString() + .substring(0, limit); + } + + public String read(int start, int stop) { + return this.getContent() + .toString() + .substring(start, stop); + } + +} diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Vehicle.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Vehicle.java new file mode 100644 index 0000000000..d5ef05bc31 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Vehicle.java @@ -0,0 +1,23 @@ +package com.baeldung.oop; + +public class Vehicle { + private int wheels; + private String model; + + public Vehicle(int wheels, String model) { + this.wheels = wheels; + this.model = model; + } + + public void start() { + // the process of starting the vehicle + } + + public void stop() { + // process to stop the vehicle + } + + public void honk() { + // produces a default honk + } +} diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java diff --git a/core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/parameterpassing/Primitives.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/Primitives.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/main/java/com/baeldung/parameterpassing/Primitives.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/Primitives.java diff --git a/core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java similarity index 96% rename from core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java index 41c67ff389..6ef9b51818 100644 --- a/core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java @@ -62,9 +62,9 @@ public class AnimalActivityUnitTest { @Test public void givenDogReference__whenRefersCatObject_shouldCallFunctionWithAnimalParam() { - Cat cat = new Cat(); + Dog dog = new Dog(); - AnimalActivity.sleep(cat); + AnimalActivity.sleep(dog); verify(mockAppender).doAppend(captorLoggingEvent.capture()); @@ -79,7 +79,7 @@ public class AnimalActivityUnitTest { @Test public void givenAnimaReference__whenRefersDogObject_shouldCallFunctionWithAnimalParam() { - Animal cat = new Cat(); + Animal cat = new Dog(); AnimalActivity.sleep(cat); diff --git a/core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/binding/AnimalUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/binding/AnimalUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/binding/CatUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/DogUnitTest.java similarity index 94% rename from core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/binding/CatUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/DogUnitTest.java index 76ccfb7719..977c5d65e6 100644 --- a/core-java-modules/core-java-lang-oop-4/src/test/java/com/baeldung/binding/CatUnitTest.java +++ b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/DogUnitTest.java @@ -22,7 +22,7 @@ import static org.mockito.Mockito.verify; * Created by madhumita.g on 01-08-2018. */ @RunWith(MockitoJUnitRunner.class) -public class CatUnitTest { +public class DogUnitTest { @Mock private Appender mockAppender; @@ -45,9 +45,9 @@ public class CatUnitTest { @Test public void makeNoiseTest() { - Cat cat = new Cat(); + Dog dog = new Dog(); - cat.makeNoise(); + dog.makeNoise(); verify(mockAppender).doAppend(captorLoggingEvent.capture()); diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java b/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-3/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java rename to core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/pom.xml b/core-java-modules/core-java-lang-oop-modules/pom.xml index 369195d477..39dfe16b17 100644 --- a/core-java-modules/core-java-lang-oop-modules/pom.xml +++ b/core-java-modules/core-java-lang-oop-modules/pom.xml @@ -22,5 +22,6 @@ core-java-lang-oop-types core-java-lang-oop-inheritance core-java-lang-oop-methods + core-java-lang-oop-others \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop/README.md b/core-java-modules/core-java-lang-oop/README.md index f7e00e44eb..1af957b532 100644 --- a/core-java-modules/core-java-lang-oop/README.md +++ b/core-java-modules/core-java-lang-oop/README.md @@ -5,5 +5,4 @@ This module contains articles about Object-oriented programming (OOP) in Java ### Relevant Articles: - [How to Make a Deep Copy of an Object in Java](https://www.baeldung.com/java-deep-copy) - [Type Erasure in Java Explained](https://www.baeldung.com/java-type-erasure) -- [Object-Oriented-Programming Concepts in Java](https://www.baeldung.com/java-oop) - [[More -->]](/core-java-modules/core-java-lang-oop-2) From fc303de35fd62000f901db6608c2d708abd6ea0d Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sat, 4 Apr 2020 12:24:39 +0200 Subject: [PATCH 367/503] [JAVA-621] Obsolete modules deletion * Delete core-java-lang-oop module (remaining code was duplicate of core-java-lang-syntax where it really belonged) * Moved code from https://www.baeldung.com/java-eclipse-equals-and-hashcode to core-java-lang where it belong * Delete core-java-lang-oop-2 module * Delete core-java-lang-oop-3 module * Delete core-java-lang-oop-4 module --- .../core-java-lang-oop-2/.gitignore | 4 -- .../core-java-lang-oop-2/README.md | 6 -- .../core-java-lang-oop-2/pom.xml | 51 --------------- .../src/main/resources/files/test.txt | 10 --- .../core-java-lang-oop-3/README.md | 7 --- .../core-java-lang-oop-3/pom.xml | 60 ------------------ .../core-java-lang-oop-4/README.md | 8 --- .../core-java-lang-oop-4/pom.xml | 60 ------------------ .../core-java-lang-oop/.gitignore | 26 -------- .../core-java-lang-oop/README.md | 8 --- core-java-modules/core-java-lang-oop/pom.xml | 62 ------------------- .../baeldung/initializationguide/User.java | 53 ---------------- .../src/main/resources/logback.xml | 19 ------ .../initializationguide/UserUnitTest.java | 37 ----------- .../src/test/resources/.gitignore | 13 ---- .../equalshashcode/entities/ComplexClass.java | 0 .../entities/PrimitiveClass.java | 0 .../equalshashcode/entities/Rectangle.java | 0 .../equalshashcode/entities/Shape.java | 0 .../equalshashcode/entities/Square.java | 0 .../entities/ComplexClassUnitTest.java | 0 .../entities/PrimitiveClassUnitTest.java | 0 .../entities/SquareClassUnitTest.java | 0 core-java-modules/pom.xml | 4 -- 24 files changed, 428 deletions(-) delete mode 100644 core-java-modules/core-java-lang-oop-2/.gitignore delete mode 100644 core-java-modules/core-java-lang-oop-2/README.md delete mode 100644 core-java-modules/core-java-lang-oop-2/pom.xml delete mode 100644 core-java-modules/core-java-lang-oop-2/src/main/resources/files/test.txt delete mode 100644 core-java-modules/core-java-lang-oop-3/README.md delete mode 100644 core-java-modules/core-java-lang-oop-3/pom.xml delete mode 100644 core-java-modules/core-java-lang-oop-4/README.md delete mode 100644 core-java-modules/core-java-lang-oop-4/pom.xml delete mode 100644 core-java-modules/core-java-lang-oop/.gitignore delete mode 100644 core-java-modules/core-java-lang-oop/README.md delete mode 100644 core-java-modules/core-java-lang-oop/pom.xml delete mode 100644 core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/initializationguide/User.java delete mode 100644 core-java-modules/core-java-lang-oop/src/main/resources/logback.xml delete mode 100644 core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/initializationguide/UserUnitTest.java delete mode 100644 core-java-modules/core-java-lang-oop/src/test/resources/.gitignore rename core-java-modules/{core-java-lang-oop-2 => core-java-lang}/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang}/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang}/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang}/src/main/java/com/baeldung/equalshashcode/entities/Shape.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang}/src/main/java/com/baeldung/equalshashcode/entities/Square.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang}/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang}/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-2 => core-java-lang}/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java (100%) diff --git a/core-java-modules/core-java-lang-oop-2/.gitignore b/core-java-modules/core-java-lang-oop-2/.gitignore deleted file mode 100644 index 36aba1c242..0000000000 --- a/core-java-modules/core-java-lang-oop-2/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -target/ -.idea/ -bin/ -*.iml \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-2/README.md b/core-java-modules/core-java-lang-oop-2/README.md deleted file mode 100644 index 5385977ef0..0000000000 --- a/core-java-modules/core-java-lang-oop-2/README.md +++ /dev/null @@ -1,6 +0,0 @@ -## Core Java Lang OOP (Part 2) - -This module contains articles about Object-oriented programming (OOP) in Java - -### Relevant Articles: -- [[<-- Prev]](/core-java-modules/core-java-lang-oop)[[More -->]](/core-java-modules/core-java-lang-oop-3) diff --git a/core-java-modules/core-java-lang-oop-2/pom.xml b/core-java-modules/core-java-lang-oop-2/pom.xml deleted file mode 100644 index ccacaf7116..0000000000 --- a/core-java-modules/core-java-lang-oop-2/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - 4.0.0 - core-java-lang-oop-2 - 0.1.0-SNAPSHOT - core-java-lang-oop-2 - jar - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../../parent-java - - - - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - nl.jqno.equalsverifier - equalsverifier - ${equalsverifier.version} - test - - - - - core-java-lang-oop-2 - - - src/main/resources - true - - - - - - - 3.10.0 - 3.0.3 - - - diff --git a/core-java-modules/core-java-lang-oop-2/src/main/resources/files/test.txt b/core-java-modules/core-java-lang-oop-2/src/main/resources/files/test.txt deleted file mode 100644 index 08e53af69d..0000000000 --- a/core-java-modules/core-java-lang-oop-2/src/main/resources/files/test.txt +++ /dev/null @@ -1,10 +0,0 @@ -This is line 1 -This is line 2 -This is line 3 -This is line 4 -This is line 5 -This is line 6 -This is line 7 -This is line 8 -This is line 9 -This is line 10 \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-3/README.md b/core-java-modules/core-java-lang-oop-3/README.md deleted file mode 100644 index 2d9085c036..0000000000 --- a/core-java-modules/core-java-lang-oop-3/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## Core Java Lang OOP (Part 3) - -This module contains articles about Object-oriented programming (OOP) in Java - -### Relevant Articles: -- [Pass-By-Value as a Parameter Passing Mechanism in Java](https://www.baeldung.com/java-pass-by-value-or-pass-by-reference) -- [[<-- Prev]](/core-java-modules/core-java-lang-oop-2)[[More -->]](/core-java-modules/core-java-lang-oop-4) diff --git a/core-java-modules/core-java-lang-oop-3/pom.xml b/core-java-modules/core-java-lang-oop-3/pom.xml deleted file mode 100644 index cc9b473d03..0000000000 --- a/core-java-modules/core-java-lang-oop-3/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - 4.0.0 - core-java-lang-oop-3 - 0.1.0-SNAPSHOT - core-java-lang-oop-3 - jar - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../../parent-java - - - - - - log4j - log4j - ${log4j.version} - - - org.slf4j - log4j-over-slf4j - ${org.slf4j.version} - - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - com.h2database - h2 - ${h2.version} - test - - - - - core-java-lang-oop-3 - - - src/main/resources - true - - - - - - 3.10.0 - - - diff --git a/core-java-modules/core-java-lang-oop-4/README.md b/core-java-modules/core-java-lang-oop-4/README.md deleted file mode 100644 index efddf9df8a..0000000000 --- a/core-java-modules/core-java-lang-oop-4/README.md +++ /dev/null @@ -1,8 +0,0 @@ -## Core Java Lang OOP (Part 4) - -This module contains articles about Object-oriented programming (OOP) in Java - -### Relevant Articles: -- [Static and Dynamic Binding in Java](https://www.baeldung.com/java-static-dynamic-binding) -- [Java ‘private’ Access Modifier](https://www.baeldung.com/java-private-keyword) -- [[<-- Prev]](/core-java-modules/core-java-lang-oop-3) \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-4/pom.xml b/core-java-modules/core-java-lang-oop-4/pom.xml deleted file mode 100644 index 3c7e4f446d..0000000000 --- a/core-java-modules/core-java-lang-oop-4/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - 4.0.0 - core-java-lang-oop-4 - 0.1.0-SNAPSHOT - core-java-lang-oop-4 - jar - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../../parent-java - - - - - - log4j - log4j - ${log4j.version} - - - org.slf4j - log4j-over-slf4j - ${org.slf4j.version} - - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - com.h2database - h2 - ${h2.version} - test - - - - - core-java-lang-oop-4 - - - src/main/resources - true - - - - - - 3.10.0 - - - diff --git a/core-java-modules/core-java-lang-oop/.gitignore b/core-java-modules/core-java-lang-oop/.gitignore deleted file mode 100644 index 3de4cc647e..0000000000 --- a/core-java-modules/core-java-lang-oop/.gitignore +++ /dev/null @@ -1,26 +0,0 @@ -*.class - -0.* - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* -.resourceCache - -# Packaged files # -*.jar -*.war -*.ear - -# Files generated by integration tests -*.txt -backup-pom.xml -/bin/ -/temp - -#IntelliJ specific -.idea/ -*.iml \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop/README.md b/core-java-modules/core-java-lang-oop/README.md deleted file mode 100644 index 1af957b532..0000000000 --- a/core-java-modules/core-java-lang-oop/README.md +++ /dev/null @@ -1,8 +0,0 @@ -## Core Java Lang OOP - -This module contains articles about Object-oriented programming (OOP) in Java - -### Relevant Articles: -- [How to Make a Deep Copy of an Object in Java](https://www.baeldung.com/java-deep-copy) -- [Type Erasure in Java Explained](https://www.baeldung.com/java-type-erasure) -- [[More -->]](/core-java-modules/core-java-lang-oop-2) diff --git a/core-java-modules/core-java-lang-oop/pom.xml b/core-java-modules/core-java-lang-oop/pom.xml deleted file mode 100644 index 4415784f85..0000000000 --- a/core-java-modules/core-java-lang-oop/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - 4.0.0 - core-java-lang-oop - 0.1.0-SNAPSHOT - core-java-lang-oop - jar - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../../parent-java - - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.google.code.gson - gson - ${gson.version} - - - - org.assertj - assertj-core - ${assertj-core.version} - test - - - - - core-java-lang-oop - - - src/main/resources - true - - - - - - 2.8.2 - - 3.10.0 - - - diff --git a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/initializationguide/User.java b/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/initializationguide/User.java deleted file mode 100644 index 1d9a872d69..0000000000 --- a/core-java-modules/core-java-lang-oop/src/main/java/com/baeldung/initializationguide/User.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.baeldung.initializationguide; - -import java.io.Serializable; - -public class User implements Serializable, Cloneable { - private static final long serialVersionUID = 1L; - static String forum; - private String name; - private int id; - - { - id = 0; - System.out.println("Instance Initializer"); - } - - static { - forum = "Java"; - System.out.println("Static Initializer"); - } - - public User(String name, int id) { - super(); - this.name = name; - this.id = id; - } - - public User() { - System.out.println("Constructor"); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - @Override - protected Object clone() throws CloneNotSupportedException { - return this; - } - -} - diff --git a/core-java-modules/core-java-lang-oop/src/main/resources/logback.xml b/core-java-modules/core-java-lang-oop/src/main/resources/logback.xml deleted file mode 100644 index 56af2d397e..0000000000 --- a/core-java-modules/core-java-lang-oop/src/main/resources/logback.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - - - - - \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/initializationguide/UserUnitTest.java b/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/initializationguide/UserUnitTest.java deleted file mode 100644 index a26b602609..0000000000 --- a/core-java-modules/core-java-lang-oop/src/test/java/com/baeldung/initializationguide/UserUnitTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.baeldung.initializationguide; -import org.junit.Before; -import org.junit.Test; - -import static org.assertj.core.api.Assertions.*; - -import java.lang.reflect.InvocationTargetException; - -public class UserUnitTest { - - @Test - public void givenUserInstance_whenIntializedWithNew_thenInstanceIsNotNull() { - User user = new User("Alice", 1); - assertThat(user).isNotNull(); - } - - @Test - public void givenUserInstance_whenInitializedWithReflection_thenInstanceIsNotNull() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { - User user = User.class.getConstructor(String.class, int.class) - .newInstance("Alice", 2); - assertThat(user).isNotNull(); - } - - @Test - public void givenUserInstance_whenCopiedWithClone_thenExactMatchIsCreated() throws CloneNotSupportedException { - User user = new User("Alice", 3); - User clonedUser = (User) user.clone(); - assertThat(clonedUser).isEqualTo(user); - } - - @Test - public void givenUserInstance_whenValuesAreNotInitialized_thenUserNameAndIdReturnDefault() { - User user = new User(); - assertThat(user.getName()).isNull(); - assertThat(user.getId() == 0); - } -} diff --git a/core-java-modules/core-java-lang-oop/src/test/resources/.gitignore b/core-java-modules/core-java-lang-oop/src/test/resources/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/core-java-modules/core-java-lang-oop/src/test/resources/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.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/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/ComplexClass.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/PrimitiveClass.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Rectangle.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/Shape.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Shape.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/Shape.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Shape.java diff --git a/core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/Square.java b/core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Square.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/main/java/com/baeldung/equalshashcode/entities/Square.java rename to core-java-modules/core-java-lang/src/main/java/com/baeldung/equalshashcode/entities/Square.java diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/ComplexClassUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/PrimitiveClassUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java b/core-java-modules/core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-2/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java rename to core-java-modules/core-java-lang/src/test/java/com/baeldung/equalshashcode/entities/SquareClassUnitTest.java diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 4d64f7e6ba..995700d32c 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -86,10 +86,6 @@ core-java-lang-math core-java-lang-math-2 core-java-lang-oop-modules - core-java-lang-oop - core-java-lang-oop-2 - core-java-lang-oop-3 - core-java-lang-oop-4 core-java-lang-operators core-java-lang-syntax core-java-lang-syntax-2 From b117f4ccd644385b4bda5269ae33ace4c90f70b8 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Tue, 7 Apr 2020 21:28:45 +0200 Subject: [PATCH 368/503] [JAVA-621] Flattened modules hierarchy --- .../core-java-lang-oop-constructors/README.md | 0 .../core-java-lang-oop-constructors/pom.xml | 4 +-- .../baeldung/constructors/BankAccount.java | 0 .../baeldung/constructors/Transaction.java | 0 .../baeldung/copyconstructor/Employee.java | 0 .../com/baeldung/copyconstructor/Manager.java | 0 .../supertypecompilerexception/MyClass.java | 0 .../MyClassSolution1.java | 0 .../MyClassSolution2.java | 0 .../MyClassSolution3.java | 0 .../MyException.java | 0 .../constructors/ConstructorUnitTest.java | 0 .../copyconstructor/EmployeeUnitTest.java | 0 .../copyconstructor/ManagerUnitTest.java | 0 .../core-java-lang-oop-generics/README.md | 0 .../core-java-lang-oop-generics/pom.xml | 4 +-- .../java/com/baeldung/generics/Entry.java | 0 .../com/baeldung/generics/GenericEntry.java | 0 .../java/com/baeldung/generics/MapEntry.java | 0 .../java/com/baeldung/generics/Product.java | 0 .../java/com/baeldung/generics/Rankable.java | 0 .../com/baeldung/rawtype/RawTypeDemo.java | 0 .../typeerasure/ArrayContentPrintUtil.java | 0 .../com/baeldung/typeerasure/BoundStack.java | 0 .../baeldung/typeerasure/IntegerStack.java | 0 .../java/com/baeldung/typeerasure/Stack.java | 0 .../generics/GenericConstructorUnitTest.java | 0 .../typeerasure/TypeErasureUnitTest.java | 0 .../core-java-lang-oop-inheritance/README.md | 0 .../core-java-lang-oop-inheritance/pom.xml | 4 +-- .../application/Application.java | 0 .../filereaders/BaseFileReader.java | 0 .../filereaders/LowercaseFileReader.java | 0 .../filereaders/UppercaseFileReader.java | 0 .../java/com/baeldung/anonymous/Book.java | 0 .../java/com/baeldung/anonymous/Main.java | 0 .../java/com/baeldung/casting/Animal.java | 0 .../com/baeldung/casting/AnimalFeeder.java | 0 .../baeldung/casting/AnimalFeederGeneric.java | 0 .../main/java/com/baeldung/casting/Cat.java | 0 .../main/java/com/baeldung/casting/Dog.java | 0 .../main/java/com/baeldung/casting/Mew.java | 0 .../com/baeldung/inheritance/ArmoredCar.java | 0 .../java/com/baeldung/inheritance/BMW.java | 0 .../java/com/baeldung/inheritance/Car.java | 0 .../com/baeldung/inheritance/Employee.java | 0 .../com/baeldung/inheritance/Floatable.java | 0 .../com/baeldung/inheritance/Flyable.java | 0 .../com/baeldung/inheritance/SpaceCar.java | 0 .../baeldung/inheritance/SpaceTraveller.java | 0 .../CommaSeparatedCustomers.java | 0 .../baeldung/innerinterfaces/Customer.java | 0 .../java/com/baeldung/interfaces/Box.java | 0 .../com/baeldung/interfaces/Employee.java | 0 .../interfaces/EmployeeSalaryComparator.java | 0 .../com/baeldung/interfaces/HasColor.java | 0 .../interfaces/multiinheritance/Car.java | 0 .../interfaces/multiinheritance/Fly.java | 0 .../multiinheritance/Transform.java | 0 .../interfaces/multiinheritance/Vehicle.java | 0 .../interfaces/polymorphysim/Circle.java | 0 .../polymorphysim/MainTestClass.java | 0 .../interfaces/polymorphysim/Shape.java | 0 .../interfaces/polymorphysim/Square.java | 0 .../keyword/superkeyword/KeywordDemo.java | 0 .../keyword/superkeyword/SuperBase.java | 0 .../keyword/superkeyword/SuperSub.java | 0 .../baeldung/polymorphism/FileManager.java | 0 .../baeldung/polymorphism/GenericFile.java | 0 .../com/baeldung/polymorphism/ImageFile.java | 0 .../com/baeldung/polymorphism/TextFile.java | 0 .../scope/method/BaseMethodClass.java | 0 .../scope/method/ChildMethodClass.java | 0 .../scope/method/MethodHidingDemo.java | 0 .../scope/variable/ChildVariable.java | 0 .../baeldung/scope/variable/HideVariable.java | 0 .../scope/variable/ParentVariable.java | 0 .../scope/variable/VariableHidingDemo.java | 0 .../src/main/resources/files/test.txt | 0 .../test/LowercaseFileReaderUnitTest.java | 0 .../test/UppercaseFileReaderUnitTest.java | 0 .../com/baeldung/casting/CastingUnitTest.java | 0 .../com/baeldung/inheritance/AppUnitTest.java | 0 .../InnerInterfaceUnitTest.java | 0 .../polymorphism/PolymorphismUnitTest.java | 0 .../core-java-lang-oop-methods/README.md | 0 .../core-java-lang-oop-methods/pom.xml | 4 +-- .../com/baeldung/basicmethods/PersonName.java | 0 .../com/baeldung/equalshashcode/Money.java | 0 .../com/baeldung/equalshashcode/Team.java | 0 .../com/baeldung/equalshashcode/Voucher.java | 0 .../baeldung/equalshashcode/WrongTeam.java | 0 .../baeldung/equalshashcode/WrongVoucher.java | 0 .../com/baeldung/hashcode/entities/User.java | 0 .../application/Application.java | 0 .../model/Car.java | 0 .../model/Vehicle.java | 0 .../util/Multiplier.java | 0 .../equalshashcode/MoneyUnitTest.java | 0 .../baeldung/equalshashcode/TeamUnitTest.java | 0 .../application/ApplicationUnitTest.java | 0 .../hashcode/entities/UserUnitTest.java | 0 .../test/MethodOverloadingUnitTest.java | 0 .../test/MethodOverridingUnitTest.java | 0 .../core-java-lang-oop-modifiers/README.md | 0 .../core-java-lang-oop-modifiers/pom.xml | 4 +-- .../com/baeldung/accessmodifiers/Public.java | 0 .../baeldung/accessmodifiers/SubClass.java | 0 .../baeldung/accessmodifiers/SuperPublic.java | 0 .../another/AnotherPublic.java | 0 .../another/AnotherSubClass.java | 0 .../another/AnotherSuperPublic.java | 0 .../publicmodifier/ListOfThree.java | 0 .../publicmodifier/SpecialCharacters.java | 0 .../publicmodifier/Student.java | 0 .../core/privatemodifier/Employee.java | 0 .../core/privatemodifier/ExampleClass.java | 0 .../privatemodifier/PublicOuterClass.java | 0 .../application/Application.java | 0 .../model/Alarm.java | 0 .../model/Car.java | 0 .../model/Motorbike.java | 0 .../model/MultiAlarmCar.java | 0 .../model/Vehicle.java | 0 .../com/baeldung/finalkeyword/BlackCat.java | 0 .../com/baeldung/finalkeyword/BlackDog.java | 0 .../java/com/baeldung/finalkeyword/Cat.java | 0 .../java/com/baeldung/finalkeyword/Dog.java | 0 .../java/com/baeldung/staticdemo/Car.java | 0 .../com/baeldung/staticdemo/Singleton.java | 0 .../com/baeldung/staticdemo/StaticBlock.java | 0 .../com/baeldung/strictfpUsage/Circle.java | 0 .../strictfpUsage/ScientificCalculator.java | 0 .../PublicAccessModifierUnitTest.java | 0 .../StaticDefaulInterfaceMethodUnitTest.java | 0 .../baeldung/finalkeyword/FinalUnitTest.java | 0 .../com/baeldung/staticdemo/CarUnitTest.java | 0 .../staticdemo/SingletonUnitTest.java | 0 .../staticdemo/StaticBlockUnitTest.java | 0 .../ScientificCalculatorUnitTest.java | 0 .../core-java-lang-oop-modules/pom.xml | 27 ------------------- .../core-java-lang-oop-others/README.md | 0 .../core-java-lang-oop-others/pom.xml | 4 +-- .../java/com/baeldung/binding/Animal.java | 0 .../com/baeldung/binding/AnimalActivity.java | 0 .../main/java/com/baeldung/binding/Dog.java | 0 .../java/com/baeldung/oop/ArmoredCar.java | 0 .../src/main/java/com/baeldung/oop/Car.java | 0 .../java/com/baeldung/oop/GenericFile.java | 0 .../main/java/com/baeldung/oop/ImageFile.java | 0 .../main/java/com/baeldung/oop/TextFile.java | 0 .../main/java/com/baeldung/oop/Vehicle.java | 0 .../parameterpassing/NonPrimitives.java | 0 .../baeldung/parameterpassing/Primitives.java | 0 .../binding/AnimalActivityUnitTest.java | 0 .../com/baeldung/binding/AnimalUnitTest.java | 0 .../com/baeldung/binding/DogUnitTest.java | 0 .../NonPrimitivesUnitTest.java | 0 .../parameterpassing/PrimitivesUnitTest.java | 0 .../core-java-lang-oop-patterns/README.md | 0 .../core-java-lang-oop-patterns/pom.xml | 4 +-- .../java/com/baeldung/deepcopy/Address.java | 0 .../main/java/com/baeldung/deepcopy/User.java | 0 .../baeldung/immutableobjects/Currency.java | 0 .../com/baeldung/immutableobjects/Money.java | 0 .../application/Application.java | 0 .../inheritancecomposition/model/Actress.java | 0 .../model/Computer.java | 0 .../inheritancecomposition/model/Memory.java | 0 .../inheritancecomposition/model/Person.java | 0 .../model/Processor.java | 0 .../model/SoundCard.java | 0 .../model/StandardMemory.java | 0 .../model/StandardProcessor.java | 0 .../model/StandardSoundCard.java | 0 .../model/Waitress.java | 0 .../relationships/aggregation/Car.java | 0 .../aggregation/CarWithStaticInnerWheel.java | 0 .../relationships/aggregation/Wheel.java | 0 .../relationships/association/Child.java | 0 .../relationships/association/Mother.java | 0 .../relationships/composition/Building.java | 0 .../BuildingWithDefinitionRoomInMethod.java | 0 .../relationships/university/Department.java | 0 .../relationships/university/Professor.java | 0 .../relationships/university/University.java | 0 .../baeldung/deepcopy/DeepCopyUnitTest.java | 0 .../deepcopy/ShallowCopyUnitTest.java | 0 .../ImmutableObjectsUnitTest.java | 0 .../ActressUnitTest.java | 0 .../CompositionUnitTest.java | 0 .../InheritanceUnitTest.java | 0 .../PersonUnitTest.java | 0 .../WaitressUnitTest.java | 0 .../core-java-lang-oop-types/README.md | 0 .../core-java-lang-oop-types/pom.xml | 4 +-- .../keyword/thiskeyword/KeywordUnitTest.java | 0 .../markerinterface/DeletableShape.java | 0 .../baeldung/markerinterface/Rectangle.java | 0 .../com/baeldung/markerinterface/Shape.java | 0 .../baeldung/markerinterface/ShapeDao.java | 0 .../main/java/com/baeldung/objects/Car.java | 0 .../MarkerInterfaceUnitTest.java | 0 .../baeldung/nestedclass/AnonymousInner.java | 0 .../com/baeldung/nestedclass/Enclosing.java | 0 .../baeldung/nestedclass/NewEnclosing.java | 0 .../com/baeldung/nestedclass/NewOuter.java | 0 .../java/com/baeldung/nestedclass/Outer.java | 0 .../com/baeldung/objects/ObjectsUnitTest.java | 0 core-java-modules/pom.xml | 9 ++++++- 210 files changed, 24 insertions(+), 44 deletions(-) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-constructors/README.md (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-constructors/pom.xml (86%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/BankAccount.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/Transaction.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Employee.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Manager.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyException.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-constructors/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/EmployeeUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/ManagerUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-generics/README.md (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-generics/pom.xml (78%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Entry.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/GenericEntry.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/MapEntry.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Product.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Rankable.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-generics/src/main/java/com/baeldung/rawtype/RawTypeDemo.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/BoundStack.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/IntegerStack.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/Stack.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-generics/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-generics/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/README.md (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/pom.xml (86%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/application/Application.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Book.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Main.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Animal.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeeder.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Cat.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Dog.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Mew.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/ArmoredCar.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/BMW.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Car.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Employee.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Floatable.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Flyable.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceCar.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceTraveller.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/Customer.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Box.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Employee.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/HasColor.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/KeywordDemo.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/FileManager.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/GenericFile.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/ImageFile.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/TextFile.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/BaseMethodClass.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/ChildMethodClass.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ChildVariable.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/HideVariable.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ParentVariable.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/main/resources/files/test.txt (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/test/java/com/baeldung/casting/CastingUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/test/java/com/baeldung/inheritance/AppUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-inheritance/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/README.md (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/pom.xml (89%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/main/java/com/baeldung/basicmethods/PersonName.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Money.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Team.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Voucher.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongTeam.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/entities/User.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/README.md (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/pom.xml (88%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/Public.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SubClass.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/ListOfThree.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/SpecialCharacters.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/Student.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/Employee.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/ExampleClass.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/PublicOuterClass.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackCat.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackDog.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Cat.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Dog.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Car.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Singleton.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/StaticBlock.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/Circle.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/ScientificCalculator.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/test/java/com/baeldung/accessmodifiers/publicmodifier/PublicAccessModifierUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/CarUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/SingletonUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/StaticBlockUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-modifiers/src/test/java/com/baeldung/strictfpUsage/ScientificCalculatorUnitTest.java (100%) delete mode 100644 core-java-modules/core-java-lang-oop-modules/pom.xml rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/README.md (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/pom.xml (78%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Animal.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/src/main/java/com/baeldung/binding/AnimalActivity.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Dog.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ArmoredCar.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Car.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/src/main/java/com/baeldung/oop/GenericFile.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ImageFile.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/src/main/java/com/baeldung/oop/TextFile.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Vehicle.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/Primitives.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/src/test/java/com/baeldung/binding/DogUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/README.md (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/pom.xml (91%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/Address.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/User.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Currency.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Money.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/application/Application.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Person.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Car.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/CarWithStaticInnerWheel.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Wheel.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Child.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Mother.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/Building.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/BuildingWithDefinitionRoomInMethod.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Department.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Professor.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/University.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/ActressUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/CompositionUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/InheritanceUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/PersonUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/WaitressUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-types/README.md (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-types/pom.xml (78%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/DeletableShape.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Rectangle.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Shape.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/ShapeDao.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-types/src/main/java/com/baeldung/objects/Car.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-types/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInner.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Enclosing.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewEnclosing.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewOuter.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Outer.java (100%) rename core-java-modules/{core-java-lang-oop-modules => }/core-java-lang-oop-types/src/test/java/com/baeldung/objects/ObjectsUnitTest.java (100%) diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/README.md b/core-java-modules/core-java-lang-oop-constructors/README.md similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/README.md rename to core-java-modules/core-java-lang-oop-constructors/README.md diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/pom.xml b/core-java-modules/core-java-lang-oop-constructors/pom.xml similarity index 86% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/pom.xml rename to core-java-modules/core-java-lang-oop-constructors/pom.xml index e961d68f11..76507103ea 100644 --- a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/pom.xml +++ b/core-java-modules/core-java-lang-oop-constructors/pom.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - core-java-lang-oop-modules - com.baeldung.core-java-lang-oop-modules + core-java-modules + com.baeldung.core-java-modules 1.0.0-SNAPSHOT 4.0.0 diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/BankAccount.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/BankAccount.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/BankAccount.java rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/BankAccount.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/Transaction.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/Transaction.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/Transaction.java rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/constructors/Transaction.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Employee.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Employee.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Employee.java rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Employee.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Manager.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Manager.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Manager.java rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/copyconstructor/Manager.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClass.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution1.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution2.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyClassSolution3.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyException.java b/core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyException.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyException.java rename to core-java-modules/core-java-lang-oop-constructors/src/main/java/com/baeldung/supertypecompilerexception/MyException.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java b/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java rename to core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/EmployeeUnitTest.java b/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/EmployeeUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/EmployeeUnitTest.java rename to core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/EmployeeUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/ManagerUnitTest.java b/core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/ManagerUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/ManagerUnitTest.java rename to core-java-modules/core-java-lang-oop-constructors/src/test/java/com/baeldung/copyconstructor/ManagerUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/README.md b/core-java-modules/core-java-lang-oop-generics/README.md similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/README.md rename to core-java-modules/core-java-lang-oop-generics/README.md diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/pom.xml b/core-java-modules/core-java-lang-oop-generics/pom.xml similarity index 78% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/pom.xml rename to core-java-modules/core-java-lang-oop-generics/pom.xml index 167aa695e0..ae141ecda2 100644 --- a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/pom.xml +++ b/core-java-modules/core-java-lang-oop-generics/pom.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - core-java-lang-oop-modules - com.baeldung.core-java-lang-oop-modules + core-java-modules + com.baeldung.core-java-modules 1.0.0-SNAPSHOT 4.0.0 diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Entry.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Entry.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Entry.java rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Entry.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/GenericEntry.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/GenericEntry.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/GenericEntry.java rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/GenericEntry.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/MapEntry.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/MapEntry.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/MapEntry.java rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/MapEntry.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Product.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Product.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Product.java rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Product.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Rankable.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Rankable.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Rankable.java rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/generics/Rankable.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/rawtype/RawTypeDemo.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/rawtype/RawTypeDemo.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/rawtype/RawTypeDemo.java rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/rawtype/RawTypeDemo.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/ArrayContentPrintUtil.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/BoundStack.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/BoundStack.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/BoundStack.java rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/BoundStack.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/IntegerStack.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/IntegerStack.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/IntegerStack.java rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/IntegerStack.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/Stack.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/Stack.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/Stack.java rename to core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/Stack.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java b/core-java-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java rename to core-java-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/generics/GenericConstructorUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java b/core-java-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java rename to core-java-modules/core-java-lang-oop-generics/src/test/java/com/baeldung/typeerasure/TypeErasureUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/README.md b/core-java-modules/core-java-lang-oop-inheritance/README.md similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/README.md rename to core-java-modules/core-java-lang-oop-inheritance/README.md diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/pom.xml b/core-java-modules/core-java-lang-oop-inheritance/pom.xml similarity index 86% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/pom.xml rename to core-java-modules/core-java-lang-oop-inheritance/pom.xml index 8e7e8e374d..a48b28a289 100644 --- a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/pom.xml +++ b/core-java-modules/core-java-lang-oop-inheritance/pom.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - core-java-lang-oop-modules - com.baeldung.core-java-lang-oop-modules + core-java-modules + com.baeldung.core-java-modules 1.0.0-SNAPSHOT 4.0.0 diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/application/Application.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/application/Application.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/application/Application.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/application/Application.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/BaseFileReader.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/LowercaseFileReader.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/filereaders/UppercaseFileReader.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Book.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Book.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Book.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Book.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Main.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Main.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Main.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/anonymous/Main.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Animal.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Animal.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Animal.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Animal.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeeder.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeeder.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeeder.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeeder.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/AnimalFeederGeneric.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Cat.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Cat.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Cat.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Cat.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Dog.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Dog.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Dog.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Dog.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Mew.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Mew.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Mew.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/casting/Mew.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/ArmoredCar.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/ArmoredCar.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/ArmoredCar.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/ArmoredCar.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/BMW.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/BMW.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/BMW.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/BMW.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Car.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Car.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Car.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Car.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Employee.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Employee.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Employee.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Employee.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Floatable.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Floatable.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Floatable.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Floatable.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Flyable.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Flyable.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Flyable.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/Flyable.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceCar.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceCar.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceCar.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceCar.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceTraveller.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceTraveller.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceTraveller.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/inheritance/SpaceTraveller.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/CommaSeparatedCustomers.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/Customer.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/Customer.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/Customer.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/innerinterfaces/Customer.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Box.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Box.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Box.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Box.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Employee.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Employee.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Employee.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Employee.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/EmployeeSalaryComparator.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/HasColor.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/HasColor.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/HasColor.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/HasColor.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Car.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Fly.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Transform.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/multiinheritance/Vehicle.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Circle.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/MainTestClass.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Shape.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/polymorphysim/Square.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/KeywordDemo.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/KeywordDemo.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/KeywordDemo.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/KeywordDemo.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/FileManager.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/FileManager.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/FileManager.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/FileManager.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/GenericFile.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/GenericFile.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/GenericFile.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/GenericFile.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/ImageFile.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/ImageFile.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/ImageFile.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/ImageFile.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/TextFile.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/TextFile.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/TextFile.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/polymorphism/TextFile.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/BaseMethodClass.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/BaseMethodClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/BaseMethodClass.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/BaseMethodClass.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/ChildMethodClass.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/ChildMethodClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/ChildMethodClass.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/ChildMethodClass.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ChildVariable.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ChildVariable.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ChildVariable.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ChildVariable.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/HideVariable.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/HideVariable.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/HideVariable.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/HideVariable.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ParentVariable.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ParentVariable.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ParentVariable.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ParentVariable.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/resources/files/test.txt b/core-java-modules/core-java-lang-oop-inheritance/src/main/resources/files/test.txt similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/main/resources/files/test.txt rename to core-java-modules/core-java-lang-oop-inheritance/src/main/resources/files/test.txt diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java rename to core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java rename to core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/casting/CastingUnitTest.java b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/casting/CastingUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/casting/CastingUnitTest.java rename to core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/casting/CastingUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/inheritance/AppUnitTest.java b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/inheritance/AppUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/inheritance/AppUnitTest.java rename to core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/inheritance/AppUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java rename to core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/innerinterfaces/InnerInterfaceUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java rename to core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/polymorphism/PolymorphismUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/README.md b/core-java-modules/core-java-lang-oop-methods/README.md similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/README.md rename to core-java-modules/core-java-lang-oop-methods/README.md diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/pom.xml b/core-java-modules/core-java-lang-oop-methods/pom.xml similarity index 89% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/pom.xml rename to core-java-modules/core-java-lang-oop-methods/pom.xml index 062af9c3cd..77e8ded8e7 100644 --- a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/pom.xml +++ b/core-java-modules/core-java-lang-oop-methods/pom.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - core-java-lang-oop-modules - com.baeldung.core-java-lang-oop-modules + core-java-modules + com.baeldung.core-java-modules 1.0.0-SNAPSHOT 4.0.0 diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/basicmethods/PersonName.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/basicmethods/PersonName.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/basicmethods/PersonName.java rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/basicmethods/PersonName.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Money.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Money.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Money.java rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Money.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Team.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Team.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Team.java rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Team.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Voucher.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Voucher.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Voucher.java rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/Voucher.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongTeam.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongTeam.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongTeam.java rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongTeam.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/equalshashcode/WrongVoucher.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/entities/User.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/entities/User.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/entities/User.java rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/entities/User.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/application/Application.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Car.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/model/Vehicle.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methodoverloadingoverriding/util/Multiplier.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java rename to core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/MoneyUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java rename to core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java rename to core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java rename to core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java rename to core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java rename to core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/README.md b/core-java-modules/core-java-lang-oop-modifiers/README.md similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/README.md rename to core-java-modules/core-java-lang-oop-modifiers/README.md diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/pom.xml b/core-java-modules/core-java-lang-oop-modifiers/pom.xml similarity index 88% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/pom.xml rename to core-java-modules/core-java-lang-oop-modifiers/pom.xml index 11e0296266..615e20690f 100644 --- a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/pom.xml +++ b/core-java-modules/core-java-lang-oop-modifiers/pom.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - core-java-lang-oop-modules - com.baeldung.core-java-lang-oop-modules + core-java-modules + com.baeldung.core-java-modules 1.0.0-SNAPSHOT 4.0.0 diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/Public.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/Public.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/Public.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/Public.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SubClass.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SubClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SubClass.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SubClass.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/SuperPublic.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherPublic.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSubClass.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/another/AnotherSuperPublic.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/ListOfThree.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/ListOfThree.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/ListOfThree.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/ListOfThree.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/SpecialCharacters.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/SpecialCharacters.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/SpecialCharacters.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/SpecialCharacters.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/Student.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/Student.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/Student.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/Student.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/Employee.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/Employee.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/Employee.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/Employee.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/ExampleClass.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/ExampleClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/ExampleClass.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/ExampleClass.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/PublicOuterClass.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/PublicOuterClass.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/PublicOuterClass.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/PublicOuterClass.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/application/Application.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Alarm.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Car.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Motorbike.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/MultiAlarmCar.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/defaultstaticinterfacemethods/model/Vehicle.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackCat.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackCat.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackCat.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackCat.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackDog.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackDog.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackDog.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/BlackDog.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Cat.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Cat.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Cat.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Cat.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Dog.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Dog.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Dog.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/finalkeyword/Dog.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Car.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Car.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Car.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Car.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Singleton.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Singleton.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Singleton.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Singleton.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/StaticBlock.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/StaticBlock.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/StaticBlock.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/StaticBlock.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/Circle.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/Circle.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/Circle.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/Circle.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/ScientificCalculator.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/ScientificCalculator.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/ScientificCalculator.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/strictfpUsage/ScientificCalculator.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/accessmodifiers/publicmodifier/PublicAccessModifierUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/accessmodifiers/publicmodifier/PublicAccessModifierUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/accessmodifiers/publicmodifier/PublicAccessModifierUnitTest.java rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/accessmodifiers/publicmodifier/PublicAccessModifierUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/finalkeyword/FinalUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/CarUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/CarUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/CarUnitTest.java rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/CarUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/SingletonUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/SingletonUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/SingletonUnitTest.java rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/SingletonUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/StaticBlockUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/StaticBlockUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/StaticBlockUnitTest.java rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/StaticBlockUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/strictfpUsage/ScientificCalculatorUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/strictfpUsage/ScientificCalculatorUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/strictfpUsage/ScientificCalculatorUnitTest.java rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/strictfpUsage/ScientificCalculatorUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/pom.xml b/core-java-modules/core-java-lang-oop-modules/pom.xml deleted file mode 100644 index 39dfe16b17..0000000000 --- a/core-java-modules/core-java-lang-oop-modules/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - core-java-modules - com.baeldung.core-java-modules - 1.0.0-SNAPSHOT - - 4.0.0 - - com.baeldung.core-java-lang-oop-modules - core-java-lang-oop-modules - core-java-lang-oop-modules - pom - - - core-java-lang-oop-constructors - core-java-lang-oop-patterns - core-java-lang-oop-generics - core-java-lang-oop-modifiers - core-java-lang-oop-types - core-java-lang-oop-inheritance - core-java-lang-oop-methods - core-java-lang-oop-others - - \ No newline at end of file diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/README.md b/core-java-modules/core-java-lang-oop-others/README.md similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/README.md rename to core-java-modules/core-java-lang-oop-others/README.md diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/pom.xml b/core-java-modules/core-java-lang-oop-others/pom.xml similarity index 78% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/pom.xml rename to core-java-modules/core-java-lang-oop-others/pom.xml index 21699cd582..8eab301748 100644 --- a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/pom.xml +++ b/core-java-modules/core-java-lang-oop-others/pom.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - core-java-lang-oop-modules - com.baeldung.core-java-lang-oop-modules + core-java-modules + com.baeldung.core-java-modules 1.0.0-SNAPSHOT 4.0.0 diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Animal.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Animal.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Animal.java rename to core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Animal.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/AnimalActivity.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/AnimalActivity.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/AnimalActivity.java rename to core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/AnimalActivity.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Dog.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Dog.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Dog.java rename to core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/binding/Dog.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ArmoredCar.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ArmoredCar.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ArmoredCar.java rename to core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ArmoredCar.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Car.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Car.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Car.java rename to core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Car.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/GenericFile.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/GenericFile.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/GenericFile.java rename to core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/GenericFile.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ImageFile.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ImageFile.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ImageFile.java rename to core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/ImageFile.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/TextFile.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/TextFile.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/TextFile.java rename to core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/TextFile.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Vehicle.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Vehicle.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Vehicle.java rename to core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/oop/Vehicle.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java rename to core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/NonPrimitives.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/Primitives.java b/core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/Primitives.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/Primitives.java rename to core-java-modules/core-java-lang-oop-others/src/main/java/com/baeldung/parameterpassing/Primitives.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java b/core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java rename to core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalActivityUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalUnitTest.java b/core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalUnitTest.java rename to core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/AnimalUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/DogUnitTest.java b/core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/DogUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/DogUnitTest.java rename to core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/binding/DogUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java b/core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java rename to core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/NonPrimitivesUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java b/core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java rename to core-java-modules/core-java-lang-oop-others/src/test/java/com/baeldung/parameterpassing/PrimitivesUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/README.md b/core-java-modules/core-java-lang-oop-patterns/README.md similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/README.md rename to core-java-modules/core-java-lang-oop-patterns/README.md diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/pom.xml b/core-java-modules/core-java-lang-oop-patterns/pom.xml similarity index 91% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/pom.xml rename to core-java-modules/core-java-lang-oop-patterns/pom.xml index 5bd3c70542..0102ef2653 100644 --- a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/pom.xml +++ b/core-java-modules/core-java-lang-oop-patterns/pom.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - core-java-lang-oop-modules - com.baeldung.core-java-lang-oop-modules + core-java-modules + com.baeldung.core-java-modules 1.0.0-SNAPSHOT 4.0.0 diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/Address.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/Address.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/Address.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/Address.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/User.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/User.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/User.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/deepcopy/User.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Currency.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Currency.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Currency.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Currency.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Money.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Money.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Money.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/immutableobjects/Money.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/application/Application.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/application/Application.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/application/Application.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/application/Application.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Actress.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Computer.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Memory.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Person.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Person.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Person.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Person.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Processor.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/SoundCard.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardMemory.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardProcessor.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardSoundCard.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/Waitress.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Car.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Car.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Car.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Car.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/CarWithStaticInnerWheel.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/CarWithStaticInnerWheel.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/CarWithStaticInnerWheel.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/CarWithStaticInnerWheel.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Wheel.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Wheel.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Wheel.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/aggregation/Wheel.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Child.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Child.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Child.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Child.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Mother.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Mother.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Mother.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/association/Mother.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/Building.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/Building.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/Building.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/Building.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/BuildingWithDefinitionRoomInMethod.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/BuildingWithDefinitionRoomInMethod.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/BuildingWithDefinitionRoomInMethod.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/composition/BuildingWithDefinitionRoomInMethod.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Department.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Department.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Department.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Department.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Professor.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Professor.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Professor.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/Professor.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/University.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/University.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/University.java rename to core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/relationships/university/University.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java b/core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java rename to core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/DeepCopyUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java b/core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java rename to core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/deepcopy/ShallowCopyUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java b/core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java rename to core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/immutableobjects/ImmutableObjectsUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/ActressUnitTest.java b/core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/ActressUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/ActressUnitTest.java rename to core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/ActressUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/CompositionUnitTest.java b/core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/CompositionUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/CompositionUnitTest.java rename to core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/CompositionUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/InheritanceUnitTest.java b/core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/InheritanceUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/InheritanceUnitTest.java rename to core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/InheritanceUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/PersonUnitTest.java b/core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/PersonUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/PersonUnitTest.java rename to core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/PersonUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/WaitressUnitTest.java b/core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/WaitressUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/WaitressUnitTest.java rename to core-java-modules/core-java-lang-oop-patterns/src/test/java/com/baeldung/inheritancecomposition/WaitressUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/README.md b/core-java-modules/core-java-lang-oop-types/README.md similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/README.md rename to core-java-modules/core-java-lang-oop-types/README.md diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/pom.xml b/core-java-modules/core-java-lang-oop-types/pom.xml similarity index 78% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/pom.xml rename to core-java-modules/core-java-lang-oop-types/pom.xml index 156ff89ccd..f73434a9ff 100644 --- a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/pom.xml +++ b/core-java-modules/core-java-lang-oop-types/pom.xml @@ -3,8 +3,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - core-java-lang-oop-modules - com.baeldung.core-java-lang-oop-modules + core-java-modules + com.baeldung.core-java-modules 1.0.0-SNAPSHOT 4.0.0 diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java rename to core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/DeletableShape.java b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/DeletableShape.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/DeletableShape.java rename to core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/DeletableShape.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Rectangle.java b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Rectangle.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Rectangle.java rename to core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Rectangle.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Shape.java b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Shape.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Shape.java rename to core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/Shape.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/ShapeDao.java b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/ShapeDao.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/ShapeDao.java rename to core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/markerinterface/ShapeDao.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/objects/Car.java b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/objects/Car.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/main/java/com/baeldung/objects/Car.java rename to core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/objects/Car.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java rename to core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/markerinterface/MarkerInterfaceUnitTest.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInner.java b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInner.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInner.java rename to core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInner.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Enclosing.java b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Enclosing.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Enclosing.java rename to core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Enclosing.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewEnclosing.java b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewEnclosing.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewEnclosing.java rename to core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewEnclosing.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewOuter.java b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewOuter.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewOuter.java rename to core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/NewOuter.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Outer.java b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Outer.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Outer.java rename to core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/Outer.java diff --git a/core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/objects/ObjectsUnitTest.java b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/objects/ObjectsUnitTest.java similarity index 100% rename from core-java-modules/core-java-lang-oop-modules/core-java-lang-oop-types/src/test/java/com/baeldung/objects/ObjectsUnitTest.java rename to core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/objects/ObjectsUnitTest.java diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 995700d32c..c6cc3726e1 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -85,7 +85,14 @@ core-java-lang-2 core-java-lang-math core-java-lang-math-2 - core-java-lang-oop-modules + core-java-lang-oop-constructors + core-java-lang-oop-patterns + core-java-lang-oop-generics + core-java-lang-oop-modifiers + core-java-lang-oop-types + core-java-lang-oop-inheritance + core-java-lang-oop-methods + core-java-lang-oop-others core-java-lang-operators core-java-lang-syntax core-java-lang-syntax-2 From c02e57fe7e1a00244bd8f83959498f5547ec1388 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sat, 11 Apr 2020 10:27:16 +0200 Subject: [PATCH 369/503] [JAVA-621] Fixes due to minor article changes * Renamed KeywordUnitTest to Keyword as it's the chosen name for the article now --- .../{KeywordUnitTest.java => Keyword.java} | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/{KeywordUnitTest.java => Keyword.java} (68%) diff --git a/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/Keyword.java similarity index 68% rename from core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java rename to core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/Keyword.java index 35fd7358af..0c45f61e1d 100644 --- a/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/KeywordUnitTest.java +++ b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/Keyword.java @@ -1,17 +1,17 @@ package com.baeldung.keyword.thiskeyword; -public class KeywordUnitTest { +public class Keyword { private String name; private int age; - public KeywordUnitTest() { + public Keyword() { this("John", 27); this.printMessage(); printInstance(this); } - public KeywordUnitTest(String name, int age) { + public Keyword(String name, int age) { this.name = name; this.age = age; } @@ -20,11 +20,11 @@ public class KeywordUnitTest { System.out.println("invoked by this"); } - public void printInstance(KeywordUnitTest thisKeyword) { + public void printInstance(Keyword thisKeyword) { System.out.println(thisKeyword); } - public KeywordUnitTest getCurrentInstance() { + public Keyword getCurrentInstance() { return this; } @@ -33,8 +33,8 @@ public class KeywordUnitTest { boolean isInnerClass = true; public ThisInnerClass() { - KeywordUnitTest thisKeyword = KeywordUnitTest.this; - String outerString = KeywordUnitTest.this.name; + Keyword thisKeyword = Keyword.this; + String outerString = Keyword.this.name; System.out.println(this.isInnerClass); } } From 4f75f2d5b0e4c93df9ba6f48662467f96bf066bb Mon Sep 17 00:00:00 2001 From: dupirefr Date: Tue, 21 Apr 2020 08:52:04 +0200 Subject: [PATCH 370/503] [JAVA-621] Ensuring each article has its own package * Putting test classes directly under abstractclasses package (no need for test subpackage, we're already in test sources) * Removed unnecessary keyword package to just let superkeyword * Renamed scope package to variableandmethodhiding * Renamed package basicmethods into methods * Putting test classes directly under methodoverloadingoverriding package (no need for test subpackage, we're already in test sources) * Moved publicmodifier package under com.baeldung as it contains code from a separate article * Moved privatemodifier under com.baeldung as it was under an unnecessary core package * Renamed staticdemo package into staticmodifier (was more adequate with other modifiers articles) * Putting test classes directly under defaultstaticinterfacemethods package (no need for test subpackage, we're already in test sources) * Moved thiskeyword package to com.baeldung instead of under keywords package --- .../com/baeldung/{keyword => }/superkeyword/KeywordDemo.java | 2 +- .../com/baeldung/{keyword => }/superkeyword/SuperBase.java | 2 +- .../com/baeldung/{keyword => }/superkeyword/SuperSub.java | 2 +- .../method/BaseMethodClass.java | 2 +- .../method/ChildMethodClass.java | 2 +- .../method/MethodHidingDemo.java | 2 +- .../variable/ChildVariable.java | 2 +- .../variable/HideVariable.java | 2 +- .../variable/ParentVariable.java | 2 +- .../variable/VariableHidingDemo.java | 2 +- .../{test => }/LowercaseFileReaderUnitTest.java | 2 +- .../{test => }/UppercaseFileReaderUnitTest.java | 2 +- .../com/baeldung/{basicmethods => methods}/PersonName.java | 2 +- .../{test => }/MethodOverloadingUnitTest.java | 2 +- .../{test => }/MethodOverridingUnitTest.java | 2 +- .../com/baeldung/{core => }/privatemodifier/Employee.java | 2 +- .../com/baeldung/{core => }/privatemodifier/ExampleClass.java | 2 +- .../baeldung/{core => }/privatemodifier/PublicOuterClass.java | 2 +- .../{accessmodifiers => }/publicmodifier/ListOfThree.java | 2 +- .../publicmodifier/SpecialCharacters.java | 2 +- .../{accessmodifiers => }/publicmodifier/Student.java | 2 +- .../java/com/baeldung/{staticdemo => staticmodifier}/Car.java | 2 +- .../baeldung/{staticdemo => staticmodifier}/Singleton.java | 2 +- .../baeldung/{staticdemo => staticmodifier}/StaticBlock.java | 2 +- .../{test => }/StaticDefaulInterfaceMethodUnitTest.java | 2 +- .../publicmodifier/PublicAccessModifierUnitTest.java | 4 +--- .../baeldung/{staticdemo => staticmodifier}/CarUnitTest.java | 2 +- .../{staticdemo => staticmodifier}/SingletonUnitTest.java | 2 +- .../{staticdemo => staticmodifier}/StaticBlockUnitTest.java | 2 +- .../java/com/baeldung/{keyword => }/thiskeyword/Keyword.java | 2 +- 30 files changed, 30 insertions(+), 32 deletions(-) rename core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/{keyword => }/superkeyword/KeywordDemo.java (82%) rename core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/{keyword => }/superkeyword/SuperBase.java (87%) rename core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/{keyword => }/superkeyword/SuperSub.java (91%) rename core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/{scope => variableandmethodhiding}/method/BaseMethodClass.java (71%) rename core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/{scope => variableandmethodhiding}/method/ChildMethodClass.java (74%) rename core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/{scope => variableandmethodhiding}/method/MethodHidingDemo.java (70%) rename core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/{scope => variableandmethodhiding}/variable/ChildVariable.java (81%) rename core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/{scope => variableandmethodhiding}/variable/HideVariable.java (89%) rename core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/{scope => variableandmethodhiding}/variable/ParentVariable.java (80%) rename core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/{scope => variableandmethodhiding}/variable/VariableHidingDemo.java (89%) rename core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/{test => }/LowercaseFileReaderUnitTest.java (94%) rename core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/{test => }/UppercaseFileReaderUnitTest.java (94%) rename core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/{basicmethods => methods}/PersonName.java (96%) rename core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/{test => }/MethodOverloadingUnitTest.java (95%) rename core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/{test => }/MethodOverridingUnitTest.java (97%) rename core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/{core => }/privatemodifier/Employee.java (96%) rename core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/{core => }/privatemodifier/ExampleClass.java (84%) rename core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/{core => }/privatemodifier/PublicOuterClass.java (90%) rename core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/{accessmodifiers => }/publicmodifier/ListOfThree.java (92%) rename core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/{accessmodifiers => }/publicmodifier/SpecialCharacters.java (61%) rename core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/{accessmodifiers => }/publicmodifier/Student.java (96%) rename core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/{staticdemo => staticmodifier}/Car.java (96%) rename core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/{staticdemo => staticmodifier}/Singleton.java (88%) rename core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/{staticdemo => staticmodifier}/StaticBlock.java (93%) rename core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/{test => }/StaticDefaulInterfaceMethodUnitTest.java (97%) rename core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/{accessmodifiers => }/publicmodifier/PublicAccessModifierUnitTest.java (93%) rename core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/{staticdemo => staticmodifier}/CarUnitTest.java (88%) rename core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/{staticdemo => staticmodifier}/SingletonUnitTest.java (90%) rename core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/{staticdemo => staticmodifier}/StaticBlockUnitTest.java (92%) rename core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/{keyword => }/thiskeyword/Keyword.java (95%) diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/KeywordDemo.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/KeywordDemo.java similarity index 82% rename from core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/KeywordDemo.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/KeywordDemo.java index 7414e52b1c..0e5bd489bb 100644 --- a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/KeywordDemo.java +++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/KeywordDemo.java @@ -1,4 +1,4 @@ -package com.baeldung.keyword.superkeyword; +package com.baeldung.superkeyword; /** * Created by Gebruiker on 5/14/2018. diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/SuperBase.java similarity index 87% rename from core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/SuperBase.java index a5304fcef9..ec6a90cb06 100644 --- a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperBase.java +++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/SuperBase.java @@ -1,4 +1,4 @@ -package com.baeldung.keyword.superkeyword; +package com.baeldung.superkeyword; /** * Created by Gebruiker on 5/14/2018. diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/SuperSub.java similarity index 91% rename from core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/SuperSub.java index 83bc04ad0f..ada52e4ff2 100644 --- a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/keyword/superkeyword/SuperSub.java +++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/superkeyword/SuperSub.java @@ -1,4 +1,4 @@ -package com.baeldung.keyword.superkeyword; +package com.baeldung.superkeyword; /** * Created by Gebruiker on 5/15/2018. diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/BaseMethodClass.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/BaseMethodClass.java similarity index 71% rename from core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/BaseMethodClass.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/BaseMethodClass.java index 46ed5fd99f..7e6b08c000 100644 --- a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/BaseMethodClass.java +++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/BaseMethodClass.java @@ -1,4 +1,4 @@ -package com.baeldung.scope.method; +package com.baeldung.variableandmethodhiding.method; public class BaseMethodClass { diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/ChildMethodClass.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/ChildMethodClass.java similarity index 74% rename from core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/ChildMethodClass.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/ChildMethodClass.java index 1d0cff2d6b..30db54cd84 100644 --- a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/ChildMethodClass.java +++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/ChildMethodClass.java @@ -1,4 +1,4 @@ -package com.baeldung.scope.method; +package com.baeldung.variableandmethodhiding.method; public class ChildMethodClass extends BaseMethodClass { diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/MethodHidingDemo.java similarity index 70% rename from core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/MethodHidingDemo.java index 7e0b3ed146..ce1feac665 100644 --- a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/method/MethodHidingDemo.java +++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/method/MethodHidingDemo.java @@ -1,4 +1,4 @@ -package com.baeldung.scope.method; +package com.baeldung.variableandmethodhiding.method; public class MethodHidingDemo { diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ChildVariable.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/ChildVariable.java similarity index 81% rename from core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ChildVariable.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/ChildVariable.java index 5730e5e282..83434f7dd3 100644 --- a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ChildVariable.java +++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/ChildVariable.java @@ -1,4 +1,4 @@ -package com.baeldung.scope.variable; +package com.baeldung.variableandmethodhiding.variable; /** * Created by Gebruiker on 5/7/2018. diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/HideVariable.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/HideVariable.java similarity index 89% rename from core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/HideVariable.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/HideVariable.java index 8243fdb249..98a29573b8 100644 --- a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/HideVariable.java +++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/HideVariable.java @@ -1,4 +1,4 @@ -package com.baeldung.scope.variable; +package com.baeldung.variableandmethodhiding.variable; /** * Created by Gebruiker on 5/6/2018. diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ParentVariable.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/ParentVariable.java similarity index 80% rename from core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ParentVariable.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/ParentVariable.java index 7f116b955e..ef17305746 100644 --- a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/ParentVariable.java +++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/ParentVariable.java @@ -1,4 +1,4 @@ -package com.baeldung.scope.variable; +package com.baeldung.variableandmethodhiding.variable; /** * Created by Gebruiker on 5/7/2018. diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/VariableHidingDemo.java similarity index 89% rename from core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java rename to core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/VariableHidingDemo.java index 1ad71bd966..0fd83ad55e 100644 --- a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/scope/variable/VariableHidingDemo.java +++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/variableandmethodhiding/variable/VariableHidingDemo.java @@ -1,4 +1,4 @@ -package com.baeldung.scope.variable; +package com.baeldung.variableandmethodhiding.variable; /** * Created by Gebruiker on 5/6/2018. diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/LowercaseFileReaderUnitTest.java similarity index 94% rename from core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java rename to core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/LowercaseFileReaderUnitTest.java index 45e16f0d25..8e970fc0c7 100644 --- a/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/LowercaseFileReaderUnitTest.java +++ b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/LowercaseFileReaderUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.abstractclasses.test; +package com.baeldung.abstractclasses; import com.baeldung.abstractclasses.filereaders.BaseFileReader; import com.baeldung.abstractclasses.filereaders.LowercaseFileReader; diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/UppercaseFileReaderUnitTest.java similarity index 94% rename from core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java rename to core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/UppercaseFileReaderUnitTest.java index dc4df900e4..e7b83a97e6 100644 --- a/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/test/UppercaseFileReaderUnitTest.java +++ b/core-java-modules/core-java-lang-oop-inheritance/src/test/java/com/baeldung/abstractclasses/UppercaseFileReaderUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.abstractclasses.test; +package com.baeldung.abstractclasses; import com.baeldung.abstractclasses.filereaders.BaseFileReader; import com.baeldung.abstractclasses.filereaders.UppercaseFileReader; diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/basicmethods/PersonName.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/PersonName.java similarity index 96% rename from core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/basicmethods/PersonName.java rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/PersonName.java index 43bbf0dd62..d1f3f58b8c 100644 --- a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/basicmethods/PersonName.java +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/methods/PersonName.java @@ -1,4 +1,4 @@ -package com.baeldung.basicmethods; +package com.baeldung.methods; import java.io.FileWriter; import java.io.IOException; diff --git a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/MethodOverloadingUnitTest.java similarity index 95% rename from core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java rename to core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/MethodOverloadingUnitTest.java index 081a30c34a..476e70618f 100644 --- a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverloadingUnitTest.java +++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/MethodOverloadingUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.methodoverloadingoverriding.test; +package com.baeldung.methodoverloadingoverriding; import com.baeldung.methodoverloadingoverriding.util.Multiplier; import org.junit.BeforeClass; diff --git a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/MethodOverridingUnitTest.java similarity index 97% rename from core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java rename to core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/MethodOverridingUnitTest.java index 554ac121bc..f4142d7382 100644 --- a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/test/MethodOverridingUnitTest.java +++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/methodoverloadingoverriding/MethodOverridingUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.methodoverloadingoverriding.test; +package com.baeldung.methodoverloadingoverriding; import com.baeldung.methodoverloadingoverriding.model.Car; import com.baeldung.methodoverloadingoverriding.model.Vehicle; diff --git a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/Employee.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/Employee.java similarity index 96% rename from core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/Employee.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/Employee.java index 4598400e93..a0f7829d51 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/Employee.java +++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/Employee.java @@ -1,4 +1,4 @@ -package com.baeldung.core.privatemodifier; +package com.baeldung.privatemodifier; public class Employee { diff --git a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/ExampleClass.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/ExampleClass.java similarity index 84% rename from core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/ExampleClass.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/ExampleClass.java index 8659b4ad9c..c87980fbe8 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/ExampleClass.java +++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/ExampleClass.java @@ -1,4 +1,4 @@ -package com.baeldung.core.privatemodifier; +package com.baeldung.privatemodifier; public class ExampleClass { diff --git a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/PublicOuterClass.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/PublicOuterClass.java similarity index 90% rename from core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/PublicOuterClass.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/PublicOuterClass.java index 8a9e8a8eb3..082d08b034 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/core/privatemodifier/PublicOuterClass.java +++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/privatemodifier/PublicOuterClass.java @@ -1,4 +1,4 @@ -package com.baeldung.core.privatemodifier; +package com.baeldung.privatemodifier; public class PublicOuterClass { diff --git a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/ListOfThree.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/ListOfThree.java similarity index 92% rename from core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/ListOfThree.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/ListOfThree.java index 2ded0ba5d3..0e3449f451 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/ListOfThree.java +++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/ListOfThree.java @@ -1,4 +1,4 @@ -package com.baeldung.accessmodifiers.publicmodifier; +package com.baeldung.publicmodifier; import java.util.AbstractList; import java.util.Arrays; diff --git a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/SpecialCharacters.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/SpecialCharacters.java similarity index 61% rename from core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/SpecialCharacters.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/SpecialCharacters.java index 5556e9aa57..633308e707 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/SpecialCharacters.java +++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/SpecialCharacters.java @@ -1,4 +1,4 @@ -package com.baeldung.accessmodifiers.publicmodifier; +package com.baeldung.publicmodifier; public class SpecialCharacters { diff --git a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/Student.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/Student.java similarity index 96% rename from core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/Student.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/Student.java index 83a0dcb30f..5aa80286bf 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/accessmodifiers/publicmodifier/Student.java +++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/publicmodifier/Student.java @@ -1,4 +1,4 @@ -package com.baeldung.accessmodifiers.publicmodifier; +package com.baeldung.publicmodifier; import java.math.BigDecimal; import java.sql.Connection; diff --git a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Car.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/Car.java similarity index 96% rename from core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Car.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/Car.java index cdb3806c35..950f008dcd 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Car.java +++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/Car.java @@ -1,4 +1,4 @@ -package com.baeldung.staticdemo; +package com.baeldung.staticmodifier; /** * This class demonstrates the use of static fields and static methods diff --git a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Singleton.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/Singleton.java similarity index 88% rename from core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Singleton.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/Singleton.java index de75af9d9d..6e7dcf7c60 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/Singleton.java +++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/Singleton.java @@ -1,4 +1,4 @@ -package com.baeldung.staticdemo; +package com.baeldung.staticmodifier; public class Singleton { private Singleton() {} diff --git a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/StaticBlock.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/StaticBlock.java similarity index 93% rename from core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/StaticBlock.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/StaticBlock.java index fde7afb090..f3eb447bdd 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticdemo/StaticBlock.java +++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/StaticBlock.java @@ -1,4 +1,4 @@ -package com.baeldung.staticdemo; +package com.baeldung.staticmodifier; import java.util.LinkedList; import java.util.List; diff --git a/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/StaticDefaulInterfaceMethodUnitTest.java similarity index 97% rename from core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/StaticDefaulInterfaceMethodUnitTest.java index e90f239756..0dffe8f80e 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/test/StaticDefaulInterfaceMethodUnitTest.java +++ b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/defaultstaticinterfacemethods/StaticDefaulInterfaceMethodUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.defaultstaticinterfacemethods.test; +package com.baeldung.defaultstaticinterfacemethods; import com.baeldung.defaultstaticinterfacemethods.model.Car; import com.baeldung.defaultstaticinterfacemethods.model.Motorbike; diff --git a/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/accessmodifiers/publicmodifier/PublicAccessModifierUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/publicmodifier/PublicAccessModifierUnitTest.java similarity index 93% rename from core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/accessmodifiers/publicmodifier/PublicAccessModifierUnitTest.java rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/publicmodifier/PublicAccessModifierUnitTest.java index c2897e7434..8c014e703b 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/accessmodifiers/publicmodifier/PublicAccessModifierUnitTest.java +++ b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/publicmodifier/PublicAccessModifierUnitTest.java @@ -1,7 +1,5 @@ -package com.baeldung.accessmodifiers.publicmodifier; +package com.baeldung.publicmodifier; -import com.baeldung.accessmodifiers.publicmodifier.ListOfThree; -import com.baeldung.accessmodifiers.publicmodifier.Student; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance.Lifecycle; diff --git a/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/CarUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/CarUnitTest.java similarity index 88% rename from core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/CarUnitTest.java rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/CarUnitTest.java index 3deec6f41c..f55955caa8 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/CarUnitTest.java +++ b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/CarUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.staticdemo; +package com.baeldung.staticmodifier; import static org.junit.Assert.*; diff --git a/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/SingletonUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/SingletonUnitTest.java similarity index 90% rename from core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/SingletonUnitTest.java rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/SingletonUnitTest.java index c1a1e1abe4..6371fd4961 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/SingletonUnitTest.java +++ b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/SingletonUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.staticdemo; +package com.baeldung.staticmodifier; import org.junit.Assert; import org.junit.Test; diff --git a/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/StaticBlockUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/StaticBlockUnitTest.java similarity index 92% rename from core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/StaticBlockUnitTest.java rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/StaticBlockUnitTest.java index 79ba4427bf..03f3e0440c 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticdemo/StaticBlockUnitTest.java +++ b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/StaticBlockUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.staticdemo; +package com.baeldung.staticmodifier; import static org.hamcrest.collection.IsIterableContainingInOrder.contains; import static org.junit.Assert.assertThat; diff --git a/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/Keyword.java b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/thiskeyword/Keyword.java similarity index 95% rename from core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/Keyword.java rename to core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/thiskeyword/Keyword.java index 0c45f61e1d..a09a1ac8e1 100644 --- a/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/keyword/thiskeyword/Keyword.java +++ b/core-java-modules/core-java-lang-oop-types/src/main/java/com/baeldung/thiskeyword/Keyword.java @@ -1,4 +1,4 @@ -package com.baeldung.keyword.thiskeyword; +package com.baeldung.thiskeyword; public class Keyword { From f56bf16d112c600fc1c6422341fcf4d91c1a52e0 Mon Sep 17 00:00:00 2001 From: Mrudav Shukla Date: Sun, 8 Jul 2018 17:41:29 +0530 Subject: [PATCH 371/503] BAEL-1921 - added example code and unit test for GlobalExceptionHandler (#4646) * added example code and unit test for GlobalExceptionHandler * Code for common exceptions --- .../reflection/exceptions/Arithmetic.java | 20 ++++++ .../exceptions/ArrayIndexOutOfBounds.java | 24 +++++++ .../reflection/exceptions/ClassCast.java | 36 +++++++++++ .../reflection/exceptions/FileNotFound.java | 25 ++++++++ .../exceptions/GlobalExceptionHandler.java | 28 ++++++++ .../exceptions/IllegalArgument.java | 18 ++++++ .../reflection/exceptions/IllegalState.java | 32 ++++++++++ .../InterruptedExceptionExample.java | 28 ++++++++ .../reflection/exceptions/MalformedURL.java | 25 ++++++++ .../reflection/exceptions/NullPointer.java | 36 +++++++++++ .../reflection/exceptions/NumberFormat.java | 23 +++++++ .../exceptions/ParseExceptionExample.java | 25 ++++++++ .../exceptions/StringIndexOutOfBounds.java | 23 +++++++ .../GlobalExceptionHandlerUnitTest.java | 64 +++++++++++++++++++ 14 files changed, 407 insertions(+) create mode 100644 core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/Arithmetic.java create mode 100644 core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ArrayIndexOutOfBounds.java create mode 100644 core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ClassCast.java create mode 100644 core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/FileNotFound.java create mode 100644 core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/GlobalExceptionHandler.java create mode 100644 core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/IllegalArgument.java create mode 100644 core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/IllegalState.java create mode 100644 core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/InterruptedExceptionExample.java create mode 100644 core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/MalformedURL.java create mode 100644 core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/NullPointer.java create mode 100644 core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/NumberFormat.java create mode 100644 core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ParseExceptionExample.java create mode 100644 core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/StringIndexOutOfBounds.java create mode 100644 core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exceptions/GlobalExceptionHandlerUnitTest.java diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/Arithmetic.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/Arithmetic.java new file mode 100644 index 0000000000..138916ec60 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/Arithmetic.java @@ -0,0 +1,20 @@ +package com.baeldung.exceptions; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Arithmetic { + + private static Logger LOGGER = LoggerFactory.getLogger(Arithmetic.class); + + public static void main(String[] args) { + + try { + int result = 30 / 0; // Trying to divide by zero + } catch (ArithmeticException e) { + LOGGER.error("ArithmeticException caught!"); + } + + } + +} diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ArrayIndexOutOfBounds.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ArrayIndexOutOfBounds.java new file mode 100644 index 0000000000..93b53f284c --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ArrayIndexOutOfBounds.java @@ -0,0 +1,24 @@ +package com.baeldung.exceptions; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ArrayIndexOutOfBounds { + + private static Logger LOGGER = LoggerFactory.getLogger(ArrayIndexOutOfBounds.class); + + public static void main(String[] args) { + + int[] nums = new int[] { 1, 2, 3 }; + + try { + int numFromNegativeIndex = nums[-1]; // Trying to access at negative index + int numFromGreaterIndex = nums[4]; // Trying to access at greater index + int numFromLengthIndex = nums[3]; // Trying to access at index equal to size of the array + } catch (ArrayIndexOutOfBoundsException e) { + LOGGER.error("ArrayIndexOutOfBoundsException caught"); + } + + } + +} diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ClassCast.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ClassCast.java new file mode 100644 index 0000000000..183f8f54a3 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ClassCast.java @@ -0,0 +1,36 @@ +package com.baeldung.exceptions; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +class Animal { + +} + +class Dog extends Animal { + +} + +class Lion extends Animal { + +} + +public class ClassCast { + + private static Logger LOGGER = LoggerFactory.getLogger(ClassCast.class); + + public static void main(String[] args) { + + try { + Animal animalOne = new Dog(); // At runtime the instance is dog + Dog bruno = (Dog) animalOne; // Downcasting + + Animal animalTwo = new Lion(); // At runtime the instance is animal + Dog tommy = (Dog) animalTwo; // Downcasting + } catch (ClassCastException e) { + LOGGER.error("ClassCastException caught!"); + } + + } + +} diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/FileNotFound.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/FileNotFound.java new file mode 100644 index 0000000000..bb9e0bf4ac --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/FileNotFound.java @@ -0,0 +1,25 @@ +package com.baeldung.exceptions; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class FileNotFound { + + private static Logger LOGGER = LoggerFactory.getLogger(FileNotFound.class); + + public static void main(String[] args) { + + BufferedReader reader = null; + try { + reader = new BufferedReader(new FileReader(new File("/invalid/file/location"))); + } catch (FileNotFoundException e) { + LOGGER.error("FileNotFoundException caught!"); + } + } + +} diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/GlobalExceptionHandler.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/GlobalExceptionHandler.java new file mode 100644 index 0000000000..ab46c83da4 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/GlobalExceptionHandler.java @@ -0,0 +1,28 @@ +package com.baeldung.exceptions; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class GlobalExceptionHandler { + + public static void main(String[] args) { + + Handler globalExceptionHandler = new Handler(); + Thread.setDefaultUncaughtExceptionHandler(globalExceptionHandler); + new GlobalExceptionHandler().performArithmeticOperation(10, 0); + } + + public int performArithmeticOperation(int num1, int num2) { + return num1/num2; + } + +} + +class Handler implements Thread.UncaughtExceptionHandler { + + private static Logger LOGGER = LoggerFactory.getLogger(Handler.class); + + public void uncaughtException(Thread t, Throwable e) { + LOGGER.info("Unhandled exception caught!"); + } +} diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/IllegalArgument.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/IllegalArgument.java new file mode 100644 index 0000000000..801536cb2d --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/IllegalArgument.java @@ -0,0 +1,18 @@ +package com.baeldung.exceptions; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class IllegalArgument { + + private static Logger LOGGER = LoggerFactory.getLogger(IllegalArgument.class); + + public static void main(String[] args) { + try { + Thread.sleep(-1000); + } catch (InterruptedException e) { + LOGGER.error("IllegalArgumentException caught!"); + } + } + +} diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/IllegalState.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/IllegalState.java new file mode 100644 index 0000000000..e8ddcea3c2 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/IllegalState.java @@ -0,0 +1,32 @@ +package com.baeldung.exceptions; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class IllegalState { + + private static Logger LOGGER = LoggerFactory.getLogger(IllegalState.class); + + public static void main(String[] args) { + + List intList = new ArrayList<>(); + + for (int i = 0; i < 10; i++) { + intList.add(i); + } + + Iterator intListIterator = intList.iterator(); // Initialized with index at -1 + + try { + intListIterator.remove(); // IllegalStateException + } catch (IllegalStateException e) { + LOGGER.error("IllegalStateException caught!"); + } + + } + +} diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/InterruptedExceptionExample.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/InterruptedExceptionExample.java new file mode 100644 index 0000000000..319fd33591 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/InterruptedExceptionExample.java @@ -0,0 +1,28 @@ +package com.baeldung.exceptions; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +class ChildThread extends Thread { + + private static Logger LOGGER = LoggerFactory.getLogger(ChildThread.class); + + public void run() { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + LOGGER.error("InterruptedException caught!"); + } + } + +} + +public class InterruptedExceptionExample { + + public static void main(String[] args) throws InterruptedException { + ChildThread childThread = new ChildThread(); + childThread.start(); + childThread.interrupt(); + } + +} diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/MalformedURL.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/MalformedURL.java new file mode 100644 index 0000000000..57fcddf76b --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/MalformedURL.java @@ -0,0 +1,25 @@ +package com.baeldung.exceptions; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class MalformedURL { + + private static Logger LOGGER = LoggerFactory.getLogger(MalformedURL.class); + + public static void main(String[] args) { + + URL baeldungURL = null; + + try { + baeldungURL = new URL("malformedurl"); + } catch (MalformedURLException e) { + LOGGER.error("MalformedURLException caught!"); + } + + } + +} diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/NullPointer.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/NullPointer.java new file mode 100644 index 0000000000..2402a786a9 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/NullPointer.java @@ -0,0 +1,36 @@ +package com.baeldung.exceptions; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NullPointer { + + private static Logger LOGGER = LoggerFactory.getLogger(NullPointer.class); + + public static void main(String[] args) { + + Person personObj = null; + + try { + String name = personObj.personName; // Accessing the field of a null object + personObj.personName = "Jon Doe"; // Modifying the field of a null object + } catch (NullPointerException e) { + LOGGER.error("NullPointerException caught!"); + } + + } +} + +class Person { + + public String personName; + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + +} diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/NumberFormat.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/NumberFormat.java new file mode 100644 index 0000000000..7050e70aee --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/NumberFormat.java @@ -0,0 +1,23 @@ +package com.baeldung.exceptions; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NumberFormat { + + private static Logger LOGGER = LoggerFactory.getLogger(NumberFormat.class); + + public static void main(String[] args) { + + String str1 = "100ABCD"; + + try { + int x = Integer.parseInt(str1); // Converting string with inappropriate format + int y = Integer.valueOf(str1); + } catch (NumberFormatException e) { + LOGGER.error("NumberFormatException caught!"); + } + + } + +} diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ParseExceptionExample.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ParseExceptionExample.java new file mode 100644 index 0000000000..f7fb4c91e4 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ParseExceptionExample.java @@ -0,0 +1,25 @@ +package com.baeldung.exceptions; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ParseExceptionExample { + + private static Logger LOGGER = LoggerFactory.getLogger(ParseExceptionExample.class); + + public static void main(String[] args) { + + DateFormat format = new SimpleDateFormat("MM, dd, yyyy"); + + try { + format.parse("01, , 2010"); + } catch (ParseException e) { + LOGGER.error("ParseException caught!"); + } + } + +} diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/StringIndexOutOfBounds.java b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/StringIndexOutOfBounds.java new file mode 100644 index 0000000000..bc297be498 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/StringIndexOutOfBounds.java @@ -0,0 +1,23 @@ +package com.baeldung.exceptions; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class StringIndexOutOfBounds { + + private static Logger LOGGER = LoggerFactory.getLogger(StringIndexOutOfBounds.class); + + public static void main(String[] args) { + + String str = "Hello World"; + + try { + char charAtNegativeIndex = str.charAt(-1); // Trying to access at negative index + char charAtLengthIndex = str.charAt(11); // Trying to access at index equal to size of the string + } catch (StringIndexOutOfBoundsException e) { + LOGGER.error("StringIndexOutOfBoundsException caught"); + } + + } + +} diff --git a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exceptions/GlobalExceptionHandlerUnitTest.java b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exceptions/GlobalExceptionHandlerUnitTest.java new file mode 100644 index 0000000000..394de9c576 --- /dev/null +++ b/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exceptions/GlobalExceptionHandlerUnitTest.java @@ -0,0 +1,64 @@ +package com.baeldung.exceptions; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.slf4j.LoggerFactory; +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.classic.spi.LoggingEvent; +import ch.qos.logback.core.Appender; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.verify; + +@RunWith(MockitoJUnitRunner.class) +public class GlobalExceptionHandlerUnitTest { + + @Mock + private Appender mockAppender; + + @Captor + private ArgumentCaptor captorLoggingEvent; + + @Before + public void setup() { + final Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); + logger.addAppender(mockAppender); + + Handler globalExceptionHandler = new Handler(); + Thread.setDefaultUncaughtExceptionHandler(globalExceptionHandler); + } + + @After + public void teardown() { + final Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); + logger.detachAppender(mockAppender); + } + + @Test + public void whenArithmeticException_thenUseUncaughtExceptionHandler() throws InterruptedException { + + Thread globalExceptionHandlerThread = new Thread() { + public void run() { + GlobalExceptionHandler globalExceptionHandlerObj = new GlobalExceptionHandler(); + globalExceptionHandlerObj.performArithmeticOperation(99, 0); + } + }; + + globalExceptionHandlerThread.start(); + globalExceptionHandlerThread.join(); + + verify(mockAppender).doAppend(captorLoggingEvent.capture()); + LoggingEvent loggingEvent = captorLoggingEvent.getValue(); + + assertThat(loggingEvent.getLevel()).isEqualTo(Level.INFO); + assertThat(loggingEvent.getFormattedMessage()).isEqualTo("Unhandled exception caught!"); + } + +} From aec4ed2d5c3939b9c21ff84ff2cd34c0f15f1d54 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Tue, 28 Apr 2020 18:20:23 +0530 Subject: [PATCH 372/503] JAVA-928: Migrate property-exp-default-config to parent-boot-2 --- .../property-exp-custom-config/pom.xml | 8 +++++++- .../java/{org => com}/baeldung/SpringContextTest.java | 0 .../property-exp-default-config/pom.xml | 4 ++-- .../java/{org => com}/baeldung/SpringContextTest.java | 0 4 files changed, 9 insertions(+), 3 deletions(-) rename spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/{org => com}/baeldung/SpringContextTest.java (100%) rename spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/{org => com}/baeldung/SpringContextTest.java (100%) diff --git a/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/pom.xml b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/pom.xml index 8ea9c8366d..e38a2742d5 100644 --- a/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/pom.xml +++ b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/pom.xml @@ -24,6 +24,12 @@ spring-boot-starter-test ${spring-boot.version} test + + + org.junit.vintage + junit-vintage-engine + + @@ -72,7 +78,7 @@ - 1.5.10.RELEASE + 2.2.6.RELEASE Custom Property Value 2.7 1.6.0 diff --git a/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-property-exp/property-exp-custom-config/src/test/java/com/baeldung/SpringContextTest.java diff --git a/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/pom.xml b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/pom.xml index aa5b8ef34a..79e194a3b5 100644 --- a/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/pom.xml +++ b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../../../parent-boot-1 + ../../../parent-boot-2 diff --git a/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/com/baeldung/SpringContextTest.java similarity index 100% rename from spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java rename to spring-boot-modules/spring-boot-property-exp/property-exp-default-config/src/test/java/com/baeldung/SpringContextTest.java From aa7daf7901d2951fc05fac9e5c352c1fe87dfc3a Mon Sep 17 00:00:00 2001 From: dupirefr Date: Tue, 28 Apr 2020 08:05:50 +0200 Subject: [PATCH 373/503] [JAVA-621] Added missing code * https://www.baeldung.com/java-type-erasure introduction code * https://www.baeldung.com/java-interfaces Electronic interface and Computer class * https://www.baeldung.com/java-abstract-class BoardGame and Checkers classes * https://www.baeldung.com/java-hashcode different ways of implementing hashCode * https://www.baeldung.com/java-inheritance-composition ComputerBuilder and StandardComputerBuilder classes * https://www.baeldung.com/java-equals-hashcode-contracts Renamed method to match article * https://www.baeldung.com/java-static Renamed class to match article * https://www.baeldung.com/java-nested-classes Renamed class to match article --- .../com/baeldung/typeerasure/Example.java | 13 ++++++ .../abstractclasses/overview/BoardGame.java | 9 ++++ .../abstractclasses/overview/Checkers.java | 8 ++++ .../com/baeldung/interfaces/Computer.java | 9 ++++ .../com/baeldung/interfaces/Electronic.java | 22 ++++++++++ .../core-java-lang-oop-methods/pom.xml | 14 +++++++ .../baeldung/hashcode/apachecommons/User.java | 42 +++++++++++++++++++ .../com/baeldung/hashcode/eclipse/User.java | 42 +++++++++++++++++++ .../com/baeldung/hashcode/improved/User.java | 37 ++++++++++++++++ .../com/baeldung/hashcode/intellij/User.java | 40 ++++++++++++++++++ .../com/baeldung/hashcode/lombok/User.java | 22 ++++++++++ .../com/baeldung/hashcode/naive/User.java | 37 ++++++++++++++++ .../hashcode/{entities => standard}/User.java | 3 +- .../baeldung/equalshashcode/TeamUnitTest.java | 2 +- ...{StaticBlock.java => StaticBlockDemo.java} | 4 +- ...Test.java => StaticBlockDemoUnitTest.java} | 4 +- .../model/ComputerBuilder.java | 13 ++++++ .../model/StandardComputerBuilder.java | 13 ++++++ ...mousInner.java => AnonymousInnerTest.java} | 2 +- 19 files changed, 328 insertions(+), 8 deletions(-) create mode 100644 core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/Example.java create mode 100644 core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/overview/BoardGame.java create mode 100644 core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/overview/Checkers.java create mode 100644 core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Computer.java create mode 100644 core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Electronic.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/apachecommons/User.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/eclipse/User.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/improved/User.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/intellij/User.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/lombok/User.java create mode 100644 core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/naive/User.java rename core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/{entities => standard}/User.java (89%) rename core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/{StaticBlock.java => StaticBlockDemo.java} (87%) rename core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/{StaticBlockUnitTest.java => StaticBlockDemoUnitTest.java} (80%) create mode 100644 core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/ComputerBuilder.java create mode 100644 core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardComputerBuilder.java rename core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/{AnonymousInner.java => AnonymousInnerTest.java} (91%) diff --git a/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/Example.java b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/Example.java new file mode 100644 index 0000000000..f816fd6d16 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-generics/src/main/java/com/baeldung/typeerasure/Example.java @@ -0,0 +1,13 @@ +package com.baeldung.typeerasure; + +public class Example { + + public static boolean containsElement(E [] elements, E element){ + for (E e : elements){ + if(e.equals(element)){ + return true; + } + } + return false; + } +} diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/overview/BoardGame.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/overview/BoardGame.java new file mode 100644 index 0000000000..e0395cec7e --- /dev/null +++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/overview/BoardGame.java @@ -0,0 +1,9 @@ +package com.baeldung.abstractclasses.overview; + +public abstract class BoardGame { + //... field declarations, constructors + + public abstract void play(); + + //... concrete methods +} diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/overview/Checkers.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/overview/Checkers.java new file mode 100644 index 0000000000..5c911649c8 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/abstractclasses/overview/Checkers.java @@ -0,0 +1,8 @@ +package com.baeldung.abstractclasses.overview; + +public class Checkers extends BoardGame { + @Override + public void play() { + //... implementation + } +} diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Computer.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Computer.java new file mode 100644 index 0000000000..94d39e2448 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Computer.java @@ -0,0 +1,9 @@ +package com.baeldung.interfaces; + +public class Computer implements Electronic { + + @Override + public int getElectricityUse() { + return 1000; + } +} diff --git a/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Electronic.java b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Electronic.java new file mode 100644 index 0000000000..fcaf67dc3a --- /dev/null +++ b/core-java-modules/core-java-lang-oop-inheritance/src/main/java/com/baeldung/interfaces/Electronic.java @@ -0,0 +1,22 @@ +package com.baeldung.interfaces; + +public interface Electronic { + // Constant variable + String LED = "LED"; + + // Abstract method + int getElectricityUse(); + + // Static method + static boolean isEnergyEfficient(String electtronicType) { + if (electtronicType.equals(LED)) { + return true; + } + return false; + } + + //Default method + default void printDescription() { + System.out.println("Electronic Description"); + } +} diff --git a/core-java-modules/core-java-lang-oop-methods/pom.xml b/core-java-modules/core-java-lang-oop-methods/pom.xml index 77e8ded8e7..3590b85454 100644 --- a/core-java-modules/core-java-lang-oop-methods/pom.xml +++ b/core-java-modules/core-java-lang-oop-methods/pom.xml @@ -14,6 +14,17 @@ jar + + org.projectlombok + lombok + ${lombok.version} + + + commons-lang + commons-lang + ${commons-lang.version} + + org.assertj assertj-core @@ -29,6 +40,9 @@ + 1.18.12 + 2.6 + 3.10.0 3.0.3 diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/apachecommons/User.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/apachecommons/User.java new file mode 100644 index 0000000000..4be082019a --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/apachecommons/User.java @@ -0,0 +1,42 @@ +package com.baeldung.hashcode.apachecommons; + +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class User { + + private final Logger logger = LoggerFactory.getLogger(User.class); + private long id; + private String name; + private String email; + + public User(long id, String name, String email) { + this.id = id; + this.name = name; + this.email = email; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null) + return false; + if (this.getClass() != o.getClass()) + return false; + User user = (User) o; + return id == user.id && (name.equals(user.name) && email.equals(user.email)); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37). + append(id). + append(name). + append(email). + toHashCode(); + } + // getters and setters here + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/eclipse/User.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/eclipse/User.java new file mode 100644 index 0000000000..e852eef96e --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/eclipse/User.java @@ -0,0 +1,42 @@ +package com.baeldung.hashcode.eclipse; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class User { + + private final Logger logger = LoggerFactory.getLogger(User.class); + private long id; + private String name; + private String email; + + public User(long id, String name, String email) { + this.id = id; + this.name = name; + this.email = email; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null) + return false; + if (this.getClass() != o.getClass()) + return false; + User user = (User) o; + return id == user.id && (name.equals(user.name) && email.equals(user.email)); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((email == null) ? 0 : email.hashCode()); + result = prime * result + (int) (id ^ (id >>> 32)); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + // getters and setters here + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/improved/User.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/improved/User.java new file mode 100644 index 0000000000..773a2c7e45 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/improved/User.java @@ -0,0 +1,37 @@ +package com.baeldung.hashcode.improved; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class User { + + private final Logger logger = LoggerFactory.getLogger(User.class); + private long id; + private String name; + private String email; + + public User(long id, String name, String email) { + this.id = id; + this.name = name; + this.email = email; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null) + return false; + if (this.getClass() != o.getClass()) + return false; + User user = (User) o; + return id == user.id && (name.equals(user.name) && email.equals(user.email)); + } + + @Override + public int hashCode() { + return (int) id * name.hashCode() * email.hashCode(); + } + // getters and setters here + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/intellij/User.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/intellij/User.java new file mode 100644 index 0000000000..f7bf1ab735 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/intellij/User.java @@ -0,0 +1,40 @@ +package com.baeldung.hashcode.intellij; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class User { + + private final Logger logger = LoggerFactory.getLogger(User.class); + private long id; + private String name; + private String email; + + public User(long id, String name, String email) { + this.id = id; + this.name = name; + this.email = email; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null) + return false; + if (this.getClass() != o.getClass()) + return false; + User user = (User) o; + return id == user.id && (name.equals(user.name) && email.equals(user.email)); + } + + @Override + public int hashCode() { + int result = (int) (id ^ (id >>> 32)); + result = 31 * result + name.hashCode(); + result = 31 * result + email.hashCode(); + return result; + } + // getters and setters here + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/lombok/User.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/lombok/User.java new file mode 100644 index 0000000000..e34246ce24 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/lombok/User.java @@ -0,0 +1,22 @@ +package com.baeldung.hashcode.lombok; + +import lombok.EqualsAndHashCode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@EqualsAndHashCode +public class User { + + private final Logger logger = LoggerFactory.getLogger(User.class); + private long id; + private String name; + private String email; + + public User(long id, String name, String email) { + this.id = id; + this.name = name; + this.email = email; + } + // getters and setters here + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/naive/User.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/naive/User.java new file mode 100644 index 0000000000..b0a33ad3e9 --- /dev/null +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/naive/User.java @@ -0,0 +1,37 @@ +package com.baeldung.hashcode.naive; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class User { + + private final Logger logger = LoggerFactory.getLogger(User.class); + private long id; + private String name; + private String email; + + public User(long id, String name, String email) { + this.id = id; + this.name = name; + this.email = email; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null) + return false; + if (this.getClass() != o.getClass()) + return false; + User user = (User) o; + return id == user.id && (name.equals(user.name) && email.equals(user.email)); + } + + @Override + public int hashCode() { + return 1; + } + // getters and setters here + +} diff --git a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/entities/User.java b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/standard/User.java similarity index 89% rename from core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/entities/User.java rename to core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/standard/User.java index 524f176e6b..f8fd5cedbd 100644 --- a/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/entities/User.java +++ b/core-java-modules/core-java-lang-oop-methods/src/main/java/com/baeldung/hashcode/standard/User.java @@ -1,4 +1,4 @@ -package com.baeldung.hashcode.entities; +package com.baeldung.hashcode.standard; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -34,7 +34,6 @@ public class User { hash = 31 * hash + (int) id; hash = 31 * hash + (name == null ? 0 : name.hashCode()); hash = 31 * hash + (email == null ? 0 : email.hashCode()); - logger.info("hashCode() method called - Computed hash: " + hash); return hash; } // getters and setters here diff --git a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java index 7dfc6d47a3..308004452b 100644 --- a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java +++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/equalshashcode/TeamUnitTest.java @@ -38,7 +38,7 @@ public class TeamUnitTest { } @Test - public void equalsContract() { + public void equalsHashCodeContracts() { EqualsVerifier.forClass(Team.class).verify(); } diff --git a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/StaticBlock.java b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/StaticBlockDemo.java similarity index 87% rename from core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/StaticBlock.java rename to core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/StaticBlockDemo.java index f3eb447bdd..637bb5e82a 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/StaticBlock.java +++ b/core-java-modules/core-java-lang-oop-modifiers/src/main/java/com/baeldung/staticmodifier/StaticBlockDemo.java @@ -3,7 +3,7 @@ package com.baeldung.staticmodifier; import java.util.LinkedList; import java.util.List; -public class StaticBlock { +public class StaticBlockDemo { private static List ranks = new LinkedList<>(); static { @@ -23,6 +23,6 @@ public class StaticBlock { } public static void setRanks(List ranks) { - StaticBlock.ranks = ranks; + StaticBlockDemo.ranks = ranks; } } diff --git a/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/StaticBlockUnitTest.java b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/StaticBlockDemoUnitTest.java similarity index 80% rename from core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/StaticBlockUnitTest.java rename to core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/StaticBlockDemoUnitTest.java index 03f3e0440c..f31a8e8895 100644 --- a/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/StaticBlockUnitTest.java +++ b/core-java-modules/core-java-lang-oop-modifiers/src/test/java/com/baeldung/staticmodifier/StaticBlockDemoUnitTest.java @@ -7,11 +7,11 @@ import java.util.List; import org.junit.Test; -public class StaticBlockUnitTest { +public class StaticBlockDemoUnitTest { @Test public void whenAddedListElementsThroughStaticBlock_thenEnsureCorrectOrder() { - List actualList = StaticBlock.getRanks(); + List actualList = StaticBlockDemo.getRanks(); assertThat(actualList, contains("Lieutenant", "Captain", "Major", "Colonel", "General")); } } diff --git a/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/ComputerBuilder.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/ComputerBuilder.java new file mode 100644 index 0000000000..4d8574e93f --- /dev/null +++ b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/ComputerBuilder.java @@ -0,0 +1,13 @@ +package com.baeldung.inheritancecomposition.model; + +public abstract class ComputerBuilder { + + public final void buildComputer() { + addProcessor(); + addMemory(); + } + + public abstract void addProcessor(); + + public abstract void addMemory(); +} diff --git a/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardComputerBuilder.java b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardComputerBuilder.java new file mode 100644 index 0000000000..76c4732ace --- /dev/null +++ b/core-java-modules/core-java-lang-oop-patterns/src/main/java/com/baeldung/inheritancecomposition/model/StandardComputerBuilder.java @@ -0,0 +1,13 @@ +package com.baeldung.inheritancecomposition.model; + +public class StandardComputerBuilder extends ComputerBuilder { + @Override + public void addProcessor() { + // method implementation + } + + @Override + public void addMemory() { + // method implementation + } +} diff --git a/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInner.java b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInnerTest.java similarity index 91% rename from core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInner.java rename to core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInnerTest.java index 9fa8ee9cd5..4e49bb5b41 100644 --- a/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInner.java +++ b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInnerTest.java @@ -6,7 +6,7 @@ abstract class SimpleAbstractClass { abstract void run(); } -public class AnonymousInner { +public class AnonymousInnerTest { @Test public void run() { From 9e83dbbc854f40b2b7ba6367cf8c3c16431652d3 Mon Sep 17 00:00:00 2001 From: mikr Date: Tue, 28 Apr 2020 22:12:00 +0200 Subject: [PATCH 374/503] JAVA-618 Restore code for Global Exception Handler --- .../baeldung/exceptions/globalexceptionhandler}/Arithmetic.java | 2 +- .../globalexceptionhandler}/ArrayIndexOutOfBounds.java | 2 +- .../baeldung/exceptions/globalexceptionhandler}/ClassCast.java | 2 +- .../exceptions/globalexceptionhandler}/FileNotFound.java | 2 +- .../globalexceptionhandler}/GlobalExceptionHandler.java | 2 +- .../exceptions/globalexceptionhandler}/IllegalArgument.java | 2 +- .../exceptions/globalexceptionhandler}/IllegalState.java | 2 +- .../globalexceptionhandler}/InterruptedExceptionExample.java | 2 +- .../exceptions/globalexceptionhandler}/MalformedURL.java | 2 +- .../exceptions/globalexceptionhandler}/NullPointer.java | 2 +- .../exceptions/globalexceptionhandler}/NumberFormat.java | 2 +- .../globalexceptionhandler}/ParseExceptionExample.java | 2 +- .../globalexceptionhandler}/StringIndexOutOfBounds.java | 2 +- .../globalexceptionhandler}/GlobalExceptionHandlerUnitTest.java | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/exceptions => core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler}/Arithmetic.java (87%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/exceptions => core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler}/ArrayIndexOutOfBounds.java (92%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/exceptions => core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler}/ClassCast.java (92%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/exceptions => core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler}/FileNotFound.java (91%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/exceptions => core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler}/GlobalExceptionHandler.java (92%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/exceptions => core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler}/IllegalArgument.java (87%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/exceptions => core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler}/IllegalState.java (92%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/exceptions => core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler}/InterruptedExceptionExample.java (91%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/exceptions => core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler}/MalformedURL.java (89%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/exceptions => core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler}/NullPointer.java (93%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/exceptions => core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler}/NumberFormat.java (90%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/exceptions => core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler}/ParseExceptionExample.java (90%) rename core-java-modules/{core-java-reflection/src/main/java/com/baeldung/reflection/exceptions => core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler}/StringIndexOutOfBounds.java (91%) rename core-java-modules/{core-java-reflection/src/test/java/com/baeldung/reflection/exceptions => core-java-exceptions/src/test/java/com/baeldung/exceptions/globalexceptionhandler}/GlobalExceptionHandlerUnitTest.java (97%) diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/Arithmetic.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/Arithmetic.java similarity index 87% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/Arithmetic.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/Arithmetic.java index 138916ec60..db29198b39 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/Arithmetic.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/Arithmetic.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.exceptions.globalexceptionhandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ArrayIndexOutOfBounds.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/ArrayIndexOutOfBounds.java similarity index 92% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ArrayIndexOutOfBounds.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/ArrayIndexOutOfBounds.java index 93b53f284c..54c95f224c 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ArrayIndexOutOfBounds.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/ArrayIndexOutOfBounds.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.exceptions.globalexceptionhandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ClassCast.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/ClassCast.java similarity index 92% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ClassCast.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/ClassCast.java index 183f8f54a3..8f8a6cf9e6 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ClassCast.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/ClassCast.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.exceptions.globalexceptionhandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/FileNotFound.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/FileNotFound.java similarity index 91% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/FileNotFound.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/FileNotFound.java index bb9e0bf4ac..a9f2e5ee84 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/FileNotFound.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/FileNotFound.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.exceptions.globalexceptionhandler; import java.io.BufferedReader; import java.io.File; diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/GlobalExceptionHandler.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/GlobalExceptionHandler.java similarity index 92% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/GlobalExceptionHandler.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/GlobalExceptionHandler.java index ab46c83da4..f2e89f44e3 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/GlobalExceptionHandler.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/GlobalExceptionHandler.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.exceptions.globalexceptionhandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/IllegalArgument.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/IllegalArgument.java similarity index 87% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/IllegalArgument.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/IllegalArgument.java index 801536cb2d..d54757dfac 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/IllegalArgument.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/IllegalArgument.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.exceptions.globalexceptionhandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/IllegalState.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/IllegalState.java similarity index 92% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/IllegalState.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/IllegalState.java index e8ddcea3c2..0a812d2b82 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/IllegalState.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/IllegalState.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.exceptions.globalexceptionhandler; import java.util.ArrayList; import java.util.Iterator; diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/InterruptedExceptionExample.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/InterruptedExceptionExample.java similarity index 91% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/InterruptedExceptionExample.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/InterruptedExceptionExample.java index 319fd33591..d0c8bb2cd0 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/InterruptedExceptionExample.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/InterruptedExceptionExample.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.exceptions.globalexceptionhandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/MalformedURL.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/MalformedURL.java similarity index 89% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/MalformedURL.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/MalformedURL.java index 57fcddf76b..9a02f005fd 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/MalformedURL.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/MalformedURL.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.exceptions.globalexceptionhandler; import java.net.MalformedURLException; import java.net.URL; diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/NullPointer.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/NullPointer.java similarity index 93% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/NullPointer.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/NullPointer.java index 2402a786a9..445cbecdc8 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/NullPointer.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/NullPointer.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.exceptions.globalexceptionhandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/NumberFormat.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/NumberFormat.java similarity index 90% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/NumberFormat.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/NumberFormat.java index 7050e70aee..576fe51f78 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/NumberFormat.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/NumberFormat.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.exceptions.globalexceptionhandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ParseExceptionExample.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/ParseExceptionExample.java similarity index 90% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ParseExceptionExample.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/ParseExceptionExample.java index f7fb4c91e4..e3b3e04b10 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/ParseExceptionExample.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/ParseExceptionExample.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.exceptions.globalexceptionhandler; import java.text.DateFormat; import java.text.ParseException; diff --git a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/StringIndexOutOfBounds.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/StringIndexOutOfBounds.java similarity index 91% rename from core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/StringIndexOutOfBounds.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/StringIndexOutOfBounds.java index bc297be498..0ee132e568 100644 --- a/core-java-modules/core-java-reflection/src/main/java/com/baeldung/reflection/exceptions/StringIndexOutOfBounds.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/globalexceptionhandler/StringIndexOutOfBounds.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.exceptions.globalexceptionhandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exceptions/GlobalExceptionHandlerUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/globalexceptionhandler/GlobalExceptionHandlerUnitTest.java similarity index 97% rename from core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exceptions/GlobalExceptionHandlerUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/globalexceptionhandler/GlobalExceptionHandlerUnitTest.java index 394de9c576..74ceb3b442 100644 --- a/core-java-modules/core-java-reflection/src/test/java/com/baeldung/reflection/exceptions/GlobalExceptionHandlerUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/globalexceptionhandler/GlobalExceptionHandlerUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.exceptions.globalexceptionhandler; import org.junit.After; import org.junit.Before; From c223b669be5cc7d913aac5821bd9af034a7a543f Mon Sep 17 00:00:00 2001 From: Marcos Lopez Gonzalez Date: Mon, 15 Apr 2019 20:47:23 +0200 Subject: [PATCH 375/503] root cause finder --- .../baeldung/exceptions/RootCauseFinder.java | 61 +++++++++++++++++++ .../exceptions/RootCauseFinderTest.java | 51 ++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 core-java-modules/core-java-lang-2/src/test/java/com/baeldung/exceptions/RootCauseFinder.java create mode 100644 core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java diff --git a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/exceptions/RootCauseFinder.java b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/exceptions/RootCauseFinder.java new file mode 100644 index 0000000000..a7963c35a8 --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/exceptions/RootCauseFinder.java @@ -0,0 +1,61 @@ +package com.baeldung.exceptions; + +import java.util.Objects; + +/** + * Utility class to find root cause exceptions. + */ +public class RootCauseFinder { + + public static Throwable findCauseUsingPlainJava(Throwable throwable) { + Objects.requireNonNull(throwable); + Throwable rootCause = throwable; + while (rootCause.getCause() != null) { + rootCause = rootCause.getCause(); + } + return rootCause; + } + + static class IntParser { + + private IntParser() { + } + + public static int parse(String input) throws InvalidNumber { + if (input == null || input.isEmpty()) { + throw new IllegalArgumentException(); + } + + try { + return new IntParser().stringToInt(input.trim()); + } catch (NaNException ex) { + throw new InvalidNumber(input, ex); + } + } + + private int stringToInt(String numberAsString) throws NaNException { + try { + return Integer.valueOf(numberAsString); + } catch (NumberFormatException ex) { + throw new NaNException(numberAsString, ex); + } + } + + } + + static class InvalidNumber extends Exception { + + InvalidNumber(String input, Throwable thr) { + super("Invalid input for a number: " + input, thr); + } + } + + static class NaNException extends Exception { + + NaNException(String number, Throwable thr) { + super(number + "is not a number", thr); + } + + } + +} diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java new file mode 100644 index 0000000000..1e58e3f602 --- /dev/null +++ b/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java @@ -0,0 +1,51 @@ +package com.baeldung.exceptions; + +import com.google.common.base.Throwables; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.junit.jupiter.api.Test; + +import static com.baeldung.exceptions.RootCauseFinder.*; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Tests the {@link RootCauseFinder}. + */ +public class RootCauseFinderTest { + + @Test + public void givenNestedException_whenFindingRootCauseUsingJava_thenRootCauseFound() { + try { + IntParser.parse("text"); + } catch (InvalidNumber ex) { + assertTrue(findCauseUsingPlainJava(ex) instanceof NumberFormatException); + } + } + + @Test + public void givenNonNestedException_whenFindingRootCauseUsingJava_thenRootCauseFound() { + try { + IntParser.parse(null); + } catch (Exception ex) { + assertTrue(findCauseUsingPlainJava(ex) instanceof IllegalArgumentException); + } + } + + @Test + public void givenNestedException_whenFindingRootCauseUsingApacheCommons_thenRootCauseFound() { + try { + IntParser.parse("text"); + } catch (InvalidNumber ex) { + assertTrue(ExceptionUtils.getRootCause(ex) instanceof NumberFormatException); + } + } + + @Test + public void givenNestedException_whenFindingRootCauseUsingGuava_thenRootCauseFound() { + try { + IntParser.parse("text"); + } catch (InvalidNumber ex) { + assertTrue(Throwables.getRootCause(ex) instanceof NumberFormatException); + } + } + +} From c59d9dbf8f886a80d1b1dd2a7b1e3cc2593099e6 Mon Sep 17 00:00:00 2001 From: Marcos Lopez Gonzalez Date: Mon, 29 Apr 2019 19:58:51 +0200 Subject: [PATCH 376/503] changed example for finder of root cause exception --- .../baeldung/exceptions/RootCauseFinder.java | 68 ++++++++++++++----- .../exceptions/RootCauseFinderTest.java | 57 ++++++++++++---- 2 files changed, 94 insertions(+), 31 deletions(-) diff --git a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/exceptions/RootCauseFinder.java b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/exceptions/RootCauseFinder.java index a7963c35a8..11f29a2cf0 100644 --- a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/exceptions/RootCauseFinder.java +++ b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/exceptions/RootCauseFinder.java @@ -1,5 +1,8 @@ package com.baeldung.exceptions; +import java.time.LocalDate; +import java.time.Period; +import java.time.format.DateTimeParseException; import java.util.Objects; /** @@ -16,44 +19,75 @@ public class RootCauseFinder { return rootCause; } - static class IntParser { + /** + * Calculates the age of a person from a given date. + */ + static class AgeCalculator { - private IntParser() { + private AgeCalculator() { } - public static int parse(String input) throws InvalidNumber { - if (input == null || input.isEmpty()) { + public static int calculateAge(String birthDate) throws CalculationException { + if (birthDate == null || birthDate.isEmpty()) { throw new IllegalArgumentException(); } try { - return new IntParser().stringToInt(input.trim()); - } catch (NaNException ex) { - throw new InvalidNumber(input, ex); + return calculateDifference(birthDate).getYears(); + } catch (DateParseException ex) { + throw new CalculationException(ex); } } - private int stringToInt(String numberAsString) throws NaNException { + private static Period calculateDifference(String birthDateAsString) throws DateParseException { + + LocalDate birthDate = null; try { - return Integer.valueOf(numberAsString); - } catch (NumberFormatException ex) { - throw new NaNException(numberAsString, ex); + birthDate = LocalDate.parse(birthDateAsString); + } catch (DateTimeParseException ex) { + throw new InvalidFormatException(birthDateAsString, ex); } + + LocalDate today = LocalDate.now(); + + if (birthDate.isAfter(today)) { + throw new DateOutOfRangeException(birthDateAsString); + } + + return Period.between(birthDate, today); } } - static class InvalidNumber extends Exception { + static class CalculationException extends Exception { - InvalidNumber(String input, Throwable thr) { - super("Invalid input for a number: " + input, thr); + CalculationException(DateParseException ex) { + super(ex); } } - static class NaNException extends Exception { + static class DateParseException extends Exception { - NaNException(String number, Throwable thr) { - super(number + "is not a number", thr); + DateParseException(String input) { + super(input); + } + + DateParseException(String input, Throwable thr) { + super(input, thr); + } + } + + static class InvalidFormatException extends DateParseException { + + InvalidFormatException(String input, Throwable thr) { + super("Invalid date format: " + input, thr); + } + } + + static class DateOutOfRangeException extends DateParseException { + + DateOutOfRangeException(String date) { + super("Date out of range: " + date); } } diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java index 1e58e3f602..c333a7ac26 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java @@ -4,6 +4,8 @@ import com.google.common.base.Throwables; import org.apache.commons.lang3.exception.ExceptionUtils; import org.junit.jupiter.api.Test; +import java.time.format.DateTimeParseException; + import static com.baeldung.exceptions.RootCauseFinder.*; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -13,38 +15,65 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class RootCauseFinderTest { @Test - public void givenNestedException_whenFindingRootCauseUsingJava_thenRootCauseFound() { + public void givenWrongFormatDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { try { - IntParser.parse("text"); - } catch (InvalidNumber ex) { - assertTrue(findCauseUsingPlainJava(ex) instanceof NumberFormatException); + AgeCalculator.calculateAge("010102"); + } catch (CalculationException ex) { + assertTrue(findCauseUsingPlainJava(ex) instanceof DateTimeParseException); } } @Test - public void givenNonNestedException_whenFindingRootCauseUsingJava_thenRootCauseFound() { + public void givenOutOfRangeDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { try { - IntParser.parse(null); + AgeCalculator.calculateAge("2020-04-04"); + } catch (CalculationException ex) { + assertTrue(findCauseUsingPlainJava(ex) instanceof DateOutOfRangeException); + } + } + + @Test + public void givenNullDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { + try { + AgeCalculator.calculateAge(null); } catch (Exception ex) { assertTrue(findCauseUsingPlainJava(ex) instanceof IllegalArgumentException); } } @Test - public void givenNestedException_whenFindingRootCauseUsingApacheCommons_thenRootCauseFound() { + public void givenWrongFormatDate_whenFindingRootCauseUsingApacheCommons_thenRootCauseFound() { try { - IntParser.parse("text"); - } catch (InvalidNumber ex) { - assertTrue(ExceptionUtils.getRootCause(ex) instanceof NumberFormatException); + AgeCalculator.calculateAge("010102"); + } catch (CalculationException ex) { + assertTrue(ExceptionUtils.getRootCause(ex) instanceof DateTimeParseException); } } @Test - public void givenNestedException_whenFindingRootCauseUsingGuava_thenRootCauseFound() { + public void givenOutOfRangeDate_whenFindingRootCauseUsingApacheCommons_thenRootCauseFound() { try { - IntParser.parse("text"); - } catch (InvalidNumber ex) { - assertTrue(Throwables.getRootCause(ex) instanceof NumberFormatException); + AgeCalculator.calculateAge("2020-04-04"); + } catch (CalculationException ex) { + assertTrue(ExceptionUtils.getRootCause(ex) instanceof DateOutOfRangeException); + } + } + + @Test + public void givenWrongFormatDate_whenFindingRootCauseUsingGuava_thenRootCauseFound() { + try { + AgeCalculator.calculateAge("010102"); + } catch (CalculationException ex) { + assertTrue(Throwables.getRootCause(ex) instanceof DateTimeParseException); + } + } + + @Test + public void givenOutOfRangeDate_whenFindingRootCauseUsingGuava_thenRootCauseFound() { + try { + AgeCalculator.calculateAge("2020-04-04"); + } catch (CalculationException ex) { + assertTrue(Throwables.getRootCause(ex) instanceof DateOutOfRangeException); } } From cdd14b23f7b491964d0c755d2248f8bf886db80b Mon Sep 17 00:00:00 2001 From: Marcos Lopez Gonzalez Date: Wed, 1 May 2019 13:10:42 +0200 Subject: [PATCH 377/503] AgeCalculator changes --- .../com/baeldung/exceptions/RootCauseFinder.java | 14 +++++++------- .../baeldung/exceptions/RootCauseFinderTest.java | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/exceptions/RootCauseFinder.java b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/exceptions/RootCauseFinder.java index 11f29a2cf0..e05dc7a6cd 100644 --- a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/exceptions/RootCauseFinder.java +++ b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/exceptions/RootCauseFinder.java @@ -33,28 +33,28 @@ public class RootCauseFinder { } try { - return calculateDifference(birthDate).getYears(); + return Period + .between(parseDate(birthDate), LocalDate.now()) + .getYears(); } catch (DateParseException ex) { throw new CalculationException(ex); } } - private static Period calculateDifference(String birthDateAsString) throws DateParseException { + private static LocalDate parseDate(String birthDateAsString) throws DateParseException { - LocalDate birthDate = null; + LocalDate birthDate; try { birthDate = LocalDate.parse(birthDateAsString); } catch (DateTimeParseException ex) { throw new InvalidFormatException(birthDateAsString, ex); } - LocalDate today = LocalDate.now(); - - if (birthDate.isAfter(today)) { + if (birthDate.isAfter(LocalDate.now())) { throw new DateOutOfRangeException(birthDateAsString); } - return Period.between(birthDate, today); + return birthDate; } } diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java index c333a7ac26..cfac81b812 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java +++ b/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java @@ -2,9 +2,12 @@ package com.baeldung.exceptions; import com.google.common.base.Throwables; import org.apache.commons.lang3.exception.ExceptionUtils; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; +import java.time.LocalDate; import java.time.format.DateTimeParseException; +import java.time.temporal.ChronoUnit; import static com.baeldung.exceptions.RootCauseFinder.*; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -14,6 +17,19 @@ import static org.junit.jupiter.api.Assertions.assertTrue; */ public class RootCauseFinderTest { + @Test + public void givenBirthDate_whenCalculatingAge_thenAgeReturned() { + try { + int age = AgeCalculator.calculateAge("1990-01-01"); + Assertions.assertEquals(1990, LocalDate + .now() + .minus(age, ChronoUnit.YEARS) + .getYear()); + } catch (CalculationException e) { + Assertions.fail(e.getMessage()); + } + } + @Test public void givenWrongFormatDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { try { From d973864c8b014e3c7db92dd14d6751e8e5980054 Mon Sep 17 00:00:00 2001 From: Marcos Lopez Gonzalez Date: Wed, 1 May 2019 13:10:42 +0200 Subject: [PATCH 378/503] AgeCalculator changesJava-618 Restore RootCauseFinder code --- .../baeldung/exceptions/RootCauseFinder.java | 95 ++++++++++++++++++ .../exceptions/RootCauseFinderTest.java | 96 +++++++++++++++++++ 2 files changed, 191 insertions(+) create mode 100644 core-java/src/main/java/com/baeldung/exceptions/RootCauseFinder.java create mode 100644 core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java diff --git a/core-java/src/main/java/com/baeldung/exceptions/RootCauseFinder.java b/core-java/src/main/java/com/baeldung/exceptions/RootCauseFinder.java new file mode 100644 index 0000000000..e05dc7a6cd --- /dev/null +++ b/core-java/src/main/java/com/baeldung/exceptions/RootCauseFinder.java @@ -0,0 +1,95 @@ +package com.baeldung.exceptions; + +import java.time.LocalDate; +import java.time.Period; +import java.time.format.DateTimeParseException; +import java.util.Objects; + +/** + * Utility class to find root cause exceptions. + */ +public class RootCauseFinder { + + public static Throwable findCauseUsingPlainJava(Throwable throwable) { + Objects.requireNonNull(throwable); + Throwable rootCause = throwable; + while (rootCause.getCause() != null) { + rootCause = rootCause.getCause(); + } + return rootCause; + } + + /** + * Calculates the age of a person from a given date. + */ + static class AgeCalculator { + + private AgeCalculator() { + } + + public static int calculateAge(String birthDate) throws CalculationException { + if (birthDate == null || birthDate.isEmpty()) { + throw new IllegalArgumentException(); + } + + try { + return Period + .between(parseDate(birthDate), LocalDate.now()) + .getYears(); + } catch (DateParseException ex) { + throw new CalculationException(ex); + } + } + + private static LocalDate parseDate(String birthDateAsString) throws DateParseException { + + LocalDate birthDate; + try { + birthDate = LocalDate.parse(birthDateAsString); + } catch (DateTimeParseException ex) { + throw new InvalidFormatException(birthDateAsString, ex); + } + + if (birthDate.isAfter(LocalDate.now())) { + throw new DateOutOfRangeException(birthDateAsString); + } + + return birthDate; + } + + } + + static class CalculationException extends Exception { + + CalculationException(DateParseException ex) { + super(ex); + } + } + + static class DateParseException extends Exception { + + DateParseException(String input) { + super(input); + } + + DateParseException(String input, Throwable thr) { + super(input, thr); + } + } + + static class InvalidFormatException extends DateParseException { + + InvalidFormatException(String input, Throwable thr) { + super("Invalid date format: " + input, thr); + } + } + + static class DateOutOfRangeException extends DateParseException { + + DateOutOfRangeException(String date) { + super("Date out of range: " + date); + } + + } + +} diff --git a/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java b/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java new file mode 100644 index 0000000000..cfac81b812 --- /dev/null +++ b/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java @@ -0,0 +1,96 @@ +package com.baeldung.exceptions; + +import com.google.common.base.Throwables; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.time.LocalDate; +import java.time.format.DateTimeParseException; +import java.time.temporal.ChronoUnit; + +import static com.baeldung.exceptions.RootCauseFinder.*; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Tests the {@link RootCauseFinder}. + */ +public class RootCauseFinderTest { + + @Test + public void givenBirthDate_whenCalculatingAge_thenAgeReturned() { + try { + int age = AgeCalculator.calculateAge("1990-01-01"); + Assertions.assertEquals(1990, LocalDate + .now() + .minus(age, ChronoUnit.YEARS) + .getYear()); + } catch (CalculationException e) { + Assertions.fail(e.getMessage()); + } + } + + @Test + public void givenWrongFormatDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { + try { + AgeCalculator.calculateAge("010102"); + } catch (CalculationException ex) { + assertTrue(findCauseUsingPlainJava(ex) instanceof DateTimeParseException); + } + } + + @Test + public void givenOutOfRangeDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { + try { + AgeCalculator.calculateAge("2020-04-04"); + } catch (CalculationException ex) { + assertTrue(findCauseUsingPlainJava(ex) instanceof DateOutOfRangeException); + } + } + + @Test + public void givenNullDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { + try { + AgeCalculator.calculateAge(null); + } catch (Exception ex) { + assertTrue(findCauseUsingPlainJava(ex) instanceof IllegalArgumentException); + } + } + + @Test + public void givenWrongFormatDate_whenFindingRootCauseUsingApacheCommons_thenRootCauseFound() { + try { + AgeCalculator.calculateAge("010102"); + } catch (CalculationException ex) { + assertTrue(ExceptionUtils.getRootCause(ex) instanceof DateTimeParseException); + } + } + + @Test + public void givenOutOfRangeDate_whenFindingRootCauseUsingApacheCommons_thenRootCauseFound() { + try { + AgeCalculator.calculateAge("2020-04-04"); + } catch (CalculationException ex) { + assertTrue(ExceptionUtils.getRootCause(ex) instanceof DateOutOfRangeException); + } + } + + @Test + public void givenWrongFormatDate_whenFindingRootCauseUsingGuava_thenRootCauseFound() { + try { + AgeCalculator.calculateAge("010102"); + } catch (CalculationException ex) { + assertTrue(Throwables.getRootCause(ex) instanceof DateTimeParseException); + } + } + + @Test + public void givenOutOfRangeDate_whenFindingRootCauseUsingGuava_thenRootCauseFound() { + try { + AgeCalculator.calculateAge("2020-04-04"); + } catch (CalculationException ex) { + assertTrue(Throwables.getRootCause(ex) instanceof DateOutOfRangeException); + } + } + +} From 491e79bd3ea1f958392d158df85c8015f2e5785c Mon Sep 17 00:00:00 2001 From: Marcos Lopez Gonzalez Date: Sat, 4 May 2019 19:59:12 +0200 Subject: [PATCH 379/503] test renamed to end with UnitTest suffix --- .../{RootCauseFinderTest.java => RootCauseFinderUnitTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename core-java/src/test/java/com/baeldung/exceptions/{RootCauseFinderTest.java => RootCauseFinderUnitTest.java} (98%) diff --git a/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java b/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderUnitTest.java similarity index 98% rename from core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java rename to core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderUnitTest.java index cfac81b812..03e6ac0f00 100644 --- a/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java +++ b/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderUnitTest.java @@ -15,7 +15,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; /** * Tests the {@link RootCauseFinder}. */ -public class RootCauseFinderTest { +public class RootCauseFinderUnitTest { @Test public void givenBirthDate_whenCalculatingAge_thenAgeReturned() { From e7cd7da8b8c4635102e64a86ca30c999e33f4b48 Mon Sep 17 00:00:00 2001 From: mikr Date: Tue, 28 Apr 2020 23:37:45 +0200 Subject: [PATCH 380/503] Java-618 Restore RootCauseFinder code (move classes to core-java-modules) --- .../baeldung/exceptions/rootcausefinder}/RootCauseFinder.java | 2 +- .../exceptions/rootcausefinder}/RootCauseFinderUnitTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename {core-java/src/main/java/com/baeldung/exceptions => core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/rootcausefinder}/RootCauseFinder.java (98%) rename {core-java/src/test/java/com/baeldung/exceptions => core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/rootcausefinder}/RootCauseFinderUnitTest.java (98%) diff --git a/core-java/src/main/java/com/baeldung/exceptions/RootCauseFinder.java b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/rootcausefinder/RootCauseFinder.java similarity index 98% rename from core-java/src/main/java/com/baeldung/exceptions/RootCauseFinder.java rename to core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/rootcausefinder/RootCauseFinder.java index e05dc7a6cd..06610f3874 100644 --- a/core-java/src/main/java/com/baeldung/exceptions/RootCauseFinder.java +++ b/core-java-modules/core-java-exceptions/src/main/java/com/baeldung/exceptions/rootcausefinder/RootCauseFinder.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.exceptions.rootcausefinder; import java.time.LocalDate; import java.time.Period; diff --git a/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/rootcausefinder/RootCauseFinderUnitTest.java similarity index 98% rename from core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderUnitTest.java rename to core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/rootcausefinder/RootCauseFinderUnitTest.java index 03e6ac0f00..f963f23712 100644 --- a/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/rootcausefinder/RootCauseFinderUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.exceptions; +package com.baeldung.exceptions.rootcausefinder; import com.google.common.base.Throwables; import org.apache.commons.lang3.exception.ExceptionUtils; From fe9405607a590555ed525cefa3ac3c0a6ccd175a Mon Sep 17 00:00:00 2001 From: Chirag Dewan Date: Wed, 29 Apr 2020 08:29:17 +0530 Subject: [PATCH 381/503] BAEL1731 Log4j2 Plugins --- .../plugins/DockerPatternConverter.java | 30 ++++ .../logging/log4j2/plugins/KafkaAppender.java | 133 ++++++++++++++++++ .../logging/log4j2/plugins/KafkaBroker.java | 38 +++++ .../logging/log4j2/plugins/KafkaLookup.java | 24 ++++ .../log4j2/src/test/resources/log4j2.xml | 9 ++ 5 files changed, 234 insertions(+) create mode 100644 logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/DockerPatternConverter.java create mode 100644 logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/KafkaAppender.java create mode 100644 logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/KafkaBroker.java create mode 100644 logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/KafkaLookup.java diff --git a/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/DockerPatternConverter.java b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/DockerPatternConverter.java new file mode 100644 index 0000000000..c2e40cd565 --- /dev/null +++ b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/DockerPatternConverter.java @@ -0,0 +1,30 @@ +package com.baeldung.logging.log4j2.plugins; + +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.config.plugins.Plugin; +import org.apache.logging.log4j.core.pattern.ConverterKeys; +import org.apache.logging.log4j.core.pattern.LogEventPatternConverter; +import org.apache.logging.log4j.core.pattern.PatternConverter; + +@Plugin(name = "DockerPatternConverter", category = PatternConverter.CATEGORY) +@ConverterKeys({"docker", "container"}) +public class DockerPatternConverter extends LogEventPatternConverter { + + private DockerPatternConverter(String[] options) { + super("Docker", "docker"); + } + + public static DockerPatternConverter newInstance(String[] options) { + return new DockerPatternConverter(options); + } + + @Override + public void format(LogEvent event, StringBuilder toAppendTo) { + toAppendTo.append(dockerContainer()); + } + + private String dockerContainer() { + //get docker container ID inside which application is running here + return "container-1"; + } +} diff --git a/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/KafkaAppender.java b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/KafkaAppender.java new file mode 100644 index 0000000000..3e91aa5e94 --- /dev/null +++ b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/KafkaAppender.java @@ -0,0 +1,133 @@ +package com.baeldung.logging.log4j2.plugins; + +import org.apache.logging.log4j.core.Core; +import org.apache.logging.log4j.core.Filter; +import org.apache.logging.log4j.core.Layout; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.appender.AbstractAppender; +import org.apache.logging.log4j.core.config.plugins.Plugin; +import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute; +import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory; +import org.apache.logging.log4j.core.config.plugins.PluginElement; +import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required; + +import java.io.Serializable; + +@Plugin(name = "Kafka2", category = Core.CATEGORY_NAME) +public class KafkaAppender extends AbstractAppender { + + @PluginBuilderFactory + public static Builder newBuilder() { + return new Builder(); + } + + public static class Builder implements org.apache.logging.log4j.core.util.Builder { + + @PluginBuilderAttribute("name") + @Required + private String name; + + @PluginBuilderAttribute("ip") + private String ipAddress; + + @PluginBuilderAttribute("port") + private int port; + + @PluginBuilderAttribute("topic") + private String topic; + + @PluginBuilderAttribute("partition") + private String partition; + + @PluginElement("Layout") + private Layout layout; + + @PluginElement("Filter") + private Filter filter; + + public Layout getLayout() { + return layout; + } + + public Builder setLayout(Layout layout) { + this.layout = layout; + return this; + } + + public Filter getFilter() { + return filter; + } + + public String getName() { + return name; + } + + public Builder setName(String name) { + this.name = name; + return this; + } + + public Builder setFilter(Filter filter) { + this.filter = filter; + return this; + } + + public String getIpAddress() { + return ipAddress; + } + + public Builder setIpAddress(String ipAddress) { + this.ipAddress = ipAddress; + return this; + } + + public int getPort() { + return port; + } + + public Builder setPort(int port) { + this.port = port; + return this; + } + + public String getTopic() { + return topic; + } + + public Builder setTopic(String topic) { + this.topic = topic; + return this; + } + + public String getPartition() { + return partition; + } + + public Builder setPartition(String partition) { + this.partition = partition; + return this; + } + + @Override + public KafkaAppender build() { + return new KafkaAppender(getName(), getFilter(), getLayout(), true, new KafkaBroker(ipAddress, port, topic, partition)); + } + } + + private KafkaBroker broker; + + private KafkaAppender(String name, Filter filter, Layout layout, boolean ignoreExceptions, KafkaBroker broker) { + super(name, filter, layout, ignoreExceptions); + this.broker = broker; + } + + @Override + public void append(LogEvent event) { + + connectAndSendToKafka(broker, event); + } + + private void connectAndSendToKafka(KafkaBroker broker, LogEvent event) { + //send to Kafka + } +} diff --git a/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/KafkaBroker.java b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/KafkaBroker.java new file mode 100644 index 0000000000..0479e71c41 --- /dev/null +++ b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/KafkaBroker.java @@ -0,0 +1,38 @@ +package com.baeldung.logging.log4j2.plugins; + +import java.io.Serializable; + +public class KafkaBroker implements Serializable { + + private final String ipAddress; + private final int port; + + public KafkaBroker(String ipAddress, int port, String topic, String partition) { + this.ipAddress = ipAddress; + this.port = port; + this.topic = topic; + this.partition = partition; + } + + public String getTopic() { + return topic; + } + + public String getPartition() { + return partition; + } + + private final String topic; + private final String partition; + + + public String getIpAddress() { + return ipAddress; + } + + public int getPort() { + return port; + } + + +} diff --git a/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/KafkaLookup.java b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/KafkaLookup.java new file mode 100644 index 0000000000..c2679861c4 --- /dev/null +++ b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/KafkaLookup.java @@ -0,0 +1,24 @@ +package com.baeldung.logging.log4j2.plugins; + +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.config.plugins.Plugin; +import org.apache.logging.log4j.core.lookup.StrLookup; + +@Plugin(name = "kafka", category = StrLookup.CATEGORY) +public class KafkaLookup implements StrLookup { + + @Override + public String lookup(String key) { + return getFromKafka(key); + } + + @Override + public String lookup(LogEvent event, String key) { + return getFromKafka(key); + } + + private String getFromKafka(String topicName) { + //kafka search logic should go here + return "topic1-p1"; + } +} diff --git a/logging-modules/log4j2/src/test/resources/log4j2.xml b/logging-modules/log4j2/src/test/resources/log4j2.xml index ee26bcecf2..050e0aa705 100644 --- a/logging-modules/log4j2/src/test/resources/log4j2.xml +++ b/logging-modules/log4j2/src/test/resources/log4j2.xml @@ -50,6 +50,12 @@ + + + + + + + + + From f01f9f9d86c98e8e61fd55bde798938de93f2a33 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Wed, 29 Apr 2020 09:08:43 +0200 Subject: [PATCH 382/503] [JAVA-621] Used *UnitTest suffix instead of Test for compliance with Maven PMD (article need update) --- .../{AnonymousInnerTest.java => AnonymousInnerUnitTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/{AnonymousInnerTest.java => AnonymousInnerUnitTest.java} (90%) diff --git a/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInnerTest.java b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInnerUnitTest.java similarity index 90% rename from core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInnerTest.java rename to core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInnerUnitTest.java index 4e49bb5b41..98917b9e05 100644 --- a/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInnerTest.java +++ b/core-java-modules/core-java-lang-oop-types/src/test/java/com/baeldung/nestedclass/AnonymousInnerUnitTest.java @@ -6,7 +6,7 @@ abstract class SimpleAbstractClass { abstract void run(); } -public class AnonymousInnerTest { +public class AnonymousInnerUnitTest { @Test public void run() { From 666ca1ac69e13b8a20e87aabde9aeb25f066e128 Mon Sep 17 00:00:00 2001 From: mikr Date: Wed, 29 Apr 2020 10:13:58 +0200 Subject: [PATCH 383/503] Java-618 Fix build failure --- core-java-modules/core-java-exceptions/pom.xml | 6 ++++++ .../exceptions/rootcausefinder/RootCauseFinderUnitTest.java | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/core-java-modules/core-java-exceptions/pom.xml b/core-java-modules/core-java-exceptions/pom.xml index 60c5e2650a..0778b6b5a3 100644 --- a/core-java-modules/core-java-exceptions/pom.xml +++ b/core-java-modules/core-java-exceptions/pom.xml @@ -29,6 +29,11 @@ ${lombok.version} provided + + org.apache.commons + commons-lang3 + ${commons.lang3.version} + org.assertj @@ -40,6 +45,7 @@ 1.5.0-b01 + 3.10 3.10.0 diff --git a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/rootcausefinder/RootCauseFinderUnitTest.java b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/rootcausefinder/RootCauseFinderUnitTest.java index f963f23712..f42388857a 100644 --- a/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/rootcausefinder/RootCauseFinderUnitTest.java +++ b/core-java-modules/core-java-exceptions/src/test/java/com/baeldung/exceptions/rootcausefinder/RootCauseFinderUnitTest.java @@ -1,5 +1,7 @@ package com.baeldung.exceptions.rootcausefinder; +import com.baeldung.exceptions.rootcausefinder.RootCauseFinder.CalculationException; +import com.baeldung.exceptions.rootcausefinder.RootCauseFinder.DateOutOfRangeException; import com.google.common.base.Throwables; import org.apache.commons.lang3.exception.ExceptionUtils; import org.junit.jupiter.api.Assertions; @@ -9,7 +11,8 @@ import java.time.LocalDate; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoUnit; -import static com.baeldung.exceptions.RootCauseFinder.*; +import static com.baeldung.exceptions.rootcausefinder.RootCauseFinder.AgeCalculator; +import static com.baeldung.exceptions.rootcausefinder.RootCauseFinder.findCauseUsingPlainJava; import static org.junit.jupiter.api.Assertions.assertTrue; /** From da22d7a839156017cfc815b3fd50e3e6180bf295 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Wed, 29 Apr 2020 10:14:43 +0200 Subject: [PATCH 384/503] [JAVA-621] Fixed package and import --- .../com/baeldung/hashcode/{entities => }/UserUnitTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/{entities => }/UserUnitTest.java (90%) diff --git a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/UserUnitTest.java similarity index 90% rename from core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java rename to core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/UserUnitTest.java index 44ea7efed1..51475acabf 100644 --- a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/entities/UserUnitTest.java +++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/UserUnitTest.java @@ -1,5 +1,6 @@ -package com.baeldung.hashcode.entities; +package com.baeldung.hashcode; +import com.baeldung.hashcode.standard.User; import org.junit.After; import org.junit.Assert; import org.junit.Before; From 95a29d7e0b889826058564d17b8bcfacdffc23bf Mon Sep 17 00:00:00 2001 From: mikr Date: Wed, 29 Apr 2020 10:24:20 +0200 Subject: [PATCH 385/503] Java-618 Fix build failure (2) --- .../exceptions/RootCauseFinderTest.java | 96 ------------------- 1 file changed, 96 deletions(-) delete mode 100644 core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java b/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java deleted file mode 100644 index cfac81b812..0000000000 --- a/core-java-modules/core-java/src/test/java/com/baeldung/exceptions/RootCauseFinderTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.baeldung.exceptions; - -import com.google.common.base.Throwables; -import org.apache.commons.lang3.exception.ExceptionUtils; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -import java.time.LocalDate; -import java.time.format.DateTimeParseException; -import java.time.temporal.ChronoUnit; - -import static com.baeldung.exceptions.RootCauseFinder.*; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * Tests the {@link RootCauseFinder}. - */ -public class RootCauseFinderTest { - - @Test - public void givenBirthDate_whenCalculatingAge_thenAgeReturned() { - try { - int age = AgeCalculator.calculateAge("1990-01-01"); - Assertions.assertEquals(1990, LocalDate - .now() - .minus(age, ChronoUnit.YEARS) - .getYear()); - } catch (CalculationException e) { - Assertions.fail(e.getMessage()); - } - } - - @Test - public void givenWrongFormatDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("010102"); - } catch (CalculationException ex) { - assertTrue(findCauseUsingPlainJava(ex) instanceof DateTimeParseException); - } - } - - @Test - public void givenOutOfRangeDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("2020-04-04"); - } catch (CalculationException ex) { - assertTrue(findCauseUsingPlainJava(ex) instanceof DateOutOfRangeException); - } - } - - @Test - public void givenNullDate_whenFindingRootCauseUsingJava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge(null); - } catch (Exception ex) { - assertTrue(findCauseUsingPlainJava(ex) instanceof IllegalArgumentException); - } - } - - @Test - public void givenWrongFormatDate_whenFindingRootCauseUsingApacheCommons_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("010102"); - } catch (CalculationException ex) { - assertTrue(ExceptionUtils.getRootCause(ex) instanceof DateTimeParseException); - } - } - - @Test - public void givenOutOfRangeDate_whenFindingRootCauseUsingApacheCommons_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("2020-04-04"); - } catch (CalculationException ex) { - assertTrue(ExceptionUtils.getRootCause(ex) instanceof DateOutOfRangeException); - } - } - - @Test - public void givenWrongFormatDate_whenFindingRootCauseUsingGuava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("010102"); - } catch (CalculationException ex) { - assertTrue(Throwables.getRootCause(ex) instanceof DateTimeParseException); - } - } - - @Test - public void givenOutOfRangeDate_whenFindingRootCauseUsingGuava_thenRootCauseFound() { - try { - AgeCalculator.calculateAge("2020-04-04"); - } catch (CalculationException ex) { - assertTrue(Throwables.getRootCause(ex) instanceof DateOutOfRangeException); - } - } - -} From 5aa57193e1328935b4cc1775ae378d846a16fd0b Mon Sep 17 00:00:00 2001 From: Ankur Gupta Date: Wed, 29 Apr 2020 20:10:16 +0530 Subject: [PATCH 386/503] ankurguptajec@gmail.com (#9192) * Java Example of Hexagonal Architecture * removing unnecessary maven files from pull request and spaces in code * Removing unnecessary lines * Example code for using Multiple Cache Manager in SpringBoot * BAEL-3963:Using multiple cache managers in Spring * removing new module created in last pull request * Fixes as per editor Suggestions * fixing spacing issue in pom.xml * Fixing spacing issue in pom.xml * Fixing spacing issue 2 * Formatting space issues in pom.xml Co-authored-by: Ankur Gupta --- spring-caching/pom.xml | 120 ++++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 61 deletions(-) diff --git a/spring-caching/pom.xml b/spring-caching/pom.xml index f56d3cf328..80644f8a5f 100644 --- a/spring-caching/pom.xml +++ b/spring-caching/pom.xml @@ -2,66 +2,64 @@ - 4.0.0 - spring-caching - 0.1-SNAPSHOT - spring-caching - war + 4.0.0 + spring-caching + 0.1-SNAPSHOT + spring-caching + war - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../parent-boot-2 - + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../parent-boot-2 + - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework - spring-context - - - org.springframework.boot - spring-boot-starter-cache - - - org.springframework - spring-web - - - org.springframework - spring-webmvc - - - org.ehcache - ehcache - - - org.springframework - spring-test - test - - - com.github.ben-manes.caffeine - caffeine - - - com.h2database - h2 - runtime - - - org.springframework.boot - spring-boot-starter-jdbc - - - - - 3.5.2 - - - \ No newline at end of file + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework + spring-context + + + org.springframework.boot + spring-boot-starter-cache + + + org.springframework + spring-web + + + org.springframework + spring-webmvc + + + org.ehcache + ehcache + + + org.springframework + spring-test + test + + + com.github.ben-manes.caffeine + caffeine + + + com.h2database + h2 + runtime + + + org.springframework.boot + spring-boot-starter-jdbc + + + + 3.5.2 + + From 299effed3e9559f021b75a2f2e68d278b7b1ac07 Mon Sep 17 00:00:00 2001 From: mikr Date: Wed, 29 Apr 2020 20:49:15 +0200 Subject: [PATCH 387/503] Java-1470 Split libraries module --- libraries-4/README.md | 44 +-- libraries-5/README.md | 21 ++ libraries-5/pom.xml | 132 ++++++- .../java/com/baeldung/akka/FirstActor.java | 0 .../main/java/com/baeldung/akka/MyActor.java | 0 .../java/com/baeldung/akka/PrinterActor.java | 0 .../java/com/baeldung/akka/ReadingActor.java | 0 .../com/baeldung/akka/WordCounterActor.java | 0 .../main/java/com/baeldung/bytebuddy/Bar.java | 0 .../main/java/com/baeldung/bytebuddy/Foo.java | 0 .../com/baeldung/caffeine/DataObject.java | 0 .../com/baeldung/jctools/MpmcBenchmark.java | 0 .../main/java/com/baeldung/jctools/README.md | 0 .../java/com/baeldung/jnats/NatsClient.java | 0 .../main/java/com/baeldung/streamex/Role.java | 0 .../java/com/baeldung/streamex/StreamEX.java | 0 .../main/java/com/baeldung/streamex/User.java | 0 .../com/baeldung/akka/AkkaActorsUnitTest.java | 0 .../baeldung/bytebuddy/ByteBuddyUnitTest.java | 0 .../baeldung/caffeine/CaffeineUnitTest.java | 21 +- .../baeldung/dockerapi/ContainerLiveTest.java | 6 +- .../dockerapi/DockerClientLiveTest.java | 0 .../com/baeldung/dockerapi/ImageLiveTest.java | 4 +- .../baeldung/dockerapi/NetworkLiveTest.java | 3 +- .../baeldung/dockerapi/VolumeLiveTest.java | 5 +- .../com/baeldung}/fugue/FugueUnitTest.java | 2 +- .../com/baeldung/jctools/JCToolsUnitTest.java | 9 +- .../baeldung/jnats/NatsClientLiveTest.java | 0 .../java/com/baeldung/jool/JOOLUnitTest.java | 0 .../PactConsumerDrivenContractUnitTest.java | 0 .../StreamExMergeStreamsUnitTest.java | 2 +- .../src/test/resources/dockerapi/Dockerfile | 0 libraries-6/README.md | 17 + libraries-6/pom.xml | 96 +++++ .../com/baeldung/fj/FunctionalJavaIOMain.java | 86 ++--- .../com/baeldung/fj/FunctionalJavaMain.java | 96 ++--- .../main/java/com/baeldung/ftp/FtpClient.java | 0 .../baeldung/javapoet/PersonGenerator.java | 0 .../kafka/TransactionalMessageProducer.java | 0 .../kafka/TransactionalWordCount.java | 0 .../main/java/com/baeldung/kafka/Tuple.java | 0 .../baeldung/reflections/ReflectionsApp.java | 142 ++++---- .../baeldung/fj/FunctionalJavaUnitTest.java | 7 +- .../ftp/FtpClientIntegrationTest.java | 0 .../ftp/JdkFtpClientIntegrationTest.java | 0 .../test/PersonGeneratorUnitTest.java | 0 .../baeldung/javapoet/test/person/Gender.java | 0 .../baeldung/javapoet/test/person/Person.java | 0 .../javapoet/test/person/Student.java | 0 .../kafkastreams/KafkaStreamsLiveTest.java | 0 .../reflections/ReflectionsUnitTest.java | 100 +++--- .../resilence4j}/Resilience4jUnitTest.java | 2 +- .../src/test/resources/ftp/baz.txt | 0 libraries/pom.xml | 332 +++++++++--------- 54 files changed, 689 insertions(+), 438 deletions(-) create mode 100644 libraries-5/README.md rename {libraries => libraries-5}/src/main/java/com/baeldung/akka/FirstActor.java (100%) rename {libraries => libraries-5}/src/main/java/com/baeldung/akka/MyActor.java (100%) rename {libraries => libraries-5}/src/main/java/com/baeldung/akka/PrinterActor.java (100%) rename {libraries => libraries-5}/src/main/java/com/baeldung/akka/ReadingActor.java (100%) rename {libraries => libraries-5}/src/main/java/com/baeldung/akka/WordCounterActor.java (100%) rename {libraries => libraries-5}/src/main/java/com/baeldung/bytebuddy/Bar.java (100%) rename {libraries => libraries-5}/src/main/java/com/baeldung/bytebuddy/Foo.java (100%) rename {libraries => libraries-5}/src/main/java/com/baeldung/caffeine/DataObject.java (100%) rename {libraries => libraries-5}/src/main/java/com/baeldung/jctools/MpmcBenchmark.java (100%) rename {libraries => libraries-5}/src/main/java/com/baeldung/jctools/README.md (100%) rename {libraries => libraries-5}/src/main/java/com/baeldung/jnats/NatsClient.java (100%) rename {libraries => libraries-5}/src/main/java/com/baeldung/streamex/Role.java (100%) rename {libraries => libraries-5}/src/main/java/com/baeldung/streamex/StreamEX.java (100%) rename {libraries => libraries-5}/src/main/java/com/baeldung/streamex/User.java (100%) rename {libraries => libraries-5}/src/test/java/com/baeldung/akka/AkkaActorsUnitTest.java (100%) rename {libraries => libraries-5}/src/test/java/com/baeldung/bytebuddy/ByteBuddyUnitTest.java (100%) rename {libraries => libraries-5}/src/test/java/com/baeldung/caffeine/CaffeineUnitTest.java (88%) rename {libraries => libraries-5}/src/test/java/com/baeldung/dockerapi/ContainerLiveTest.java (94%) rename {libraries => libraries-5}/src/test/java/com/baeldung/dockerapi/DockerClientLiveTest.java (100%) rename {libraries => libraries-5}/src/test/java/com/baeldung/dockerapi/ImageLiveTest.java (96%) rename {libraries => libraries-5}/src/test/java/com/baeldung/dockerapi/NetworkLiveTest.java (95%) rename {libraries => libraries-5}/src/test/java/com/baeldung/dockerapi/VolumeLiveTest.java (92%) rename {libraries/src/test/java/com/baeldung/atlassian => libraries-5/src/test/java/com/baeldung}/fugue/FugueUnitTest.java (99%) rename {libraries => libraries-5}/src/test/java/com/baeldung/jctools/JCToolsUnitTest.java (88%) rename {libraries => libraries-5}/src/test/java/com/baeldung/jnats/NatsClientLiveTest.java (100%) rename {libraries => libraries-5}/src/test/java/com/baeldung/jool/JOOLUnitTest.java (100%) rename {libraries => libraries-5}/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java (100%) rename {libraries/src/test/java/com/baeldung/stream => libraries-5/src/test/java/com/baeldung/streamex}/StreamExMergeStreamsUnitTest.java (98%) rename {libraries => libraries-5}/src/test/resources/dockerapi/Dockerfile (100%) create mode 100644 libraries-6/README.md rename {libraries => libraries-6}/src/main/java/com/baeldung/fj/FunctionalJavaIOMain.java (96%) rename {libraries => libraries-6}/src/main/java/com/baeldung/fj/FunctionalJavaMain.java (96%) rename {libraries => libraries-6}/src/main/java/com/baeldung/ftp/FtpClient.java (100%) rename {libraries => libraries-6}/src/main/java/com/baeldung/javapoet/PersonGenerator.java (100%) rename {libraries => libraries-6}/src/main/java/com/baeldung/kafka/TransactionalMessageProducer.java (100%) rename {libraries => libraries-6}/src/main/java/com/baeldung/kafka/TransactionalWordCount.java (100%) rename {libraries => libraries-6}/src/main/java/com/baeldung/kafka/Tuple.java (100%) rename {libraries => libraries-6}/src/main/java/com/baeldung/reflections/ReflectionsApp.java (97%) rename {libraries => libraries-6}/src/test/java/com/baeldung/fj/FunctionalJavaUnitTest.java (95%) rename {libraries => libraries-6}/src/test/java/com/baeldung/ftp/FtpClientIntegrationTest.java (100%) rename {libraries => libraries-6}/src/test/java/com/baeldung/ftp/JdkFtpClientIntegrationTest.java (100%) rename {libraries => libraries-6}/src/test/java/com/baeldung/javapoet/test/PersonGeneratorUnitTest.java (100%) rename {libraries => libraries-6}/src/test/java/com/baeldung/javapoet/test/person/Gender.java (100%) rename {libraries => libraries-6}/src/test/java/com/baeldung/javapoet/test/person/Person.java (100%) rename {libraries => libraries-6}/src/test/java/com/baeldung/javapoet/test/person/Student.java (100%) rename {libraries => libraries-6}/src/test/java/com/baeldung/kafkastreams/KafkaStreamsLiveTest.java (100%) rename {libraries => libraries-6}/src/test/java/com/baeldung/reflections/ReflectionsUnitTest.java (96%) rename {libraries/src/test/java/com/baeldung/resilience4j => libraries-6/src/test/java/com/baeldung/resilence4j}/Resilience4jUnitTest.java (99%) rename {libraries => libraries-6}/src/test/resources/ftp/baz.txt (100%) diff --git a/libraries-4/README.md b/libraries-4/README.md index f650c073a7..9cda07bdf5 100644 --- a/libraries-4/README.md +++ b/libraries-4/README.md @@ -1,4 +1,4 @@ -## Libraries +## Libraries-4 This module contains articles about various Java libraries. These are small libraries that are relatively easy to use and do not require any separate module of their own. @@ -8,36 +8,14 @@ The code examples related to different libraries are each in their own module. Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-modules) we already have separate modules. Please make sure to have a look at the existing modules in such cases. ### Relevant articles - -- [Introduction to Javatuples](https://www.baeldung.com/java-tuples) -- [Introduction to Javassist](https://www.baeldung.com/javassist) -- [Introduction to Apache Flink with Java](https://www.baeldung.com/apache-flink) -- [Intro to JaVers](https://www.baeldung.com/javers) -- [Merging Streams in Java](https://www.baeldung.com/java-merge-streams) -- [Introduction to Quartz](https://www.baeldung.com/quartz) -- [How to Warm Up the JVM](https://www.baeldung.com/java-jvm-warmup) -- [Software Transactional Memory in Java Using Multiverse](https://www.baeldung.com/java-multiverse-stm) -- [Locality-Sensitive Hashing in Java Using Java-LSH](https://www.baeldung.com/locality-sensitive-hashing) -- [Introduction to Neuroph](https://www.baeldung.com/neuroph) - -#5 -- [Introduction to Caffeine](https://www.baeldung.com/java-caching-caffeine) -- [Introduction to StreamEx](https://www.baeldung.com/streamex) -- [A Docker Guide for Java](https://www.baeldung.com/docker-java-api) -- [Introduction to Akka Actors in Java](https://www.baeldung.com/akka-actors-java) -- [A Guide to Byte Buddy](https://www.baeldung.com/byte-buddy) -- [Introduction to jOOL](https://www.baeldung.com/jool) -- [Consumer Driven Contracts with Pact](https://www.baeldung.com/pact-junit-consumer-driven-contracts) -- [Introduction to Atlassian Fugue](https://www.baeldung.com/java-fugue) -- [Publish and Receive Messages with Nats Java Client](https://www.baeldung.com/nats-java-client) -- [Java Concurrency Utility with JCTools](https://www.baeldung.com/java-concurrency-jc-tools) - -#6 -- [Introduction to JavaPoet](https://www.baeldung.com/java-poet) -- [Guide to Resilience4j](https://www.baeldung.com/resilience4j) -- [Implementing a FTP-Client in Java](https://www.baeldung.com/java-ftp-client) -- [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) +- [Quick Guide to RSS with Rome](https://www.baeldung.com/rome-rss) +- [Introduction to PCollections](https://www.baeldung.com/java-pcollections) +- [Introduction to Eclipse Collections](https://www.baeldung.com/eclipse-collections) +- [DistinctBy in the Java Stream API](https://www.baeldung.com/java-streams-distinct-by) +- [Introduction to NoException](https://www.baeldung.com/no-exception) +- [Spring Yarg Integration](https://www.baeldung.com/spring-yarg) +- [Delete a Directory Recursively in Java](https://www.baeldung.com/java-delete-directory) +- [Guide to JDeferred](https://www.baeldung.com/jdeferred) +- [Introduction to MBassador](https://www.baeldung.com/mbassador) +- [Using Pairs in Java](https://www.baeldung.com/java-pairs) - More articles [[next -->]](/libraries-2) diff --git a/libraries-5/README.md b/libraries-5/README.md new file mode 100644 index 0000000000..f1e749b293 --- /dev/null +++ b/libraries-5/README.md @@ -0,0 +1,21 @@ +## Libraries-5 + +This module contains articles about various Java libraries. +These are small libraries that are relatively easy to use and do not require any separate module of their own. + +The code examples related to different libraries are each in their own module. + +Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-modules) we already have separate modules. Please make sure to have a look at the existing modules in such cases. + +### Relevant articles +- [Introduction to Caffeine](https://www.baeldung.com/java-caching-caffeine) +- [Introduction to StreamEx](https://www.baeldung.com/streamex) +- [A Docker Guide for Java](https://www.baeldung.com/docker-java-api) +- [Introduction to Akka Actors in Java](https://www.baeldung.com/akka-actors-java) +- [A Guide to Byte Buddy](https://www.baeldung.com/byte-buddy) +- [Introduction to jOOL](https://www.baeldung.com/jool) +- [Consumer Driven Contracts with Pact](https://www.baeldung.com/pact-junit-consumer-driven-contracts) +- [Introduction to Atlassian Fugue](https://www.baeldung.com/java-fugue) +- [Publish and Receive Messages with Nats Java Client](https://www.baeldung.com/nats-java-client) +- [Java Concurrency Utility with JCTools](https://www.baeldung.com/java-concurrency-jc-tools) +- More articles [[<-- prev]](/libraries-4) [[next -->]](/libraries-6) diff --git a/libraries-5/pom.xml b/libraries-5/pom.xml index b5a1ecd49c..41c92e54c3 100644 --- a/libraries-5/pom.xml +++ b/libraries-5/pom.xml @@ -7,9 +7,139 @@ com.baeldung 1.0.0-SNAPSHOT - 4.0.0 libraries-5 + 4.0.0 + + + org.springframework + spring-web + ${spring.version} + + + org.assertj + assertj-core + ${assertj.version} + + + org.jooq + jool + ${jool.version} + + + au.com.dius + pact-jvm-consumer-junit_2.11 + ${pact.version} + test + + + org.codehaus.groovy + groovy-all + + + + + + + com.typesafe.akka + akka-actor_2.12 + ${typesafe-akka.version} + + + com.typesafe.akka + akka-testkit_2.12 + ${typesafe-akka.version} + test + + + + one.util + streamex + ${streamex.version} + + + net.bytebuddy + byte-buddy + ${bytebuddy.version} + + + net.bytebuddy + byte-buddy-agent + ${bytebuddy.version} + + + + + com.github.docker-java + docker-java + ${docker.version} + + + org.slf4j + slf4j-log4j12 + + + org.slf4j + jcl-over-slf4j + + + ch.qos.logback + logback-classic + + + + + + + com.github.ben-manes.caffeine + caffeine + ${caffeine.version} + + + com.google.code.findbugs + jsr305 + ${findbugs.version} + test + + + + io.atlassian.fugue + fugue + ${fugue.version} + + + io.nats + jnats + ${jnats.version} + + + org.jctools + jctools-core + ${jctools.version} + + + org.openjdk.jmh + jmh-core + ${jmh.version} + + + + + 3.5.0 + 0.9.12 + 4.3.8.RELEASE + 3.6.2 + 2.5.26 + 0.6.5 + 1.7.1 + 3.0.14 + 2.5.5 + 3.0.2 + 4.5.1 + 1.0 + 2.1.2 + 1.19 + \ No newline at end of file diff --git a/libraries/src/main/java/com/baeldung/akka/FirstActor.java b/libraries-5/src/main/java/com/baeldung/akka/FirstActor.java similarity index 100% rename from libraries/src/main/java/com/baeldung/akka/FirstActor.java rename to libraries-5/src/main/java/com/baeldung/akka/FirstActor.java diff --git a/libraries/src/main/java/com/baeldung/akka/MyActor.java b/libraries-5/src/main/java/com/baeldung/akka/MyActor.java similarity index 100% rename from libraries/src/main/java/com/baeldung/akka/MyActor.java rename to libraries-5/src/main/java/com/baeldung/akka/MyActor.java diff --git a/libraries/src/main/java/com/baeldung/akka/PrinterActor.java b/libraries-5/src/main/java/com/baeldung/akka/PrinterActor.java similarity index 100% rename from libraries/src/main/java/com/baeldung/akka/PrinterActor.java rename to libraries-5/src/main/java/com/baeldung/akka/PrinterActor.java diff --git a/libraries/src/main/java/com/baeldung/akka/ReadingActor.java b/libraries-5/src/main/java/com/baeldung/akka/ReadingActor.java similarity index 100% rename from libraries/src/main/java/com/baeldung/akka/ReadingActor.java rename to libraries-5/src/main/java/com/baeldung/akka/ReadingActor.java diff --git a/libraries/src/main/java/com/baeldung/akka/WordCounterActor.java b/libraries-5/src/main/java/com/baeldung/akka/WordCounterActor.java similarity index 100% rename from libraries/src/main/java/com/baeldung/akka/WordCounterActor.java rename to libraries-5/src/main/java/com/baeldung/akka/WordCounterActor.java diff --git a/libraries/src/main/java/com/baeldung/bytebuddy/Bar.java b/libraries-5/src/main/java/com/baeldung/bytebuddy/Bar.java similarity index 100% rename from libraries/src/main/java/com/baeldung/bytebuddy/Bar.java rename to libraries-5/src/main/java/com/baeldung/bytebuddy/Bar.java diff --git a/libraries/src/main/java/com/baeldung/bytebuddy/Foo.java b/libraries-5/src/main/java/com/baeldung/bytebuddy/Foo.java similarity index 100% rename from libraries/src/main/java/com/baeldung/bytebuddy/Foo.java rename to libraries-5/src/main/java/com/baeldung/bytebuddy/Foo.java diff --git a/libraries/src/main/java/com/baeldung/caffeine/DataObject.java b/libraries-5/src/main/java/com/baeldung/caffeine/DataObject.java similarity index 100% rename from libraries/src/main/java/com/baeldung/caffeine/DataObject.java rename to libraries-5/src/main/java/com/baeldung/caffeine/DataObject.java diff --git a/libraries/src/main/java/com/baeldung/jctools/MpmcBenchmark.java b/libraries-5/src/main/java/com/baeldung/jctools/MpmcBenchmark.java similarity index 100% rename from libraries/src/main/java/com/baeldung/jctools/MpmcBenchmark.java rename to libraries-5/src/main/java/com/baeldung/jctools/MpmcBenchmark.java diff --git a/libraries/src/main/java/com/baeldung/jctools/README.md b/libraries-5/src/main/java/com/baeldung/jctools/README.md similarity index 100% rename from libraries/src/main/java/com/baeldung/jctools/README.md rename to libraries-5/src/main/java/com/baeldung/jctools/README.md diff --git a/libraries/src/main/java/com/baeldung/jnats/NatsClient.java b/libraries-5/src/main/java/com/baeldung/jnats/NatsClient.java similarity index 100% rename from libraries/src/main/java/com/baeldung/jnats/NatsClient.java rename to libraries-5/src/main/java/com/baeldung/jnats/NatsClient.java diff --git a/libraries/src/main/java/com/baeldung/streamex/Role.java b/libraries-5/src/main/java/com/baeldung/streamex/Role.java similarity index 100% rename from libraries/src/main/java/com/baeldung/streamex/Role.java rename to libraries-5/src/main/java/com/baeldung/streamex/Role.java diff --git a/libraries/src/main/java/com/baeldung/streamex/StreamEX.java b/libraries-5/src/main/java/com/baeldung/streamex/StreamEX.java similarity index 100% rename from libraries/src/main/java/com/baeldung/streamex/StreamEX.java rename to libraries-5/src/main/java/com/baeldung/streamex/StreamEX.java diff --git a/libraries/src/main/java/com/baeldung/streamex/User.java b/libraries-5/src/main/java/com/baeldung/streamex/User.java similarity index 100% rename from libraries/src/main/java/com/baeldung/streamex/User.java rename to libraries-5/src/main/java/com/baeldung/streamex/User.java diff --git a/libraries/src/test/java/com/baeldung/akka/AkkaActorsUnitTest.java b/libraries-5/src/test/java/com/baeldung/akka/AkkaActorsUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/akka/AkkaActorsUnitTest.java rename to libraries-5/src/test/java/com/baeldung/akka/AkkaActorsUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/bytebuddy/ByteBuddyUnitTest.java b/libraries-5/src/test/java/com/baeldung/bytebuddy/ByteBuddyUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/bytebuddy/ByteBuddyUnitTest.java rename to libraries-5/src/test/java/com/baeldung/bytebuddy/ByteBuddyUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/caffeine/CaffeineUnitTest.java b/libraries-5/src/test/java/com/baeldung/caffeine/CaffeineUnitTest.java similarity index 88% rename from libraries/src/test/java/com/baeldung/caffeine/CaffeineUnitTest.java rename to libraries-5/src/test/java/com/baeldung/caffeine/CaffeineUnitTest.java index d523d0ff8b..65c441c50d 100644 --- a/libraries/src/test/java/com/baeldung/caffeine/CaffeineUnitTest.java +++ b/libraries-5/src/test/java/com/baeldung/caffeine/CaffeineUnitTest.java @@ -8,6 +8,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Nonnull; +import org.junit.Assert; import org.junit.Test; import com.github.benmanes.caffeine.cache.*; @@ -65,43 +66,43 @@ public class CaffeineUnitTest { assertEquals("Data for " + key, dataObject.getData()); }); - cache.getAll(Arrays.asList("A", "B", "C")).thenAccept(dataObjectMap -> assertEquals(3, dataObjectMap.size())); + cache.getAll(Arrays.asList("A", "B", "C")).thenAccept(dataObjectMap -> Assert.assertEquals(3, dataObjectMap.size())); } @Test public void givenLoadingCacheWithSmallSize_whenPut_thenSizeIsConstant() { LoadingCache cache = Caffeine.newBuilder().maximumSize(1).refreshAfterWrite(10, TimeUnit.MINUTES).build(k -> DataObject.get("Data for " + k)); - assertEquals(0, cache.estimatedSize()); + Assert.assertEquals(0, cache.estimatedSize()); cache.get("A"); - assertEquals(1, cache.estimatedSize()); + Assert.assertEquals(1, cache.estimatedSize()); cache.get("B"); cache.cleanUp(); - assertEquals(1, cache.estimatedSize()); + Assert.assertEquals(1, cache.estimatedSize()); } @Test public void givenLoadingCacheWithWeigher_whenPut_thenSizeIsConstant() { LoadingCache cache = Caffeine.newBuilder().maximumWeight(10).weigher((k, v) -> 5).build(k -> DataObject.get("Data for " + k)); - assertEquals(0, cache.estimatedSize()); + Assert.assertEquals(0, cache.estimatedSize()); cache.get("A"); - assertEquals(1, cache.estimatedSize()); + Assert.assertEquals(1, cache.estimatedSize()); cache.get("B"); - assertEquals(2, cache.estimatedSize()); + Assert.assertEquals(2, cache.estimatedSize()); cache.get("C"); cache.cleanUp(); - assertEquals(2, cache.estimatedSize()); + Assert.assertEquals(2, cache.estimatedSize()); } @Test @@ -138,7 +139,7 @@ public class CaffeineUnitTest { cache.get("A"); cache.get("A"); - assertEquals(1, cache.stats().hitCount()); - assertEquals(1, cache.stats().missCount()); + Assert.assertEquals(1, cache.stats().hitCount()); + Assert.assertEquals(1, cache.stats().missCount()); } } \ No newline at end of file diff --git a/libraries/src/test/java/com/baeldung/dockerapi/ContainerLiveTest.java b/libraries-5/src/test/java/com/baeldung/dockerapi/ContainerLiveTest.java similarity index 94% rename from libraries/src/test/java/com/baeldung/dockerapi/ContainerLiveTest.java rename to libraries-5/src/test/java/com/baeldung/dockerapi/ContainerLiveTest.java index e6f0fd1c31..007c70355a 100644 --- a/libraries/src/test/java/com/baeldung/dockerapi/ContainerLiveTest.java +++ b/libraries-5/src/test/java/com/baeldung/dockerapi/ContainerLiveTest.java @@ -6,6 +6,8 @@ import com.github.dockerjava.api.command.InspectContainerResponse; import com.github.dockerjava.api.model.Container; import com.github.dockerjava.api.model.PortBinding; import com.github.dockerjava.core.DockerClientBuilder; +import org.hamcrest.MatcherAssert; +import org.hamcrest.core.Is; import org.junit.BeforeClass; import org.junit.Test; @@ -51,7 +53,7 @@ public class ContainerLiveTest { CreateContainerResponse container = dockerClient.createContainerCmd("mongo:3.6").withCmd("--bind_ip_all").withName("mongo").withHostName("baeldung").withEnv("MONGO_LATEST_VERSION=3.6").withPortBindings(PortBinding.parse("9999:27017")).exec(); // then - assertThat(container.getId(), is(not(null))); + MatcherAssert.assertThat(container.getId(), is(not(null))); } @Test @@ -104,7 +106,7 @@ public class ContainerLiveTest { // then InspectContainerResponse containerResponse = dockerClient.inspectContainerCmd(container.getId()).exec(); - assertThat(containerResponse.getId(), is(container.getId())); + MatcherAssert.assertThat(containerResponse.getId(), Is.is(container.getId())); } @Test diff --git a/libraries/src/test/java/com/baeldung/dockerapi/DockerClientLiveTest.java b/libraries-5/src/test/java/com/baeldung/dockerapi/DockerClientLiveTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/dockerapi/DockerClientLiveTest.java rename to libraries-5/src/test/java/com/baeldung/dockerapi/DockerClientLiveTest.java diff --git a/libraries/src/test/java/com/baeldung/dockerapi/ImageLiveTest.java b/libraries-5/src/test/java/com/baeldung/dockerapi/ImageLiveTest.java similarity index 96% rename from libraries/src/test/java/com/baeldung/dockerapi/ImageLiveTest.java rename to libraries-5/src/test/java/com/baeldung/dockerapi/ImageLiveTest.java index 7e8cd6a354..96e7922f2a 100644 --- a/libraries/src/test/java/com/baeldung/dockerapi/ImageLiveTest.java +++ b/libraries-5/src/test/java/com/baeldung/dockerapi/ImageLiveTest.java @@ -8,6 +8,8 @@ import com.github.dockerjava.core.DockerClientBuilder; import com.github.dockerjava.core.command.BuildImageResultCallback; import com.github.dockerjava.core.command.PullImageResultCallback; import com.github.dockerjava.core.command.PushImageResultCallback; +import org.hamcrest.MatcherAssert; +import org.hamcrest.core.Is; import org.junit.BeforeClass; import org.junit.Test; @@ -81,7 +83,7 @@ public class ImageLiveTest { InspectImageResponse imageResponse = dockerClient.inspectImageCmd(image.getId()).exec(); // then - assertThat(imageResponse.getId(), is(image.getId())); + MatcherAssert.assertThat(imageResponse.getId(), Is.is(image.getId())); } @Test diff --git a/libraries/src/test/java/com/baeldung/dockerapi/NetworkLiveTest.java b/libraries-5/src/test/java/com/baeldung/dockerapi/NetworkLiveTest.java similarity index 95% rename from libraries/src/test/java/com/baeldung/dockerapi/NetworkLiveTest.java rename to libraries-5/src/test/java/com/baeldung/dockerapi/NetworkLiveTest.java index d3abbe2e7e..31ad32c7b5 100644 --- a/libraries/src/test/java/com/baeldung/dockerapi/NetworkLiveTest.java +++ b/libraries-5/src/test/java/com/baeldung/dockerapi/NetworkLiveTest.java @@ -5,6 +5,7 @@ import com.github.dockerjava.api.command.CreateNetworkResponse; import com.github.dockerjava.api.model.Network; import com.github.dockerjava.api.model.Network.Ipam; import com.github.dockerjava.core.DockerClientBuilder; +import org.hamcrest.MatcherAssert; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; @@ -64,7 +65,7 @@ public class NetworkLiveTest { Network network = dockerClient.inspectNetworkCmd().withNetworkId(networkName).exec(); // then - assertThat(network.getName(), is(networkName)); + MatcherAssert.assertThat(network.getName(), is(networkName)); } @Test diff --git a/libraries/src/test/java/com/baeldung/dockerapi/VolumeLiveTest.java b/libraries-5/src/test/java/com/baeldung/dockerapi/VolumeLiveTest.java similarity index 92% rename from libraries/src/test/java/com/baeldung/dockerapi/VolumeLiveTest.java rename to libraries-5/src/test/java/com/baeldung/dockerapi/VolumeLiveTest.java index 9e60a76b33..f2a078b2c6 100644 --- a/libraries/src/test/java/com/baeldung/dockerapi/VolumeLiveTest.java +++ b/libraries-5/src/test/java/com/baeldung/dockerapi/VolumeLiveTest.java @@ -5,6 +5,7 @@ import com.github.dockerjava.api.command.CreateVolumeResponse; import com.github.dockerjava.api.command.InspectVolumeResponse; import com.github.dockerjava.api.command.ListVolumesResponse; import com.github.dockerjava.core.DockerClientBuilder; +import org.hamcrest.MatcherAssert; import org.junit.BeforeClass; import org.junit.Test; @@ -57,7 +58,7 @@ public class VolumeLiveTest { CreateVolumeResponse unnamedVolume = dockerClient.createVolumeCmd().exec(); // then - assertThat(unnamedVolume.getName(), is(not(null))); + MatcherAssert.assertThat(unnamedVolume.getName(), is(not(null))); } @Test @@ -67,7 +68,7 @@ public class VolumeLiveTest { CreateVolumeResponse namedVolume = dockerClient.createVolumeCmd().withName("myNamedVolume").exec(); // then - assertThat(namedVolume.getName(), is(not(null))); + MatcherAssert.assertThat(namedVolume.getName(), is(not(null))); } @Test diff --git a/libraries/src/test/java/com/baeldung/atlassian/fugue/FugueUnitTest.java b/libraries-5/src/test/java/com/baeldung/fugue/FugueUnitTest.java similarity index 99% rename from libraries/src/test/java/com/baeldung/atlassian/fugue/FugueUnitTest.java rename to libraries-5/src/test/java/com/baeldung/fugue/FugueUnitTest.java index 773e39b76a..c3a89a1355 100644 --- a/libraries/src/test/java/com/baeldung/atlassian/fugue/FugueUnitTest.java +++ b/libraries-5/src/test/java/com/baeldung/fugue/FugueUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.atlassian.fugue; +package com.baeldung.fugue; import io.atlassian.fugue.*; import org.junit.Assert; diff --git a/libraries/src/test/java/com/baeldung/jctools/JCToolsUnitTest.java b/libraries-5/src/test/java/com/baeldung/jctools/JCToolsUnitTest.java similarity index 88% rename from libraries/src/test/java/com/baeldung/jctools/JCToolsUnitTest.java rename to libraries-5/src/test/java/com/baeldung/jctools/JCToolsUnitTest.java index 4a9d0fadb2..a5dacdbdac 100644 --- a/libraries/src/test/java/com/baeldung/jctools/JCToolsUnitTest.java +++ b/libraries-5/src/test/java/com/baeldung/jctools/JCToolsUnitTest.java @@ -1,5 +1,6 @@ package com.baeldung.jctools; +import org.assertj.core.api.Assertions; import org.jctools.queues.SpscArrayQueue; import org.jctools.queues.SpscChunkedArrayQueue; import org.junit.Test; @@ -44,16 +45,16 @@ public class JCToolsUnitTest { @Test public void whenQueueIsFull_thenNoMoreElementsCanBeAdded() throws InterruptedException { SpscChunkedArrayQueue queue = new SpscChunkedArrayQueue<>(8, 16); - assertThat(queue.capacity()).isEqualTo(16); + Assertions.assertThat(queue.capacity()).isEqualTo(16); CountDownLatch startConsuming = new CountDownLatch(1); CountDownLatch awakeProducer = new CountDownLatch(1); AtomicReference error = new AtomicReference<>(); Thread producer = new Thread(() -> { IntStream.range(0, queue.capacity()).forEach(i -> { - assertThat(queue.offer(i)).isTrue(); + Assertions.assertThat(queue.offer(i)).isTrue(); }); - assertThat(queue.offer(queue.capacity())).isFalse(); + Assertions.assertThat(queue.offer(queue.capacity())).isFalse(); startConsuming.countDown(); try { awakeProducer.await(); @@ -61,7 +62,7 @@ public class JCToolsUnitTest { throw new RuntimeException(e); } - assertThat(queue.offer(queue.capacity())).isTrue(); + Assertions.assertThat(queue.offer(queue.capacity())).isTrue(); }); producer.setUncaughtExceptionHandler((t, e) -> { error.set(e); diff --git a/libraries/src/test/java/com/baeldung/jnats/NatsClientLiveTest.java b/libraries-5/src/test/java/com/baeldung/jnats/NatsClientLiveTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/jnats/NatsClientLiveTest.java rename to libraries-5/src/test/java/com/baeldung/jnats/NatsClientLiveTest.java diff --git a/libraries/src/test/java/com/baeldung/jool/JOOLUnitTest.java b/libraries-5/src/test/java/com/baeldung/jool/JOOLUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/jool/JOOLUnitTest.java rename to libraries-5/src/test/java/com/baeldung/jool/JOOLUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java b/libraries-5/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java rename to libraries-5/src/test/java/com/baeldung/pact/PactConsumerDrivenContractUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/stream/StreamExMergeStreamsUnitTest.java b/libraries-5/src/test/java/com/baeldung/streamex/StreamExMergeStreamsUnitTest.java similarity index 98% rename from libraries/src/test/java/com/baeldung/stream/StreamExMergeStreamsUnitTest.java rename to libraries-5/src/test/java/com/baeldung/streamex/StreamExMergeStreamsUnitTest.java index 220348bf36..b267eaea9b 100644 --- a/libraries/src/test/java/com/baeldung/stream/StreamExMergeStreamsUnitTest.java +++ b/libraries-5/src/test/java/com/baeldung/streamex/StreamExMergeStreamsUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.stream; +package com.baeldung.streamex; import one.util.streamex.StreamEx; import org.junit.Test; diff --git a/libraries/src/test/resources/dockerapi/Dockerfile b/libraries-5/src/test/resources/dockerapi/Dockerfile similarity index 100% rename from libraries/src/test/resources/dockerapi/Dockerfile rename to libraries-5/src/test/resources/dockerapi/Dockerfile diff --git a/libraries-6/README.md b/libraries-6/README.md new file mode 100644 index 0000000000..79bb83113e --- /dev/null +++ b/libraries-6/README.md @@ -0,0 +1,17 @@ +## Libraries-6 + +This module contains articles about various Java libraries. +These are small libraries that are relatively easy to use and do not require any separate module of their own. + +The code examples related to different libraries are each in their own module. + +Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-modules) we already have separate modules. Please make sure to have a look at the existing modules in such cases. + +### Relevant articles +- [Introduction to JavaPoet](https://www.baeldung.com/java-poet) +- [Guide to Resilience4j](https://www.baeldung.com/resilience4j) +- [Implementing a FTP-Client in Java](https://www.baeldung.com/java-ftp-client) +- [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) +- More articles [[<-- prev]](/libraries-5) diff --git a/libraries-6/pom.xml b/libraries-6/pom.xml index be74ff9ef0..030e5aa77b 100644 --- a/libraries-6/pom.xml +++ b/libraries-6/pom.xml @@ -11,5 +11,101 @@ libraries-6 + + + org.functionaljava + functionaljava-java8 + ${functionaljava.version} + + + com.codepoetics + protonpack + ${protonpack.version} + + + org.apache.kafka + kafka-streams + ${kafka.version} + + + org.apache.kafka + kafka-clients + ${kafka.version} + test + test + + + io.github.resilience4j + resilience4j-circuitbreaker + ${resilience4j.version} + + + io.github.resilience4j + resilience4j-bulkhead + ${resilience4j.version} + + + io.github.resilience4j + resilience4j-retry + ${resilience4j.version} + + + io.github.resilience4j + resilience4j-timelimiter + ${resilience4j.version} + + + com.squareup + javapoet + ${javapoet.version} + + + org.mockftpserver + MockFtpServer + ${mockftpserver.version} + test + + + + org.reflections + reflections + ${reflections.version} + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + commons-net + commons-net + ${commons-net.version} + + + org.assertj + assertj-core + ${assertj.version} + + + commons-io + commons-io + ${commonsio.version} + test + + + + + 2.0.0 + 1.10.0 + 0.9.11 + 2.7.1 + 4.8.1 + 0.12.1 + 1.15 + 3.6 + 3.6.2 + 2.6 + + \ No newline at end of file diff --git a/libraries/src/main/java/com/baeldung/fj/FunctionalJavaIOMain.java b/libraries-6/src/main/java/com/baeldung/fj/FunctionalJavaIOMain.java similarity index 96% rename from libraries/src/main/java/com/baeldung/fj/FunctionalJavaIOMain.java rename to libraries-6/src/main/java/com/baeldung/fj/FunctionalJavaIOMain.java index eaa201d1ba..e97f128b30 100644 --- a/libraries/src/main/java/com/baeldung/fj/FunctionalJavaIOMain.java +++ b/libraries-6/src/main/java/com/baeldung/fj/FunctionalJavaIOMain.java @@ -1,43 +1,43 @@ -package com.baeldung.fj; - -import fj.F; -import fj.F1Functions; -import fj.Unit; -import fj.data.IO; -import fj.data.IOFunctions; - -public class FunctionalJavaIOMain { - - public static IO printLetters(final String s) { - return () -> { - for (int i = 0; i < s.length(); i++) { - System.out.println(s.charAt(i)); - } - return Unit.unit(); - }; - } - - public static void main(String[] args) { - - F> printLetters = i -> printLetters(i); - - IO lowerCase = IOFunctions.stdoutPrintln("What's your first Name ?"); - - IO input = IOFunctions.stdoutPrint("First Name: "); - - IO userInput = IOFunctions.append(lowerCase, input); - - IO readInput = IOFunctions.stdinReadLine(); - - F toUpperCase = i -> i.toUpperCase(); - - F> transformInput = F1Functions., String> o(printLetters).f(toUpperCase); - - IO readAndPrintResult = IOFunctions.bind(readInput, transformInput); - - IO program = IOFunctions.bind(userInput, nothing -> readAndPrintResult); - - IOFunctions.toSafe(program).run(); - - } -} +package com.baeldung.fj; + +import fj.F; +import fj.F1Functions; +import fj.Unit; +import fj.data.IO; +import fj.data.IOFunctions; + +public class FunctionalJavaIOMain { + + public static IO printLetters(final String s) { + return () -> { + for (int i = 0; i < s.length(); i++) { + System.out.println(s.charAt(i)); + } + return Unit.unit(); + }; + } + + public static void main(String[] args) { + + F> printLetters = i -> printLetters(i); + + IO lowerCase = IOFunctions.stdoutPrintln("What's your first Name ?"); + + IO input = IOFunctions.stdoutPrint("First Name: "); + + IO userInput = IOFunctions.append(lowerCase, input); + + IO readInput = IOFunctions.stdinReadLine(); + + F toUpperCase = i -> i.toUpperCase(); + + F> transformInput = F1Functions., String> o(printLetters).f(toUpperCase); + + IO readAndPrintResult = IOFunctions.bind(readInput, transformInput); + + IO program = IOFunctions.bind(userInput, nothing -> readAndPrintResult); + + IOFunctions.toSafe(program).run(); + + } +} diff --git a/libraries/src/main/java/com/baeldung/fj/FunctionalJavaMain.java b/libraries-6/src/main/java/com/baeldung/fj/FunctionalJavaMain.java similarity index 96% rename from libraries/src/main/java/com/baeldung/fj/FunctionalJavaMain.java rename to libraries-6/src/main/java/com/baeldung/fj/FunctionalJavaMain.java index c6412f2923..1a59e6c22a 100644 --- a/libraries/src/main/java/com/baeldung/fj/FunctionalJavaMain.java +++ b/libraries-6/src/main/java/com/baeldung/fj/FunctionalJavaMain.java @@ -1,48 +1,48 @@ -package com.baeldung.fj; - -import fj.F; -import fj.Show; -import fj.data.Array; -import fj.data.List; -import fj.data.Option; -import fj.function.Characters; -import fj.function.Integers; - -public class FunctionalJavaMain { - - public static final F isEven = i -> i % 2 == 0; - - public static void main(String[] args) { - - List fList = List.list(3, 4, 5, 6); - List evenList = fList.map(isEven); - Show.listShow(Show.booleanShow).println(evenList); - - fList = fList.map(i -> i + 1); - Show.listShow(Show.intShow).println(fList); - - Array a = Array.array(17, 44, 67, 2, 22, 80, 1, 27); - Array b = a.filter(Integers.even); - Show.arrayShow(Show.intShow).println(b); - - Array array = Array.array("Welcome", "To", "baeldung"); - Boolean isExist = array.exists(s -> List.fromString(s).forall(Characters.isLowerCase)); - System.out.println(isExist); - - Array intArray = Array.array(17, 44, 67, 2, 22, 80, 1, 27); - int sum = intArray.foldLeft(Integers.add, 0); - System.out.println(sum); - - Option n1 = Option.some(1); - Option n2 = Option.some(2); - - F> f1 = i -> i % 2 == 0 ? Option.some(i + 100) : Option.none(); - - Option result1 = n1.bind(f1); - Option result2 = n2.bind(f1); - - Show.optionShow(Show.intShow).println(result1); - Show.optionShow(Show.intShow).println(result2); - } - -} +package com.baeldung.fj; + +import fj.F; +import fj.Show; +import fj.data.Array; +import fj.data.List; +import fj.data.Option; +import fj.function.Characters; +import fj.function.Integers; + +public class FunctionalJavaMain { + + public static final F isEven = i -> i % 2 == 0; + + public static void main(String[] args) { + + List fList = List.list(3, 4, 5, 6); + List evenList = fList.map(isEven); + Show.listShow(Show.booleanShow).println(evenList); + + fList = fList.map(i -> i + 1); + Show.listShow(Show.intShow).println(fList); + + Array a = Array.array(17, 44, 67, 2, 22, 80, 1, 27); + Array b = a.filter(Integers.even); + Show.arrayShow(Show.intShow).println(b); + + Array array = Array.array("Welcome", "To", "baeldung"); + Boolean isExist = array.exists(s -> List.fromString(s).forall(Characters.isLowerCase)); + System.out.println(isExist); + + Array intArray = Array.array(17, 44, 67, 2, 22, 80, 1, 27); + int sum = intArray.foldLeft(Integers.add, 0); + System.out.println(sum); + + Option n1 = Option.some(1); + Option n2 = Option.some(2); + + F> f1 = i -> i % 2 == 0 ? Option.some(i + 100) : Option.none(); + + Option result1 = n1.bind(f1); + Option result2 = n2.bind(f1); + + Show.optionShow(Show.intShow).println(result1); + Show.optionShow(Show.intShow).println(result2); + } + +} diff --git a/libraries/src/main/java/com/baeldung/ftp/FtpClient.java b/libraries-6/src/main/java/com/baeldung/ftp/FtpClient.java similarity index 100% rename from libraries/src/main/java/com/baeldung/ftp/FtpClient.java rename to libraries-6/src/main/java/com/baeldung/ftp/FtpClient.java diff --git a/libraries/src/main/java/com/baeldung/javapoet/PersonGenerator.java b/libraries-6/src/main/java/com/baeldung/javapoet/PersonGenerator.java similarity index 100% rename from libraries/src/main/java/com/baeldung/javapoet/PersonGenerator.java rename to libraries-6/src/main/java/com/baeldung/javapoet/PersonGenerator.java diff --git a/libraries/src/main/java/com/baeldung/kafka/TransactionalMessageProducer.java b/libraries-6/src/main/java/com/baeldung/kafka/TransactionalMessageProducer.java similarity index 100% rename from libraries/src/main/java/com/baeldung/kafka/TransactionalMessageProducer.java rename to libraries-6/src/main/java/com/baeldung/kafka/TransactionalMessageProducer.java diff --git a/libraries/src/main/java/com/baeldung/kafka/TransactionalWordCount.java b/libraries-6/src/main/java/com/baeldung/kafka/TransactionalWordCount.java similarity index 100% rename from libraries/src/main/java/com/baeldung/kafka/TransactionalWordCount.java rename to libraries-6/src/main/java/com/baeldung/kafka/TransactionalWordCount.java diff --git a/libraries/src/main/java/com/baeldung/kafka/Tuple.java b/libraries-6/src/main/java/com/baeldung/kafka/Tuple.java similarity index 100% rename from libraries/src/main/java/com/baeldung/kafka/Tuple.java rename to libraries-6/src/main/java/com/baeldung/kafka/Tuple.java diff --git a/libraries/src/main/java/com/baeldung/reflections/ReflectionsApp.java b/libraries-6/src/main/java/com/baeldung/reflections/ReflectionsApp.java similarity index 97% rename from libraries/src/main/java/com/baeldung/reflections/ReflectionsApp.java rename to libraries-6/src/main/java/com/baeldung/reflections/ReflectionsApp.java index 30da8ea837..4f5b6dd183 100644 --- a/libraries/src/main/java/com/baeldung/reflections/ReflectionsApp.java +++ b/libraries-6/src/main/java/com/baeldung/reflections/ReflectionsApp.java @@ -1,71 +1,71 @@ -package com.baeldung.reflections; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.Date; -import java.util.Set; -import java.util.regex.Pattern; - -import org.reflections.Reflections; -import org.reflections.scanners.MethodAnnotationsScanner; -import org.reflections.scanners.MethodParameterScanner; -import org.reflections.scanners.ResourcesScanner; -import org.reflections.scanners.Scanner; -import org.reflections.scanners.SubTypesScanner; -import org.reflections.util.ClasspathHelper; -import org.reflections.util.ConfigurationBuilder; - -public class ReflectionsApp { - - public Set> getReflectionsSubTypes() { - Reflections reflections = new Reflections("org.reflections"); - Set> scannersSet = reflections.getSubTypesOf(Scanner.class); - return scannersSet; - } - - public Set> getJDKFunctinalInterfaces() { - Reflections reflections = new Reflections("java.util.function"); - Set> typesSet = reflections.getTypesAnnotatedWith(FunctionalInterface.class); - return typesSet; - } - - public Set getDateDeprecatedMethods() { - Reflections reflections = new Reflections(java.util.Date.class, new MethodAnnotationsScanner()); - Set deprecatedMethodsSet = reflections.getMethodsAnnotatedWith(Deprecated.class); - return deprecatedMethodsSet; - } - - @SuppressWarnings("rawtypes") - public Set getDateDeprecatedConstructors() { - Reflections reflections = new Reflections(java.util.Date.class, new MethodAnnotationsScanner()); - Set constructorsSet = reflections.getConstructorsAnnotatedWith(Deprecated.class); - return constructorsSet; - } - - public Set getMethodsWithDateParam() { - Reflections reflections = new Reflections(java.text.SimpleDateFormat.class, new MethodParameterScanner()); - Set methodsSet = reflections.getMethodsMatchParams(Date.class); - return methodsSet; - } - - public Set getMethodsWithVoidReturn() { - Reflections reflections = new Reflections(java.text.SimpleDateFormat.class, new MethodParameterScanner()); - Set methodsSet = reflections.getMethodsReturn(void.class); - return methodsSet; - } - - public Set getPomXmlPaths() { - Reflections reflections = new Reflections(new ResourcesScanner()); - Set resourcesSet = reflections.getResources(Pattern.compile(".*pom\\.xml")); - return resourcesSet; - } - - public Set> getReflectionsSubTypesUsingBuilder() { - Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("org.reflections")) - .setScanners(new SubTypesScanner())); - - Set> scannersSet = reflections.getSubTypesOf(Scanner.class); - return scannersSet; - } - -} +package com.baeldung.reflections; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.util.Date; +import java.util.Set; +import java.util.regex.Pattern; + +import org.reflections.Reflections; +import org.reflections.scanners.MethodAnnotationsScanner; +import org.reflections.scanners.MethodParameterScanner; +import org.reflections.scanners.ResourcesScanner; +import org.reflections.scanners.Scanner; +import org.reflections.scanners.SubTypesScanner; +import org.reflections.util.ClasspathHelper; +import org.reflections.util.ConfigurationBuilder; + +public class ReflectionsApp { + + public Set> getReflectionsSubTypes() { + Reflections reflections = new Reflections("org.reflections"); + Set> scannersSet = reflections.getSubTypesOf(Scanner.class); + return scannersSet; + } + + public Set> getJDKFunctinalInterfaces() { + Reflections reflections = new Reflections("java.util.function"); + Set> typesSet = reflections.getTypesAnnotatedWith(FunctionalInterface.class); + return typesSet; + } + + public Set getDateDeprecatedMethods() { + Reflections reflections = new Reflections(java.util.Date.class, new MethodAnnotationsScanner()); + Set deprecatedMethodsSet = reflections.getMethodsAnnotatedWith(Deprecated.class); + return deprecatedMethodsSet; + } + + @SuppressWarnings("rawtypes") + public Set getDateDeprecatedConstructors() { + Reflections reflections = new Reflections(java.util.Date.class, new MethodAnnotationsScanner()); + Set constructorsSet = reflections.getConstructorsAnnotatedWith(Deprecated.class); + return constructorsSet; + } + + public Set getMethodsWithDateParam() { + Reflections reflections = new Reflections(java.text.SimpleDateFormat.class, new MethodParameterScanner()); + Set methodsSet = reflections.getMethodsMatchParams(Date.class); + return methodsSet; + } + + public Set getMethodsWithVoidReturn() { + Reflections reflections = new Reflections(java.text.SimpleDateFormat.class, new MethodParameterScanner()); + Set methodsSet = reflections.getMethodsReturn(void.class); + return methodsSet; + } + + public Set getPomXmlPaths() { + Reflections reflections = new Reflections(new ResourcesScanner()); + Set resourcesSet = reflections.getResources(Pattern.compile(".*pom\\.xml")); + return resourcesSet; + } + + public Set> getReflectionsSubTypesUsingBuilder() { + Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forPackage("org.reflections")) + .setScanners(new SubTypesScanner())); + + Set> scannersSet = reflections.getSubTypesOf(Scanner.class); + return scannersSet; + } + +} diff --git a/libraries/src/test/java/com/baeldung/fj/FunctionalJavaUnitTest.java b/libraries-6/src/test/java/com/baeldung/fj/FunctionalJavaUnitTest.java similarity index 95% rename from libraries/src/test/java/com/baeldung/fj/FunctionalJavaUnitTest.java rename to libraries-6/src/test/java/com/baeldung/fj/FunctionalJavaUnitTest.java index 97ead07470..f79d334b23 100644 --- a/libraries/src/test/java/com/baeldung/fj/FunctionalJavaUnitTest.java +++ b/libraries-6/src/test/java/com/baeldung/fj/FunctionalJavaUnitTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import org.junit.Assert; import org.junit.Test; import fj.F; @@ -96,9 +97,9 @@ public class FunctionalJavaUnitTest { Option result2 = n2.bind(function); Option result3 = n3.bind(function); - assertEquals(Option.none(), result1); - assertEquals(Option.some(102), result2); - assertEquals(Option.none(), result3); + Assert.assertEquals(Option.none(), result1); + Assert.assertEquals(Option.some(102), result2); + Assert.assertEquals(Option.none(), result3); } @Test diff --git a/libraries/src/test/java/com/baeldung/ftp/FtpClientIntegrationTest.java b/libraries-6/src/test/java/com/baeldung/ftp/FtpClientIntegrationTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/ftp/FtpClientIntegrationTest.java rename to libraries-6/src/test/java/com/baeldung/ftp/FtpClientIntegrationTest.java diff --git a/libraries/src/test/java/com/baeldung/ftp/JdkFtpClientIntegrationTest.java b/libraries-6/src/test/java/com/baeldung/ftp/JdkFtpClientIntegrationTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/ftp/JdkFtpClientIntegrationTest.java rename to libraries-6/src/test/java/com/baeldung/ftp/JdkFtpClientIntegrationTest.java diff --git a/libraries/src/test/java/com/baeldung/javapoet/test/PersonGeneratorUnitTest.java b/libraries-6/src/test/java/com/baeldung/javapoet/test/PersonGeneratorUnitTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/javapoet/test/PersonGeneratorUnitTest.java rename to libraries-6/src/test/java/com/baeldung/javapoet/test/PersonGeneratorUnitTest.java diff --git a/libraries/src/test/java/com/baeldung/javapoet/test/person/Gender.java b/libraries-6/src/test/java/com/baeldung/javapoet/test/person/Gender.java similarity index 100% rename from libraries/src/test/java/com/baeldung/javapoet/test/person/Gender.java rename to libraries-6/src/test/java/com/baeldung/javapoet/test/person/Gender.java diff --git a/libraries/src/test/java/com/baeldung/javapoet/test/person/Person.java b/libraries-6/src/test/java/com/baeldung/javapoet/test/person/Person.java similarity index 100% rename from libraries/src/test/java/com/baeldung/javapoet/test/person/Person.java rename to libraries-6/src/test/java/com/baeldung/javapoet/test/person/Person.java diff --git a/libraries/src/test/java/com/baeldung/javapoet/test/person/Student.java b/libraries-6/src/test/java/com/baeldung/javapoet/test/person/Student.java similarity index 100% rename from libraries/src/test/java/com/baeldung/javapoet/test/person/Student.java rename to libraries-6/src/test/java/com/baeldung/javapoet/test/person/Student.java diff --git a/libraries/src/test/java/com/baeldung/kafkastreams/KafkaStreamsLiveTest.java b/libraries-6/src/test/java/com/baeldung/kafkastreams/KafkaStreamsLiveTest.java similarity index 100% rename from libraries/src/test/java/com/baeldung/kafkastreams/KafkaStreamsLiveTest.java rename to libraries-6/src/test/java/com/baeldung/kafkastreams/KafkaStreamsLiveTest.java diff --git a/libraries/src/test/java/com/baeldung/reflections/ReflectionsUnitTest.java b/libraries-6/src/test/java/com/baeldung/reflections/ReflectionsUnitTest.java similarity index 96% rename from libraries/src/test/java/com/baeldung/reflections/ReflectionsUnitTest.java rename to libraries-6/src/test/java/com/baeldung/reflections/ReflectionsUnitTest.java index 9a3ef0747b..b86094b6f4 100644 --- a/libraries/src/test/java/com/baeldung/reflections/ReflectionsUnitTest.java +++ b/libraries-6/src/test/java/com/baeldung/reflections/ReflectionsUnitTest.java @@ -1,50 +1,50 @@ -package com.baeldung.reflections; - -import static org.junit.jupiter.api.Assertions.assertFalse; - -import org.junit.jupiter.api.Test; - -public class ReflectionsUnitTest { - - @Test - public void givenTypeThenGetAllSubTypes() { - ReflectionsApp reflectionsApp = new ReflectionsApp(); - assertFalse(reflectionsApp.getReflectionsSubTypes() - .isEmpty()); - } - - @Test - public void givenTypeAndUsingBuilderThenGetAllSubTypes() { - ReflectionsApp reflectionsApp = new ReflectionsApp(); - assertFalse(reflectionsApp.getReflectionsSubTypesUsingBuilder() - .isEmpty()); - } - - @Test - public void givenAnnotationThenGetAllAnnotatedMethods() { - ReflectionsApp reflectionsApp = new ReflectionsApp(); - assertFalse(reflectionsApp.getDateDeprecatedMethods() - .isEmpty()); - } - - @Test - public void givenAnnotationThenGetAllAnnotatedConstructors() { - ReflectionsApp reflectionsApp = new ReflectionsApp(); - assertFalse(reflectionsApp.getDateDeprecatedConstructors() - .isEmpty()); - } - - @Test - public void givenParamTypeThenGetAllMethods() { - ReflectionsApp reflectionsApp = new ReflectionsApp(); - assertFalse(reflectionsApp.getMethodsWithDateParam() - .isEmpty()); - } - - @Test - public void givenReturnTypeThenGetAllMethods() { - ReflectionsApp reflectionsApp = new ReflectionsApp(); - assertFalse(reflectionsApp.getMethodsWithVoidReturn() - .isEmpty()); - } -} +package com.baeldung.reflections; + +import static org.junit.jupiter.api.Assertions.assertFalse; + +import org.junit.jupiter.api.Test; + +public class ReflectionsUnitTest { + + @Test + public void givenTypeThenGetAllSubTypes() { + ReflectionsApp reflectionsApp = new ReflectionsApp(); + assertFalse(reflectionsApp.getReflectionsSubTypes() + .isEmpty()); + } + + @Test + public void givenTypeAndUsingBuilderThenGetAllSubTypes() { + ReflectionsApp reflectionsApp = new ReflectionsApp(); + assertFalse(reflectionsApp.getReflectionsSubTypesUsingBuilder() + .isEmpty()); + } + + @Test + public void givenAnnotationThenGetAllAnnotatedMethods() { + ReflectionsApp reflectionsApp = new ReflectionsApp(); + assertFalse(reflectionsApp.getDateDeprecatedMethods() + .isEmpty()); + } + + @Test + public void givenAnnotationThenGetAllAnnotatedConstructors() { + ReflectionsApp reflectionsApp = new ReflectionsApp(); + assertFalse(reflectionsApp.getDateDeprecatedConstructors() + .isEmpty()); + } + + @Test + public void givenParamTypeThenGetAllMethods() { + ReflectionsApp reflectionsApp = new ReflectionsApp(); + assertFalse(reflectionsApp.getMethodsWithDateParam() + .isEmpty()); + } + + @Test + public void givenReturnTypeThenGetAllMethods() { + ReflectionsApp reflectionsApp = new ReflectionsApp(); + assertFalse(reflectionsApp.getMethodsWithVoidReturn() + .isEmpty()); + } +} diff --git a/libraries/src/test/java/com/baeldung/resilience4j/Resilience4jUnitTest.java b/libraries-6/src/test/java/com/baeldung/resilence4j/Resilience4jUnitTest.java similarity index 99% rename from libraries/src/test/java/com/baeldung/resilience4j/Resilience4jUnitTest.java rename to libraries-6/src/test/java/com/baeldung/resilence4j/Resilience4jUnitTest.java index ced95c99cb..1d69d20bc2 100644 --- a/libraries/src/test/java/com/baeldung/resilience4j/Resilience4jUnitTest.java +++ b/libraries-6/src/test/java/com/baeldung/resilence4j/Resilience4jUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.resilience4j; +package com.baeldung.resilence4j; import io.github.resilience4j.bulkhead.Bulkhead; import io.github.resilience4j.bulkhead.BulkheadConfig; diff --git a/libraries/src/test/resources/ftp/baz.txt b/libraries-6/src/test/resources/ftp/baz.txt similarity index 100% rename from libraries/src/test/resources/ftp/baz.txt rename to libraries-6/src/test/resources/ftp/baz.txt diff --git a/libraries/pom.xml b/libraries/pom.xml index 5d540f0d90..da9c9de907 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -12,18 +12,18 @@ - - - com.typesafe.akka - akka-actor_2.12 - ${typesafe-akka.version} - - - com.typesafe.akka - akka-testkit_2.12 - ${typesafe-akka.version} - test - + + + + + + + + + + + + org.beykery @@ -36,16 +36,16 @@ cglib ${cglib.version} - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - commons-net - commons-net - ${commons-net.version} - + + + + + + + + + + org.javatuples @@ -64,11 +64,11 @@ ${javers.version} - - io.nats - jnats - ${jnats.version} - + + + + + @@ -228,11 +228,11 @@ jool ${jool.version} - - org.openjdk.jmh - jmh-core - ${jmh.version} - + + + + + junit junit @@ -244,18 +244,18 @@ java-lsh ${java-lsh.version} - - au.com.dius - pact-jvm-consumer-junit_2.11 - ${pact.version} - test - - - org.codehaus.groovy - groovy-all - - - + + + + + + + + + + + + @@ -274,16 +274,16 @@ ${org.hamcrest.java-hamcrest.version} test - - net.bytebuddy - byte-buddy - ${bytebuddy.version} - - - net.bytebuddy - byte-buddy-agent - ${bytebuddy.version} - + + + + + + + + + + @@ -320,43 +320,43 @@ - - com.codepoetics - protonpack - ${protonpack.version} - - - org.functionaljava - functionaljava-java8 - ${functionaljava.version} - - - com.github.ben-manes.caffeine - caffeine - ${caffeine.version} - + + + + + + + + + + + + + + + - - - com.github.docker-java - docker-java - ${docker.version} - - - org.slf4j - slf4j-log4j12 - - - org.slf4j - jcl-over-slf4j - - - ch.qos.logback - logback-classic - - - - + + + + + + + + + + + + + + + + + + + + + @@ -364,58 +364,58 @@ google-oauth-client-jetty ${google-api.version} - - org.apache.kafka - kafka-streams - ${kafka.version} - - - org.apache.kafka - kafka-clients - ${kafka.version} - test - test - + + + + + + + + + + + + - - - io.atlassian.fugue - fugue - ${fugue.version} - + + + + + + - - org.jctools - jctools-core - ${jctools.version} - + + + + + - - io.github.resilience4j - resilience4j-circuitbreaker - ${resilience4j.version} - - - io.github.resilience4j - resilience4j-bulkhead - ${resilience4j.version} - - - io.github.resilience4j - resilience4j-retry - ${resilience4j.version} - - - io.github.resilience4j - resilience4j-timelimiter - ${resilience4j.version} - - - com.squareup - javapoet - ${javapoet.version} - + + + + + + + + + + + + + + + + + + + + + + + + + org.hamcrest hamcrest-all @@ -423,18 +423,18 @@ test - - org.mockftpserver - MockFtpServer - ${mockftpserver.version} - test - - - - org.reflections - reflections - ${reflections.version} - + + + + + + + + + + + + @@ -562,7 +562,7 @@ 1.2 3.6.2 3.1.0 - 1.0 + 2.92 1.9.26 @@ -574,24 +574,24 @@ 3.5.0 2.0.0.0 - 1.7.1 + - 1.15 - 2.5.5 + + 1.23.0 - 2.0.0 - 3.0.14 + + 0.9.4.0006L - 2.1.2 - 2.5.11 - 0.12.1 - 1.10.0 + + + + 1.3 3.2.0-m7 5.1.1 @@ -603,17 +603,17 @@ 3.0.3 2.3.0 0.9.12 - 1.19 + - 4.8.1 - 4.5.1 + + 3.0.2 - 2.7.1 - 3.6 - 0.9.11 + + + From 9bf7546d42eae5dd8d191c29ee7bb56c242120bf Mon Sep 17 00:00:00 2001 From: Sasa M Date: Wed, 29 Apr 2020 21:55:30 +0200 Subject: [PATCH 388/503] Creating TypeMap to use property mapping and converter class --- .../com/baeldung/modelmapper/MapperUtil.java | 2 +- .../baeldung/modelmapper/UserPropertyMap.java | 37 ------------------- .../modelmapper/UsersListConverter.java | 23 ++++++++++++ .../modelmapper/UsersListMappingUnitTest.java | 30 +++++++++------ 4 files changed, 43 insertions(+), 49 deletions(-) delete mode 100644 java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java create mode 100644 java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UsersListConverter.java diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java index 9c6a5a0320..23a549e652 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/MapperUtil.java @@ -6,7 +6,7 @@ import java.util.List; import java.util.stream.Collectors; /** - * This is a helper class that contains method for generic mapping of the users list. + * This is a helper class that contains method for custom mapping of the users list. * Initially, an instance of ModelMapper was created. * * @author Sasa Milenkovic diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java deleted file mode 100644 index 5b2942b158..0000000000 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.baeldung.modelmapper; - -import org.modelmapper.AbstractConverter; -import org.modelmapper.Converter; -import org.modelmapper.PropertyMap; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * UserPropertyMap class instantiates the converter to map the data from the UserList to the UsersLisDTO. - * In the configuration method, we call a converter to do the mapping. - * - * @author Sasa Milenkovic - */ -public class UserPropertyMap extends PropertyMap { - - - Converter, List> converter = new AbstractConverter, List>() { - - - @Override - protected List convert(List users) { - - return users - .stream() - .map(User::getUsername) - .collect(Collectors.toList()); - } - }; - - @Override - protected void configure() { - - using(converter).map(source.getUsers(), destination.getUsernames()); - } -} diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UsersListConverter.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UsersListConverter.java new file mode 100644 index 0000000000..19423713e2 --- /dev/null +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UsersListConverter.java @@ -0,0 +1,23 @@ +package com.baeldung.modelmapper; + +import org.modelmapper.AbstractConverter; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * UsersListConverter class map the property data from the list of users into the list of user names. + * + * @author Sasa Milenkovic + */ +public class UsersListConverter extends AbstractConverter, List> { + + @Override + protected List convert(List users) { + + return users + .stream() + .map(User::getUsername) + .collect(Collectors.toList()); + } +} diff --git a/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java index 982622e1f5..a8a72b12f7 100644 --- a/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java +++ b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UsersListMappingUnitTest.java @@ -4,6 +4,7 @@ import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; import org.modelmapper.ModelMapper; +import org.modelmapper.TypeMap; import org.modelmapper.TypeToken; import java.util.ArrayList; @@ -12,14 +13,12 @@ import java.util.List; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.hasProperty; -import static org.hamcrest.collection.IsCollectionWithSize.hasSize; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; /** * This class has test methods of mapping Integer to Character list, - * mapping user list to DTO list using MapperUtil generic methods and Converter + * mapping users list to DTO list using MapperUtil custom type method and property mapping using converter class * * @author Sasa Milenkovic */ @@ -32,7 +31,12 @@ public class UsersListMappingUnitTest { public void init() { modelMapper = new ModelMapper(); - modelMapper.addMappings(new UserPropertyMap()); + + TypeMap typeMap = modelMapper.createTypeMap(UserList.class, UserListDTO.class); + + typeMap.addMappings(mapper -> mapper.using(new UsersListConverter()) + .map(UserList::getUsers, UserListDTO::setUsernames)); + users = new ArrayList(); users.add(new User("b100", "user1", "user1@baeldung.com", "111-222", "USER")); users.add(new User("b101", "user2", "user2@baeldung.com", "111-333", "USER")); @@ -41,7 +45,7 @@ public class UsersListMappingUnitTest { } @Test - public void whenMapIntegerToCharList() { + public void whenInteger_thenMapToCharacter() { List integers = new ArrayList(); @@ -57,9 +61,9 @@ public class UsersListMappingUnitTest { } @Test - public void givenUsersList_whenUseGenericType_thenMapToDto() { + public void givenUsersList_whenUseGenericType_thenMapToUserDTO() { - // Mapping lists using custom type methods + // Mapping lists using custom (generic) type mapping List userDtoList = MapperUtil.mapList(users, UserDTO.class); @@ -68,16 +72,20 @@ public class UsersListMappingUnitTest { .and(hasProperty("email", equalTo("user1@baeldung.com"))) .and(hasProperty("username", equalTo("user1"))))); - // Mapping lists using PropertyMap and Converter + + } + + @Test + public void givenUsersList_whenUseConverter_thenMapToUsernames() { + + // Mapping lists using property mapping and converter UserList userList = new UserList(); userList.setUsers(users); UserListDTO dtos = new UserListDTO(); modelMapper.map(userList, dtos); - assertNotNull(dtos); - assertThat(dtos, Matchers.hasProperty("usernames")); - assertThat(dtos.getUsernames(), hasSize(3)); + assertThat(dtos.getUsernames(), hasItems("user1", "user2", "user3")); } From 753c0ef0d0c8ac22f35964ba55889fbf3e03d33c Mon Sep 17 00:00:00 2001 From: mikr Date: Wed, 29 Apr 2020 21:55:48 +0200 Subject: [PATCH 389/503] Java-1470 Fix compilation errors and Readme files --- libraries-2/README.md | 2 +- libraries-3/README.md | 1 + libraries-4/README.md | 2 +- libraries/README.md | 33 ----- libraries/pom.xml | 273 +++++------------------------------------- 5 files changed, 32 insertions(+), 279 deletions(-) diff --git a/libraries-2/README.md b/libraries-2/README.md index edf513c6ee..8dae12a1cf 100644 --- a/libraries-2/README.md +++ b/libraries-2/README.md @@ -18,5 +18,5 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Guide to MapDB](https://www.baeldung.com/mapdb) - [A Guide to Apache Mesos](https://www.baeldung.com/apache-mesos) - [JasperReports with Spring](https://www.baeldung.com/spring-jasper) -- More articles [[<-- prev]](/libraries) +- More articles [[<-- prev]](/libraries) [[next -->]](/libraries-3) diff --git a/libraries-3/README.md b/libraries-3/README.md index ec433960ef..7c30cabaf1 100644 --- a/libraries-3/README.md +++ b/libraries-3/README.md @@ -17,3 +17,4 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Using NullAway to Avoid NullPointerExceptions](https://www.baeldung.com/java-nullaway) - [Introduction to Alibaba Arthas](https://www.baeldung.com/java-alibaba-arthas-intro) - [Quick Guide to Spring Cloud Circuit Breaker](https://www.baeldung.com/spring-cloud-circuit-breaker) +- More articles [[<-- prev]](/libraries-2) [[next -->]](/libraries-4) \ No newline at end of file diff --git a/libraries-4/README.md b/libraries-4/README.md index 9cda07bdf5..0dee9f1c1e 100644 --- a/libraries-4/README.md +++ b/libraries-4/README.md @@ -18,4 +18,4 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Guide to JDeferred](https://www.baeldung.com/jdeferred) - [Introduction to MBassador](https://www.baeldung.com/mbassador) - [Using Pairs in Java](https://www.baeldung.com/java-pairs) -- More articles [[next -->]](/libraries-2) +- More articles [[<-- prev]](/libraries-3) [[next -->]](/libraries-5) diff --git a/libraries/README.md b/libraries/README.md index 3f259e4222..b61289504c 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -19,37 +19,4 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Software Transactional Memory in Java Using Multiverse](https://www.baeldung.com/java-multiverse-stm) - [Locality-Sensitive Hashing in Java Using Java-LSH](https://www.baeldung.com/locality-sensitive-hashing) - [Introduction to Neuroph](https://www.baeldung.com/neuroph) - -#4 -- [Quick Guide to RSS with Rome](https://www.baeldung.com/rome-rss) -- [Introduction to PCollections](https://www.baeldung.com/java-pcollections) -- [Introduction to Eclipse Collections](https://www.baeldung.com/eclipse-collections) -- [DistinctBy in the Java Stream API](https://www.baeldung.com/java-streams-distinct-by) -- [Introduction to NoException](https://www.baeldung.com/no-exception) -- [Spring Yarg Integration](https://www.baeldung.com/spring-yarg) -- [Delete a Directory Recursively in Java](https://www.baeldung.com/java-delete-directory) -- [Guide to JDeferred](https://www.baeldung.com/jdeferred) -- [Introduction to MBassador](https://www.baeldung.com/mbassador) -- [Using Pairs in Java](https://www.baeldung.com/java-pairs) - -#5 -- [Introduction to Caffeine](https://www.baeldung.com/java-caching-caffeine) -- [Introduction to StreamEx](https://www.baeldung.com/streamex) -- [A Docker Guide for Java](https://www.baeldung.com/docker-java-api) -- [Introduction to Akka Actors in Java](https://www.baeldung.com/akka-actors-java) -- [A Guide to Byte Buddy](https://www.baeldung.com/byte-buddy) -- [Introduction to jOOL](https://www.baeldung.com/jool) -- [Consumer Driven Contracts with Pact](https://www.baeldung.com/pact-junit-consumer-driven-contracts) -- [Introduction to Atlassian Fugue](https://www.baeldung.com/java-fugue) -- [Publish and Receive Messages with Nats Java Client](https://www.baeldung.com/nats-java-client) -- [Java Concurrency Utility with JCTools](https://www.baeldung.com/java-concurrency-jc-tools) - -#6 -- [Introduction to JavaPoet](https://www.baeldung.com/java-poet) -- [Guide to Resilience4j](https://www.baeldung.com/resilience4j) -- [Implementing a FTP-Client in Java](https://www.baeldung.com/java-ftp-client) -- [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) - More articles [[next -->]](/libraries-2) diff --git a/libraries/pom.xml b/libraries/pom.xml index da9c9de907..fee66f928d 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -12,18 +12,6 @@ - - - - - - - - - - - - org.beykery @@ -36,16 +24,16 @@ cglib ${cglib.version} - - - - - - - - - - + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + commons-net + commons-net + ${commons-net.version} + org.javatuples @@ -63,18 +51,6 @@ javers-core ${javers.version} - - - - - - - - - - - - net.serenity-bdd serenity-core @@ -218,21 +194,16 @@ quartz ${quartz.version} - - - - - org.jooq jool ${jool.version} - - - - - + + org.openjdk.jmh + jmh-core + ${jmh.version} + junit junit @@ -244,119 +215,23 @@ java-lsh ${java-lsh.version} - - - - - - - - - - - - - - - - - - - - - - - - + + commons-io + commons-io + ${commonsio.version} + org.hamcrest java-hamcrest ${org.hamcrest.java-hamcrest.version} test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + com.codepoetics + protonpack + ${protonpack.version} + @@ -364,77 +239,12 @@ google-oauth-client-jetty ${google-api.version} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.hamcrest hamcrest-all ${hamcrest-all.version} test - - - - - - - - - - - - - @@ -562,8 +372,6 @@ 1.2 3.6.2 3.1.0 - - 2.92 1.9.26 1.41.0 @@ -572,26 +380,10 @@ 1.1.0 0.10 3.5.0 - 2.0.0.0 - - - - - - - - - + 1.15 1.23.0 - - - 0.9.4.0006L - - - - 1.3 3.2.0-m7 5.1.1 @@ -603,17 +395,10 @@ 3.0.3 2.3.0 0.9.12 - - - - - - - + 1.19 3.0.2 - - - + 3.6 + 2.6 From 4552da7ba7126e190234553d39e77444f63785ff Mon Sep 17 00:00:00 2001 From: mikr Date: Wed, 29 Apr 2020 22:02:31 +0200 Subject: [PATCH 390/503] Java-1470 Add new modules to main pom --- pom.xml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index d481f95042..ed4b3e5b30 100644 --- a/pom.xml +++ b/pom.xml @@ -497,6 +497,9 @@ libraries-2 libraries-3 + libraries-4 + libraries-5 + libraries-6 libraries-apache-commons libraries-apache-commons-collections libraries-apache-commons-io @@ -1012,8 +1015,8 @@ libraries-2 libraries-3 libraries-4 - - + libraries-5 + libraries-6 libraries-apache-commons libraries-apache-commons-collections From 2c99a832cdf6a9850790aad0b4ab69f2b6192ac0 Mon Sep 17 00:00:00 2001 From: SippingCode <55111084+SippingCode@users.noreply.github.com> Date: Thu, 30 Apr 2020 08:16:05 +0200 Subject: [PATCH 391/503] Bael 3970 (#9132) * Manual logout with Spring Security - Basic manual logout - logout with Clear Data Site Header * Add missing annotation for controller. Change mapping URL value. * Add intergration tests for manual logouts. * BAEL-3970 - Add asserts on test. Fix tests names. Remove unused imports. * BAEL-3970 - Use PostMapping annotation. Remove unnecessary information for security configuration. * remove logout controllers * Add multiple entrypoints configurations. Create custom handlers for different logouts (basic, cookie clearing, clear-site-data). * Refactor configuration with lambda DSL. --- .../manuallogout/BasicAuthController.java | 32 ------- .../manuallogout/ClearSiteDataController.java | 29 ------ .../SimpleSecurityConfiguration.java | 89 ++++++++++++++----- .../ManualLogoutIntegrationTest.java | 24 +++-- 4 files changed, 84 insertions(+), 90 deletions(-) delete mode 100644 spring-5-security/src/main/java/com/baeldung/manuallogout/BasicAuthController.java delete mode 100644 spring-5-security/src/main/java/com/baeldung/manuallogout/ClearSiteDataController.java diff --git a/spring-5-security/src/main/java/com/baeldung/manuallogout/BasicAuthController.java b/spring-5-security/src/main/java/com/baeldung/manuallogout/BasicAuthController.java deleted file mode 100644 index 8f01940dce..0000000000 --- a/spring-5-security/src/main/java/com/baeldung/manuallogout/BasicAuthController.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baeldung.manuallogout; - -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; - -@Controller -public class BasicAuthController { - - @RequestMapping(value = {"/basiclogout"}, method = RequestMethod.POST) - public String logout(HttpServletRequest request, HttpServletResponse response) { - HttpSession session; - SecurityContextHolder.clearContext(); - session = request.getSession(false); - if (session != null) { - session.invalidate(); - } - for (Cookie cookie : request.getCookies()) { - String cookieName = cookie.getName(); - Cookie cookieToDelete = new Cookie(cookieName, null); - cookieToDelete.setMaxAge(0); - response.addCookie(cookieToDelete); - } - return "redirect:/login?logout"; - } -} diff --git a/spring-5-security/src/main/java/com/baeldung/manuallogout/ClearSiteDataController.java b/spring-5-security/src/main/java/com/baeldung/manuallogout/ClearSiteDataController.java deleted file mode 100644 index 7eef397da3..0000000000 --- a/spring-5-security/src/main/java/com/baeldung/manuallogout/ClearSiteDataController.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.manuallogout; - -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.web.authentication.logout.HeaderWriterLogoutHandler; -import org.springframework.security.web.header.writers.ClearSiteDataHeaderWriter; -import org.springframework.security.web.header.writers.ClearSiteDataHeaderWriter.Directive; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -@Controller -public class ClearSiteDataController { - - Directive[] SOURCE = {Directive.COOKIES, Directive.STORAGE, Directive.EXECUTION_CONTEXTS, Directive.CACHE}; - - @RequestMapping(value = {"/csdlogout"}, method = RequestMethod.POST) - public String logout(HttpServletRequest request, HttpServletResponse response) { - Authentication auth = SecurityContextHolder.getContext().getAuthentication(); - if (auth != null) { - ClearSiteDataHeaderWriter csdHeaderWriter = new ClearSiteDataHeaderWriter(SOURCE); - new HeaderWriterLogoutHandler(csdHeaderWriter).logout(request, response, auth); - } - return "redirect:/login?logout"; - } -} diff --git a/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java b/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java index 6f14f6fca2..63394b64f2 100644 --- a/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java +++ b/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java @@ -1,39 +1,80 @@ package com.baeldung.manuallogout; import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; 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.web.authentication.logout.CookieClearingLogoutHandler; +import org.springframework.security.web.authentication.logout.HeaderWriterLogoutHandler; +import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; +import org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices; +import org.springframework.security.web.header.writers.ClearSiteDataHeaderWriter; + +import javax.servlet.http.Cookie; + +import static org.springframework.security.web.header.writers.ClearSiteDataHeaderWriter.Directive.*; @Configuration @EnableWebSecurity -public class SimpleSecurityConfiguration extends WebSecurityConfigurerAdapter { +public class SimpleSecurityConfiguration { - @Override - protected void configure(HttpSecurity http) throws Exception { - http.formLogin() - .loginProcessingUrl("/login") - .loginPage("/login") - .usernameParameter("username") - .passwordParameter("password") - .defaultSuccessUrl("/") - .failureUrl("/login?error"); + @Order(3) + @Configuration + public static class DefaultLogoutConfiguration extends WebSecurityConfigurerAdapter { + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .antMatcher("/basic/**") + .authorizeRequests(authz -> authz.anyRequest().permitAll()) + .logout(logout -> logout + .logoutUrl("/basic/basiclogout") + .addLogoutHandler(new SecurityContextLogoutHandler()) + .addLogoutHandler(new CookieClearingLogoutHandler(AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY)) + ); + } } - @Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.inMemoryAuthentication() - .withUser("user") - .password("password") - .roles("USER") - .and() - .withUser("manager") - .password("password") - .credentialsExpired(true) - .accountExpired(true) - .accountLocked(true) - .authorities("WRITE_PRIVILEGES", "READ_PRIVILEGES") - .roles("MANAGER"); + @Order(2) + @Configuration + public static class AllCookieClearingLogoutConfiguration extends WebSecurityConfigurerAdapter { + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .antMatcher("/cookies/**") + .authorizeRequests(authz -> authz.anyRequest().permitAll()) + .logout(logout -> logout + .logoutUrl("/cookies/cookielogout") + .addLogoutHandler(new SecurityContextLogoutHandler()) + .addLogoutHandler((request, response, auth) -> { + for (Cookie cookie : request.getCookies()) { + String cookieName = cookie.getName(); + Cookie cookieToDelete = new Cookie(cookieName, null); + cookieToDelete.setMaxAge(0); + response.addCookie(cookieToDelete); + } + } + )); + } + } + + @Order(1) + @Configuration + public static class ClearSiteDataHeaderLogoutConfiguration extends WebSecurityConfigurerAdapter { + + private static final ClearSiteDataHeaderWriter.Directive[] SOURCE = + { CACHE, COOKIES, STORAGE, EXECUTION_CONTEXTS }; + + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .antMatcher("/csd/**") + .authorizeRequests(authz -> authz.anyRequest().permitAll()) + .logout(logout -> logout + .logoutUrl("/csd/csdlogout") + .addLogoutHandler(new HeaderWriterLogoutHandler(new ClearSiteDataHeaderWriter(SOURCE))) + ); + } } } diff --git a/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java b/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java index a64cb82910..09e7daf877 100644 --- a/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java +++ b/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java @@ -7,6 +7,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpSession; import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; @@ -36,7 +37,22 @@ public class ManualLogoutIntegrationTest { @WithMockUser(value = "spring") @Test - public void givenLoggedUserWhenUserLogoutThenSessionCleared() throws Exception { + public void givenLoggedUserWhenUserLogoutThenSessionClearedAndNecessaryCookieCleared() throws Exception { + + MockHttpServletRequest requestStateAfterLogout = this.mockMvc.perform(post("/basic/basiclogout").secure(true).with(csrf())) + .andExpect(status().is3xxRedirection()) + .andExpect(unauthenticated()) + .andExpect(cookie().maxAge(AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, 0)) + .andReturn() + .getRequest(); + + HttpSession sessionStateAfterLogout = requestStateAfterLogout.getSession(); + assertNull(sessionStateAfterLogout.getAttribute(ATTRIBUTE_NAME)); + } + + @WithMockUser(value = "spring") + @Test + public void givenLoggedUserWhenUserLogoutThenSessionClearedAndAllCookiesCleared() throws Exception { MockHttpSession session = new MockHttpSession(); session.setAttribute(ATTRIBUTE_NAME, ATTRIBUTE_VALUE); @@ -44,7 +60,7 @@ public class ManualLogoutIntegrationTest { Cookie randomCookie = new Cookie(COOKIE_NAME, COOKIE_VALUE); randomCookie.setMaxAge(EXPIRY); // 10 minutes - MockHttpServletRequest requestStateAfterLogout = this.mockMvc.perform(post("/basiclogout").secure(true).with(csrf()).session(session).cookie(randomCookie)) + MockHttpServletRequest requestStateAfterLogout = this.mockMvc.perform(post("/cookies/cookielogout").secure(true).with(csrf()).session(session).cookie(randomCookie)) .andExpect(status().is3xxRedirection()) .andExpect(unauthenticated()) .andExpect(cookie().maxAge(COOKIE_NAME, 0)) @@ -53,15 +69,13 @@ public class ManualLogoutIntegrationTest { HttpSession sessionStateAfterLogout = requestStateAfterLogout.getSession(); assertNull(sessionStateAfterLogout.getAttribute(ATTRIBUTE_NAME)); - - } @WithMockUser(value = "spring") @Test public void givenLoggedUserWhenUserLogoutThenClearDataSiteHeaderPresent() throws Exception { - this.mockMvc.perform(post("/csdlogout").secure(true).with(csrf())) + this.mockMvc.perform(post("/csd/csdlogout").secure(true).with(csrf())) .andDo(print()) .andExpect(status().is3xxRedirection()) .andExpect(header().exists(CLEAR_SITE_DATA_HEADER)) From 89da31cbcebd898b84557cc38b0af546d66ff34d Mon Sep 17 00:00:00 2001 From: Kamlesh Kumar Date: Thu, 30 Apr 2020 17:48:30 +0530 Subject: [PATCH 392/503] BAEL-3837: Java Deadlock and Livelock (#8943) --- .../deadlockAndLivelock/DeadlockExample.java | 60 +++++++++++++ .../deadlockAndLivelock/LivelockExample.java | 86 +++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/deadlockAndLivelock/DeadlockExample.java create mode 100644 core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/deadlockAndLivelock/LivelockExample.java diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/deadlockAndLivelock/DeadlockExample.java b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/deadlockAndLivelock/DeadlockExample.java new file mode 100644 index 0000000000..bcdaf302ea --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/deadlockAndLivelock/DeadlockExample.java @@ -0,0 +1,60 @@ +package com.baeldung.deadlockAndLivelock; + +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +public class DeadlockExample { + + private Lock lock1 = new ReentrantLock(true); + private Lock lock2 = new ReentrantLock(true); + + public static void main(String[] args) { + DeadlockExample deadlock = new DeadlockExample(); + new Thread(deadlock::operation1, "T1").start(); + new Thread(deadlock::operation2, "T2").start(); + + } + + public void operation1() { + lock1.lock(); + print("lock1 acquired, waiting to acquire lock2."); + sleep(50); + + lock2.lock(); + print("lock2 acquired"); + + print("executing first operation."); + + lock2.unlock(); + lock1.unlock(); + + } + + public void operation2() { + lock2.lock(); + print("lock2 acquired, waiting to acquire lock1."); + sleep(50); + + lock1.lock(); + print("lock1 acquired"); + + print("executing second operation."); + + lock1.unlock(); + lock2.unlock(); + } + + public void print(String message) { + System.out.println("Thread " + Thread.currentThread() + .getName() + ": " + message); + } + + public void sleep(long millis) { + try { + Thread.sleep(millis); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + +} diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/deadlockAndLivelock/LivelockExample.java b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/deadlockAndLivelock/LivelockExample.java new file mode 100644 index 0000000000..b0d66a92c2 --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/deadlockAndLivelock/LivelockExample.java @@ -0,0 +1,86 @@ +package com.baeldung.deadlockAndLivelock; + +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; + +public class LivelockExample { + + private Lock lock1 = new ReentrantLock(true); + private Lock lock2 = new ReentrantLock(true); + + public static void main(String[] args) { + LivelockExample livelock = new LivelockExample(); + new Thread(livelock::operation1, "T1").start(); + new Thread(livelock::operation2, "T2").start(); + + } + + public void operation1() { + while (true) { + tryLock(lock1, 50); + print("lock1 acquired, trying to acquire lock2."); + sleep(50); + + if (tryLock(lock2)) { + print("lock2 acquired."); + } else { + print("cannot acquire lock2, releasing lock1."); + lock1.unlock(); + continue; + } + + print("executing first operation."); + break; + } + lock2.unlock(); + lock1.unlock(); + } + + public void operation2() { + while (true) { + tryLock(lock2, 50); + print("lock2 acquired, trying to acquire lock1."); + sleep(50); + + if (tryLock(lock1)) { + print("lock1 acquired."); + } else { + print("cannot acquire lock1, releasing lock2."); + lock2.unlock(); + continue; + } + + print("executing second operation."); + break; + } + lock1.unlock(); + lock2.unlock(); + } + + public void print(String message) { + System.out.println("Thread " + Thread.currentThread() + .getName() + ": " + message); + } + + public void sleep(long millis) { + try { + Thread.sleep(millis); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + public void tryLock(Lock lock, long millis) { + try { + lock.tryLock(10, TimeUnit.MILLISECONDS); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + public boolean tryLock(Lock lock) { + return lock.tryLock(); + } + +} From 4bb9f166b6df24f11549f9f2627aaf26fbb9e7b6 Mon Sep 17 00:00:00 2001 From: Sasa M Date: Sun, 19 Apr 2020 21:02:17 +0200 Subject: [PATCH 393/503] Source project for the draft article --- model-mapper/src/Main.java | 58 +++++++++++++++ model-mapper/src/com/baeldung/model/User.java | 70 +++++++++++++++++++ .../src/com/baeldung/model/UserDTO.java | 49 +++++++++++++ .../src/com/baeldung/model/UserList.java | 21 ++++++ .../src/com/baeldung/util/MapperUtil.java | 47 +++++++++++++ .../com/baeldung/util/UserPropertyMap.java | 36 ++++++++++ 6 files changed, 281 insertions(+) create mode 100644 model-mapper/src/Main.java create mode 100644 model-mapper/src/com/baeldung/model/User.java create mode 100644 model-mapper/src/com/baeldung/model/UserDTO.java create mode 100644 model-mapper/src/com/baeldung/model/UserList.java create mode 100644 model-mapper/src/com/baeldung/util/MapperUtil.java create mode 100644 model-mapper/src/com/baeldung/util/UserPropertyMap.java diff --git a/model-mapper/src/Main.java b/model-mapper/src/Main.java new file mode 100644 index 0000000000..a6deb49168 --- /dev/null +++ b/model-mapper/src/Main.java @@ -0,0 +1,58 @@ +import com.baeldung.model.User; +import com.baeldung.model.UserDTO; +import com.baeldung.model.UserList; +import com.baeldung.util.MapperUtil; +import com.baeldung.util.UserPropertyMap; +import org.modelmapper.ModelMapper; +import org.modelmapper.TypeToken; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author sasam0320 + * @date 4/18/2020 + */ + +public class Main { + + public static void main(String[] args) { + + //Instantiate ModelMapper + + ModelMapper mapper = new ModelMapper(); + mapper.addMappings(new UserPropertyMap()); + + // Mapping lists using TypeToken generic class + + List integers = new ArrayList(); + + integers.add(1); + integers.add(2); + integers.add(3); + + List characters = mapper.map(integers, new TypeToken>() {}.getType()); + + System.out.println("Character list: " + characters); + + // Mapping lists using generic type methods + + List users = new ArrayList(); + users.add(new User("b100", "user1", "user1@baeldung.com", "111-222", "USER")); + users.add(new User("b101", "user2", "user2@baeldung.com", "111-333", "USER")); + users.add(new User("b102", "user3", "user3@baeldung.com", "111-444", "ADMIN")); + + List userDtoList = MapperUtil.mapList(users, UserDTO.class); + userDtoList.stream().map(userDto -> userDto.getEmail()).forEachOrdered(System.out::println); + + // Mapping lists using PropertyMap and Converter + + UserList userList = new UserList(); + userList.setUsers(users); + UserDTO dto = new UserDTO(); + + mapper.map(userList, dto); + dto.getUsernames().forEach(System.out::println); + + } +} diff --git a/model-mapper/src/com/baeldung/model/User.java b/model-mapper/src/com/baeldung/model/User.java new file mode 100644 index 0000000000..73e4baafb5 --- /dev/null +++ b/model-mapper/src/com/baeldung/model/User.java @@ -0,0 +1,70 @@ +package com.baeldung.model; + +import java.util.List; + +/** + * @author sasam0320 + * @date 4/18/2020 + */ +public class User { + + private String userId; + private String userName; + private String email; + private String contactNumber; + private String userType; + + // Standard constructors, getters and setters + + public User(){} + + public User(String userId, String userName, String email, String contactNumber, String userType) { + this.userId = userId; + this.userName = userName; + this.email = email; + this.contactNumber = contactNumber; + this.userType = userType; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getContactNumber() { + return contactNumber; + } + + public void setContactNumber(String contactNumber) { + this.contactNumber = contactNumber; + } + + public String getUserType() { + return userType; + } + + public void setUserType(String userType) { + this.userType = userType; + } + + +} diff --git a/model-mapper/src/com/baeldung/model/UserDTO.java b/model-mapper/src/com/baeldung/model/UserDTO.java new file mode 100644 index 0000000000..ed056ace8c --- /dev/null +++ b/model-mapper/src/com/baeldung/model/UserDTO.java @@ -0,0 +1,49 @@ +package com.baeldung.model; + +import java.util.List; + +/** + * @author sasam0320 + * @date 4/18/2020 + */ +public class UserDTO { + + private String userId; + private String userName; + private String email; + private List usernames; + + // getters and setters + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public List getUsernames() { + return usernames; + } + + public void setUsernames(List usernames) { + this.usernames = usernames; + } +} diff --git a/model-mapper/src/com/baeldung/model/UserList.java b/model-mapper/src/com/baeldung/model/UserList.java new file mode 100644 index 0000000000..b30d5507d5 --- /dev/null +++ b/model-mapper/src/com/baeldung/model/UserList.java @@ -0,0 +1,21 @@ +package com.baeldung.model; + +import java.util.Collection; + +/** + * @author sasam0320 + * @date 4/18/2020 + */ + +public class UserList { + + private Collection users; + + public Collection getUsers() { + return users; + } + + public void setUsers(Collection users) { + this.users = users; + } +} diff --git a/model-mapper/src/com/baeldung/util/MapperUtil.java b/model-mapper/src/com/baeldung/util/MapperUtil.java new file mode 100644 index 0000000000..fe10b7777d --- /dev/null +++ b/model-mapper/src/com/baeldung/util/MapperUtil.java @@ -0,0 +1,47 @@ +package com.baeldung.util; + +import org.modelmapper.ModelMapper; +import org.modelmapper.convention.MatchingStrategies; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author sasam0320 + * @date 4/18/2020 + */ +public class MapperUtil { + + + private static ModelMapper modelMapper = new ModelMapper(); + + + static { + + modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); + + } + + private MapperUtil() { + + + } + + public static T mapTo(final S source, final Class target) { + + return modelMapper.map(source, target); + } + + public static List mapList(final List sourceList, final Class target) { + + List targetList = new ArrayList(); + + for (S source : sourceList) { + + targetList.add(modelMapper.map(source, target)); + } + + return targetList; + } + +} diff --git a/model-mapper/src/com/baeldung/util/UserPropertyMap.java b/model-mapper/src/com/baeldung/util/UserPropertyMap.java new file mode 100644 index 0000000000..4346174440 --- /dev/null +++ b/model-mapper/src/com/baeldung/util/UserPropertyMap.java @@ -0,0 +1,36 @@ +package com.baeldung.util; + +import com.baeldung.model.User; +import com.baeldung.model.UserDTO; +import com.baeldung.model.UserList; +import org.modelmapper.AbstractConverter; +import org.modelmapper.Converter; +import org.modelmapper.PropertyMap; +import java.util.ArrayList; +import java.util.List; + +/** + * @author sasam0320 + * @date 4/18/2020 + */ + +public class UserPropertyMap extends PropertyMap { + + + Converter, List> converter = new AbstractConverter, List>() { + + List usernames = new ArrayList<>(); + + protected List convert(List users) { + + users.forEach(user -> usernames.add(user.getUserName())); + return usernames; + } + + }; + + @Override + protected void configure() { + using(converter).map(source.getUsers(), destination.getUsernames()); + } +} From b9cbfa49c4aa8c4ff114f634b82a3514f0785d84 Mon Sep 17 00:00:00 2001 From: Sasa M Date: Tue, 21 Apr 2020 18:46:45 +0200 Subject: [PATCH 394/503] Moving com.baeldung.modelmmaper package to java-collections-conversations module --- .../modelmapper}/UserPropertyMap.java | 12 ++- .../baeldung/modelmapper/UserMappingTest.java | 85 +++++++++++++++++++ model-mapper/src/Main.java | 58 ------------- model-mapper/src/com/baeldung/model/User.java | 70 --------------- .../src/com/baeldung/model/UserDTO.java | 49 ----------- .../src/com/baeldung/model/UserList.java | 21 ----- .../src/com/baeldung/util/MapperUtil.java | 47 ---------- 7 files changed, 90 insertions(+), 252 deletions(-) rename {model-mapper/src/com/baeldung/util => java-collections-conversions-2/src/main/java/com/baeldung/modelmapper}/UserPropertyMap.java (68%) create mode 100644 java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UserMappingTest.java delete mode 100644 model-mapper/src/Main.java delete mode 100644 model-mapper/src/com/baeldung/model/User.java delete mode 100644 model-mapper/src/com/baeldung/model/UserDTO.java delete mode 100644 model-mapper/src/com/baeldung/model/UserList.java delete mode 100644 model-mapper/src/com/baeldung/util/MapperUtil.java diff --git a/model-mapper/src/com/baeldung/util/UserPropertyMap.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java similarity index 68% rename from model-mapper/src/com/baeldung/util/UserPropertyMap.java rename to java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java index 4346174440..9fa945ce32 100644 --- a/model-mapper/src/com/baeldung/util/UserPropertyMap.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java @@ -1,8 +1,5 @@ -package com.baeldung.util; +package com.baeldung.modelmapper; -import com.baeldung.model.User; -import com.baeldung.model.UserDTO; -import com.baeldung.model.UserList; import org.modelmapper.AbstractConverter; import org.modelmapper.Converter; import org.modelmapper.PropertyMap; @@ -11,10 +8,11 @@ import java.util.List; /** * @author sasam0320 - * @date 4/18/2020 + * @description + * UserPropertyMap class instantiates the converter to map the data from the user list to the user name list. + * In the configuration method, we call a converter to do the mapping. */ - -public class UserPropertyMap extends PropertyMap { +public class UserPropertyMap extends PropertyMap { Converter, List> converter = new AbstractConverter, List>() { diff --git a/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UserMappingTest.java b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UserMappingTest.java new file mode 100644 index 0000000000..44a929621b --- /dev/null +++ b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UserMappingTest.java @@ -0,0 +1,85 @@ +package com.baeldung.modelmapper; + +import org.hamcrest.Matchers; +import org.junit.Before; +import org.junit.Test; +import org.modelmapper.ModelMapper; +import org.modelmapper.TypeToken; + +import java.util.ArrayList; +import java.util.List; + +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.hasProperty; +import static org.hamcrest.collection.IsCollectionWithSize.hasSize; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; + + +/** + * @sasam0320 + * @description + * This class has test methods of mapping Integer to Character list, + * mapping user list to DTO list using MapperUtil generic methods and Converter + */ +public class UserMappingTest { + + private ModelMapper mapper; + private List users; + + @Before + public void init() { + + mapper = new ModelMapper(); + mapper.addMappings(new UserPropertyMap()); + users = new ArrayList(); + users.add(new User("b100", "user1", "user1@baeldung.com", "111-222", "USER")); + users.add(new User("b101", "user2", "user2@baeldung.com", "111-333", "USER")); + users.add(new User("b102", "user3", "user3@baeldung.com", "111-444", "ADMIN")); + + } + + @Test + public void testMapIntegerList() { + + List integers = new ArrayList(); + + integers.add(1); + integers.add(2); + integers.add(3); + + List characters = mapper.map(integers, new TypeToken>() { + }.getType()); + + assertThat(characters, hasItems('1','2','3')); + + } + + @Test + public void testMapGenericTypeLists() { + + // Mapping lists using generic type methods + + List userDtoList = MapperUtil.mapList(users, UserDTO.class); + + assertThat(userDtoList, Matchers.hasItem( + Matchers.both(hasProperty("userId", equalTo("b100"))) + .and(hasProperty("email", equalTo("user1@baeldung.com"))) + .and(hasProperty("userName", equalTo("user1"))))); + + // Mapping lists using PropertyMap and Converter + + UserList userList = new UserList(); + userList.setUsers(users); + UserListDTO dto = new UserListDTO(); + mapper.map(userList, dto); + + assertNotNull(dto); + assertThat(dto, Matchers.hasProperty("usernames")); + assertThat(dto.getUsernames(), hasSize(3)); + + } + +} \ No newline at end of file diff --git a/model-mapper/src/Main.java b/model-mapper/src/Main.java deleted file mode 100644 index a6deb49168..0000000000 --- a/model-mapper/src/Main.java +++ /dev/null @@ -1,58 +0,0 @@ -import com.baeldung.model.User; -import com.baeldung.model.UserDTO; -import com.baeldung.model.UserList; -import com.baeldung.util.MapperUtil; -import com.baeldung.util.UserPropertyMap; -import org.modelmapper.ModelMapper; -import org.modelmapper.TypeToken; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author sasam0320 - * @date 4/18/2020 - */ - -public class Main { - - public static void main(String[] args) { - - //Instantiate ModelMapper - - ModelMapper mapper = new ModelMapper(); - mapper.addMappings(new UserPropertyMap()); - - // Mapping lists using TypeToken generic class - - List integers = new ArrayList(); - - integers.add(1); - integers.add(2); - integers.add(3); - - List characters = mapper.map(integers, new TypeToken>() {}.getType()); - - System.out.println("Character list: " + characters); - - // Mapping lists using generic type methods - - List users = new ArrayList(); - users.add(new User("b100", "user1", "user1@baeldung.com", "111-222", "USER")); - users.add(new User("b101", "user2", "user2@baeldung.com", "111-333", "USER")); - users.add(new User("b102", "user3", "user3@baeldung.com", "111-444", "ADMIN")); - - List userDtoList = MapperUtil.mapList(users, UserDTO.class); - userDtoList.stream().map(userDto -> userDto.getEmail()).forEachOrdered(System.out::println); - - // Mapping lists using PropertyMap and Converter - - UserList userList = new UserList(); - userList.setUsers(users); - UserDTO dto = new UserDTO(); - - mapper.map(userList, dto); - dto.getUsernames().forEach(System.out::println); - - } -} diff --git a/model-mapper/src/com/baeldung/model/User.java b/model-mapper/src/com/baeldung/model/User.java deleted file mode 100644 index 73e4baafb5..0000000000 --- a/model-mapper/src/com/baeldung/model/User.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.baeldung.model; - -import java.util.List; - -/** - * @author sasam0320 - * @date 4/18/2020 - */ -public class User { - - private String userId; - private String userName; - private String email; - private String contactNumber; - private String userType; - - // Standard constructors, getters and setters - - public User(){} - - public User(String userId, String userName, String email, String contactNumber, String userType) { - this.userId = userId; - this.userName = userName; - this.email = email; - this.contactNumber = contactNumber; - this.userType = userType; - } - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getContactNumber() { - return contactNumber; - } - - public void setContactNumber(String contactNumber) { - this.contactNumber = contactNumber; - } - - public String getUserType() { - return userType; - } - - public void setUserType(String userType) { - this.userType = userType; - } - - -} diff --git a/model-mapper/src/com/baeldung/model/UserDTO.java b/model-mapper/src/com/baeldung/model/UserDTO.java deleted file mode 100644 index ed056ace8c..0000000000 --- a/model-mapper/src/com/baeldung/model/UserDTO.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.baeldung.model; - -import java.util.List; - -/** - * @author sasam0320 - * @date 4/18/2020 - */ -public class UserDTO { - - private String userId; - private String userName; - private String email; - private List usernames; - - // getters and setters - - public String getUserId() { - return userId; - } - - public void setUserId(String userId) { - this.userId = userId; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public List getUsernames() { - return usernames; - } - - public void setUsernames(List usernames) { - this.usernames = usernames; - } -} diff --git a/model-mapper/src/com/baeldung/model/UserList.java b/model-mapper/src/com/baeldung/model/UserList.java deleted file mode 100644 index b30d5507d5..0000000000 --- a/model-mapper/src/com/baeldung/model/UserList.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.model; - -import java.util.Collection; - -/** - * @author sasam0320 - * @date 4/18/2020 - */ - -public class UserList { - - private Collection users; - - public Collection getUsers() { - return users; - } - - public void setUsers(Collection users) { - this.users = users; - } -} diff --git a/model-mapper/src/com/baeldung/util/MapperUtil.java b/model-mapper/src/com/baeldung/util/MapperUtil.java deleted file mode 100644 index fe10b7777d..0000000000 --- a/model-mapper/src/com/baeldung/util/MapperUtil.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.baeldung.util; - -import org.modelmapper.ModelMapper; -import org.modelmapper.convention.MatchingStrategies; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author sasam0320 - * @date 4/18/2020 - */ -public class MapperUtil { - - - private static ModelMapper modelMapper = new ModelMapper(); - - - static { - - modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); - - } - - private MapperUtil() { - - - } - - public static T mapTo(final S source, final Class target) { - - return modelMapper.map(source, target); - } - - public static List mapList(final List sourceList, final Class target) { - - List targetList = new ArrayList(); - - for (S source : sourceList) { - - targetList.add(modelMapper.map(source, target)); - } - - return targetList; - } - -} From 4bc8c329fc8e8c247f296a1a68b2f436737ed3b1 Mon Sep 17 00:00:00 2001 From: Sasa M Date: Tue, 21 Apr 2020 21:29:38 +0200 Subject: [PATCH 395/503] Renaming test methods and formatting --- .../baeldung/modelmapper/UserPropertyMap.java | 3 +- .../baeldung/modelmapper/UserMappingTest.java | 85 ------------------- 2 files changed, 1 insertion(+), 87 deletions(-) delete mode 100644 java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UserMappingTest.java diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java index 9fa945ce32..3d9059c520 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java @@ -7,10 +7,9 @@ import java.util.ArrayList; import java.util.List; /** - * @author sasam0320 - * @description * UserPropertyMap class instantiates the converter to map the data from the user list to the user name list. * In the configuration method, we call a converter to do the mapping. + * @author sasam0320 */ public class UserPropertyMap extends PropertyMap { diff --git a/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UserMappingTest.java b/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UserMappingTest.java deleted file mode 100644 index 44a929621b..0000000000 --- a/java-collections-conversions-2/src/test/java/com/baeldung/modelmapper/UserMappingTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.baeldung.modelmapper; - -import org.hamcrest.Matchers; -import org.junit.Before; -import org.junit.Test; -import org.modelmapper.ModelMapper; -import org.modelmapper.TypeToken; - -import java.util.ArrayList; -import java.util.List; - -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.hasItems; -import static org.hamcrest.Matchers.hasProperty; -import static org.hamcrest.collection.IsCollectionWithSize.hasSize; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; - - -/** - * @sasam0320 - * @description - * This class has test methods of mapping Integer to Character list, - * mapping user list to DTO list using MapperUtil generic methods and Converter - */ -public class UserMappingTest { - - private ModelMapper mapper; - private List users; - - @Before - public void init() { - - mapper = new ModelMapper(); - mapper.addMappings(new UserPropertyMap()); - users = new ArrayList(); - users.add(new User("b100", "user1", "user1@baeldung.com", "111-222", "USER")); - users.add(new User("b101", "user2", "user2@baeldung.com", "111-333", "USER")); - users.add(new User("b102", "user3", "user3@baeldung.com", "111-444", "ADMIN")); - - } - - @Test - public void testMapIntegerList() { - - List integers = new ArrayList(); - - integers.add(1); - integers.add(2); - integers.add(3); - - List characters = mapper.map(integers, new TypeToken>() { - }.getType()); - - assertThat(characters, hasItems('1','2','3')); - - } - - @Test - public void testMapGenericTypeLists() { - - // Mapping lists using generic type methods - - List userDtoList = MapperUtil.mapList(users, UserDTO.class); - - assertThat(userDtoList, Matchers.hasItem( - Matchers.both(hasProperty("userId", equalTo("b100"))) - .and(hasProperty("email", equalTo("user1@baeldung.com"))) - .and(hasProperty("userName", equalTo("user1"))))); - - // Mapping lists using PropertyMap and Converter - - UserList userList = new UserList(); - userList.setUsers(users); - UserListDTO dto = new UserListDTO(); - mapper.map(userList, dto); - - assertNotNull(dto); - assertThat(dto, Matchers.hasProperty("usernames")); - assertThat(dto.getUsernames(), hasSize(3)); - - } - -} \ No newline at end of file From 58dc739c3efd0f03dcbae6fe9743a2f60baadab2 Mon Sep 17 00:00:00 2001 From: Sasa M Date: Tue, 21 Apr 2020 22:26:22 +0200 Subject: [PATCH 396/503] changes in build pom.xml --- .../main/java/com/baeldung/modelmapper/UserPropertyMap.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java index 3d9059c520..d2c32a307d 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java @@ -3,13 +3,15 @@ package com.baeldung.modelmapper; import org.modelmapper.AbstractConverter; import org.modelmapper.Converter; import org.modelmapper.PropertyMap; + import java.util.ArrayList; import java.util.List; /** * UserPropertyMap class instantiates the converter to map the data from the user list to the user name list. * In the configuration method, we call a converter to do the mapping. - * @author sasam0320 + * + * @author Sasa Milenkovic */ public class UserPropertyMap extends PropertyMap { From 9f0d8cf6aba2043abddb6bb2c5ef63785ffbb4d0 Mon Sep 17 00:00:00 2001 From: Sasa M Date: Sat, 25 Apr 2020 21:57:43 +0200 Subject: [PATCH 397/503] Refactoring code in com.baeldung.modelmapper package --- .../java/com/baeldung/modelmapper/UserPropertyMap.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java index d2c32a307d..0d2ebf7b4c 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java @@ -18,14 +18,15 @@ public class UserPropertyMap extends PropertyMap { Converter, List> converter = new AbstractConverter, List>() { - List usernames = new ArrayList<>(); + protected List usernames; + @Override protected List convert(List users) { - users.forEach(user -> usernames.add(user.getUserName())); + usernames = new ArrayList(); + users.forEach(user -> usernames.add(user.getUsername())); return usernames; } - }; @Override From c2e64bea7273cb971caa03e750a1683a7e7a0fd8 Mon Sep 17 00:00:00 2001 From: Sasa M Date: Sun, 26 Apr 2020 18:37:31 +0200 Subject: [PATCH 398/503] Customizing Java 8 code in modemmapper package --- .../com/baeldung/modelmapper/UserPropertyMap.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java index 0d2ebf7b4c..5b2942b158 100644 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java +++ b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java @@ -4,11 +4,11 @@ import org.modelmapper.AbstractConverter; import org.modelmapper.Converter; import org.modelmapper.PropertyMap; -import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** - * UserPropertyMap class instantiates the converter to map the data from the user list to the user name list. + * UserPropertyMap class instantiates the converter to map the data from the UserList to the UsersLisDTO. * In the configuration method, we call a converter to do the mapping. * * @author Sasa Milenkovic @@ -18,19 +18,20 @@ public class UserPropertyMap extends PropertyMap { Converter, List> converter = new AbstractConverter, List>() { - protected List usernames; @Override protected List convert(List users) { - usernames = new ArrayList(); - users.forEach(user -> usernames.add(user.getUsername())); - return usernames; + return users + .stream() + .map(User::getUsername) + .collect(Collectors.toList()); } }; @Override protected void configure() { + using(converter).map(source.getUsers(), destination.getUsernames()); } } From 9e6dd6f41bbe105e52e59139c5114ce5ae1fbf40 Mon Sep 17 00:00:00 2001 From: Sasa M Date: Wed, 29 Apr 2020 21:55:30 +0200 Subject: [PATCH 399/503] Creating TypeMap to use property mapping and converter class --- .../baeldung/modelmapper/UserPropertyMap.java | 37 ------------------- 1 file changed, 37 deletions(-) delete mode 100644 java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java diff --git a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java b/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java deleted file mode 100644 index 5b2942b158..0000000000 --- a/java-collections-conversions-2/src/main/java/com/baeldung/modelmapper/UserPropertyMap.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.baeldung.modelmapper; - -import org.modelmapper.AbstractConverter; -import org.modelmapper.Converter; -import org.modelmapper.PropertyMap; - -import java.util.List; -import java.util.stream.Collectors; - -/** - * UserPropertyMap class instantiates the converter to map the data from the UserList to the UsersLisDTO. - * In the configuration method, we call a converter to do the mapping. - * - * @author Sasa Milenkovic - */ -public class UserPropertyMap extends PropertyMap { - - - Converter, List> converter = new AbstractConverter, List>() { - - - @Override - protected List convert(List users) { - - return users - .stream() - .map(User::getUsername) - .collect(Collectors.toList()); - } - }; - - @Override - protected void configure() { - - using(converter).map(source.getUsers(), destination.getUsernames()); - } -} From b5159c71cb937b8f41ec51761953e327111c4865 Mon Sep 17 00:00:00 2001 From: mikr Date: Thu, 30 Apr 2020 16:17:05 +0200 Subject: [PATCH 400/503] Java-1470 Fix failing integration tests --- libraries-4/pom.xml | 5 +++++ libraries-5/pom.xml | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libraries-4/pom.xml b/libraries-4/pom.xml index 1b2db27861..f26e7fc055 100644 --- a/libraries-4/pom.xml +++ b/libraries-4/pom.xml @@ -88,6 +88,11 @@ javax.el-api ${javax.el.version} + + org.glassfish.web + javax.el + 2.2.4 + diff --git a/libraries-5/pom.xml b/libraries-5/pom.xml index 41c92e54c3..63296d4a89 100644 --- a/libraries-5/pom.xml +++ b/libraries-5/pom.xml @@ -43,12 +43,12 @@ com.typesafe.akka - akka-actor_2.12 + akka-actor_${scala.version} ${typesafe-akka.version} com.typesafe.akka - akka-testkit_2.12 + akka-testkit_${scala.version} ${typesafe-akka.version} test @@ -130,7 +130,8 @@ 0.9.12 4.3.8.RELEASE 3.6.2 - 2.5.26 + 2.11 + 2.5.11 0.6.5 1.7.1 3.0.14 From cd07a21b8e3bfe637016823dd5afd2e362893e1b Mon Sep 17 00:00:00 2001 From: Sasa M Date: Thu, 30 Apr 2020 16:20:39 +0200 Subject: [PATCH 401/503] Add hamcrest jar dependency in parent-java build --- java-collections-conversions-2/pom.xml | 2 +- parent-java/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/java-collections-conversions-2/pom.xml b/java-collections-conversions-2/pom.xml index 892d73cb2b..0f7cdadeb2 100644 --- a/java-collections-conversions-2/pom.xml +++ b/java-collections-conversions-2/pom.xml @@ -33,7 +33,7 @@ org.hamcrest - hamcrest-all + hamcrest ${hamcrest.version} test diff --git a/parent-java/pom.xml b/parent-java/pom.xml index 3b2b5f59de..baad9fecf4 100644 --- a/parent-java/pom.xml +++ b/parent-java/pom.xml @@ -47,7 +47,7 @@ 1.19 2.3.7 4.12 - 1.3 + 2.2 From f19c4d9b5d96aff843dc3a290d62ad5b221b89e6 Mon Sep 17 00:00:00 2001 From: mikr Date: Thu, 30 Apr 2020 18:11:37 +0200 Subject: [PATCH 402/503] Java-1520 Split or move algorithms-miscellaneous-5 module --- algorithms-miscellaneous-5/README.md | 8 +- algorithms-miscellaneous-5/pom.xml | 14 +- algorithms-miscellaneous-6/README.md | 6 + algorithms-miscellaneous-6/pom.xml | 25 +++ .../BalancedBracketsUsingDeque.java | 0 .../BalancedBracketsUsingString.java | 0 .../algorithms/caesarcipher/CaesarCipher.java | 0 .../baeldung/algorithms/greedy/Follower.java | 0 .../algorithms/greedy/FollowersPath.java | 0 .../algorithms/greedy/GreedyAlgorithm.java | 0 .../algorithms/greedy/NonGreedyAlgorithm.java | 0 .../algorithms/greedy/SocialConnector.java | 0 .../algorithms/greedy/SocialUser.java | 0 .../algorithms/kruskal/CycleDetector.java | 0 .../algorithms/kruskal/DisjointSetInfo.java | 0 .../baeldung/algorithms/kruskal/Kruskal.java | 0 .../algorithms/minheapmerge/HeapNode.java | 26 +-- .../algorithms/minheapmerge/MinHeap.java | 176 +++++++++--------- .../BalancedBracketsUsingDequeUnitTest.java | 0 .../BalancedBracketsUsingStringUnitTest.java | 0 .../caesarcipher/CaesarCipherUnitTest.java | 0 .../greedy/GreedyAlgorithmUnitTest.java | 0 .../algorithms/kruskal/KruskalUnitTest.java | 0 .../minheapmerge/MinHeapUnitTest.java | 44 ++--- 24 files changed, 160 insertions(+), 139 deletions(-) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDeque.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingString.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/caesarcipher/CaesarCipher.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/greedy/Follower.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/greedy/FollowersPath.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/greedy/GreedyAlgorithm.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/greedy/NonGreedyAlgorithm.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/greedy/SocialConnector.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/greedy/SocialUser.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/kruskal/CycleDetector.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/kruskal/DisjointSetInfo.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/minheapmerge/HeapNode.java (95%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java (96%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDequeUnitTest.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingStringUnitTest.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/test/java/com/baeldung/algorithms/caesarcipher/CaesarCipherUnitTest.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/test/java/com/baeldung/algorithms/greedy/GreedyAlgorithmUnitTest.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java (100%) rename {algorithms-miscellaneous-5 => algorithms-miscellaneous-6}/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapUnitTest.java (96%) diff --git a/algorithms-miscellaneous-5/README.md b/algorithms-miscellaneous-5/README.md index 6e0de7d64e..3e6eeb4c93 100644 --- a/algorithms-miscellaneous-5/README.md +++ b/algorithms-miscellaneous-5/README.md @@ -15,9 +15,5 @@ This module contains articles about algorithms. Some classes of algorithms, e.g. - [Maximum Subarray Problem](https://www.baeldung.com/java-maximum-subarray) - [How to Merge Two Sorted Arrays](https://www.baeldung.com/java-merge-sorted-arrays) - [Median of Stream of Integers using Heap](https://www.baeldung.com/java-stream-integers-median-using-heap) -- [Kruskal’s Algorithm for Spanning Trees](https://www.baeldung.com/java-spanning-trees-kruskal) -- [Balanced Brackets Algorithm in Java](https://www.baeldung.com/java-balanced-brackets-algorithm) -- [Efficiently Merge Sorted Java Sequences](https://www.baeldung.com/java-merge-sorted-sequences) -- [Introduction to Greedy Algorithms with Java](https://www.baeldung.com/java-greedy-algorithms) -- [The Caesar Cipher in Java](https://www.baeldung.com/java-caesar-cipher) -- More articles: [[<-- prev]](/../algorithms-miscellaneous-4) +- More articles: [[<-- prev]](/../algorithms-miscellaneous-4) [[next -->]](/../algorithms-miscellaneous-6) + diff --git a/algorithms-miscellaneous-5/pom.xml b/algorithms-miscellaneous-5/pom.xml index 4131e1791d..9d0326241a 100644 --- a/algorithms-miscellaneous-5/pom.xml +++ b/algorithms-miscellaneous-5/pom.xml @@ -21,16 +21,10 @@ ${commons-codec.version} - org.apache.commons - commons-math3 - ${commons-math3.version} - - - org.projectlombok - lombok - ${lombok.version} - provided - + org.apache.commons + commons-math3 + ${commons-math3.version} + pl.allegro.finance tradukisto diff --git a/algorithms-miscellaneous-6/README.md b/algorithms-miscellaneous-6/README.md index 99be63d7ca..22ee51530f 100644 --- a/algorithms-miscellaneous-6/README.md +++ b/algorithms-miscellaneous-6/README.md @@ -2,3 +2,9 @@ - [Boruvka’s Algorithm for Minimum Spanning Trees](https://www.baeldung.com/java-boruvka-algorithm) - [Gradient Descent in Java](https://www.baeldung.com/java-gradient-descent) +- [Kruskal’s Algorithm for Spanning Trees](https://www.baeldung.com/java-spanning-trees-kruskal) +- [Balanced Brackets Algorithm in Java](https://www.baeldung.com/java-balanced-brackets-algorithm) +- [Efficiently Merge Sorted Java Sequences](https://www.baeldung.com/java-merge-sorted-sequences) +- [Introduction to Greedy Algorithms with Java](https://www.baeldung.com/java-greedy-algorithms) +- [The Caesar Cipher in Java](https://www.baeldung.com/java-caesar-cipher) +- More articles: [[<-- prev]](/../algorithms-miscellaneous-5) diff --git a/algorithms-miscellaneous-6/pom.xml b/algorithms-miscellaneous-6/pom.xml index fda9cf10f9..0a0edcbb3f 100644 --- a/algorithms-miscellaneous-6/pom.xml +++ b/algorithms-miscellaneous-6/pom.xml @@ -18,10 +18,35 @@ guava ${guava.version} + + org.junit.platform + junit-platform-commons + ${junit.platform.version} + + + org.assertj + assertj-core + ${org.assertj.core.version} + test + + + org.projectlombok + lombok + ${lombok.version} + provided + + + org.apache.commons + commons-math3 + ${commons-math3.version} + 28.1-jre + 3.9.0 + 1.6.0 + 3.6.1 diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDeque.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDeque.java similarity index 100% rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDeque.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDeque.java diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingString.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingString.java similarity index 100% rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingString.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingString.java diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/caesarcipher/CaesarCipher.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/caesarcipher/CaesarCipher.java similarity index 100% rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/caesarcipher/CaesarCipher.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/caesarcipher/CaesarCipher.java diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/Follower.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/Follower.java similarity index 100% rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/Follower.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/Follower.java diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/FollowersPath.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/FollowersPath.java similarity index 100% rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/FollowersPath.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/FollowersPath.java diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/GreedyAlgorithm.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/GreedyAlgorithm.java similarity index 100% rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/GreedyAlgorithm.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/GreedyAlgorithm.java diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/NonGreedyAlgorithm.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/NonGreedyAlgorithm.java similarity index 100% rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/NonGreedyAlgorithm.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/NonGreedyAlgorithm.java diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/SocialConnector.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/SocialConnector.java similarity index 100% rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/SocialConnector.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/SocialConnector.java diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/SocialUser.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/SocialUser.java similarity index 100% rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/greedy/SocialUser.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/greedy/SocialUser.java diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/CycleDetector.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/kruskal/CycleDetector.java similarity index 100% rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/CycleDetector.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/kruskal/CycleDetector.java diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/DisjointSetInfo.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/kruskal/DisjointSetInfo.java similarity index 100% rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/DisjointSetInfo.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/kruskal/DisjointSetInfo.java diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java similarity index 100% rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/HeapNode.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/minheapmerge/HeapNode.java similarity index 95% rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/HeapNode.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/minheapmerge/HeapNode.java index 9e8439cb87..e2e41baf4d 100644 --- a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/HeapNode.java +++ b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/minheapmerge/HeapNode.java @@ -1,13 +1,13 @@ -package com.baeldung.algorithms.minheapmerge; - -public class HeapNode { - - int element; - int arrayIndex; - int nextElementIndex = 1; - - public HeapNode(int element, int arrayIndex) { - this.element = element; - this.arrayIndex = arrayIndex; - } -} +package com.baeldung.algorithms.minheapmerge; + +public class HeapNode { + + int element; + int arrayIndex; + int nextElementIndex = 1; + + public HeapNode(int element, int arrayIndex) { + this.element = element; + this.arrayIndex = arrayIndex; + } +} diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java similarity index 96% rename from algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java index b77ce43160..0217480e9e 100644 --- a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java +++ b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/minheapmerge/MinHeap.java @@ -1,88 +1,88 @@ -package com.baeldung.algorithms.minheapmerge; - -public class MinHeap { - - HeapNode[] heapNodes; - - public MinHeap(HeapNode heapNodes[]) { - this.heapNodes = heapNodes; - heapifyFromLastLeafsParent(); - } - - void heapifyFromLastLeafsParent() { - int lastLeafsParentIndex = getParentNodeIndex(heapNodes.length); - while (lastLeafsParentIndex >= 0) { - heapify(lastLeafsParentIndex); - lastLeafsParentIndex--; - } - } - - void heapify(int index) { - int leftNodeIndex = getLeftNodeIndex(index); - int rightNodeIndex = getRightNodeIndex(index); - int smallestElementIndex = index; - if (leftNodeIndex < heapNodes.length && heapNodes[leftNodeIndex].element < heapNodes[index].element) { - smallestElementIndex = leftNodeIndex; - } - if (rightNodeIndex < heapNodes.length && heapNodes[rightNodeIndex].element < heapNodes[smallestElementIndex].element) { - smallestElementIndex = rightNodeIndex; - } - if (smallestElementIndex != index) { - swap(index, smallestElementIndex); - heapify(smallestElementIndex); - } - } - - int getParentNodeIndex(int index) { - return (index - 1) / 2; - } - - int getLeftNodeIndex(int index) { - return (2 * index + 1); - } - - int getRightNodeIndex(int index) { - return (2 * index + 2); - } - - HeapNode getRootNode() { - return heapNodes[0]; - } - - void heapifyFromRoot() { - heapify(0); - } - - void swap(int i, int j) { - HeapNode temp = heapNodes[i]; - heapNodes[i] = heapNodes[j]; - heapNodes[j] = temp; - } - - static int[] merge(int[][] array) { - HeapNode[] heapNodes = new HeapNode[array.length]; - int resultingArraySize = 0; - - for (int i = 0; i < array.length; i++) { - HeapNode node = new HeapNode(array[i][0], i); - heapNodes[i] = node; - resultingArraySize += array[i].length; - } - - MinHeap minHeap = new MinHeap(heapNodes); - int[] resultingArray = new int[resultingArraySize]; - - for (int i = 0; i < resultingArraySize; i++) { - HeapNode root = minHeap.getRootNode(); - resultingArray[i] = root.element; - - if (root.nextElementIndex < array[root.arrayIndex].length) { - root.element = array[root.arrayIndex][root.nextElementIndex++]; - } else { - root.element = Integer.MAX_VALUE; - } - minHeap.heapifyFromRoot(); - } - return resultingArray; - } -} +package com.baeldung.algorithms.minheapmerge; + +public class MinHeap { + + HeapNode[] heapNodes; + + public MinHeap(HeapNode heapNodes[]) { + this.heapNodes = heapNodes; + heapifyFromLastLeafsParent(); + } + + void heapifyFromLastLeafsParent() { + int lastLeafsParentIndex = getParentNodeIndex(heapNodes.length); + while (lastLeafsParentIndex >= 0) { + heapify(lastLeafsParentIndex); + lastLeafsParentIndex--; + } + } + + void heapify(int index) { + int leftNodeIndex = getLeftNodeIndex(index); + int rightNodeIndex = getRightNodeIndex(index); + int smallestElementIndex = index; + if (leftNodeIndex < heapNodes.length && heapNodes[leftNodeIndex].element < heapNodes[index].element) { + smallestElementIndex = leftNodeIndex; + } + if (rightNodeIndex < heapNodes.length && heapNodes[rightNodeIndex].element < heapNodes[smallestElementIndex].element) { + smallestElementIndex = rightNodeIndex; + } + if (smallestElementIndex != index) { + swap(index, smallestElementIndex); + heapify(smallestElementIndex); + } + } + + int getParentNodeIndex(int index) { + return (index - 1) / 2; + } + + int getLeftNodeIndex(int index) { + return (2 * index + 1); + } + + int getRightNodeIndex(int index) { + return (2 * index + 2); + } + + HeapNode getRootNode() { + return heapNodes[0]; + } + + void heapifyFromRoot() { + heapify(0); + } + + void swap(int i, int j) { + HeapNode temp = heapNodes[i]; + heapNodes[i] = heapNodes[j]; + heapNodes[j] = temp; + } + + static int[] merge(int[][] array) { + HeapNode[] heapNodes = new HeapNode[array.length]; + int resultingArraySize = 0; + + for (int i = 0; i < array.length; i++) { + HeapNode node = new HeapNode(array[i][0], i); + heapNodes[i] = node; + resultingArraySize += array[i].length; + } + + MinHeap minHeap = new MinHeap(heapNodes); + int[] resultingArray = new int[resultingArraySize]; + + for (int i = 0; i < resultingArraySize; i++) { + HeapNode root = minHeap.getRootNode(); + resultingArray[i] = root.element; + + if (root.nextElementIndex < array[root.arrayIndex].length) { + root.element = array[root.arrayIndex][root.nextElementIndex++]; + } else { + root.element = Integer.MAX_VALUE; + } + minHeap.heapifyFromRoot(); + } + return resultingArray; + } +} diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDequeUnitTest.java b/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDequeUnitTest.java similarity index 100% rename from algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDequeUnitTest.java rename to algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingDequeUnitTest.java diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingStringUnitTest.java b/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingStringUnitTest.java similarity index 100% rename from algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingStringUnitTest.java rename to algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/balancedbrackets/BalancedBracketsUsingStringUnitTest.java diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/caesarcipher/CaesarCipherUnitTest.java b/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/caesarcipher/CaesarCipherUnitTest.java similarity index 100% rename from algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/caesarcipher/CaesarCipherUnitTest.java rename to algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/caesarcipher/CaesarCipherUnitTest.java diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/greedy/GreedyAlgorithmUnitTest.java b/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/greedy/GreedyAlgorithmUnitTest.java similarity index 100% rename from algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/greedy/GreedyAlgorithmUnitTest.java rename to algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/greedy/GreedyAlgorithmUnitTest.java diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java b/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java similarity index 100% rename from algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java rename to algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapUnitTest.java b/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapUnitTest.java similarity index 96% rename from algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapUnitTest.java rename to algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapUnitTest.java index 80d0d20f05..f84c860dcc 100644 --- a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapUnitTest.java +++ b/algorithms-miscellaneous-6/src/test/java/com/baeldung/algorithms/minheapmerge/MinHeapUnitTest.java @@ -1,22 +1,22 @@ -package com.baeldung.algorithms.minheapmerge; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import org.junit.Test; - -public class MinHeapUnitTest { - - private final int[][] inputArray = { { 0, 6 }, { 1, 5, 10, 100 }, { 2, 4, 200, 650 } }; - private final int[] expectedArray = { 0, 1, 2, 4, 5, 6, 10, 100, 200, 650 }; - - @Test - public void givenSortedArrays_whenMerged_thenShouldReturnASingleSortedarray() { - int[] resultArray = MinHeap.merge(inputArray); - - assertThat(resultArray.length, is(equalTo(10))); - assertThat(resultArray, is(equalTo(expectedArray))); - } - -} +package com.baeldung.algorithms.minheapmerge; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import org.junit.Test; + +public class MinHeapUnitTest { + + private final int[][] inputArray = { { 0, 6 }, { 1, 5, 10, 100 }, { 2, 4, 200, 650 } }; + private final int[] expectedArray = { 0, 1, 2, 4, 5, 6, 10, 100, 200, 650 }; + + @Test + public void givenSortedArrays_whenMerged_thenShouldReturnASingleSortedarray() { + int[] resultArray = MinHeap.merge(inputArray); + + assertThat(resultArray.length, is(equalTo(10))); + assertThat(resultArray, is(equalTo(expectedArray))); + } + +} From 23bc2db643ff723e4c2d899c7dd0d1c008dc3454 Mon Sep 17 00:00:00 2001 From: sergio41 Date: Thu, 30 Apr 2020 18:44:05 +0200 Subject: [PATCH 403/503] [BAEL-3944] Minor changes on examples and identations --- .../PhoneNumbersRegexUnitTest.java | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/phonenumbers/PhoneNumbersRegexUnitTest.java b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/phonenumbers/PhoneNumbersRegexUnitTest.java index f7a9d70850..ec0380c450 100644 --- a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/phonenumbers/PhoneNumbersRegexUnitTest.java +++ b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/phonenumbers/PhoneNumbersRegexUnitTest.java @@ -15,37 +15,38 @@ public class PhoneNumbersRegexUnitTest { Matcher matcher = pattern.matcher("2055550125"); assertTrue(matcher.matches()); } - + @Test - public void whenMatchesTenDigitsNumberWhitespacesHyphen_thenCorrect() { - Pattern pattern = Pattern.compile("^(\\d{3}[- ]?){2}\\d{4}$"); + public void whenMatchesTenDigitsNumberWhitespacesDotHyphen_thenCorrect() { + Pattern pattern = Pattern.compile("^(\\d{3}[- .]?){2}\\d{4}$"); Matcher matcher = pattern.matcher("202 555 0125"); assertTrue(matcher.matches()); } - + @Test public void whenMatchesTenDigitsNumberParenthesis_thenCorrect() { - Pattern pattern = Pattern.compile("^\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$"); - Matcher matcher = pattern.matcher("(202)-555-0125"); + Pattern pattern = Pattern.compile("^((\\(\\d{3}\\))|\\d{3})[- .]?\\d{3}[- .]?\\d{4}$"); + Matcher matcher = pattern.matcher("(202) 555-0125"); assertTrue(matcher.matches()); } - + @Test public void whenMatchesTenDigitsNumberPrefix_thenCorrect() { - Pattern pattern = Pattern.compile("^(\\+\\d{1,3}( )?)?\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$"); - Matcher matcher = pattern.matcher("+111 (202)-555-0125"); + Pattern pattern = Pattern.compile("^(\\+\\d{1,3}( )?)?((\\(\\d{3}\\))|\\d{3})[- .]?\\d{3}[- .]?\\d{4}$"); + Matcher matcher = pattern.matcher("+111 (202) 555-0125"); assertTrue(matcher.matches()); } - + @Test public void whenMatchesPhoneNumber_thenCorrect() { - String patterns = "^(\\+\\d{1,3}( )?)?\\(?\\d{3}\\)?[- ]?\\d{3}[- ]?\\d{4}$" + - "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?){2}\\d{3}$" + - "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?)(\\d{2}[ ]?){2}\\d{2}$"; - - String[] validPhoneNumbers = {"2055550125","202 555 0125", "(202)-555-0125", "+111 (202)-555-0125", - "636 856 789", "+111 636 856 789", "636 85 67 89", "+111 636 85 67 89"}; - + String patterns + = "^(\\+\\d{1,3}( )?)?((\\(\\d{3}\\))|\\d{3})[- .]?\\d{3}[- .]?\\d{4}$" + + "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?){2}\\d{3}$" + + "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?)(\\d{2}[ ]?){2}\\d{2}$"; + + String[] validPhoneNumbers + = {"2055550125","202 555 0125", "(202) 555-0125", "+111 (202) 555-0125", "636 856 789", "+111 636 856 789", "636 85 67 89", "+111 636 85 67 89"}; + Pattern pattern = Pattern.compile(patterns); for(String phoneNumber : validPhoneNumbers) { Matcher matcher = pattern.matcher(phoneNumber); From 5a73101deb657414252d3ddfa91cab365504c90d Mon Sep 17 00:00:00 2001 From: sergio41 Date: Thu, 30 Apr 2020 19:09:11 +0200 Subject: [PATCH 404/503] [BAEL-3944] Identation --- .../baeldung/regex/phonenumbers/PhoneNumbersRegexUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/phonenumbers/PhoneNumbersRegexUnitTest.java b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/phonenumbers/PhoneNumbersRegexUnitTest.java index ec0380c450..afabf47baa 100644 --- a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/phonenumbers/PhoneNumbersRegexUnitTest.java +++ b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/phonenumbers/PhoneNumbersRegexUnitTest.java @@ -45,7 +45,7 @@ public class PhoneNumbersRegexUnitTest { + "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?)(\\d{2}[ ]?){2}\\d{2}$"; String[] validPhoneNumbers - = {"2055550125","202 555 0125", "(202) 555-0125", "+111 (202) 555-0125", "636 856 789", "+111 636 856 789", "636 85 67 89", "+111 636 85 67 89"}; + = {"2055550125","202 555 0125", "(202) 555-0125", "+111 (202) 555-0125", "636 856 789", "+111 636 856 789", "636 85 67 89", "+111 636 85 67 89"}; Pattern pattern = Pattern.compile(patterns); for(String phoneNumber : validPhoneNumbers) { From 100c78e15b33a44a3c4733bcf3e80fc733ba6f9e Mon Sep 17 00:00:00 2001 From: mikr Date: Fri, 1 May 2020 16:34:19 +0200 Subject: [PATCH 405/503] Java-1520 Fix whitespaces in algorithms-miscellaneous-5 pom --- algorithms-miscellaneous-5/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/algorithms-miscellaneous-5/pom.xml b/algorithms-miscellaneous-5/pom.xml index 9d0326241a..615cf03467 100644 --- a/algorithms-miscellaneous-5/pom.xml +++ b/algorithms-miscellaneous-5/pom.xml @@ -21,10 +21,10 @@ ${commons-codec.version} - org.apache.commons - commons-math3 - ${commons-math3.version} - + org.apache.commons + commons-math3 + ${commons-math3.version} + pl.allegro.finance tradukisto From 5bfa01ec05e0d3d9364a042c307425f370877691 Mon Sep 17 00:00:00 2001 From: Arindum Roy Date: Sat, 2 May 2020 00:20:16 +0530 Subject: [PATCH 406/503] "spring-data-jpa-5 new module" --- .../baeldung/composite/BookApplication.java | 12 ---- .../com/baeldung/composite/entity/Book.java | 47 -------------- .../com/baeldung/composite/entity/BookId.java | 51 --------------- .../composite/repository/BookRepository.java | 16 ----- .../BookRepositoryIntegrationTest.java | 63 ------------------- 5 files changed, 189 deletions(-) delete mode 100644 persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/BookApplication.java delete mode 100644 persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/entity/Book.java delete mode 100644 persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/entity/BookId.java delete mode 100644 persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/repository/BookRepository.java delete mode 100644 persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/composite/repository/BookRepositoryIntegrationTest.java diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/BookApplication.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/BookApplication.java deleted file mode 100644 index 52f06058aa..0000000000 --- a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/BookApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.baeldung.composite; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class BookApplication { - - public static void main(String[] args) { - SpringApplication.run(BookApplication.class); - } -} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/entity/Book.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/entity/Book.java deleted file mode 100644 index e4f1727654..0000000000 --- a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/entity/Book.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.baeldung.composite.entity; - -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; - -@Entity -public class Book { - - @EmbeddedId - private BookId id; - private String genre; - private Integer price; - - public Book() { - } - - public Book(String author, String name, String genre, Integer price) { - BookId id = new BookId(author, name); - this.id = id; - this.genre = genre; - this.price = price; - } - - public BookId getId() { - return id; - } - - public void setId(BookId id) { - this.id = id; - } - - public String getGenre() { - return genre; - } - - public void setGenre(String genre) { - this.genre = genre; - } - - public Integer getPrice() { - return price; - } - - public void setPrice(Integer price) { - this.price = price; - } -} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/entity/BookId.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/entity/BookId.java deleted file mode 100644 index 1524452412..0000000000 --- a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/entity/BookId.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.baeldung.composite.entity; - -import javax.persistence.Embeddable; -import java.io.Serializable; -import java.util.Objects; - -@Embeddable -public class BookId implements Serializable { - - private String author; - private String name; - - public BookId() { - } - - public BookId(String author, String name) { - this.author = author; - this.name = name; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - BookId bookId = (BookId) o; - return Objects.equals(author, bookId.author) && Objects.equals(name, bookId.name); - } - - @Override - public int hashCode() { - return Objects.hash(author, name); - } -} diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/repository/BookRepository.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/repository/BookRepository.java deleted file mode 100644 index 3c09f909f0..0000000000 --- a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/composite/repository/BookRepository.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.composite.repository; - -import com.baeldung.composite.entity.Book; -import com.baeldung.composite.entity.BookId; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -public interface BookRepository extends JpaRepository { - - List findByIdName(String name); - - List findByIdAuthor(String author); -} diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/composite/repository/BookRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/composite/repository/BookRepositoryIntegrationTest.java deleted file mode 100644 index 362950bea9..0000000000 --- a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/composite/repository/BookRepositoryIntegrationTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.baeldung.composite.repository; - -import com.baeldung.composite.BookApplication; -import com.baeldung.composite.entity.Book; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -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.util.Arrays; -import java.util.List; - -import static org.junit.Assert.assertEquals; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = BookApplication.class) -public class BookRepositoryIntegrationTest { - - public static final String JAVA_101 = "Java101"; - public static final String JANE = "Jane"; - @Autowired - BookRepository repository; - - @Before - public void setUp() { - Book book1 = new Book("John", JAVA_101, "Tech", 20); - Book book2 = new Book(JANE, JAVA_101, "Arch", 25); - Book book3 = new Book(JANE, "Scala101", "Tech", 23); - - repository.saveAll(Arrays.asList(book1, book2, book3)); - } - - @After - public void tearDown() { - repository.deleteAll(); - } - - @Test - public void testFindByName() { - List books = repository.findByIdName(JAVA_101); - - assertEquals(2, books.size()); - } - - @Test - public void testFindByAuthor() { - List books = repository.findByIdAuthor(JANE); - - assertEquals(2, books.size()); - } - - @Test - public void testFindByGenre() { - List books = repository.findByIdAuthor(JANE); - - assertEquals(2, books.size()); - } -} \ No newline at end of file From 8ef7cc6b81e62d42ca8afa533610cec0cf489337 Mon Sep 17 00:00:00 2001 From: Arindum Roy Date: Sat, 2 May 2020 00:23:59 +0530 Subject: [PATCH 407/503] all files --- .../spring-data-jpa-5/README.md | 11 ++++ persistence-modules/spring-data-jpa-5/pom.xml | 47 ++++++++++++++ .../baeldung/composite/BookApplication.java | 12 ++++ .../com/baeldung/composite/entity/Book.java | 47 ++++++++++++++ .../com/baeldung/composite/entity/BookId.java | 51 +++++++++++++++ .../composite/repository/BookRepository.java | 18 ++++++ .../src/main/resources/application.properties | 2 + .../BookRepositoryIntegrationTest.java | 64 +++++++++++++++++++ .../resources/application-test.properties | 2 + 9 files changed, 254 insertions(+) create mode 100644 persistence-modules/spring-data-jpa-5/README.md create mode 100644 persistence-modules/spring-data-jpa-5/pom.xml create mode 100644 persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/BookApplication.java create mode 100644 persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/entity/Book.java create mode 100644 persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/entity/BookId.java create mode 100644 persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/repository/BookRepository.java create mode 100644 persistence-modules/spring-data-jpa-5/src/main/resources/application.properties create mode 100644 persistence-modules/spring-data-jpa-5/src/test/java/com/baeldung/composite/repository/BookRepositoryIntegrationTest.java create mode 100644 persistence-modules/spring-data-jpa-5/src/test/resources/application-test.properties diff --git a/persistence-modules/spring-data-jpa-5/README.md b/persistence-modules/spring-data-jpa-5/README.md new file mode 100644 index 0000000000..51c39f7bb0 --- /dev/null +++ b/persistence-modules/spring-data-jpa-5/README.md @@ -0,0 +1,11 @@ +### Relevant Articles: +- [Derived Query Methods in Spring Data JPA Repositories](TBD) + +### Eclipse Config +After importing the project into Eclipse, you may see the following error: +"No persistence xml file found in project" + +This can be ignored: +- Project -> Properties -> Java Persistance -> JPA -> Error/Warnings -> Select Ignore on "No persistence xml file found in project" +Or: +- Eclipse -> Preferences - Validation - disable the "Build" execution of the JPA Validator diff --git a/persistence-modules/spring-data-jpa-5/pom.xml b/persistence-modules/spring-data-jpa-5/pom.xml new file mode 100644 index 0000000000..c71cec1d08 --- /dev/null +++ b/persistence-modules/spring-data-jpa-5/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + spring-data-jpa-5 + spring-data-jpa-5 + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + org.springframework.boot + spring-boot-starter-data-jdbc + + + + mysql + mysql-connector-java + + + + org.postgresql + postgresql + + + + com.h2database + h2 + + + + \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/BookApplication.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/BookApplication.java new file mode 100644 index 0000000000..52f06058aa --- /dev/null +++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/BookApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.composite; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class BookApplication { + + public static void main(String[] args) { + SpringApplication.run(BookApplication.class); + } +} diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/entity/Book.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/entity/Book.java new file mode 100644 index 0000000000..e4f1727654 --- /dev/null +++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/entity/Book.java @@ -0,0 +1,47 @@ +package com.baeldung.composite.entity; + +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; + +@Entity +public class Book { + + @EmbeddedId + private BookId id; + private String genre; + private Integer price; + + public Book() { + } + + public Book(String author, String name, String genre, Integer price) { + BookId id = new BookId(author, name); + this.id = id; + this.genre = genre; + this.price = price; + } + + public BookId getId() { + return id; + } + + public void setId(BookId id) { + this.id = id; + } + + public String getGenre() { + return genre; + } + + public void setGenre(String genre) { + this.genre = genre; + } + + public Integer getPrice() { + return price; + } + + public void setPrice(Integer price) { + this.price = price; + } +} diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/entity/BookId.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/entity/BookId.java new file mode 100644 index 0000000000..1524452412 --- /dev/null +++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/entity/BookId.java @@ -0,0 +1,51 @@ +package com.baeldung.composite.entity; + +import javax.persistence.Embeddable; +import java.io.Serializable; +import java.util.Objects; + +@Embeddable +public class BookId implements Serializable { + + private String author; + private String name; + + public BookId() { + } + + public BookId(String author, String name) { + this.author = author; + this.name = name; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + BookId bookId = (BookId) o; + return Objects.equals(author, bookId.author) && Objects.equals(name, bookId.name); + } + + @Override + public int hashCode() { + return Objects.hash(author, name); + } +} diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/repository/BookRepository.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/repository/BookRepository.java new file mode 100644 index 0000000000..d5993eaf79 --- /dev/null +++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/composite/repository/BookRepository.java @@ -0,0 +1,18 @@ +package com.baeldung.composite.repository; + +import com.baeldung.composite.entity.Book; +import com.baeldung.composite.entity.BookId; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface BookRepository extends JpaRepository { + + List findByIdName(String name); + + List findByIdAuthor(String author); + + List findByGenre(String genre); +} diff --git a/persistence-modules/spring-data-jpa-5/src/main/resources/application.properties b/persistence-modules/spring-data-jpa-5/src/main/resources/application.properties new file mode 100644 index 0000000000..dfc5e56e33 --- /dev/null +++ b/persistence-modules/spring-data-jpa-5/src/main/resources/application.properties @@ -0,0 +1,2 @@ +spring.jpa.show-sql=true + diff --git a/persistence-modules/spring-data-jpa-5/src/test/java/com/baeldung/composite/repository/BookRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-5/src/test/java/com/baeldung/composite/repository/BookRepositoryIntegrationTest.java new file mode 100644 index 0000000000..9d25acbd96 --- /dev/null +++ b/persistence-modules/spring-data-jpa-5/src/test/java/com/baeldung/composite/repository/BookRepositoryIntegrationTest.java @@ -0,0 +1,64 @@ +package com.baeldung.composite.repository; + +import com.baeldung.composite.BookApplication; +import com.baeldung.composite.entity.Book; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +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.util.Arrays; +import java.util.List; + +import static org.junit.Assert.assertEquals; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = BookApplication.class) +public class BookRepositoryIntegrationTest { + + public static final String JAVA_101 = "Java101"; + public static final String JANE = "Jane"; + public static final String TECH = "Tech"; + @Autowired + BookRepository repository; + + @Before + public void setUp() { + Book book1 = new Book("John", JAVA_101, TECH, 20); + Book book2 = new Book(JANE, JAVA_101, "Arch", 25); + Book book3 = new Book(JANE, "Scala101", TECH, 23); + + repository.saveAll(Arrays.asList(book1, book2, book3)); + } + + @After + public void tearDown() { + repository.deleteAll(); + } + + @Test + public void testFindByName() { + List books = repository.findByIdName(JAVA_101); + + assertEquals(2, books.size()); + } + + @Test + public void testFindByAuthor() { + List books = repository.findByIdAuthor(JANE); + + assertEquals(2, books.size()); + } + + @Test + public void testFindByGenre() { + List books = repository.findByGenre(TECH); + + assertEquals(2, books.size()); + } +} \ No newline at end of file diff --git a/persistence-modules/spring-data-jpa-5/src/test/resources/application-test.properties b/persistence-modules/spring-data-jpa-5/src/test/resources/application-test.properties new file mode 100644 index 0000000000..f9497c8f37 --- /dev/null +++ b/persistence-modules/spring-data-jpa-5/src/test/resources/application-test.properties @@ -0,0 +1,2 @@ +spring.jpa.hibernate.ddl-auto=update +spring.datasource.url=jdbc:h2:mem:jpa3 \ No newline at end of file From ed27094b5b53b122cbd392f43743333479fd45d8 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Fri, 1 May 2020 20:56:43 +0200 Subject: [PATCH 408/503] [JAVA-621] Got last compilation error --- .../com/baeldung/hashcode/application/ApplicationUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java index 49857f355a..18b2d4d570 100644 --- a/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java +++ b/core-java-modules/core-java-lang-oop-methods/src/test/java/com/baeldung/hashcode/application/ApplicationUnitTest.java @@ -1,6 +1,6 @@ package com.baeldung.hashcode.application; -import com.baeldung.hashcode.entities.User; +import com.baeldung.hashcode.standard.User; import org.junit.Test; import java.util.HashMap; From 5724e188a07a73612802981271b5f367fbc858be Mon Sep 17 00:00:00 2001 From: Arindum Roy Date: Sat, 2 May 2020 00:28:53 +0530 Subject: [PATCH 409/503] "updated README.md" --- persistence-modules/spring-data-jpa-5/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/spring-data-jpa-5/README.md b/persistence-modules/spring-data-jpa-5/README.md index 51c39f7bb0..dd4ac22e4a 100644 --- a/persistence-modules/spring-data-jpa-5/README.md +++ b/persistence-modules/spring-data-jpa-5/README.md @@ -1,5 +1,5 @@ ### Relevant Articles: -- [Derived Query Methods in Spring Data JPA Repositories](TBD) +- [Spring JPA @Embedded and @EmbeddedId](TBD) ### Eclipse Config After importing the project into Eclipse, you may see the following error: From 52df2121273352051f1e620c57a78cf7f1905224 Mon Sep 17 00:00:00 2001 From: mikr Date: Fri, 1 May 2020 21:34:10 +0200 Subject: [PATCH 410/503] Java-1470 Move libraries-4/5/6 to different profile --- pom.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index ed4b3e5b30..171c652994 100644 --- a/pom.xml +++ b/pom.xml @@ -497,9 +497,6 @@ libraries-2 libraries-3 - libraries-4 - libraries-5 - libraries-6 libraries-apache-commons libraries-apache-commons-collections libraries-apache-commons-io @@ -814,6 +811,9 @@ jws libraries + libraries-4 + libraries-5 + libraries-6 vaadin vavr @@ -1014,9 +1014,6 @@ libraries-2 libraries-3 - libraries-4 - libraries-5 - libraries-6 libraries-apache-commons libraries-apache-commons-collections @@ -1317,6 +1314,9 @@ jws libraries + libraries-4 + libraries-5 + libraries-6 vaadin vavr From 9797d3a4fcce87047d2402efc1585ece9cf1147c Mon Sep 17 00:00:00 2001 From: Aaron Juarez Date: Fri, 1 May 2020 15:35:29 -0400 Subject: [PATCH 411/503] Bael-3966: code fixes after editor review (#9203) --- .../core-java-lang-operators/pom.xml | 6 +++++ .../com/baeldung/objectclass/Borrower.java | 0 .../java/com/baeldung/objectclass/Lender.java | 0 .../java/com/baeldung/objectclass/User.java | 0 .../objectclass/CreditAppUnitTest.java | 23 +++++++++++++++---- 5 files changed, 25 insertions(+), 4 deletions(-) rename core-java-modules/{core-java => core-java-lang-operators}/src/main/java/com/baeldung/objectclass/Borrower.java (100%) rename core-java-modules/{core-java => core-java-lang-operators}/src/main/java/com/baeldung/objectclass/Lender.java (100%) rename core-java-modules/{core-java => core-java-lang-operators}/src/main/java/com/baeldung/objectclass/User.java (100%) rename core-java-modules/{core-java => core-java-lang-operators}/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java (74%) diff --git a/core-java-modules/core-java-lang-operators/pom.xml b/core-java-modules/core-java-lang-operators/pom.xml index b95caa81b8..09fbce4b3c 100644 --- a/core-java-modules/core-java-lang-operators/pom.xml +++ b/core-java-modules/core-java-lang-operators/pom.xml @@ -17,6 +17,12 @@ + + org.projectlombok + lombok + ${lombok.version} + provided + org.assertj diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/objectclass/Borrower.java b/core-java-modules/core-java-lang-operators/src/main/java/com/baeldung/objectclass/Borrower.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/objectclass/Borrower.java rename to core-java-modules/core-java-lang-operators/src/main/java/com/baeldung/objectclass/Borrower.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/objectclass/Lender.java b/core-java-modules/core-java-lang-operators/src/main/java/com/baeldung/objectclass/Lender.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/objectclass/Lender.java rename to core-java-modules/core-java-lang-operators/src/main/java/com/baeldung/objectclass/Lender.java diff --git a/core-java-modules/core-java/src/main/java/com/baeldung/objectclass/User.java b/core-java-modules/core-java-lang-operators/src/main/java/com/baeldung/objectclass/User.java similarity index 100% rename from core-java-modules/core-java/src/main/java/com/baeldung/objectclass/User.java rename to core-java-modules/core-java-lang-operators/src/main/java/com/baeldung/objectclass/User.java diff --git a/core-java-modules/core-java/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java b/core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java similarity index 74% rename from core-java-modules/core-java/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java rename to core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java index 8330ddbac5..bba30adcdb 100644 --- a/core-java-modules/core-java/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java +++ b/core-java-modules/core-java-lang-operators/src/test/java/com/baeldung/objectclass/CreditAppUnitTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.Ignore; import org.junit.Test; public class CreditAppUnitTest { @@ -40,13 +41,28 @@ public class CreditAppUnitTest { assertNotNull(lender); } + @Ignore + @Test + public void givenBorrower_whenDoubleOrNotString_thenRequestLoan() { + Borrower borrower = new Borrower(); + double amount = 100.0; + + /*if(amount instanceof Double) { // Compilation error, no autoboxing + borrower.requestLoan(amount); + } + + if(!(amount instanceof String)) { // Compilation error, incompatible operands + borrower.requestLoan(amount); + }*/ + + } + @Test public void givenBorrower_whenLoanAmountIsDouble_thenRequestLoan() { Borrower borrower = new Borrower(); double amount = 100.0; - //if(amount instanceof Double) // Compilation error, no autoboxing - if(Double.class.isInstance(amount)) { + if(Double.class.isInstance(amount)) { // No compilation error borrower.requestLoan(amount); } assertEquals(100, borrower.getTotalLoanAmount()); @@ -57,8 +73,7 @@ public class CreditAppUnitTest { Borrower borrower = new Borrower(); Double amount = 100.0; - //if(amount instanceof String) // Compilation error, incompatible operands - if(!String.class.isInstance(amount)) { + if(!String.class.isInstance(amount)) { // No compilation error borrower.requestLoan(amount); } assertEquals(100, borrower.getTotalLoanAmount()); From c10208b4d926ad4ee6795082cecba8c3228415bc Mon Sep 17 00:00:00 2001 From: Kyle Doyle Date: Fri, 1 May 2020 19:48:38 -0400 Subject: [PATCH 412/503] Bael 3893 - Code review updates --- .../awsappsync/AppSyncClientHelper.java | 2 +- .../awsappsync/AwsAppSyncApplication.java | 6 +- .../AwsAppSyncApplicationTests.java | 77 ++++++++++++------- pom.xml | 2 +- 4 files changed, 53 insertions(+), 34 deletions(-) diff --git a/aws-app-sync/src/main/java/com/baeldung/awsappsync/AppSyncClientHelper.java b/aws-app-sync/src/main/java/com/baeldung/awsappsync/AppSyncClientHelper.java index fcbc0aa275..b310e60748 100644 --- a/aws-app-sync/src/main/java/com/baeldung/awsappsync/AppSyncClientHelper.java +++ b/aws-app-sync/src/main/java/com/baeldung/awsappsync/AppSyncClientHelper.java @@ -11,7 +11,7 @@ import java.util.Map; public class AppSyncClientHelper { static String apiUrl = "https://m4i3b6icrrb7livfbypfspiifi.appsync-api.us-east-2.amazonaws.com"; - static String apiKey = "da2-es2s6oj4mzhbxk5yu26ss2ruj4"; + static String apiKey = "da2-bm4rpatkkrc5jfyhvvq7itjeke"; static String API_KEY_HEADER = "x-api-key"; public static WebClient.ResponseSpec getResponseBodySpec(Map requestBody) { diff --git a/aws-app-sync/src/main/java/com/baeldung/awsappsync/AwsAppSyncApplication.java b/aws-app-sync/src/main/java/com/baeldung/awsappsync/AwsAppSyncApplication.java index ae012c91a5..19fffd2994 100644 --- a/aws-app-sync/src/main/java/com/baeldung/awsappsync/AwsAppSyncApplication.java +++ b/aws-app-sync/src/main/java/com/baeldung/awsappsync/AwsAppSyncApplication.java @@ -6,8 +6,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class AwsAppSyncApplication { - public static void main(String[] args) { - SpringApplication.run(AwsAppSyncApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(AwsAppSyncApplication.class, args); + } } diff --git a/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java b/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java index cd14bcd5b2..6e94651789 100644 --- a/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java +++ b/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java @@ -12,42 +12,61 @@ import static org.junit.jupiter.api.Assertions.*; @SpringBootTest class AwsAppSyncApplicationTests { - @Test - void givenGraphQuery_whenListEvents_thenReturnAllEvents() { + @Test + void givenGraphQuery_whenListEvents_thenReturnAllEvents() { - Map requestBody = new HashMap<>(); - requestBody.put("query", "query ListEvents { listEvents { items { id name where when description } } }"); - requestBody.put("variables", ""); - requestBody.put("operationName", "ListEvents"); + Map requestBody = new HashMap<>(); + requestBody.put("query", "query ListEvents {" + + " listEvents {" + + " items {" + + " id" + + " name" + + " where" + + " when" + + " description" + + " }" + + " }" + + "}"); + requestBody.put("variables", ""); + requestBody.put("operationName", "ListEvents"); - String bodyString = AppSyncClientHelper.getResponseBodySpec(requestBody) - .bodyToMono(String.class).block(); + String bodyString = AppSyncClientHelper.getResponseBodySpec(requestBody) + .bodyToMono(String.class).block(); - assertNotNull(bodyString); - assertTrue(bodyString.contains("My First Event")); - assertTrue(bodyString.contains("where")); - assertTrue(bodyString.contains("when")); - } + assertNotNull(bodyString); + assertTrue(bodyString.contains("My First Event")); + assertTrue(bodyString.contains("where")); + assertTrue(bodyString.contains("when")); + } - @Test - void givenGraphAdd_whenMutation_thenReturnIdNameDesc() { + @Test + void givenGraphAdd_whenMutation_thenReturnIdNameDesc() { - String queryString = "mutation add { createEvent( name:\"My added GraphQL event\" where:\"Day 2\"" + - " when:\"Saturday night\" description:\"Studying GraphQL\" ){ id name description } }"; + String queryString = "mutation add {" + + " createEvent(" + + " name:\"My added GraphQL event\"" + + " where:\"Day 2\"" + + " when:\"Saturday night\"" + + " description:\"Studying GraphQL\"" + + " ){" + + " id" + + " name" + + " description" + + " }" + + "}"; + Map requestBody = new HashMap<>(); + requestBody.put("query", queryString); + requestBody.put("variables", ""); + requestBody.put("operationName", "add"); - Map requestBody = new HashMap<>(); - requestBody.put("query", queryString); - requestBody.put("variables", ""); - requestBody.put("operationName", "add"); + WebClient.ResponseSpec response = AppSyncClientHelper.getResponseBodySpec(requestBody); - WebClient.ResponseSpec response = AppSyncClientHelper.getResponseBodySpec(requestBody); + String bodyString = response.bodyToMono(String.class).block(); - String bodyString = response.bodyToMono(String.class).block(); - - assertNotNull(bodyString); - assertTrue(bodyString.contains("My added GraphQL event")); - assertFalse(bodyString.contains("where")); - assertFalse(bodyString.contains("when")); - } + assertNotNull(bodyString); + assertTrue(bodyString.contains("My added GraphQL event")); + assertFalse(bodyString.contains("where")); + assertFalse(bodyString.contains("when")); + } } diff --git a/pom.xml b/pom.xml index 22d73f3a9e..8f2cc8e902 100644 --- a/pom.xml +++ b/pom.xml @@ -1015,7 +1015,7 @@ asm atomix aws - aws-app-sync + aws-app-sync aws-lambda axon azure From dd052eb2fc0457e67b20302392072136b242c7f9 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Sat, 2 May 2020 18:27:41 +0200 Subject: [PATCH 413/503] BAEL-3730: Force simple cache manager usage (#9211) --- .../caching/boot/SimpleCacheCustomizerIntegrationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-caching/src/test/java/com/baeldung/caching/boot/SimpleCacheCustomizerIntegrationTest.java b/spring-caching/src/test/java/com/baeldung/caching/boot/SimpleCacheCustomizerIntegrationTest.java index 56a4bd4745..3c83065c5c 100644 --- a/spring-caching/src/test/java/com/baeldung/caching/boot/SimpleCacheCustomizerIntegrationTest.java +++ b/spring-caching/src/test/java/com/baeldung/caching/boot/SimpleCacheCustomizerIntegrationTest.java @@ -10,7 +10,7 @@ import org.springframework.test.context.junit4.SpringRunner; import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) -@SpringBootTest +@SpringBootTest("spring.cache.type=simple") public class SimpleCacheCustomizerIntegrationTest { @Autowired From 2b4c2e3c8c9f75b4e65c8e351d34b98bee4d7720 Mon Sep 17 00:00:00 2001 From: Belma Jakupovic Date: Sat, 2 May 2020 18:30:36 +0200 Subject: [PATCH 414/503] bjakupovic remove sys. prints (#9208) --- .../src/main/java/com/baeldung/s/TextManipulator.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/patterns/solid/src/main/java/com/baeldung/s/TextManipulator.java b/patterns/solid/src/main/java/com/baeldung/s/TextManipulator.java index a6b32a0ff9..d084a78815 100644 --- a/patterns/solid/src/main/java/com/baeldung/s/TextManipulator.java +++ b/patterns/solid/src/main/java/com/baeldung/s/TextManipulator.java @@ -15,16 +15,18 @@ public class TextManipulator { text = text.concat(newText); } - public void findWordAndReplace(String word, String replacementWord) { + public String findWordAndReplace(String word, String replacementWord) { if (text.contains(word)) { text = text.replace(word, replacementWord); - } else System.out.println("Word you want to replace is not found in the text"); + } + return text; } - public void findWordAndDelete(String word) { + public String findWordAndDelete(String word) { if (text.contains(word)) { text = text.replace(word, ""); - } else System.out.println("Word you want to delete is not found in the text"); + } + return text; } /* From cb9ed74dab4f05a111023836dc2da902947217d1 Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sun, 3 May 2020 15:35:23 +0530 Subject: [PATCH 415/503] fix integration test cases --- spring-mvc-java/pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 079a664a5d..30c6961f03 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -69,6 +69,12 @@ commons-io ${commons-io.version} + + commons-fileupload + commons-fileupload + 1.4 + + From 63fb2df0ba1f83e6b7451e7204f65ce08a12ae32 Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sun, 3 May 2020 15:37:23 +0530 Subject: [PATCH 416/503] fix integration test cases --- spring-mvc-java/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 30c6961f03..9e3457aa8a 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -72,7 +72,7 @@ commons-fileupload commons-fileupload - 1.4 + ${commons-fileupload.version} @@ -243,6 +243,7 @@ 3.5 1.3.2 2.5 + 1.4 2.2.0 From e41cc37b61f7052c55bb297f1ee0ec4ea4291600 Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sun, 3 May 2020 16:38:26 +0530 Subject: [PATCH 417/503] updated readme file --- spring-core-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-core-2/README.md b/spring-core-2/README.md index 947b816db8..6068e8c3c2 100644 --- a/spring-core-2/README.md +++ b/spring-core-2/README.md @@ -14,4 +14,5 @@ This module contains articles about core Spring functionality - [Spring Events](https://www.baeldung.com/spring-events) - [Spring Null-Safety Annotations](https://www.baeldung.com/spring-null-safety-annotations) - [Using @Autowired in Abstract Classes](https://www.baeldung.com/spring-autowired-abstract-class) +- [Running Setup Data in Startup] (https://www.baeldung.com/running-setup-logic-on-startup-in-spring) - More articles: [[<-- prev]](/spring-core)[[next -->]](/spring-core-3) From a1cfe519cafd993135d54bd14af21d912d5f22b1 Mon Sep 17 00:00:00 2001 From: Anshul BANSAL Date: Sun, 3 May 2020 14:38:08 +0300 Subject: [PATCH 418/503] BAEL-3995 - Spring Security with Okta --- spring-security-modules/pom.xml | 1 + .../spring-security-okta/pom.xml | 62 +++++++++++++++++++ .../java/com/baeldung/okta/Application.java | 13 ++++ .../okta/controller/AdminController.java | 43 +++++++++++++ .../okta/controller/HomeController.java | 16 +++++ .../src/main/resources/application.properties | 8 +++ 6 files changed, 143 insertions(+) create mode 100644 spring-security-modules/spring-security-okta/pom.xml create mode 100644 spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/Application.java create mode 100644 spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/controller/AdminController.java create mode 100644 spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/controller/HomeController.java create mode 100644 spring-security-modules/spring-security-okta/src/main/resources/application.properties diff --git a/spring-security-modules/pom.xml b/spring-security-modules/pom.xml index 49a0db03ed..59dd75cbda 100644 --- a/spring-security-modules/pom.xml +++ b/spring-security-modules/pom.xml @@ -30,6 +30,7 @@ spring-security-mvc-login spring-security-mvc-persisted-remember-me spring-security-mvc-socket + spring-security-okta spring-security-oidc spring-security-react spring-security-rest diff --git a/spring-security-modules/spring-security-okta/pom.xml b/spring-security-modules/spring-security-okta/pom.xml new file mode 100644 index 0000000000..c5ff9013b5 --- /dev/null +++ b/spring-security-modules/spring-security-okta/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + spring-security-okta + 1.0-SNAPSHOT + spring-security-okta + war + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-web + + + com.okta.spring + okta-spring-boot-starter + ${okta.spring.version} + + + com.okta.spring + okta-spring-sdk + ${okta.spring.version} + + + + + spring-security-okta + + + src/main/resources + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + repackage + + + + + + + + + 1.4.0 + + diff --git a/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/Application.java b/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/Application.java new file mode 100644 index 0000000000..0c5cc94f10 --- /dev/null +++ b/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/Application.java @@ -0,0 +1,13 @@ +package com.baeldung.okta; + +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-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/controller/AdminController.java b/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/controller/AdminController.java new file mode 100644 index 0000000000..c7786c4006 --- /dev/null +++ b/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/controller/AdminController.java @@ -0,0 +1,43 @@ +package com.baeldung.okta.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.okta.sdk.client.Client; +import com.okta.sdk.resource.user.User; +import com.okta.sdk.resource.user.UserBuilder; +import com.okta.sdk.resource.user.UserList; + +@RestController +public class AdminController { + + @Autowired + public Client client; + + @GetMapping("/users") + public UserList getUsers() { + return client.listUsers(); + } + + @GetMapping("/user") + public UserList searchUserByEmail(@RequestParam String query) { + return client.listUsers(query, null, null, null, null); + } + + @GetMapping("/createUser") + public User createUser() { + char[] tempPassword = {'P','a','$','$','w','0','r','d'}; + User user = UserBuilder.instance() + .setEmail("norman.lewis@email.com") + .setFirstName("Norman") + .setLastName("Lewis") + .setPassword(tempPassword) + .setActive(true) + .buildAndCreate(client); + return user; + } + +} + diff --git a/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/controller/HomeController.java b/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/controller/HomeController.java new file mode 100644 index 0000000000..b8f3ec4e10 --- /dev/null +++ b/spring-security-modules/spring-security-okta/src/main/java/com/baeldung/okta/controller/HomeController.java @@ -0,0 +1,16 @@ +package com.baeldung.okta.controller; + +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.security.oauth2.core.oidc.user.OidcUser; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HomeController { + + @GetMapping("/") + public String home(@AuthenticationPrincipal OidcUser user) { + return "Welcome, "+ user.getFullName() +"!"; + } + +} diff --git a/spring-security-modules/spring-security-okta/src/main/resources/application.properties b/spring-security-modules/spring-security-okta/src/main/resources/application.properties new file mode 100644 index 0000000000..4a584e3c29 --- /dev/null +++ b/spring-security-modules/spring-security-okta/src/main/resources/application.properties @@ -0,0 +1,8 @@ +okta.oauth2.issuer= //Auth server issuer URL +okta.oauth2.client-id= //Client ID of our Okta application +okta.oauth2.client-secret= //Client secret of our Okta application +okta.oauth2.redirect-uri=/authorization-code/callback + +#Okta Spring SDK configs +okta.client.orgUrl= //orgURL +okta.client.token= //token generated \ No newline at end of file From 05a4f60e38babd42b62b825157247195bd5778da Mon Sep 17 00:00:00 2001 From: Cristian Rosu Date: Sun, 3 May 2020 17:28:27 +0300 Subject: [PATCH 419/503] BAEL-3826: creating PDFs using Thymeleaf as template engine --- pdf/pom.xml | 10 ++++ .../com/baeldung/pdf/PDFThymeleafExample.java | 48 +++++++++++++++++++ .../main/resources/thymeleaf_template.html | 7 +++ 3 files changed, 65 insertions(+) create mode 100644 pdf/src/main/java/com/baeldung/pdf/PDFThymeleafExample.java create mode 100644 pdf/src/main/resources/thymeleaf_template.html diff --git a/pdf/pom.xml b/pdf/pom.xml index d148aa1670..463c88948d 100644 --- a/pdf/pom.xml +++ b/pdf/pom.xml @@ -60,6 +60,16 @@ poi-ooxml ${poi-ooxml.version} + + org.thymeleaf + thymeleaf + 3.0.11.RELEASE + + + org.xhtmlrenderer + flying-saucer-pdf + 9.1.20 + diff --git a/pdf/src/main/java/com/baeldung/pdf/PDFThymeleafExample.java b/pdf/src/main/java/com/baeldung/pdf/PDFThymeleafExample.java new file mode 100644 index 0000000000..2e1df1d320 --- /dev/null +++ b/pdf/src/main/java/com/baeldung/pdf/PDFThymeleafExample.java @@ -0,0 +1,48 @@ +package com.baeldung.pdf; + +import com.lowagie.text.DocumentException; +import org.thymeleaf.TemplateEngine; +import org.thymeleaf.context.Context; +import org.thymeleaf.templatemode.TemplateMode; +import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; +import org.xhtmlrenderer.pdf.ITextRenderer; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +public class PDFThymeleafExample { + + public static void main(String[] args) throws IOException, DocumentException { + PDFThymeleafExample thymeleaf2Pdf = new PDFThymeleafExample(); + String html = thymeleaf2Pdf.parseThymeleafTemplate(); + thymeleaf2Pdf.generatePdfFromHtml(html); + } + + public void generatePdfFromHtml(String html) throws IOException, DocumentException { + String outputFolder = System.getProperty("user.home") + File.separator + "thymeleaf.pdf"; + OutputStream outputStream = new FileOutputStream(outputFolder); + + ITextRenderer renderer = new ITextRenderer(); + renderer.setDocumentFromString(html); + renderer.layout(); + renderer.createPDF(outputStream); + + outputStream.close(); + } + + private String parseThymeleafTemplate() { + ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver(); + templateResolver.setSuffix(".html"); + templateResolver.setTemplateMode(TemplateMode.HTML); + + TemplateEngine templateEngine = new TemplateEngine(); + templateEngine.setTemplateResolver(templateResolver); + + Context context = new Context(); + context.setVariable("to", "Baeldung.com"); + + return templateEngine.process("thymeleaf_template", context); + } +} diff --git a/pdf/src/main/resources/thymeleaf_template.html b/pdf/src/main/resources/thymeleaf_template.html new file mode 100644 index 0000000000..3e856367cc --- /dev/null +++ b/pdf/src/main/resources/thymeleaf_template.html @@ -0,0 +1,7 @@ + + +

    + +

    + + \ No newline at end of file From dbb4a85c1071d6d95dbbf6ee939945b5ddccbf15 Mon Sep 17 00:00:00 2001 From: sergio41 Date: Sun, 3 May 2020 16:44:14 +0200 Subject: [PATCH 420/503] [BAEL-3944] Negative test cases --- .../PhoneNumbersRegexUnitTest.java | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/phonenumbers/PhoneNumbersRegexUnitTest.java b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/phonenumbers/PhoneNumbersRegexUnitTest.java index afabf47baa..11bf1618b6 100644 --- a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/phonenumbers/PhoneNumbersRegexUnitTest.java +++ b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/phonenumbers/PhoneNumbersRegexUnitTest.java @@ -15,6 +15,13 @@ public class PhoneNumbersRegexUnitTest { Matcher matcher = pattern.matcher("2055550125"); assertTrue(matcher.matches()); } + + @Test + public void whenMOreThanTenDigits_thenNotCorrect() { + Pattern pattern = Pattern.compile("^\\d{10}$"); + Matcher matcher = pattern.matcher("20555501251"); + assertFalse(matcher.matches()); + } @Test public void whenMatchesTenDigitsNumberWhitespacesDotHyphen_thenCorrect() { @@ -22,6 +29,27 @@ public class PhoneNumbersRegexUnitTest { Matcher matcher = pattern.matcher("202 555 0125"); assertTrue(matcher.matches()); } + + @Test + public void whenIncludesBracket_thenNotCorrect() { + Pattern pattern = Pattern.compile("^(\\d{3}[- .]?){2}\\d{4}$"); + Matcher matcher = pattern.matcher("202]555 0125"); + assertFalse(matcher.matches()); + } + + @Test + public void whenNotStartsWithBatchesOfThreeDigits_thenNotCorrect() { + Pattern pattern = Pattern.compile("^(\\d{3}[- .]?){2}\\d{4}$"); + Matcher matcher = pattern.matcher("2021 555 0125"); + assertFalse(matcher.matches()); + } + + @Test + public void whenLastPartWithNoFourDigits_thenNotCorrect() { + Pattern pattern = Pattern.compile("^(\\d{3}[- .]?){2}\\d{4}$"); + Matcher matcher = pattern.matcher("202 555 012"); + assertFalse(matcher.matches()); + } @Test public void whenMatchesTenDigitsNumberParenthesis_thenCorrect() { @@ -30,6 +58,20 @@ public class PhoneNumbersRegexUnitTest { assertTrue(matcher.matches()); } + @Test + public void whenJustOpeningParenthesis_thenNotCorrect() { + Pattern pattern = Pattern.compile("^((\\(\\d{3}\\))|\\d{3})[- .]?\\d{3}[- .]?\\d{4}$"); + Matcher matcher = pattern.matcher("(202 555-0125"); + assertFalse(matcher.matches()); + } + + @Test + public void whenJustClosingParenthesis_thenNotCorrect() { + Pattern pattern = Pattern.compile("^((\\(\\d{3}\\))|\\d{3})[- .]?\\d{3}[- .]?\\d{4}$"); + Matcher matcher = pattern.matcher("202) 555-0125"); + assertFalse(matcher.matches()); + } + @Test public void whenMatchesTenDigitsNumberPrefix_thenCorrect() { Pattern pattern = Pattern.compile("^(\\+\\d{1,3}( )?)?((\\(\\d{3}\\))|\\d{3})[- .]?\\d{3}[- .]?\\d{4}$"); @@ -37,6 +79,20 @@ public class PhoneNumbersRegexUnitTest { assertTrue(matcher.matches()); } + @Test + public void whenIncorrectPrefix_thenNotCorrect() { + Pattern pattern = Pattern.compile("^(\\+\\d{1,3}( )?)?((\\(\\d{3}\\))|\\d{3})[- .]?\\d{3}[- .]?\\d{4}$"); + Matcher matcher = pattern.matcher("-111 (202) 555-0125"); + assertFalse(matcher.matches()); + } + + @Test + public void whenTooLongPrefix_thenNotCorrect() { + Pattern pattern = Pattern.compile("^(\\+\\d{1,3}( )?)?((\\(\\d{3}\\))|\\d{3})[- .]?\\d{3}[- .]?\\d{4}$"); + Matcher matcher = pattern.matcher("+1111 (202) 555-0125"); + assertFalse(matcher.matches()); + } + @Test public void whenMatchesPhoneNumber_thenCorrect() { String patterns @@ -53,4 +109,21 @@ public class PhoneNumbersRegexUnitTest { assertTrue(matcher.matches()); } } + + @Test + public void whenNotMatchesPhoneNumber_thenNotCorrect() { + String patterns + = "^(\\+\\d{1,3}( )?)?((\\(\\d{3}\\))|\\d{3})[- .]?\\d{3}[- .]?\\d{4}$" + + "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?){2}\\d{3}$" + + "|^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?)(\\d{2}[ ]?){2}\\d{2}$"; + + String[] invalidPhoneNumbers + = {"20555501251","202]555 0125", "2021 555 012", "(202 555-0125", "202) 555-0125", "-111 (202) 555-0125", "+1111 (202) 555-0125", "636 85 789", "636 85 67 893"}; + + Pattern pattern = Pattern.compile(patterns); + for(String phoneNumber : invalidPhoneNumbers) { + Matcher matcher = pattern.matcher(phoneNumber); + assertFalse(matcher.matches()); + } + } } From 04ac8037041d7df0edf4016629ff6e3235f1b899 Mon Sep 17 00:00:00 2001 From: dupirefr Date: Sun, 3 May 2020 19:42:17 +0200 Subject: [PATCH 421/503] [JAVA-621] Fixed core-java-lang-oop-inheritance module description --- core-java-modules/core-java-lang-oop-inheritance/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core-java-modules/core-java-lang-oop-inheritance/README.md b/core-java-modules/core-java-lang-oop-inheritance/README.md index e264f9fae4..c87bdf13d7 100644 --- a/core-java-modules/core-java-lang-oop-inheritance/README.md +++ b/core-java-modules/core-java-lang-oop-inheritance/README.md @@ -1,6 +1,6 @@ -## Core Java Lang OOP - Types +## Core Java Lang OOP - Inheritance -This module contains articles about types in Java +This module contains articles about inheritance in Java ### Relevant Articles: - [Java Interfaces](https://www.baeldung.com/java-interfaces) From 50a6563e30fd87dc040cdb6d72da0cac9f67928f Mon Sep 17 00:00:00 2001 From: Arindum Roy Date: Sun, 3 May 2020 23:19:33 +0530 Subject: [PATCH 422/503] "updated pom.xml" --- persistence-modules/spring-data-jpa-5/pom.xml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/persistence-modules/spring-data-jpa-5/pom.xml b/persistence-modules/spring-data-jpa-5/pom.xml index c71cec1d08..390cfaf0c0 100644 --- a/persistence-modules/spring-data-jpa-5/pom.xml +++ b/persistence-modules/spring-data-jpa-5/pom.xml @@ -28,16 +28,6 @@ spring-boot-starter-data-jdbc - - mysql - mysql-connector-java - - - - org.postgresql - postgresql - - com.h2database h2 From f8cae12a3830b303442bcd808439a9f057027def Mon Sep 17 00:00:00 2001 From: Kyle Doyle Date: Sun, 3 May 2020 13:53:19 -0400 Subject: [PATCH 423/503] Bael-3893 - Updated indents with 4 spaces --- aws-app-sync/pom.xml | 90 ++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/aws-app-sync/pom.xml b/aws-app-sync/pom.xml index ef2085ff35..1f915978ab 100644 --- a/aws-app-sync/pom.xml +++ b/aws-app-sync/pom.xml @@ -1,56 +1,56 @@ - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.2.6.RELEASE - - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.2.6.RELEASE + + - com.baeldung - aws-app-sync - 0.0.1-SNAPSHOT - aws-app-sync + com.baeldung + aws-app-sync + 0.0.1-SNAPSHOT + aws-app-sync - Spring Boot using AWS App Sync + Spring Boot using AWS App Sync - - 1.8 - + + 1.8 + - + - - org.springframework.boot - spring-boot-starter-web - + + 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-starter-webflux - - + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + org.springframework.boot + spring-boot-starter-webflux + + - - - - org.springframework.boot - spring-boot-maven-plugin - - - + + + + org.springframework.boot + spring-boot-maven-plugin + + + From 43816bc2822b0440860aba1a584dca33d5502d41 Mon Sep 17 00:00:00 2001 From: Arindum Roy Date: Sun, 3 May 2020 23:33:39 +0530 Subject: [PATCH 424/503] update --- persistence-modules/spring-data-jpa-5/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/spring-data-jpa-5/pom.xml b/persistence-modules/spring-data-jpa-5/pom.xml index 390cfaf0c0..7f2c724f98 100644 --- a/persistence-modules/spring-data-jpa-5/pom.xml +++ b/persistence-modules/spring-data-jpa-5/pom.xml @@ -34,4 +34,4 @@
    - \ No newline at end of file + From 4487ac8654ac989a607998ae382dadb5979ab173 Mon Sep 17 00:00:00 2001 From: Arindum Roy Date: Sun, 3 May 2020 23:36:14 +0530 Subject: [PATCH 425/503] update --- .../src/test/resources/application-test.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/persistence-modules/spring-data-jpa-5/src/test/resources/application-test.properties b/persistence-modules/spring-data-jpa-5/src/test/resources/application-test.properties index f9497c8f37..207de2e8ec 100644 --- a/persistence-modules/spring-data-jpa-5/src/test/resources/application-test.properties +++ b/persistence-modules/spring-data-jpa-5/src/test/resources/application-test.properties @@ -1,2 +1 @@ spring.jpa.hibernate.ddl-auto=update -spring.datasource.url=jdbc:h2:mem:jpa3 \ No newline at end of file From ba42ca2dbbd07c5e89abeda3aef065f50bb74a82 Mon Sep 17 00:00:00 2001 From: Maciej Glowka Date: Sun, 3 May 2020 22:05:04 +0200 Subject: [PATCH 426/503] BAEL-3829: example of dynamic bean autowiring in Spring --- .../BeanFactoryDynamicAutowireService.java | 22 ++++++++++++++ .../autowire/DynamicAutowireConfig.java | 9 ++++++ .../InterfaceDynamicAutowireService.java | 26 ++++++++++++++++ .../dynamic/autowire/RegionService.java | 7 +++++ .../dynamic/autowire/USARegionService.java | 16 ++++++++++ .../dynamic/autowire/UkRegionService.java | 16 ++++++++++ .../DynamicAutowireIntegrationTest.java | 30 +++++++++++++++++++ 7 files changed, 126 insertions(+) create mode 100644 spring-core-4/src/main/java/com/baeldung/dynamic/autowire/BeanFactoryDynamicAutowireService.java create mode 100644 spring-core-4/src/main/java/com/baeldung/dynamic/autowire/DynamicAutowireConfig.java create mode 100644 spring-core-4/src/main/java/com/baeldung/dynamic/autowire/InterfaceDynamicAutowireService.java create mode 100644 spring-core-4/src/main/java/com/baeldung/dynamic/autowire/RegionService.java create mode 100644 spring-core-4/src/main/java/com/baeldung/dynamic/autowire/USARegionService.java create mode 100644 spring-core-4/src/main/java/com/baeldung/dynamic/autowire/UkRegionService.java create mode 100644 spring-core-4/src/test/java/com/baeldung/dynamic/autowire/DynamicAutowireIntegrationTest.java diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/BeanFactoryDynamicAutowireService.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/BeanFactoryDynamicAutowireService.java new file mode 100644 index 0000000000..5f8f2e548e --- /dev/null +++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/BeanFactoryDynamicAutowireService.java @@ -0,0 +1,22 @@ +package com.baeldung.dynamic.autowire; + +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class BeanFactoryDynamicAutowireService { + private final BeanFactory beanFactory; + + @Autowired + public BeanFactoryDynamicAutowireService(BeanFactory beanFactory) { + this.beanFactory = beanFactory; + } + + public boolean isServerActive(String countryCode, int serverId) { + RegionService service = beanFactory.getBean(countryCode, RegionService.class); + + return service.isServerActive(serverId); + } + +} diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/DynamicAutowireConfig.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/DynamicAutowireConfig.java new file mode 100644 index 0000000000..256bd9b495 --- /dev/null +++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/DynamicAutowireConfig.java @@ -0,0 +1,9 @@ +package com.baeldung.dynamic.autowire; + +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ComponentScan("com.baeldung.dynamic.autowire") +public class DynamicAutowireConfig { +} diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/InterfaceDynamicAutowireService.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/InterfaceDynamicAutowireService.java new file mode 100644 index 0000000000..ad655f5c42 --- /dev/null +++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/InterfaceDynamicAutowireService.java @@ -0,0 +1,26 @@ +package com.baeldung.dynamic.autowire; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +@Service +public class InterfaceDynamicAutowireService { + private final Map servicesByCountryCode; + + @Autowired + public InterfaceDynamicAutowireService(List regionServices) { + servicesByCountryCode = regionServices.stream() + .collect(Collectors.toMap(RegionService::getCountryCode, Function.identity())); + } + + public boolean isServerActive(String countryCode, int serverId) { + RegionService service = servicesByCountryCode.get(countryCode); + + return service.isServerActive(serverId); + } +} diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/RegionService.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/RegionService.java new file mode 100644 index 0000000000..f9f92d045a --- /dev/null +++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/RegionService.java @@ -0,0 +1,7 @@ +package com.baeldung.dynamic.autowire; + +public interface RegionService { + boolean isServerActive(int serverId); + + String getCountryCode(); +} diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/USARegionService.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/USARegionService.java new file mode 100644 index 0000000000..cfad0146e5 --- /dev/null +++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/USARegionService.java @@ -0,0 +1,16 @@ +package com.baeldung.dynamic.autowire; + +import org.springframework.stereotype.Service; + +@Service("usa") +public class USARegionService implements RegionService { + @Override + public boolean isServerActive(int serverId) { + return true; + } + + @Override + public String getCountryCode() { + return "usa"; + } +} diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/UkRegionService.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/UkRegionService.java new file mode 100644 index 0000000000..1fbe8ed96e --- /dev/null +++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/UkRegionService.java @@ -0,0 +1,16 @@ +package com.baeldung.dynamic.autowire; + +import org.springframework.stereotype.Service; + +@Service("uk") +public class UkRegionService implements RegionService { + @Override + public boolean isServerActive(int serverId) { + return false; + } + + @Override + public String getCountryCode() { + return "uk"; + } +} diff --git a/spring-core-4/src/test/java/com/baeldung/dynamic/autowire/DynamicAutowireIntegrationTest.java b/spring-core-4/src/test/java/com/baeldung/dynamic/autowire/DynamicAutowireIntegrationTest.java new file mode 100644 index 0000000000..5afab69c53 --- /dev/null +++ b/spring-core-4/src/test/java/com/baeldung/dynamic/autowire/DynamicAutowireIntegrationTest.java @@ -0,0 +1,30 @@ +package com.baeldung.dynamic.autowire; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(classes = DynamicAutowireConfig.class) +public class DynamicAutowireIntegrationTest { + + @Autowired + private BeanFactoryDynamicAutowireService beanFactoryDynamicAutowireService; + + @Autowired + private InterfaceDynamicAutowireService interfaceDynamicAutowireService; + + @Test + public void testConstructWorkerByJava() { + assertThat(beanFactoryDynamicAutowireService.isServerActive("uk", 101), is(false)); + assertThat(interfaceDynamicAutowireService.isServerActive("uk", 101), is(false)); + + assertThat(beanFactoryDynamicAutowireService.isServerActive("usa", 101), is(true)); + assertThat(interfaceDynamicAutowireService.isServerActive("usa", 101), is(true)); + } +} From b26b71567acaafa778f4b97d08a6c95b7c2dd528 Mon Sep 17 00:00:00 2001 From: aitorcuesta <56877414+aitorcuesta@users.noreply.github.com> Date: Sun, 3 May 2020 22:25:39 +0200 Subject: [PATCH 427/503] [BAEL-3614] - Spring Redis Configuration From application.properties File (#9226) * BAEL-3614 - Initial commit * BAEL-3614 - Removing unnecessary properties --- persistence-modules/redis/pom.xml | 32 ++++++--- .../redis/configuration/RedisConfig.java | 24 +++++++ .../SpringRedisConfigurationApplication.java | 19 ++++++ .../controller/BooksController.java | 32 +++++++++ .../redis/configuration/entity/Book.java | 46 +++++++++++++ .../repository/BooksRepository.java | 25 +++++++ .../src/main/resources/application.properties | 9 +++ .../controller/BooksControllerUnitTest.java | 52 +++++++++++++++ .../repository/BooksRepositoryUnitTest.java | 66 +++++++++++++++++++ 9 files changed, 295 insertions(+), 10 deletions(-) create mode 100644 persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/RedisConfig.java create mode 100644 persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/SpringRedisConfigurationApplication.java create mode 100644 persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/controller/BooksController.java create mode 100644 persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/entity/Book.java create mode 100644 persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/repository/BooksRepository.java create mode 100644 persistence-modules/redis/src/main/resources/application.properties create mode 100644 persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/controller/BooksControllerUnitTest.java create mode 100644 persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/repository/BooksRepositoryUnitTest.java diff --git a/persistence-modules/redis/pom.xml b/persistence-modules/redis/pom.xml index fffcfbb96b..c9206e5f92 100644 --- a/persistence-modules/redis/pom.xml +++ b/persistence-modules/redis/pom.xml @@ -9,16 +9,31 @@ com.baeldung - persistence-modules - 1.0.0-SNAPSHOT + parent-boot-2 + 0.0.1-SNAPSHOT + ../../parent-boot-2 + + org.springframework.boot + spring-boot-starter + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-data-redis + + redis.clients jedis - ${jedis.version} - + com.github.kstyrc embedded-redis @@ -32,15 +47,12 @@ io.lettuce lettuce-core - ${lettuce-core.version} - + - - 3.2.0 + 0.6 - 3.3.0 - 5.0.1.RELEASE + 3.3.0 diff --git a/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/RedisConfig.java b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/RedisConfig.java new file mode 100644 index 0000000000..ad43ad8159 --- /dev/null +++ b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/RedisConfig.java @@ -0,0 +1,24 @@ +package com.baeldung.spring.redis.configuration; + +import org.springframework.boot.autoconfigure.data.redis.RedisProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; + +import com.baeldung.spring.redis.configuration.entity.Book; + +@Configuration +@EnableConfigurationProperties(RedisProperties.class) +public class RedisConfig { + + @Bean + public RedisTemplate redisTemplate(RedisConnectionFactory connectionFactory) { + RedisTemplate template = new RedisTemplate<>(); + template.setConnectionFactory(connectionFactory); + // Add some specific configuration here. Key serializers, etc. + return template; + } + +} diff --git a/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/SpringRedisConfigurationApplication.java b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/SpringRedisConfigurationApplication.java new file mode 100644 index 0000000000..932a6b7478 --- /dev/null +++ b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/SpringRedisConfigurationApplication.java @@ -0,0 +1,19 @@ +package com.baeldung.spring.redis.configuration; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringRedisConfigurationApplication implements CommandLineRunner { + + public static void main(String[] args) { + SpringApplication.run(SpringRedisConfigurationApplication.class, args); + } + + @Override + public void run(String... args) throws Exception { + + } + +} diff --git a/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/controller/BooksController.java b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/controller/BooksController.java new file mode 100644 index 0000000000..b3faf030c9 --- /dev/null +++ b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/controller/BooksController.java @@ -0,0 +1,32 @@ +package com.baeldung.spring.redis.configuration.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.spring.redis.configuration.entity.Book; +import com.baeldung.spring.redis.configuration.repository.BooksRepository; + +@RestController +@RequestMapping("/books") +public class BooksController { + + @Autowired + private BooksRepository repository; + + @PostMapping("/create") + public String newBook(@RequestBody Book newBook) { + repository.save(newBook); + return "Added"; + } + + @GetMapping("/get/{id}") + public Book findOne(@PathVariable Long id) { + return repository.findById(id); + } + +} diff --git a/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/entity/Book.java b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/entity/Book.java new file mode 100644 index 0000000000..52d579d4fb --- /dev/null +++ b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/entity/Book.java @@ -0,0 +1,46 @@ +package com.baeldung.spring.redis.configuration.entity; + +import java.io.Serializable; + +public class Book implements Serializable { + + private static final long serialVersionUID = 1L; + + private Long id; + + private String name; + + public Book() { + } + + public Book(String name) { + this.name = name; + } + + public Book(Long id, String name) { + this.id = id; + this.name = name; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "Book [id=" + id + ", name=" + name + "]"; + } + +} diff --git a/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/repository/BooksRepository.java b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/repository/BooksRepository.java new file mode 100644 index 0000000000..a6eba0e742 --- /dev/null +++ b/persistence-modules/redis/src/main/java/com/baeldung/spring/redis/configuration/repository/BooksRepository.java @@ -0,0 +1,25 @@ +package com.baeldung.spring.redis.configuration.repository; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Component; + +import com.baeldung.spring.redis.configuration.entity.Book; + +@Component +public class BooksRepository { + + @Autowired + private RedisTemplate redisTemplate; + + public void save(Book book) { + redisTemplate.opsForValue() + .set(book.getId(), book); + } + + public Book findById(Long id) { + return redisTemplate.opsForValue() + .get(id); + } + +} diff --git a/persistence-modules/redis/src/main/resources/application.properties b/persistence-modules/redis/src/main/resources/application.properties new file mode 100644 index 0000000000..e3140c4e29 --- /dev/null +++ b/persistence-modules/redis/src/main/resources/application.properties @@ -0,0 +1,9 @@ +spring.redis.database=0 +spring.redis.host=localhost +spring.redis.port=16379 +spring.redis.password=mypass +spring.redis.timeout=60000 +spring.redis.lettuce.pool.max-active=8 +spring.redis.lettuce.pool.max-idle=8 +spring.redis.lettuce.pool.max-wait=-1 +spring.redis.lettuce.pool.min-idle=0 \ No newline at end of file diff --git a/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/controller/BooksControllerUnitTest.java b/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/controller/BooksControllerUnitTest.java new file mode 100644 index 0000000000..a5c3340065 --- /dev/null +++ b/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/controller/BooksControllerUnitTest.java @@ -0,0 +1,52 @@ +package com.baeldung.spring.redis.configuration.controller; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.mockito.Mockito.when; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.baeldung.spring.redis.configuration.entity.Book; +import com.baeldung.spring.redis.configuration.repository.BooksRepository; + +@RunWith(SpringJUnit4ClassRunner.class) +public class BooksControllerUnitTest { + + @Spy + @InjectMocks + private BooksController booksController; + + @Mock + private BooksRepository booksRepository; + + private static final Long BOOK_ID = 1l; + private static final Long OTHER_BOOK_ID = 2l; + private static final String BOOK_NAME = "Ulysses"; + private static final String ADDED = "Added"; + + @Test + public void whenNewBook_thenCorrect() { + assertEquals(ADDED, booksController.newBook(new Book(BOOK_ID, BOOK_NAME))); + } + + @Test + public void whenFindOneFinds_thenCorrect() { + Book book = new Book(BOOK_ID, BOOK_NAME); + when(booksRepository.findById(BOOK_ID)).thenReturn(book); + assertSame(book, booksController.findOne(BOOK_ID)); + } + + @Test + public void whenFindOneNotFound_thenReturnsNull() { + Book book = new Book(BOOK_ID, BOOK_NAME); + when(booksRepository.findById(BOOK_ID)).thenReturn(book); + assertNull(booksController.findOne(OTHER_BOOK_ID)); + } + +} diff --git a/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/repository/BooksRepositoryUnitTest.java b/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/repository/BooksRepositoryUnitTest.java new file mode 100644 index 0000000000..1edf9c7e89 --- /dev/null +++ b/persistence-modules/redis/src/test/java/com/baeldung/spring/redis/configuration/repository/BooksRepositoryUnitTest.java @@ -0,0 +1,66 @@ +package com.baeldung.spring.redis.configuration.repository; + +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ValueOperations; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import com.baeldung.spring.redis.configuration.entity.Book; + +@RunWith(SpringJUnit4ClassRunner.class) +public class BooksRepositoryUnitTest { + + @Spy + @InjectMocks + private BooksRepository booksRepository; + + @Mock + private RedisTemplate redisTemplate; + + @Mock + private ValueOperations valueOperations; + + private static final Long BOOK_ID = 1l; + private static final Long OTHER_BOOK_ID = 2l; + private static final String BOOK_NAME = "Ulysses"; + + @Test + public void whenSave_thenCorrect() { + Book book = new Book(BOOK_ID, BOOK_NAME); + when(redisTemplate.opsForValue()).thenReturn(valueOperations); + booksRepository.save(book); + verify(redisTemplate, times(1)).opsForValue(); + verify(valueOperations, times(1)).set(BOOK_ID, book); + } + + @Test + public void whenFindByIdFound_thenReturnsBook() { + Book book = new Book(BOOK_ID, BOOK_NAME); + when(redisTemplate.opsForValue()).thenReturn(valueOperations); + when(valueOperations.get(BOOK_ID)).thenReturn(book); + assertSame(book, booksRepository.findById(BOOK_ID)); + verify(redisTemplate, times(1)).opsForValue(); + verify(valueOperations, times(1)).get(BOOK_ID); + } + + @Test + public void whenFindByIdNotFound_thenReturnsNull() { + Book book = new Book(BOOK_ID, BOOK_NAME); + when(redisTemplate.opsForValue()).thenReturn(valueOperations); + when(valueOperations.get(BOOK_ID)).thenReturn(book); + assertNull(booksRepository.findById(OTHER_BOOK_ID)); + verify(redisTemplate, times(1)).opsForValue(); + verify(valueOperations, times(1)).get(OTHER_BOOK_ID); + } + +} From 7ec77df0960181bdf35e8770d332ac7602b43e8a Mon Sep 17 00:00:00 2001 From: Chirag Dewan Date: Mon, 4 May 2020 18:11:12 +0530 Subject: [PATCH 428/503] BAEL1731 Adding listappender --- .../logging/log4j2/plugins/ListAppender.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/ListAppender.java diff --git a/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/ListAppender.java b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/ListAppender.java new file mode 100644 index 0000000000..e3819028db --- /dev/null +++ b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/plugins/ListAppender.java @@ -0,0 +1,48 @@ +/** + * + */ +package com.baeldung.logging.log4j2.plugins; + +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.core.Appender; +import org.apache.logging.log4j.core.Core; +import org.apache.logging.log4j.core.Filter; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.appender.AbstractAppender; +import org.apache.logging.log4j.core.config.plugins.Plugin; +import org.apache.logging.log4j.core.config.plugins.PluginAttribute; +import org.apache.logging.log4j.core.config.plugins.PluginElement; +import org.apache.logging.log4j.core.config.plugins.PluginFactory; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static java.util.Collections.synchronizedList; + +@Plugin(name = "ListAppender", category = Core.CATEGORY_NAME, elementType = Appender.ELEMENT_TYPE) +public class ListAppender extends AbstractAppender { + + private List logList; + + protected ListAppender(String name, Filter filter) { + super(name, filter, null); + logList = synchronizedList(new ArrayList<>()); + } + + @PluginFactory + public static ListAppender createAppender(@PluginAttribute("name") String name, @PluginElement("Filter") final Filter filter) { + return new ListAppender(name, filter); + } + + @Override + public void append(LogEvent event) { + if (event.getLevel() + .isLessSpecificThan(Level.WARN)) { + error("Unable to log less than WARN level."); + return; + } + logList.add(event); + } + +} From 93074cdabc271fb356f30c16837d751313f309cb Mon Sep 17 00:00:00 2001 From: Sampada <46674082+sampada07@users.noreply.github.com> Date: Mon, 4 May 2020 20:36:20 +0530 Subject: [PATCH 429/503] JAVA-929: Migrate spring-cloud-aws to parent-boot-2 (#9230) * JAVA-929: Migrate spring-cloud-aws to parent-boot-2 * JAVA-929: Corrected Live Tests * JAVA-929: Updated README --- spring-cloud/spring-cloud-aws/README.md | 1 - spring-cloud/spring-cloud-aws/pom.xml | 12 +++++++--- .../spring/cloud/aws/s3/SpringCloudS3.java | 24 ++++++++++++------- .../src/main/resources/application.properties | 1 - 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/spring-cloud/spring-cloud-aws/README.md b/spring-cloud/spring-cloud-aws/README.md index bf33728c74..ddcc97420f 100644 --- a/spring-cloud/spring-cloud-aws/README.md +++ b/spring-cloud/spring-cloud-aws/README.md @@ -23,7 +23,6 @@ Let's say that the RDS instance is called `spring-cloud-test-db` having the mast to write the following in `application.properties`: ``` -cloud.aws.rds.spring-cloud-test-db cloud.aws.rds.spring-cloud-test-db.password=se3retpass ``` Multiple application classes are available under this project. To launch InstanceProfileAwsApplication application, replace `start-class` under `pom.xml`: diff --git a/spring-cloud/spring-cloud-aws/pom.xml b/spring-cloud/spring-cloud-aws/pom.xml index abf9363288..2b05020888 100644 --- a/spring-cloud/spring-cloud-aws/pom.xml +++ b/spring-cloud/spring-cloud-aws/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../../parent-boot-1 + ../../parent-boot-2 @@ -43,6 +43,12 @@ org.postgresql postgresql + + + mysql + mysql-connector-java + + @@ -60,7 +66,7 @@ com.baeldung.spring.cloud.aws.SpringCloudAwsApplication Dalston.SR4 - 2.0.1.RELEASE + 2.2.1.RELEASE diff --git a/spring-cloud/spring-cloud-aws/src/main/java/com/baeldung/spring/cloud/aws/s3/SpringCloudS3.java b/spring-cloud/spring-cloud-aws/src/main/java/com/baeldung/spring/cloud/aws/s3/SpringCloudS3.java index cfad6e904f..acfd6d339e 100644 --- a/spring-cloud/spring-cloud-aws/src/main/java/com/baeldung/spring/cloud/aws/s3/SpringCloudS3.java +++ b/spring-cloud/spring-cloud-aws/src/main/java/com/baeldung/spring/cloud/aws/s3/SpringCloudS3.java @@ -1,12 +1,5 @@ package com.baeldung.spring.cloud.aws.s3; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.Resource; -import org.springframework.core.io.ResourceLoader; -import org.springframework.core.io.WritableResource; -import org.springframework.core.io.support.ResourcePatternResolver; -import org.springframework.stereotype.Component; - import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -14,14 +7,29 @@ import java.io.OutputStream; import java.nio.file.Files; import java.nio.file.StandardCopyOption; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cloud.aws.core.io.s3.PathMatchingSimpleStorageResourcePatternResolver; +import org.springframework.context.ApplicationContext; +import org.springframework.core.io.Resource; +import org.springframework.core.io.ResourceLoader; +import org.springframework.core.io.WritableResource; +import org.springframework.core.io.support.ResourcePatternResolver; +import org.springframework.stereotype.Component; + +import com.amazonaws.services.s3.AmazonS3; + @Component public class SpringCloudS3 { @Autowired ResourceLoader resourceLoader; + private ResourcePatternResolver resourcePatternResolver; + @Autowired - ResourcePatternResolver resourcePatternResolver; + public void setupResolver(ApplicationContext applicationContext, AmazonS3 amazonS3) { + this.resourcePatternResolver = new PathMatchingSimpleStorageResourcePatternResolver(amazonS3, applicationContext); + } public void downloadS3Object(String s3Url) throws IOException { Resource resource = resourceLoader.getResource(s3Url); diff --git a/spring-cloud/spring-cloud-aws/src/main/resources/application.properties b/spring-cloud/spring-cloud-aws/src/main/resources/application.properties index 690eda13a2..e8139326b9 100644 --- a/spring-cloud/spring-cloud-aws/src/main/resources/application.properties +++ b/spring-cloud/spring-cloud-aws/src/main/resources/application.properties @@ -2,7 +2,6 @@ cloud.aws.credentials.accessKey=YourAccessKey cloud.aws.credentials.secretKey=YourSecretKey cloud.aws.region.static=us-east-1 -cloud.aws.rds.spring-cloud-test-db cloud.aws.rds.spring-cloud-test-db.password=se3retpass # These 3 properties are optional From b3f1413445507f4c921de74950dce9e7c5f9532d Mon Sep 17 00:00:00 2001 From: marc06210 <47176686+marc06210@users.noreply.github.com> Date: Mon, 4 May 2020 18:03:21 +0200 Subject: [PATCH 430/503] BAEL-3960 (#9070) Bael-3960, asserting log messages with junit code. --- testing-modules/pom.xml | 1 + testing-modules/testing-assertions/pom.xml | 28 ++++++++++ .../baeldung/junit/log/BusinessWorker.java | 16 ++++++ .../src/main/resources/logback.xml | 16 ++++++ .../junit/log/BusinessWorkerUnitTest.java | 48 +++++++++++++++++ .../baeldung/junit/log/MemoryAppender.java | 51 +++++++++++++++++++ .../src/test/resources/logback.xml | 13 +++++ 7 files changed, 173 insertions(+) create mode 100644 testing-modules/testing-assertions/pom.xml create mode 100644 testing-modules/testing-assertions/src/main/java/com/baeldung/junit/log/BusinessWorker.java create mode 100644 testing-modules/testing-assertions/src/main/resources/logback.xml create mode 100644 testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/BusinessWorkerUnitTest.java create mode 100644 testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/MemoryAppender.java create mode 100644 testing-modules/testing-assertions/src/test/resources/logback.xml diff --git a/testing-modules/pom.xml b/testing-modules/pom.xml index 951909b36f..b467b3c503 100644 --- a/testing-modules/pom.xml +++ b/testing-modules/pom.xml @@ -33,6 +33,7 @@ selenium-junit-testng spring-testing test-containers + testing-assertions testng junit-5-basics easymock diff --git a/testing-modules/testing-assertions/pom.xml b/testing-modules/testing-assertions/pom.xml new file mode 100644 index 0000000000..0a7c4b0860 --- /dev/null +++ b/testing-modules/testing-assertions/pom.xml @@ -0,0 +1,28 @@ + + 4.0.0 + testing-assertions + 0.0.1-SNAPSHOT + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../../parent-java + + + + + ch.qos.logback + logback-classic + 1.2.3 + + + org.assertj + assertj-core + 3.15.0 + test + + + diff --git a/testing-modules/testing-assertions/src/main/java/com/baeldung/junit/log/BusinessWorker.java b/testing-modules/testing-assertions/src/main/java/com/baeldung/junit/log/BusinessWorker.java new file mode 100644 index 0000000000..86cd38824c --- /dev/null +++ b/testing-modules/testing-assertions/src/main/java/com/baeldung/junit/log/BusinessWorker.java @@ -0,0 +1,16 @@ +package com.baeldung.junit.log; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class BusinessWorker { + private static Logger LOGGER = LoggerFactory.getLogger(BusinessWorker.class); + + public void generateLogs(String msg) { + LOGGER.trace(msg); + LOGGER.debug(msg); + LOGGER.info(msg); + LOGGER.warn(msg); + LOGGER.error(msg); + } +} diff --git a/testing-modules/testing-assertions/src/main/resources/logback.xml b/testing-modules/testing-assertions/src/main/resources/logback.xml new file mode 100644 index 0000000000..d485da62ff --- /dev/null +++ b/testing-modules/testing-assertions/src/main/resources/logback.xml @@ -0,0 +1,16 @@ + + + + + + %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n + + + + + + + + + + \ No newline at end of file diff --git a/testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/BusinessWorkerUnitTest.java b/testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/BusinessWorkerUnitTest.java new file mode 100644 index 0000000000..9200caf13d --- /dev/null +++ b/testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/BusinessWorkerUnitTest.java @@ -0,0 +1,48 @@ +package com.baeldung.junit.log; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.LoggerFactory; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.Logger; +import ch.qos.logback.classic.LoggerContext; + +public class BusinessWorkerUnitTest { + private static MemoryAppender memoryAppender; + private static final String LOGGER_NAME = "com.baeldung.junit.log"; + private static final String MSG = "This is a test message!!!"; + + @Before + public void setup() { + Logger logger = (Logger) LoggerFactory.getLogger(LOGGER_NAME); + memoryAppender = new MemoryAppender(); + memoryAppender.setContext((LoggerContext) LoggerFactory.getILoggerFactory()); + logger.setLevel(Level.DEBUG); + logger.addAppender(memoryAppender); + memoryAppender.start(); + + } + + @After + public void cleanUp() { + memoryAppender.reset(); + memoryAppender.stop(); + } + + @Test + public void test() { + BusinessWorker worker = new BusinessWorker(); + worker.generateLogs(MSG); + + // I check that I only have 4 messages (all but trace) + assertThat(memoryAppender.countEventsForLogger(LOGGER_NAME)).isEqualTo(4); + // I look for a specific message at a specific level, and I only have 1 + assertThat(memoryAppender.search(MSG, Level.INFO).size()).isEqualTo(1); + // I check that the entry that is not present is the trace level + assertThat(memoryAppender.contains(MSG, Level.TRACE)).isFalse(); + } +} diff --git a/testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/MemoryAppender.java b/testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/MemoryAppender.java new file mode 100644 index 0000000000..31c5c69766 --- /dev/null +++ b/testing-modules/testing-assertions/src/test/java/com/baeldung/junit/log/MemoryAppender.java @@ -0,0 +1,51 @@ +package com.baeldung.junit.log; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.read.ListAppender; + +/** + * In memory slf4j appender
    + * Convenient appender to be able to check slf4j invocations + */ +public class MemoryAppender extends ListAppender { + public void reset() { + this.list.clear(); + } + + public boolean contains(String string, Level level) { + return this.list.stream() + .anyMatch(event -> event.getMessage().toString().contains(string) + && event.getLevel().equals(level)); + } + + public int countEventsForLogger(String loggerName) { + return (int) this.list.stream() + .filter(event -> event.getLoggerName().contains(loggerName)).count(); + } + + public List search(String string) { + return this.list.stream() + .filter(event -> event.getMessage().toString().contains(string)) + .collect(Collectors.toList()); + } + + public List search(String string, Level level) { + return this.list.stream() + .filter(event -> event.getMessage().toString().contains(string) + && event.getLevel().equals(level)) + .collect(Collectors.toList()); + } + + public int getSize() { + return this.list.size(); + } + + public List getLoggedEvents() { + return Collections.unmodifiableList(this.list); + } +} diff --git a/testing-modules/testing-assertions/src/test/resources/logback.xml b/testing-modules/testing-assertions/src/test/resources/logback.xml new file mode 100644 index 0000000000..980ce897ff --- /dev/null +++ b/testing-modules/testing-assertions/src/test/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + + %d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n + + + + + + + \ No newline at end of file From ab9e0e164fe3662deaf3697f5e8cfa440217eac6 Mon Sep 17 00:00:00 2001 From: Roque Santos Date: Mon, 4 May 2020 13:37:38 -0300 Subject: [PATCH 431/503] BAEL-3842 : How to add proxy support to Jsoup (#9202) --- .../jsonproxy/JsoupProxyIntegrationTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 jsoup/src/test/java/com/baeldung/jsonproxy/JsoupProxyIntegrationTest.java diff --git a/jsoup/src/test/java/com/baeldung/jsonproxy/JsoupProxyIntegrationTest.java b/jsoup/src/test/java/com/baeldung/jsonproxy/JsoupProxyIntegrationTest.java new file mode 100644 index 0000000000..8e854ead6a --- /dev/null +++ b/jsoup/src/test/java/com/baeldung/jsonproxy/JsoupProxyIntegrationTest.java @@ -0,0 +1,27 @@ +package com.baeldung.jsonproxy; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.Proxy; + +import org.jsoup.Jsoup; +import org.junit.Test; + +public class JsoupProxyIntegrationTest { + + @Test + public void whenUsingHostAndPort_thenConnect() throws IOException { + Jsoup.connect("https://spring.io/blog") + .proxy("200.216.227.141", 53281) + .get(); + } + + @Test + public void whenUsingProxyClass_thenConnect() throws IOException { + Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("200.216.227.141", 53281)); + + Jsoup.connect("https://spring.io/blog") + .proxy(proxy) + .get(); + } +} From aee002eecaae940b0164a5ec44b136a00f794406 Mon Sep 17 00:00:00 2001 From: Benjamin Caure Date: Mon, 4 May 2020 22:00:03 +0200 Subject: [PATCH 432/503] rename integration to live test (#9232) --- ...ationTest.java => BsonToJsonLiveTest.java} | 284 +++++++++--------- 1 file changed, 142 insertions(+), 142 deletions(-) rename persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/{BsonToJsonIntegrationTest.java => BsonToJsonLiveTest.java} (96%) diff --git a/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonIntegrationTest.java b/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonLiveTest.java similarity index 96% rename from persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonIntegrationTest.java rename to persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonLiveTest.java index e382ea4ab2..4e70394069 100644 --- a/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonIntegrationTest.java +++ b/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonLiveTest.java @@ -1,142 +1,142 @@ -package com.baeldung.bsontojson; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.sql.Timestamp; -import java.time.Instant; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Date; -import java.util.TimeZone; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.bson.Document; -import org.bson.json.Converter; -import org.bson.json.JsonMode; -import org.bson.json.JsonWriterSettings; -import org.bson.json.StrictJsonWriter; -import org.bson.types.ObjectId; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.jupiter.api.AfterEach; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.baeldung.morphia.domain.Book; -import com.baeldung.morphia.domain.Publisher; -import com.mongodb.MongoClient; -import com.mongodb.client.MongoDatabase; - -import dev.morphia.Datastore; -import dev.morphia.Morphia; - -public class BsonToJsonIntegrationTest { - - private static final String DB_NAME = "library"; - private static Datastore datastore; - - @BeforeClass - public static void setUp() { - Morphia morphia = new Morphia(); - morphia.mapPackage("com.baeldung.morphia"); - datastore = morphia.createDatastore(new MongoClient(), DB_NAME); - datastore.ensureIndexes(); - - datastore.save(new Book() - .setIsbn("isbn") - .setTitle("title") - .setAuthor("author") - .setCost(3.95) - .setPublisher(new Publisher(new ObjectId("fffffffffffffffffffffffa"),"publisher")) - .setPublishDate(LocalDateTime.parse("2020-01-01T18:13:32Z", DateTimeFormatter.ISO_DATE_TIME)) - .addCompanionBooks(new Book().setIsbn("isbn2"))); - } - - @AfterClass - public static void tearDown() { - datastore.delete(datastore.createQuery(Book.class)); - } - - @Test - public void givenBsonDocument_whenUsingStandardJsonTransformation_thenJsonDateIsObjectEpochTime() { - - String json = null; - try (MongoClient mongoClient = new MongoClient()) { - MongoDatabase mongoDatabase = mongoClient.getDatabase(DB_NAME); - Document bson = mongoDatabase.getCollection("Books").find().first(); - json = bson.toJson(); - } - - String expectedJson = "{\"_id\": \"isbn\", " + - "\"className\": \"com.baeldung.morphia.domain.Book\", " + - "\"title\": \"title\", " + - "\"author\": \"author\", " + - "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " + - "\"name\": \"publisher\"}, " + - "\"price\": 3.95, " + - "\"publishDate\": {\"$date\": 1577898812000}}"; - - assertNotNull(json); - - assertEquals(expectedJson, json); - } - - - @Test - public void givenBsonDocument_whenUsingRelaxedJsonTransformation_thenJsonDateIsObjectIsoDate() { - - String json = null; - try (MongoClient mongoClient = new MongoClient()) { - MongoDatabase mongoDatabase = mongoClient.getDatabase(DB_NAME); - Document bson = mongoDatabase.getCollection("Books").find().first(); - json = bson.toJson(JsonWriterSettings - .builder() - .outputMode(JsonMode.RELAXED) - .build()); - } - - String expectedJson = "{\"_id\": \"isbn\", " + - "\"className\": \"com.baeldung.morphia.domain.Book\", " + - "\"title\": \"title\", " + - "\"author\": \"author\", " + - "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " + - "\"name\": \"publisher\"}, " + - "\"price\": 3.95, " + - "\"publishDate\": {\"$date\": \"2020-01-01T17:13:32Z\"}}"; - - assertNotNull(json); - - assertEquals(expectedJson, json); - } - - @Test - public void givenBsonDocument_whenUsingCustomJsonTransformation_thenJsonDateIsStringField() { - - String json = null; - try (MongoClient mongoClient = new MongoClient()) { - MongoDatabase mongoDatabase = mongoClient.getDatabase(DB_NAME); - Document bson = mongoDatabase.getCollection("Books").find().first(); - json = bson.toJson(JsonWriterSettings - .builder() - .dateTimeConverter(new JsonDateTimeConverter()) - .build()); - } - - String expectedJson = "{\"_id\": \"isbn\", " + - "\"className\": \"com.baeldung.morphia.domain.Book\", " + - "\"title\": \"title\", " + - "\"author\": \"author\", " + - "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " + - "\"name\": \"publisher\"}, " + - "\"price\": 3.95, " + - "\"publishDate\": \"2020-01-01T17:13:32Z\"}"; - - assertEquals(expectedJson, json); - - } - -} +package com.baeldung.bsontojson; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.sql.Timestamp; +import java.time.Instant; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.TimeZone; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.bson.Document; +import org.bson.json.Converter; +import org.bson.json.JsonMode; +import org.bson.json.JsonWriterSettings; +import org.bson.json.StrictJsonWriter; +import org.bson.types.ObjectId; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.baeldung.morphia.domain.Book; +import com.baeldung.morphia.domain.Publisher; +import com.mongodb.MongoClient; +import com.mongodb.client.MongoDatabase; + +import dev.morphia.Datastore; +import dev.morphia.Morphia; + +public class BsonToJsonLiveTest { + + private static final String DB_NAME = "library"; + private static Datastore datastore; + + @BeforeClass + public static void setUp() { + Morphia morphia = new Morphia(); + morphia.mapPackage("com.baeldung.morphia"); + datastore = morphia.createDatastore(new MongoClient(), DB_NAME); + datastore.ensureIndexes(); + + datastore.save(new Book() + .setIsbn("isbn") + .setTitle("title") + .setAuthor("author") + .setCost(3.95) + .setPublisher(new Publisher(new ObjectId("fffffffffffffffffffffffa"),"publisher")) + .setPublishDate(LocalDateTime.parse("2020-01-01T18:13:32Z", DateTimeFormatter.ISO_DATE_TIME)) + .addCompanionBooks(new Book().setIsbn("isbn2"))); + } + + @AfterClass + public static void tearDown() { + datastore.delete(datastore.createQuery(Book.class)); + } + + @Test + public void givenBsonDocument_whenUsingStandardJsonTransformation_thenJsonDateIsObjectEpochTime() { + + String json = null; + try (MongoClient mongoClient = new MongoClient()) { + MongoDatabase mongoDatabase = mongoClient.getDatabase(DB_NAME); + Document bson = mongoDatabase.getCollection("Books").find().first(); + json = bson.toJson(); + } + + String expectedJson = "{\"_id\": \"isbn\", " + + "\"className\": \"com.baeldung.morphia.domain.Book\", " + + "\"title\": \"title\", " + + "\"author\": \"author\", " + + "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " + + "\"name\": \"publisher\"}, " + + "\"price\": 3.95, " + + "\"publishDate\": {\"$date\": 1577898812000}}"; + + assertNotNull(json); + + assertEquals(expectedJson, json); + } + + + @Test + public void givenBsonDocument_whenUsingRelaxedJsonTransformation_thenJsonDateIsObjectIsoDate() { + + String json = null; + try (MongoClient mongoClient = new MongoClient()) { + MongoDatabase mongoDatabase = mongoClient.getDatabase(DB_NAME); + Document bson = mongoDatabase.getCollection("Books").find().first(); + json = bson.toJson(JsonWriterSettings + .builder() + .outputMode(JsonMode.RELAXED) + .build()); + } + + String expectedJson = "{\"_id\": \"isbn\", " + + "\"className\": \"com.baeldung.morphia.domain.Book\", " + + "\"title\": \"title\", " + + "\"author\": \"author\", " + + "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " + + "\"name\": \"publisher\"}, " + + "\"price\": 3.95, " + + "\"publishDate\": {\"$date\": \"2020-01-01T17:13:32Z\"}}"; + + assertNotNull(json); + + assertEquals(expectedJson, json); + } + + @Test + public void givenBsonDocument_whenUsingCustomJsonTransformation_thenJsonDateIsStringField() { + + String json = null; + try (MongoClient mongoClient = new MongoClient()) { + MongoDatabase mongoDatabase = mongoClient.getDatabase(DB_NAME); + Document bson = mongoDatabase.getCollection("Books").find().first(); + json = bson.toJson(JsonWriterSettings + .builder() + .dateTimeConverter(new JsonDateTimeConverter()) + .build()); + } + + String expectedJson = "{\"_id\": \"isbn\", " + + "\"className\": \"com.baeldung.morphia.domain.Book\", " + + "\"title\": \"title\", " + + "\"author\": \"author\", " + + "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " + + "\"name\": \"publisher\"}, " + + "\"price\": 3.95, " + + "\"publishDate\": \"2020-01-01T17:13:32Z\"}"; + + assertEquals(expectedJson, json); + + } + +} From 2d7bc17dda09aa2a524963ec5f3a3739e977fdd7 Mon Sep 17 00:00:00 2001 From: SippingCode <55111084+SippingCode@users.noreply.github.com> Date: Tue, 5 May 2020 00:08:00 +0200 Subject: [PATCH 433/503] Bael 3970 (#9236) * Manual logout with Spring Security - Basic manual logout - logout with Clear Data Site Header * Add missing annotation for controller. Change mapping URL value. * Add intergration tests for manual logouts. * BAEL-3970 - Add asserts on test. Fix tests names. Remove unused imports. * BAEL-3970 - Use PostMapping annotation. Remove unnecessary information for security configuration. * remove logout controllers * Add multiple entrypoints configurations. Create custom handlers for different logouts (basic, cookie clearing, clear-site-data). * Refactor configuration with lambda DSL. * BAEL-3970 - Remove unnecessary handler for basic logout. Fix integration tests for basic logout. --- .../SimpleSecurityConfiguration.java | 58 +++++++++---------- .../ManualLogoutIntegrationTest.java | 9 +-- 2 files changed, 29 insertions(+), 38 deletions(-) diff --git a/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java b/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java index 63394b64f2..08c2d83b99 100644 --- a/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java +++ b/spring-5-security/src/main/java/com/baeldung/manuallogout/SimpleSecurityConfiguration.java @@ -2,14 +2,12 @@ package com.baeldung.manuallogout; import org.springframework.context.annotation.Configuration; import org.springframework.core.annotation.Order; -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.web.authentication.logout.CookieClearingLogoutHandler; import org.springframework.security.web.authentication.logout.HeaderWriterLogoutHandler; import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler; -import org.springframework.security.web.authentication.rememberme.AbstractRememberMeServices; import org.springframework.security.web.header.writers.ClearSiteDataHeaderWriter; import javax.servlet.http.Cookie; @@ -26,13 +24,11 @@ public class SimpleSecurityConfiguration { @Override protected void configure(HttpSecurity http) throws Exception { http - .antMatcher("/basic/**") - .authorizeRequests(authz -> authz.anyRequest().permitAll()) - .logout(logout -> logout - .logoutUrl("/basic/basiclogout") - .addLogoutHandler(new SecurityContextLogoutHandler()) - .addLogoutHandler(new CookieClearingLogoutHandler(AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY)) - ); + .antMatcher("/basic/**") + .authorizeRequests(authz -> authz.anyRequest().permitAll()) + .logout(logout -> logout + .logoutUrl("/basic/basiclogout") + ); } } @@ -42,20 +38,20 @@ public class SimpleSecurityConfiguration { @Override protected void configure(HttpSecurity http) throws Exception { http - .antMatcher("/cookies/**") - .authorizeRequests(authz -> authz.anyRequest().permitAll()) - .logout(logout -> logout - .logoutUrl("/cookies/cookielogout") - .addLogoutHandler(new SecurityContextLogoutHandler()) - .addLogoutHandler((request, response, auth) -> { - for (Cookie cookie : request.getCookies()) { - String cookieName = cookie.getName(); - Cookie cookieToDelete = new Cookie(cookieName, null); - cookieToDelete.setMaxAge(0); - response.addCookie(cookieToDelete); - } - } - )); + .antMatcher("/cookies/**") + .authorizeRequests(authz -> authz.anyRequest().permitAll()) + .logout(logout -> logout + .logoutUrl("/cookies/cookielogout") + .addLogoutHandler(new SecurityContextLogoutHandler()) + .addLogoutHandler((request, response, auth) -> { + for (Cookie cookie : request.getCookies()) { + String cookieName = cookie.getName(); + Cookie cookieToDelete = new Cookie(cookieName, null); + cookieToDelete.setMaxAge(0); + response.addCookie(cookieToDelete); + } + }) + ); } } @@ -64,17 +60,17 @@ public class SimpleSecurityConfiguration { public static class ClearSiteDataHeaderLogoutConfiguration extends WebSecurityConfigurerAdapter { private static final ClearSiteDataHeaderWriter.Directive[] SOURCE = - { CACHE, COOKIES, STORAGE, EXECUTION_CONTEXTS }; + {CACHE, COOKIES, STORAGE, EXECUTION_CONTEXTS}; @Override protected void configure(HttpSecurity http) throws Exception { http - .antMatcher("/csd/**") - .authorizeRequests(authz -> authz.anyRequest().permitAll()) - .logout(logout -> logout - .logoutUrl("/csd/csdlogout") - .addLogoutHandler(new HeaderWriterLogoutHandler(new ClearSiteDataHeaderWriter(SOURCE))) - ); + .antMatcher("/csd/**") + .authorizeRequests(authz -> authz.anyRequest().permitAll()) + .logout(logout -> logout + .logoutUrl("/csd/csdlogout") + .addLogoutHandler(new HeaderWriterLogoutHandler(new ClearSiteDataHeaderWriter(SOURCE))) + ); } } } diff --git a/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java b/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java index 09e7daf877..8909dc2620 100644 --- a/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java +++ b/spring-5-security/src/test/java/com/baeldung/manuallogout/ManualLogoutIntegrationTest.java @@ -39,15 +39,10 @@ public class ManualLogoutIntegrationTest { @Test public void givenLoggedUserWhenUserLogoutThenSessionClearedAndNecessaryCookieCleared() throws Exception { - MockHttpServletRequest requestStateAfterLogout = this.mockMvc.perform(post("/basic/basiclogout").secure(true).with(csrf())) + this.mockMvc.perform(post("/basic/basiclogout").secure(true).with(csrf())) .andExpect(status().is3xxRedirection()) .andExpect(unauthenticated()) - .andExpect(cookie().maxAge(AbstractRememberMeServices.SPRING_SECURITY_REMEMBER_ME_COOKIE_KEY, 0)) - .andReturn() - .getRequest(); - - HttpSession sessionStateAfterLogout = requestStateAfterLogout.getSession(); - assertNull(sessionStateAfterLogout.getAttribute(ATTRIBUTE_NAME)); + .andReturn(); } @WithMockUser(value = "spring") From 7f4368556772836b2dd53b3360c8a735b742290b Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 08:35:36 +0800 Subject: [PATCH 434/503] Update README.md --- libraries-3/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries-3/README.md b/libraries-3/README.md index ec433960ef..62bd3b9f66 100644 --- a/libraries-3/README.md +++ b/libraries-3/README.md @@ -16,4 +16,3 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Introduction to Takes](https://www.baeldung.com/java-takes) - [Using NullAway to Avoid NullPointerExceptions](https://www.baeldung.com/java-nullaway) - [Introduction to Alibaba Arthas](https://www.baeldung.com/java-alibaba-arthas-intro) -- [Quick Guide to Spring Cloud Circuit Breaker](https://www.baeldung.com/spring-cloud-circuit-breaker) From dd4b25e855a1a94127f73420b92f1ee285cb3123 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 08:43:18 +0800 Subject: [PATCH 435/503] Update README.md --- spring-mvc-basics-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-mvc-basics-2/README.md b/spring-mvc-basics-2/README.md index e52459bd6e..673b7b1fef 100644 --- a/spring-mvc-basics-2/README.md +++ b/spring-mvc-basics-2/README.md @@ -9,7 +9,7 @@ This module contains articles about Spring MVC - [Servlet Redirect vs Forward](https://www.baeldung.com/servlet-redirect-forward) - [Apache Tiles Integration with Spring MVC](https://www.baeldung.com/spring-mvc-apache-tiles) - [Guide to Spring Email](https://www.baeldung.com/spring-email) -- [Using ThymeLeaf and FreeMarker Emails Templates with Spring](https://www.baeldung.com/thymeleaf-freemarker-email) +- [Using ThymeLeaf and FreeMarker Emails Templates with Spring](https://www.baeldung.com/spring-email-templates) - [Request Method Not Supported (405) in Spring](https://www.baeldung.com/spring-request-method-not-supported-405) - [Spring @RequestParam Annotation](https://www.baeldung.com/spring-request-param) - More articles: [[more -->]](/spring-mvc-basics-3) From 1f95843c36f170d285b432d61091d7989b89cbdd Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 08:47:17 +0800 Subject: [PATCH 436/503] Delete README.md --- bazel/bazelapp/README.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 bazel/bazelapp/README.md diff --git a/bazel/bazelapp/README.md b/bazel/bazelapp/README.md deleted file mode 100644 index 528f797c21..0000000000 --- a/bazel/bazelapp/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: - -- [Building Java Applications with Bazel](https://www.baeldung.com/bazel-build-tool) From e164ae4c72a806049f4054947b28c3df1194a0e0 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 08:53:16 +0800 Subject: [PATCH 437/503] Delete README.md --- oauth2-framework-impl/oauth2-authorization-server/README.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 oauth2-framework-impl/oauth2-authorization-server/README.md diff --git a/oauth2-framework-impl/oauth2-authorization-server/README.md b/oauth2-framework-impl/oauth2-authorization-server/README.md deleted file mode 100644 index 4bcb9790b1..0000000000 --- a/oauth2-framework-impl/oauth2-authorization-server/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) From 33fa3b7275fe96aaee04a14f7f8a9dfcdb1aca59 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 08:57:04 +0800 Subject: [PATCH 438/503] Delete README.md --- oauth2-framework-impl/oauth2-resource-server/README.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 oauth2-framework-impl/oauth2-resource-server/README.md diff --git a/oauth2-framework-impl/oauth2-resource-server/README.md b/oauth2-framework-impl/oauth2-resource-server/README.md deleted file mode 100644 index 4bcb9790b1..0000000000 --- a/oauth2-framework-impl/oauth2-resource-server/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) From caca2dbea73fa638ff7fd24d2798c0296bf07e99 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 09:00:24 +0800 Subject: [PATCH 439/503] Update README.md --- spring-swagger-codegen/spring-swagger-codegen-app/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-swagger-codegen/spring-swagger-codegen-app/README.md b/spring-swagger-codegen/spring-swagger-codegen-app/README.md index 1cb9e35d99..8740b17ba3 100644 --- a/spring-swagger-codegen/spring-swagger-codegen-app/README.md +++ b/spring-swagger-codegen/spring-swagger-codegen-app/README.md @@ -1,3 +1,3 @@ ## Spring Swagger Codegen App -This module contains the code for [Generate Spring Boot REST Client with Swagger](http://www.baeldung.com/spring-boot-rest-client-swagger-codegen). +This module contains the code for Generate Spring Boot REST Client with Swagger. From 0167480f880aae12f1af7bfd5a6b7ce81a7eb6e4 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 09:21:38 +0800 Subject: [PATCH 440/503] Update README.md --- core-java-modules/core-java-concurrency-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-java-modules/core-java-concurrency-2/README.md b/core-java-modules/core-java-concurrency-2/README.md index ab7eebc26a..23471a237e 100644 --- a/core-java-modules/core-java-concurrency-2/README.md +++ b/core-java-modules/core-java-concurrency-2/README.md @@ -4,5 +4,5 @@ ### Relevant Articles: - [Using a Mutex Object in Java](https://www.baeldung.com/java-mutex) -- [Testing Multi-Threaded Code in Java] (https://www.baeldung.com/java-testing-multithreaded) +- [Testing Multi-Threaded Code in Java](https://www.baeldung.com/java-testing-multithreaded) From 714d60351b93e1dac87065e88e8c27dc93075217 Mon Sep 17 00:00:00 2001 From: Kirill Vlasov Date: Tue, 5 May 2020 11:44:30 +0500 Subject: [PATCH 441/503] Replacing postgres database with h2 for integration test --- .../resources/customlogouthandler/application.properties | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/application.properties b/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/application.properties index 9edd853f2c..84347c2664 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/application.properties +++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/resources/customlogouthandler/application.properties @@ -1,5 +1,4 @@ -spring.datasource.url=jdbc:postgresql://localhost:5432/test +spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.url=jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE spring.datasource.username=test -spring.datasource.password=test - -spring.jpa.hibernate.ddl-auto=create +spring.datasource.password=test \ No newline at end of file From d95a78b1924fe104b8de116bfc8c4e306ec52199 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 15:26:18 +0800 Subject: [PATCH 442/503] Update README.md --- spring-core-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-core-2/README.md b/spring-core-2/README.md index 947b816db8..10d3080b45 100644 --- a/spring-core-2/README.md +++ b/spring-core-2/README.md @@ -14,4 +14,5 @@ This module contains articles about core Spring functionality - [Spring Events](https://www.baeldung.com/spring-events) - [Spring Null-Safety Annotations](https://www.baeldung.com/spring-null-safety-annotations) - [Using @Autowired in Abstract Classes](https://www.baeldung.com/spring-autowired-abstract-class) +- [Running Setup Data on Startup in Spring](https://www.baeldung.com/running-setup-logic-on-startup-in-spring) - More articles: [[<-- prev]](/spring-core)[[next -->]](/spring-core-3) From 0cad7c5cc584059d15901f9270214e07dc533294 Mon Sep 17 00:00:00 2001 From: Eduard Ardeleanu Date: Tue, 5 May 2020 10:37:20 +0300 Subject: [PATCH 443/503] BAEL-3971: Generate DDL script in Spring (#9120) * BAEL-3971: Generate DDL script in Spring * BAEL-3971: implement review comments * BAEL-3971: fix typo * BAEL-3971: move code examples to module spring-data-jpa-5 Co-authored-by: ashleyfrieze --- persistence-modules/pom.xml | 1 + .../spring-data-jpa-5/README.md | 2 + persistence-modules/spring-data-jpa-5/pom.xml | 2 +- .../schemageneration/AccountApplication.java | 12 +++ .../schemageneration/HibernateUtil.java | 39 ++++++++++ .../schemageneration/model/Account.java | 74 +++++++++++++++++++ .../model/AccountSetting.java | 68 +++++++++++++++++ .../repository/AccountRepository.java | 8 ++ .../repository/AccountSettingRepository.java | 8 ++ .../src/main/resources/application.properties | 11 +++ .../AccountRepositoryIntegrationTest.java | 72 ++++++++++++++++++ .../resources/application-test.properties | 2 + 12 files changed, 298 insertions(+), 1 deletion(-) create mode 100644 persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/AccountApplication.java create mode 100644 persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/HibernateUtil.java create mode 100644 persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/model/Account.java create mode 100644 persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/model/AccountSetting.java create mode 100644 persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/repository/AccountRepository.java create mode 100644 persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/repository/AccountSettingRepository.java create mode 100644 persistence-modules/spring-data-jpa-5/src/test/java/com/baeldung/schemageneration/AccountRepositoryIntegrationTest.java diff --git a/persistence-modules/pom.xml b/persistence-modules/pom.xml index ec7f0bcec2..78da896861 100644 --- a/persistence-modules/pom.xml +++ b/persistence-modules/pom.xml @@ -61,6 +61,7 @@ spring-data-jpa-2 spring-data-jpa-3 spring-data-jpa-4 + spring-data-jpa-5 spring-data-keyvalue spring-data-mongodb spring-data-neo4j diff --git a/persistence-modules/spring-data-jpa-5/README.md b/persistence-modules/spring-data-jpa-5/README.md index dd4ac22e4a..e8f83654df 100644 --- a/persistence-modules/spring-data-jpa-5/README.md +++ b/persistence-modules/spring-data-jpa-5/README.md @@ -1,4 +1,5 @@ ### Relevant Articles: + - [Spring JPA @Embedded and @EmbeddedId](TBD) ### Eclipse Config @@ -9,3 +10,4 @@ This can be ignored: - Project -> Properties -> Java Persistance -> JPA -> Error/Warnings -> Select Ignore on "No persistence xml file found in project" Or: - Eclipse -> Preferences - Validation - disable the "Build" execution of the JPA Validator + diff --git a/persistence-modules/spring-data-jpa-5/pom.xml b/persistence-modules/spring-data-jpa-5/pom.xml index 7f2c724f98..3053384559 100644 --- a/persistence-modules/spring-data-jpa-5/pom.xml +++ b/persistence-modules/spring-data-jpa-5/pom.xml @@ -33,5 +33,5 @@ h2 - + diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/AccountApplication.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/AccountApplication.java new file mode 100644 index 0000000000..547992a6c1 --- /dev/null +++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/AccountApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.schemageneration; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class AccountApplication { + + public static void main(String[] args) { + SpringApplication.run(AccountApplication.class, args); + } +} diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/HibernateUtil.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/HibernateUtil.java new file mode 100644 index 0000000000..7d69d65705 --- /dev/null +++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/HibernateUtil.java @@ -0,0 +1,39 @@ +package com.baeldung.schemageneration; + +import com.baeldung.schemageneration.model.Account; +import com.baeldung.schemageneration.model.AccountSetting; +import org.hibernate.boot.Metadata; +import org.hibernate.boot.MetadataSources; +import org.hibernate.boot.registry.StandardServiceRegistry; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.cfg.Environment; +import org.hibernate.tool.hbm2ddl.SchemaExport; +import org.hibernate.tool.schema.TargetType; + +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Map; + +public class HibernateUtil { + + /** + * Generates database create commands for the specified entities using Hibernate native API, SchemaExport. + * Creation commands are exported into the create.sql file. + */ + public static void generateSchema() { + Map settings = new HashMap<>(); + settings.put(Environment.URL, "jdbc:h2:mem:schema"); + + StandardServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(settings).build(); + + MetadataSources metadataSources = new MetadataSources(serviceRegistry); + metadataSources.addAnnotatedClass(Account.class); + metadataSources.addAnnotatedClass(AccountSetting.class); + Metadata metadata = metadataSources.buildMetadata(); + + SchemaExport schemaExport = new SchemaExport(); + schemaExport.setFormat(true); + schemaExport.setOutputFile("create.sql"); + schemaExport.createOnly(EnumSet.of(TargetType.SCRIPT), metadata); + } +} diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/model/Account.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/model/Account.java new file mode 100644 index 0000000000..785e275e26 --- /dev/null +++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/model/Account.java @@ -0,0 +1,74 @@ +package com.baeldung.schemageneration.model; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import java.util.ArrayList; +import java.util.List; + +@Entity +@Table(name = "accounts") +public class Account { + + @Id + @GeneratedValue + private Long id; + + @Column(nullable = false, length = 100) + private String name; + + @Column(name = "email_address") + private String emailAddress; + + @OneToMany(mappedBy = "account", cascade = CascadeType.ALL) + private List accountSettings = new ArrayList<>(); + + public Account() { + } + + public Account(String name, String emailAddress) { + this.name = name; + this.emailAddress = emailAddress; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmailAddress() { + return emailAddress; + } + + public void setEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + } + + public List getAccountSettings() { + return accountSettings; + } + + public void setAccountSettings(List accountSettings) { + this.accountSettings = accountSettings; + } + + public void addAccountSetting(AccountSetting setting) { + this.accountSettings.add(setting); + setting.setAccount(this); + } +} diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/model/AccountSetting.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/model/AccountSetting.java new file mode 100644 index 0000000000..61e43894a8 --- /dev/null +++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/model/AccountSetting.java @@ -0,0 +1,68 @@ +package com.baeldung.schemageneration.model; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +@Entity +@Table(name = "account_settings") +public class AccountSetting { + + @Id + @GeneratedValue + private Long id; + + @Column(name = "name", nullable = false) + private String settingName; + + @Column(name = "value", nullable = false) + private String settingValue; + + @ManyToOne() + @JoinColumn(name ="account_id", nullable = false) + private Account account; + + public AccountSetting() { + } + + public AccountSetting(String settingName, String settingValue) { + this.settingName = settingName; + this.settingValue = settingValue; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getSettingName() { + return settingName; + } + + public void setSettingName(String settingName) { + this.settingName = settingName; + } + + public String getSettingValue() { + return settingValue; + } + + public void setSettingValue(String settingValue) { + this.settingValue = settingValue; + } + + public Account getAccount() { + return account; + } + + public void setAccount(Account account) { + this.account = account; + } +} diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/repository/AccountRepository.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/repository/AccountRepository.java new file mode 100644 index 0000000000..dc57ffe6d3 --- /dev/null +++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/repository/AccountRepository.java @@ -0,0 +1,8 @@ +package com.baeldung.schemageneration.repository; + +import com.baeldung.schemageneration.model.Account; +import org.springframework.data.repository.CrudRepository; + +public interface AccountRepository extends CrudRepository { + Account findByName(String name); +} diff --git a/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/repository/AccountSettingRepository.java b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/repository/AccountSettingRepository.java new file mode 100644 index 0000000000..c2b8ff7398 --- /dev/null +++ b/persistence-modules/spring-data-jpa-5/src/main/java/com/baeldung/schemageneration/repository/AccountSettingRepository.java @@ -0,0 +1,8 @@ +package com.baeldung.schemageneration.repository; + +import com.baeldung.schemageneration.model.AccountSetting; +import org.springframework.data.repository.CrudRepository; + +public interface AccountSettingRepository extends CrudRepository { + AccountSetting findByAccountId(Long accountId); +} diff --git a/persistence-modules/spring-data-jpa-5/src/main/resources/application.properties b/persistence-modules/spring-data-jpa-5/src/main/resources/application.properties index dfc5e56e33..f55ad438ff 100644 --- a/persistence-modules/spring-data-jpa-5/src/main/resources/application.properties +++ b/persistence-modules/spring-data-jpa-5/src/main/resources/application.properties @@ -1,2 +1,13 @@ + +spring.datasource.url=jdbc:h2:mem:baeldung + +# JPA-Schema-Generation +# Use below configuration to generate database schema create commands based on the entity models +# and export them into the create.sql file +#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create +#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=create.sql +#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-source=metadata +#spring.jpa.properties.hibernate.format_sql=true + spring.jpa.show-sql=true diff --git a/persistence-modules/spring-data-jpa-5/src/test/java/com/baeldung/schemageneration/AccountRepositoryIntegrationTest.java b/persistence-modules/spring-data-jpa-5/src/test/java/com/baeldung/schemageneration/AccountRepositoryIntegrationTest.java new file mode 100644 index 0000000000..86a7671fe4 --- /dev/null +++ b/persistence-modules/spring-data-jpa-5/src/test/java/com/baeldung/schemageneration/AccountRepositoryIntegrationTest.java @@ -0,0 +1,72 @@ +package com.baeldung.schemageneration; + +import com.baeldung.schemageneration.model.Account; +import com.baeldung.schemageneration.model.AccountSetting; +import com.baeldung.schemageneration.repository.AccountRepository; +import com.baeldung.schemageneration.repository.AccountSettingRepository; +import org.junit.After; +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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = AccountApplication.class) +public class AccountRepositoryIntegrationTest { + + private static final String USER_NAME = "Eduard"; + private static final String USER_EMAIL_ADDRESS = "eduard@gmx.com"; + private static final String ACCOUNT_SETTING_NAME = "Timezone"; + private static final String ACCOUNT_SETTING_VALUE = "UTC+02"; + + @Autowired + private AccountRepository accountRepository; + + @Autowired + private AccountSettingRepository accountSettingRepository; + + @After + public void tearDown() { + accountRepository.deleteAll(); + } + + @Test + public void givenNewAccount_whenSave_thenSuccess() { + Account account = new Account(USER_NAME, USER_EMAIL_ADDRESS); + accountRepository.save(account); + + assertEquals(1, accountRepository.count()); + } + + @Test + public void givenSavedAccount_whenFindByName_thenFound() { + Account account = new Account(USER_NAME, USER_EMAIL_ADDRESS); + accountRepository.save(account); + + Account accountFound = accountRepository.findByName(USER_NAME); + + assertNotNull(accountFound); + assertEquals(USER_NAME, accountFound.getName()); + assertEquals(USER_EMAIL_ADDRESS, accountFound.getEmailAddress()); + } + + @Test + public void givenSavedAccount_whenAccountSettingIsAdded_thenPersisted() { + Account account = new Account(USER_NAME, USER_EMAIL_ADDRESS); + account.addAccountSetting(new AccountSetting(ACCOUNT_SETTING_NAME, ACCOUNT_SETTING_VALUE)); + accountRepository.save(account); + + Account accountFound = accountRepository.findByName(USER_NAME); + assertNotNull(accountFound); + AccountSetting accountSetting = accountSettingRepository.findByAccountId(accountFound.getId()); + + assertNotNull(accountSetting); + assertEquals(ACCOUNT_SETTING_NAME, accountSetting.getSettingName()); + assertEquals(ACCOUNT_SETTING_VALUE, accountSetting.getSettingValue()); + } + +} diff --git a/persistence-modules/spring-data-jpa-5/src/test/resources/application-test.properties b/persistence-modules/spring-data-jpa-5/src/test/resources/application-test.properties index 207de2e8ec..e3d39fe1e2 100644 --- a/persistence-modules/spring-data-jpa-5/src/test/resources/application-test.properties +++ b/persistence-modules/spring-data-jpa-5/src/test/resources/application-test.properties @@ -1 +1,3 @@ spring.jpa.hibernate.ddl-auto=update +spring.datasource.url=jdbc:h2:mem:baeldung + From efa810462107cdbc98de292f81eb4c7c1c72fccd Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 16:42:15 +0800 Subject: [PATCH 444/503] Update README.md --- spring-thymeleaf-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-thymeleaf-2/README.md b/spring-thymeleaf-2/README.md index d5c5ead43d..d2d10f81da 100644 --- a/spring-thymeleaf-2/README.md +++ b/spring-thymeleaf-2/README.md @@ -13,4 +13,5 @@ This module contains articles about Spring with Thymeleaf - [Working with Boolean in Thymeleaf](https://www.baeldung.com/thymeleaf-boolean) - [Working With Custom HTML Attributes in Thymeleaf](https://www.baeldung.com/thymeleaf-custom-html-attributes) - [How to Create an Executable JAR with Maven](https://www.baeldung.com/executable-jar-with-maven) +- [https://www.baeldung.com/spring-mvc-thymeleaf-data](https://www.baeldung.com/spring-mvc-thymeleaf-data) - [[<-- prev]](/spring-thymeleaf) From 66cf67cc7c6ac5b21efbcf47fd50ef2f466c598a Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 16:45:16 +0800 Subject: [PATCH 445/503] Update README.md --- spring-cloud/spring-cloud-circuit-breaker/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-cloud/spring-cloud-circuit-breaker/README.md b/spring-cloud/spring-cloud-circuit-breaker/README.md index 040eb0ccee..894be93408 100644 --- a/spring-cloud/spring-cloud-circuit-breaker/README.md +++ b/spring-cloud/spring-cloud-circuit-breaker/README.md @@ -3,3 +3,5 @@ This module contains articles about Spring Cloud Circuit Breaker ### Relevant Articles: + +- [Quick Guide to Spring Cloud Circuit Breaker](https://www.baeldung.com/spring-cloud-circuit-breaker) From 38bc3707712404e25431a2c1d1b8ba2222eb3984 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 16:47:03 +0800 Subject: [PATCH 446/503] Update README.md --- persistence-modules/hibernate-jpa/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/hibernate-jpa/README.md b/persistence-modules/hibernate-jpa/README.md index fb48f975bc..514fcedb8a 100644 --- a/persistence-modules/hibernate-jpa/README.md +++ b/persistence-modules/hibernate-jpa/README.md @@ -14,3 +14,4 @@ This module contains articles specific to use of Hibernate as a JPA implementati - [TransactionRequiredException Error](https://www.baeldung.com/jpa-transaction-required-exception) - [JPA/Hibernate Persistence Context](https://www.baeldung.com/jpa-hibernate-persistence-context) - [Quick Guide to EntityManager#getReference()](https://www.baeldung.com/jpa-entity-manager-get-reference) +- [Hibernate Error “No Persistence Provider for EntityManager”](https://www.baeldung.com/hibernate-no-persistence-provider) From 66832ae37ec0c57512b8466c5feed6867a0b81be Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 16:51:28 +0800 Subject: [PATCH 447/503] Update README.md --- core-java-modules/core-java-streams-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-streams-3/README.md b/core-java-modules/core-java-streams-3/README.md index 05c4b99900..65713aa04f 100644 --- a/core-java-modules/core-java-streams-3/README.md +++ b/core-java-modules/core-java-streams-3/README.md @@ -10,4 +10,5 @@ This module contains articles about the Stream API in Java. - [Primitive Type Streams in Java 8](https://www.baeldung.com/java-8-primitive-streams) - [Debugging Java 8 Streams with IntelliJ](https://www.baeldung.com/intellij-debugging-java-streams) - [Add BigDecimals using the Stream API](https://www.baeldung.com/java-stream-add-bigdecimals) +- [Should We Close a Java Stream?](https://www.baeldung.com/java-stream-close) - More articles: [[<-- prev>]](/../core-java-streams-2) From 44c7cecd657092a6fb68c5944d2b2236d1f7f450 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 16:53:27 +0800 Subject: [PATCH 448/503] Update README.md --- core-java-modules/core-java-collections-maps-3/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-collections-maps-3/README.md b/core-java-modules/core-java-collections-maps-3/README.md index 64a3b75d83..7386f7e9b7 100644 --- a/core-java-modules/core-java-collections-maps-3/README.md +++ b/core-java-modules/core-java-collections-maps-3/README.md @@ -5,4 +5,5 @@ This module contains articles about Map data structures in Java. ### Relevant Articles: - [Java TreeMap vs HashMap](https://www.baeldung.com/java-treemap-vs-hashmap) - [Comparing Two HashMaps in Java](https://www.baeldung.com/java-compare-hashmaps) +- [The Map.computeIfAbsent() Method](https://www.baeldung.com/java-map-computeifabsent) - More articles: [[<-- prev]](/core-java-modules/core-java-collections-maps-2) From 48525264a085b93b8810ac175c5539720a8abd7b Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 16:57:15 +0800 Subject: [PATCH 449/503] Update README.md --- core-java-modules/core-java-networking-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-networking-2/README.md b/core-java-modules/core-java-networking-2/README.md index 120b111ff5..662d97252e 100644 --- a/core-java-modules/core-java-networking-2/README.md +++ b/core-java-modules/core-java-networking-2/README.md @@ -11,4 +11,5 @@ This module contains articles about networking in Java - [Sending Emails with Java](https://www.baeldung.com/java-email) - [Authentication with HttpUrlConnection](https://www.baeldung.com/java-http-url-connection) - [Download a File from an URL in Java](https://www.baeldung.com/java-download-file) +- [Handling java.net.ConnectException](https://www.baeldung.com/java-net-connectexception) - [[<-- Prev]](/core-java-modules/core-java-networking) From 01dc9eec8d506bbd6e8dceaf6d3c93a8731c605c Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 17:03:15 +0800 Subject: [PATCH 450/503] Create README.md --- spring-boot-modules/spring-boot/src/test/resources/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 spring-boot-modules/spring-boot/src/test/resources/README.md diff --git a/spring-boot-modules/spring-boot/src/test/resources/README.md b/spring-boot-modules/spring-boot/src/test/resources/README.md new file mode 100644 index 0000000000..51c95afd9d --- /dev/null +++ b/spring-boot-modules/spring-boot/src/test/resources/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [How to Test GraphQL Using Postman](https://www.baeldung.com/graphql-postman) From 60364c19e5f642785bcba10cee9f322f66cb697b Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 17:05:25 +0800 Subject: [PATCH 451/503] Update README.md --- libraries-testing/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries-testing/README.md b/libraries-testing/README.md index 7098c10d28..ffdefe4b19 100644 --- a/libraries-testing/README.md +++ b/libraries-testing/README.md @@ -11,4 +11,4 @@ This module contains articles about test libraries. - [Introduction to Awaitlity](https://www.baeldung.com/awaitlity-testing) - [Introduction to Hoverfly in Java](https://www.baeldung.com/hoverfly) - [Testing with Hamcrest](https://www.baeldung.com/java-junit-hamcrest-guide) -- [Introduction To DBUnit](https://www.baeldung.com/dbunit) +- [Introduction To DBUnit](https://www.baeldung.com/java-dbunit) From e232346eb937bab9bf2d74a727e90d833f1d5982 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 17:08:45 +0800 Subject: [PATCH 452/503] Update README.md --- testing-modules/junit5-annotations/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/testing-modules/junit5-annotations/README.md b/testing-modules/junit5-annotations/README.md index 02d4cd652a..bd51bb3d2d 100644 --- a/testing-modules/junit5-annotations/README.md +++ b/testing-modules/junit5-annotations/README.md @@ -7,3 +7,4 @@ This module contains articles about JUnit 5 Annotations - [JUnit 5 Conditional Test Execution with Annotations](https://www.baeldung.com/junit-5-conditional-test-execution) - [JUnit5 Programmatic Extension Registration with @RegisterExtension](https://www.baeldung.com/junit-5-registerextension-annotation) - [Guide to JUnit 5 Parameterized Tests](https://www.baeldung.com/parameterized-tests-junit-5) +- [Writing Templates for Test Cases Using JUnit 5](https://www.baeldung.com/junit5-test-templates) From 4ef6e5efbd0236c1b031a8f53f197b7bcac412b3 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 17:10:54 +0800 Subject: [PATCH 453/503] Update README.md --- reactor-core/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/reactor-core/README.md b/reactor-core/README.md index e3cca35f86..0214aa26fd 100644 --- a/reactor-core/README.md +++ b/reactor-core/README.md @@ -7,3 +7,4 @@ This module contains articles about Reactor Core. - [Intro To Reactor Core](https://www.baeldung.com/reactor-core) - [Combining Publishers in Project Reactor](https://www.baeldung.com/reactor-combine-streams) - [Programmatically Creating Sequences with Project Reactor](https://www.baeldung.com/flux-sequences-reactor) +- [How to Extract a Mono’s Content in Java](https://www.baeldung.com/java-string-from-mono) From c034df09fc1118f67b403c11bc8dbdf9f3b554c5 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 17:16:27 +0800 Subject: [PATCH 454/503] Update README.md --- core-groovy/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core-groovy/README.md b/core-groovy/README.md index 25a0aece3a..f852b3ccf2 100644 --- a/core-groovy/README.md +++ b/core-groovy/README.md @@ -12,4 +12,5 @@ This module contains articles about core Groovy concepts - [Closures in Groovy](https://www.baeldung.com/groovy-closures) - [Converting a String to a Date in Groovy](https://www.baeldung.com/groovy-string-to-date) - [Guide to I/O in Groovy](https://www.baeldung.com/groovy-io) -- [[More -->]](/core-groovy-2) \ No newline at end of file +- [Convert String to Integer in Groovy](https://www.baeldung.com/groovy-convert-string-to-integer) +- [[More -->]](/core-groovy-2) From 424fecc7d9c44d0953405f7e5a1df882e6be00d4 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 17:23:23 +0800 Subject: [PATCH 455/503] Update README.md --- testing-modules/mockito-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/testing-modules/mockito-2/README.md b/testing-modules/mockito-2/README.md index 6c9ddee01d..329228186f 100644 --- a/testing-modules/mockito-2/README.md +++ b/testing-modules/mockito-2/README.md @@ -5,3 +5,4 @@ - [Mockito Strict Stubbing and The UnnecessaryStubbingException](https://www.baeldung.com/mockito-unnecessary-stubbing-exception) - [Mockito and Fluent APIs](https://www.baeldung.com/mockito-fluent-apis) - [Mocking the ObjectMapper readValue() Method](https://www.baeldung.com/mockito-mock-jackson-read-value) +- [Introduction to Mockito’s AdditionalAnswers](https://www.baeldung.com/mockito-additionalanswers) From 629ba77f5676616d0c8aad7eeb8fc6121c1e5c94 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 17:27:51 +0800 Subject: [PATCH 456/503] Update README.md --- persistence-modules/java-mongodb/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/java-mongodb/README.md b/persistence-modules/java-mongodb/README.md index 5c3c448b03..b79cea6781 100644 --- a/persistence-modules/java-mongodb/README.md +++ b/persistence-modules/java-mongodb/README.md @@ -11,3 +11,4 @@ This module contains articles about MongoDB in Java. - [Introduction to Morphia – Java ODM for MongoDB](https://www.baeldung.com/mongodb-morphia) - [MongoDB Aggregations Using Java](https://www.baeldung.com/java-mongodb-aggregations) - [MongoDB BSON to JSON](https://www.baeldung.com/bson-to-json) +- [BSON to JSON Document Conversion in Java](https://www.baeldung.com/java-convert-bson-to-json) From e0c1a17a68e69c737153ea97951ce3729927b471 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 17:31:23 +0800 Subject: [PATCH 457/503] Create README.md --- terraform/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 terraform/README.md diff --git a/terraform/README.md b/terraform/README.md new file mode 100644 index 0000000000..19abd2ff20 --- /dev/null +++ b/terraform/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Introduction to Terraform](https://www.baeldung.com/ops/terraform-intro) From 1793a19bfc8dde7c1fcc14e44a68566072104512 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 17:36:42 +0800 Subject: [PATCH 458/503] Update README.md --- persistence-modules/spring-data-jpa-4/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/spring-data-jpa-4/README.md b/persistence-modules/spring-data-jpa-4/README.md index 3884435f75..085dfcb366 100644 --- a/persistence-modules/spring-data-jpa-4/README.md +++ b/persistence-modules/spring-data-jpa-4/README.md @@ -6,6 +6,7 @@ - [JPA Entity Lifecycle Events](https://www.baeldung.com/jpa-entity-lifecycle-events) - [Working with Lazy Element Collections in JPA](https://www.baeldung.com/java-jpa-lazy-collections) - [Calling Stored Procedures from Spring Data JPA Repositories](https://www.baeldung.com/spring-data-jpa-stored-procedures) +- [Custom Naming Convention with Spring Data JPA](https://www.baeldung.com/spring-data-jpa-custom-naming) ### Eclipse Config After importing the project into Eclipse, you may see the following error: From 7d3aa9f3e594acb660606993b060963ab06430b0 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 17:43:34 +0800 Subject: [PATCH 459/503] Create README.md --- java-collections-maps-3/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 java-collections-maps-3/README.md diff --git a/java-collections-maps-3/README.md b/java-collections-maps-3/README.md new file mode 100644 index 0000000000..4da8547824 --- /dev/null +++ b/java-collections-maps-3/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Java Map With Case-Insensitive Keys](https://www.baeldung.com/java-map-with-case-insensitive-keys) From 6335a8eaa526fa5040e10f639e951e4acea64fbf Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 17:47:21 +0800 Subject: [PATCH 460/503] Create README.md --- netty/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 netty/README.md diff --git a/netty/README.md b/netty/README.md new file mode 100644 index 0000000000..30c63cd5a8 --- /dev/null +++ b/netty/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [HTTP/2 in Netty](https://www.baeldung.com/netty-http2) From 9d62a60deb4e6dec5909da86fbe41b56b75059c1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 17:50:35 +0800 Subject: [PATCH 461/503] Update README.md --- persistence-modules/spring-boot-persistence-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/spring-boot-persistence-2/README.md b/persistence-modules/spring-boot-persistence-2/README.md index 5d171fb2ca..3ea93db4fe 100644 --- a/persistence-modules/spring-boot-persistence-2/README.md +++ b/persistence-modules/spring-boot-persistence-2/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Using JDBI with Spring Boot](https://www.baeldung.com/spring-boot-jdbi) +- [Oracle Connection Pooling With Spring](https://www.baeldung.com/spring-oracle-connection-pooling) From 22b4859f6269868251ee42854d6a909059bcfdf1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 5 May 2020 17:54:09 +0800 Subject: [PATCH 462/503] Update README.md --- atomikos/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atomikos/README.md b/atomikos/README.md index 19f2e871d4..2c44e388fe 100644 --- a/atomikos/README.md +++ b/atomikos/README.md @@ -4,4 +4,4 @@ This module contains articles about Atomikos ### Relevant Articles: -- [Guide Transactions Using Atomikos]() +- [A Guide to Atomikos](https://www.baeldung.com/java-atomikos) From da533f662a495d2fb78d619c4e2edfd9db65dc77 Mon Sep 17 00:00:00 2001 From: Tyrell Flurry Date: Tue, 5 May 2020 08:01:34 -0400 Subject: [PATCH 463/503] BAEL-3929: changed plugin version. --- maven-all/maven-unused-dependencies/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maven-all/maven-unused-dependencies/pom.xml b/maven-all/maven-unused-dependencies/pom.xml index c8f6c1f04b..825858e481 100644 --- a/maven-all/maven-unused-dependencies/pom.xml +++ b/maven-all/maven-unused-dependencies/pom.xml @@ -9,7 +9,7 @@ 3.2.2 1.7.25 - 3.1.1 + 3.1.2 3.1 From 0f78e9a073b1c8b941375ac5e725a7180288fd42 Mon Sep 17 00:00:00 2001 From: Vikas Rajput Date: Tue, 5 May 2020 19:53:34 +0530 Subject: [PATCH 464/503] Bael 3557: Deleted /app package (#9242) * BAEL-3557: Completed a simple web application in spring boot and groovy * BAEL-3557: renamed packagename from com.baeldung.app to more unique name - com.baeldung.springwithgroovy * BAEL-3557: Deleted /app package Co-authored-by: Vikas Ramsingh Rajput --- .../app/SpringBootGroovyApplication.groovy | 13 --- .../app/controller/TodoController.groovy | 48 --------- .../com/baeldung/app/entity/Todo.groovy | 23 ----- .../app/repository/TodoRepository.groovy | 9 -- .../baeldung/app/service/TodoService.groovy | 16 --- .../app/service/impl/TodoServiceImpl.groovy | 40 -------- .../com/baeldung/app/TodoAppUnitTest.groovy | 97 ------------------- 7 files changed, 246 deletions(-) delete mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/app/SpringBootGroovyApplication.groovy delete mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/app/controller/TodoController.groovy delete mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/app/entity/Todo.groovy delete mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/app/repository/TodoRepository.groovy delete mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/app/service/TodoService.groovy delete mode 100644 spring-boot-groovy/src/main/groovy/com/baeldung/app/service/impl/TodoServiceImpl.groovy delete mode 100644 spring-boot-groovy/src/test/groovy/com/baeldung/app/TodoAppUnitTest.groovy diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/SpringBootGroovyApplication.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/app/SpringBootGroovyApplication.groovy deleted file mode 100644 index 226a2ff53d..0000000000 --- a/spring-boot-groovy/src/main/groovy/com/baeldung/app/SpringBootGroovyApplication.groovy +++ /dev/null @@ -1,13 +0,0 @@ -package com.baeldung.app - -import org.springframework.boot.SpringApplication -import org.springframework.boot.autoconfigure.SpringBootApplication - -import com.baeldung.app.SpringBootGroovyApplication - -@SpringBootApplication -class SpringBootGroovyApplication { - static void main(String[] args) { - SpringApplication.run SpringBootGroovyApplication, args - } -} diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/controller/TodoController.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/app/controller/TodoController.groovy deleted file mode 100644 index 02f6d0223b..0000000000 --- a/spring-boot-groovy/src/main/groovy/com/baeldung/app/controller/TodoController.groovy +++ /dev/null @@ -1,48 +0,0 @@ -package com.baeldung.app.controller - -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.web.bind.annotation.DeleteMapping -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.PathVariable -import org.springframework.web.bind.annotation.PostMapping -import org.springframework.web.bind.annotation.PutMapping -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RequestMethod -import org.springframework.web.bind.annotation.RestController - -import com.baeldung.app.entity.Todo -import com.baeldung.app.service.TodoService - -@RestController -@RequestMapping('todo') -public class TodoController { - - @Autowired - TodoService todoService - - @GetMapping - List getAllTodoList(){ - todoService.findAll() - } - - @PostMapping - Todo saveTodo(@RequestBody Todo todo){ - todoService.saveTodo todo - } - - @PutMapping - Todo updateTodo(@RequestBody Todo todo){ - todoService.updateTodo todo - } - - @DeleteMapping('/{todoId}') - deleteTodo(@PathVariable Integer todoId){ - todoService.deleteTodo todoId - } - - @GetMapping('/{todoId}') - Todo getTodoById(@PathVariable Integer todoId){ - todoService.findById todoId - } -} \ No newline at end of file diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/entity/Todo.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/app/entity/Todo.groovy deleted file mode 100644 index 9f1253c5b3..0000000000 --- a/spring-boot-groovy/src/main/groovy/com/baeldung/app/entity/Todo.groovy +++ /dev/null @@ -1,23 +0,0 @@ -package com.baeldung.app.entity - -import javax.persistence.Column -import javax.persistence.Entity -import javax.persistence.GeneratedValue -import javax.persistence.GenerationType -import javax.persistence.Id -import javax.persistence.Table - -@Entity -@Table(name = 'todo') -class Todo { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - Integer id - - @Column - String task - - @Column - Boolean isCompleted - -} diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/repository/TodoRepository.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/app/repository/TodoRepository.groovy deleted file mode 100644 index c0b35cc37d..0000000000 --- a/spring-boot-groovy/src/main/groovy/com/baeldung/app/repository/TodoRepository.groovy +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.app.repository - -import org.springframework.data.jpa.repository.JpaRepository -import org.springframework.stereotype.Repository - -import com.baeldung.app.entity.Todo - -@Repository -interface TodoRepository extends JpaRepository {} \ No newline at end of file diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/service/TodoService.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/app/service/TodoService.groovy deleted file mode 100644 index 0a59d93330..0000000000 --- a/spring-boot-groovy/src/main/groovy/com/baeldung/app/service/TodoService.groovy +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.app.service - -import com.baeldung.app.entity.Todo - -interface TodoService { - - List findAll() - - Todo findById(Integer todoId) - - Todo saveTodo(Todo todo) - - Todo updateTodo(Todo todo) - - Todo deleteTodo(Integer todoId) -} diff --git a/spring-boot-groovy/src/main/groovy/com/baeldung/app/service/impl/TodoServiceImpl.groovy b/spring-boot-groovy/src/main/groovy/com/baeldung/app/service/impl/TodoServiceImpl.groovy deleted file mode 100644 index 6d0ee03a9f..0000000000 --- a/spring-boot-groovy/src/main/groovy/com/baeldung/app/service/impl/TodoServiceImpl.groovy +++ /dev/null @@ -1,40 +0,0 @@ -package com.baeldung.app.service.impl - -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.stereotype.Service - -import com.baeldung.app.entity.Todo -import com.baeldung.app.repository.TodoRepository -import com.baeldung.app.service.TodoService - -@Service -class TodoServiceImpl implements TodoService { - - @Autowired - TodoRepository todoRepository - - @Override - List findAll() { - todoRepository.findAll() - } - - @Override - Todo findById(Integer todoId) { - todoRepository.findById todoId get() - } - - @Override - Todo saveTodo(Todo todo){ - todoRepository.save todo - } - - @Override - Todo updateTodo(Todo todo){ - todoRepository.save todo - } - - @Override - Todo deleteTodo(Integer todoId){ - todoRepository.deleteById todoId - } -} diff --git a/spring-boot-groovy/src/test/groovy/com/baeldung/app/TodoAppUnitTest.groovy b/spring-boot-groovy/src/test/groovy/com/baeldung/app/TodoAppUnitTest.groovy deleted file mode 100644 index faf2d64ba7..0000000000 --- a/spring-boot-groovy/src/test/groovy/com/baeldung/app/TodoAppUnitTest.groovy +++ /dev/null @@ -1,97 +0,0 @@ -package com.baeldung.app - -import static org.junit.jupiter.api.Assertions.assertEquals -import static org.junit.jupiter.api.Assertions.assertTrue - -import org.junit.BeforeClass -import org.junit.Test -import org.junit.runner.RunWith -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.http.HttpStatus -import org.springframework.http.MediaType -import org.springframework.test.context.event.annotation.BeforeTestClass -import org.springframework.test.context.junit4.SpringRunner - -import com.baeldung.app.entity.Todo - -import io.restassured.RestAssured -import io.restassured.response.Response - -class TodoAppUnitTest { - static API_ROOT = 'http://localhost:8081/todo' - static readingTodoId - static writingTodoId - - @BeforeClass - static void populateDummyData() { - Todo readingTodo = new Todo(task: 'Reading', isCompleted: false) - Todo writingTodo = new Todo(task: 'Writing', isCompleted: false) - - final Response readingResponse = - RestAssured.given() - .contentType(MediaType.APPLICATION_JSON_VALUE) - .body(readingTodo).post(API_ROOT) - - Todo cookingTodoResponse = readingResponse.as Todo.class - readingTodoId = cookingTodoResponse.getId() - - final Response writingResponse = - RestAssured.given() - .contentType(MediaType.APPLICATION_JSON_VALUE) - .body(writingTodo).post(API_ROOT) - - Todo writingTodoResponse = writingResponse.as Todo.class - writingTodoId = writingTodoResponse.getId() - } - - @Test - void whenGetAllTodoList_thenOk(){ - final Response response = RestAssured.get(API_ROOT) - - assertEquals HttpStatus.OK.value(),response.getStatusCode() - assertTrue response.as(List.class).size() > 0 - } - - @Test - void whenGetTodoById_thenOk(){ - final Response response = - RestAssured.get("$API_ROOT/$readingTodoId") - - assertEquals HttpStatus.OK.value(),response.getStatusCode() - Todo todoResponse = response.as Todo.class - assertEquals readingTodoId,todoResponse.getId() - } - - @Test - void whenUpdateTodoById_thenOk(){ - Todo todo = new Todo(id:readingTodoId, isCompleted: true) - final Response response = - RestAssured.given() - .contentType(MediaType.APPLICATION_JSON_VALUE) - .body(todo).put(API_ROOT) - - assertEquals HttpStatus.OK.value(),response.getStatusCode() - Todo todoResponse = response.as Todo.class - assertTrue todoResponse.getIsCompleted() - } - - @Test - void whenDeleteTodoById_thenOk(){ - final Response response = - RestAssured.given() - .delete("$API_ROOT/$writingTodoId") - - assertEquals HttpStatus.OK.value(),response.getStatusCode() - } - - @Test - void whenSaveTodo_thenOk(){ - Todo todo = new Todo(task: 'Blogging', isCompleted: false) - final Response response = - RestAssured.given() - .contentType(MediaType.APPLICATION_JSON_VALUE) - .body(todo).post(API_ROOT) - - assertEquals HttpStatus.OK.value(),response.getStatusCode() - } -} \ No newline at end of file From 87b4ea1d0d1e32e58be4bd335f539e4631965f7e Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Tue, 5 May 2020 22:19:53 +0200 Subject: [PATCH 465/503] JAVA-1529: Move Working with Date Parameters in Spring --- spring-mvc-java-2/README.md | 1 + .../src/main/java/com/baeldung/datetime/DateTimeConfig.java | 0 .../src/main/java/com/baeldung/datetime/DateTimeController.java | 0 spring-mvc-java/README.md | 1 - 4 files changed, 1 insertion(+), 1 deletion(-) rename {spring-mvc-java => spring-mvc-java-2}/src/main/java/com/baeldung/datetime/DateTimeConfig.java (100%) rename {spring-mvc-java => spring-mvc-java-2}/src/main/java/com/baeldung/datetime/DateTimeController.java (100%) diff --git a/spring-mvc-java-2/README.md b/spring-mvc-java-2/README.md index b5d5df3cd4..04c0fc958a 100644 --- a/spring-mvc-java-2/README.md +++ b/spring-mvc-java-2/README.md @@ -1,3 +1,4 @@ ### Relevant Articles: - [Cache Headers in Spring MVC](https://www.baeldung.com/spring-mvc-cache-headers) +- [Working with Date Parameters in Spring](https://www.baeldung.com/spring-date-parameters) diff --git a/spring-mvc-java/src/main/java/com/baeldung/datetime/DateTimeConfig.java b/spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeConfig.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/datetime/DateTimeConfig.java rename to spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeConfig.java diff --git a/spring-mvc-java/src/main/java/com/baeldung/datetime/DateTimeController.java b/spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeController.java similarity index 100% rename from spring-mvc-java/src/main/java/com/baeldung/datetime/DateTimeController.java rename to spring-mvc-java-2/src/main/java/com/baeldung/datetime/DateTimeController.java diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index f1263860f9..0cac937a81 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -14,6 +14,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Upload and Display Excel Files with Spring MVC](https://www.baeldung.com/spring-mvc-excel-files) - [web.xml vs Initializer with Spring](https://www.baeldung.com/spring-xml-vs-java-config) - [Spring MVC @PathVariable with a dot (.) gets truncated](https://www.baeldung.com/spring-mvc-pathvariable-dot) -- [Working with Date Parameters in Spring](https://www.baeldung.com/spring-date-parameters) - [A Java Web Application Without a web.xml](https://www.baeldung.com/java-web-app-without-web-xml) - [Accessing Spring MVC Model Objects in JavaScript](https://www.baeldung.com/spring-mvc-model-objects-js) From 34c18aefc4a480e361138a761f27f1838d3a5df6 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Tue, 5 May 2020 22:21:38 +0200 Subject: [PATCH 466/503] JAVA-1529: Spring MVC @PathVariable with a dot (.) gets truncated --- spring-mvc-java-2/README.md | 1 + .../CustomWebMvcConfigurationSupport.java | 2 +- .../com/baeldung/pathvariable}/SiteController.java | 12 +++++++----- spring-mvc-java/README.md | 1 - 4 files changed, 9 insertions(+), 7 deletions(-) rename {spring-mvc-java/src/main/java/com/baeldung/spring/web/config => spring-mvc-java-2/src/main/java/com/baeldung/pathvariable}/CustomWebMvcConfigurationSupport.java (93%) rename {spring-mvc-java/src/main/java/com/baeldung/web/controller => spring-mvc-java-2/src/main/java/com/baeldung/pathvariable}/SiteController.java (69%) diff --git a/spring-mvc-java-2/README.md b/spring-mvc-java-2/README.md index 04c0fc958a..50cdafe1d7 100644 --- a/spring-mvc-java-2/README.md +++ b/spring-mvc-java-2/README.md @@ -2,3 +2,4 @@ - [Cache Headers in Spring MVC](https://www.baeldung.com/spring-mvc-cache-headers) - [Working with Date Parameters in Spring](https://www.baeldung.com/spring-date-parameters) +- [Spring MVC @PathVariable with a dot (.) gets truncated](https://www.baeldung.com/spring-mvc-pathvariable-dot) \ No newline at end of file diff --git a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/CustomWebMvcConfigurationSupport.java b/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/CustomWebMvcConfigurationSupport.java similarity index 93% rename from spring-mvc-java/src/main/java/com/baeldung/spring/web/config/CustomWebMvcConfigurationSupport.java rename to spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/CustomWebMvcConfigurationSupport.java index a0dd7358d0..12c208c623 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/spring/web/config/CustomWebMvcConfigurationSupport.java +++ b/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/CustomWebMvcConfigurationSupport.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.web.config; +package com.baeldung.pathvariable; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/SiteController.java b/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/SiteController.java similarity index 69% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/SiteController.java rename to spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/SiteController.java index 3867380665..0ba6d12a0f 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/web/controller/SiteController.java +++ b/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/SiteController.java @@ -1,27 +1,29 @@ -package com.baeldung.web.controller; +package com.baeldung.pathvariable; +import org.springframework.stereotype.Controller; +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.RequestMethod; +@Controller @RequestMapping("/site") public class SiteController { - @RequestMapping(value = "/{firstValue}/{secondValue}", method = RequestMethod.GET) + @GetMapping("/{firstValue}/{secondValue}") public String requestWithError(@PathVariable("firstValue") String firstValue, @PathVariable("secondValue") String secondValue) { return firstValue + " - " + secondValue; } - @RequestMapping(value = "/{firstValue}/{secondValue:.+}", method = RequestMethod.GET) + @GetMapping("/{firstValue}/{secondValue:.+}") public String requestWithRegex(@PathVariable("firstValue") String firstValue, @PathVariable("secondValue") String secondValue) { return firstValue + " - " + secondValue; } - @RequestMapping(value = "/{firstValue}/{secondValue}/", method = RequestMethod.GET) + @GetMapping("/{firstValue}/{secondValue}/") public String requestWithSlash(@PathVariable("firstValue") String firstValue, @PathVariable("secondValue") String secondValue) { diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index 0cac937a81..0edc73e0e0 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -13,6 +13,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Introduction to HtmlUnit](https://www.baeldung.com/htmlunit) - [Upload and Display Excel Files with Spring MVC](https://www.baeldung.com/spring-mvc-excel-files) - [web.xml vs Initializer with Spring](https://www.baeldung.com/spring-xml-vs-java-config) -- [Spring MVC @PathVariable with a dot (.) gets truncated](https://www.baeldung.com/spring-mvc-pathvariable-dot) - [A Java Web Application Without a web.xml](https://www.baeldung.com/java-web-app-without-web-xml) - [Accessing Spring MVC Model Objects in JavaScript](https://www.baeldung.com/spring-mvc-model-objects-js) From 50208fb01304c8398e92c816589de92ff3e7a46b Mon Sep 17 00:00:00 2001 From: kwoyke Date: Tue, 5 May 2020 22:27:16 +0200 Subject: [PATCH 467/503] Verify if the connection is still alive (#9246) --- .../com/baeldung/connectionpool/BasicConnectionPool.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/connectionpool/BasicConnectionPool.java b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/connectionpool/BasicConnectionPool.java index 289db18c53..22ef0e5411 100644 --- a/persistence-modules/core-java-persistence/src/main/java/com/baeldung/connectionpool/BasicConnectionPool.java +++ b/persistence-modules/core-java-persistence/src/main/java/com/baeldung/connectionpool/BasicConnectionPool.java @@ -14,7 +14,8 @@ public class BasicConnectionPool implements ConnectionPool { private final List connectionPool; private final List usedConnections = new ArrayList<>(); private static final int INITIAL_POOL_SIZE = 10; - private final int MAX_POOL_SIZE = 20; + private static final int MAX_POOL_SIZE = 20; + private static final int MAX_TIMEOUT = 5; public static BasicConnectionPool create(String url, String user, String password) throws SQLException { List pool = new ArrayList<>(INITIAL_POOL_SIZE); @@ -42,6 +43,11 @@ public class BasicConnectionPool implements ConnectionPool { } Connection connection = connectionPool.remove(connectionPool.size() - 1); + + if(!connection.isValid(MAX_TIMEOUT)){ + connection = createConnection(url, user, password); + } + usedConnections.add(connection); return connection; } From 13f2b10c8b7bff8dd99fa5831434ce97247815a6 Mon Sep 17 00:00:00 2001 From: Maciej Glowka Date: Wed, 6 May 2020 00:35:07 +0200 Subject: [PATCH 468/503] BAEL-3829: added more distinct bean names, changed country codes to ISO codes --- .../autowire/BeanFactoryDynamicAutowireService.java | 9 +++++++-- ...va => CustomMapFromListDynamicAutowireService.java} | 10 +++++----- .../{UkRegionService.java => GBRegionService.java} | 8 ++++---- .../com/baeldung/dynamic/autowire/RegionService.java | 2 +- .../{USARegionService.java => USRegionService.java} | 8 ++++---- .../autowire/DynamicAutowireIntegrationTest.java | 10 +++++----- 6 files changed, 26 insertions(+), 21 deletions(-) rename spring-core-4/src/main/java/com/baeldung/dynamic/autowire/{InterfaceDynamicAutowireService.java => CustomMapFromListDynamicAutowireService.java} (55%) rename spring-core-4/src/main/java/com/baeldung/dynamic/autowire/{UkRegionService.java => GBRegionService.java} (58%) rename spring-core-4/src/main/java/com/baeldung/dynamic/autowire/{USARegionService.java => USRegionService.java} (58%) diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/BeanFactoryDynamicAutowireService.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/BeanFactoryDynamicAutowireService.java index 5f8f2e548e..4ad4420489 100644 --- a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/BeanFactoryDynamicAutowireService.java +++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/BeanFactoryDynamicAutowireService.java @@ -6,6 +6,7 @@ import org.springframework.stereotype.Service; @Service public class BeanFactoryDynamicAutowireService { + private static final String SERVICE_NAME_SUFFIX = "regionService"; private final BeanFactory beanFactory; @Autowired @@ -13,10 +14,14 @@ public class BeanFactoryDynamicAutowireService { this.beanFactory = beanFactory; } - public boolean isServerActive(String countryCode, int serverId) { - RegionService service = beanFactory.getBean(countryCode, RegionService.class); + public boolean isServerActive(String isoCountryCode, int serverId) { + RegionService service = beanFactory.getBean(getRegionServiceBeanName(isoCountryCode), RegionService.class); return service.isServerActive(serverId); } + private String getRegionServiceBeanName(String isoCountryCode) { + return isoCountryCode + SERVICE_NAME_SUFFIX; + } + } diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/InterfaceDynamicAutowireService.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/CustomMapFromListDynamicAutowireService.java similarity index 55% rename from spring-core-4/src/main/java/com/baeldung/dynamic/autowire/InterfaceDynamicAutowireService.java rename to spring-core-4/src/main/java/com/baeldung/dynamic/autowire/CustomMapFromListDynamicAutowireService.java index ad655f5c42..e04c345d51 100644 --- a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/InterfaceDynamicAutowireService.java +++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/CustomMapFromListDynamicAutowireService.java @@ -9,17 +9,17 @@ import java.util.function.Function; import java.util.stream.Collectors; @Service -public class InterfaceDynamicAutowireService { +public class CustomMapFromListDynamicAutowireService { private final Map servicesByCountryCode; @Autowired - public InterfaceDynamicAutowireService(List regionServices) { + public CustomMapFromListDynamicAutowireService(List regionServices) { servicesByCountryCode = regionServices.stream() - .collect(Collectors.toMap(RegionService::getCountryCode, Function.identity())); + .collect(Collectors.toMap(RegionService::getISOCountryCode, Function.identity())); } - public boolean isServerActive(String countryCode, int serverId) { - RegionService service = servicesByCountryCode.get(countryCode); + public boolean isServerActive(String isoCountryCode, int serverId) { + RegionService service = servicesByCountryCode.get(isoCountryCode); return service.isServerActive(serverId); } diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/UkRegionService.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/GBRegionService.java similarity index 58% rename from spring-core-4/src/main/java/com/baeldung/dynamic/autowire/UkRegionService.java rename to spring-core-4/src/main/java/com/baeldung/dynamic/autowire/GBRegionService.java index 1fbe8ed96e..8c6a1372d4 100644 --- a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/UkRegionService.java +++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/GBRegionService.java @@ -2,15 +2,15 @@ package com.baeldung.dynamic.autowire; import org.springframework.stereotype.Service; -@Service("uk") -public class UkRegionService implements RegionService { +@Service("GBregionService") +public class GBRegionService implements RegionService { @Override public boolean isServerActive(int serverId) { return false; } @Override - public String getCountryCode() { - return "uk"; + public String getISOCountryCode() { + return "GB"; } } diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/RegionService.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/RegionService.java index f9f92d045a..a2caf38ab3 100644 --- a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/RegionService.java +++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/RegionService.java @@ -3,5 +3,5 @@ package com.baeldung.dynamic.autowire; public interface RegionService { boolean isServerActive(int serverId); - String getCountryCode(); + String getISOCountryCode(); } diff --git a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/USARegionService.java b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/USRegionService.java similarity index 58% rename from spring-core-4/src/main/java/com/baeldung/dynamic/autowire/USARegionService.java rename to spring-core-4/src/main/java/com/baeldung/dynamic/autowire/USRegionService.java index cfad0146e5..a2d5f47553 100644 --- a/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/USARegionService.java +++ b/spring-core-4/src/main/java/com/baeldung/dynamic/autowire/USRegionService.java @@ -2,15 +2,15 @@ package com.baeldung.dynamic.autowire; import org.springframework.stereotype.Service; -@Service("usa") -public class USARegionService implements RegionService { +@Service("USregionService") +public class USRegionService implements RegionService { @Override public boolean isServerActive(int serverId) { return true; } @Override - public String getCountryCode() { - return "usa"; + public String getISOCountryCode() { + return "US"; } } diff --git a/spring-core-4/src/test/java/com/baeldung/dynamic/autowire/DynamicAutowireIntegrationTest.java b/spring-core-4/src/test/java/com/baeldung/dynamic/autowire/DynamicAutowireIntegrationTest.java index 5afab69c53..3eb6268e97 100644 --- a/spring-core-4/src/test/java/com/baeldung/dynamic/autowire/DynamicAutowireIntegrationTest.java +++ b/spring-core-4/src/test/java/com/baeldung/dynamic/autowire/DynamicAutowireIntegrationTest.java @@ -17,14 +17,14 @@ public class DynamicAutowireIntegrationTest { private BeanFactoryDynamicAutowireService beanFactoryDynamicAutowireService; @Autowired - private InterfaceDynamicAutowireService interfaceDynamicAutowireService; + private CustomMapFromListDynamicAutowireService customMapFromListDynamicAutowireService; @Test public void testConstructWorkerByJava() { - assertThat(beanFactoryDynamicAutowireService.isServerActive("uk", 101), is(false)); - assertThat(interfaceDynamicAutowireService.isServerActive("uk", 101), is(false)); + assertThat(beanFactoryDynamicAutowireService.isServerActive("GB", 101), is(false)); + assertThat(customMapFromListDynamicAutowireService.isServerActive("GB", 101), is(false)); - assertThat(beanFactoryDynamicAutowireService.isServerActive("usa", 101), is(true)); - assertThat(interfaceDynamicAutowireService.isServerActive("usa", 101), is(true)); + assertThat(beanFactoryDynamicAutowireService.isServerActive("US", 101), is(true)); + assertThat(customMapFromListDynamicAutowireService.isServerActive("US", 101), is(true)); } } From daa42ab3a0f71d99ba45de268da9a75bb8db67b4 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Wed, 6 May 2020 01:05:52 +0200 Subject: [PATCH 469/503] JAVA-1529: Add MVC config --- spring-mvc-java-2/pom.xml | 18 ++++++++++----- .../baeldung/pathvariable/SiteController.java | 3 ++- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 17 ++++++++++++++ .../src/main/webapp/WEB-INF/web.xml | 22 +++++++++++++++++++ 4 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml create mode 100644 spring-mvc-java-2/src/main/webapp/WEB-INF/web.xml diff --git a/spring-mvc-java-2/pom.xml b/spring-mvc-java-2/pom.xml index d5b7d087ab..7deab74fcb 100644 --- a/spring-mvc-java-2/pom.xml +++ b/spring-mvc-java-2/pom.xml @@ -7,14 +7,14 @@ 0.1-SNAPSHOT spring-mvc-java-2 war - + com.baeldung parent-boot-2 0.0.1-SNAPSHOT ../parent-boot-2 - + javax.servlet @@ -26,14 +26,22 @@ spring-webmvc ${spring.mvc.version} - - + + + spring-mvc-java-2 + + + src/main/resources + true + + + + 4.0.1 5.2.2.RELEASE - \ No newline at end of file diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/SiteController.java b/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/SiteController.java index 0ba6d12a0f..493161b0eb 100644 --- a/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/SiteController.java +++ b/spring-mvc-java-2/src/main/java/com/baeldung/pathvariable/SiteController.java @@ -4,8 +4,9 @@ import org.springframework.stereotype.Controller; 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; -@Controller +@RestController @RequestMapping("/site") public class SiteController { diff --git a/spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml new file mode 100644 index 0000000000..b8e280dfdf --- /dev/null +++ b/spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/spring-mvc-java-2/src/main/webapp/WEB-INF/web.xml b/spring-mvc-java-2/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..86a24e7646 --- /dev/null +++ b/spring-mvc-java-2/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,22 @@ + + + Spring MVC Application 2 + + + mvc + + org.springframework.web.servlet.DispatcherServlet + + + contextConfigLocation + /WEB-INF/mvc-servlet.xml + + 1 + + + + mvc + / + + \ No newline at end of file From 2d08a88ec0a796805531a5455d23c9501b84cb38 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Wed, 6 May 2020 01:31:06 +0200 Subject: [PATCH 470/503] Move A Quick Guide to Spring MVC Matrix Variables --- spring-mvc-java-2/README.md | 3 ++- spring-mvc-java-2/pom.xml | 5 +++++ .../{WebConfig.java => CacheWebConfig.java} | 2 +- .../matrix/config/MatrixWebConfig.java | 18 +++++++++++++++++ .../matrix}/controller/CompanyController.java | 17 +++++----------- .../controller/EmployeeController.java | 20 +++++-------------- .../com/baeldung/matrix}/model/Company.java | 2 +- .../com/baeldung/matrix}/model/Employee.java | 2 +- .../src/main/webapp/WEB-INF/mvc-servlet.xml | 10 ++++++++++ .../main/webapp/WEB-INF/view/companyHome.jsp | 0 .../main/webapp/WEB-INF/view/companyView.jsp | 0 .../main/webapp/WEB-INF/view/employeeHome.jsp | 0 .../main/webapp/WEB-INF/view/employeeView.jsp | 0 ...CacheControlControllerIntegrationTest.java | 2 +- .../matrix}/EmployeeMvcIntegrationTest.java | 16 +++++++-------- .../matrix}/EmployeeNoMvcIntegrationTest.java | 10 +++++----- spring-mvc-java/README.md | 1 - 17 files changed, 61 insertions(+), 47 deletions(-) rename spring-mvc-java-2/src/main/java/com/baeldung/cache/{WebConfig.java => CacheWebConfig.java} (96%) create mode 100644 spring-mvc-java-2/src/main/java/com/baeldung/matrix/config/MatrixWebConfig.java rename {spring-mvc-java/src/main/java/com/baeldung/web => spring-mvc-java-2/src/main/java/com/baeldung/matrix}/controller/CompanyController.java (81%) rename {spring-mvc-java/src/main/java/com/baeldung/web => spring-mvc-java-2/src/main/java/com/baeldung/matrix}/controller/EmployeeController.java (86%) rename {spring-mvc-java/src/main/java/com/baeldung => spring-mvc-java-2/src/main/java/com/baeldung/matrix}/model/Company.java (94%) rename {spring-mvc-java/src/main/java/com/baeldung => spring-mvc-java-2/src/main/java/com/baeldung/matrix}/model/Employee.java (97%) rename {spring-mvc-java => spring-mvc-java-2}/src/main/webapp/WEB-INF/view/companyHome.jsp (100%) rename {spring-mvc-java => spring-mvc-java-2}/src/main/webapp/WEB-INF/view/companyView.jsp (100%) rename {spring-mvc-java => spring-mvc-java-2}/src/main/webapp/WEB-INF/view/employeeHome.jsp (100%) rename {spring-mvc-java => spring-mvc-java-2}/src/main/webapp/WEB-INF/view/employeeView.jsp (100%) rename {spring-mvc-java/src/test/java/com/baeldung/web/controller => spring-mvc-java-2/src/test/java/com/baeldung/matrix}/EmployeeMvcIntegrationTest.java (81%) rename {spring-mvc-java/src/test/java/com/baeldung/web/controller => spring-mvc-java-2/src/test/java/com/baeldung/matrix}/EmployeeNoMvcIntegrationTest.java (86%) diff --git a/spring-mvc-java-2/README.md b/spring-mvc-java-2/README.md index 50cdafe1d7..09c8d8b294 100644 --- a/spring-mvc-java-2/README.md +++ b/spring-mvc-java-2/README.md @@ -2,4 +2,5 @@ - [Cache Headers in Spring MVC](https://www.baeldung.com/spring-mvc-cache-headers) - [Working with Date Parameters in Spring](https://www.baeldung.com/spring-date-parameters) -- [Spring MVC @PathVariable with a dot (.) gets truncated](https://www.baeldung.com/spring-mvc-pathvariable-dot) \ No newline at end of file +- [Spring MVC @PathVariable with a dot (.) gets truncated](https://www.baeldung.com/spring-mvc-pathvariable-dot) +- [A Quick Guide to Spring MVC Matrix Variables](https://www.baeldung.com/spring-mvc-matrix-variables) \ No newline at end of file diff --git a/spring-mvc-java-2/pom.xml b/spring-mvc-java-2/pom.xml index 7deab74fcb..af622321cb 100644 --- a/spring-mvc-java-2/pom.xml +++ b/spring-mvc-java-2/pom.xml @@ -26,6 +26,11 @@ spring-webmvc ${spring.mvc.version} + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/cache/WebConfig.java b/spring-mvc-java-2/src/main/java/com/baeldung/cache/CacheWebConfig.java similarity index 96% rename from spring-mvc-java-2/src/main/java/com/baeldung/cache/WebConfig.java rename to spring-mvc-java-2/src/main/java/com/baeldung/cache/CacheWebConfig.java index 2f07912e80..95367077bd 100644 --- a/spring-mvc-java-2/src/main/java/com/baeldung/cache/WebConfig.java +++ b/spring-mvc-java-2/src/main/java/com/baeldung/cache/CacheWebConfig.java @@ -15,7 +15,7 @@ import java.util.concurrent.TimeUnit; @EnableWebMvc @Configuration @ComponentScan(basePackages = {"com.baeldung.cache"}) -public class WebConfig implements WebMvcConfigurer { +public class CacheWebConfig implements WebMvcConfigurer { @Override public void addViewControllers(final ViewControllerRegistry registry) { diff --git a/spring-mvc-java-2/src/main/java/com/baeldung/matrix/config/MatrixWebConfig.java b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/config/MatrixWebConfig.java new file mode 100644 index 0000000000..489740fd33 --- /dev/null +++ b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/config/MatrixWebConfig.java @@ -0,0 +1,18 @@ +package com.baeldung.matrix.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.util.UrlPathHelper; + +@Configuration +public class MatrixWebConfig implements WebMvcConfigurer { + + @Override + public void configurePathMatch(PathMatchConfigurer configurer) { + final UrlPathHelper urlPathHelper = new UrlPathHelper(); + urlPathHelper.setRemoveSemicolonContent(false); + + configurer.setUrlPathHelper(urlPathHelper); + } +} diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/CompanyController.java b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/CompanyController.java similarity index 81% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/CompanyController.java rename to spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/CompanyController.java index af1e729c13..7a21ded026 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/web/controller/CompanyController.java +++ b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/CompanyController.java @@ -1,23 +1,16 @@ -package com.baeldung.web.controller; - -import java.util.HashMap; -import java.util.Map; +package com.baeldung.matrix.controller; +import com.baeldung.matrix.model.Company; import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.MatrixVariable; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; -import com.baeldung.model.Company; +import java.util.HashMap; +import java.util.Map; @Controller public class CompanyController { diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/EmployeeController.java b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/EmployeeController.java similarity index 86% rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/EmployeeController.java rename to spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/EmployeeController.java index 251287dff8..3f9de2179a 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/web/controller/EmployeeController.java +++ b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/controller/EmployeeController.java @@ -1,32 +1,22 @@ -package com.baeldung.web.controller; +package com.baeldung.matrix.controller; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import com.baeldung.matrix.model.Employee; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.validation.BindingResult; -import org.springframework.web.bind.annotation.MatrixVariable; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.SessionAttributes; +import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; -import com.baeldung.model.Employee; +import java.util.*; @SessionAttributes("employees") @Controller public class EmployeeController { - Map employeeMap = new HashMap<>(); + public Map employeeMap = new HashMap<>(); @ModelAttribute("employees") public void initEmployees() { diff --git a/spring-mvc-java/src/main/java/com/baeldung/model/Company.java b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Company.java similarity index 94% rename from spring-mvc-java/src/main/java/com/baeldung/model/Company.java rename to spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Company.java index 558507268a..cdf6cb0fd6 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/model/Company.java +++ b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Company.java @@ -1,4 +1,4 @@ -package com.baeldung.model; +package com.baeldung.matrix.model; public class Company { diff --git a/spring-mvc-java/src/main/java/com/baeldung/model/Employee.java b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Employee.java similarity index 97% rename from spring-mvc-java/src/main/java/com/baeldung/model/Employee.java rename to spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Employee.java index fb0a452219..c3384122b4 100644 --- a/spring-mvc-java/src/main/java/com/baeldung/model/Employee.java +++ b/spring-mvc-java-2/src/main/java/com/baeldung/matrix/model/Employee.java @@ -1,4 +1,4 @@ -package com.baeldung.model; +package com.baeldung.matrix.model; import javax.xml.bind.annotation.XmlRootElement; diff --git a/spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml b/spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml index b8e280dfdf..00dac5f8cb 100644 --- a/spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml +++ b/spring-mvc-java-2/src/main/webapp/WEB-INF/mvc-servlet.xml @@ -11,7 +11,17 @@ http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> + + + + /WEB-INF/view/ + + + .jsp + + + \ No newline at end of file diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/view/companyHome.jsp b/spring-mvc-java-2/src/main/webapp/WEB-INF/view/companyHome.jsp similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/view/companyHome.jsp rename to spring-mvc-java-2/src/main/webapp/WEB-INF/view/companyHome.jsp diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/view/companyView.jsp b/spring-mvc-java-2/src/main/webapp/WEB-INF/view/companyView.jsp similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/view/companyView.jsp rename to spring-mvc-java-2/src/main/webapp/WEB-INF/view/companyView.jsp diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/view/employeeHome.jsp b/spring-mvc-java-2/src/main/webapp/WEB-INF/view/employeeHome.jsp similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/view/employeeHome.jsp rename to spring-mvc-java-2/src/main/webapp/WEB-INF/view/employeeHome.jsp diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/view/employeeView.jsp b/spring-mvc-java-2/src/main/webapp/WEB-INF/view/employeeView.jsp similarity index 100% rename from spring-mvc-java/src/main/webapp/WEB-INF/view/employeeView.jsp rename to spring-mvc-java-2/src/main/webapp/WEB-INF/view/employeeView.jsp diff --git a/spring-mvc-java-2/src/test/java/com/baeldung/cache/CacheControlControllerIntegrationTest.java b/spring-mvc-java-2/src/test/java/com/baeldung/cache/CacheControlControllerIntegrationTest.java index 7acfe5e480..1e34dd182b 100644 --- a/spring-mvc-java-2/src/test/java/com/baeldung/cache/CacheControlControllerIntegrationTest.java +++ b/spring-mvc-java-2/src/test/java/com/baeldung/cache/CacheControlControllerIntegrationTest.java @@ -19,7 +19,7 @@ import static org.springframework.http.HttpHeaders.IF_UNMODIFIED_SINCE; @ExtendWith(SpringExtension.class) @WebAppConfiguration -@ContextConfiguration(classes = {WebConfig.class, WebConfig.class}) +@ContextConfiguration(classes = {CacheWebConfig.class, CacheWebConfig.class}) public class CacheControlControllerIntegrationTest { @Autowired diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/EmployeeMvcIntegrationTest.java b/spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeMvcIntegrationTest.java similarity index 81% rename from spring-mvc-java/src/test/java/com/baeldung/web/controller/EmployeeMvcIntegrationTest.java rename to spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeMvcIntegrationTest.java index 86420a5fbd..c061c1efc7 100644 --- a/spring-mvc-java/src/test/java/com/baeldung/web/controller/EmployeeMvcIntegrationTest.java +++ b/spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeMvcIntegrationTest.java @@ -1,11 +1,7 @@ -package com.baeldung.web.controller; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; +package com.baeldung.matrix; +import com.baeldung.matrix.config.MatrixWebConfig; +import com.baeldung.matrix.controller.EmployeeController; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -18,11 +14,13 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; -import com.baeldung.spring.web.config.WebConfig; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration -@ContextConfiguration(classes = WebConfig.class) +@ContextConfiguration(classes = { MatrixWebConfig.class, EmployeeController.class }) public class EmployeeMvcIntegrationTest { @Autowired diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/EmployeeNoMvcIntegrationTest.java b/spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeNoMvcIntegrationTest.java similarity index 86% rename from spring-mvc-java/src/test/java/com/baeldung/web/controller/EmployeeNoMvcIntegrationTest.java rename to spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeNoMvcIntegrationTest.java index e84c20c973..2ca70cc0b9 100644 --- a/spring-mvc-java/src/test/java/com/baeldung/web/controller/EmployeeNoMvcIntegrationTest.java +++ b/spring-mvc-java-2/src/test/java/com/baeldung/matrix/EmployeeNoMvcIntegrationTest.java @@ -1,5 +1,8 @@ -package com.baeldung.web.controller; +package com.baeldung.matrix; +import com.baeldung.matrix.config.MatrixWebConfig; +import com.baeldung.matrix.controller.EmployeeController; +import com.baeldung.matrix.model.Employee; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -9,12 +12,9 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; -import com.baeldung.model.Employee; -import com.baeldung.spring.web.config.WebConfig; - @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration -@ContextConfiguration(classes = WebConfig.class) +@ContextConfiguration(classes = { MatrixWebConfig.class, EmployeeController.class }) public class EmployeeNoMvcIntegrationTest { @Autowired diff --git a/spring-mvc-java/README.md b/spring-mvc-java/README.md index 0edc73e0e0..877d92901a 100644 --- a/spring-mvc-java/README.md +++ b/spring-mvc-java/README.md @@ -8,7 +8,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring ### Relevant Articles: - [Integration Testing in Spring](https://www.baeldung.com/integration-testing-in-spring) -- [A Quick Guide to Spring MVC Matrix Variables](https://www.baeldung.com/spring-mvc-matrix-variables) - [File Upload with Spring MVC](https://www.baeldung.com/spring-file-upload) - [Introduction to HtmlUnit](https://www.baeldung.com/htmlunit) - [Upload and Display Excel Files with Spring MVC](https://www.baeldung.com/spring-mvc-excel-files) From fb5b157ce455b182a729ede1362d86bf4e1a235e Mon Sep 17 00:00:00 2001 From: sasam0320 <63002713+sasam0320@users.noreply.github.com> Date: Wed, 6 May 2020 05:28:28 +0200 Subject: [PATCH 471/503] Add missing code snippets (#9228) --- .../spring-boot-properties/pom.xml | 1 + .../processor/JdbcProperties.java | 21 +++++++++++ .../processor/PropertyBeanInjection.java | 11 ++++-- .../configurationproperties/Database.java | 36 +++++++++++++++++++ .../DatabaseConfig.java | 23 ++++++++++++ .../DatabaseConfigPropertiesApp.java | 13 +++++++ .../spring/PropertyPlaceholderConfig.java | 23 ++++++++++++ .../PropertySourcesPlaceholderConfig.java | 24 +++++++++++++ .../src/main/resources/application.properties | 3 -- .../main/resources/configForProperties.xml | 6 +++- .../configForPropertyPlaceholderBeans.xml | 23 ++++++++++++ .../configuration-processor.properties | 3 ++ .../src/main/resources/database.properties | 4 +++ .../src/main/resources/database.yml | 5 +++ .../PropertyBeanInjectionUnitTest.java | 5 +++ .../ConfigPropertiesIntegrationTest.java | 16 +++++++-- ...PlaceholdersJavaConfigIntegrationTest.java | 23 ++++++++++++ ...ePlaceholdersXmlConfigIntegrationTest.java | 25 +++++++++++++ ...plePropertiesXmlConfigIntegrationTest.java | 3 ++ .../baeldung/test/IntegrationTestSuite.java | 6 ++-- .../configuration-processor.properties | 1 + .../test/resources/database-test.properties | 3 ++ 22 files changed, 268 insertions(+), 10 deletions(-) create mode 100644 spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/JdbcProperties.java create mode 100644 spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/Database.java create mode 100644 spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/DatabaseConfig.java create mode 100644 spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/DatabaseConfigPropertiesApp.java create mode 100644 spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertyPlaceholderConfig.java create mode 100644 spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertySourcesPlaceholderConfig.java create mode 100644 spring-boot-modules/spring-boot-properties/src/main/resources/configForPropertyPlaceholderBeans.xml create mode 100644 spring-boot-modules/spring-boot-properties/src/main/resources/configuration-processor.properties create mode 100644 spring-boot-modules/spring-boot-properties/src/main/resources/database.properties create mode 100644 spring-boot-modules/spring-boot-properties/src/main/resources/database.yml create mode 100644 spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersJavaConfigIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersXmlConfigIntegrationTest.java create mode 100644 spring-boot-modules/spring-boot-properties/src/test/resources/database-test.properties diff --git a/spring-boot-modules/spring-boot-properties/pom.xml b/spring-boot-modules/spring-boot-properties/pom.xml index ec05ec1bdc..ef9c084f4c 100644 --- a/spring-boot-modules/spring-boot-properties/pom.xml +++ b/spring-boot-modules/spring-boot-properties/pom.xml @@ -128,6 +128,7 @@ 4.4.11 @ 2.2.4.RELEASE + com.baeldung.buildproperties.Application
    diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/JdbcProperties.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/JdbcProperties.java new file mode 100644 index 0000000000..bbd193acba --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configuration/processor/JdbcProperties.java @@ -0,0 +1,21 @@ +package com.baeldung.configuration.processor; + +import org.springframework.boot.context.properties.*; +import org.springframework.context.annotation.*; +import org.springframework.beans.factory.annotation.*; + +@Configuration +@ConfigurationProperties(prefix = "com.baeldung") +public class JdbcProperties { + + @Value("${jdbc.url:jdbc:postgresql:/localhost:5432}") + private String jdbcUrl; + + public String getJdbcUrl() { + return jdbcUrl; + } + + public void setJdbcUrl(String jdbcUrl) { + this.jdbcUrl = jdbcUrl; + } +} \ No newline at end of file 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 index 3bcbf41f54..89a8f9458c 100644 --- 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 @@ -6,16 +6,23 @@ import org.springframework.stereotype.*; @Component public class PropertyBeanInjection { - private final CustomProperties customProperties; + private CustomProperties customProperties; - PropertyBeanInjection(@Autowired CustomProperties customProperties) { + private JdbcProperties jdbcProperties; + + PropertyBeanInjection(@Autowired CustomProperties customProperties, @Autowired JdbcProperties jdbcProperties) { this.customProperties = customProperties; + this.jdbcProperties = jdbcProperties; } String getUrl() { return customProperties.getUrl(); } + String getJdbcUrl() { + return jdbcProperties.getJdbcUrl(); + } + int getTimeoutInMilliseconds() { return customProperties.getTimeoutInMilliSeconds(); } diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/Database.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/Database.java new file mode 100644 index 0000000000..990ede35cd --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/Database.java @@ -0,0 +1,36 @@ +package com.baeldung.configurationproperties; + +import org.springframework.boot.context.properties.ConfigurationProperties; + + +@ConfigurationProperties(prefix = "database") +public class Database { + + String url; + String username; + String password; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/DatabaseConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/DatabaseConfig.java new file mode 100644 index 0000000000..8f17c98f03 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/DatabaseConfig.java @@ -0,0 +1,23 @@ +package com.baeldung.configurationproperties; + +import org.springframework.core.env.Environment; +import org.springframework.beans.factory.annotation.*; +import org.springframework.context.annotation.*; + +@Configuration +public class DatabaseConfig { + + @Autowired private Environment env; + + @Bean(name="dataSource") + public Database dataSource() { + + Database dataSource = new Database(); + dataSource.setUrl(env.getProperty("jdbc.url")); + dataSource.setUsername(env.getProperty("database.username")); + dataSource.setPassword(env.getProperty("database.password")); + + return dataSource; + } + +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/DatabaseConfigPropertiesApp.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/DatabaseConfigPropertiesApp.java new file mode 100644 index 0000000000..bb1c937f60 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/configurationproperties/DatabaseConfigPropertiesApp.java @@ -0,0 +1,13 @@ +package com.baeldung.configurationproperties; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackageClasses = {Database.class,DatabaseConfig.class}) +public class DatabaseConfigPropertiesApp{ + + public static void main(String[]args) {SpringApplication.run(DatabaseConfigPropertiesApp.class,args);} + +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertyPlaceholderConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertyPlaceholderConfig.java new file mode 100644 index 0000000000..0d1eb4ccf7 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertyPlaceholderConfig.java @@ -0,0 +1,23 @@ +package com.baeldung.properties.spring; + +import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.*; + +@Configuration +public class PropertyPlaceholderConfig { + + public PropertyPlaceholderConfig(){ + super(); + } + + @Bean + public static PropertyPlaceholderConfigurer properties() { + PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); + Resource[] resources = new ClassPathResource[]{ new ClassPathResource("foo.properties") }; + ppc.setLocations( resources ); + ppc.setIgnoreUnresolvablePlaceholders( true ); + return ppc; + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertySourcesPlaceholderConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertySourcesPlaceholderConfig.java new file mode 100644 index 0000000000..8ff464e4cf --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertySourcesPlaceholderConfig.java @@ -0,0 +1,24 @@ +package com.baeldung.properties.spring; + +import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.*; + +@Configuration +public class PropertySourcesPlaceholderConfig{ + + public PropertySourcesPlaceholderConfig(){ + super(); + } + + @Bean + public static PropertySourcesPlaceholderConfigurer properties(){ + PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer(); + Resource[] resources = new ClassPathResource[]{ new ClassPathResource("foo.properties") }; + pspc.setLocations(resources); + pspc.setIgnoreUnresolvablePlaceholders(true); + return pspc; + } + +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/application.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/application.properties index d4d1df7abc..af38556f81 100644 --- a/spring-boot-modules/spring-boot-properties/src/main/resources/application.properties +++ b/spring-boot-modules/spring-boot-properties/src/main/resources/application.properties @@ -3,6 +3,3 @@ spring.properties.refreshDelay=1000 spring.config.location=file:extra.properties spring.main.allow-bean-definition-overriding=true -database.url=jdbc:postgresql:/localhost:5432/instance -database.username=foo -database.password=bar \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/configForProperties.xml b/spring-boot-modules/spring-boot-properties/src/main/resources/configForProperties.xml index d796f791cb..4468bb485f 100644 --- a/spring-boot-modules/spring-boot-properties/src/main/resources/configForProperties.xml +++ b/spring-boot-modules/spring-boot-properties/src/main/resources/configForProperties.xml @@ -7,10 +7,14 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd" > - + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/configForPropertyPlaceholderBeans.xml b/spring-boot-modules/spring-boot-properties/src/main/resources/configForPropertyPlaceholderBeans.xml new file mode 100644 index 0000000000..a296cf5169 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/resources/configForPropertyPlaceholderBeans.xml @@ -0,0 +1,23 @@ + + + + + + + classpath:foo.properties + + + + + + + + + classpath:foo.properties + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/configuration-processor.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/configuration-processor.properties new file mode 100644 index 0000000000..b68a4fbda3 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/resources/configuration-processor.properties @@ -0,0 +1,3 @@ +com.baeldung.url=www.abc.test.com +com.baeldung.jdbc.url= +com.baeldung.timeout-in-milli-seconds=2000 diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/database.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/database.properties new file mode 100644 index 0000000000..6524ce6109 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/resources/database.properties @@ -0,0 +1,4 @@ +database.url=jdbc:postgresql:/localhost:5432/instance +database.username=foo +database.password=bar +jdbc.url=jdbc:postgresql:/localhost:5432 \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/database.yml b/spring-boot-modules/spring-boot-properties/src/main/resources/database.yml new file mode 100644 index 0000000000..8404d9411a --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/resources/database.yml @@ -0,0 +1,5 @@ +database: + url: jdbc:postresql:/localhost:5432/instance + username: foo + password: bar +secret: foo \ No newline at end of file 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 index bdeb6547c3..eb6add2b94 100644 --- 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 @@ -15,6 +15,11 @@ class PropertyBeanInjectionUnitTest { @Autowired private PropertyBeanInjection propertyBeanInjection; + @Test + void checkThatJdbcPropertiesHaveTheCorrectValueFromPropertiesFile() { + Assertions.assertEquals("jdbc:postgresql:/localhost:5432", propertyBeanInjection.getJdbcUrl()); + } + @Test void checkThatCustomPropertiesHaveTheCorrectValueFromPropertiesFile() { Assertions.assertEquals("www.abc.test.com", propertyBeanInjection.getUrl()); diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ConfigPropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ConfigPropertiesIntegrationTest.java index 141400b1fe..2b0833c387 100644 --- a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ConfigPropertiesIntegrationTest.java +++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/configurationproperties/ConfigPropertiesIntegrationTest.java @@ -4,6 +4,7 @@ import org.junit.Assert; 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.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; @@ -13,13 +14,17 @@ import com.baeldung.properties.AdditionalProperties; import com.baeldung.properties.ConfigPropertiesDemoApplication; @RunWith(SpringRunner.class) -@SpringBootTest(classes = ConfigPropertiesDemoApplication.class) -@TestPropertySource("classpath:configprops-test.properties") +@SpringBootTest(classes = {ConfigPropertiesDemoApplication.class, DatabaseConfigPropertiesApp.class}) +@TestPropertySource(locations = {"classpath:configprops-test.properties", "classpath:database-test.properties"}) public class ConfigPropertiesIntegrationTest { @Autowired private ConfigProperties properties; + @Autowired + @Qualifier("dataSource") + private Database databaseProperties; + @Autowired private AdditionalProperties additionalProperties; @@ -53,4 +58,11 @@ public class ConfigPropertiesIntegrationTest { Assert.assertTrue(additionalProperties.getUnit().equals("km")); Assert.assertTrue(additionalProperties.getMax() == 100); } + + @Test + public void whenDatabasePropertyQueriedthenReturnsProperty() { + Assert.assertTrue(databaseProperties.getUrl().equals("jdbc:postgresql:/localhost:5432")); + Assert.assertTrue(databaseProperties.getUsername().equals("foo")); + Assert.assertTrue(databaseProperties.getPassword().equals("bar")); + } } diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersJavaConfigIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersJavaConfigIntegrationTest.java new file mode 100644 index 0000000000..8ebda90321 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersJavaConfigIntegrationTest.java @@ -0,0 +1,23 @@ +package com.baeldung.properties.multiple; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; + +import com.baeldung.properties.spring.PropertyPlaceholderConfig; +import com.baeldung.properties.spring.PropertySourcesPlaceholderConfig; + +import static org.assertj.core.api.Assertions.assertThat; + +@SpringJUnitConfig({PropertyPlaceholderConfig.class, PropertySourcesPlaceholderConfig.class}) +public class MultiplePlaceholdersJavaConfigIntegrationTest { + + @Value("${key.something}") + private String something; + + + @Test + public void whenReadInjectedValues_thenGetCorrectValues() { + assertThat(something).isEqualTo("val"); + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersXmlConfigIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersXmlConfigIntegrationTest.java new file mode 100644 index 0000000000..b863e2e080 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersXmlConfigIntegrationTest.java @@ -0,0 +1,25 @@ +package com.baeldung.properties.multiple; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; + +import static org.assertj.core.api.Assertions.assertThat; + + +@SpringJUnitConfig(locations = "classpath:configForPropertyPlaceholderBeans.xml") +public class MultiplePlaceholdersXmlConfigIntegrationTest { + + @Value("${foo}") + private String something; + + @Value("${key.something}") + private String something2; + + + @Test + public void whenReadInjectedValues_thenGetCorrectValues() { + assertThat(something).isEqualTo("bar"); + assertThat(something2).isEqualTo("val"); + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesXmlConfigIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesXmlConfigIntegrationTest.java index db71e816dd..6827ee1cf1 100644 --- a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesXmlConfigIntegrationTest.java +++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesXmlConfigIntegrationTest.java @@ -13,9 +13,12 @@ public class MultiplePropertiesXmlConfigIntegrationTest { @Value("${key.something2}") private String something2; + @Value("${jdbc.url}") private String jdbcUrl; + @Test public void whenReadInjectedValues_thenGetCorrectValues() { assertThat(something).isEqualTo("val"); assertThat(something2).isEqualTo("val2"); + assertThat(jdbcUrl).isEqualTo("jdbc:postgresql:/localhost:5432"); } } diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/test/IntegrationTestSuite.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/test/IntegrationTestSuite.java index d41d328867..0e0f8f6230 100644 --- a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/test/IntegrationTestSuite.java +++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/test/IntegrationTestSuite.java @@ -10,6 +10,8 @@ import com.baeldung.properties.basic.PropertiesWithXmlIntegrationTest; import com.baeldung.properties.external.ExternalPropertiesWithJavaIntegrationTest; import com.baeldung.properties.external.ExternalPropertiesWithMultipleXmlsIntegrationTest; import com.baeldung.properties.external.ExternalPropertiesWithXmlManualTest; +import com.baeldung.properties.multiple.MultiplePropertiesXmlConfigIntegrationTest; +import com.baeldung.properties.multiple.MultiplePlaceholdersXmlConfigIntegrationTest; @RunWith(Suite.class) @SuiteClasses({ //@formatter:off @@ -17,8 +19,8 @@ import com.baeldung.properties.external.ExternalPropertiesWithXmlManualTest; ExternalPropertiesWithJavaIntegrationTest.class, ExternalPropertiesWithMultipleXmlsIntegrationTest.class, ExternalPropertiesWithXmlManualTest.class, - ExtendedPropertiesWithJavaIntegrationTest.class, - PropertiesWithMultipleXmlsIntegrationTest.class, + ExtendedPropertiesWithJavaIntegrationTest.class, MultiplePropertiesXmlConfigIntegrationTest.class, + PropertiesWithMultipleXmlsIntegrationTest.class, MultiplePlaceholdersXmlConfigIntegrationTest.class })// @formatter:on public final class IntegrationTestSuite { // 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 index 00369f2eff..b68a4fbda3 100644 --- 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 @@ -1,2 +1,3 @@ com.baeldung.url=www.abc.test.com +com.baeldung.jdbc.url= com.baeldung.timeout-in-milli-seconds=2000 diff --git a/spring-boot-modules/spring-boot-properties/src/test/resources/database-test.properties b/spring-boot-modules/spring-boot-properties/src/test/resources/database-test.properties new file mode 100644 index 0000000000..384d0850ab --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/test/resources/database-test.properties @@ -0,0 +1,3 @@ +jdbc.url=jdbc:postgresql:/localhost:5432 +database.username=foo +database.password=bar From b4315b82d889944899672ddde5675c31599fdc33 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 6 May 2020 15:12:08 +0800 Subject: [PATCH 472/503] Update README.md --- spring-thymeleaf-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-thymeleaf-2/README.md b/spring-thymeleaf-2/README.md index d2d10f81da..a8c067a443 100644 --- a/spring-thymeleaf-2/README.md +++ b/spring-thymeleaf-2/README.md @@ -13,5 +13,5 @@ This module contains articles about Spring with Thymeleaf - [Working with Boolean in Thymeleaf](https://www.baeldung.com/thymeleaf-boolean) - [Working With Custom HTML Attributes in Thymeleaf](https://www.baeldung.com/thymeleaf-custom-html-attributes) - [How to Create an Executable JAR with Maven](https://www.baeldung.com/executable-jar-with-maven) -- [https://www.baeldung.com/spring-mvc-thymeleaf-data](https://www.baeldung.com/spring-mvc-thymeleaf-data) +- [Spring MVC Data and Thymeleaf](https://www.baeldung.com/spring-mvc-thymeleaf-data) - [[<-- prev]](/spring-thymeleaf) From c9ebd8e33e6da1859c06e02e53db7dd615bef7e1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 6 May 2020 15:17:10 +0800 Subject: [PATCH 473/503] Update README.md --- atomikos/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/atomikos/README.md b/atomikos/README.md index 2c44e388fe..f9129233ec 100644 --- a/atomikos/README.md +++ b/atomikos/README.md @@ -1,5 +1,4 @@ ## Atomikos - This module contains articles about Atomikos ### Relevant Articles: From 2dd9b8010750d017d47597e8df82d3ce5a825943 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Wed, 6 May 2020 18:14:05 +0530 Subject: [PATCH 474/503] JAVA-956: Migrate apache-shiro to parent-boot-2 --- apache-shiro/pom.xml | 4 ++-- .../src/main/java/com/baeldung/Main.java | 7 ++++-- .../main/java/com/baeldung/MyCustomRealm.java | 22 +++++++++++++------ .../shiro/permissions/custom/Main.java | 9 ++++---- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/apache-shiro/pom.xml b/apache-shiro/pom.xml index d519ba42af..3df6283437 100644 --- a/apache-shiro/pom.xml +++ b/apache-shiro/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/apache-shiro/src/main/java/com/baeldung/Main.java b/apache-shiro/src/main/java/com/baeldung/Main.java index 5e341f251b..99515bb705 100644 --- a/apache-shiro/src/main/java/com/baeldung/Main.java +++ b/apache-shiro/src/main/java/com/baeldung/Main.java @@ -1,11 +1,14 @@ package com.baeldung; import org.apache.shiro.SecurityUtils; -import org.apache.shiro.authc.*; +import org.apache.shiro.authc.AuthenticationException; +import org.apache.shiro.authc.IncorrectCredentialsException; +import org.apache.shiro.authc.LockedAccountException; +import org.apache.shiro.authc.UnknownAccountException; +import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.mgt.DefaultSecurityManager; import org.apache.shiro.mgt.SecurityManager; import org.apache.shiro.realm.Realm; -import org.apache.shiro.realm.text.IniRealm; import org.apache.shiro.session.Session; import org.apache.shiro.subject.Subject; import org.slf4j.Logger; diff --git a/apache-shiro/src/main/java/com/baeldung/MyCustomRealm.java b/apache-shiro/src/main/java/com/baeldung/MyCustomRealm.java index 8d792c76a5..6d7c01d96e 100644 --- a/apache-shiro/src/main/java/com/baeldung/MyCustomRealm.java +++ b/apache-shiro/src/main/java/com/baeldung/MyCustomRealm.java @@ -1,16 +1,24 @@ package com.baeldung; -import org.apache.shiro.authc.*; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.apache.shiro.authc.AuthenticationException; +import org.apache.shiro.authc.AuthenticationInfo; +import org.apache.shiro.authc.AuthenticationToken; +import org.apache.shiro.authc.SimpleAuthenticationInfo; +import org.apache.shiro.authc.UnknownAccountException; +import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.authz.AuthorizationInfo; import org.apache.shiro.authz.SimpleAuthorizationInfo; import org.apache.shiro.realm.jdbc.JdbcRealm; import org.apache.shiro.subject.PrincipalCollection; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.sql.Connection; -import java.sql.SQLException; -import java.util.*; public class MyCustomRealm extends JdbcRealm { diff --git a/apache-shiro/src/main/java/com/baeldung/shiro/permissions/custom/Main.java b/apache-shiro/src/main/java/com/baeldung/shiro/permissions/custom/Main.java index a373122d6c..a902a24388 100644 --- a/apache-shiro/src/main/java/com/baeldung/shiro/permissions/custom/Main.java +++ b/apache-shiro/src/main/java/com/baeldung/shiro/permissions/custom/Main.java @@ -1,14 +1,15 @@ package com.baeldung.shiro.permissions.custom; -import com.baeldung.MyCustomRealm; import org.apache.shiro.SecurityUtils; -import org.apache.shiro.authc.*; +import org.apache.shiro.authc.AuthenticationException; +import org.apache.shiro.authc.IncorrectCredentialsException; +import org.apache.shiro.authc.LockedAccountException; +import org.apache.shiro.authc.UnknownAccountException; +import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.config.Ini; import org.apache.shiro.mgt.DefaultSecurityManager; import org.apache.shiro.mgt.SecurityManager; -import org.apache.shiro.realm.Realm; import org.apache.shiro.realm.text.IniRealm; -import org.apache.shiro.session.Session; import org.apache.shiro.subject.Subject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; From 9770eda888cbb418aa6be7ff1c891c706bf1339c Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 6 May 2020 10:38:16 -0600 Subject: [PATCH 475/503] BAEL-3972: Move code examples to new package --- .../spring-security-core/README.md | 1 + .../app/controller/TaskController.java | 58 ----------------- .../java/com/baeldung/checkrolejava/App.java | 11 ++++ .../checkrolejava/UnauthorizedException.java | 8 +++ .../checkrolejava/UserController.java | 62 +++++++++++++++++++ 5 files changed, 82 insertions(+), 58 deletions(-) create mode 100644 spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/App.java create mode 100644 spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/UnauthorizedException.java create mode 100644 spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/UserController.java diff --git a/spring-security-modules/spring-security-core/README.md b/spring-security-modules/spring-security-core/README.md index e42dfecaa0..f28b3abb2b 100644 --- a/spring-security-modules/spring-security-core/README.md +++ b/spring-security-modules/spring-security-core/README.md @@ -8,6 +8,7 @@ This module contains articles about core Spring Security - [Introduction to Spring Method Security](https://www.baeldung.com/spring-security-method-security) - [Overview and Need for DelegatingFilterProxy in Spring](https://www.baeldung.com/spring-delegating-filter-proxy) - [Deny Access on Missing @PreAuthorize to Spring Controller Methods](https://www.baeldung.com/spring-deny-access) +- [Spring Security: Check If a User Has a Role in Java](https://www.baeldung.com/spring-security-check-user-role) ### Build the Project diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java index 67072b5d61..7e6b2c3d9c 100644 --- a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/app/controller/TaskController.java @@ -42,62 +42,4 @@ public class TaskController { return ResponseEntity.ok().body(tasks); } - - /** - * Example of restricting specific endpoints to specific roles using @PreAuthorize. - */ - @GetMapping("/manager") - @PreAuthorize("hasRole('ROLE_MANAGER')") - public ResponseEntity> getAlManagerTasks() { - Iterable tasks = taskService.findAll(); - - return ResponseEntity.ok().body(tasks); - } - - /** - * Example of restricting specific endpoints to specific roles using SecurityContext. - */ - @GetMapping("/actuator") - public ResponseEntity> getAlActuatorTasks() { - Authentication auth = SecurityContextHolder.getContext().getAuthentication(); - if (auth != null && auth.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ACTUATOR"))) - { - return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); - } - - Iterable tasks = taskService.findAll(); - - return ResponseEntity.ok().body(tasks); - } - - /** - * Example of restricting specific endpoints to specific roles using UserDetailsService. - */ - @GetMapping("/admin") - public ResponseEntity> getAlAdminTasks() { - if(userDetailsService != null) { - UserDetails details = userDetailsService.loadUserByUsername("pam"); - if (details != null && details.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ADMIN"))) { - return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); - } - } - - Iterable tasks = taskService.findAll(); - - return ResponseEntity.ok().body(tasks); - } - - /** - * Example of restricting specific endpoints to specific roles using HttpServletRequest. - */ - @GetMapping("/admin2") - public ResponseEntity> getAlAdminTasksUsingServlet(HttpServletRequest request) { - if (!request.isUserInRole("ROLE_ADMIN")) { - return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); - } - - Iterable tasks = taskService.findAll(); - - return ResponseEntity.ok().body(tasks); - } } diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/App.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/App.java new file mode 100644 index 0000000000..357583a572 --- /dev/null +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/App.java @@ -0,0 +1,11 @@ +package com.baeldung.checkrolejava; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class App { + public static void main(String[] args) { + SpringApplication.run(com.baeldung.app.App.class, args); + } +} diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/UnauthorizedException.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/UnauthorizedException.java new file mode 100644 index 0000000000..11fe9f9e5f --- /dev/null +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/UnauthorizedException.java @@ -0,0 +1,8 @@ +package com.baeldung.checkrolejava; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +@ResponseStatus(value = HttpStatus.UNAUTHORIZED) +public class UnauthorizedException extends RuntimeException { +} diff --git a/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/UserController.java b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/UserController.java new file mode 100644 index 0000000000..3092e94c7f --- /dev/null +++ b/spring-security-modules/spring-security-core/src/main/java/com/baeldung/checkrolejava/UserController.java @@ -0,0 +1,62 @@ +package com.baeldung.checkrolejava; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + +import javax.servlet.http.HttpServletRequest; + +@Controller +public class UserController { + + @Autowired + private UserDetailsService userDetailsService; + + @PreAuthorize("hasRole('ROLE_ADMIN')") + @GetMapping("/user/{id}") + public String getUser(@PathVariable("id") String id) { + return "user"; + } + + @PreAuthorize("hasAnyRole('ROLE_ADMIN','ROLE_MANAGER')") + @GetMapping("/users") + public String getUsers() { + return "users"; + } + + @GetMapping("v2/user/{id}") + public String getUserUsingSecurityContext() { + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + if (auth != null && auth.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ADMIN"))) { + return "user"; + } + + throw new UnauthorizedException(); + } + + @GetMapping("v2/users") + public String getUsersUsingDetailsService() { + UserDetails details = userDetailsService.loadUserByUsername("mike"); + if (details != null && details.getAuthorities().stream() + .anyMatch(a -> a.getAuthority().equals("ADMIN"))) { + return "users"; + } + + throw new UnauthorizedException(); + } + + @GetMapping("v3/users") + public String getUsers(HttpServletRequest request) { + if (request.isUserInRole("ROLE_ADMIN")) { + return "users"; + } + + throw new UnauthorizedException(); + } +} From 86da74f733b9f74eac83cff3012ea9241c660f89 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Wed, 6 May 2020 22:35:28 +0530 Subject: [PATCH 476/503] JAVA-955: Migrate stripe to parent-boot-2 --- stripe/pom.xml | 4 ++-- .../com/baeldung/stripe/ChargeRequest.java | 23 +++++++++++++++++++ .../src/main/resources/application.properties | 2 ++ stripe/src/main/resources/static/index.html | 2 +- 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 stripe/src/main/resources/application.properties diff --git a/stripe/pom.xml b/stripe/pom.xml index 07d2968f5f..29a07b4163 100644 --- a/stripe/pom.xml +++ b/stripe/pom.xml @@ -11,9 +11,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/stripe/src/main/java/com/baeldung/stripe/ChargeRequest.java b/stripe/src/main/java/com/baeldung/stripe/ChargeRequest.java index a5c056b659..190911afb3 100644 --- a/stripe/src/main/java/com/baeldung/stripe/ChargeRequest.java +++ b/stripe/src/main/java/com/baeldung/stripe/ChargeRequest.java @@ -13,4 +13,27 @@ public class ChargeRequest { private Currency currency; private String stripeEmail; private String stripeToken; + public String getDescription() { + return description; + } + public int getAmount() { + return amount; + } + public Currency getCurrency() { + return currency; + } + public String getStripeEmail() { + return stripeEmail; + } + public String getStripeToken() { + return stripeToken; + } + public void setDescription(String description) { + this.description = description; + } + public void setCurrency(Currency currency) { + this.currency = currency; + } + + } diff --git a/stripe/src/main/resources/application.properties b/stripe/src/main/resources/application.properties new file mode 100644 index 0000000000..f36df33897 --- /dev/null +++ b/stripe/src/main/resources/application.properties @@ -0,0 +1,2 @@ +STRIPE_SECRET_KEY= +STRIPE_PUBLIC_KEY= \ No newline at end of file diff --git a/stripe/src/main/resources/static/index.html b/stripe/src/main/resources/static/index.html index 090a01e91d..d7ba2bef91 100644 --- a/stripe/src/main/resources/static/index.html +++ b/stripe/src/main/resources/static/index.html @@ -1,7 +1,7 @@ - + From 1497cbd69b143064b6ea9e2d9909c367b9a614c1 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Wed, 6 May 2020 22:43:04 +0530 Subject: [PATCH 477/503] JAVA-955: removed lombok version --- stripe/pom.xml | 3 --- 1 file changed, 3 deletions(-) diff --git a/stripe/pom.xml b/stripe/pom.xml index 29a07b4163..48505c9e4e 100644 --- a/stripe/pom.xml +++ b/stripe/pom.xml @@ -28,9 +28,6 @@ org.projectlombok lombok - ${lombok.version} - com.stripe From 847d6ab0424833d0896e796c8a2fe91825f0c95b Mon Sep 17 00:00:00 2001 From: Yavuz Tas <12643010+yavuztas@users.noreply.github.com> Date: Thu, 7 May 2020 04:22:23 +0200 Subject: [PATCH 478/503] Changes for BAEL-2621 (#9217) * update dependency versions to latest * merge repository packages * remove obselete xml configuration * fix formatting * clean up * update package name * revert spring data jpa xml config and demonstrate how to import in PersistenceConfig by a commented @ImportResource annotation * rename jpa repositories xml to make it more clear * remove obselete @EnableJpaRepositories configs since we don't use spring data's jpa repositories for these congigurations --- .../spring-persistence-simple/pom.xml | 4 +-- .../baeldung/config/PersistenceConfig.java | 4 +-- .../baeldung/config/PersistenceJPAConfig.java | 2 -- .../persistence/config/PersistenceConfig.java | 17 ++++++------- .../spring/data/persistence/model/User.java | 25 ++++++++++++------- .../{dao => repository}/IFooDao.java | 4 ++- .../UserRepository.java | 22 ++++++++-------- .../UserRepositoryCustom.java | 8 +++--- .../UserRepositoryCustomImpl.java | 17 +++++-------- .../persistence/service/impl/FooService.java | 2 +- ...ml => springDataJpaRepositoriesConfig.xml} | 7 +++--- .../UserRepositoryCommon.java | 2 +- .../UserRepositoryIntegrationTest.java | 13 ++++------ 13 files changed, 62 insertions(+), 65 deletions(-) rename persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/{dao => repository}/IFooDao.java (87%) rename persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/{jpaquery => repository}/UserRepository.java (96%) rename persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/{jpaquery => repository}/UserRepositoryCustom.java (85%) rename persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/{jpaquery => repository}/UserRepositoryCustomImpl.java (85%) rename persistence-modules/spring-persistence-simple/src/main/resources/{springDataPersistenceConfig.xml => springDataJpaRepositoriesConfig.xml} (58%) rename persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/{jpaquery => repository}/UserRepositoryCommon.java (99%) rename persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/{jpaquery => repository}/UserRepositoryIntegrationTest.java (94%) diff --git a/persistence-modules/spring-persistence-simple/pom.xml b/persistence-modules/spring-persistence-simple/pom.xml index 878c4592f9..7318ec55bd 100644 --- a/persistence-modules/spring-persistence-simple/pom.xml +++ b/persistence-modules/spring-persistence-simple/pom.xml @@ -132,13 +132,13 @@ - 5.2.5.RELEASE + 5.2.6.RELEASE 5.4.13.Final 8.0.19 1.4.200 - 2.2.6.RELEASE + 2.2.7.RELEASE 9.0.0.M26 1.1 4.2.1 diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceConfig.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceConfig.java index 80f3ff14c5..cdddbaa787 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceConfig.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceConfig.java @@ -11,7 +11,6 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.orm.hibernate5.HibernateTransactionManager; import org.springframework.orm.hibernate5.LocalSessionFactoryBean; import org.springframework.orm.jpa.JpaTransactionManager; @@ -26,7 +25,6 @@ import java.util.Properties; @Configuration @EnableTransactionManagement -@EnableJpaRepositories(basePackages = { "com.baeldung.hibernate.dao" }, transactionManagerRef = "jpaTransactionManager") @EnableJpaAuditing @PropertySource({ "classpath:persistence-mysql.properties" }) @ComponentScan(basePackages = { "com.baeldung.persistence.dao", "com.baeldung.jpa.dao" }) @@ -97,7 +95,7 @@ public class PersistenceConfig { return new FooService(); } - private final Properties hibernateProperties() { + private Properties hibernateProperties() { final Properties hibernateProperties = new Properties(); hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java index 06cae493c9..e8a2aefd6b 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java @@ -8,7 +8,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.jdbc.datasource.DriverManagerDataSource; import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.JpaVendorAdapter; @@ -24,7 +23,6 @@ import java.util.Properties; @EnableTransactionManagement @PropertySource({ "classpath:persistence-h2.properties" }) @ComponentScan({ "com.baeldung.persistence","com.baeldung.jpa.dao" }) -@EnableJpaRepositories(basePackages = "com.baeldung.jpa.dao") public class PersistenceJPAConfig { @Autowired diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/config/PersistenceConfig.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/config/PersistenceConfig.java index 66b540a692..604923d615 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/config/PersistenceConfig.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/config/PersistenceConfig.java @@ -1,9 +1,6 @@ package com.baeldung.spring.data.persistence.config; -import java.util.Properties; - -import javax.sql.DataSource; - +import com.google.common.base.Preconditions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -19,14 +16,15 @@ import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; -import com.google.common.base.Preconditions; +import javax.sql.DataSource; +import java.util.Properties; @Configuration @EnableTransactionManagement @PropertySource({ "classpath:persistence-${envTarget:h2}.properties" }) @ComponentScan({ "com.baeldung.spring.data.persistence" }) -// @ImportResource("classpath*:springDataPersistenceConfig.xml") -@EnableJpaRepositories(basePackages = { "com.baeldung.spring.data.persistence.dao", "com.baeldung.spring.data.persistence.jpaquery" }) +//@ImportResource("classpath*:*springDataJpaRepositoriesConfig.xml") +@EnableJpaRepositories("com.baeldung.spring.data.persistence.repository") public class PersistenceConfig { @Autowired @@ -40,10 +38,9 @@ public class PersistenceConfig { public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); - em.setPackagesToScan(new String[] { "com.baeldung.spring.data.persistence.model" }); + em.setPackagesToScan("com.baeldung.spring.data.persistence.model"); final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); - // vendorAdapter.set em.setJpaVendorAdapter(vendorAdapter); em.setJpaProperties(additionalProperties()); @@ -78,7 +75,7 @@ public class PersistenceConfig { final Properties hibernateProperties = new Properties(); hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto")); hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect")); - // hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true"); + return hibernateProperties; } diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/User.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/User.java index 09f1092644..1475eccbf0 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/User.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/model/User.java @@ -1,7 +1,6 @@ package com.baeldung.spring.data.persistence.model; import javax.persistence.*; - import java.time.LocalDate; import java.util.List; import java.util.Objects; @@ -13,14 +12,22 @@ public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private int id; + private String name; + private LocalDate creationDate; + private LocalDate lastLoginDate; + private boolean active; + private int age; + @Column(unique = true, nullable = false) private String email; + private Integer status; + @OneToMany List possessionList; @@ -28,7 +35,7 @@ public class User { super(); } - public User(String name, LocalDate creationDate,String email, Integer status) { + public User(String name, LocalDate creationDate, String email, Integer status) { this.name = name; this.creationDate = creationDate; this.email = email; @@ -75,7 +82,7 @@ public class User { public void setAge(final int age) { this.age = age; } - + public LocalDate getCreationDate() { return creationDate; } @@ -94,18 +101,18 @@ public class User { builder.append("User [name=").append(name).append(", id=").append(id).append("]"); return builder.toString(); } - + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; User user = (User) o; return id == user.id && - age == user.age && - Objects.equals(name, user.name) && - Objects.equals(creationDate, user.creationDate) && - Objects.equals(email, user.email) && - Objects.equals(status, user.status); + age == user.age && + Objects.equals(name, user.name) && + Objects.equals(creationDate, user.creationDate) && + Objects.equals(email, user.email) && + Objects.equals(status, user.status); } @Override diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/dao/IFooDao.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/IFooDao.java similarity index 87% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/dao/IFooDao.java rename to persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/IFooDao.java index d2b746dc8b..0b750e37e1 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/dao/IFooDao.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/IFooDao.java @@ -1,11 +1,13 @@ -package com.baeldung.spring.data.persistence.dao; +package com.baeldung.spring.data.persistence.repository; import com.baeldung.spring.data.persistence.model.Foo; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; + public interface IFooDao extends JpaRepository { @Query("SELECT f FROM Foo f WHERE LOWER(f.name) = LOWER(:name)") Foo retrieveByName(@Param("name") String name); + } diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepository.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepository.java similarity index 96% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepository.java rename to persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepository.java index f22970c401..a8e3a536c3 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepository.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepository.java @@ -1,9 +1,4 @@ -package com.baeldung.spring.data.persistence.jpaquery; - -import java.time.LocalDate; -import java.util.Collection; -import java.util.List; -import java.util.stream.Stream; +package com.baeldung.spring.data.persistence.repository; import com.baeldung.spring.data.persistence.model.User; import org.springframework.data.domain.Page; @@ -14,13 +9,18 @@ import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import java.time.LocalDate; +import java.util.Collection; +import java.util.List; +import java.util.stream.Stream; + public interface UserRepository extends JpaRepository, UserRepositoryCustom { Stream findAllByName(String name); @Query("SELECT u FROM User u WHERE u.status = 1") Collection findAllActiveUsers(); - + @Query("select u from User u where u.email like '%@gmail.com'") List findUsersWithGmailAddress(); @@ -74,14 +74,14 @@ public interface UserRepository extends JpaRepository, UserReposi @Query(value = "INSERT INTO Users (name, age, email, status, active) VALUES (:name, :age, :email, :status, :active)", nativeQuery = true) @Modifying void insertUser(@Param("name") String name, @Param("age") Integer age, @Param("email") String email, @Param("status") Integer status, @Param("active") boolean active); - + @Modifying @Query(value = "UPDATE Users u SET status = ? WHERE u.name = ?", nativeQuery = true) int updateUserSetStatusForNameNativePostgres(Integer status, String name); - + @Query(value = "SELECT u FROM User u WHERE u.name IN :names") - List findUserByNameList(@Param("names") Collection names); - + List findUserByNameList(@Param("names") Collection names); + void deleteAllByCreationDateAfter(LocalDate date); @Modifying(clearAutomatically = true, flushAutomatically = true) diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCustom.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustom.java similarity index 85% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCustom.java rename to persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustom.java index 8bfcb93158..77e661bbbe 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCustom.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustom.java @@ -1,14 +1,16 @@ -package com.baeldung.spring.data.persistence.jpaquery; +package com.baeldung.spring.data.persistence.repository; + +import com.baeldung.spring.data.persistence.model.User; import java.util.Collection; import java.util.List; import java.util.Set; import java.util.function.Predicate; -import com.baeldung.spring.data.persistence.model.User; - public interface UserRepositoryCustom { + List findUserByEmails(Set emails); List findAllUsersByPredicates(Collection> predicates); + } diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCustomImpl.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustomImpl.java similarity index 85% rename from persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCustomImpl.java rename to persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustomImpl.java index f264ca0b44..366b2c54d0 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCustomImpl.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCustomImpl.java @@ -1,5 +1,10 @@ -package com.baeldung.spring.data.persistence.jpaquery; +package com.baeldung.spring.data.persistence.repository; +import com.baeldung.spring.data.persistence.model.User; + +import javax.persistence.EntityManager; +import javax.persistence.PersistenceContext; +import javax.persistence.criteria.*; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -7,16 +12,6 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Path; -import javax.persistence.criteria.Predicate; -import javax.persistence.criteria.Root; - -import com.baeldung.spring.data.persistence.model.User; - public class UserRepositoryCustomImpl implements UserRepositoryCustom { @PersistenceContext diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/impl/FooService.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/impl/FooService.java index cd566ba9f6..c1406b8602 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/impl/FooService.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/spring/data/persistence/service/impl/FooService.java @@ -2,7 +2,7 @@ package com.baeldung.spring.data.persistence.service.impl; import com.baeldung.spring.data.persistence.model.Foo; -import com.baeldung.spring.data.persistence.dao.IFooDao; +import com.baeldung.spring.data.persistence.repository.IFooDao; import com.baeldung.spring.data.persistence.service.IFooService; import com.baeldung.spring.data.persistence.service.common.AbstractService; import org.springframework.beans.factory.annotation.Autowired; diff --git a/persistence-modules/spring-persistence-simple/src/main/resources/springDataPersistenceConfig.xml b/persistence-modules/spring-persistence-simple/src/main/resources/springDataJpaRepositoriesConfig.xml similarity index 58% rename from persistence-modules/spring-persistence-simple/src/main/resources/springDataPersistenceConfig.xml rename to persistence-modules/spring-persistence-simple/src/main/resources/springDataJpaRepositoriesConfig.xml index 5ea2d9c05b..91778a17af 100644 --- a/persistence-modules/spring-persistence-simple/src/main/resources/springDataPersistenceConfig.xml +++ b/persistence-modules/spring-persistence-simple/src/main/resources/springDataJpaRepositoriesConfig.xml @@ -1,12 +1,13 @@ - - + \ No newline at end of file diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCommon.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCommon.java similarity index 99% rename from persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCommon.java rename to persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCommon.java index 5874b3c643..13b5b4357d 100644 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryCommon.java +++ b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryCommon.java @@ -1,4 +1,4 @@ -package com.baeldung.spring.data.persistence.jpaquery; +package com.baeldung.spring.data.persistence.repository; import com.baeldung.spring.data.persistence.config.PersistenceConfig; import com.baeldung.spring.data.persistence.model.User; diff --git a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryIntegrationTest.java b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryIntegrationTest.java similarity index 94% rename from persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryIntegrationTest.java rename to persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryIntegrationTest.java index 3bffb51917..c76e345fdd 100644 --- a/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/jpaquery/UserRepositoryIntegrationTest.java +++ b/persistence-modules/spring-persistence-simple/src/test/java/com/baeldung/spring/data/persistence/repository/UserRepositoryIntegrationTest.java @@ -1,8 +1,4 @@ -package com.baeldung.spring.data.persistence.jpaquery; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.time.LocalDate; +package com.baeldung.spring.data.persistence.repository; import com.baeldung.spring.data.persistence.config.PersistenceConfig; import com.baeldung.spring.data.persistence.model.User; @@ -14,9 +10,10 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.support.AnnotationConfigContextLoader; import org.springframework.transaction.annotation.Transactional; -/** - * Created by adam. - */ +import java.time.LocalDate; + +import static org.assertj.core.api.Assertions.assertThat; + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class) @DirtiesContext From 0e33f2d06cd9f71bdfa810e1ecd6bf2c754b4cab Mon Sep 17 00:00:00 2001 From: Maciej Glowka Date: Thu, 7 May 2020 23:25:43 +0200 Subject: [PATCH 479/503] BAEL-3829: fixed test method names --- .../dynamic/autowire/DynamicAutowireIntegrationTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spring-core-4/src/test/java/com/baeldung/dynamic/autowire/DynamicAutowireIntegrationTest.java b/spring-core-4/src/test/java/com/baeldung/dynamic/autowire/DynamicAutowireIntegrationTest.java index 3eb6268e97..56582ecb66 100644 --- a/spring-core-4/src/test/java/com/baeldung/dynamic/autowire/DynamicAutowireIntegrationTest.java +++ b/spring-core-4/src/test/java/com/baeldung/dynamic/autowire/DynamicAutowireIntegrationTest.java @@ -20,10 +20,13 @@ public class DynamicAutowireIntegrationTest { private CustomMapFromListDynamicAutowireService customMapFromListDynamicAutowireService; @Test - public void testConstructWorkerByJava() { + public void givenDynamicallyAutowiredBean_whenCheckingServerInGB_thenServerIsNotActive() { assertThat(beanFactoryDynamicAutowireService.isServerActive("GB", 101), is(false)); assertThat(customMapFromListDynamicAutowireService.isServerActive("GB", 101), is(false)); + } + @Test + public void givenDynamicallyAutowiredBean_whenCheckingServerInUS_thenServerIsActive() { assertThat(beanFactoryDynamicAutowireService.isServerActive("US", 101), is(true)); assertThat(customMapFromListDynamicAutowireService.isServerActive("US", 101), is(true)); } From a93fc0541e9f463f394659fb9a1a05ec1f13e689 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Fri, 8 May 2020 19:06:20 +0530 Subject: [PATCH 480/503] JAVA-954: Migrate spring-social-login to parent-boot-2 --- spring-social-login/pom.xml | 20 +++++++++--- .../java/com/baeldung/config/Application.java | 2 +- .../com/baeldung/config/SecurityConfig.java | 32 ++++++++++++++----- 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/spring-social-login/pom.xml b/spring-social-login/pom.xml index 9fa839f1c2..628f439cc0 100644 --- a/spring-social-login/pom.xml +++ b/spring-social-login/pom.xml @@ -8,9 +8,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 @@ -42,15 +42,16 @@ org.thymeleaf.extras - thymeleaf-extras-springsecurity4 + thymeleaf-extras-springsecurity5 org.springframework.social spring-social-facebook + ${spring.social.facebook.version} - + org.springframework.boot spring-boot-starter-data-jpa @@ -60,6 +61,12 @@ com.h2database h2 + + + net.bytebuddy + byte-buddy-dep + ${bytebuddy.version} + @@ -93,5 +100,10 @@ + + + 1.10.9 + 2.0.3.RELEASE + \ No newline at end of file diff --git a/spring-social-login/src/main/java/com/baeldung/config/Application.java b/spring-social-login/src/main/java/com/baeldung/config/Application.java index 5d083d2d47..c65df6dbfe 100644 --- a/spring-social-login/src/main/java/com/baeldung/config/Application.java +++ b/spring-social-login/src/main/java/com/baeldung/config/Application.java @@ -3,7 +3,7 @@ package com.baeldung.config; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.web.support.SpringBootServletInitializer; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; @SpringBootApplication diff --git a/spring-social-login/src/main/java/com/baeldung/config/SecurityConfig.java b/spring-social-login/src/main/java/com/baeldung/config/SecurityConfig.java index 3d3081fef9..152c7b229a 100644 --- a/spring-social-login/src/main/java/com/baeldung/config/SecurityConfig.java +++ b/spring-social-login/src/main/java/com/baeldung/config/SecurityConfig.java @@ -1,8 +1,7 @@ package com.baeldung.config; -import com.baeldung.security.FacebookSignInAdapter; -import com.baeldung.security.FacebookConnectionSignup; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -14,22 +13,27 @@ import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.social.connect.ConnectionFactoryLocator; import org.springframework.social.connect.UsersConnectionRepository; import org.springframework.social.connect.mem.InMemoryUsersConnectionRepository; +import org.springframework.social.connect.support.ConnectionFactoryRegistry; import org.springframework.social.connect.web.ProviderSignInController; +import org.springframework.social.facebook.connect.FacebookConnectionFactory; + +import com.baeldung.security.FacebookConnectionSignup; +import com.baeldung.security.FacebookSignInAdapter; @Configuration @EnableWebSecurity @ComponentScan(basePackages = { "com.baeldung.security" }) public class SecurityConfig extends WebSecurityConfigurerAdapter { + + @Value("${spring.social.facebook.appSecret}") + String appSecret; + + @Value("${spring.social.facebook.appId}") + String appId; @Autowired private UserDetailsService userDetailsService; - @Autowired - private ConnectionFactoryLocator connectionFactoryLocator; - - @Autowired - private UsersConnectionRepository usersConnectionRepository; - @Autowired private FacebookConnectionSignup facebookConnectionSignup; @@ -55,7 +59,19 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { @Bean // @Primary public ProviderSignInController providerSignInController() { + ConnectionFactoryLocator connectionFactoryLocator = connectionFactoryLocator(); + UsersConnectionRepository usersConnectionRepository = getUsersConnectionRepository(connectionFactoryLocator); ((InMemoryUsersConnectionRepository) usersConnectionRepository).setConnectionSignUp(facebookConnectionSignup); return new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, new FacebookSignInAdapter()); } + + private ConnectionFactoryLocator connectionFactoryLocator() { + ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry(); + registry.addConnectionFactory(new FacebookConnectionFactory(appId, appSecret)); + return registry; + } + + private UsersConnectionRepository getUsersConnectionRepository(ConnectionFactoryLocator connectionFactoryLocator) { + return new InMemoryUsersConnectionRepository(connectionFactoryLocator); + } } \ No newline at end of file From 7e8d36d0840862273aca040356f5c04846b6b20d Mon Sep 17 00:00:00 2001 From: Cristian Rosu Date: Fri, 8 May 2020 20:17:17 +0300 Subject: [PATCH 481/503] BAEL-3826: test Thymeleaf PDF generation using ByteArrayOutputStream --- .../baeldung/pdf/PDFThymeleafUnitTest.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 pdf/src/test/java/com/baeldung/pdf/PDFThymeleafUnitTest.java diff --git a/pdf/src/test/java/com/baeldung/pdf/PDFThymeleafUnitTest.java b/pdf/src/test/java/com/baeldung/pdf/PDFThymeleafUnitTest.java new file mode 100644 index 0000000000..7d927072aa --- /dev/null +++ b/pdf/src/test/java/com/baeldung/pdf/PDFThymeleafUnitTest.java @@ -0,0 +1,50 @@ +package com.baeldung.pdf; + +import com.lowagie.text.DocumentException; +import org.junit.Test; +import org.thymeleaf.TemplateEngine; +import org.thymeleaf.context.Context; +import org.thymeleaf.templatemode.TemplateMode; +import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; +import org.xhtmlrenderer.pdf.ITextRenderer; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import static org.junit.Assert.assertTrue; + +public class PDFThymeleafUnitTest { + + @Test + public void givenThymeleafTemplate_whenParsedAndRenderedToPDF_thenItShouldNotBeEmpty() throws DocumentException, IOException { + String html = parseThymeleafTemplate(); + ByteArrayOutputStream outputStream = generatePdfOutputStreamFromHtml(html); + assertTrue(outputStream.size() > 0); + } + + private ByteArrayOutputStream generatePdfOutputStreamFromHtml(String html) throws IOException, DocumentException { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + + ITextRenderer renderer = new ITextRenderer(); + renderer.setDocumentFromString(html); + renderer.layout(); + renderer.createPDF(outputStream); + + outputStream.close(); + return outputStream; + } + + private String parseThymeleafTemplate() { + ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver(); + templateResolver.setSuffix(".html"); + templateResolver.setTemplateMode(TemplateMode.HTML); + + TemplateEngine templateEngine = new TemplateEngine(); + templateEngine.setTemplateResolver(templateResolver); + + Context context = new Context(); + context.setVariable("to", "Baeldung.com"); + + return templateEngine.process("thymeleaf_template", context); + } +} From f83c73a830814faee3411215dbaf5f82b8fcf278 Mon Sep 17 00:00:00 2001 From: Cristian Rosu Date: Fri, 8 May 2020 20:18:22 +0300 Subject: [PATCH 482/503] BAEL-3826: appropriate spacing --- pdf/src/test/java/com/baeldung/pdf/PDFThymeleafUnitTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pdf/src/test/java/com/baeldung/pdf/PDFThymeleafUnitTest.java b/pdf/src/test/java/com/baeldung/pdf/PDFThymeleafUnitTest.java index 7d927072aa..e253dce06c 100644 --- a/pdf/src/test/java/com/baeldung/pdf/PDFThymeleafUnitTest.java +++ b/pdf/src/test/java/com/baeldung/pdf/PDFThymeleafUnitTest.java @@ -18,7 +18,9 @@ public class PDFThymeleafUnitTest { @Test public void givenThymeleafTemplate_whenParsedAndRenderedToPDF_thenItShouldNotBeEmpty() throws DocumentException, IOException { String html = parseThymeleafTemplate(); + ByteArrayOutputStream outputStream = generatePdfOutputStreamFromHtml(html); + assertTrue(outputStream.size() > 0); } From e1a6292ea60a390fdb983f961a8ac11ecd805bad Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sat, 9 May 2020 14:43:40 +0530 Subject: [PATCH 483/503] updated readme file --- spring-core-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-core-2/README.md b/spring-core-2/README.md index 6068e8c3c2..d9110f629d 100644 --- a/spring-core-2/README.md +++ b/spring-core-2/README.md @@ -14,5 +14,5 @@ This module contains articles about core Spring functionality - [Spring Events](https://www.baeldung.com/spring-events) - [Spring Null-Safety Annotations](https://www.baeldung.com/spring-null-safety-annotations) - [Using @Autowired in Abstract Classes](https://www.baeldung.com/spring-autowired-abstract-class) -- [Running Setup Data in Startup] (https://www.baeldung.com/running-setup-logic-on-startup-in-spring) +- [Running Setup Data in Startup](https://www.baeldung.com/running-setup-logic-on-startup-in-spring) - More articles: [[<-- prev]](/spring-core)[[next -->]](/spring-core-3) From 57a38967638dd32afa8871ba1508c107043cd530 Mon Sep 17 00:00:00 2001 From: Maiklins Date: Sat, 9 May 2020 14:00:25 +0200 Subject: [PATCH 484/503] Bael-3857 introduction to lock free data structures (#9238) * BAEL-3857 Introduction to Lock-Free Data Structures * BAEL-3857 Declare variables as final / volatile * BAEL-3857 Declare node value as final Co-authored-by: mikr --- .../baeldung/lockfree/NonBlockingQueue.java | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/lockfree/NonBlockingQueue.java diff --git a/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/lockfree/NonBlockingQueue.java b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/lockfree/NonBlockingQueue.java new file mode 100644 index 0000000000..9140dc287d --- /dev/null +++ b/core-java-modules/core-java-concurrency-advanced-3/src/main/java/com/baeldung/lockfree/NonBlockingQueue.java @@ -0,0 +1,81 @@ +package com.baeldung.lockfree; + +import java.util.NoSuchElementException; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; + +public class NonBlockingQueue { + + private final AtomicReference> head, tail; + private final AtomicInteger size; + + public NonBlockingQueue() { + head = new AtomicReference<>(null); + tail = new AtomicReference<>(null); + size = new AtomicInteger(); + size.set(0); + } + + public void add(T element) { + if (element == null) { + throw new NullPointerException(); + } + + Node node = new Node<>(element); + Node currentTail; + do { + currentTail = tail.get(); + node.setPrevious(currentTail); + } while(!tail.compareAndSet(currentTail, node)); + + if(node.previous != null) { + node.previous.next = node; + } + + head.compareAndSet(null, node); //if we are inserting the first element + size.incrementAndGet(); + } + + public T get() { + if(head.get() == null) { + throw new NoSuchElementException(); + } + + Node currentHead; + Node nextNode; + do { + currentHead = head.get(); + nextNode = currentHead.getNext(); + } while(!head.compareAndSet(currentHead, nextNode)); + + size.decrementAndGet(); + return currentHead.getValue(); + } + + public int size() { + return this.size.get(); + } + + private class Node { + private final T value; + private volatile Node next; + private volatile Node previous; + + public Node(T value) { + this.value = value; + this.next = null; + } + + public T getValue() { + return value; + } + + public Node getNext() { + return next; + } + + public void setPrevious(Node previous) { + this.previous = previous; + } + } +} From 8d41b96d0775c0cdb78fc0feaf40dbe78676e1b2 Mon Sep 17 00:00:00 2001 From: Anshul Bansal Date: Sat, 9 May 2020 15:30:54 +0300 Subject: [PATCH 485/503] corrected alphabetical order of modules --- spring-security-modules/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-modules/pom.xml b/spring-security-modules/pom.xml index 59dd75cbda..7ce33dd3e3 100644 --- a/spring-security-modules/pom.xml +++ b/spring-security-modules/pom.xml @@ -30,8 +30,8 @@ spring-security-mvc-login spring-security-mvc-persisted-remember-me spring-security-mvc-socket - spring-security-okta spring-security-oidc + spring-security-okta spring-security-react spring-security-rest spring-security-rest-basic-auth From af387990c86b52957874329517a3e8daebf90dc9 Mon Sep 17 00:00:00 2001 From: Cicio Flaviu Date: Sun, 10 May 2020 08:43:51 +0300 Subject: [PATCH 486/503] BAEL-3849 Implemented example code for comparing Transactional. (#9261) --- .../TransactionalCompareApplication.java | 12 ++++ .../spring/transactional/entity/Car.java | 60 +++++++++++++++++++ .../repository/CarRepository.java | 7 +++ .../transactional/service/CarService.java | 25 ++++++++ .../transactional/service/RentalService.java | 22 +++++++ 5 files changed, 126 insertions(+) create mode 100644 persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/TransactionalCompareApplication.java create mode 100644 persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/entity/Car.java create mode 100644 persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/repository/CarRepository.java create mode 100644 persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/service/CarService.java create mode 100644 persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/service/RentalService.java diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/TransactionalCompareApplication.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/TransactionalCompareApplication.java new file mode 100644 index 0000000000..7fee55be8a --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/TransactionalCompareApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.spring.transactional; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +class TransactionalCompareApplication { + + public static void main(String[] args) { + SpringApplication.run(TransactionalCompareApplication.class, args); + } +} diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/entity/Car.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/entity/Car.java new file mode 100644 index 0000000000..1219111ffa --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/entity/Car.java @@ -0,0 +1,60 @@ +package com.baeldung.spring.transactional.entity; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class Car { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + private String make; + + private String model; + + public Car() { + } + + public Car(Long id, String make, String model) { + this.id = id; + this.make = make; + this.model = model; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getMake() { + return make; + } + + public void setMake(String make) { + this.make = make; + } + + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } + + @Override + public String toString() { + return "Car{" + + "id=" + id + + ", make='" + make + '\'' + + ", model='" + model + '\'' + + '}'; + } +} diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/repository/CarRepository.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/repository/CarRepository.java new file mode 100644 index 0000000000..f8ecc8f550 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/repository/CarRepository.java @@ -0,0 +1,7 @@ +package com.baeldung.spring.transactional.repository; + +import com.baeldung.spring.transactional.entity.Car; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface CarRepository extends JpaRepository { +} diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/service/CarService.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/service/CarService.java new file mode 100644 index 0000000000..0821ddb02b --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/service/CarService.java @@ -0,0 +1,25 @@ +package com.baeldung.spring.transactional.service; + +import com.baeldung.spring.transactional.entity.Car; +import com.baeldung.spring.transactional.repository.CarRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Isolation; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import javax.persistence.EntityExistsException; + +@Service +@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.SUPPORTS, readOnly = false, timeout = 30) +public class CarService { + + @Autowired + private CarRepository carRepository; + + @Transactional(rollbackFor = IllegalArgumentException.class, noRollbackFor = EntityExistsException.class, + rollbackForClassName = "IllegalArgumentException", noRollbackForClassName = "EntityExistsException") + public Car save(Car car) { + return carRepository.save(car); + } +} diff --git a/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/service/RentalService.java b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/service/RentalService.java new file mode 100644 index 0000000000..0aa0815a98 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-2/src/main/java/com/baeldung/spring/transactional/service/RentalService.java @@ -0,0 +1,22 @@ +package com.baeldung.spring.transactional.service; + +import com.baeldung.spring.transactional.entity.Car; +import com.baeldung.spring.transactional.repository.CarRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.persistence.EntityExistsException; +import javax.transaction.Transactional; + +@Service +@Transactional(Transactional.TxType.SUPPORTS) +public class RentalService { + + @Autowired + private CarRepository carRepository; + + @Transactional(rollbackOn = IllegalArgumentException.class, dontRollbackOn = EntityExistsException.class) + public Car rent(Car car) { + return carRepository.save(car); + } +} From 8e5456b24bced301812c4129a9bed6eee7a574f9 Mon Sep 17 00:00:00 2001 From: Mona Mohamadinia Date: Sun, 10 May 2020 13:34:01 +0430 Subject: [PATCH 487/503] Added The Sample Codes for Lateinit Initialization (#9253) --- .../com/baeldung/late/LateInitUnitTest.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/late/LateInitUnitTest.kt diff --git a/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/late/LateInitUnitTest.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/late/LateInitUnitTest.kt new file mode 100644 index 0000000000..c99e438742 --- /dev/null +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/late/LateInitUnitTest.kt @@ -0,0 +1,22 @@ +package com.baeldung.late + +import org.junit.Test +import kotlin.test.assertFalse +import kotlin.test.assertTrue + +class LateInitUnitTest { + + private lateinit var answer: String + + @Test(expected = UninitializedPropertyAccessException::class) + fun givenLateInit_WhenNotInitialized_ShouldThrowAnException() { + answer.length + } + + @Test + fun givenLateInit_TheIsInitialized_ReturnsTheInitializationStatus() { + assertFalse { this::answer.isInitialized } + answer = "42" + assertTrue { this::answer.isInitialized } + } +} From 5c90dbc963995c23ca155cbf87100224804627cb Mon Sep 17 00:00:00 2001 From: Somnath Musib <7885767+musibs@users.noreply.github.com> Date: Mon, 11 May 2020 00:14:53 +1000 Subject: [PATCH 488/503] BAEL-3852 - A Guide to Foreign Memory Access API in Java 14 (#9040) * Code sample for Java Hexagonal architecture * BAEL-3838 Capturing a Java Thread Dump * BAEL-3852 Foreign memory api in Java * BAEL-3852 - Review changes of A Guide to Foreign Memory Access API in Java 14 * BAEL-3852 - Additional review changes for A Guide to Foreign Memory Access API in Java 14 * Review changes for alignment and class removal * Removed incorrectly added old files from the PR * Indentation changes Co-authored-by: Somnath Musib --- .../foreign/api/ForeignMemoryUnitTest.java | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 core-java-modules/core-java-14/src/test/java/com/baeldung/java14/foreign/api/ForeignMemoryUnitTest.java diff --git a/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/foreign/api/ForeignMemoryUnitTest.java b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/foreign/api/ForeignMemoryUnitTest.java new file mode 100644 index 0000000000..b2264f30e6 --- /dev/null +++ b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/foreign/api/ForeignMemoryUnitTest.java @@ -0,0 +1,84 @@ +package com.baeldung.java14.foreign.api; + +import jdk.incubator.foreign.*; +import org.junit.Test; + +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; + +import java.lang.invoke.VarHandle; +import java.nio.ByteOrder; + +public class ForeignMemoryUnitTest { + + @Test + public void whenAValueIsSet_thenAccessTheValue() { + long value = 10; + MemoryAddress memoryAddress = + MemorySegment.allocateNative(8).baseAddress(); + VarHandle varHandle = MemoryHandles.varHandle(long.class, + ByteOrder.nativeOrder()); + varHandle.set(memoryAddress, value); + assertThat(varHandle.get(memoryAddress), is(value)); + } + + @Test + public void whenMultipleValuesAreSet_thenAccessAll() { + VarHandle varHandle = MemoryHandles.varHandle(int.class, + ByteOrder.nativeOrder()); + + try(MemorySegment memorySegment = + MemorySegment.allocateNative(100)) { + MemoryAddress base = memorySegment.baseAddress(); + for(int i=0; i<25; i++) { + varHandle.set(base.addOffset((i*4)), i); + } + for(int i=0; i<25; i++) { + assertThat(varHandle.get(base.addOffset((i*4))), is(i)); + } + } + } + + @Test + public void whenSetValuesWithMemoryLayout_thenTheyCanBeRetrieved() { + SequenceLayout sequenceLayout = + MemoryLayout.ofSequence(25, + MemoryLayout.ofValueBits(64, ByteOrder.nativeOrder())); + VarHandle varHandle = + sequenceLayout.varHandle(long.class, + MemoryLayout.PathElement.sequenceElement()); + + try(MemorySegment memorySegment = + MemorySegment.allocateNative(sequenceLayout)) { + MemoryAddress base = memorySegment.baseAddress(); + for(long i=0; i Date: Mon, 11 May 2020 08:28:13 -0400 Subject: [PATCH 489/503] Bael-3893 - Fixed string concatenation operator --- .../AwsAppSyncApplicationTests.java | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java b/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java index 6e94651789..22d99959b3 100644 --- a/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java +++ b/aws-app-sync/src/test/java/com/baeldung/awsappsync/AwsAppSyncApplicationTests.java @@ -16,17 +16,17 @@ class AwsAppSyncApplicationTests { void givenGraphQuery_whenListEvents_thenReturnAllEvents() { Map requestBody = new HashMap<>(); - requestBody.put("query", "query ListEvents {" + - " listEvents {" + - " items {" + - " id" + - " name" + - " where" + - " when" + - " description" + - " }" + - " }" + - "}"); + requestBody.put("query", "query ListEvents {" + + " listEvents {" + + " items {" + + " id" + + " name" + + " where" + + " when" + + " description" + + " }" + + " }" + + "}"); requestBody.put("variables", ""); requestBody.put("operationName", "ListEvents"); @@ -42,18 +42,18 @@ class AwsAppSyncApplicationTests { @Test void givenGraphAdd_whenMutation_thenReturnIdNameDesc() { - String queryString = "mutation add {" + - " createEvent(" + - " name:\"My added GraphQL event\"" + - " where:\"Day 2\"" + - " when:\"Saturday night\"" + - " description:\"Studying GraphQL\"" + - " ){" + - " id" + - " name" + - " description" + - " }" + - "}"; + String queryString = "mutation add {" + + " createEvent(" + + " name:\"My added GraphQL event\"" + + " where:\"Day 2\"" + + " when:\"Saturday night\"" + + " description:\"Studying GraphQL\"" + + " ){" + + " id" + + " name" + + " description" + + " }" + + "}"; Map requestBody = new HashMap<>(); requestBody.put("query", queryString); From 699e94fdb64af3fc6ad6afb32f71f90fe0fbe9f1 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Mon, 11 May 2020 18:54:07 +0530 Subject: [PATCH 490/503] JAVA-952: Migrate spring-session to parent-boot-2 --- spring-session/pom.xml | 4 ++-- spring-session/spring-session-redis/pom.xml | 11 ++++++++--- .../baeldung/spring/session/SecurityConfig.java | 14 +++++++++++--- .../session/SessionControllerIntegrationTest.java | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/spring-session/pom.xml b/spring-session/pom.xml index 42a414afdc..8388efb6c3 100644 --- a/spring-session/pom.xml +++ b/spring-session/pom.xml @@ -10,9 +10,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-session/spring-session-redis/pom.xml b/spring-session/spring-session-redis/pom.xml index 37402634b0..8d225e06ed 100644 --- a/spring-session/spring-session-redis/pom.xml +++ b/spring-session/spring-session-redis/pom.xml @@ -9,9 +9,9 @@ com.baeldung - parent-boot-1 + parent-boot-2 0.0.1-SNAPSHOT - ../../parent-boot-1 + ../../parent-boot-2 @@ -25,7 +25,7 @@ org.springframework.session - spring-session + spring-session-data-redis org.springframework.boot @@ -36,6 +36,11 @@ embedded-redis ${embedded-redis.version} + + redis.clients + jedis + jar + diff --git a/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SecurityConfig.java b/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SecurityConfig.java index 1da6d9422d..678c98e7eb 100644 --- a/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SecurityConfig.java +++ b/spring-session/spring-session-redis/src/main/java/com/baeldung/spring/session/SecurityConfig.java @@ -1,23 +1,31 @@ package com.baeldung.spring.session; import org.springframework.beans.factory.annotation.Autowired; +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; @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { - + @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { - auth.inMemoryAuthentication().withUser("admin").password("password").roles("ADMIN"); + auth.inMemoryAuthentication().withUser("admin").password(passwordEncoder().encode("password")).roles("ADMIN"); } - + @Override protected void configure(HttpSecurity http) throws Exception { http.httpBasic().and().authorizeRequests().antMatchers("/").hasRole("ADMIN").anyRequest().authenticated(); } + + @Bean + public PasswordEncoder passwordEncoder() { + return new BCryptPasswordEncoder(); + } } diff --git a/spring-session/spring-session-redis/src/test/java/com/baeldung/spring/session/SessionControllerIntegrationTest.java b/spring-session/spring-session-redis/src/test/java/com/baeldung/spring/session/SessionControllerIntegrationTest.java index 7ee0294315..065533c73f 100644 --- a/spring-session/spring-session-redis/src/test/java/com/baeldung/spring/session/SessionControllerIntegrationTest.java +++ b/spring-session/spring-session-redis/src/test/java/com/baeldung/spring/session/SessionControllerIntegrationTest.java @@ -5,7 +5,7 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.client.TestRestTemplate; From 9d2e94f5290187f3a48faa34d4363a25a49a951c Mon Sep 17 00:00:00 2001 From: Justin Albano Date: Mon, 11 May 2020 11:47:04 -0400 Subject: [PATCH 491/503] BAEL-3951: Added JDK 14 record example and associated tests. (#9270) --- .../com/baeldung/java14/record/Person.java | 22 +++ .../baeldung/java14/record/PersonTest.java | 150 ++++++++++++++++++ 2 files changed, 172 insertions(+) create mode 100644 core-java-modules/core-java-14/src/main/java/com/baeldung/java14/record/Person.java create mode 100644 core-java-modules/core-java-14/src/test/java/com/baeldung/java14/record/PersonTest.java diff --git a/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/record/Person.java b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/record/Person.java new file mode 100644 index 0000000000..33243c4ecf --- /dev/null +++ b/core-java-modules/core-java-14/src/main/java/com/baeldung/java14/record/Person.java @@ -0,0 +1,22 @@ +package com.baeldung.java14.record; + +import java.util.Objects; + +public record Person (String name, String address) { + + public static String UNKWOWN_ADDRESS = "Unknown"; + public static String UNNAMED = "Unnamed"; + + public Person { + Objects.requireNonNull(name); + Objects.requireNonNull(address); + } + + public Person(String name) { + this(name, UNKWOWN_ADDRESS); + } + + public static Person unnamed(String address) { + return new Person(UNNAMED, address); + } +} diff --git a/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/record/PersonTest.java b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/record/PersonTest.java new file mode 100644 index 0000000000..4a7d4ede5f --- /dev/null +++ b/core-java-modules/core-java-14/src/test/java/com/baeldung/java14/record/PersonTest.java @@ -0,0 +1,150 @@ +package com.baeldung.java14.record; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class PersonTest { + + @Test + public void givenSameNameAndAddress_whenEquals_thenPersonsEqual() { + + String name = "John Doe"; + String address = "100 Linda Ln."; + + Person person1 = new Person(name, address); + Person person2 = new Person(name, address); + + assertTrue(person1.equals(person2)); + } + + @Test + public void givenDifferentObject_whenEquals_thenNotEqual() { + + Person person = new Person("John Doe", "100 Linda Ln."); + + assertFalse(person.equals(new Object())); + } + + @Test + public void givenDifferentName_whenEquals_thenPersonsNotEqual() { + + String address = "100 Linda Ln."; + + Person person1 = new Person("Jane Doe", address); + Person person2 = new Person("John Doe", address); + + assertFalse(person1.equals(person2)); + } + + @Test + public void givenDifferentAddress_whenEquals_thenPersonsNotEqual() { + + String name = "John Doe"; + + Person person1 = new Person(name, "100 Linda Ln."); + Person person2 = new Person(name, "200 London Ave."); + + assertFalse(person1.equals(person2)); + } + + @Test + public void givenSameNameAndAddress_whenHashCode_thenPersonsEqual() { + + String name = "John Doe"; + String address = "100 Linda Ln."; + + Person person1 = new Person(name, address); + Person person2 = new Person(name, address); + + assertEquals(person1.hashCode(), person2.hashCode()); + } + + @Test + public void givenDifferentObject_whenHashCode_thenNotEqual() { + + Person person = new Person("John Doe", "100 Linda Ln."); + + assertNotEquals(person.hashCode(), new Object().hashCode()); + } + + @Test + public void givenDifferentName_whenHashCode_thenPersonsNotEqual() { + + String address = "100 Linda Ln."; + + Person person1 = new Person("Jane Doe", address); + Person person2 = new Person("John Doe", address); + + assertNotEquals(person1.hashCode(), person2.hashCode()); + } + + @Test + public void givenDifferentAddress_whenHashCode_thenPersonsNotEqual() { + + String name = "John Doe"; + + Person person1 = new Person(name, "100 Linda Ln."); + Person person2 = new Person(name, "200 London Ave."); + + assertNotEquals(person1.hashCode(), person2.hashCode()); + } + + @Test + public void givenValidNameAndAddress_whenGetNameAndAddress_thenExpectedValuesReturned() { + + String name = "John Doe"; + String address = "100 Linda Ln."; + + Person person = new Person(name, address); + + assertEquals(name, person.name()); + assertEquals(address, person.address()); + } + + @Test + public void givenValidNameAndAddress_whenToString_thenCorrectStringReturned() { + + String name = "John Doe"; + String address = "100 Linda Ln."; + + Person person = new Person(name, address); + + assertEquals("Person[name=" + name + ", address=" + address + "]", person.toString()); + } + + @Test(expected = NullPointerException.class) + public void givenNullName_whenConstruct_thenErrorThrown() { + new Person(null, "100 Linda Ln."); + } + + @Test(expected = NullPointerException.class) + public void givenNullAddress_whenConstruct_thenErrorThrown() { + new Person("John Doe", null); + } + + @Test + public void givenUnknownAddress_whenConstructing_thenAddressPopulated() { + + String name = "John Doe"; + + Person person = new Person(name); + + assertEquals(name, person.name()); + assertEquals(Person.UNKWOWN_ADDRESS, person.address()); + } + + @Test + public void givenUnnamed_whenConstructingThroughFactory_thenNamePopulated() { + + String address = "100 Linda Ln."; + + Person person = Person.unnamed(address); + + assertEquals(Person.UNNAMED, person.name()); + assertEquals(address, person.address()); + } +} From 20843c7f224fe68e772b0518532c881fff483483 Mon Sep 17 00:00:00 2001 From: mdabrowski-eu Date: Fri, 24 Apr 2020 01:56:25 +0200 Subject: [PATCH 492/503] BAEL-3863 Introduction to Finagle --- finagle/README.md | 7 +++++ finagle/pom.xml | 30 +++++++++++++++++++ .../java/com/baeldung/finagle/Client.java | 24 +++++++++++++++ .../com/baeldung/finagle/GreetingService.java | 18 +++++++++++ .../java/com/baeldung/finagle/LogFilter.java | 17 +++++++++++ .../java/com/baeldung/finagle/Server.java | 15 ++++++++++ finagle/src/main/resources/logback.xml | 13 ++++++++ .../src/main/resources/twitter4j.properties | 4 +++ 8 files changed, 128 insertions(+) create mode 100644 finagle/README.md create mode 100644 finagle/pom.xml create mode 100644 finagle/src/main/java/com/baeldung/finagle/Client.java create mode 100644 finagle/src/main/java/com/baeldung/finagle/GreetingService.java create mode 100644 finagle/src/main/java/com/baeldung/finagle/LogFilter.java create mode 100644 finagle/src/main/java/com/baeldung/finagle/Server.java create mode 100644 finagle/src/main/resources/logback.xml create mode 100644 finagle/src/main/resources/twitter4j.properties diff --git a/finagle/README.md b/finagle/README.md new file mode 100644 index 0000000000..d16afdc10d --- /dev/null +++ b/finagle/README.md @@ -0,0 +1,7 @@ +## Finagle + +This module contains articles about Finagle and associated libraries. + +### Relevant articles + +- [Introduction to Finagle](https://www.baeldung.com/introduction-to-finagle) diff --git a/finagle/pom.xml b/finagle/pom.xml new file mode 100644 index 0000000000..f1dc932c13 --- /dev/null +++ b/finagle/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + Finagle + Finagle + jar + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + com.twitter + finagle-core_2.13 + 20.4.0 + + + com.twitter + finagle-http_2.13 + 20.4.0 + + + + + + diff --git a/finagle/src/main/java/com/baeldung/finagle/Client.java b/finagle/src/main/java/com/baeldung/finagle/Client.java new file mode 100644 index 0000000000..a881f1c37c --- /dev/null +++ b/finagle/src/main/java/com/baeldung/finagle/Client.java @@ -0,0 +1,24 @@ +package com.baeldung.finagle; + +import com.twitter.finagle.Http; +import com.twitter.finagle.Service; +import com.twitter.finagle.http.Method; +import com.twitter.finagle.http.Request; +import com.twitter.finagle.http.Response; +import com.twitter.util.Await; +import com.twitter.util.Future; +import scala.runtime.BoxedUnit; + +public class Client { + public static void main(String[] args) throws Exception { + Service service = new LogFilter().andThen(Http.newService(":8080")); + Request request = Request.apply(Method.Get(), "/?name=John"); + request.host("localhost"); + Future response = service.apply(request); + Await.result(response + .onSuccess(r -> { + System.out.println(r.getContentString()); + return BoxedUnit.UNIT; + })); + } +} diff --git a/finagle/src/main/java/com/baeldung/finagle/GreetingService.java b/finagle/src/main/java/com/baeldung/finagle/GreetingService.java new file mode 100644 index 0000000000..c795724192 --- /dev/null +++ b/finagle/src/main/java/com/baeldung/finagle/GreetingService.java @@ -0,0 +1,18 @@ +package com.baeldung.finagle; + +import com.twitter.finagle.Service; +import com.twitter.finagle.http.Request; +import com.twitter.finagle.http.Response; +import com.twitter.finagle.http.Status; +import com.twitter.io.Buf; +import com.twitter.io.Reader; +import com.twitter.util.Future; + +public class GreetingService extends Service { + @Override + public Future apply(Request request) { + String greeting = "Hello " + request.getParam("name"); + Reader reader = Reader.fromBuf(new Buf.ByteArray(greeting.getBytes(), 0, greeting.length())); + return Future.value(Response.apply(request.version(), Status.Ok(), reader)); + } +} diff --git a/finagle/src/main/java/com/baeldung/finagle/LogFilter.java b/finagle/src/main/java/com/baeldung/finagle/LogFilter.java new file mode 100644 index 0000000000..d381456cfe --- /dev/null +++ b/finagle/src/main/java/com/baeldung/finagle/LogFilter.java @@ -0,0 +1,17 @@ +package com.baeldung.finagle; + +import com.twitter.finagle.Service; +import com.twitter.finagle.SimpleFilter; +import com.twitter.finagle.http.Request; +import com.twitter.finagle.http.Response; +import com.twitter.util.Future; + +public class LogFilter extends SimpleFilter { + @Override + public Future apply(Request request, Service service) { + System.out.println("Request host:" + request.host().getOrElse(() -> "")); + System.out.println("Request params:"); + request.getParams().forEach(entry -> System.out.println("\t" + entry.getKey() + " : " + entry.getValue())); + return service.apply(request); + } +} diff --git a/finagle/src/main/java/com/baeldung/finagle/Server.java b/finagle/src/main/java/com/baeldung/finagle/Server.java new file mode 100644 index 0000000000..8a9c9be192 --- /dev/null +++ b/finagle/src/main/java/com/baeldung/finagle/Server.java @@ -0,0 +1,15 @@ +package com.baeldung.finagle; + +import com.twitter.finagle.Http; +import com.twitter.finagle.ListeningServer; +import com.twitter.finagle.Service; +import com.twitter.util.Await; +import com.twitter.util.TimeoutException; + +public class Server { + public static void main(String[] args) throws TimeoutException, InterruptedException { + Service service = new LogFilter().andThen(new GreetingService()); + ListeningServer server = Http.serve(":8080", service); + Await.ready(server); + } +} diff --git a/finagle/src/main/resources/logback.xml b/finagle/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/finagle/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/finagle/src/main/resources/twitter4j.properties b/finagle/src/main/resources/twitter4j.properties new file mode 100644 index 0000000000..ee11dc62a1 --- /dev/null +++ b/finagle/src/main/resources/twitter4j.properties @@ -0,0 +1,4 @@ +oauth.consumerKey=//TODO +oauth.consumerSecret=//TODO +oauth.accessToken=//TODO +oauth.accessTokenSecret=//TODO From 33edef47e18c16e03ce056af609dc984d6f4a566 Mon Sep 17 00:00:00 2001 From: mdabrowski-eu Date: Fri, 24 Apr 2020 02:05:49 +0200 Subject: [PATCH 493/503] BAEL-3863 add Finagle module to root pom.xml --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 34703c6f73..813a42c93d 100644 --- a/pom.xml +++ b/pom.xml @@ -418,6 +418,7 @@ ethereum feign + finagle flyway-cdi-extension geotools From ff684f13b6d4d27f063d0e912ca9e6b0151acb0e Mon Sep 17 00:00:00 2001 From: mdabrowski-eu Date: Fri, 24 Apr 2020 20:52:23 +0200 Subject: [PATCH 494/503] BAEL-3863 moved Finagle package to libraries-rpc, added test --- {finagle => libraries-rpc}/README.md | 0 {finagle => libraries-rpc}/pom.xml | 4 +- .../com/baeldung/rpc}/finagle/Client.java | 2 +- .../rpc}/finagle/GreetingService.java | 2 +- .../com/baeldung/rpc}/finagle/LogFilter.java | 2 +- .../com/baeldung/rpc}/finagle/Server.java | 2 +- .../src/main/resources/logback.xml | 0 .../src/main/resources/twitter4j.properties | 0 .../rpc/finagle/ClientServerTest.java | 40 +++++++++++++++++++ pom.xml | 2 +- 10 files changed, 47 insertions(+), 7 deletions(-) rename {finagle => libraries-rpc}/README.md (100%) rename {finagle => libraries-rpc}/pom.xml (92%) rename {finagle/src/main/java/com/baeldung => libraries-rpc/src/main/java/com/baeldung/rpc}/finagle/Client.java (96%) rename {finagle/src/main/java/com/baeldung => libraries-rpc/src/main/java/com/baeldung/rpc}/finagle/GreetingService.java (95%) rename {finagle/src/main/java/com/baeldung => libraries-rpc/src/main/java/com/baeldung/rpc}/finagle/LogFilter.java (95%) rename {finagle/src/main/java/com/baeldung => libraries-rpc/src/main/java/com/baeldung/rpc}/finagle/Server.java (93%) rename {finagle => libraries-rpc}/src/main/resources/logback.xml (100%) rename {finagle => libraries-rpc}/src/main/resources/twitter4j.properties (100%) create mode 100644 libraries-rpc/src/test/java/com/baeldung/rpc/finagle/ClientServerTest.java diff --git a/finagle/README.md b/libraries-rpc/README.md similarity index 100% rename from finagle/README.md rename to libraries-rpc/README.md diff --git a/finagle/pom.xml b/libraries-rpc/pom.xml similarity index 92% rename from finagle/pom.xml rename to libraries-rpc/pom.xml index f1dc932c13..145693cac1 100644 --- a/finagle/pom.xml +++ b/libraries-rpc/pom.xml @@ -2,8 +2,8 @@ 4.0.0 - Finagle - Finagle + libraries-rpc + libraries-rpc jar diff --git a/finagle/src/main/java/com/baeldung/finagle/Client.java b/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/Client.java similarity index 96% rename from finagle/src/main/java/com/baeldung/finagle/Client.java rename to libraries-rpc/src/main/java/com/baeldung/rpc/finagle/Client.java index a881f1c37c..989c79f302 100644 --- a/finagle/src/main/java/com/baeldung/finagle/Client.java +++ b/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/Client.java @@ -1,4 +1,4 @@ -package com.baeldung.finagle; +package com.baeldung.rpc.finagle; import com.twitter.finagle.Http; import com.twitter.finagle.Service; diff --git a/finagle/src/main/java/com/baeldung/finagle/GreetingService.java b/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/GreetingService.java similarity index 95% rename from finagle/src/main/java/com/baeldung/finagle/GreetingService.java rename to libraries-rpc/src/main/java/com/baeldung/rpc/finagle/GreetingService.java index c795724192..7f3d741f94 100644 --- a/finagle/src/main/java/com/baeldung/finagle/GreetingService.java +++ b/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/GreetingService.java @@ -1,4 +1,4 @@ -package com.baeldung.finagle; +package com.baeldung.rpc.finagle; import com.twitter.finagle.Service; import com.twitter.finagle.http.Request; diff --git a/finagle/src/main/java/com/baeldung/finagle/LogFilter.java b/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/LogFilter.java similarity index 95% rename from finagle/src/main/java/com/baeldung/finagle/LogFilter.java rename to libraries-rpc/src/main/java/com/baeldung/rpc/finagle/LogFilter.java index d381456cfe..3ef57ed18f 100644 --- a/finagle/src/main/java/com/baeldung/finagle/LogFilter.java +++ b/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/LogFilter.java @@ -1,4 +1,4 @@ -package com.baeldung.finagle; +package com.baeldung.rpc.finagle; import com.twitter.finagle.Service; import com.twitter.finagle.SimpleFilter; diff --git a/finagle/src/main/java/com/baeldung/finagle/Server.java b/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/Server.java similarity index 93% rename from finagle/src/main/java/com/baeldung/finagle/Server.java rename to libraries-rpc/src/main/java/com/baeldung/rpc/finagle/Server.java index 8a9c9be192..5bc8d93eaf 100644 --- a/finagle/src/main/java/com/baeldung/finagle/Server.java +++ b/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/Server.java @@ -1,4 +1,4 @@ -package com.baeldung.finagle; +package com.baeldung.rpc.finagle; import com.twitter.finagle.Http; import com.twitter.finagle.ListeningServer; diff --git a/finagle/src/main/resources/logback.xml b/libraries-rpc/src/main/resources/logback.xml similarity index 100% rename from finagle/src/main/resources/logback.xml rename to libraries-rpc/src/main/resources/logback.xml diff --git a/finagle/src/main/resources/twitter4j.properties b/libraries-rpc/src/main/resources/twitter4j.properties similarity index 100% rename from finagle/src/main/resources/twitter4j.properties rename to libraries-rpc/src/main/resources/twitter4j.properties diff --git a/libraries-rpc/src/test/java/com/baeldung/rpc/finagle/ClientServerTest.java b/libraries-rpc/src/test/java/com/baeldung/rpc/finagle/ClientServerTest.java new file mode 100644 index 0000000000..b3faa1968c --- /dev/null +++ b/libraries-rpc/src/test/java/com/baeldung/rpc/finagle/ClientServerTest.java @@ -0,0 +1,40 @@ +package com.baeldung.rpc.finagle; + +import com.twitter.finagle.Http; +import com.twitter.finagle.Service; +import com.twitter.finagle.http.Method; +import com.twitter.finagle.http.Request; +import com.twitter.finagle.http.Response; +import com.twitter.util.Await; +import com.twitter.util.Future; +import org.junit.Test; +import scala.runtime.BoxedUnit; + +import static org.junit.Assert.assertEquals; + +public class ClientServerTest { + @Test + public void clientShouldReceiveResponseFromServer() throws Exception { + // given + Service serverService = new LogFilter().andThen(new GreetingService()); + Http.serve(":8080", serverService); + + Service clientService = new LogFilter().andThen(Http.newService(":8080")); + + // when + Request request = Request.apply(Method.Get(), "/?name=John"); + request.host("localhost"); + Future response = clientService.apply(request); + + // then + Await.result(response + .onSuccess(r -> { + assertEquals("Hello John", r.getContentString()); + return BoxedUnit.UNIT; + }) + .onFailure(r -> { + throw new RuntimeException(r); + }) + ); + } +} diff --git a/pom.xml b/pom.xml index 813a42c93d..c16775bfc9 100644 --- a/pom.xml +++ b/pom.xml @@ -418,7 +418,6 @@ ethereum feign - finagle flyway-cdi-extension geotools @@ -509,6 +508,7 @@ libraries-http-2 libraries-io libraries-primitive + libraries-rpc libraries-security libraries-server libraries-testing From 3e0c3a0d0a621a3dcf909314fffb5a25b3a17a93 Mon Sep 17 00:00:00 2001 From: mdabrowski-eu Date: Fri, 24 Apr 2020 20:54:23 +0200 Subject: [PATCH 495/503] BAEL-3863 removed README.md --- libraries-rpc/README.md | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 libraries-rpc/README.md diff --git a/libraries-rpc/README.md b/libraries-rpc/README.md deleted file mode 100644 index d16afdc10d..0000000000 --- a/libraries-rpc/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## Finagle - -This module contains articles about Finagle and associated libraries. - -### Relevant articles - -- [Introduction to Finagle](https://www.baeldung.com/introduction-to-finagle) From ca7d40de8fdca6741021f8273613a8ee53f7c907 Mon Sep 17 00:00:00 2001 From: mdabrowski-eu Date: Fri, 24 Apr 2020 20:59:20 +0200 Subject: [PATCH 496/503] BAEL-3863 removed redundant examples --- .../java/com/baeldung/rpc/finagle/Client.java | 24 ------------------- .../java/com/baeldung/rpc/finagle/Server.java | 15 ------------ 2 files changed, 39 deletions(-) delete mode 100644 libraries-rpc/src/main/java/com/baeldung/rpc/finagle/Client.java delete mode 100644 libraries-rpc/src/main/java/com/baeldung/rpc/finagle/Server.java diff --git a/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/Client.java b/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/Client.java deleted file mode 100644 index 989c79f302..0000000000 --- a/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/Client.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.rpc.finagle; - -import com.twitter.finagle.Http; -import com.twitter.finagle.Service; -import com.twitter.finagle.http.Method; -import com.twitter.finagle.http.Request; -import com.twitter.finagle.http.Response; -import com.twitter.util.Await; -import com.twitter.util.Future; -import scala.runtime.BoxedUnit; - -public class Client { - public static void main(String[] args) throws Exception { - Service service = new LogFilter().andThen(Http.newService(":8080")); - Request request = Request.apply(Method.Get(), "/?name=John"); - request.host("localhost"); - Future response = service.apply(request); - Await.result(response - .onSuccess(r -> { - System.out.println(r.getContentString()); - return BoxedUnit.UNIT; - })); - } -} diff --git a/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/Server.java b/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/Server.java deleted file mode 100644 index 5bc8d93eaf..0000000000 --- a/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/Server.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.rpc.finagle; - -import com.twitter.finagle.Http; -import com.twitter.finagle.ListeningServer; -import com.twitter.finagle.Service; -import com.twitter.util.Await; -import com.twitter.util.TimeoutException; - -public class Server { - public static void main(String[] args) throws TimeoutException, InterruptedException { - Service service = new LogFilter().andThen(new GreetingService()); - ListeningServer server = Http.serve(":8080", service); - Await.ready(server); - } -} From cf6cbe92b9e229c28a354d683d6a3cb6a2d8eb3a Mon Sep 17 00:00:00 2001 From: mdabrowski-eu Date: Sat, 25 Apr 2020 18:07:27 +0200 Subject: [PATCH 497/503] BAEL-3863 Renamed tests to follow convention --- .../{ClientServerTest.java => FinagleIntegrationTest.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename libraries-rpc/src/test/java/com/baeldung/rpc/finagle/{ClientServerTest.java => FinagleIntegrationTest.java} (88%) diff --git a/libraries-rpc/src/test/java/com/baeldung/rpc/finagle/ClientServerTest.java b/libraries-rpc/src/test/java/com/baeldung/rpc/finagle/FinagleIntegrationTest.java similarity index 88% rename from libraries-rpc/src/test/java/com/baeldung/rpc/finagle/ClientServerTest.java rename to libraries-rpc/src/test/java/com/baeldung/rpc/finagle/FinagleIntegrationTest.java index b3faa1968c..8dcdb19e7e 100644 --- a/libraries-rpc/src/test/java/com/baeldung/rpc/finagle/ClientServerTest.java +++ b/libraries-rpc/src/test/java/com/baeldung/rpc/finagle/FinagleIntegrationTest.java @@ -12,9 +12,9 @@ import scala.runtime.BoxedUnit; import static org.junit.Assert.assertEquals; -public class ClientServerTest { +public class FinagleIntegrationTest { @Test - public void clientShouldReceiveResponseFromServer() throws Exception { + public void givenServerAndClient_whenRequestSent_thenClientShouldReceiveResponseFromServer() throws Exception { // given Service serverService = new LogFilter().andThen(new GreetingService()); Http.serve(":8080", serverService); From 6deafc178d25d2b6247074bf02249349591dba4c Mon Sep 17 00:00:00 2001 From: mdabrowski-eu Date: Sun, 26 Apr 2020 16:15:17 +0200 Subject: [PATCH 498/503] BAEL-3863 replace stdouts with logger --- .../main/java/com/baeldung/rpc/finagle/LogFilter.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/LogFilter.java b/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/LogFilter.java index 3ef57ed18f..7fc5440016 100644 --- a/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/LogFilter.java +++ b/libraries-rpc/src/main/java/com/baeldung/rpc/finagle/LogFilter.java @@ -5,13 +5,18 @@ import com.twitter.finagle.SimpleFilter; import com.twitter.finagle.http.Request; import com.twitter.finagle.http.Response; import com.twitter.util.Future; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class LogFilter extends SimpleFilter { + + private static final Logger logger = LoggerFactory.getLogger(LogFilter.class); + @Override public Future apply(Request request, Service service) { - System.out.println("Request host:" + request.host().getOrElse(() -> "")); - System.out.println("Request params:"); - request.getParams().forEach(entry -> System.out.println("\t" + entry.getKey() + " : " + entry.getValue())); + logger.info("Request host:" + request.host().getOrElse(() -> "")); + logger.info("Request params:"); + request.getParams().forEach(entry -> logger.info("\t" + entry.getKey() + " : " + entry.getValue())); return service.apply(request); } } From 7da38b99cb4d8f4d02ef4eac8efc4143433671d6 Mon Sep 17 00:00:00 2001 From: mdabrowski-eu Date: Sun, 26 Apr 2020 16:25:51 +0200 Subject: [PATCH 499/503] BAEL-3863 add versions properties --- libraries-rpc/pom.xml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libraries-rpc/pom.xml b/libraries-rpc/pom.xml index 145693cac1..8741a41062 100644 --- a/libraries-rpc/pom.xml +++ b/libraries-rpc/pom.xml @@ -16,15 +16,20 @@ com.twitter finagle-core_2.13 - 20.4.0 + ${finagle.core.version} com.twitter finagle-http_2.13 - 20.4.0 + ${finagle.http.version} + + 20.4.0 + 20.4.0 + + From 6709017cc02040e210265e91a9792fdc405d6aef Mon Sep 17 00:00:00 2001 From: mdabrowski-eu Date: Sat, 9 May 2020 18:01:17 +0200 Subject: [PATCH 500/503] BAEL-3863 removed redundant twitter4j.properties file --- libraries-rpc/src/main/resources/twitter4j.properties | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 libraries-rpc/src/main/resources/twitter4j.properties diff --git a/libraries-rpc/src/main/resources/twitter4j.properties b/libraries-rpc/src/main/resources/twitter4j.properties deleted file mode 100644 index ee11dc62a1..0000000000 --- a/libraries-rpc/src/main/resources/twitter4j.properties +++ /dev/null @@ -1,4 +0,0 @@ -oauth.consumerKey=//TODO -oauth.consumerSecret=//TODO -oauth.accessToken=//TODO -oauth.accessTokenSecret=//TODO From 00f5e0012cfa89c0a38c5ff123dd88af76aecfc3 Mon Sep 17 00:00:00 2001 From: Jonathan Cook Date: Wed, 13 May 2020 03:46:33 +0200 Subject: [PATCH 501/503] BAEL-3925 - How to call Python from Java? (#9277) * BAEL-3491 - Check for null before calling parse in the Double.parseDouble * BAEL-3491 - Check for null before calling parse in the Double.parseDouble - Return to indentation with spaces. * BAEL-3854 - Pattern Matching for instanceof in Java 14 * BAEL-3854 - Pattern Matching for instanceof in Java 14 - add unit test * BAEL-3868 - Fix the integrations tests in mocks * BAEL-3925 - How to call Python from Java Co-authored-by: Jonathan Cook --- java-python-interop/README.md | 5 + java-python-interop/pom.xml | 55 ++++++++ .../interop/ScriptEngineManagerUtils.java | 34 +++++ .../src/main/resources/logback.xml | 13 ++ .../interop/JavaPythonInteropUnitTest.java | 131 ++++++++++++++++++ .../src/test/resources/hello.py | 1 + pom.xml | 3 +- 7 files changed, 241 insertions(+), 1 deletion(-) create mode 100644 java-python-interop/README.md create mode 100644 java-python-interop/pom.xml create mode 100644 java-python-interop/src/main/java/com/baeldung/python/interop/ScriptEngineManagerUtils.java create mode 100644 java-python-interop/src/main/resources/logback.xml create mode 100644 java-python-interop/src/test/java/com/baeldung/python/interop/JavaPythonInteropUnitTest.java create mode 100644 java-python-interop/src/test/resources/hello.py diff --git a/java-python-interop/README.md b/java-python-interop/README.md new file mode 100644 index 0000000000..dc9573ecde --- /dev/null +++ b/java-python-interop/README.md @@ -0,0 +1,5 @@ +## Java Python Interop + +This module contains articles about Java and Python interoperability. + +### Relevant Articles: diff --git a/java-python-interop/pom.xml b/java-python-interop/pom.xml new file mode 100644 index 0000000000..6ee5a0be3b --- /dev/null +++ b/java-python-interop/pom.xml @@ -0,0 +1,55 @@ + + + 4.0.0 + java-python-interop + 0.0.1-SNAPSHOT + java-python-interop + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + org.python + jython-slim + ${jython.version} + + + org.apache.commons + commons-exec + ${commons-exec.version} + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + java-python-interop + + + src/main/resources + true + + + src/test/resources + true + + + + + + 2.7.2 + 1.3 + 3.6.1 + + + \ No newline at end of file diff --git a/java-python-interop/src/main/java/com/baeldung/python/interop/ScriptEngineManagerUtils.java b/java-python-interop/src/main/java/com/baeldung/python/interop/ScriptEngineManagerUtils.java new file mode 100644 index 0000000000..981f174c33 --- /dev/null +++ b/java-python-interop/src/main/java/com/baeldung/python/interop/ScriptEngineManagerUtils.java @@ -0,0 +1,34 @@ +package com.baeldung.python.interop; + +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.script.ScriptEngineFactory; +import javax.script.ScriptEngineManager; + +public class ScriptEngineManagerUtils { + + private static final Logger LOGGER = LoggerFactory.getLogger(ScriptEngineManagerUtils.class); + + private ScriptEngineManagerUtils() { + } + + public static void listEngines() { + ScriptEngineManager manager = new ScriptEngineManager(); + List engines = manager.getEngineFactories(); + + for (ScriptEngineFactory engine : engines) { + LOGGER.info("Engine name: {}", engine.getEngineName()); + LOGGER.info("Version: {}", engine.getEngineVersion()); + LOGGER.info("Language: {}", engine.getLanguageName()); + + LOGGER.info("Short Names:"); + for (String names : engine.getNames()) { + LOGGER.info(names); + } + } + } + +} diff --git a/java-python-interop/src/main/resources/logback.xml b/java-python-interop/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/java-python-interop/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/java-python-interop/src/test/java/com/baeldung/python/interop/JavaPythonInteropUnitTest.java b/java-python-interop/src/test/java/com/baeldung/python/interop/JavaPythonInteropUnitTest.java new file mode 100644 index 0000000000..5ec3a2b61f --- /dev/null +++ b/java-python-interop/src/test/java/com/baeldung/python/interop/JavaPythonInteropUnitTest.java @@ -0,0 +1,131 @@ +package com.baeldung.python.interop; + +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.hasItem; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; + +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.StringWriter; +import java.util.List; +import java.util.stream.Collectors; + +import javax.script.ScriptContext; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.SimpleScriptContext; + +import org.apache.commons.exec.CommandLine; +import org.apache.commons.exec.DefaultExecutor; +import org.apache.commons.exec.ExecuteException; +import org.apache.commons.exec.PumpStreamHandler; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.python.core.PyException; +import org.python.core.PyObject; +import org.python.util.PythonInterpreter; + +public class JavaPythonInteropUnitTest { + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Test + public void givenPythonScript_whenPythonProcessInvoked_thenSuccess() throws Exception { + ProcessBuilder processBuilder = new ProcessBuilder("python", resolvePythonScriptPath("hello.py")); + processBuilder.redirectErrorStream(true); + + Process process = processBuilder.start(); + List results = readProcessOutput(process.getInputStream()); + + assertThat("Results should not be empty", results, is(not(empty()))); + assertThat("Results should contain output of script: ", results, hasItem(containsString("Hello Baeldung Readers!!"))); + + int exitCode = process.waitFor(); + assertEquals("No errors should be detected", 0, exitCode); + } + + @Test + public void givenPythonScriptEngineIsAvailable_whenScriptInvoked_thenOutputDisplayed() throws Exception { + StringWriter output = new StringWriter(); + ScriptContext context = new SimpleScriptContext(); + context.setWriter(output); + + ScriptEngineManager manager = new ScriptEngineManager(); + ScriptEngine engine = manager.getEngineByName("python"); + engine.eval(new FileReader(resolvePythonScriptPath("hello.py")), context); + assertEquals("Should contain script output: ", "Hello Baeldung Readers!!", output.toString() + .trim()); + } + + @Test + public void givenPythonInterpreter_whenPrintExecuted_thenOutputDisplayed() { + try (PythonInterpreter pyInterp = new PythonInterpreter()) { + StringWriter output = new StringWriter(); + pyInterp.setOut(output); + + pyInterp.exec("print('Hello Baeldung Readers!!')"); + assertEquals("Should contain script output: ", "Hello Baeldung Readers!!", output.toString() + .trim()); + } + } + + @Test + public void givenPythonInterpreter_whenNumbersAdded_thenOutputDisplayed() { + try (PythonInterpreter pyInterp = new PythonInterpreter()) { + pyInterp.exec("x = 10+10"); + PyObject x = pyInterp.get("x"); + assertEquals("x: ", 20, x.asInt()); + } + } + + @Test + public void givenPythonInterpreter_whenErrorOccurs_thenExceptionIsThrown() { + thrown.expect(PyException.class); + thrown.expectMessage("ImportError: No module named syds"); + + try (PythonInterpreter pyInterp = new PythonInterpreter()) { + pyInterp.exec("import syds"); + } + } + + @Test + public void givenPythonScript_whenPythonProcessExecuted_thenSuccess() throws ExecuteException, IOException { + String line = "python " + resolvePythonScriptPath("hello.py"); + CommandLine cmdLine = CommandLine.parse(line); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + PumpStreamHandler streamHandler = new PumpStreamHandler(outputStream); + + DefaultExecutor executor = new DefaultExecutor(); + executor.setStreamHandler(streamHandler); + + int exitCode = executor.execute(cmdLine); + assertEquals("No errors should be detected", 0, exitCode); + assertEquals("Should contain script output: ", "Hello Baeldung Readers!!", outputStream.toString() + .trim()); + } + + private List readProcessOutput(InputStream inputStream) throws IOException { + try (BufferedReader output = new BufferedReader(new InputStreamReader(inputStream))) { + return output.lines() + .collect(Collectors.toList()); + } + } + + private String resolvePythonScriptPath(String filename) { + File file = new File("src/test/resources/" + filename); + return file.getAbsolutePath(); + } + +} diff --git a/java-python-interop/src/test/resources/hello.py b/java-python-interop/src/test/resources/hello.py new file mode 100644 index 0000000000..13275d9257 --- /dev/null +++ b/java-python-interop/src/test/resources/hello.py @@ -0,0 +1 @@ +print("Hello Baeldung Readers!!") \ No newline at end of file diff --git a/pom.xml b/pom.xml index 34703c6f73..f750ea8869 100644 --- a/pom.xml +++ b/pom.xml @@ -461,7 +461,8 @@ java-lite java-numbers java-numbers-2 - java-numbers-3 + java-numbers-3 + java-python-interop java-rmi java-spi java-vavr-stream From 020837fa2f2feb4295a315ff285691a459ba54a9 Mon Sep 17 00:00:00 2001 From: sasam0320 <63002713+sasam0320@users.noreply.github.com> Date: Wed, 13 May 2020 11:09:41 +0200 Subject: [PATCH 502/503] BAEL 3234 - Add missing code snippets from the Spring Properties article (#9280) --- .../main/resources/configForDbProperties.xml | 19 +++++++++++++++++++ .../main/resources/configForProperties.xml | 3 ++- .../src/main/resources/database.properties | 5 +++-- ...plePropertiesXmlConfigIntegrationTest.java | 2 +- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 spring-boot-modules/spring-boot-properties/src/main/resources/configForDbProperties.xml diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/configForDbProperties.xml b/spring-boot-modules/spring-boot-properties/src/main/resources/configForDbProperties.xml new file mode 100644 index 0000000000..00fd5f0508 --- /dev/null +++ b/spring-boot-modules/spring-boot-properties/src/main/resources/configForDbProperties.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/configForProperties.xml b/spring-boot-modules/spring-boot-properties/src/main/resources/configForProperties.xml index 4468bb485f..bf4452da4a 100644 --- a/spring-boot-modules/spring-boot-properties/src/main/resources/configForProperties.xml +++ b/spring-boot-modules/spring-boot-properties/src/main/resources/configForProperties.xml @@ -7,7 +7,8 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd" > - + + diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/database.properties b/spring-boot-modules/spring-boot-properties/src/main/resources/database.properties index 6524ce6109..eb5703ca72 100644 --- a/spring-boot-modules/spring-boot-properties/src/main/resources/database.properties +++ b/spring-boot-modules/spring-boot-properties/src/main/resources/database.properties @@ -1,4 +1,5 @@ -database.url=jdbc:postgresql:/localhost:5432/instance + +jdbc.url=jdbc:postgresql:/localhost:5432 database.username=foo database.password=bar -jdbc.url=jdbc:postgresql:/localhost:5432 \ No newline at end of file + diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesXmlConfigIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesXmlConfigIntegrationTest.java index 6827ee1cf1..2150d4b3ec 100644 --- a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesXmlConfigIntegrationTest.java +++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePropertiesXmlConfigIntegrationTest.java @@ -6,7 +6,7 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import static org.assertj.core.api.Assertions.assertThat; -@SpringJUnitConfig(locations = "classpath:configForProperties.xml") +@SpringJUnitConfig(locations = {"classpath:configForProperties.xml", "classpath:configForDbProperties.xml"}) public class MultiplePropertiesXmlConfigIntegrationTest { @Value("${key.something}") private String something; From b48a87a352ac4d8fec84c257fcb182111a8f6e83 Mon Sep 17 00:00:00 2001 From: Benjamin Caure Date: Wed, 13 May 2020 17:43:22 +0200 Subject: [PATCH 503/503] Copy "BSON to JSON" tutorial entities to dedicated package (#9283) com.baeldung.bsontojson --- .../java/com/baeldung/bsontojson/Book.java | 168 ++++++++++++++++++ .../com/baeldung/bsontojson/Publisher.java | 70 ++++++++ .../bsontojson/BsonToJsonLiveTest.java | 22 +-- 3 files changed, 242 insertions(+), 18 deletions(-) create mode 100644 persistence-modules/java-mongodb/src/main/java/com/baeldung/bsontojson/Book.java create mode 100644 persistence-modules/java-mongodb/src/main/java/com/baeldung/bsontojson/Publisher.java diff --git a/persistence-modules/java-mongodb/src/main/java/com/baeldung/bsontojson/Book.java b/persistence-modules/java-mongodb/src/main/java/com/baeldung/bsontojson/Book.java new file mode 100644 index 0000000000..44e4ecb539 --- /dev/null +++ b/persistence-modules/java-mongodb/src/main/java/com/baeldung/bsontojson/Book.java @@ -0,0 +1,168 @@ +package com.baeldung.bsontojson; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.HashSet; +import java.util.Set; + +import dev.morphia.annotations.Embedded; +import dev.morphia.annotations.Entity; +import dev.morphia.annotations.Field; +import dev.morphia.annotations.Id; +import dev.morphia.annotations.Index; +import dev.morphia.annotations.IndexOptions; +import dev.morphia.annotations.Indexes; +import dev.morphia.annotations.Property; +import dev.morphia.annotations.Reference; +import dev.morphia.annotations.Validation; + +@Entity("Books") +@Indexes({ @Index(fields = @Field("title"), options = @IndexOptions(name = "book_title")) }) +@Validation("{ price : { $gt : 0 } }") +public class Book { + @Id + private String isbn; + @Property + private String title; + private String author; + @Embedded + private Publisher publisher; + @Property("price") + private double cost; + @Reference + private Set companionBooks; + @Property + private LocalDateTime publishDate; + + public Book() { + + } + + public Book(String isbn, String title, String author, double cost, Publisher publisher) { + this.isbn = isbn; + this.title = title; + this.author = author; + this.cost = cost; + this.publisher = publisher; + this.companionBooks = new HashSet<>(); + } + + // Getters and setters ... + public String getIsbn() { + return isbn; + } + + public Book setIsbn(String isbn) { + this.isbn = isbn; + return this; + } + + public String getTitle() { + return title; + } + + public Book setTitle(String title) { + this.title = title; + return this; + } + + public String getAuthor() { + return author; + } + + public Book setAuthor(String author) { + this.author = author; + return this; + } + + public Publisher getPublisher() { + return publisher; + } + + public Book setPublisher(Publisher publisher) { + this.publisher = publisher; + return this; + } + + public double getCost() { + return cost; + } + + public Book setCost(double cost) { + this.cost = cost; + return this; + } + + public LocalDateTime getPublishDate() { + return publishDate; + } + + public Book setPublishDate(LocalDateTime publishDate) { + this.publishDate = publishDate; + return this; + } + + public Set getCompanionBooks() { + return companionBooks; + } + + public Book addCompanionBooks(Book book) { + if (companionBooks != null) + this.companionBooks.add(book); + return this; + } + + @Override + public String toString() { + return "Book [isbn=" + isbn + ", title=" + title + ", author=" + author + ", publisher=" + publisher + ", cost=" + cost + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((author == null) ? 0 : author.hashCode()); + long temp; + temp = Double.doubleToLongBits(cost); + result = prime * result + (int) (temp ^ (temp >>> 32)); + result = prime * result + ((isbn == null) ? 0 : isbn.hashCode()); + result = prime * result + ((publisher == null) ? 0 : publisher.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Book other = (Book) obj; + if (author == null) { + if (other.author != null) + return false; + } else if (!author.equals(other.author)) + return false; + if (Double.doubleToLongBits(cost) != Double.doubleToLongBits(other.cost)) + return false; + if (isbn == null) { + if (other.isbn != null) + return false; + } else if (!isbn.equals(other.isbn)) + return false; + if (publisher == null) { + if (other.publisher != null) + return false; + } else if (!publisher.equals(other.publisher)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + +} diff --git a/persistence-modules/java-mongodb/src/main/java/com/baeldung/bsontojson/Publisher.java b/persistence-modules/java-mongodb/src/main/java/com/baeldung/bsontojson/Publisher.java new file mode 100644 index 0000000000..1ab262c82b --- /dev/null +++ b/persistence-modules/java-mongodb/src/main/java/com/baeldung/bsontojson/Publisher.java @@ -0,0 +1,70 @@ +package com.baeldung.bsontojson; + +import org.bson.types.ObjectId; + +import dev.morphia.annotations.Entity; +import dev.morphia.annotations.Id; + +@Entity +public class Publisher { + + @Id + private ObjectId id; + private String name; + + public Publisher() { + + } + + public Publisher(ObjectId id, String name) { + this.id = id; + this.name = name; + } + + public ObjectId getId() { + return id; + } + + public void setId(ObjectId id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public String toString() { + return "Catalog [id=" + id + ", name=" + name + "]"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Publisher other = (Publisher) obj; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + +} diff --git a/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonLiveTest.java b/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonLiveTest.java index 4e70394069..12053523f8 100644 --- a/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonLiveTest.java +++ b/persistence-modules/java-mongodb/src/test/java/com/baeldung/bsontojson/BsonToJsonLiveTest.java @@ -2,32 +2,18 @@ package com.baeldung.bsontojson; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import java.sql.Timestamp; -import java.time.Instant; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.Date; -import java.util.TimeZone; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.bson.Document; -import org.bson.json.Converter; import org.bson.json.JsonMode; import org.bson.json.JsonWriterSettings; -import org.bson.json.StrictJsonWriter; import org.bson.types.ObjectId; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -import org.junit.jupiter.api.AfterEach; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.baeldung.morphia.domain.Book; -import com.baeldung.morphia.domain.Publisher; import com.mongodb.MongoClient; import com.mongodb.client.MongoDatabase; @@ -42,7 +28,7 @@ public class BsonToJsonLiveTest { @BeforeClass public static void setUp() { Morphia morphia = new Morphia(); - morphia.mapPackage("com.baeldung.morphia"); + morphia.mapPackage("com.baeldung.bsontojson"); datastore = morphia.createDatastore(new MongoClient(), DB_NAME); datastore.ensureIndexes(); @@ -72,7 +58,7 @@ public class BsonToJsonLiveTest { } String expectedJson = "{\"_id\": \"isbn\", " + - "\"className\": \"com.baeldung.morphia.domain.Book\", " + + "\"className\": \"com.baeldung.bsontojson.Book\", " + "\"title\": \"title\", " + "\"author\": \"author\", " + "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " + @@ -100,7 +86,7 @@ public class BsonToJsonLiveTest { } String expectedJson = "{\"_id\": \"isbn\", " + - "\"className\": \"com.baeldung.morphia.domain.Book\", " + + "\"className\": \"com.baeldung.bsontojson.Book\", " + "\"title\": \"title\", " + "\"author\": \"author\", " + "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " + @@ -127,7 +113,7 @@ public class BsonToJsonLiveTest { } String expectedJson = "{\"_id\": \"isbn\", " + - "\"className\": \"com.baeldung.morphia.domain.Book\", " + + "\"className\": \"com.baeldung.bsontojson.Book\", " + "\"title\": \"title\", " + "\"author\": \"author\", " + "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " +