From e3a84dae5b623ed2245d35ccaf5073e5582113fa Mon Sep 17 00:00:00 2001 From: Dmytro Korniienko Date: Sun, 9 Sep 2018 13:13:17 +0300 Subject: [PATCH 01/22] BAEL-2070 Qualifier used instead of Primary to distinguish between different repository beans --- .../baeldung/dependency/exception/app/PurchaseDeptService.java | 3 ++- .../dependency/exception/repository/DressRepository.java | 3 ++- .../dependency/exception/repository/ShoeRepository.java | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/spring-core/src/main/java/com/baeldung/dependency/exception/app/PurchaseDeptService.java b/spring-core/src/main/java/com/baeldung/dependency/exception/app/PurchaseDeptService.java index 1e6fad63aa..e0fe01acdd 100644 --- a/spring-core/src/main/java/com/baeldung/dependency/exception/app/PurchaseDeptService.java +++ b/spring-core/src/main/java/com/baeldung/dependency/exception/app/PurchaseDeptService.java @@ -1,13 +1,14 @@ package com.baeldung.dependency.exception.app; import com.baeldung.dependency.exception.repository.InventoryRepository; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; @Service public class PurchaseDeptService { private InventoryRepository repository; - public PurchaseDeptService(InventoryRepository repository) { + public PurchaseDeptService(@Qualifier("dresses") InventoryRepository repository) { this.repository = repository; } } \ No newline at end of file diff --git a/spring-core/src/main/java/com/baeldung/dependency/exception/repository/DressRepository.java b/spring-core/src/main/java/com/baeldung/dependency/exception/repository/DressRepository.java index 4a6c836143..5a1371ce04 100644 --- a/spring-core/src/main/java/com/baeldung/dependency/exception/repository/DressRepository.java +++ b/spring-core/src/main/java/com/baeldung/dependency/exception/repository/DressRepository.java @@ -1,9 +1,10 @@ package com.baeldung.dependency.exception.repository; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Repository; -@Primary +@Qualifier("dresses") @Repository public class DressRepository implements InventoryRepository { } diff --git a/spring-core/src/main/java/com/baeldung/dependency/exception/repository/ShoeRepository.java b/spring-core/src/main/java/com/baeldung/dependency/exception/repository/ShoeRepository.java index 60495914cd..227d8934b6 100644 --- a/spring-core/src/main/java/com/baeldung/dependency/exception/repository/ShoeRepository.java +++ b/spring-core/src/main/java/com/baeldung/dependency/exception/repository/ShoeRepository.java @@ -1,7 +1,9 @@ package com.baeldung.dependency.exception.repository; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Repository; +@Qualifier("shoes") @Repository public class ShoeRepository implements InventoryRepository { } From 9664247f4f426bea83b625a510b76ffe9068e08c Mon Sep 17 00:00:00 2001 From: Dmytro Korniienko Date: Mon, 10 Sep 2018 21:29:38 +0300 Subject: [PATCH 02/22] BAEL-2095 CrudRepository save() method --- .../baeldung/config/CustomConfiguration.java | 29 ++++++++++++++++ .../dao/repositories/InventoryRepository.java | 7 ++++ .../baeldung/domain/MerchandiseEntity.java | 34 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 spring-data-jpa/src/main/java/com/baeldung/config/CustomConfiguration.java create mode 100644 spring-data-jpa/src/main/java/com/baeldung/dao/repositories/InventoryRepository.java create mode 100644 spring-data-jpa/src/main/java/com/baeldung/domain/MerchandiseEntity.java diff --git a/spring-data-jpa/src/main/java/com/baeldung/config/CustomConfiguration.java b/spring-data-jpa/src/main/java/com/baeldung/config/CustomConfiguration.java new file mode 100644 index 0000000000..5af5351d76 --- /dev/null +++ b/spring-data-jpa/src/main/java/com/baeldung/config/CustomConfiguration.java @@ -0,0 +1,29 @@ +package com.baeldung.config; + +import com.baeldung.dao.repositories.InventoryRepository; +import com.baeldung.domain.MerchandiseEntity; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; + +@SpringBootApplication +@EnableJpaRepositories(basePackageClasses = InventoryRepository.class) +@EntityScan(basePackageClasses = MerchandiseEntity.class) +public class CustomConfiguration { + public static void main(String[] args) { + ConfigurableApplicationContext context = SpringApplication.run(CustomConfiguration.class, args); + + InventoryRepository repo = context.getBean(InventoryRepository.class); + + MerchandiseEntity pants = new MerchandiseEntity("Pair of Pants"); + repo.save(pants); + + MerchandiseEntity shorts = new MerchandiseEntity("Pair of Shorts"); + repo.save(shorts); + + pants.setTitle("Branded Luxury Pants"); + repo.save(pants); + } +} diff --git a/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/InventoryRepository.java b/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/InventoryRepository.java new file mode 100644 index 0000000000..a575f0b915 --- /dev/null +++ b/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/InventoryRepository.java @@ -0,0 +1,7 @@ +package com.baeldung.dao.repositories; + +import com.baeldung.domain.MerchandiseEntity; +import org.springframework.data.repository.CrudRepository; + +public interface InventoryRepository extends CrudRepository { +} diff --git a/spring-data-jpa/src/main/java/com/baeldung/domain/MerchandiseEntity.java b/spring-data-jpa/src/main/java/com/baeldung/domain/MerchandiseEntity.java new file mode 100644 index 0000000000..921edf1b85 --- /dev/null +++ b/spring-data-jpa/src/main/java/com/baeldung/domain/MerchandiseEntity.java @@ -0,0 +1,34 @@ +package com.baeldung.domain; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class MerchandiseEntity { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + private String title; + + public MerchandiseEntity() { + } + + public MerchandiseEntity(String title) { + this.title = title; + } + + public Long getId() { + return id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } +} From 2e60aa32a251a43e3153c5aeb9609bde16995e60 Mon Sep 17 00:00:00 2001 From: Dmytro Korniienko Date: Tue, 11 Sep 2018 00:13:41 +0300 Subject: [PATCH 03/22] (REVERT) BAEL-2095 CrudRepository save() method --- .../baeldung/config/CustomConfiguration.java | 29 ---------------- .../dao/repositories/InventoryRepository.java | 7 ---- .../baeldung/domain/MerchandiseEntity.java | 34 ------------------- 3 files changed, 70 deletions(-) delete mode 100644 spring-data-jpa/src/main/java/com/baeldung/config/CustomConfiguration.java delete mode 100644 spring-data-jpa/src/main/java/com/baeldung/dao/repositories/InventoryRepository.java delete mode 100644 spring-data-jpa/src/main/java/com/baeldung/domain/MerchandiseEntity.java diff --git a/spring-data-jpa/src/main/java/com/baeldung/config/CustomConfiguration.java b/spring-data-jpa/src/main/java/com/baeldung/config/CustomConfiguration.java deleted file mode 100644 index 5af5351d76..0000000000 --- a/spring-data-jpa/src/main/java/com/baeldung/config/CustomConfiguration.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baeldung.config; - -import com.baeldung.dao.repositories.InventoryRepository; -import com.baeldung.domain.MerchandiseEntity; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; - -@SpringBootApplication -@EnableJpaRepositories(basePackageClasses = InventoryRepository.class) -@EntityScan(basePackageClasses = MerchandiseEntity.class) -public class CustomConfiguration { - public static void main(String[] args) { - ConfigurableApplicationContext context = SpringApplication.run(CustomConfiguration.class, args); - - InventoryRepository repo = context.getBean(InventoryRepository.class); - - MerchandiseEntity pants = new MerchandiseEntity("Pair of Pants"); - repo.save(pants); - - MerchandiseEntity shorts = new MerchandiseEntity("Pair of Shorts"); - repo.save(shorts); - - pants.setTitle("Branded Luxury Pants"); - repo.save(pants); - } -} diff --git a/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/InventoryRepository.java b/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/InventoryRepository.java deleted file mode 100644 index a575f0b915..0000000000 --- a/spring-data-jpa/src/main/java/com/baeldung/dao/repositories/InventoryRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.baeldung.dao.repositories; - -import com.baeldung.domain.MerchandiseEntity; -import org.springframework.data.repository.CrudRepository; - -public interface InventoryRepository extends CrudRepository { -} diff --git a/spring-data-jpa/src/main/java/com/baeldung/domain/MerchandiseEntity.java b/spring-data-jpa/src/main/java/com/baeldung/domain/MerchandiseEntity.java deleted file mode 100644 index 921edf1b85..0000000000 --- a/spring-data-jpa/src/main/java/com/baeldung/domain/MerchandiseEntity.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.baeldung.domain; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -@Entity -public class MerchandiseEntity { - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - private String title; - - public MerchandiseEntity() { - } - - public MerchandiseEntity(String title) { - this.title = title; - } - - public Long getId() { - return id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } -} From f9065d21b777cc8e29da6138914fc5cd66f59803 Mon Sep 17 00:00:00 2001 From: Dmytro Korniienko Date: Mon, 1 Oct 2018 10:17:39 +0300 Subject: [PATCH 04/22] BAEL-2258 Guide to DateTimeFormatter. Tests added for various formatting patterns and styles --- .../DateTimeFormatterUnitTest.java | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/core-java-8/src/test/java/com/baeldung/internationalization/DateTimeFormatterUnitTest.java b/core-java-8/src/test/java/com/baeldung/internationalization/DateTimeFormatterUnitTest.java index 4d95bc82e1..cbb84a8783 100644 --- a/core-java-8/src/test/java/com/baeldung/internationalization/DateTimeFormatterUnitTest.java +++ b/core-java-8/src/test/java/com/baeldung/internationalization/DateTimeFormatterUnitTest.java @@ -3,11 +3,14 @@ package com.baeldung.internationalization; import org.junit.Assert; import org.junit.Test; +import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.LocalTime; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.FormatStyle; +import java.time.temporal.ChronoUnit; import java.util.Locale; import java.util.TimeZone; @@ -43,4 +46,70 @@ public class DateTimeFormatterUnitTest { Assert.assertEquals("Monday, January 1, 2018 10:15:50 AM PST", formattedDateTime); Assert.assertEquals("lundi 1 janvier 2018 10 h 15 PST", frFormattedDateTime); } + + @Test + public void shoulPrintFormattedDate() { + String europeanDatePattern = "dd.MM.yyyy"; + DateTimeFormatter europeanDateFormatter = DateTimeFormatter.ofPattern(europeanDatePattern); + LocalDate summerDay = LocalDate.of(2016, 7, 31); + Assert.assertEquals("31.07.2016", europeanDateFormatter.format(summerDay)); + } + + @Test + public void shouldPrintFormattedTime24() { + String timeColonPattern = "HH:mm:ss"; + DateTimeFormatter timeColonFormatter = DateTimeFormatter.ofPattern(timeColonPattern); + LocalTime colonTime = LocalTime.of(17, 35, 50); + Assert.assertEquals("17:35:50", timeColonFormatter.format(colonTime)); + } + + @Test + public void shouldPrintFormattedTimeWithMillis() { + String timeColonPattern = "HH:mm:ss SSS"; + DateTimeFormatter timeColonFormatter = DateTimeFormatter.ofPattern(timeColonPattern); + LocalTime colonTime = LocalTime.of(17, 35, 50).plus(329, ChronoUnit.MILLIS); + Assert.assertEquals("17:35:50 329", timeColonFormatter.format(colonTime)); + } + + @Test + public void shouldPrintFormattedTimePM() { + String timeColonPattern = "hh:mm:ss a"; + DateTimeFormatter timeColonFormatter = DateTimeFormatter.ofPattern(timeColonPattern); + LocalTime colonTime = LocalTime.of(17, 35, 50); + Assert.assertEquals("05:35:50 PM", timeColonFormatter.format(colonTime)); + } + + @Test + public void shouldPrintFormattedUTCRelatedZonedDateTime() { + String newYorkDateTimePattern = "dd.MM.yyyy HH:mm z"; + DateTimeFormatter newYorkDateFormatter = DateTimeFormatter.ofPattern(newYorkDateTimePattern); + LocalDateTime summerDay = LocalDateTime.of(2016, 7, 31, 14, 15); + Assert.assertEquals("31.07.2016 14:15 UTC-04:00", newYorkDateFormatter.format(ZonedDateTime.of(summerDay, ZoneId.of("UTC-4")))); + } + + @Test + public void shouldPrintFormattedNewYorkZonedDateTime() { + String newYorkDateTimePattern = "dd.MM.yyyy HH:mm z"; + DateTimeFormatter newYorkDateFormatter = DateTimeFormatter.ofPattern(newYorkDateTimePattern); + LocalDateTime summerDay = LocalDateTime.of(2016, 7, 31, 14, 15); + Assert.assertEquals("31.07.2016 14:15 EDT", newYorkDateFormatter.format(ZonedDateTime.of(summerDay, ZoneId.of("America/New_York")))); + } + + @Test + public void shouldPrintStyledDate() { + LocalDate anotherSummerDay = LocalDate.of(2016, 8, 23); + Assert.assertEquals("Tuesday, August 23, 2016", DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL).format(anotherSummerDay)); + Assert.assertEquals("August 23, 2016", DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG).format(anotherSummerDay)); + Assert.assertEquals("Aug 23, 2016", DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).format(anotherSummerDay)); + Assert.assertEquals("8/23/16", DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT).format(anotherSummerDay)); + } + + @Test + public void shouldPrintStyledDateTime() { + LocalDateTime anotherSummerDay = LocalDateTime.of(2016, 8, 23, 13, 12, 45); + Assert.assertEquals("Tuesday, August 23, 2016 1:12:45 PM EET", DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).withZone(ZoneId.of("Europe/Helsinki")).format(anotherSummerDay)); + Assert.assertEquals("August 23, 2016 1:12:45 PM EET", DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG).withZone(ZoneId.of("Europe/Helsinki")).format(anotherSummerDay)); + Assert.assertEquals("Aug 23, 2016 1:12:45 PM", DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withZone(ZoneId.of("Europe/Helsinki")).format(anotherSummerDay)); + Assert.assertEquals("8/23/16 1:12 PM", DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT).withZone(ZoneId.of("Europe/Helsinki")).format(anotherSummerDay)); + } } From 7f6df18b64e5defb7909d6aa08748bf1cda41fc5 Mon Sep 17 00:00:00 2001 From: Dmytro Korniienko Date: Wed, 3 Oct 2018 23:55:24 +0300 Subject: [PATCH 05/22] BAEL-2258 Guide to DateTimeFormatter. Predefined formatters tests added --- .../internationalization/DateTimeFormatterUnitTest.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core-java-8/src/test/java/com/baeldung/internationalization/DateTimeFormatterUnitTest.java b/core-java-8/src/test/java/com/baeldung/internationalization/DateTimeFormatterUnitTest.java index cbb84a8783..1260a6db92 100644 --- a/core-java-8/src/test/java/com/baeldung/internationalization/DateTimeFormatterUnitTest.java +++ b/core-java-8/src/test/java/com/baeldung/internationalization/DateTimeFormatterUnitTest.java @@ -48,7 +48,7 @@ public class DateTimeFormatterUnitTest { } @Test - public void shoulPrintFormattedDate() { + public void shouldPrintFormattedDate() { String europeanDatePattern = "dd.MM.yyyy"; DateTimeFormatter europeanDateFormatter = DateTimeFormatter.ofPattern(europeanDatePattern); LocalDate summerDay = LocalDate.of(2016, 7, 31); @@ -112,4 +112,11 @@ public class DateTimeFormatterUnitTest { Assert.assertEquals("Aug 23, 2016 1:12:45 PM", DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withZone(ZoneId.of("Europe/Helsinki")).format(anotherSummerDay)); Assert.assertEquals("8/23/16 1:12 PM", DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT).withZone(ZoneId.of("Europe/Helsinki")).format(anotherSummerDay)); } + + @Test + public void shouldPrintFormattedDateTimeWithPredefined() { + Assert.assertEquals("2018-03-09", DateTimeFormatter.ISO_LOCAL_DATE.format(LocalDate.of(2018, 3, 9))); + Assert.assertEquals("2018-03-09-03:00", DateTimeFormatter.ISO_OFFSET_DATE.format(LocalDate.of(2018, 3, 9).atStartOfDay(ZoneId.of("UTC-3")))); + Assert.assertEquals("Fri, 9 Mar 2018 00:00:00 -0300", DateTimeFormatter.RFC_1123_DATE_TIME.format(LocalDate.of(2018, 3, 9).atStartOfDay(ZoneId.of("UTC-3")))); + } } From 08e902cb26072d8959bbcc191a91d1737d235c7d Mon Sep 17 00:00:00 2001 From: Dmytro Korniienko Date: Thu, 4 Oct 2018 23:14:59 +0300 Subject: [PATCH 06/22] BAEL-2258 Guide to DateTimeFormatter. parse() method usage tests added --- .../DateTimeFormatterUnitTest.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/core-java-8/src/test/java/com/baeldung/internationalization/DateTimeFormatterUnitTest.java b/core-java-8/src/test/java/com/baeldung/internationalization/DateTimeFormatterUnitTest.java index 1260a6db92..36a5f6210b 100644 --- a/core-java-8/src/test/java/com/baeldung/internationalization/DateTimeFormatterUnitTest.java +++ b/core-java-8/src/test/java/com/baeldung/internationalization/DateTimeFormatterUnitTest.java @@ -9,6 +9,7 @@ import java.time.LocalTime; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.time.format.FormatStyle; import java.time.temporal.ChronoUnit; import java.util.Locale; @@ -119,4 +120,39 @@ public class DateTimeFormatterUnitTest { Assert.assertEquals("2018-03-09-03:00", DateTimeFormatter.ISO_OFFSET_DATE.format(LocalDate.of(2018, 3, 9).atStartOfDay(ZoneId.of("UTC-3")))); Assert.assertEquals("Fri, 9 Mar 2018 00:00:00 -0300", DateTimeFormatter.RFC_1123_DATE_TIME.format(LocalDate.of(2018, 3, 9).atStartOfDay(ZoneId.of("UTC-3")))); } + + @Test + public void shouldParseDateTime() { + Assert.assertEquals(LocalDate.of(2018, 3, 12), LocalDate.from(DateTimeFormatter.ISO_LOCAL_DATE.parse("2018-03-09")).plusDays(3)); + } + + @Test + public void shouldParseFormatStyleFull() { + ZonedDateTime dateTime = ZonedDateTime.from(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).parse("Tuesday, August 23, 2016 1:12:45 PM EET")); + Assert.assertEquals(ZonedDateTime.of(LocalDateTime.of(2016, 8, 23, 22, 12, 45), ZoneId.of("Europe/Bucharest")), dateTime.plusHours(9)); + } + + @Test + public void shouldParseDateWithCustomFormatter() { + DateTimeFormatter europeanDateFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy"); + Assert.assertFalse(LocalDate.from(europeanDateFormatter.parse("15.08.2014")).isLeapYear()); + } + + @Test + public void shouldParseTimeWithCustomFormatter() { + DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("hh:mm:ss a"); + Assert.assertTrue(LocalTime.from(timeFormatter.parse("12:25:30 AM")).isBefore(LocalTime.NOON)); + } + + @Test + public void shouldParseZonedDateTimeWithCustomFormatter() { + DateTimeFormatter zonedFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm z"); + Assert.assertEquals(7200, ZonedDateTime.from(zonedFormatter.parse("31.07.2016 14:15 GMT+02:00")).getOffset().getTotalSeconds()); + } + + @Test(expected = DateTimeParseException.class) + public void shouldExpectAnExceptionIfDateTimeStringNotMatchPattern() { + DateTimeFormatter zonedFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm z"); + ZonedDateTime.from(zonedFormatter.parse("31.07.2016 14:15")); + } } From 45da250fffffffae062047e43973416232872624 Mon Sep 17 00:00:00 2001 From: clininger Date: Mon, 8 Oct 2018 07:33:16 +0700 Subject: [PATCH 07/22] BAEL-2184 Converting a Collection to ArrayList --- .../convertcollectiontoarraylist/Foo.java | 52 +++++++ .../FooUnitTest.java | 144 ++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 core-java-collections/src/main/java/com/baeldung/convertcollectiontoarraylist/Foo.java create mode 100644 core-java-collections/src/test/java/com/baeldung/convertcollectiontoarraylist/FooUnitTest.java diff --git a/core-java-collections/src/main/java/com/baeldung/convertcollectiontoarraylist/Foo.java b/core-java-collections/src/main/java/com/baeldung/convertcollectiontoarraylist/Foo.java new file mode 100644 index 0000000000..3123295641 --- /dev/null +++ b/core-java-collections/src/main/java/com/baeldung/convertcollectiontoarraylist/Foo.java @@ -0,0 +1,52 @@ +package com.baeldung.convertcollectiontoarraylist; + +/** + * This POJO is the element type of our collection. It has a deepCopy() method. + * + * @author chris + */ +public class Foo { + + private int id; + private String name; + private Foo parent; + + public Foo() { + } + + public Foo(int id, String name, Foo parent) { + this.id = id; + this.name = name; + this.parent = parent; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Foo getParent() { + return parent; + } + + public void setParent(Foo parent) { + this.parent = parent; + } + + public Foo deepCopy() { + return new Foo(this.id, this.name, + this.parent != null ? this.parent.deepCopy() : null); + } + +} diff --git a/core-java-collections/src/test/java/com/baeldung/convertcollectiontoarraylist/FooUnitTest.java b/core-java-collections/src/test/java/com/baeldung/convertcollectiontoarraylist/FooUnitTest.java new file mode 100644 index 0000000000..fd07848383 --- /dev/null +++ b/core-java-collections/src/test/java/com/baeldung/convertcollectiontoarraylist/FooUnitTest.java @@ -0,0 +1,144 @@ +package com.baeldung.convertcollectiontoarraylist; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Iterator; +import static java.util.stream.Collectors.toCollection; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author chris + */ +public class FooUnitTest { + private static Collection srcCollection = new HashSet<>(); + + public FooUnitTest() { + } + + @BeforeClass + public static void setUpClass() { + int i = 0; + Foo john = new Foo(i++, "John", null); + Foo mary = new Foo(i++, "Mary", null); + Foo sam = new Foo(i++, "Sam", john); + Foo alice = new Foo(i++, "Alice", john); + Foo buffy = new Foo(i++, "Buffy", sam); + srcCollection.add(john); + srcCollection.add(mary); + srcCollection.add(sam); + srcCollection.add(alice); + srcCollection.add(buffy); + } + + /** + * Section 3. Using the ArrayList Constructor + */ + @Test + public void testConstructor() { + ArrayList newList = new ArrayList<>(srcCollection); + verifyShallowCopy(srcCollection, newList); + } + + /** + * Section 4. Using the Streams API + */ + @Test + public void testStream() { + ArrayList newList = srcCollection.stream().collect(toCollection(ArrayList::new)); + verifyShallowCopy(srcCollection, newList); + } + + /** + * Section 5. Deep Copy + */ + @Test + public void testStreamDeepCopy() { + ArrayList newList = srcCollection.stream() + .map(foo -> foo.deepCopy()) + .collect(toCollection(ArrayList::new)); + verifyDeepCopy(srcCollection, newList); + } + + /** + * Section 6. Controlling the List Order + */ + @Test + public void testSortOrder() { + assertFalse("Oops: source collection is already sorted!", isSorted(srcCollection)); + ArrayList newList = srcCollection.stream() + .map(foo -> foo.deepCopy()) + .sorted(Comparator.comparing(Foo::getName)) + .collect(toCollection(ArrayList::new)); + assertTrue("ArrayList is not sorted by name", isSorted(newList)); + } + + /** + * Verify that the contents of the two collections are the same + * @param a + * @param 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()); + } + } + + /** + * Verify that the contents of the two collections are the same + * @param a + * @param 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(); + while (iterA.hasNext()) { + Foo nextA = iterA.next(); + Foo nextB = iterB.next(); + // should not be same instance + assertFalse("Foo instances are the same!", nextA == nextB); + // but should have same content + assertFalse("Foo instances have different content!", fooDiff(nextA, nextB)); + } + } + + /** + * Return true if the contents of a and b differ. Test parent recursively + * @param a + * @param b + * @return False if the two items are the same + */ + private boolean fooDiff(Foo a, Foo b) { + if (a != null && b != null) { + return a.getId() != b.getId() + || !a.getName().equals(b.getName()) + || fooDiff(a.getParent(), b.getParent()); + } + return !(a == null && b == null); + } + + /** + * @param c collection of Foo + * @return true if the collection is sorted by name + */ + private boolean isSorted(Collection c) { + String prevName = null; + for (Foo foo : c) { + if (prevName == null || foo.getName().compareTo(prevName) > 0) { + prevName = foo.getName(); + } else { + return false; + } + } + return true; + } +} From 7d64241f1634ebf68688a81bb431b7b90d704f68 Mon Sep 17 00:00:00 2001 From: clininger Date: Mon, 8 Oct 2018 08:21:35 +0700 Subject: [PATCH 08/22] BAEL-2184 test names --- .../convertcollectiontoarraylist/FooUnitTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core-java-collections/src/test/java/com/baeldung/convertcollectiontoarraylist/FooUnitTest.java b/core-java-collections/src/test/java/com/baeldung/convertcollectiontoarraylist/FooUnitTest.java index fd07848383..5b46434a0b 100644 --- a/core-java-collections/src/test/java/com/baeldung/convertcollectiontoarraylist/FooUnitTest.java +++ b/core-java-collections/src/test/java/com/baeldung/convertcollectiontoarraylist/FooUnitTest.java @@ -39,7 +39,7 @@ public class FooUnitTest { * Section 3. Using the ArrayList Constructor */ @Test - public void testConstructor() { + public void whenUsingConstructor_thenVerifyShallowCopy() { ArrayList newList = new ArrayList<>(srcCollection); verifyShallowCopy(srcCollection, newList); } @@ -48,7 +48,7 @@ public class FooUnitTest { * Section 4. Using the Streams API */ @Test - public void testStream() { + public void whenUsingStream_thenVerifyShallowCopy() { ArrayList newList = srcCollection.stream().collect(toCollection(ArrayList::new)); verifyShallowCopy(srcCollection, newList); } @@ -57,7 +57,7 @@ public class FooUnitTest { * Section 5. Deep Copy */ @Test - public void testStreamDeepCopy() { + public void whenUsingDeepCopy_thenVerifyDeepCopy() { ArrayList newList = srcCollection.stream() .map(foo -> foo.deepCopy()) .collect(toCollection(ArrayList::new)); @@ -68,7 +68,7 @@ public class FooUnitTest { * Section 6. Controlling the List Order */ @Test - public void testSortOrder() { + public void whenUsingSortedStream_thenVerifySortOrder() { assertFalse("Oops: source collection is already sorted!", isSorted(srcCollection)); ArrayList newList = srcCollection.stream() .map(foo -> foo.deepCopy()) From 3c0bd8e6e8a5f6db610e65270eb4bcb0c1b8813f Mon Sep 17 00:00:00 2001 From: clininger Date: Mon, 8 Oct 2018 08:42:33 +0700 Subject: [PATCH 09/22] BAEL-2184 formatting --- .../com/baeldung/convertcollectiontoarraylist/Foo.java | 4 ++-- .../convertcollectiontoarraylist/FooUnitTest.java | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/core-java-collections/src/main/java/com/baeldung/convertcollectiontoarraylist/Foo.java b/core-java-collections/src/main/java/com/baeldung/convertcollectiontoarraylist/Foo.java index 3123295641..5c9464182e 100644 --- a/core-java-collections/src/main/java/com/baeldung/convertcollectiontoarraylist/Foo.java +++ b/core-java-collections/src/main/java/com/baeldung/convertcollectiontoarraylist/Foo.java @@ -45,8 +45,8 @@ public class Foo { } public Foo deepCopy() { - return new Foo(this.id, this.name, - this.parent != null ? this.parent.deepCopy() : null); + return new Foo( + this.id, this.name, this.parent != null ? this.parent.deepCopy() : null); } } diff --git a/core-java-collections/src/test/java/com/baeldung/convertcollectiontoarraylist/FooUnitTest.java b/core-java-collections/src/test/java/com/baeldung/convertcollectiontoarraylist/FooUnitTest.java index 5b46434a0b..2b5751ef9e 100644 --- a/core-java-collections/src/test/java/com/baeldung/convertcollectiontoarraylist/FooUnitTest.java +++ b/core-java-collections/src/test/java/com/baeldung/convertcollectiontoarraylist/FooUnitTest.java @@ -33,6 +33,9 @@ public class FooUnitTest { srcCollection.add(sam); srcCollection.add(alice); srcCollection.add(buffy); + + // make sure the collection isn't sorted accidentally + assertFalse("Oops: source collection is already sorted!", isSorted(srcCollection)); } /** @@ -50,6 +53,7 @@ public class FooUnitTest { @Test public void whenUsingStream_thenVerifyShallowCopy() { ArrayList newList = srcCollection.stream().collect(toCollection(ArrayList::new)); + verifyShallowCopy(srcCollection, newList); } @@ -61,6 +65,7 @@ public class FooUnitTest { ArrayList newList = srcCollection.stream() .map(foo -> foo.deepCopy()) .collect(toCollection(ArrayList::new)); + verifyDeepCopy(srcCollection, newList); } @@ -69,11 +74,11 @@ public class FooUnitTest { */ @Test public void whenUsingSortedStream_thenVerifySortOrder() { - assertFalse("Oops: source collection is already sorted!", isSorted(srcCollection)); ArrayList newList = srcCollection.stream() .map(foo -> foo.deepCopy()) .sorted(Comparator.comparing(Foo::getName)) .collect(toCollection(ArrayList::new)); + assertTrue("ArrayList is not sorted by name", isSorted(newList)); } @@ -130,7 +135,7 @@ public class FooUnitTest { * @param c collection of Foo * @return true if the collection is sorted by name */ - private boolean isSorted(Collection c) { + private static boolean isSorted(Collection c) { String prevName = null; for (Foo foo : c) { if (prevName == null || foo.getName().compareTo(prevName) > 0) { From 7538a4b534a22993e1f3e3eaa73fc55821bc6198 Mon Sep 17 00:00:00 2001 From: clininger Date: Tue, 9 Oct 2018 02:48:17 +0700 Subject: [PATCH 10/22] BAEL-2184 ignore netbeans project files --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 180462a32f..7fe2778755 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,5 @@ jmeter/src/main/resources/*-JMeter.csv **/dist **/tmp **/out-tsc +**/nbproject/ +**/nb-configuration.xml \ No newline at end of file From ee1b2cb40bd8158f8f5798d2a04efbd45afca225 Mon Sep 17 00:00:00 2001 From: clininger Date: Tue, 9 Oct 2018 21:20:09 +0700 Subject: [PATCH 11/22] BAEL-2184 sorted test not include deep copy --- .../com/baeldung/convertcollectiontoarraylist/FooUnitTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/core-java-collections/src/test/java/com/baeldung/convertcollectiontoarraylist/FooUnitTest.java b/core-java-collections/src/test/java/com/baeldung/convertcollectiontoarraylist/FooUnitTest.java index 2b5751ef9e..5be4121bc7 100644 --- a/core-java-collections/src/test/java/com/baeldung/convertcollectiontoarraylist/FooUnitTest.java +++ b/core-java-collections/src/test/java/com/baeldung/convertcollectiontoarraylist/FooUnitTest.java @@ -75,7 +75,6 @@ public class FooUnitTest { @Test public void whenUsingSortedStream_thenVerifySortOrder() { ArrayList newList = srcCollection.stream() - .map(foo -> foo.deepCopy()) .sorted(Comparator.comparing(Foo::getName)) .collect(toCollection(ArrayList::new)); From e5be99d3281421c6199178b32bf50ee0a7d95915 Mon Sep 17 00:00:00 2001 From: Nikhil Khatwani Date: Tue, 9 Oct 2018 23:16:56 +0530 Subject: [PATCH 12/22] Changes for BAEL-2288 --- .../java/com/baeldung/classloader/CustomClassLoader.java | 9 ++++++--- .../baeldung/classloader/CustomClassLoaderUnitTest.java | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core-java/src/main/java/com/baeldung/classloader/CustomClassLoader.java b/core-java/src/main/java/com/baeldung/classloader/CustomClassLoader.java index c44e863776..532adce1ab 100644 --- a/core-java/src/main/java/com/baeldung/classloader/CustomClassLoader.java +++ b/core-java/src/main/java/com/baeldung/classloader/CustomClassLoader.java @@ -1,11 +1,14 @@ package com.baeldung.classloader; -import java.io.*; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; public class CustomClassLoader extends ClassLoader { - - public Class getClass(String name) throws ClassNotFoundException { + @Override + public Class findClass(String name) throws ClassNotFoundException { byte[] b = loadClassFromFile(name); return defineClass(name, b, 0, b.length); } diff --git a/core-java/src/test/java/com/baeldung/classloader/CustomClassLoaderUnitTest.java b/core-java/src/test/java/com/baeldung/classloader/CustomClassLoaderUnitTest.java index ec35885b84..cabf9f7bdb 100644 --- a/core-java/src/test/java/com/baeldung/classloader/CustomClassLoaderUnitTest.java +++ b/core-java/src/test/java/com/baeldung/classloader/CustomClassLoaderUnitTest.java @@ -11,7 +11,7 @@ public class CustomClassLoaderUnitTest { public void customLoader() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException { CustomClassLoader customClassLoader = new CustomClassLoader(); - Class c = customClassLoader.getClass(PrintClassLoader.class.getName()); + Class c = customClassLoader.findClass(PrintClassLoader.class.getName()); Object ob = c.newInstance(); From a0d084751ac81d409d744b8b1d0513219615dc55 Mon Sep 17 00:00:00 2001 From: Nikhil Khatwani Date: Tue, 9 Oct 2018 23:47:04 +0530 Subject: [PATCH 13/22] Changes for BAEL-2243 --- .../java/com/baeldung/hibernate/pojo/User.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/hibernate5/src/main/java/com/baeldung/hibernate/pojo/User.java b/hibernate5/src/main/java/com/baeldung/hibernate/pojo/User.java index 90203d29ec..16430570c4 100644 --- a/hibernate5/src/main/java/com/baeldung/hibernate/pojo/User.java +++ b/hibernate5/src/main/java/com/baeldung/hibernate/pojo/User.java @@ -4,13 +4,23 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; -import javax.persistence.SequenceGenerator; + +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Parameter; @Entity public class User { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequence-generator") - @SequenceGenerator(name = "sequence-generator", sequenceName = "user_sequence", initialValue = 4) + @GenericGenerator( + name = "genericGenerator", + strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator", + parameters = { + @Parameter(name = "sequence_name", value = "user_sequence"), + @Parameter(name = "initial_value", value = "4"), + @Parameter(name = "increment_size", value = "1") + } + ) private long userId; public long getUserId() { From 6612e5d99cb0edc7f86728b40d08643c7f36166d Mon Sep 17 00:00:00 2001 From: Nikhil Khatwani Date: Tue, 9 Oct 2018 23:48:39 +0530 Subject: [PATCH 14/22] Changes for BAEL-2243 --- .../src/main/java/com/baeldung/hibernate/pojo/User.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hibernate5/src/main/java/com/baeldung/hibernate/pojo/User.java b/hibernate5/src/main/java/com/baeldung/hibernate/pojo/User.java index 16430570c4..ccbdf80bf1 100644 --- a/hibernate5/src/main/java/com/baeldung/hibernate/pojo/User.java +++ b/hibernate5/src/main/java/com/baeldung/hibernate/pojo/User.java @@ -11,9 +11,9 @@ import org.hibernate.annotations.Parameter; @Entity public class User { @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequence-generator") + @GeneratedValue(generator = "sequence-generator") @GenericGenerator( - name = "genericGenerator", + name = "sequence-generator", strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator", parameters = { @Parameter(name = "sequence_name", value = "user_sequence"), From 50c281d9be4d660642657c39d6547dcb5d1d1747 Mon Sep 17 00:00:00 2001 From: Andrea Ligios Date: Tue, 9 Oct 2018 20:47:03 +0200 Subject: [PATCH 15/22] Using Maven Versions Plugin Issue: BAEL-2191 --- maven/versions-maven-plugin/original/pom.xml | 76 ++++++++++++++++++++ maven/versions-maven-plugin/pom.xml | 76 ++++++++++++++++++++ maven/versions-maven-plugin/run-the-demo.sh | 74 +++++++++++++++++++ 3 files changed, 226 insertions(+) create mode 100644 maven/versions-maven-plugin/original/pom.xml create mode 100644 maven/versions-maven-plugin/pom.xml create mode 100755 maven/versions-maven-plugin/run-the-demo.sh diff --git a/maven/versions-maven-plugin/original/pom.xml b/maven/versions-maven-plugin/original/pom.xml new file mode 100644 index 0000000000..295c77b860 --- /dev/null +++ b/maven/versions-maven-plugin/original/pom.xml @@ -0,0 +1,76 @@ + + 4.0.0 + com.baeldung + versions-maven-plugin-example + 0.0.1-SNAPSHOT + + + 1.15 + + + + + + commons-io + commons-io + 2.3 + + + + org.apache.commons + commons-collections4 + 4.0 + + + + org.apache.commons + commons-lang3 + 3.0 + + + + org.apache.commons + commons-compress + ${commons-compress-version} + + + + commons-beanutils + commons-beanutils + 1.9.1-SNAPSHOT + + + + + + + + org.codehaus.mojo + versions-maven-plugin + 2.7 + + + org.apache.commons:commons-collections4 + + + + + + + + + apache.snapshots + Apache Development Snapshot Repository + https://repository.apache.org/content/repositories/snapshots/ + + false + + + true + + + + + \ No newline at end of file diff --git a/maven/versions-maven-plugin/pom.xml b/maven/versions-maven-plugin/pom.xml new file mode 100644 index 0000000000..295c77b860 --- /dev/null +++ b/maven/versions-maven-plugin/pom.xml @@ -0,0 +1,76 @@ + + 4.0.0 + com.baeldung + versions-maven-plugin-example + 0.0.1-SNAPSHOT + + + 1.15 + + + + + + commons-io + commons-io + 2.3 + + + + org.apache.commons + commons-collections4 + 4.0 + + + + org.apache.commons + commons-lang3 + 3.0 + + + + org.apache.commons + commons-compress + ${commons-compress-version} + + + + commons-beanutils + commons-beanutils + 1.9.1-SNAPSHOT + + + + + + + + org.codehaus.mojo + versions-maven-plugin + 2.7 + + + org.apache.commons:commons-collections4 + + + + + + + + + apache.snapshots + Apache Development Snapshot Repository + https://repository.apache.org/content/repositories/snapshots/ + + false + + + true + + + + + \ No newline at end of file diff --git a/maven/versions-maven-plugin/run-the-demo.sh b/maven/versions-maven-plugin/run-the-demo.sh new file mode 100755 index 0000000000..89ca871e01 --- /dev/null +++ b/maven/versions-maven-plugin/run-the-demo.sh @@ -0,0 +1,74 @@ +#!/bin/bash +#function to display commands +exe() { echo -e "\$ $@\n" ; "$@" ; } + +TEXT_COLOR='\033[1;33m' #Yellow +NO_COLOR='\033[0m' # No Color + +clear + +echo -e "======================================================================================" +echo -e " Showcase for the BAELDUNG tutorial \"Use the latest version of a dependency in Maven\"" +echo -e " Author: Andrea Ligios" +echo -e "======================================================================================" + +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " Resetting the demo environment (which will be altered during the run): " +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +rm -f pom.xml.versionsBackup +cp original/pom.xml pom.xml +ls -lt pom.* +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " Checking for newer versions of the Maven dependencies:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +exe mvn versions:display-dependency-updates +echo +read -p "Press enter to continue" + +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " Updating SNAPSHOT dependencies to their RELEASE version, if any:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +exe mvn versions:use-releases +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " A backup has been created automatically:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +ls -lt pom.* +echo +read -p "Press enter to continue" + +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " Updating RELEASE dependencies to their *next* RELEASE version:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +exe mvn versions:use-next-releases +echo +read -p "Press enter to continue" + +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " Reverting every modification made since the beginning:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +exe mvn versions:revert +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " The backup is gone, and the pom.xml contains the initial dependencies:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +ls -lt pom.* +echo +read -p "Press enter to continue" + +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " Updating RELEASE dependencies to their *latest* RELEASE version:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +exe mvn versions:use-latest-releases +echo +read -p "Press enter to continue" + +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " Committing the modifications to pom.xml:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +exe mvn versions:commit +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " The backup is gone, and the pom.xml contains the latest dependencies:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +ls -lt pom.* +echo + +echo -e "${TEXT_COLOR}\nThat's all folks!${NO_COLOR}\n" From 1931f571d11946f2990681825631eafacd2a260f Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Tue, 9 Oct 2018 22:21:36 +0300 Subject: [PATCH 16/22] fixing test name --- .../com/baeldung/java/map/KeyCheckTest.java | 44 ------------------- .../baeldung/java/map/KeyCheckUnitTest.java | 29 ++++++++++++ 2 files changed, 29 insertions(+), 44 deletions(-) delete mode 100644 core-java-collections/src/test/java/com/baeldung/java/map/KeyCheckTest.java create mode 100644 core-java-collections/src/test/java/com/baeldung/java/map/KeyCheckUnitTest.java diff --git a/core-java-collections/src/test/java/com/baeldung/java/map/KeyCheckTest.java b/core-java-collections/src/test/java/com/baeldung/java/map/KeyCheckTest.java deleted file mode 100644 index 024b2973d2..0000000000 --- a/core-java-collections/src/test/java/com/baeldung/java/map/KeyCheckTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.baeldung.java.map; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -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 com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.LinkedHashMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.TreeMultimap; - - -public class KeyCheckTest { - - @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-collections/src/test/java/com/baeldung/java/map/KeyCheckUnitTest.java b/core-java-collections/src/test/java/com/baeldung/java/map/KeyCheckUnitTest.java new file mode 100644 index 0000000000..2c97a97690 --- /dev/null +++ b/core-java-collections/src/test/java/com/baeldung/java/map/KeyCheckUnitTest.java @@ -0,0 +1,29 @@ +package com.baeldung.java.map; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import java.util.Collections; +import java.util.Map; + +import org.junit.Test; + +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 From 51ef1d3ae9350e9dc8ef533a0f396423f4153d03 Mon Sep 17 00:00:00 2001 From: eric-martin Date: Tue, 9 Oct 2018 20:34:58 -0500 Subject: [PATCH 17/22] BAEL-2258: Moved to java-dates --- .../java/com/baeldung/datetime}/DateTimeFormatterUnitTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {core-java-8/src/test/java/com/baeldung/internationalization => java-dates/src/test/java/com/baeldung/datetime}/DateTimeFormatterUnitTest.java (99%) diff --git a/core-java-8/src/test/java/com/baeldung/internationalization/DateTimeFormatterUnitTest.java b/java-dates/src/test/java/com/baeldung/datetime/DateTimeFormatterUnitTest.java similarity index 99% rename from core-java-8/src/test/java/com/baeldung/internationalization/DateTimeFormatterUnitTest.java rename to java-dates/src/test/java/com/baeldung/datetime/DateTimeFormatterUnitTest.java index 36a5f6210b..f3b2b11893 100644 --- a/core-java-8/src/test/java/com/baeldung/internationalization/DateTimeFormatterUnitTest.java +++ b/java-dates/src/test/java/com/baeldung/datetime/DateTimeFormatterUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.internationalization; +package com.baeldung.datetime; import org.junit.Assert; import org.junit.Test; From 53d22bebbc24b17fd5da8f2a294f813af3003eda Mon Sep 17 00:00:00 2001 From: Alejandro Gervasio Date: Wed, 10 Oct 2018 00:20:23 -0300 Subject: [PATCH 18/22] BAEL-2287 - An Introduction to Synchronized Java Collections (#5385) * Initial Commit * Add pom.xml * Update pom.xml * Update pom.xml * Update SynchronizedSortedMapUnitTest.java --- core-java-collections/pom.xml | 173 +++++++++--------- .../application/Application.java | 18 ++ .../test/SynchronizedCollectionUnitTest.java | 28 +++ .../test/SynchronizedListUnitTest.java | 51 ++++++ .../test/SynchronizedMapUnitTest.java | 30 +++ .../test/SynchronizedSetUnitTest.java | 26 +++ .../test/SynchronizedSortedMapUnitTest.java | 29 +++ .../test/SynchronizedSortedSetUnitTest.java | 28 +++ 8 files changed, 293 insertions(+), 90 deletions(-) create mode 100644 core-java-collections/src/main/java/com/baeldung/synchronizedcollections/application/Application.java create mode 100644 core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedCollectionUnitTest.java create mode 100644 core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedListUnitTest.java create mode 100644 core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedMapUnitTest.java create mode 100644 core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSetUnitTest.java create mode 100644 core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedMapUnitTest.java create mode 100644 core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedSetUnitTest.java diff --git a/core-java-collections/pom.xml b/core-java-collections/pom.xml index 06b79fff22..694d2da5eb 100644 --- a/core-java-collections/pom.xml +++ b/core-java-collections/pom.xml @@ -1,90 +1,83 @@ - - 4.0.0 - com.baeldung - core-java-collections - 0.1.0-SNAPSHOT - jar - core-java-collections - - - com.baeldung - parent-java - 0.0.1-SNAPSHOT - ../parent-java - - - - - net.sourceforge.collections - collections-generic - ${collections-generic.version} - - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - - - com.jayway.awaitility - awaitility - ${avaitility.version} - test - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - org.eclipse.collections - eclipse-collections - ${eclipse.collections.version} - - - org.assertj - assertj-core - ${assertj.version} - test - - - org.junit.platform - junit-platform-runner - ${junit.platform.version} - test - - - org.openjdk.jmh - jmh-core - ${openjdk.jmh.version} - - - org.openjdk.jmh - jmh-generator-annprocess - ${openjdk.jmh.version} - - - org.apache.commons - commons-exec - 1.3 - - - one.util - streamex - 0.6.5 - - - - - - - 1.19 - 1.2.0 - 3.5 - 4.1 - 4.01 - 1.7.0 - 3.6.1 - 7.1.0 - - + + 4.0.0 + com.baeldung + core-java-collections + 0.1.0-SNAPSHOT + jar + core-java-collections + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + + + + net.sourceforge.collections + collections-generic + ${collections-generic.version} + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + com.jayway.awaitility + awaitility + ${avaitility.version} + test + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + org.eclipse.collections + eclipse-collections + ${eclipse.collections.version} + + + org.assertj + assertj-core + ${assertj.version} + test + + + org.junit.platform + junit-platform-runner + ${junit.platform.version} + test + + + org.openjdk.jmh + jmh-core + ${openjdk.jmh.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${openjdk.jmh.version} + + + org.apache.commons + commons-exec + 1.3 + + + + + 1.19 + 1.2.0 + 3.5 + 4.1 + 4.01 + 1.7.0 + 3.6.1 + 7.1.0 + + diff --git a/core-java-collections/src/main/java/com/baeldung/synchronizedcollections/application/Application.java b/core-java-collections/src/main/java/com/baeldung/synchronizedcollections/application/Application.java new file mode 100644 index 0000000000..1840c125d0 --- /dev/null +++ b/core-java-collections/src/main/java/com/baeldung/synchronizedcollections/application/Application.java @@ -0,0 +1,18 @@ +package com.baeldung.synchronizedcollections.application; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.logging.Logger; + +public class Application { + + private static final Logger LOGGER = Logger.getLogger(Application.class.getName()); + + public static void main(String[] args) throws InterruptedException { + List syncCollection = Collections.synchronizedList(Arrays.asList(1, 2, 3, 4, 5, 6)); + synchronized (syncCollection) { + syncCollection.forEach((e) -> {LOGGER.info(e.toString());}); + } + } +} diff --git a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedCollectionUnitTest.java b/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedCollectionUnitTest.java new file mode 100644 index 0000000000..84feeb6eaa --- /dev/null +++ b/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedCollectionUnitTest.java @@ -0,0 +1,28 @@ +package com.baeldung.synchronizedcollections.test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; + +public class SynchronizedCollectionUnitTest { + + @Test + public void givenSynchronizedCollection_whenTwoThreadsAddElements_thenCorrectCollectionSize() throws InterruptedException { + Collection syncCollection = Collections.synchronizedCollection(new ArrayList<>()); + + Runnable listOperations = () -> { + syncCollection.addAll(Arrays.asList(1, 2, 3, 4, 5, 6)); + }; + Thread thread1 = new Thread(listOperations); + Thread thread2 = new Thread(listOperations); + thread1.start(); + thread2.start(); + thread1.join(); + thread2.join(); + + assertThat(syncCollection.size()).isEqualTo(12); + } +} diff --git a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedListUnitTest.java b/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedListUnitTest.java new file mode 100644 index 0000000000..68fc3becd4 --- /dev/null +++ b/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedListUnitTest.java @@ -0,0 +1,51 @@ +package com.baeldung.synchronizedcollections.test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.junit.Test; +import static org.assertj.core.api.Assertions.*; + +public class SynchronizedListUnitTest { + + @Test + public void givenSynchronizedList_whenTwoThreadsAddElements_thenCorrectListSize() throws InterruptedException { + List syncList = Collections.synchronizedList(new ArrayList<>()); + + Runnable listOperations = () -> { + syncList.addAll(Arrays.asList(1, 2, 3, 4, 5, 6)); + }; + Thread thread1 = new Thread(listOperations); + Thread thread2 = new Thread(listOperations); + thread1.start(); + thread2.start(); + thread1.join(); + thread2.join(); + + assertThat(syncList.size()).isEqualTo(12); + } + + @Test + public void givenStringList_whenTwoThreadsIterateOnSynchronizedList_thenCorrectResult() throws InterruptedException { + List syncCollection = Collections.synchronizedList(Arrays.asList("a", "b", "c")); + List uppercasedCollection = new ArrayList<>(); + + Runnable listOperations = () -> { + synchronized (syncCollection) { + syncCollection.forEach((e) -> { + uppercasedCollection.add(e.toUpperCase()); + }); + } + }; + + Thread thread1 = new Thread(listOperations); + Thread thread2 = new Thread(listOperations); + thread1.start(); + thread2.start(); + thread1.join(); + thread2.join(); + + assertThat(uppercasedCollection.get(0)).isEqualTo("A"); + } +} diff --git a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedMapUnitTest.java b/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedMapUnitTest.java new file mode 100644 index 0000000000..abfb866e9c --- /dev/null +++ b/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedMapUnitTest.java @@ -0,0 +1,30 @@ +package com.baeldung.synchronizedcollections.test; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import org.junit.Test; +import static org.assertj.core.api.Assertions.*; + +public class SynchronizedMapUnitTest { + + @Test + public void givenSynchronizedMap_whenTwoThreadsAddElements_thenCorrectMapSize() throws InterruptedException { + Map syncMap = Collections.synchronizedMap(new HashMap<>()); + + Runnable mapOperations = () -> { + syncMap.put(1, "one"); + syncMap.put(2, "two"); + syncMap.put(3, "three"); + + }; + Thread thread1 = new Thread(mapOperations); + Thread thread2 = new Thread(mapOperations); + thread1.start(); + thread2.start(); + thread1.join(); + thread2.join(); + + assertThat(syncMap.size()).isEqualTo(3); + } +} diff --git a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSetUnitTest.java b/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSetUnitTest.java new file mode 100644 index 0000000000..58a33b207d --- /dev/null +++ b/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSetUnitTest.java @@ -0,0 +1,26 @@ +package com.baeldung.synchronizedcollections.test; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import org.junit.Test; +import static org.assertj.core.api.Assertions.*; + +public class SynchronizedSetUnitTest { + + @Test + public void givenSynchronizedSet_whenTwoThreadsAddElements_thenCorrectSetSize() throws InterruptedException { + Set syncSet = Collections.synchronizedSet(new HashSet<>()); + + Runnable setOperations = () -> {syncSet.addAll(Arrays.asList(1, 2, 3, 4, 5, 6));}; + Thread thread1 = new Thread(setOperations); + Thread thread2 = new Thread(setOperations); + thread1.start(); + thread2.start(); + thread1.join(); + thread2.join(); + + assertThat(syncSet.size()).isEqualTo(6); + } +} diff --git a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedMapUnitTest.java b/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedMapUnitTest.java new file mode 100644 index 0000000000..4b0ed6d8c8 --- /dev/null +++ b/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedMapUnitTest.java @@ -0,0 +1,29 @@ +package com.baeldung.synchronizedcollections.test; + +import java.util.Collections; +import java.util.Map; +import java.util.TreeMap; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; + +public class SynchronizedSortedMapUnitTest { + + @Test + public void givenSynchronizedSorteMap_whenTwoThreadsAddElements_thenCorrectSortedMapSize() throws InterruptedException { + Map syncSortedMap = Collections.synchronizedSortedMap(new TreeMap<>()); + + Runnable sortedMapOperations = () -> { + syncSortedMap.put(1, "One"); + syncSortedMap.put(2, "Two"); + syncSortedMap.put(3, "Three"); + }; + Thread thread1 = new Thread(sortedMapOperations); + Thread thread2 = new Thread(sortedMapOperations); + thread1.start(); + thread2.start(); + thread1.join(); + thread2.join(); + + assertThat(syncSortedMap.size()).isEqualTo(3); + } +} diff --git a/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedSetUnitTest.java b/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedSetUnitTest.java new file mode 100644 index 0000000000..0e26c6eb1c --- /dev/null +++ b/core-java-collections/src/test/java/com/baeldung/synchronizedcollections/test/SynchronizedSortedSetUnitTest.java @@ -0,0 +1,28 @@ +package com.baeldung.synchronizedcollections.test; + +import java.util.Arrays; +import java.util.Collections; +import java.util.SortedSet; +import java.util.TreeSet; +import static org.assertj.core.api.Assertions.assertThat; +import org.junit.Test; + +public class SynchronizedSortedSetUnitTest { + + @Test + public void givenSynchronizedSortedSet_whenTwoThreadsAddElements_thenCorrectSortedSetSize() throws InterruptedException { + SortedSet syncSortedSet = Collections.synchronizedSortedSet(new TreeSet<>()); + + Runnable sortedSetOperations = () -> {syncSortedSet.addAll(Arrays.asList(1, 2, 3, 4, 5, 6));}; + sortedSetOperations.run(); + sortedSetOperations.run(); + Thread thread1 = new Thread(sortedSetOperations); + Thread thread2 = new Thread(sortedSetOperations); + thread1.start(); + thread2.start(); + thread1.join(); + thread2.join(); + + assertThat(syncSortedSet.size()).isEqualTo(6); + } +} From cf628344b6a67244a77b307c9dfac543016cb5f4 Mon Sep 17 00:00:00 2001 From: j-bennett Date: Tue, 9 Oct 2018 23:21:58 -0400 Subject: [PATCH 19/22] BAEL-2222: Format ZonedDateTime to String --- java-dates/pom.xml | 4 +- .../zoneddatetime/ZonedDateTimeUnitTest.java | 43 +++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 java-dates/src/test/java/com/baeldung/zoneddatetime/ZonedDateTimeUnitTest.java diff --git a/java-dates/pom.xml b/java-dates/pom.xml index 13e2a077e1..2618fad1d4 100644 --- a/java-dates/pom.xml +++ b/java-dates/pom.xml @@ -80,7 +80,7 @@ 2.10 3.6.1 - 9 - 9 + 1.9 + 1.9 diff --git a/java-dates/src/test/java/com/baeldung/zoneddatetime/ZonedDateTimeUnitTest.java b/java-dates/src/test/java/com/baeldung/zoneddatetime/ZonedDateTimeUnitTest.java new file mode 100644 index 0000000000..355fef35c6 --- /dev/null +++ b/java-dates/src/test/java/com/baeldung/zoneddatetime/ZonedDateTimeUnitTest.java @@ -0,0 +1,43 @@ +package com.baeldung.zoneddatetime; + +import java.time.LocalDateTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.util.logging.Logger; + +import org.junit.Test; + +public class ZonedDateTimeUnitTest { + + private static final Logger log = Logger.getLogger(ZonedDateTimeUnitTest.class.getName()); + + @Test + public void testZonedDateTimeToString() { + + ZonedDateTime zonedDateTimeNow = ZonedDateTime.now(ZoneId.of("UTC")); + ZonedDateTime zonedDateTimeOf = ZonedDateTime.of(2018, 01, 01, 0, 0, 0, 0, ZoneId.of("UTC")); + + LocalDateTime localDateTime = LocalDateTime.now(); + ZonedDateTime zonedDateTime = ZonedDateTime.of(localDateTime, ZoneId.of("UTC")); + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy - hh:mm:ss Z"); + String formattedString = zonedDateTime.format(formatter); + + DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("MM/dd/yyyy - hh:mm:ss z"); + String formattedString2 = zonedDateTime.format(formatter2); + + log.info(formattedString); + log.info(formattedString2); + + } + + @Test + public void testZonedDateTimeFromString() { + + ZonedDateTime zonedDateTime = ZonedDateTime.parse("2011-12-03T10:15:30+01:00", DateTimeFormatter.ISO_ZONED_DATE_TIME); + + log.info(zonedDateTime.format(DateTimeFormatter.ISO_ZONED_DATE_TIME)); + } + +} From 50ffa8118657386e61de03a7642033514db83cac Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 10 Oct 2018 20:04:51 +0300 Subject: [PATCH 20/22] add reactor core --- spring-data-mongodb/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spring-data-mongodb/pom.xml b/spring-data-mongodb/pom.xml index ad70d987bb..072ed7a2ac 100644 --- a/spring-data-mongodb/pom.xml +++ b/spring-data-mongodb/pom.xml @@ -34,6 +34,12 @@ ${mongodb-reactivestreams.version} + + io.projectreactor + reactor-core + ${projectreactor.version} + + io.projectreactor reactor-test @@ -109,6 +115,7 @@ 5.1.0.RELEASE 1.9.2 3.2.0.RELEASE + From 5ab63bb07b4fbbdd04932097f35d506590ec07aa Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 10 Oct 2018 20:16:49 +0300 Subject: [PATCH 21/22] fix javax el --- javaxval/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/javaxval/pom.xml b/javaxval/pom.xml index 86a7e6955b..0263fb68af 100644 --- a/javaxval/pom.xml +++ b/javaxval/pom.xml @@ -33,7 +33,7 @@ ${javax.el-api.version} - org.glassfish.web + org.glassfish javax.el ${javax.el.version} From 12b1a90a746a341834d831770ad905942ac1e9b8 Mon Sep 17 00:00:00 2001 From: Eugen Paraschiv Date: Wed, 10 Oct 2018 20:24:43 +0300 Subject: [PATCH 22/22] rebalancing the first and second default profiles --- pom.xml | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/pom.xml b/pom.xml index 008d0aeac3..e6618da0a2 100644 --- a/pom.xml +++ b/pom.xml @@ -526,31 +526,6 @@ spring-resttemplate - spring-security-acl - spring-security-cache-control - spring-security-client/spring-security-jsp-authentication - spring-security-client/spring-security-jsp-authorize - spring-security-client/spring-security-jsp-config - spring-security-client/spring-security-mvc - spring-security-client/spring-security-thymeleaf-authentication - spring-security-client/spring-security-thymeleaf-authorize - spring-security-client/spring-security-thymeleaf-config - spring-security-core - spring-security-mvc-boot - spring-security-mvc-custom - spring-security-mvc-digest-auth - spring-security-mvc-ldap - spring-security-mvc-login - spring-security-mvc-persisted-remember-me - spring-security-mvc-session - spring-security-mvc-socket - spring-security-openid - - spring-security-rest-basic-auth - spring-security-rest-custom - spring-security-rest - spring-security-sso - spring-security-x509 @@ -719,7 +694,33 @@ - flyway-cdi-extension + flyway-cdi-extension + + spring-security-acl + spring-security-cache-control + spring-security-client/spring-security-jsp-authentication + spring-security-client/spring-security-jsp-authorize + spring-security-client/spring-security-jsp-config + spring-security-client/spring-security-mvc + spring-security-client/spring-security-thymeleaf-authentication + spring-security-client/spring-security-thymeleaf-authorize + spring-security-client/spring-security-thymeleaf-config + spring-security-core + spring-security-mvc-boot + spring-security-mvc-custom + spring-security-mvc-digest-auth + spring-security-mvc-ldap + spring-security-mvc-login + spring-security-mvc-persisted-remember-me + spring-security-mvc-session + spring-security-mvc-socket + spring-security-openid + + spring-security-rest-basic-auth + spring-security-rest-custom + spring-security-rest + spring-security-sso + spring-security-x509