From dc3589a7a0548e0d6d1a1158fabd0f6af9bd4b2e Mon Sep 17 00:00:00 2001 From: Doha2012 Date: Fri, 11 Aug 2017 22:02:08 +0200 Subject: [PATCH 1/3] fix spring-boot module (#2422) * fix spring config * fix spring config * fix spring config * minor fix * fix spring-boot module --- spring-boot/pom.xml | 8 ++++---- .../baeldung/servlets/props/PropertySourcesLoader.java | 2 +- .../utils/{Application.java => UtilsApplication.java} | 4 ++-- spring-boot/src/main/webapp/WEB-INF/context.xml | 4 ++-- spring-boot/src/main/webapp/WEB-INF/dispatcher.xml | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) rename spring-boot/src/main/java/com/baeldung/utils/{Application.java => UtilsApplication.java} (83%) diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml index 2a1de00039..3fafa6ade2 100644 --- a/spring-boot/pom.xml +++ b/spring-boot/pom.xml @@ -52,7 +52,7 @@ test - + io.dropwizard.metrics @@ -253,8 +253,8 @@ - org.baeldung.boot.DemoApplication - 4.3.4.RELEASE + 4.3.4.RELEASE 2.2.1 3.1.1 3.3.7-1 diff --git a/spring-boot/src/main/java/com/baeldung/servlets/props/PropertySourcesLoader.java b/spring-boot/src/main/java/com/baeldung/servlets/props/PropertySourcesLoader.java index 56a6751326..aa70bac777 100644 --- a/spring-boot/src/main/java/com/baeldung/servlets/props/PropertySourcesLoader.java +++ b/spring-boot/src/main/java/com/baeldung/servlets/props/PropertySourcesLoader.java @@ -9,7 +9,7 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.ConfigurableEnvironment; @Configuration -@ComponentScan(basePackages = { "com.baeldung.*" }) +@ComponentScan(basePackages = { "com.baeldung.servlets.*" }) @PropertySource("classpath:custom.properties") public class PropertySourcesLoader { private static final Logger log = LoggerFactory.getLogger(PropertySourcesLoader.class); diff --git a/spring-boot/src/main/java/com/baeldung/utils/Application.java b/spring-boot/src/main/java/com/baeldung/utils/UtilsApplication.java similarity index 83% rename from spring-boot/src/main/java/com/baeldung/utils/Application.java rename to spring-boot/src/main/java/com/baeldung/utils/UtilsApplication.java index 9d5d75bce2..b63ada9eee 100644 --- a/spring-boot/src/main/java/com/baeldung/utils/Application.java +++ b/spring-boot/src/main/java/com/baeldung/utils/UtilsApplication.java @@ -10,11 +10,11 @@ import com.baeldung.autoconfiguration.MySQLAutoconfiguration; @SpringBootApplication(exclude=MySQLAutoconfiguration.class) @ComponentScan(basePackages="com.baeldung.utils") -public class Application { +public class UtilsApplication { @RolesAllowed("*") public static void main(String[] args) { - SpringApplication.run(Application.class, args); + SpringApplication.run(UtilsApplication.class, args); } } diff --git a/spring-boot/src/main/webapp/WEB-INF/context.xml b/spring-boot/src/main/webapp/WEB-INF/context.xml index 263bed4430..32f11f78f6 100644 --- a/spring-boot/src/main/webapp/WEB-INF/context.xml +++ b/spring-boot/src/main/webapp/WEB-INF/context.xml @@ -6,7 +6,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd"> - + - + \ No newline at end of file diff --git a/spring-boot/src/main/webapp/WEB-INF/dispatcher.xml b/spring-boot/src/main/webapp/WEB-INF/dispatcher.xml index ade8e66777..54e62921be 100644 --- a/spring-boot/src/main/webapp/WEB-INF/dispatcher.xml +++ b/spring-boot/src/main/webapp/WEB-INF/dispatcher.xml @@ -7,7 +7,7 @@ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> - + From a4132df3e541db2825134cbd81222b43c7c74525 Mon Sep 17 00:00:00 2001 From: Doha2012 Date: Sat, 12 Aug 2017 07:49:55 +0200 Subject: [PATCH 2/3] fix pom (#2423) * fix spring config * fix spring config * fix spring config * minor fix * fix spring-boot module * fix pom --- spring-boot/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot/pom.xml b/spring-boot/pom.xml index 3fafa6ade2..0cf7df86cd 100644 --- a/spring-boot/pom.xml +++ b/spring-boot/pom.xml @@ -253,8 +253,8 @@ - 4.3.4.RELEASE + org.baeldung.boot.DemoApplication + 4.3.4.RELEASE 2.2.1 3.1.1 3.3.7-1 From 310e89e4f04402700be4a5fa4686a9c7914ec6f6 Mon Sep 17 00:00:00 2001 From: Ahmed Tawila Date: Sat, 12 Aug 2017 07:59:15 +0200 Subject: [PATCH 3/3] BAEL-1035 Introduction to Eclipse Collections (#2421) * Evaluation article: Different Types of Bean Injection in Spring * added tests & changed configuration to Java-based config * removed xml config files * rename unit tests * BAEL-972 - Apache Commons Text * remove code from evaluation article * remove code from evaluation article * BAEL-972 - Apache Commons Text - added another example * BAEL-972 - Apache Commons Text - just indentation * BAEL-994 - TemporalAdjuster in Java * BAEL-994 - TemporalAdjuster in Java * BAEL-994 - TemporalAdjuster in Java * BAEL-994 - TemporalAdjuster in Java * BAEL-994 - TemporalAdjuster in Java - fix problems * BAEL-1033 Introduction to StreamUtils * BAEL-1033 Introduction to StreamUtils * BAEL-1033 Introduction to StreamUtils * fix formatting * BAEL-1033 minor refactor * BAEL-1035 Introduction to Eclipse Collections * format * BAEL-1035 Introduction to Eclipse Collections * BAEL-1035 Introduction to Eclipse Collections --- libraries/pom.xml | 2 +- .../baeldung/eclipsecollections/Student.java | 26 ++++++++++++ .../CollectPatternTest.java | 4 +- .../eclipsecollections/FlatCollectTest.java | 42 +++++++++++++++++++ .../PartitionPatternTest.java | 1 - .../baeldung/eclipsecollections/ZipTest.java | 22 ++++++++++ .../eclipsecollections/ZipWithIndexTest.java | 22 ++++++++++ 7 files changed, 115 insertions(+), 4 deletions(-) create mode 100644 libraries/src/test/java/com/baeldung/eclipsecollections/FlatCollectTest.java create mode 100644 libraries/src/test/java/com/baeldung/eclipsecollections/ZipTest.java create mode 100644 libraries/src/test/java/com/baeldung/eclipsecollections/ZipWithIndexTest.java diff --git a/libraries/pom.xml b/libraries/pom.xml index 490302ca29..a16a4de59d 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -515,4 +515,4 @@ 1.0 8.2.0 - + \ No newline at end of file diff --git a/libraries/src/main/java/com/baeldung/eclipsecollections/Student.java b/libraries/src/main/java/com/baeldung/eclipsecollections/Student.java index 2c634a28d9..cf6c06cec0 100644 --- a/libraries/src/main/java/com/baeldung/eclipsecollections/Student.java +++ b/libraries/src/main/java/com/baeldung/eclipsecollections/Student.java @@ -1,15 +1,25 @@ package com.baeldung.eclipsecollections; +import java.util.List; + public class Student { private String firstName; private String lastName; + private List addresses; public Student(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } + public Student(String firstName, String lastName, List addresses) { + super(); + this.firstName = firstName; + this.lastName = lastName; + this.addresses = addresses; + } + public String getFirstName() { return this.firstName; } @@ -17,4 +27,20 @@ public class Student { public String getLastName() { return this.lastName; } + + public List getAddresses() { + return addresses; + } + + public void setAddresses(List addresses) { + this.addresses = addresses; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } } \ No newline at end of file diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/CollectPatternTest.java b/libraries/src/test/java/com/baeldung/eclipsecollections/CollectPatternTest.java index 51591cd08c..5fb63794a1 100644 --- a/libraries/src/test/java/com/baeldung/eclipsecollections/CollectPatternTest.java +++ b/libraries/src/test/java/com/baeldung/eclipsecollections/CollectPatternTest.java @@ -16,7 +16,7 @@ public class CollectPatternTest { MutableList lastNames = students.collect(Student::getLastName); - assertEquals(lastNames.get(0), "Hopkins"); - assertEquals(lastNames.get(1), "Adams"); + assertEquals("Hopkins", lastNames.get(0)); + assertEquals("Adams", lastNames.get(1)); } } diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/FlatCollectTest.java b/libraries/src/test/java/com/baeldung/eclipsecollections/FlatCollectTest.java new file mode 100644 index 0000000000..3d1453e557 --- /dev/null +++ b/libraries/src/test/java/com/baeldung/eclipsecollections/FlatCollectTest.java @@ -0,0 +1,42 @@ +package com.baeldung.eclipsecollections; + +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.impl.list.mutable.FastList; +import static org.junit.Assert.assertEquals; +import org.junit.Before; +import org.junit.Test; + +public class FlatCollectTest { + + MutableList addresses1; + MutableList addresses2; + MutableList addresses3; + MutableList addresses4; + + MutableList students; + + @Before + public void setup() { + String address1 = "73 Pacific St., Forest Hills, NY 11375"; + String address2 = "93 Bayport Ave., South Richmond Hill, NY 11419"; + String address3 = "548 Market St, San Francisco, CA 94104"; + String address4 = "8605 Santa Monica Blvd, West Hollywood, CA 90069"; + + this.addresses1 = FastList.newListWith(address1, address2); + this.addresses2 = FastList.newListWith(address3, address4); + Student student1 = new Student("John", "Hopkins", addresses1); + Student student2 = new Student("George", "Adams", addresses2); + this.addresses2 = FastList.newListWith(address3, address4); + this.students = FastList.newListWith(student1, student2); + } + + @Test + public void whenFlatCollect_thenCorrect() { + MutableList addresses = students.flatCollect(Student::getAddresses); + + assertEquals("73 Pacific St., Forest Hills, NY 11375", addresses.get(0)); + assertEquals("93 Bayport Ave., South Richmond Hill, NY 11419", addresses.get(1)); + assertEquals("548 Market St, San Francisco, CA 94104", addresses.get(2)); + assertEquals("8605 Santa Monica Blvd, West Hollywood, CA 90069", addresses.get(3)); + } +} diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/PartitionPatternTest.java b/libraries/src/test/java/com/baeldung/eclipsecollections/PartitionPatternTest.java index 3e52829824..4d9619817b 100644 --- a/libraries/src/test/java/com/baeldung/eclipsecollections/PartitionPatternTest.java +++ b/libraries/src/test/java/com/baeldung/eclipsecollections/PartitionPatternTest.java @@ -28,7 +28,6 @@ public class PartitionPatternTest { list.add(38); } - @SuppressWarnings({ "unused" }) @Test public void whenAnySatisfiesCondition_thenCorrect() { MutableList numbers = list; diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/ZipTest.java b/libraries/src/test/java/com/baeldung/eclipsecollections/ZipTest.java new file mode 100644 index 0000000000..9dfab8f32d --- /dev/null +++ b/libraries/src/test/java/com/baeldung/eclipsecollections/ZipTest.java @@ -0,0 +1,22 @@ +package com.baeldung.eclipsecollections; + +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.api.tuple.Pair; +import org.eclipse.collections.impl.factory.Lists; +import org.eclipse.collections.impl.tuple.Tuples; +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class ZipTest { + + @Test + public void whenZip_thenCorrect() { + MutableList numbers = Lists.mutable.with("1", "2", "3", "Ignored"); + MutableList cars = Lists.mutable.with("Porsche", "Volvo", "Toyota"); + MutableList> pairs = numbers.zip(cars); + + assertEquals(Tuples.pair("1", "Porsche"), pairs.get(0)); + assertEquals(Tuples.pair("2", "Volvo"), pairs.get(1)); + assertEquals(Tuples.pair("3", "Toyota"), pairs.get(2)); + } +} diff --git a/libraries/src/test/java/com/baeldung/eclipsecollections/ZipWithIndexTest.java b/libraries/src/test/java/com/baeldung/eclipsecollections/ZipWithIndexTest.java new file mode 100644 index 0000000000..3e8fe9b410 --- /dev/null +++ b/libraries/src/test/java/com/baeldung/eclipsecollections/ZipWithIndexTest.java @@ -0,0 +1,22 @@ +package com.baeldung.eclipsecollections; + +import static org.junit.Assert.assertEquals; + +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.api.tuple.Pair; +import org.eclipse.collections.impl.list.mutable.FastList; +import org.eclipse.collections.impl.tuple.Tuples; +import org.junit.Test; + +public class ZipWithIndexTest { + + @Test + public void whenZip_thenCorrect() { + MutableList cars = FastList.newListWith("Porsche", "Volvo", "Toyota"); + MutableList> pairs = cars.zipWithIndex(); + + assertEquals(Tuples.pair("Porsche", 0), pairs.get(0)); + assertEquals(Tuples.pair("Volvo", 1), pairs.get(1)); + assertEquals(Tuples.pair("Toyota", 2), pairs.get(2)); + } +}