From ab784af235a2dc2ec9a8409ff9cc09c111c4ef6b Mon Sep 17 00:00:00 2001 From: mikr Date: Sat, 29 Feb 2020 16:12:08 +0100 Subject: [PATCH 01/73] JAVA-841 Standardize package in spring-security-modules-mvc-boot-2 module --- .../spring-security-mvc-boot-2/pom.xml | 11 +++++------ .../h2/H2JdbcAuthenticationApplication.java | 2 +- .../h2/config/SecurityConfiguration.java | 2 +- .../jdbcauthentication/h2/web/UserController.java | 2 +- .../mysql/MySqlJdbcAuthenticationApplication.java | 2 +- .../mysql/config/SecurityConfiguration.java | 2 +- .../jdbcauthentication/mysql/web/UserController.java | 2 +- .../postgre/PostgreJdbcAuthenticationApplication.java | 2 +- .../postgre/config/SecurityConfiguration.java | 2 +- .../postgre/web/UserController.java | 2 +- .../CustomAuthenticationProvider.java | 2 +- .../multipleauthproviders/MultipleAuthController.java | 2 +- .../MultipleAuthProvidersApplication.java | 2 +- .../MultipleAuthProvidersSecurityConfig.java | 2 +- .../MultipleEntryPointsApplication.java | 2 +- .../MultipleEntryPointsSecurityConfig.java | 2 +- .../baeldung/multipleentrypoints/PagesController.java | 2 +- .../multiplelogin/MultipleLoginApplication.java | 3 +-- .../multiplelogin/MultipleLoginMvcConfig.java | 4 +--- .../multiplelogin/MultipleLoginSecurityConfig.java | 2 +- .../baeldung/multiplelogin/UsersController.java | 2 +- .../baeldung/ssl/HttpsEnabledApplication.java | 2 +- .../{org => com}/baeldung/ssl/SecurityConfig.java | 2 +- .../{org => com}/baeldung/ssl/WelcomeController.java | 3 +-- .../jdbcauthentication/h2/SpringContextTest.java | 3 +-- .../h2/web/UserControllerLiveTest.java | 2 +- .../mysql/web/UserControllerLiveTest.java | 2 +- .../postgre/web/UserControllerLiveTest.java | 2 +- .../baeldung/web/HttpsApplicationIntegrationTest.java | 4 ++-- ...ltipleAuthProvidersApplicationIntegrationTest.java | 4 ++-- .../web/MultipleEntryPointsIntegrationTest.java | 4 ++-- 31 files changed, 38 insertions(+), 44 deletions(-) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/jdbcauthentication/h2/H2JdbcAuthenticationApplication.java (92%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/jdbcauthentication/h2/config/SecurityConfiguration.java (97%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/jdbcauthentication/h2/web/UserController.java (89%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/jdbcauthentication/mysql/MySqlJdbcAuthenticationApplication.java (90%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/jdbcauthentication/mysql/config/SecurityConfiguration.java (95%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/jdbcauthentication/mysql/web/UserController.java (88%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/jdbcauthentication/postgre/PostgreJdbcAuthenticationApplication.java (90%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/jdbcauthentication/postgre/config/SecurityConfiguration.java (93%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/jdbcauthentication/postgre/web/UserController.java (88%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/multipleauthproviders/CustomAuthenticationProvider.java (96%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/multipleauthproviders/MultipleAuthController.java (85%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/multipleauthproviders/MultipleAuthProvidersApplication.java (92%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/multipleauthproviders/MultipleAuthProvidersSecurityConfig.java (97%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/multipleentrypoints/MultipleEntryPointsApplication.java (92%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/multipleentrypoints/MultipleEntryPointsSecurityConfig.java (99%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/multipleentrypoints/PagesController.java (96%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/multiplelogin/MultipleLoginApplication.java (85%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/multiplelogin/MultipleLoginMvcConfig.java (89%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/multiplelogin/MultipleLoginSecurityConfig.java (99%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/multiplelogin/UsersController.java (95%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/ssl/HttpsEnabledApplication.java (95%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/ssl/SecurityConfig.java (95%) rename spring-security-modules/spring-security-mvc-boot-2/src/main/java/{org => com}/baeldung/ssl/WelcomeController.java (74%) rename spring-security-modules/spring-security-mvc-boot-2/src/test/java/{org => com}/baeldung/jdbcauthentication/h2/SpringContextTest.java (76%) rename spring-security-modules/spring-security-mvc-boot-2/src/test/java/{org => com}/baeldung/jdbcauthentication/h2/web/UserControllerLiveTest.java (95%) rename spring-security-modules/spring-security-mvc-boot-2/src/test/java/{org => com}/baeldung/jdbcauthentication/mysql/web/UserControllerLiveTest.java (95%) rename spring-security-modules/spring-security-mvc-boot-2/src/test/java/{org => com}/baeldung/jdbcauthentication/postgre/web/UserControllerLiveTest.java (95%) rename spring-security-modules/spring-security-mvc-boot-2/src/test/java/{org => com}/baeldung/web/HttpsApplicationIntegrationTest.java (96%) rename spring-security-modules/spring-security-mvc-boot-2/src/test/java/{org => com}/baeldung/web/MultipleAuthProvidersApplicationIntegrationTest.java (96%) rename spring-security-modules/spring-security-mvc-boot-2/src/test/java/{org => com}/baeldung/web/MultipleEntryPointsIntegrationTest.java (96%) diff --git a/spring-security-modules/spring-security-mvc-boot-2/pom.xml b/spring-security-modules/spring-security-mvc-boot-2/pom.xml index fca38b9714..799b3acd96 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/pom.xml +++ b/spring-security-modules/spring-security-mvc-boot-2/pom.xml @@ -227,16 +227,15 @@ - org.baeldung.custom.Application - - + + + com.baeldung.multiplelogin.MultipleLoginApplication - + - + 1.1.2 1.6.1 diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/h2/H2JdbcAuthenticationApplication.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/h2/H2JdbcAuthenticationApplication.java similarity index 92% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/h2/H2JdbcAuthenticationApplication.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/h2/H2JdbcAuthenticationApplication.java index 6936cdc560..d71885d73c 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/h2/H2JdbcAuthenticationApplication.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/h2/H2JdbcAuthenticationApplication.java @@ -1,4 +1,4 @@ -package org.baeldung.jdbcauthentication.h2; +package com.baeldung.jdbcauthentication.h2; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/h2/config/SecurityConfiguration.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/h2/config/SecurityConfiguration.java similarity index 97% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/h2/config/SecurityConfiguration.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/h2/config/SecurityConfiguration.java index 8b8696f0b2..50dc5b6958 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/h2/config/SecurityConfiguration.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/h2/config/SecurityConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.jdbcauthentication.h2.config; +package com.baeldung.jdbcauthentication.h2.config; import javax.sql.DataSource; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/h2/web/UserController.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/h2/web/UserController.java similarity index 89% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/h2/web/UserController.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/h2/web/UserController.java index 0955061614..03271677a4 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/h2/web/UserController.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/h2/web/UserController.java @@ -1,4 +1,4 @@ -package org.baeldung.jdbcauthentication.h2.web; +package com.baeldung.jdbcauthentication.h2.web; import java.security.Principal; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/mysql/MySqlJdbcAuthenticationApplication.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/mysql/MySqlJdbcAuthenticationApplication.java similarity index 90% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/mysql/MySqlJdbcAuthenticationApplication.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/mysql/MySqlJdbcAuthenticationApplication.java index 52934e0096..1f4c54e512 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/mysql/MySqlJdbcAuthenticationApplication.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/mysql/MySqlJdbcAuthenticationApplication.java @@ -1,4 +1,4 @@ -package org.baeldung.jdbcauthentication.mysql; +package com.baeldung.jdbcauthentication.mysql; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/mysql/config/SecurityConfiguration.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/mysql/config/SecurityConfiguration.java similarity index 95% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/mysql/config/SecurityConfiguration.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/mysql/config/SecurityConfiguration.java index 157c0be748..a0584818cd 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/mysql/config/SecurityConfiguration.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/mysql/config/SecurityConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.jdbcauthentication.mysql.config; +package com.baeldung.jdbcauthentication.mysql.config; import javax.sql.DataSource; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/mysql/web/UserController.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/mysql/web/UserController.java similarity index 88% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/mysql/web/UserController.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/mysql/web/UserController.java index f1060b5f78..ed15f8bfe6 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/mysql/web/UserController.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/mysql/web/UserController.java @@ -1,4 +1,4 @@ -package org.baeldung.jdbcauthentication.mysql.web; +package com.baeldung.jdbcauthentication.mysql.web; import java.security.Principal; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/postgre/PostgreJdbcAuthenticationApplication.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/postgre/PostgreJdbcAuthenticationApplication.java similarity index 90% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/postgre/PostgreJdbcAuthenticationApplication.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/postgre/PostgreJdbcAuthenticationApplication.java index 2c4d1a5255..4b074ef51d 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/postgre/PostgreJdbcAuthenticationApplication.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/postgre/PostgreJdbcAuthenticationApplication.java @@ -1,4 +1,4 @@ -package org.baeldung.jdbcauthentication.postgre; +package com.baeldung.jdbcauthentication.postgre; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/postgre/config/SecurityConfiguration.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/postgre/config/SecurityConfiguration.java similarity index 93% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/postgre/config/SecurityConfiguration.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/postgre/config/SecurityConfiguration.java index ba79635852..85dc9d364c 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/postgre/config/SecurityConfiguration.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/postgre/config/SecurityConfiguration.java @@ -1,4 +1,4 @@ -package org.baeldung.jdbcauthentication.postgre.config; +package com.baeldung.jdbcauthentication.postgre.config; import javax.sql.DataSource; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/postgre/web/UserController.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/postgre/web/UserController.java similarity index 88% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/postgre/web/UserController.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/postgre/web/UserController.java index c8fd3812b1..da85a46562 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/jdbcauthentication/postgre/web/UserController.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/jdbcauthentication/postgre/web/UserController.java @@ -1,4 +1,4 @@ -package org.baeldung.jdbcauthentication.postgre.web; +package com.baeldung.jdbcauthentication.postgre.web; import java.security.Principal; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleauthproviders/CustomAuthenticationProvider.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleauthproviders/CustomAuthenticationProvider.java similarity index 96% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleauthproviders/CustomAuthenticationProvider.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleauthproviders/CustomAuthenticationProvider.java index 1a89c362cd..97a8d8ac2a 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleauthproviders/CustomAuthenticationProvider.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleauthproviders/CustomAuthenticationProvider.java @@ -1,4 +1,4 @@ -package org.baeldung.multipleauthproviders; +package com.baeldung.multipleauthproviders; import java.util.Collections; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleauthproviders/MultipleAuthController.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleauthproviders/MultipleAuthController.java similarity index 85% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleauthproviders/MultipleAuthController.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleauthproviders/MultipleAuthController.java index b63169bb00..0079c84c6c 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleauthproviders/MultipleAuthController.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleauthproviders/MultipleAuthController.java @@ -1,4 +1,4 @@ -package org.baeldung.multipleauthproviders; +package com.baeldung.multipleauthproviders; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleauthproviders/MultipleAuthProvidersApplication.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleauthproviders/MultipleAuthProvidersApplication.java similarity index 92% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleauthproviders/MultipleAuthProvidersApplication.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleauthproviders/MultipleAuthProvidersApplication.java index 1f641298c3..e1a437e9a9 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleauthproviders/MultipleAuthProvidersApplication.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleauthproviders/MultipleAuthProvidersApplication.java @@ -1,4 +1,4 @@ -package org.baeldung.multipleauthproviders; +package com.baeldung.multipleauthproviders; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleauthproviders/MultipleAuthProvidersSecurityConfig.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleauthproviders/MultipleAuthProvidersSecurityConfig.java similarity index 97% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleauthproviders/MultipleAuthProvidersSecurityConfig.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleauthproviders/MultipleAuthProvidersSecurityConfig.java index 3819e981a2..aa2ffc9046 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleauthproviders/MultipleAuthProvidersSecurityConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleauthproviders/MultipleAuthProvidersSecurityConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.multipleauthproviders; +package com.baeldung.multipleauthproviders; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleentrypoints/MultipleEntryPointsApplication.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleentrypoints/MultipleEntryPointsApplication.java similarity index 92% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleentrypoints/MultipleEntryPointsApplication.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleentrypoints/MultipleEntryPointsApplication.java index 847dab073e..4ed36f770f 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleentrypoints/MultipleEntryPointsApplication.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleentrypoints/MultipleEntryPointsApplication.java @@ -1,4 +1,4 @@ -package org.baeldung.multipleentrypoints; +package com.baeldung.multipleentrypoints; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleentrypoints/MultipleEntryPointsSecurityConfig.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleentrypoints/MultipleEntryPointsSecurityConfig.java similarity index 99% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleentrypoints/MultipleEntryPointsSecurityConfig.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleentrypoints/MultipleEntryPointsSecurityConfig.java index dc89c83cde..b6155fc100 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleentrypoints/MultipleEntryPointsSecurityConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleentrypoints/MultipleEntryPointsSecurityConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.multipleentrypoints; +package com.baeldung.multipleentrypoints; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleentrypoints/PagesController.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleentrypoints/PagesController.java similarity index 96% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleentrypoints/PagesController.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleentrypoints/PagesController.java index b3462d4061..ba5028aea7 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multipleentrypoints/PagesController.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multipleentrypoints/PagesController.java @@ -1,4 +1,4 @@ -package org.baeldung.multipleentrypoints; +package com.baeldung.multipleentrypoints; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multiplelogin/MultipleLoginApplication.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multiplelogin/MultipleLoginApplication.java similarity index 85% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multiplelogin/MultipleLoginApplication.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multiplelogin/MultipleLoginApplication.java index 90bb5e4260..abba2ba339 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multiplelogin/MultipleLoginApplication.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multiplelogin/MultipleLoginApplication.java @@ -1,4 +1,4 @@ -package org.baeldung.multiplelogin; +package com.baeldung.multiplelogin; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -7,7 +7,6 @@ import org.springframework.context.annotation.PropertySource; @SpringBootApplication @PropertySource("classpath:application-defaults.properties") -@ComponentScan("org.baeldung.multiplelogin") public class MultipleLoginApplication { public static void main(String[] args) { SpringApplication.run(MultipleLoginApplication.class, args); diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multiplelogin/MultipleLoginMvcConfig.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multiplelogin/MultipleLoginMvcConfig.java similarity index 89% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multiplelogin/MultipleLoginMvcConfig.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multiplelogin/MultipleLoginMvcConfig.java index 204b186411..86b3314c7c 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multiplelogin/MultipleLoginMvcConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multiplelogin/MultipleLoginMvcConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.multiplelogin; +package com.baeldung.multiplelogin; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -6,14 +6,12 @@ import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView; import org.springframework.context.annotation.ComponentScan; @EnableWebMvc @Configuration -@ComponentScan("org.baeldung.controller") public class MultipleLoginMvcConfig implements WebMvcConfigurer { public MultipleLoginMvcConfig() { diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multiplelogin/MultipleLoginSecurityConfig.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multiplelogin/MultipleLoginSecurityConfig.java similarity index 99% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multiplelogin/MultipleLoginSecurityConfig.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multiplelogin/MultipleLoginSecurityConfig.java index 9962bf41a9..3d12951f39 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multiplelogin/MultipleLoginSecurityConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multiplelogin/MultipleLoginSecurityConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.multiplelogin; +package com.baeldung.multiplelogin; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multiplelogin/UsersController.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multiplelogin/UsersController.java similarity index 95% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multiplelogin/UsersController.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multiplelogin/UsersController.java index 61d7da127c..03be0fd6b2 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/multiplelogin/UsersController.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/multiplelogin/UsersController.java @@ -1,4 +1,4 @@ -package org.baeldung.multiplelogin; +package com.baeldung.multiplelogin; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/ssl/HttpsEnabledApplication.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/ssl/HttpsEnabledApplication.java similarity index 95% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/ssl/HttpsEnabledApplication.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/ssl/HttpsEnabledApplication.java index 17c249067c..f6a550ae54 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/ssl/HttpsEnabledApplication.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/ssl/HttpsEnabledApplication.java @@ -1,4 +1,4 @@ -package org.baeldung.ssl; +package com.baeldung.ssl; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/ssl/SecurityConfig.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/ssl/SecurityConfig.java similarity index 95% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/ssl/SecurityConfig.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/ssl/SecurityConfig.java index 92f92d8fc7..4bddf0592a 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/ssl/SecurityConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/ssl/SecurityConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.ssl; +package com.baeldung.ssl; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/ssl/WelcomeController.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/ssl/WelcomeController.java similarity index 74% rename from spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/ssl/WelcomeController.java rename to spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/ssl/WelcomeController.java index 72ad8abb85..2bd8c8cfde 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/org/baeldung/ssl/WelcomeController.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/ssl/WelcomeController.java @@ -1,8 +1,7 @@ -package org.baeldung.ssl; +package com.baeldung.ssl; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ResponseBody; @Controller public class WelcomeController { diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/jdbcauthentication/h2/SpringContextTest.java b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/jdbcauthentication/h2/SpringContextTest.java similarity index 76% rename from spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/jdbcauthentication/h2/SpringContextTest.java rename to spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/jdbcauthentication/h2/SpringContextTest.java index 659dad9155..5bd2a0ce27 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/jdbcauthentication/h2/SpringContextTest.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/jdbcauthentication/h2/SpringContextTest.java @@ -1,6 +1,5 @@ -package org.baeldung.jdbcauthentication.h2; +package com.baeldung.jdbcauthentication.h2; -import org.baeldung.jdbcauthentication.h2.H2JdbcAuthenticationApplication; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/jdbcauthentication/h2/web/UserControllerLiveTest.java b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/jdbcauthentication/h2/web/UserControllerLiveTest.java similarity index 95% rename from spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/jdbcauthentication/h2/web/UserControllerLiveTest.java rename to spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/jdbcauthentication/h2/web/UserControllerLiveTest.java index 638e9d7919..12b5ca5867 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/jdbcauthentication/h2/web/UserControllerLiveTest.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/jdbcauthentication/h2/web/UserControllerLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.jdbcauthentication.h2.web; +package com.baeldung.jdbcauthentication.h2.web; import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.is; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/jdbcauthentication/mysql/web/UserControllerLiveTest.java b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/jdbcauthentication/mysql/web/UserControllerLiveTest.java similarity index 95% rename from spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/jdbcauthentication/mysql/web/UserControllerLiveTest.java rename to spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/jdbcauthentication/mysql/web/UserControllerLiveTest.java index 261063cbb6..79bc84ea69 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/jdbcauthentication/mysql/web/UserControllerLiveTest.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/jdbcauthentication/mysql/web/UserControllerLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.jdbcauthentication.mysql.web; +package com.baeldung.jdbcauthentication.mysql.web; import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.is; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/jdbcauthentication/postgre/web/UserControllerLiveTest.java b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/jdbcauthentication/postgre/web/UserControllerLiveTest.java similarity index 95% rename from spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/jdbcauthentication/postgre/web/UserControllerLiveTest.java rename to spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/jdbcauthentication/postgre/web/UserControllerLiveTest.java index 82bf6df8db..e6426a843e 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/jdbcauthentication/postgre/web/UserControllerLiveTest.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/jdbcauthentication/postgre/web/UserControllerLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.jdbcauthentication.postgre.web; +package com.baeldung.jdbcauthentication.postgre.web; import static io.restassured.RestAssured.given; import static org.hamcrest.CoreMatchers.is; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/web/HttpsApplicationIntegrationTest.java b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/web/HttpsApplicationIntegrationTest.java similarity index 96% rename from spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/web/HttpsApplicationIntegrationTest.java rename to spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/web/HttpsApplicationIntegrationTest.java index fe7883ec94..63d47e6a46 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/web/HttpsApplicationIntegrationTest.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/web/HttpsApplicationIntegrationTest.java @@ -1,10 +1,10 @@ -package org.baeldung.web; +package com.baeldung.web; import org.apache.http.client.HttpClient; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContextBuilder; -import org.baeldung.ssl.HttpsEnabledApplication; +import com.baeldung.ssl.HttpsEnabledApplication; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Value; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/web/MultipleAuthProvidersApplicationIntegrationTest.java b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/web/MultipleAuthProvidersApplicationIntegrationTest.java similarity index 96% rename from spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/web/MultipleAuthProvidersApplicationIntegrationTest.java rename to spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/web/MultipleAuthProvidersApplicationIntegrationTest.java index 9ef09f1f67..c5ef469fe8 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/web/MultipleAuthProvidersApplicationIntegrationTest.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/web/MultipleAuthProvidersApplicationIntegrationTest.java @@ -1,10 +1,10 @@ -package org.baeldung.web; +package com.baeldung.web; import static org.assertj.core.api.Assertions.assertThat; import java.util.Collections; -import org.baeldung.multipleauthproviders.MultipleAuthProvidersApplication; +import com.baeldung.multipleauthproviders.MultipleAuthProvidersApplication; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/web/MultipleEntryPointsIntegrationTest.java b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/web/MultipleEntryPointsIntegrationTest.java similarity index 96% rename from spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/web/MultipleEntryPointsIntegrationTest.java rename to spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/web/MultipleEntryPointsIntegrationTest.java index 422be2ac88..352b4af244 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/test/java/org/baeldung/web/MultipleEntryPointsIntegrationTest.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/test/java/com/baeldung/web/MultipleEntryPointsIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.web; +package com.baeldung.web; import org.junit.Before; import org.junit.Test; @@ -15,7 +15,7 @@ import org.springframework.web.context.WebApplicationContext; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; -import org.baeldung.multipleentrypoints.MultipleEntryPointsApplication; +import com.baeldung.multipleentrypoints.MultipleEntryPointsApplication; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.*; From 8efe817cd38e160faafa9fb113b73fcee773ba90 Mon Sep 17 00:00:00 2001 From: Roger Yates <587230+rojyates@users.noreply.github.com> Date: Tue, 10 Mar 2020 09:19:13 +1000 Subject: [PATCH 02/73] BAEL-3603 Add test examples for Java IO versus NIO article --- core-java-modules/core-java-io-2/pom.xml | 8 ++ .../BlockingClientUnitTest.java | 51 ++++++++++ .../NonBlockingClientUnitTest.java | 94 +++++++++++++++++++ 3 files changed, 153 insertions(+) create mode 100644 core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/BlockingClientUnitTest.java create mode 100644 core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java diff --git a/core-java-modules/core-java-io-2/pom.xml b/core-java-modules/core-java-io-2/pom.xml index 0c271737d9..960cc51bbd 100644 --- a/core-java-modules/core-java-io-2/pom.xml +++ b/core-java-modules/core-java-io-2/pom.xml @@ -45,6 +45,14 @@ ${assertj.version} test + + + com.github.tomakehurst + wiremock + 2.26.3 + test + + diff --git a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/BlockingClientUnitTest.java b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/BlockingClientUnitTest.java new file mode 100644 index 0000000000..eca2a2638f --- /dev/null +++ b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/BlockingClientUnitTest.java @@ -0,0 +1,51 @@ +package com.baeldung.blockingnonblocking; + +import com.github.tomakehurst.wiremock.junit.WireMockRule; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import java.io.*; +import java.net.Socket; + +import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; +import static org.junit.Assert.assertTrue; + +public class BlockingClientUnitTest { + private static final String REQUESTED_RESOURCE = "/test.json"; + + @Rule public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); + + @Before + public void setup() { + stubFor(get(urlEqualTo(REQUESTED_RESOURCE)).willReturn(aResponse() + .withStatus(200) + .withBody("{ \"response\" : \"It worked!\" }\r\n\r\n"))); + } + + @Test + public void givenJavaIOSocket_whenReadingAndWritingWithStreams_thenReadSuccessfully() throws IOException { + // given an IO socket and somewhere to store our result + Socket socket = new Socket("localhost", wireMockRule.port()); + StringBuilder ourStore = new StringBuilder(); + + // when we write and read (using try-with-resources so our resources are auto-closed) + try (InputStream serverInput = socket.getInputStream(); + BufferedReader reader = new BufferedReader(new InputStreamReader(serverInput)); + OutputStream clientOutput = socket.getOutputStream(); + PrintWriter writer = new PrintWriter(new OutputStreamWriter(clientOutput))) { + writer.print("GET " + REQUESTED_RESOURCE + " HTTP/1.0\r\n\r\n"); + writer.flush(); // important - without this the request is never sent, and the test will hang on readLine() + + for (String line; (line = reader.readLine()) != null; ) { + ourStore.append(line); + } + } + + // then we read and saved our data + assertTrue(ourStore + .toString() + .contains("It worked!")); + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java new file mode 100644 index 0000000000..47115887ab --- /dev/null +++ b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java @@ -0,0 +1,94 @@ +package com.baeldung.blockingnonblocking; + +import com.github.tomakehurst.wiremock.junit.WireMockRule; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.channels.SocketChannel; +import java.nio.charset.Charset; +import java.nio.charset.CharsetDecoder; +import java.nio.charset.StandardCharsets; + +import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; +import static org.junit.Assert.assertTrue; + +public class NonBlockingClientUnitTest { + private String REQUESTED_RESOURCE = "/test.json"; + + @Rule public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); + + @Before + public void setup() { + stubFor(get(urlEqualTo(REQUESTED_RESOURCE)).willReturn(aResponse() + .withStatus(200) + .withBody("{ \"response\" : \"It worked!\" }"))); + } + + @Test + public void givenJavaNIOSocketChannel_whenReadingAndWriting_thenUseBuffers() throws IOException { + // given a NIO SocketChannel and a charset + InetSocketAddress address = new InetSocketAddress("localhost", wireMockRule.port()); + SocketChannel socketChannel = SocketChannel.open(address); + Charset charset = StandardCharsets.UTF_8; + + // when we write and read using buffers + socketChannel.write(charset.encode(CharBuffer.wrap("GET " + REQUESTED_RESOURCE + " HTTP/1.0\r\n\r\n"))); + + ByteBuffer buffer = ByteBuffer.allocate(8); // or allocateDirect if we need direct memory access + CharBuffer charBuffer = CharBuffer.allocate(8192); + CharsetDecoder decoder = charset.newDecoder(); + StringBuilder ourStore = new StringBuilder(); + while (socketChannel.read(buffer) != -1 || buffer.position() > 0) { + buffer.flip(); + storeBufferContents(buffer, charBuffer, decoder, ourStore); + buffer.compact(); + } + socketChannel.close(); + + // then we read and saved our data + assertTrue(ourStore + .toString() + .contains("It worked!")); + } + + @Test + public void givenJavaNIO_whenReadingAndWriting_thenSmallBuffers() throws IOException { + // given a NIO SocketChannel and a charset + InetSocketAddress address = new InetSocketAddress("localhost", wireMockRule.port()); + SocketChannel socket = SocketChannel.open(address); + Charset charset = StandardCharsets.UTF_8; + + // when we write and read using buffers that are too small for our message + socket.write(charset.encode(CharBuffer.wrap("GET " + REQUESTED_RESOURCE + " HTTP/1.0\r\n\r\n"))); + + ByteBuffer buffer = ByteBuffer.allocate(8); // or allocateDirect if we need direct memory access + CharBuffer charBuffer = CharBuffer.allocate(8); + CharsetDecoder decoder = charset.newDecoder(); + StringBuilder ourStore = new StringBuilder(); + while (socket.read(buffer) != -1 || buffer.position() > 0) { + buffer.flip(); + storeBufferContents(buffer, charBuffer, decoder, ourStore); + buffer.compact(); + } + socket.close(); + + // then we read and saved our data + assertTrue(ourStore + .toString() + .contains("It worked!")); + } + + void storeBufferContents(ByteBuffer buffer, CharBuffer charBuffer, CharsetDecoder decoder, StringBuilder ourStore) { + decoder.decode(buffer, charBuffer, true); + charBuffer.flip(); + ourStore.append(charBuffer); + charBuffer.clear(); + } + +} \ No newline at end of file From fad2d2a67ccc4d709f817ae902fa5078cca00d68 Mon Sep 17 00:00:00 2001 From: Roger Yates <587230+rojyates@users.noreply.github.com> Date: Thu, 12 Mar 2020 06:12:42 +1000 Subject: [PATCH 03/73] BAEL-3603 Add line separator to preserve lines read --- .../com/baeldung/blockingnonblocking/BlockingClientUnitTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/BlockingClientUnitTest.java b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/BlockingClientUnitTest.java index eca2a2638f..3fc968ded0 100644 --- a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/BlockingClientUnitTest.java +++ b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/BlockingClientUnitTest.java @@ -40,6 +40,7 @@ public class BlockingClientUnitTest { for (String line; (line = reader.readLine()) != null; ) { ourStore.append(line); + ourStore.append(System.lineSeparator()); } } From ab71c5eb09b079f0ede80c0ad0d9b3ed01018223 Mon Sep 17 00:00:00 2001 From: mikr Date: Sun, 15 Mar 2020 16:37:38 +0100 Subject: [PATCH 04/73] JAVA-841 Standardize packages in spring-security-mvc-boot --- .../spring-security-mvc-boot-1/pom.xml | 4 ++-- .../baeldung/{ => relationships}/AppConfig.java | 6 +++--- .../{ => relationships}/SpringSecurityConfig.java | 6 +++--- .../{ => relationships}/models/AppUser.java | 2 +- .../baeldung/{ => relationships}/models/Tweet.java | 2 +- .../repositories/TweetRepository.java | 4 ++-- .../repositories/UserRepository.java | 7 ++----- .../security/AppUserPrincipal.java | 4 ++-- .../security/AuthenticationSuccessHandlerImpl.java | 4 ++-- .../security/CustomUserDetailsService.java | 6 +++--- .../{ => relationships}/util/DummyContentUtil.java | 6 +++--- .../baeldung/roles}/custom/Application.java | 4 ++-- .../roles}/custom/config/MethodSecurityConfig.java | 6 +++--- .../baeldung/roles}/custom/config/MvcConfig.java | 2 +- .../roles}/custom/config/SecurityConfig.java | 2 +- .../roles}/custom/persistence/SetupData.java | 14 +++++++------- .../persistence/dao/OrganizationRepository.java | 4 ++-- .../persistence/dao/PrivilegeRepository.java | 4 ++-- .../custom/persistence/dao/UserRepository.java | 4 ++-- .../roles}/custom/persistence/model/Foo.java | 2 +- .../custom/persistence/model/Organization.java | 2 +- .../roles}/custom/persistence/model/Privilege.java | 2 +- .../roles}/custom/persistence/model/User.java | 2 +- .../CustomMethodSecurityExpressionHandler.java | 2 +- .../CustomMethodSecurityExpressionRoot.java | 4 ++-- .../custom/security/CustomPermissionEvaluator.java | 2 +- .../custom/security/MySecurityExpressionRoot.java | 4 ++-- .../custom/security/MyUserDetailsService.java | 6 +++--- .../roles}/custom/security/MyUserPrincipal.java | 6 +++--- .../baeldung/roles}/custom/web/MainController.java | 10 +++++----- .../baeldung/roles}/ip/IpApplication.java | 4 ++-- .../ip/config/CustomIpAuthenticationProvider.java | 2 +- .../baeldung/roles}/ip/config/SecurityConfig.java | 2 +- .../roles}/ip/config/SecurityXmlConfig.java | 2 +- .../baeldung/roles}/ip/web/MainController.java | 4 ++-- .../CustomAuthenticationProvider.java | 6 +++--- .../rolesauthorities/MyLogoutSuccessHandler.java | 2 +- .../rolesauthorities/MyUserDetailsService.java | 8 ++++---- .../RolesAuthoritiesApplication.java | 4 ++-- .../roles}/rolesauthorities/config/MvcConfig.java | 2 +- .../rolesauthorities/config/SecurityConfig.java | 10 +++++----- .../roles}/rolesauthorities/model/Privilege.java | 2 +- .../roles}/rolesauthorities/model/Role.java | 2 +- .../roles}/rolesauthorities/model/User.java | 2 +- .../rolesauthorities/persistence/IUserService.java | 9 +++++++++ .../persistence/PrivilegeRepository.java | 4 ++-- .../persistence/RoleRepository.java | 4 ++-- .../persistence/SetupDataLoader.java | 8 ++++---- .../persistence/UserRepository.java | 4 ++-- .../rolesauthorities/persistence/UserService.java | 4 ++-- .../baeldung/roles}/voter/MinuteBasedVoter.java | 2 +- .../baeldung/roles}/voter/VoterApplication.java | 4 ++-- .../baeldung/roles}/voter/VoterMvcConfig.java | 4 +--- .../baeldung/roles}/voter/WebSecurityConfig.java | 3 +-- .../baeldung/roles}/voter/XmlSecurityConfig.java | 5 +---- .../rolesauthorities/persistence/IUserService.java | 9 --------- .../resources/spring-security-custom-voter.xml | 4 ++-- .../SpringDataWithSecurityIntegrationTest.java | 13 ++++++------- .../baeldung/roles}/SpringContextTest.java | 4 ++-- .../baeldung/roles}/web/ApplicationLiveTest.java | 6 +++--- .../CustomUserDetailsServiceIntegrationTest.java | 8 ++++---- .../baeldung/roles}/web/IpLiveTest.java | 4 ++-- 62 files changed, 137 insertions(+), 147 deletions(-) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/{ => relationships}/AppConfig.java (92%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/{ => relationships}/SpringSecurityConfig.java (94%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/{ => relationships}/models/AppUser.java (97%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/{ => relationships}/models/Tweet.java (96%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/{data => relationships}/repositories/TweetRepository.java (84%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/{data => relationships}/repositories/UserRepository.java (76%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/{ => relationships}/security/AppUserPrincipal.java (93%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/{ => relationships}/security/AuthenticationSuccessHandlerImpl.java (88%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/{ => relationships}/security/CustomUserDetailsService.java (87%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/{ => relationships}/util/DummyContentUtil.java (95%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/Application.java (88%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/config/MethodSecurityConfig.java (83%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/config/MvcConfig.java (97%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/config/SecurityConfig.java (96%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/persistence/SetupData.java (83%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/persistence/dao/OrganizationRepository.java (63%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/persistence/dao/PrivilegeRepository.java (62%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/persistence/dao/UserRepository.java (74%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/persistence/model/Foo.java (97%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/persistence/model/Organization.java (97%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/persistence/model/Privilege.java (97%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/persistence/model/User.java (98%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/security/CustomMethodSecurityExpressionHandler.java (96%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/security/CustomMethodSecurityExpressionRoot.java (92%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/security/CustomPermissionEvaluator.java (97%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/security/MySecurityExpressionRoot.java (98%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/security/MyUserDetailsService.java (83%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/security/MyUserPrincipal.java (89%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/custom/web/MainController.java (87%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/ip/IpApplication.java (90%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/ip/config/CustomIpAuthenticationProvider.java (98%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/ip/config/SecurityConfig.java (97%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/ip/config/SecurityXmlConfig.java (78%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/ip/web/MainController.java (94%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/rolesauthorities/CustomAuthenticationProvider.java (89%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/rolesauthorities/MyLogoutSuccessHandler.java (95%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/rolesauthorities/MyUserDetailsService.java (90%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/rolesauthorities/RolesAuthoritiesApplication.java (87%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/rolesauthorities/config/MvcConfig.java (97%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/rolesauthorities/config/SecurityConfig.java (90%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/rolesauthorities/model/Privilege.java (97%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/rolesauthorities/model/Role.java (97%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/rolesauthorities/model/User.java (98%) create mode 100644 spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/IUserService.java rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/rolesauthorities/persistence/PrivilegeRepository.java (65%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/rolesauthorities/persistence/RoleRepository.java (63%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/rolesauthorities/persistence/SetupDataLoader.java (93%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/rolesauthorities/persistence/UserRepository.java (64%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/rolesauthorities/persistence/UserService.java (77%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/voter/MinuteBasedVoter.java (96%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/voter/VoterApplication.java (83%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/voter/VoterMvcConfig.java (71%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/voter/WebSecurityConfig.java (96%) rename spring-security-modules/spring-security-mvc-boot-1/src/main/java/{org/baeldung => com/baeldung/roles}/voter/XmlSecurityConfig.java (60%) delete mode 100644 spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/IUserService.java rename spring-security-modules/spring-security-mvc-boot-1/src/test/java/{org/baeldung => com/baeldung/roles}/SpringContextTest.java (83%) rename spring-security-modules/spring-security-mvc-boot-1/src/test/java/{org/baeldung => com/baeldung/roles}/web/ApplicationLiveTest.java (94%) rename spring-security-modules/spring-security-mvc-boot-1/src/test/java/{org/baeldung => com/baeldung/roles}/web/CustomUserDetailsServiceIntegrationTest.java (95%) rename spring-security-modules/spring-security-mvc-boot-1/src/test/java/{org/baeldung => com/baeldung/roles}/web/IpLiveTest.java (90%) diff --git a/spring-security-modules/spring-security-mvc-boot-1/pom.xml b/spring-security-modules/spring-security-mvc-boot-1/pom.xml index 7dfee200d4..476159f306 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/pom.xml +++ b/spring-security-modules/spring-security-mvc-boot-1/pom.xml @@ -222,10 +222,10 @@ - org.baeldung.custom.Application + com.baeldung.roles.custom.Application - + 1.1.2 1.6.1 diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/AppConfig.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/AppConfig.java similarity index 92% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/AppConfig.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/AppConfig.java index 8719e39a20..ab2cc71fec 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/AppConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/AppConfig.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.relationships; import java.util.Properties; @@ -19,7 +19,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter @SpringBootApplication @PropertySource({"classpath:persistence-h2.properties", "classpath:application-defaults.properties"}) -@EnableJpaRepositories(basePackages = { "com.baeldung.data.repositories" }) +@EnableJpaRepositories(basePackages = {"com.baeldung.relationships.repositories"}) @EnableWebMvc @Import(SpringSecurityConfig.class) public class AppConfig extends WebMvcConfigurerAdapter { @@ -41,7 +41,7 @@ public class AppConfig extends WebMvcConfigurerAdapter { public LocalContainerEntityManagerFactoryBean entityManagerFactory() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); - em.setPackagesToScan(new String[] { "com.baeldung.models" }); + em.setPackagesToScan(new String[] { "com.baeldung.relationships.models" }); em.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); em.setJpaProperties(additionalProperties()); return em; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/SpringSecurityConfig.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/SpringSecurityConfig.java similarity index 94% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/SpringSecurityConfig.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/SpringSecurityConfig.java index ee13678a24..88814038a8 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/SpringSecurityConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/SpringSecurityConfig.java @@ -1,4 +1,4 @@ -package com.baeldung; +package com.baeldung.relationships; import javax.annotation.PostConstruct; import javax.sql.DataSource; @@ -18,8 +18,8 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.data.repository.query.SecurityEvaluationContextExtension; import org.springframework.web.context.WebApplicationContext; -import com.baeldung.security.AuthenticationSuccessHandlerImpl; -import com.baeldung.security.CustomUserDetailsService; +import com.baeldung.relationships.security.AuthenticationSuccessHandlerImpl; +import com.baeldung.relationships.security.CustomUserDetailsService; @Configuration @EnableWebSecurity diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/models/AppUser.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/models/AppUser.java similarity index 97% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/models/AppUser.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/models/AppUser.java index e48233f90a..2efd24e879 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/models/AppUser.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/models/AppUser.java @@ -1,4 +1,4 @@ -package com.baeldung.models; +package com.baeldung.relationships.models; import java.util.Date; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/models/Tweet.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/models/Tweet.java similarity index 96% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/models/Tweet.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/models/Tweet.java index 54a96deaf3..d8496f89be 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/models/Tweet.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/models/Tweet.java @@ -1,4 +1,4 @@ -package com.baeldung.models; +package com.baeldung.relationships.models; import java.util.HashSet; import java.util.Set; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/data/repositories/TweetRepository.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/repositories/TweetRepository.java similarity index 84% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/data/repositories/TweetRepository.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/repositories/TweetRepository.java index 7d6446ed0d..4e4b16a151 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/data/repositories/TweetRepository.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/repositories/TweetRepository.java @@ -1,11 +1,11 @@ -package com.baeldung.data.repositories; +package com.baeldung.relationships.repositories; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.PagingAndSortingRepository; -import com.baeldung.models.Tweet; +import com.baeldung.relationships.models.Tweet; public interface TweetRepository extends PagingAndSortingRepository { diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/data/repositories/UserRepository.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/repositories/UserRepository.java similarity index 76% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/data/repositories/UserRepository.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/repositories/UserRepository.java index 5240c683e0..883ea332f8 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/data/repositories/UserRepository.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/repositories/UserRepository.java @@ -1,18 +1,15 @@ -package com.baeldung.data.repositories; +package com.baeldung.relationships.repositories; import java.util.Date; import java.util.List; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.query.Param; -import org.springframework.stereotype.Repository; import org.springframework.transaction.annotation.Transactional; -import com.baeldung.models.AppUser; +import com.baeldung.relationships.models.AppUser; public interface UserRepository extends CrudRepository { AppUser findByUsername(String username); diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/security/AppUserPrincipal.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/security/AppUserPrincipal.java similarity index 93% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/security/AppUserPrincipal.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/security/AppUserPrincipal.java index 195f9f7bf6..1ae7d95e41 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/security/AppUserPrincipal.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/security/AppUserPrincipal.java @@ -1,4 +1,4 @@ -package com.baeldung.security; +package com.baeldung.relationships.security; import java.util.Collection; import java.util.Collections; @@ -8,7 +8,7 @@ import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; -import com.baeldung.models.AppUser; +import com.baeldung.relationships.models.AppUser; public class AppUserPrincipal implements UserDetails { diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/security/AuthenticationSuccessHandlerImpl.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/security/AuthenticationSuccessHandlerImpl.java similarity index 88% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/security/AuthenticationSuccessHandlerImpl.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/security/AuthenticationSuccessHandlerImpl.java index 3fc2bc6559..1b85294467 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/security/AuthenticationSuccessHandlerImpl.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/security/AuthenticationSuccessHandlerImpl.java @@ -1,4 +1,4 @@ -package com.baeldung.security; +package com.baeldung.relationships.security; import java.io.IOException; import java.util.Date; @@ -12,7 +12,7 @@ import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.AuthenticationSuccessHandler; import org.springframework.stereotype.Component; -import com.baeldung.data.repositories.UserRepository; +import com.baeldung.relationships.repositories.UserRepository; @Component public class AuthenticationSuccessHandlerImpl implements AuthenticationSuccessHandler { diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/security/CustomUserDetailsService.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/security/CustomUserDetailsService.java similarity index 87% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/security/CustomUserDetailsService.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/security/CustomUserDetailsService.java index 016f4f7fa9..10c266bb74 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/security/CustomUserDetailsService.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/security/CustomUserDetailsService.java @@ -1,4 +1,4 @@ -package com.baeldung.security; +package com.baeldung.relationships.security; import javax.annotation.PostConstruct; @@ -9,8 +9,8 @@ import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; import org.springframework.web.context.WebApplicationContext; -import com.baeldung.data.repositories.UserRepository; -import com.baeldung.models.AppUser; +import com.baeldung.relationships.repositories.UserRepository; +import com.baeldung.relationships.models.AppUser; @Service public class CustomUserDetailsService implements UserDetailsService { diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/util/DummyContentUtil.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/util/DummyContentUtil.java similarity index 95% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/util/DummyContentUtil.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/util/DummyContentUtil.java index f1640264d2..b8e5192b48 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/util/DummyContentUtil.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/relationships/util/DummyContentUtil.java @@ -1,4 +1,4 @@ -package com.baeldung.util; +package com.baeldung.relationships.util; import java.util.ArrayList; import java.util.Collection; @@ -10,8 +10,8 @@ import java.util.stream.IntStream; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import com.baeldung.models.AppUser; -import com.baeldung.models.Tweet; +import com.baeldung.relationships.models.AppUser; +import com.baeldung.relationships.models.Tweet; public class DummyContentUtil { diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/Application.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/Application.java similarity index 88% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/Application.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/Application.java index e051e5a853..e7ace1f962 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/Application.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/Application.java @@ -1,4 +1,4 @@ -package org.baeldung.custom; +package com.baeldung.roles.custom; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -7,7 +7,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.PropertySource; @SpringBootApplication -@ComponentScan("org.baeldung.custom") +@ComponentScan("com.baeldung.roles.custom") @PropertySource("classpath:application-defaults.properties") public class Application extends SpringBootServletInitializer { public static void main(String[] args) { diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/config/MethodSecurityConfig.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/config/MethodSecurityConfig.java similarity index 83% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/config/MethodSecurityConfig.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/config/MethodSecurityConfig.java index 6a005153dc..57ab8b120f 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/config/MethodSecurityConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/config/MethodSecurityConfig.java @@ -1,7 +1,7 @@ -package org.baeldung.custom.config; +package com.baeldung.roles.custom.config; -import org.baeldung.custom.security.CustomMethodSecurityExpressionHandler; -import org.baeldung.custom.security.CustomPermissionEvaluator; +import com.baeldung.roles.custom.security.CustomMethodSecurityExpressionHandler; +import com.baeldung.roles.custom.security.CustomPermissionEvaluator; import org.springframework.context.annotation.Configuration; import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/config/MvcConfig.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/config/MvcConfig.java similarity index 97% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/config/MvcConfig.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/config/MvcConfig.java index 58d11ea9ae..c99d1e38a5 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/config/MvcConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/config/MvcConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.custom.config; +package com.baeldung.roles.custom.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/config/SecurityConfig.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/config/SecurityConfig.java similarity index 96% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/config/SecurityConfig.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/config/SecurityConfig.java index 06357650dc..6bf04120ab 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/config/SecurityConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/config/SecurityConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.custom.config; +package com.baeldung.roles.custom.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/SetupData.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/SetupData.java similarity index 83% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/SetupData.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/SetupData.java index f0fcce3908..ab57e7436c 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/SetupData.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/SetupData.java @@ -1,16 +1,16 @@ -package org.baeldung.custom.persistence; +package com.baeldung.roles.custom.persistence; import java.util.Arrays; import java.util.HashSet; import javax.annotation.PostConstruct; -import org.baeldung.custom.persistence.dao.OrganizationRepository; -import org.baeldung.custom.persistence.dao.PrivilegeRepository; -import org.baeldung.custom.persistence.dao.UserRepository; -import org.baeldung.custom.persistence.model.Organization; -import org.baeldung.custom.persistence.model.Privilege; -import org.baeldung.custom.persistence.model.User; +import com.baeldung.roles.custom.persistence.dao.OrganizationRepository; +import com.baeldung.roles.custom.persistence.dao.PrivilegeRepository; +import com.baeldung.roles.custom.persistence.dao.UserRepository; +import com.baeldung.roles.custom.persistence.model.Organization; +import com.baeldung.roles.custom.persistence.model.Privilege; +import com.baeldung.roles.custom.persistence.model.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Component; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/dao/OrganizationRepository.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/dao/OrganizationRepository.java similarity index 63% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/dao/OrganizationRepository.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/dao/OrganizationRepository.java index 1319a7b9f8..2f585f3527 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/dao/OrganizationRepository.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/dao/OrganizationRepository.java @@ -1,6 +1,6 @@ -package org.baeldung.custom.persistence.dao; +package com.baeldung.roles.custom.persistence.dao; -import org.baeldung.custom.persistence.model.Organization; +import com.baeldung.roles.custom.persistence.model.Organization; import org.springframework.data.jpa.repository.JpaRepository; public interface OrganizationRepository extends JpaRepository { diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/dao/PrivilegeRepository.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/dao/PrivilegeRepository.java similarity index 62% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/dao/PrivilegeRepository.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/dao/PrivilegeRepository.java index c232bb986c..c83e0f505e 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/dao/PrivilegeRepository.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/dao/PrivilegeRepository.java @@ -1,6 +1,6 @@ -package org.baeldung.custom.persistence.dao; +package com.baeldung.roles.custom.persistence.dao; -import org.baeldung.custom.persistence.model.Privilege; +import com.baeldung.roles.custom.persistence.model.Privilege; import org.springframework.data.jpa.repository.JpaRepository; public interface PrivilegeRepository extends JpaRepository { diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/dao/UserRepository.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/dao/UserRepository.java similarity index 74% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/dao/UserRepository.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/dao/UserRepository.java index 68dd1d756c..884a998219 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/dao/UserRepository.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/dao/UserRepository.java @@ -1,6 +1,6 @@ -package org.baeldung.custom.persistence.dao; +package com.baeldung.roles.custom.persistence.dao; -import org.baeldung.custom.persistence.model.User; +import com.baeldung.roles.custom.persistence.model.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.transaction.annotation.Transactional; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/model/Foo.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/model/Foo.java similarity index 97% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/model/Foo.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/model/Foo.java index f139382eea..3dbf48f7ce 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/model/Foo.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/model/Foo.java @@ -1,4 +1,4 @@ -package org.baeldung.custom.persistence.model; +package com.baeldung.roles.custom.persistence.model; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/model/Organization.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/model/Organization.java similarity index 97% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/model/Organization.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/model/Organization.java index 1fdb88e320..0d0220b6b2 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/model/Organization.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/model/Organization.java @@ -1,4 +1,4 @@ -package org.baeldung.custom.persistence.model; +package com.baeldung.roles.custom.persistence.model; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/model/Privilege.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/model/Privilege.java similarity index 97% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/model/Privilege.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/model/Privilege.java index ed3edd5085..60e0506641 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/model/Privilege.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/model/Privilege.java @@ -1,4 +1,4 @@ -package org.baeldung.custom.persistence.model; +package com.baeldung.roles.custom.persistence.model; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/model/User.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/model/User.java similarity index 98% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/model/User.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/model/User.java index c14ef034b4..219f40a3df 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/persistence/model/User.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/persistence/model/User.java @@ -1,4 +1,4 @@ -package org.baeldung.custom.persistence.model; +package com.baeldung.roles.custom.persistence.model; import java.util.Set; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/CustomMethodSecurityExpressionHandler.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/CustomMethodSecurityExpressionHandler.java similarity index 96% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/CustomMethodSecurityExpressionHandler.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/CustomMethodSecurityExpressionHandler.java index 646f5a387f..76e94a9dd4 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/CustomMethodSecurityExpressionHandler.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/CustomMethodSecurityExpressionHandler.java @@ -1,4 +1,4 @@ -package org.baeldung.custom.security; +package com.baeldung.roles.custom.security; import org.aopalliance.intercept.MethodInvocation; import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/CustomMethodSecurityExpressionRoot.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/CustomMethodSecurityExpressionRoot.java similarity index 92% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/CustomMethodSecurityExpressionRoot.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/CustomMethodSecurityExpressionRoot.java index b2f2be8cf5..dd9f6a5786 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/CustomMethodSecurityExpressionRoot.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/CustomMethodSecurityExpressionRoot.java @@ -1,6 +1,6 @@ -package org.baeldung.custom.security; +package com.baeldung.roles.custom.security; -import org.baeldung.custom.persistence.model.User; +import com.baeldung.roles.custom.persistence.model.User; import org.springframework.security.access.expression.SecurityExpressionRoot; import org.springframework.security.access.expression.method.MethodSecurityExpressionOperations; import org.springframework.security.core.Authentication; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/CustomPermissionEvaluator.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/CustomPermissionEvaluator.java similarity index 97% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/CustomPermissionEvaluator.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/CustomPermissionEvaluator.java index f436b4488b..d69e405b28 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/CustomPermissionEvaluator.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/CustomPermissionEvaluator.java @@ -1,4 +1,4 @@ -package org.baeldung.custom.security; +package com.baeldung.roles.custom.security; import java.io.Serializable; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/MySecurityExpressionRoot.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/MySecurityExpressionRoot.java similarity index 98% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/MySecurityExpressionRoot.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/MySecurityExpressionRoot.java index 03d18cb755..8448ad9075 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/MySecurityExpressionRoot.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/MySecurityExpressionRoot.java @@ -1,11 +1,11 @@ -package org.baeldung.custom.security; +package com.baeldung.roles.custom.security; import java.io.Serializable; import java.util.Collection; import java.util.HashSet; import java.util.Set; -import org.baeldung.custom.persistence.model.User; +import com.baeldung.roles.custom.persistence.model.User; import org.springframework.security.access.PermissionEvaluator; import org.springframework.security.access.expression.method.MethodSecurityExpressionOperations; import org.springframework.security.access.hierarchicalroles.RoleHierarchy; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/MyUserDetailsService.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/MyUserDetailsService.java similarity index 83% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/MyUserDetailsService.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/MyUserDetailsService.java index b9b40fbcb9..c6514d6c05 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/MyUserDetailsService.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/MyUserDetailsService.java @@ -1,7 +1,7 @@ -package org.baeldung.custom.security; +package com.baeldung.roles.custom.security; -import org.baeldung.custom.persistence.dao.UserRepository; -import org.baeldung.custom.persistence.model.User; +import com.baeldung.roles.custom.persistence.dao.UserRepository; +import com.baeldung.roles.custom.persistence.model.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/MyUserPrincipal.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/MyUserPrincipal.java similarity index 89% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/MyUserPrincipal.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/MyUserPrincipal.java index 7d57227316..41741c64f4 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/security/MyUserPrincipal.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/security/MyUserPrincipal.java @@ -1,11 +1,11 @@ -package org.baeldung.custom.security; +package com.baeldung.roles.custom.security; import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.baeldung.custom.persistence.model.Privilege; -import org.baeldung.custom.persistence.model.User; +import com.baeldung.roles.custom.persistence.model.Privilege; +import com.baeldung.roles.custom.persistence.model.User; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/web/MainController.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/web/MainController.java similarity index 87% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/web/MainController.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/web/MainController.java index 74de45d1a8..beb12f7749 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/custom/web/MainController.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/custom/web/MainController.java @@ -1,9 +1,9 @@ -package org.baeldung.custom.web; +package com.baeldung.roles.custom.web; -import org.baeldung.custom.persistence.dao.OrganizationRepository; -import org.baeldung.custom.persistence.model.Foo; -import org.baeldung.custom.persistence.model.Organization; -import org.baeldung.custom.security.MyUserPrincipal; +import com.baeldung.roles.custom.persistence.dao.OrganizationRepository; +import com.baeldung.roles.custom.persistence.model.Foo; +import com.baeldung.roles.custom.persistence.model.Organization; +import com.baeldung.roles.custom.security.MyUserPrincipal; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/ip/IpApplication.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/ip/IpApplication.java similarity index 90% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/ip/IpApplication.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/ip/IpApplication.java index d77414c54e..b9a86fee3e 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/ip/IpApplication.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/ip/IpApplication.java @@ -1,4 +1,4 @@ -package org.baeldung.ip; +package com.baeldung.roles.ip; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -7,7 +7,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.PropertySource; @SpringBootApplication -@ComponentScan("org.baeldung.ip") +@ComponentScan("com.baeldung.ip") @PropertySource("classpath:application-defaults.properties") public class IpApplication extends SpringBootServletInitializer { public static void main(String[] args) { diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/ip/config/CustomIpAuthenticationProvider.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/ip/config/CustomIpAuthenticationProvider.java similarity index 98% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/ip/config/CustomIpAuthenticationProvider.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/ip/config/CustomIpAuthenticationProvider.java index 078dd81259..adcadb65e8 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/ip/config/CustomIpAuthenticationProvider.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/ip/config/CustomIpAuthenticationProvider.java @@ -1,4 +1,4 @@ -package org.baeldung.ip.config; +package com.baeldung.roles.ip.config; import java.util.ArrayList; import java.util.HashSet; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/ip/config/SecurityConfig.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/ip/config/SecurityConfig.java similarity index 97% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/ip/config/SecurityConfig.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/ip/config/SecurityConfig.java index 3a8032a734..46ba62afb3 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/ip/config/SecurityConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/ip/config/SecurityConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.ip.config; +package com.baeldung.roles.ip.config; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/ip/config/SecurityXmlConfig.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/ip/config/SecurityXmlConfig.java similarity index 78% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/ip/config/SecurityXmlConfig.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/ip/config/SecurityXmlConfig.java index 1d22ca4c67..4b2cf43f6a 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/ip/config/SecurityXmlConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/ip/config/SecurityXmlConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.ip.config; +package com.baeldung.roles.ip.config; //@Configuration diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/ip/web/MainController.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/ip/web/MainController.java similarity index 94% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/ip/web/MainController.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/ip/web/MainController.java index 940194c421..438b668c5f 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/ip/web/MainController.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/ip/web/MainController.java @@ -1,11 +1,11 @@ -package org.baeldung.ip.web; +package com.baeldung.roles.ip.web; import java.util.List; import javax.servlet.Filter; import javax.servlet.http.HttpServletRequest; -import org.baeldung.custom.persistence.model.Foo; +import com.baeldung.roles.custom.persistence.model.Foo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.security.web.FilterChainProxy; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/CustomAuthenticationProvider.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/CustomAuthenticationProvider.java similarity index 89% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/CustomAuthenticationProvider.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/CustomAuthenticationProvider.java index d7195ac358..5168e64b4a 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/CustomAuthenticationProvider.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/CustomAuthenticationProvider.java @@ -1,7 +1,7 @@ -package org.baeldung.rolesauthorities; +package com.baeldung.roles.rolesauthorities; -import org.baeldung.rolesauthorities.model.User; -import org.baeldung.rolesauthorities.persistence.UserRepository; +import com.baeldung.roles.rolesauthorities.model.User; +import com.baeldung.roles.rolesauthorities.persistence.UserRepository; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.dao.DaoAuthenticationProvider; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/MyLogoutSuccessHandler.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/MyLogoutSuccessHandler.java similarity index 95% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/MyLogoutSuccessHandler.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/MyLogoutSuccessHandler.java index b0dc0b7537..23104e5292 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/MyLogoutSuccessHandler.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/MyLogoutSuccessHandler.java @@ -1,4 +1,4 @@ -package org.baeldung.rolesauthorities; +package com.baeldung.roles.rolesauthorities; import java.io.IOException; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/MyUserDetailsService.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/MyUserDetailsService.java similarity index 90% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/MyUserDetailsService.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/MyUserDetailsService.java index f38b867a75..18230ba794 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/MyUserDetailsService.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/MyUserDetailsService.java @@ -1,13 +1,13 @@ -package org.baeldung.rolesauthorities; +package com.baeldung.roles.rolesauthorities; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.stream.Collectors; -import org.baeldung.rolesauthorities.model.Role; -import org.baeldung.rolesauthorities.model.User; -import org.baeldung.rolesauthorities.persistence.UserRepository; +import com.baeldung.roles.rolesauthorities.model.Role; +import com.baeldung.roles.rolesauthorities.model.User; +import com.baeldung.roles.rolesauthorities.persistence.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/RolesAuthoritiesApplication.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/RolesAuthoritiesApplication.java similarity index 87% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/RolesAuthoritiesApplication.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/RolesAuthoritiesApplication.java index 3c4e6f7b5a..d3e54b4303 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/RolesAuthoritiesApplication.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/RolesAuthoritiesApplication.java @@ -1,4 +1,4 @@ -package org.baeldung.rolesauthorities; +package com.baeldung.roles.rolesauthorities; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -8,7 +8,7 @@ import org.springframework.context.annotation.Configuration; @Configuration @EnableAutoConfiguration -@ComponentScan("org.baeldung.rolesauthorities") +@ComponentScan("com.baeldung.rolesauthorities") public class RolesAuthoritiesApplication extends SpringBootServletInitializer { public static void main(String[] args) { System.setProperty("spring.profiles.default", "rolesauthorities"); diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/config/MvcConfig.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/config/MvcConfig.java similarity index 97% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/config/MvcConfig.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/config/MvcConfig.java index c42958457e..61394b6178 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/config/MvcConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/config/MvcConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.rolesauthorities.config; +package com.baeldung.roles.rolesauthorities.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/config/SecurityConfig.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/config/SecurityConfig.java similarity index 90% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/config/SecurityConfig.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/config/SecurityConfig.java index 7624dd7d39..cb8476fcc7 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/config/SecurityConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/config/SecurityConfig.java @@ -1,7 +1,7 @@ -package org.baeldung.rolesauthorities.config; +package com.baeldung.roles.rolesauthorities.config; -import org.baeldung.rolesauthorities.CustomAuthenticationProvider; -import org.baeldung.rolesauthorities.persistence.UserRepository; +import com.baeldung.roles.rolesauthorities.CustomAuthenticationProvider; +import com.baeldung.roles.rolesauthorities.persistence.UserRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -18,7 +18,7 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; @Configuration -@ComponentScan(basePackages = { "org.baeldung.rolesauthorities" }) +@ComponentScan(basePackages = {"com.baeldung.rolesauthorities"}) @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @@ -76,7 +76,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { @Bean public DaoAuthenticationProvider authProvider() { - final CustomAuthenticationProvider authProvider + final CustomAuthenticationProvider authProvider = new CustomAuthenticationProvider(userRepository, userDetailsService); authProvider.setPasswordEncoder(encoder()); return authProvider; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/model/Privilege.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/model/Privilege.java similarity index 97% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/model/Privilege.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/model/Privilege.java index ab2cd08610..507beaffa8 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/model/Privilege.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/model/Privilege.java @@ -1,4 +1,4 @@ -package org.baeldung.rolesauthorities.model; +package com.baeldung.roles.rolesauthorities.model; import java.util.Collection; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/model/Role.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/model/Role.java similarity index 97% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/model/Role.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/model/Role.java index ac33e32fcf..a284d92090 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/model/Role.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/model/Role.java @@ -1,4 +1,4 @@ -package org.baeldung.rolesauthorities.model; +package com.baeldung.roles.rolesauthorities.model; import java.util.Collection; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/model/User.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/model/User.java similarity index 98% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/model/User.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/model/User.java index dc1096541d..ebf0c9b310 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/model/User.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/model/User.java @@ -1,4 +1,4 @@ -package org.baeldung.rolesauthorities.model; +package com.baeldung.roles.rolesauthorities.model; import java.util.Collection; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/IUserService.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/IUserService.java new file mode 100644 index 0000000000..be9cb911d7 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/IUserService.java @@ -0,0 +1,9 @@ +package com.baeldung.roles.rolesauthorities.persistence; + +import com.baeldung.roles.rolesauthorities.model.User; + +public interface IUserService { + + User findUserByEmail(String email); + +} diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/PrivilegeRepository.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/PrivilegeRepository.java similarity index 65% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/PrivilegeRepository.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/PrivilegeRepository.java index 05d5f2b870..f8ba7def49 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/PrivilegeRepository.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/PrivilegeRepository.java @@ -1,6 +1,6 @@ -package org.baeldung.rolesauthorities.persistence; +package com.baeldung.roles.rolesauthorities.persistence; -import org.baeldung.rolesauthorities.model.Privilege; +import com.baeldung.roles.rolesauthorities.model.Privilege; import org.springframework.data.jpa.repository.JpaRepository; public interface PrivilegeRepository extends JpaRepository { diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/RoleRepository.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/RoleRepository.java similarity index 63% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/RoleRepository.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/RoleRepository.java index 25e3b3a1f6..e5833712fe 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/RoleRepository.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/RoleRepository.java @@ -1,6 +1,6 @@ -package org.baeldung.rolesauthorities.persistence; +package com.baeldung.roles.rolesauthorities.persistence; -import org.baeldung.rolesauthorities.model.Role; +import com.baeldung.roles.rolesauthorities.model.Role; import org.springframework.data.jpa.repository.JpaRepository; public interface RoleRepository extends JpaRepository { diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/SetupDataLoader.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/SetupDataLoader.java similarity index 93% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/SetupDataLoader.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/SetupDataLoader.java index 46dad4f06d..140fc56e53 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/SetupDataLoader.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/SetupDataLoader.java @@ -1,13 +1,13 @@ -package org.baeldung.rolesauthorities.persistence; +package com.baeldung.roles.rolesauthorities.persistence; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; -import org.baeldung.rolesauthorities.model.Privilege; -import org.baeldung.rolesauthorities.model.Role; -import org.baeldung.rolesauthorities.model.User; +import com.baeldung.roles.rolesauthorities.model.Privilege; +import com.baeldung.roles.rolesauthorities.model.Role; +import com.baeldung.roles.rolesauthorities.model.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationListener; import org.springframework.context.event.ContextRefreshedEvent; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/UserRepository.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/UserRepository.java similarity index 64% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/UserRepository.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/UserRepository.java index bca2953153..6801eec01d 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/UserRepository.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/UserRepository.java @@ -1,6 +1,6 @@ -package org.baeldung.rolesauthorities.persistence; +package com.baeldung.roles.rolesauthorities.persistence; -import org.baeldung.rolesauthorities.model.User; +import com.baeldung.roles.rolesauthorities.model.User; import org.springframework.data.jpa.repository.JpaRepository; public interface UserRepository extends JpaRepository { diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/UserService.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/UserService.java similarity index 77% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/UserService.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/UserService.java index 3b16c78898..17770e5cd0 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/UserService.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/rolesauthorities/persistence/UserService.java @@ -1,8 +1,8 @@ -package org.baeldung.rolesauthorities.persistence; +package com.baeldung.roles.rolesauthorities.persistence; import javax.transaction.Transactional; -import org.baeldung.rolesauthorities.model.User; +import com.baeldung.roles.rolesauthorities.model.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/voter/MinuteBasedVoter.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/voter/MinuteBasedVoter.java similarity index 96% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/voter/MinuteBasedVoter.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/voter/MinuteBasedVoter.java index 2beda1e557..6970441a4e 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/voter/MinuteBasedVoter.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/voter/MinuteBasedVoter.java @@ -1,4 +1,4 @@ -package org.baeldung.voter; +package com.baeldung.roles.voter; import java.time.LocalDateTime; import java.util.Collection; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/voter/VoterApplication.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/voter/VoterApplication.java similarity index 83% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/voter/VoterApplication.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/voter/VoterApplication.java index d2078e6115..d3e0652ae9 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/voter/VoterApplication.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/voter/VoterApplication.java @@ -1,4 +1,4 @@ -package org.baeldung.voter; +package com.baeldung.roles.voter; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -7,7 +7,7 @@ import org.springframework.context.annotation.Configuration; @Configuration @EnableAutoConfiguration -@ComponentScan(basePackages = { "org.baeldung.voter" }) +@ComponentScan(basePackages = {"com.baeldung.voter"}) public class VoterApplication { public static void main(String[] args) { diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/voter/VoterMvcConfig.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/voter/VoterMvcConfig.java similarity index 71% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/voter/VoterMvcConfig.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/voter/VoterMvcConfig.java index 8f41153f06..f11a4ae06c 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/voter/VoterMvcConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/voter/VoterMvcConfig.java @@ -1,10 +1,8 @@ -package org.baeldung.voter; +package com.baeldung.roles.voter; import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; /** * Created by ambrusadrianz on 30/09/2016. diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/voter/WebSecurityConfig.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/voter/WebSecurityConfig.java similarity index 96% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/voter/WebSecurityConfig.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/voter/WebSecurityConfig.java index 84ed070e8e..8a0f438b49 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/voter/WebSecurityConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/voter/WebSecurityConfig.java @@ -1,4 +1,4 @@ -package org.baeldung.voter; +package com.baeldung.roles.voter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -15,7 +15,6 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.access.expression.WebExpressionVoter; -import org.springframework.security.web.util.matcher.AntPathRequestMatcher; import java.util.Arrays; import java.util.List; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/voter/XmlSecurityConfig.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/voter/XmlSecurityConfig.java similarity index 60% rename from spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/voter/XmlSecurityConfig.java rename to spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/voter/XmlSecurityConfig.java index 8041585f42..0ef2ef51c7 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/voter/XmlSecurityConfig.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/com/baeldung/roles/voter/XmlSecurityConfig.java @@ -1,7 +1,4 @@ -package org.baeldung.voter; - -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.ImportResource; +package com.baeldung.roles.voter; /** * Created by ambrusadrianz on 09/10/2016. diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/IUserService.java b/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/IUserService.java deleted file mode 100644 index 2c508cbd20..0000000000 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/java/org/baeldung/rolesauthorities/persistence/IUserService.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.baeldung.rolesauthorities.persistence; - -import org.baeldung.rolesauthorities.model.User; - -public interface IUserService { - - User findUserByEmail(String email); - -} diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/main/resources/spring-security-custom-voter.xml b/spring-security-modules/spring-security-mvc-boot-1/src/main/resources/spring-security-custom-voter.xml index 0b334a3694..9f510280a1 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/main/resources/spring-security-custom-voter.xml +++ b/spring-security-modules/spring-security-mvc-boot-1/src/main/resources/spring-security-custom-voter.xml @@ -22,12 +22,12 @@ - + - + diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/test/java/com/baeldung/relationships/SpringDataWithSecurityIntegrationTest.java b/spring-security-modules/spring-security-mvc-boot-1/src/test/java/com/baeldung/relationships/SpringDataWithSecurityIntegrationTest.java index b2def82c51..54120650d9 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/test/java/com/baeldung/relationships/SpringDataWithSecurityIntegrationTest.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/test/java/com/baeldung/relationships/SpringDataWithSecurityIntegrationTest.java @@ -1,12 +1,11 @@ package com.baeldung.relationships; -import com.baeldung.AppConfig; -import com.baeldung.data.repositories.TweetRepository; -import com.baeldung.data.repositories.UserRepository; -import com.baeldung.models.AppUser; -import com.baeldung.models.Tweet; -import com.baeldung.security.AppUserPrincipal; -import com.baeldung.util.DummyContentUtil; +import com.baeldung.relationships.repositories.TweetRepository; +import com.baeldung.relationships.repositories.UserRepository; +import com.baeldung.relationships.models.AppUser; +import com.baeldung.relationships.models.Tweet; +import com.baeldung.relationships.security.AppUserPrincipal; +import com.baeldung.relationships.util.DummyContentUtil; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/test/java/org/baeldung/SpringContextTest.java b/spring-security-modules/spring-security-mvc-boot-1/src/test/java/com/baeldung/roles/SpringContextTest.java similarity index 83% rename from spring-security-modules/spring-security-mvc-boot-1/src/test/java/org/baeldung/SpringContextTest.java rename to spring-security-modules/spring-security-mvc-boot-1/src/test/java/com/baeldung/roles/SpringContextTest.java index 2041249b71..7b23b878c8 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/test/java/org/baeldung/SpringContextTest.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/test/java/com/baeldung/roles/SpringContextTest.java @@ -1,6 +1,6 @@ -package org.baeldung; +package com.baeldung.roles; -import org.baeldung.custom.Application; +import com.baeldung.roles.custom.Application; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/test/java/org/baeldung/web/ApplicationLiveTest.java b/spring-security-modules/spring-security-mvc-boot-1/src/test/java/com/baeldung/roles/web/ApplicationLiveTest.java similarity index 94% rename from spring-security-modules/spring-security-mvc-boot-1/src/test/java/org/baeldung/web/ApplicationLiveTest.java rename to spring-security-modules/spring-security-mvc-boot-1/src/test/java/com/baeldung/roles/web/ApplicationLiveTest.java index e199411e58..5a040b8dea 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/test/java/org/baeldung/web/ApplicationLiveTest.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/test/java/com/baeldung/roles/web/ApplicationLiveTest.java @@ -1,9 +1,9 @@ -package org.baeldung.web; +package com.baeldung.roles.web; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import org.baeldung.custom.persistence.model.Foo; +import com.baeldung.roles.custom.persistence.model.Foo; import io.restassured.RestAssured; import io.restassured.authentication.FormAuthConfig; @@ -13,7 +13,7 @@ import io.restassured.specification.RequestSpecification; import org.junit.Test; import org.springframework.http.MediaType; -// In order to execute these tests, org.baeldung.custom.Application needs to be running. +// In order to execute these tests, com.baeldung.custom.Application needs to be running. public class ApplicationLiveTest { @Test diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/test/java/org/baeldung/web/CustomUserDetailsServiceIntegrationTest.java b/spring-security-modules/spring-security-mvc-boot-1/src/test/java/com/baeldung/roles/web/CustomUserDetailsServiceIntegrationTest.java similarity index 95% rename from spring-security-modules/spring-security-mvc-boot-1/src/test/java/org/baeldung/web/CustomUserDetailsServiceIntegrationTest.java rename to spring-security-modules/spring-security-mvc-boot-1/src/test/java/com/baeldung/roles/web/CustomUserDetailsServiceIntegrationTest.java index d16acc729a..df7645150f 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/test/java/org/baeldung/web/CustomUserDetailsServiceIntegrationTest.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/test/java/com/baeldung/roles/web/CustomUserDetailsServiceIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.web; +package com.baeldung.roles.web; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; @@ -7,8 +7,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import org.apache.http.HttpHeaders; -import org.baeldung.custom.Application; -import org.baeldung.custom.persistence.model.Foo; +import com.baeldung.roles.custom.Application; +import com.baeldung.roles.custom.persistence.model.Foo; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; @@ -59,7 +59,7 @@ public class CustomUserDetailsServiceIntegrationTest { @WithAnonymousUser public void givenAnonymous_whenRequestFoo_thenRetrieveUnauthorized() throws Exception { this.mvc.perform(get("/foos/1").with(csrf())) - .andExpect(status().isUnauthorized()); + .andExpect(status().isFound()); } @Test diff --git a/spring-security-modules/spring-security-mvc-boot-1/src/test/java/org/baeldung/web/IpLiveTest.java b/spring-security-modules/spring-security-mvc-boot-1/src/test/java/com/baeldung/roles/web/IpLiveTest.java similarity index 90% rename from spring-security-modules/spring-security-mvc-boot-1/src/test/java/org/baeldung/web/IpLiveTest.java rename to spring-security-modules/spring-security-mvc-boot-1/src/test/java/com/baeldung/roles/web/IpLiveTest.java index 761f5450f7..2d0e2e5402 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/src/test/java/org/baeldung/web/IpLiveTest.java +++ b/spring-security-modules/spring-security-mvc-boot-1/src/test/java/com/baeldung/roles/web/IpLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.web; +package com.baeldung.roles.web; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -8,7 +8,7 @@ import io.restassured.response.Response; import org.junit.Test; -// In order to execute these tests, org.baeldung.ip.IpApplication needs to be running. +// In order to execute these tests, com.baeldung.ip.IpApplication needs to be running. public class IpLiveTest { @Test From 5c83dddb9182c0d74ba3685d6f5c7f09f7417681 Mon Sep 17 00:00:00 2001 From: Roger Yates <587230+rojyates@users.noreply.github.com> Date: Mon, 16 Mar 2020 06:23:33 +1000 Subject: [PATCH 05/73] BAEL-3603 Update method names and variable name for PR --- .../blockingnonblocking/BlockingClientUnitTest.java | 2 +- .../NonBlockingClientUnitTest.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/BlockingClientUnitTest.java b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/BlockingClientUnitTest.java index 3fc968ded0..cd3d688763 100644 --- a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/BlockingClientUnitTest.java +++ b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/BlockingClientUnitTest.java @@ -25,7 +25,7 @@ public class BlockingClientUnitTest { } @Test - public void givenJavaIOSocket_whenReadingAndWritingWithStreams_thenReadSuccessfully() throws IOException { + public void givenJavaIOSocket_whenReadingAndWritingWithStreams_thenSuccess() throws IOException { // given an IO socket and somewhere to store our result Socket socket = new Socket("localhost", wireMockRule.port()); StringBuilder ourStore = new StringBuilder(); diff --git a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java index 47115887ab..90edee0306 100644 --- a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java +++ b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java @@ -31,7 +31,7 @@ public class NonBlockingClientUnitTest { } @Test - public void givenJavaNIOSocketChannel_whenReadingAndWriting_thenUseBuffers() throws IOException { + public void givenJavaNIOSocketChannel_whenReadingAndWritingWithBuffers_thenSuccess() throws IOException { // given a NIO SocketChannel and a charset InetSocketAddress address = new InetSocketAddress("localhost", wireMockRule.port()); SocketChannel socketChannel = SocketChannel.open(address); @@ -58,25 +58,25 @@ public class NonBlockingClientUnitTest { } @Test - public void givenJavaNIO_whenReadingAndWriting_thenSmallBuffers() throws IOException { + public void givenJavaNIOSocketChannel_whenReadingAndWritingWithSmallBuffers_thenSuccess() throws IOException { // given a NIO SocketChannel and a charset InetSocketAddress address = new InetSocketAddress("localhost", wireMockRule.port()); - SocketChannel socket = SocketChannel.open(address); + SocketChannel socketChannel = SocketChannel.open(address); Charset charset = StandardCharsets.UTF_8; // when we write and read using buffers that are too small for our message - socket.write(charset.encode(CharBuffer.wrap("GET " + REQUESTED_RESOURCE + " HTTP/1.0\r\n\r\n"))); + socketChannel.write(charset.encode(CharBuffer.wrap("GET " + REQUESTED_RESOURCE + " HTTP/1.0\r\n\r\n"))); ByteBuffer buffer = ByteBuffer.allocate(8); // or allocateDirect if we need direct memory access CharBuffer charBuffer = CharBuffer.allocate(8); CharsetDecoder decoder = charset.newDecoder(); StringBuilder ourStore = new StringBuilder(); - while (socket.read(buffer) != -1 || buffer.position() > 0) { + while (socketChannel.read(buffer) != -1 || buffer.position() > 0) { buffer.flip(); storeBufferContents(buffer, charBuffer, decoder, ourStore); buffer.compact(); } - socket.close(); + socketChannel.close(); // then we read and saved our data assertTrue(ourStore From 0b8b9715c6e1b3c6349db051f63688bf315542c0 Mon Sep 17 00:00:00 2001 From: Antonio Moreno Date: Thu, 6 Feb 2020 22:55:09 +0000 Subject: [PATCH 06/73] BAEL-3635 Intro to Alibaba Arthas Adding a case study to show Arthas. --- .../baeldung/arthas/FibonacciGenerator.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 libraries-3/src/main/java/com/baeldung/arthas/FibonacciGenerator.java diff --git a/libraries-3/src/main/java/com/baeldung/arthas/FibonacciGenerator.java b/libraries-3/src/main/java/com/baeldung/arthas/FibonacciGenerator.java new file mode 100644 index 0000000000..27cf0dacf6 --- /dev/null +++ b/libraries-3/src/main/java/com/baeldung/arthas/FibonacciGenerator.java @@ -0,0 +1,25 @@ +package com.baeldung.arthas; + +import java.io.IOException; + +import static java.lang.String.format; + +public class FibonacciGenerator { + + public static void main(String[] args) throws IOException { + System.out.println("Press a key to continue"); + System.in.read(); + for (int i = 0; i < 100; i++) { + long result = fibonacci(i); + System.out.println(format("fib(%d): %d", i, result)); + } + } + + public static long fibonacci(int n) { + if (n == 0 || n == 1) { + return 1L; + } else { + return fibonacci(n - 1) + fibonacci(n - 2); + } + } +} From 38843e814bfcee140d766957f63514e984210230 Mon Sep 17 00:00:00 2001 From: Roger Yates <587230+rojyates@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:32:39 +1000 Subject: [PATCH 07/73] BAEL-3603 Update variable names --- .../NonBlockingClientUnitTest.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java index 90edee0306..838d456f03 100644 --- a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java +++ b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java @@ -40,14 +40,14 @@ public class NonBlockingClientUnitTest { // when we write and read using buffers socketChannel.write(charset.encode(CharBuffer.wrap("GET " + REQUESTED_RESOURCE + " HTTP/1.0\r\n\r\n"))); - ByteBuffer buffer = ByteBuffer.allocate(8); // or allocateDirect if we need direct memory access + ByteBuffer byteBuffer = ByteBuffer.allocate(8192); // or allocateDirect if we need direct memory access CharBuffer charBuffer = CharBuffer.allocate(8192); - CharsetDecoder decoder = charset.newDecoder(); + CharsetDecoder charsetDecoder = charset.newDecoder(); StringBuilder ourStore = new StringBuilder(); - while (socketChannel.read(buffer) != -1 || buffer.position() > 0) { - buffer.flip(); - storeBufferContents(buffer, charBuffer, decoder, ourStore); - buffer.compact(); + while (socketChannel.read(byteBuffer) != -1 || byteBuffer.position() > 0) { + byteBuffer.flip(); + storeBufferContents(byteBuffer, charBuffer, charsetDecoder, ourStore); + byteBuffer.compact(); } socketChannel.close(); @@ -67,14 +67,14 @@ public class NonBlockingClientUnitTest { // when we write and read using buffers that are too small for our message socketChannel.write(charset.encode(CharBuffer.wrap("GET " + REQUESTED_RESOURCE + " HTTP/1.0\r\n\r\n"))); - ByteBuffer buffer = ByteBuffer.allocate(8); // or allocateDirect if we need direct memory access + ByteBuffer byteBuffer = ByteBuffer.allocate(8); // or allocateDirect if we need direct memory access CharBuffer charBuffer = CharBuffer.allocate(8); - CharsetDecoder decoder = charset.newDecoder(); + CharsetDecoder charsetDecoder = charset.newDecoder(); StringBuilder ourStore = new StringBuilder(); - while (socketChannel.read(buffer) != -1 || buffer.position() > 0) { - buffer.flip(); - storeBufferContents(buffer, charBuffer, decoder, ourStore); - buffer.compact(); + while (socketChannel.read(byteBuffer) != -1 || byteBuffer.position() > 0) { + byteBuffer.flip(); + storeBufferContents(byteBuffer, charBuffer, charsetDecoder, ourStore); + byteBuffer.compact(); } socketChannel.close(); From 0f5889567e3dc1cb1d7fff20e855a30f81842a14 Mon Sep 17 00:00:00 2001 From: Roger Yates <587230+rojyates@users.noreply.github.com> Date: Tue, 17 Mar 2020 06:35:29 +1000 Subject: [PATCH 08/73] BAEL-3603 Update variable names --- .../blockingnonblocking/NonBlockingClientUnitTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java index 838d456f03..3e606476e6 100644 --- a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java +++ b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/blockingnonblocking/NonBlockingClientUnitTest.java @@ -84,8 +84,8 @@ public class NonBlockingClientUnitTest { .contains("It worked!")); } - void storeBufferContents(ByteBuffer buffer, CharBuffer charBuffer, CharsetDecoder decoder, StringBuilder ourStore) { - decoder.decode(buffer, charBuffer, true); + void storeBufferContents(ByteBuffer byteBuffer, CharBuffer charBuffer, CharsetDecoder charsetDecoder, StringBuilder ourStore) { + charsetDecoder.decode(byteBuffer, charBuffer, true); charBuffer.flip(); ourStore.append(charBuffer); charBuffer.clear(); From a1973baca1eac87a03cc5eea5881097d2c203625 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 17 Mar 2020 19:04:55 +0800 Subject: [PATCH 09/73] Update README.md --- custom-pmd/README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/custom-pmd/README.md b/custom-pmd/README.md index 0c42106fe8..d49047f180 100644 --- a/custom-pmd/README.md +++ b/custom-pmd/README.md @@ -1,7 +1,3 @@ ## Custom PMD Rules This module contains articles about PMD - -### Relevant Articles: - -- [Introduction To PMD](https://www.baeldung.com/pmd) \ No newline at end of file From 148ca99aef2ae569f4bf73b33d4ba0f9bf9db4fe Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 17 Mar 2020 19:05:32 +0800 Subject: [PATCH 10/73] Delete README.md --- .../README.md | 159 ------------------ 1 file changed, 159 deletions(-) delete mode 100644 spring-swagger-codegen/spring-swagger-codegen-api-client/README.md diff --git a/spring-swagger-codegen/spring-swagger-codegen-api-client/README.md b/spring-swagger-codegen/spring-swagger-codegen-api-client/README.md deleted file mode 100644 index cffab6b9c7..0000000000 --- a/spring-swagger-codegen/spring-swagger-codegen-api-client/README.md +++ /dev/null @@ -1,159 +0,0 @@ -## Spring Swagger Codegen API Client - -This module contains the code for [Generate Spring Boot REST Client with Swagger](http://www.baeldung.com/spring-boot-rest-client-swagger-codegen). - -## Requirements - -Building the API client library requires [Maven](https://maven.apache.org/) to be installed. - -## Installation - -To install the API client library to your local Maven repository, simply execute: - -```shell -mvn install -``` - -To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: - -```shell -mvn deploy -``` - -Refer to the [official documentation](https://maven.apache.org/plugins/maven-deploy-plugin/usage.html) for more information. - -### Maven users - -Add this dependency to your project's POM: - -```xml - - com.baeldung - spring-swagger-codegen-api-client - 0.0.1-SNAPSHOT - compile - -``` - -### Gradle users - -Add this dependency to your project's build file: - -```groovy -compile "com.baeldung:spring-swagger-codegen-api-client:0.0.1-SNAPSHOT" -``` - -### Others - -At first generate the JAR by executing: - - mvn package - -Then manually install the following JARs: - -* target/spring-swagger-codegen-api-client-0.0.1-SNAPSHOT.jar -* target/lib/*.jar - -## Getting Started - -Please follow the [installation](#installation) instruction and execute the following Java code: - -```java - -import com.baeldung.petstore.client.invoker.*; -import com.baeldung.petstore.client.invoker.auth.*; -import com.baeldung.petstore.client.model.*; -import com.baeldung.petstore.client.api.PetApi; - -import java.io.File; -import java.util.*; - -public class PetApiExample { - - public static void main(String[] args) { - ApiClient defaultClient = Configuration.getDefaultApiClient(); - - // Configure OAuth2 access token for authorization: petstore_auth - OAuth petstore_auth = (OAuth) defaultClient.getAuthentication("petstore_auth"); - petstore_auth.setAccessToken("YOUR ACCESS TOKEN"); - - PetApi apiInstance = new PetApi(); - Pet body = new Pet(); // Pet | Pet object that needs to be added to the store - try { - apiInstance.addPet(body); - } catch (ApiException e) { - System.err.println("Exception when calling PetApi#addPet"); - e.printStackTrace(); - } - } -} - -``` - -## Documentation for API Endpoints - -All URIs are relative to *http://petstore.swagger.io/v2* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -*PetApi* | [**addPet**](docs/PetApi.md#addPet) | **POST** /pet | Add a new pet to the store -*PetApi* | [**deletePet**](docs/PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet -*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status -*PetApi* | [**findPetsByTags**](docs/PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags -*PetApi* | [**getPetById**](docs/PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID -*PetApi* | [**updatePet**](docs/PetApi.md#updatePet) | **PUT** /pet | Update an existing pet -*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data -*PetApi* | [**uploadFile**](docs/PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image -*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -*StoreApi* | [**getInventory**](docs/StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status -*StoreApi* | [**getOrderById**](docs/StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID -*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet -*UserApi* | [**createUser**](docs/UserApi.md#createUser) | **POST** /user | Create user -*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array -*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array -*UserApi* | [**deleteUser**](docs/UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user -*UserApi* | [**getUserByName**](docs/UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name -*UserApi* | [**loginUser**](docs/UserApi.md#loginUser) | **GET** /user/login | Logs user into the system -*UserApi* | [**logoutUser**](docs/UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session -*UserApi* | [**updateUser**](docs/UserApi.md#updateUser) | **PUT** /user/{username} | Updated user - - -## Documentation for Models - - - [Category](docs/Category.md) - - [ModelApiResponse](docs/ModelApiResponse.md) - - [Order](docs/Order.md) - - [Pet](docs/Pet.md) - - [Tag](docs/Tag.md) - - [User](docs/User.md) - - -## Documentation for Authorization - -Authentication schemes defined for the API: -### api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - -### petstore_auth - -- **Type**: OAuth -- **Flow**: implicit -- **Authorization URL**: http://petstore.swagger.io/oauth/dialog -- **Scopes**: - - write:pets: modify pets in your account - - read:pets: read your pets - - -## Recommendation - -It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues. - -## Author - -apiteam@swagger.io - - - From ca6c9c018827d0abbeee966cdbf62aa958f6ce91 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 17 Mar 2020 19:06:38 +0800 Subject: [PATCH 11/73] Update README.md --- ddd/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/ddd/README.md b/ddd/README.md index cd7cf90d61..ad84dc40b2 100644 --- a/ddd/README.md +++ b/ddd/README.md @@ -6,5 +6,4 @@ This module contains articles about Domain-driven Design (DDD) - [Persisting DDD Aggregates](https://www.baeldung.com/spring-persisting-ddd-aggregates) - [Double Dispatch in DDD](https://www.baeldung.com/ddd-double-dispatch) -- [DDD Aggregates and @DomainEvents](https://www.baeldung.com/spring-data-ddd) - [Organizing Layers Using Hexagonal Architecture, DDD, and Spring](https://www.baeldung.com/hexagonal-architecture-ddd-spring) From 994a5531c2518826c5610cf85b5d6d440fbb0234 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 17 Mar 2020 19:08:26 +0800 Subject: [PATCH 12/73] Update README.md --- rxjava-core/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/rxjava-core/README.md b/rxjava-core/README.md index 95a374668d..2773bd9423 100644 --- a/rxjava-core/README.md +++ b/rxjava-core/README.md @@ -13,5 +13,4 @@ This module contains articles about RxJava. - [RxJava Maybe](https://www.baeldung.com/rxjava-maybe) - [Combining RxJava Completables](https://www.baeldung.com/rxjava-completable) - [RxJava Hooks](https://www.baeldung.com/rxjava-hooks) -- [Introduction to rxjava-jdbc](https://www.baeldung.com/rxjava-jdbc) - More articles: [[next -->]](/rxjava-2) From 369cfe24ab46db81083898b2aa51e0d4f8a375b3 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 17 Mar 2020 19:09:27 +0800 Subject: [PATCH 13/73] Update README.md --- core-java-modules/core-java-9-improvements/README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/core-java-modules/core-java-9-improvements/README.md b/core-java-modules/core-java-9-improvements/README.md index 5864170e85..c89d0e3c09 100644 --- a/core-java-modules/core-java-9-improvements/README.md +++ b/core-java-modules/core-java-9-improvements/README.md @@ -9,8 +9,3 @@ This module contains articles about the improvements to core Java features intro - [Java 9 Stream API Improvements](https://www.baeldung.com/java-9-stream-api) - [Java 9 java.util.Objects Additions](https://www.baeldung.com/java-9-objects-new) - [Java 9 CompletableFuture API Improvements](https://www.baeldung.com/java-9-completablefuture) - -#### Relevant articles not in this module: - -- [Java 9 Process API Improvements](https://www.baeldung.com/java-9-process-api) (see the [core-java-os](/core-java-os) module) - From e478767d6af17869672ac40cd906764dfa3db8ac Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 17 Mar 2020 19:10:07 +0800 Subject: [PATCH 14/73] Update README.md --- spring-boot-modules/spring-boot-mvc-2/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-mvc-2/README.md b/spring-boot-modules/spring-boot-mvc-2/README.md index cb0eea4c2a..dc6a136131 100644 --- a/spring-boot-modules/spring-boot-mvc-2/README.md +++ b/spring-boot-modules/spring-boot-mvc-2/README.md @@ -6,4 +6,4 @@ This module contains articles about Spring Web MVC in Spring Boot projects. - [Functional Controllers in Spring MVC](https://www.baeldung.com/spring-mvc-functional-controllers) - [Specify an Array of Strings as Body Parameters in Swagger](https://www.baeldung.com/swagger-body-array-of-strings) -- More articles: [[prev -->]](/spring-boot-mvc) +- More articles: [[prev -->]](/spring-boot-modules/spring-boot-mvc) From 71b2a9308f8423ea3b38fc4a2fc19e38468af900 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Tue, 17 Mar 2020 19:10:55 +0800 Subject: [PATCH 15/73] Update README.md --- spring-boot-modules/spring-boot-mvc/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-modules/spring-boot-mvc/README.md b/spring-boot-modules/spring-boot-mvc/README.md index b4f87d1d40..2e67c42ede 100644 --- a/spring-boot-modules/spring-boot-mvc/README.md +++ b/spring-boot-modules/spring-boot-mvc/README.md @@ -10,4 +10,4 @@ This module contains articles about Spring Web MVC in Spring Boot projects. - [A Controller, Service and DAO Example with Spring Boot and JSF](https://www.baeldung.com/jsf-spring-boot-controller-service-dao) - [Setting Up Swagger 2 with a Spring REST API](https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api) - [Using Spring ResponseEntity to Manipulate the HTTP Response](https://www.baeldung.com/spring-response-entity) -- More articles: [[next -->]](/spring-boot-mvc-2) +- More articles: [[next -->]](/spring-boot-modules/spring-boot-mvc-2) From 4131d1ebbd6974b494a70471be3696b186c4626e Mon Sep 17 00:00:00 2001 From: Graham Cox Date: Tue, 17 Mar 2020 14:30:46 +0000 Subject: [PATCH 16/73] Moved the Moshi examples to json-2 (#8898) --- json-2/pom.xml | 17 +++++++++++++++++ .../moshi/AlternativeAdapterUnitTest.java | 0 .../java/com/baeldung/moshi/ArrayUnitTest.java | 0 .../baeldung/moshi/ComplexAdapterUnitTest.java | 0 .../com/baeldung/moshi/DefaultUnitTest.java | 0 .../com/baeldung/moshi/PrimitiveUnitTest.java | 0 .../java/com/baeldung/moshi/RenameUnitTest.java | 0 .../baeldung/moshi/SimpleAdapterUnitTest.java | 0 .../com/baeldung/moshi/TransientUnitTest.java | 0 libraries-3/pom.xml | 11 ----------- 10 files changed, 17 insertions(+), 11 deletions(-) rename {libraries-3 => json-2}/src/test/java/com/baeldung/moshi/AlternativeAdapterUnitTest.java (100%) rename {libraries-3 => json-2}/src/test/java/com/baeldung/moshi/ArrayUnitTest.java (100%) rename {libraries-3 => json-2}/src/test/java/com/baeldung/moshi/ComplexAdapterUnitTest.java (100%) rename {libraries-3 => json-2}/src/test/java/com/baeldung/moshi/DefaultUnitTest.java (100%) rename {libraries-3 => json-2}/src/test/java/com/baeldung/moshi/PrimitiveUnitTest.java (100%) rename {libraries-3 => json-2}/src/test/java/com/baeldung/moshi/RenameUnitTest.java (100%) rename {libraries-3 => json-2}/src/test/java/com/baeldung/moshi/SimpleAdapterUnitTest.java (100%) rename {libraries-3 => json-2}/src/test/java/com/baeldung/moshi/TransientUnitTest.java (100%) diff --git a/json-2/pom.xml b/json-2/pom.xml index 72b3295b2b..e0295af59b 100644 --- a/json-2/pom.xml +++ b/json-2/pom.xml @@ -33,9 +33,26 @@ ${assertj-core.version} test + + + com.squareup.moshi + moshi + ${moshi.version} + + + com.squareup.moshi + moshi-adapters + ${moshi.version} + + + org.apache.commons + commons-lang3 + 3.9 + 0.9.23 3.11.1 + 1.9.2 diff --git a/libraries-3/src/test/java/com/baeldung/moshi/AlternativeAdapterUnitTest.java b/json-2/src/test/java/com/baeldung/moshi/AlternativeAdapterUnitTest.java similarity index 100% rename from libraries-3/src/test/java/com/baeldung/moshi/AlternativeAdapterUnitTest.java rename to json-2/src/test/java/com/baeldung/moshi/AlternativeAdapterUnitTest.java diff --git a/libraries-3/src/test/java/com/baeldung/moshi/ArrayUnitTest.java b/json-2/src/test/java/com/baeldung/moshi/ArrayUnitTest.java similarity index 100% rename from libraries-3/src/test/java/com/baeldung/moshi/ArrayUnitTest.java rename to json-2/src/test/java/com/baeldung/moshi/ArrayUnitTest.java diff --git a/libraries-3/src/test/java/com/baeldung/moshi/ComplexAdapterUnitTest.java b/json-2/src/test/java/com/baeldung/moshi/ComplexAdapterUnitTest.java similarity index 100% rename from libraries-3/src/test/java/com/baeldung/moshi/ComplexAdapterUnitTest.java rename to json-2/src/test/java/com/baeldung/moshi/ComplexAdapterUnitTest.java diff --git a/libraries-3/src/test/java/com/baeldung/moshi/DefaultUnitTest.java b/json-2/src/test/java/com/baeldung/moshi/DefaultUnitTest.java similarity index 100% rename from libraries-3/src/test/java/com/baeldung/moshi/DefaultUnitTest.java rename to json-2/src/test/java/com/baeldung/moshi/DefaultUnitTest.java diff --git a/libraries-3/src/test/java/com/baeldung/moshi/PrimitiveUnitTest.java b/json-2/src/test/java/com/baeldung/moshi/PrimitiveUnitTest.java similarity index 100% rename from libraries-3/src/test/java/com/baeldung/moshi/PrimitiveUnitTest.java rename to json-2/src/test/java/com/baeldung/moshi/PrimitiveUnitTest.java diff --git a/libraries-3/src/test/java/com/baeldung/moshi/RenameUnitTest.java b/json-2/src/test/java/com/baeldung/moshi/RenameUnitTest.java similarity index 100% rename from libraries-3/src/test/java/com/baeldung/moshi/RenameUnitTest.java rename to json-2/src/test/java/com/baeldung/moshi/RenameUnitTest.java diff --git a/libraries-3/src/test/java/com/baeldung/moshi/SimpleAdapterUnitTest.java b/json-2/src/test/java/com/baeldung/moshi/SimpleAdapterUnitTest.java similarity index 100% rename from libraries-3/src/test/java/com/baeldung/moshi/SimpleAdapterUnitTest.java rename to json-2/src/test/java/com/baeldung/moshi/SimpleAdapterUnitTest.java diff --git a/libraries-3/src/test/java/com/baeldung/moshi/TransientUnitTest.java b/json-2/src/test/java/com/baeldung/moshi/TransientUnitTest.java similarity index 100% rename from libraries-3/src/test/java/com/baeldung/moshi/TransientUnitTest.java rename to json-2/src/test/java/com/baeldung/moshi/TransientUnitTest.java diff --git a/libraries-3/pom.xml b/libraries-3/pom.xml index a438d423e2..68b5f2aa21 100644 --- a/libraries-3/pom.xml +++ b/libraries-3/pom.xml @@ -73,16 +73,6 @@ ${cache2k.version} pom - - com.squareup.moshi - moshi - ${moshi.version} - - - com.squareup.moshi - moshi-adapters - ${moshi.version} - com.jcabi jcabi-aspects @@ -201,7 +191,6 @@ 0.43 2.7.2 1.2.3.Final - 1.9.2 0.22.6 1.9.2 0.14.1 From 8c56c4ef43c7f9d6edbddececf6f2d0ae0833579 Mon Sep 17 00:00:00 2001 From: George Haris <40850523+gecharita@users.noreply.github.com> Date: Tue, 17 Mar 2020 22:31:11 +0200 Subject: [PATCH 17/73] BAEL-3835 (#8901) * BAEL-3835: Inject a value to a static field * BAEL-3835: integration of code into the src directory Co-authored-by: Georgios Charitakis --- .../staticvalue/injection/Application.java | 16 ++++++++++ .../injection/PropertyController.java | 30 +++++++++++++++++++ .../src/main/resources/application.properties | 1 + 3 files changed, 47 insertions(+) create mode 100644 spring-core-3/src/main/java/com/baeldung/staticvalue/injection/Application.java create mode 100644 spring-core-3/src/main/java/com/baeldung/staticvalue/injection/PropertyController.java create mode 100644 spring-core-3/src/main/resources/application.properties diff --git a/spring-core-3/src/main/java/com/baeldung/staticvalue/injection/Application.java b/spring-core-3/src/main/java/com/baeldung/staticvalue/injection/Application.java new file mode 100644 index 0000000000..45c47c955f --- /dev/null +++ b/spring-core-3/src/main/java/com/baeldung/staticvalue/injection/Application.java @@ -0,0 +1,16 @@ +package com.baeldung.staticvalue.injection; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.PropertySource; + +@SpringBootApplication +@PropertySource("/application.properties") + +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/spring-core-3/src/main/java/com/baeldung/staticvalue/injection/PropertyController.java b/spring-core-3/src/main/java/com/baeldung/staticvalue/injection/PropertyController.java new file mode 100644 index 0000000000..f5910ea4f8 --- /dev/null +++ b/spring-core-3/src/main/java/com/baeldung/staticvalue/injection/PropertyController.java @@ -0,0 +1,30 @@ +package com.baeldung.staticvalue.injection; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Arrays; +import java.util.List; + +@RestController +public class PropertyController { + + @Value("${name}") + private String name; + + @Value("${name}") + private static String NAME_NULL; + + private static String NAME_STATIC; + + @Value("${name}") + public void setNameStatic(String name){ + PropertyController.NAME_STATIC = name; + } + + @GetMapping("/properties") + public List getProperties(){ + return Arrays.asList(this.name, NAME_STATIC, NAME_NULL) ; + } +} diff --git a/spring-core-3/src/main/resources/application.properties b/spring-core-3/src/main/resources/application.properties new file mode 100644 index 0000000000..828fa9cd2a --- /dev/null +++ b/spring-core-3/src/main/resources/application.properties @@ -0,0 +1 @@ +name = Inject a value to a static field From 5b154ca3325c63472acc0b3b1f11abb74cce066a Mon Sep 17 00:00:00 2001 From: Sam Millington Date: Tue, 17 Mar 2020 20:42:04 +0000 Subject: [PATCH 18/73] Delete static-value-injection folder (#8902) Co-authored-by: SBLUKcic --- .../static-value-injection/README.md | 22 -------- spring-core-3/static-value-injection/pom.xml | 52 ------------------- .../main/java/com/baeldung/Application.java | 13 ----- .../controller/PropertyController.java | 31 ----------- .../src/main/resources/application.properties | 1 - .../java/com/baeldung/ApplicationTests.java | 13 ----- 6 files changed, 132 deletions(-) delete mode 100644 spring-core-3/static-value-injection/README.md delete mode 100644 spring-core-3/static-value-injection/pom.xml delete mode 100644 spring-core-3/static-value-injection/src/main/java/com/baeldung/Application.java delete mode 100644 spring-core-3/static-value-injection/src/main/java/com/baeldung/controller/PropertyController.java delete mode 100644 spring-core-3/static-value-injection/src/main/resources/application.properties delete mode 100644 spring-core-3/static-value-injection/src/test/java/com/baeldung/ApplicationTests.java diff --git a/spring-core-3/static-value-injection/README.md b/spring-core-3/static-value-injection/README.md deleted file mode 100644 index 06dfa29f80..0000000000 --- a/spring-core-3/static-value-injection/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# Inject a value to a static field - -## How to run -```sh -mvn clean install -mvn spring-boot:run -``` - -## Request - -**GET** -http://localhost:8080/properties - - -## Response -```json -[ - "Inject a value to a static field", - "Inject a value to a static field", - null -] -``` diff --git a/spring-core-3/static-value-injection/pom.xml b/spring-core-3/static-value-injection/pom.xml deleted file mode 100644 index aa45fde886..0000000000 --- a/spring-core-3/static-value-injection/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.2.4.RELEASE - - - com.baeldung - static.value.injection - 0.0.1-SNAPSHOT - static.value.injection - Demo project for Spring Boot - - - 1.8 - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.vintage - junit-vintage-engine - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/spring-core-3/static-value-injection/src/main/java/com/baeldung/Application.java b/spring-core-3/static-value-injection/src/main/java/com/baeldung/Application.java deleted file mode 100644 index c1875216b5..0000000000 --- a/spring-core-3/static-value-injection/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-core-3/static-value-injection/src/main/java/com/baeldung/controller/PropertyController.java b/spring-core-3/static-value-injection/src/main/java/com/baeldung/controller/PropertyController.java deleted file mode 100644 index 03a2518117..0000000000 --- a/spring-core-3/static-value-injection/src/main/java/com/baeldung/controller/PropertyController.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.baeldung.controller; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.Arrays; -import java.util.List; - -@RestController -public class PropertyController { - - @Value("${name}") - private String name; - - @Value("${name}") - private static String NAME_NULL; - - private static String NAME_STATIC; - - @Value("${name}") - public void setNameStatic(String name){ - PropertyController.NAME_STATIC = name; - } - - @GetMapping("/properties") - public List getProperties(){ - return Arrays.asList(this.name, NAME_STATIC, NAME_NULL) ; - } -} diff --git a/spring-core-3/static-value-injection/src/main/resources/application.properties b/spring-core-3/static-value-injection/src/main/resources/application.properties deleted file mode 100644 index 828fa9cd2a..0000000000 --- a/spring-core-3/static-value-injection/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -name = Inject a value to a static field diff --git a/spring-core-3/static-value-injection/src/test/java/com/baeldung/ApplicationTests.java b/spring-core-3/static-value-injection/src/test/java/com/baeldung/ApplicationTests.java deleted file mode 100644 index 4ad83bc539..0000000000 --- a/spring-core-3/static-value-injection/src/test/java/com/baeldung/ApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.baeldung; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class ApplicationTests { - - @Test - void contextLoads() { - } - -} From 54c1d28b2ee66077f42f16eadd8a17304e0f3cd1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:08:48 +0800 Subject: [PATCH 19/73] Create README.md --- spring-threads/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 spring-threads/README.md diff --git a/spring-threads/README.md b/spring-threads/README.md new file mode 100644 index 0000000000..c3762cd86f --- /dev/null +++ b/spring-threads/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [ThreadPoolTaskExecutor corePoolSize vs. maxPoolSize](https://www.baeldung.com/java-threadpooltaskexecutor-core-vs-max-poolsize) From fbb59ff98b2b4e26c99aac6186da132411dc3599 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:13:12 +0800 Subject: [PATCH 20/73] Create README.md --- gradle/gradle-to-maven/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 gradle/gradle-to-maven/README.md diff --git a/gradle/gradle-to-maven/README.md b/gradle/gradle-to-maven/README.md new file mode 100644 index 0000000000..9acbfb1647 --- /dev/null +++ b/gradle/gradle-to-maven/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Converting Gradle Build File to Maven POM](https://www.baeldung.com/gradle-build-to-maven-pom) From 57c66c0906c43f5dcf8df09bc47fbfbd4892b3cb Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:15:40 +0800 Subject: [PATCH 21/73] 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 42e4619a59..3884435f75 100644 --- a/persistence-modules/spring-data-jpa-4/README.md +++ b/persistence-modules/spring-data-jpa-4/README.md @@ -5,6 +5,7 @@ - [Programmatic Transaction Management in Spring](https://www.baeldung.com/spring-programmatic-transaction-management) - [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) ### Eclipse Config After importing the project into Eclipse, you may see the following error: From 7a445ff86c815cbc87c9f86164ad400c1b3b4f4c Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:18:27 +0800 Subject: [PATCH 22/73] Update README.md --- spring-amqp/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-amqp/README.md b/spring-amqp/README.md index 6b09aec10a..7d202f49f8 100644 --- a/spring-amqp/README.md +++ b/spring-amqp/README.md @@ -7,3 +7,4 @@ This module contains articles about Spring with the AMQP messaging system - [Messaging With Spring AMQP](https://www.baeldung.com/spring-amqp) - [RabbitMQ Message Dispatching with Spring AMQP](https://www.baeldung.com/rabbitmq-spring-amqp) - [Error Handling with Spring AMQP](https://www.baeldung.com/spring-amqp-error-handling) +- [Exponential Backoff With Spring AMQP](https://www.baeldung.com/spring-amqp-exponential-backoff) From d46ed5c784426fd9bf454451f00f3411737438f5 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:20:03 +0800 Subject: [PATCH 23/73] Update README.md --- json-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/json-2/README.md b/json-2/README.md index b0f49f0e48..c2b6b36a11 100644 --- a/json-2/README.md +++ b/json-2/README.md @@ -4,3 +4,4 @@ This module contains articles about JSON. ### Relevant Articles: - [Introduction to Jsoniter](https://www.baeldung.com/java-jsoniter) +- [Introduction to Moshi Json](https://www.baeldung.com/java-json-moshi) From e11224d89aae2d91549635c72f59c9ade3063201 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:22:52 +0800 Subject: [PATCH 24/73] 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 08e8dae8ef..835b8b0b54 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) +- [Check for null Before Calling Parse in Double.parseDouble](https://www.baeldung.com/java-check-null-parse-double) From 98c4810ae4f22f62628f4f310d9ad2eaa93eb2da Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:26:04 +0800 Subject: [PATCH 25/73] Update README.md --- core-java-modules/core-java-nio-2/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core-java-modules/core-java-nio-2/README.md b/core-java-modules/core-java-nio-2/README.md index 8b29c97385..ef73159f66 100644 --- a/core-java-modules/core-java-nio-2/README.md +++ b/core-java-modules/core-java-nio-2/README.md @@ -8,4 +8,5 @@ This module contains articles about core Java non-blocking input and output (IO) - [Create a Symbolic Link with Java](https://www.baeldung.com/java-symlink) - [Introduction to the Java NIO Selector](https://www.baeldung.com/java-nio-selector) - [Using Java MappedByteBuffer](https://www.baeldung.com/java-mapped-byte-buffer) -- [[<-- Prev]](/core-java-modules/core-java-nio) \ No newline at end of file +- [How to Lock a File in Java](https://www.baeldung.com/java-lock-files) +- [[<-- Prev]](/core-java-modules/core-java-nio) From 2c04d869770746c2a971221f441dc25e8d6a4e87 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:28:35 +0800 Subject: [PATCH 26/73] Update README.md --- spring-boot-modules/spring-boot-mvc-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-mvc-2/README.md b/spring-boot-modules/spring-boot-mvc-2/README.md index dc6a136131..4200f58024 100644 --- a/spring-boot-modules/spring-boot-mvc-2/README.md +++ b/spring-boot-modules/spring-boot-mvc-2/README.md @@ -6,4 +6,5 @@ This module contains articles about Spring Web MVC in Spring Boot projects. - [Functional Controllers in Spring MVC](https://www.baeldung.com/spring-mvc-functional-controllers) - [Specify an Array of Strings as Body Parameters in Swagger](https://www.baeldung.com/swagger-body-array-of-strings) +- [Swagger @ApiParam vs @ApiModelProperty](https://www.baeldung.com/swagger-apiparam-vs-apimodelproperty) - More articles: [[prev -->]](/spring-boot-modules/spring-boot-mvc) From 020a62b92cd3bae37f2b11afba3158267d078723 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:32:33 +0800 Subject: [PATCH 27/73] Create README.md --- play-framework/async-http/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 play-framework/async-http/README.md diff --git a/play-framework/async-http/README.md b/play-framework/async-http/README.md new file mode 100644 index 0000000000..c42b86ad4e --- /dev/null +++ b/play-framework/async-http/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Asynchronous HTTP Programming with Play Framework](https://www.baeldung.com/java-play-asynchronous-http-programming) From 08e438fce277e9eae280d23f5862978093153058 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:39:29 +0800 Subject: [PATCH 28/73] Update README.md --- spring-rest-http/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-rest-http/README.md b/spring-rest-http/README.md index 54b31e80c4..35793cb281 100644 --- a/spring-rest-http/README.md +++ b/spring-rest-http/README.md @@ -12,3 +12,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Returning Custom Status Codes from Spring Controllers](https://www.baeldung.com/spring-mvc-controller-custom-http-status-code) - [Spring RequestMapping](https://www.baeldung.com/spring-requestmapping) - [Guide to DeferredResult in Spring](https://www.baeldung.com/spring-deferred-result) +- [Using JSON Patch in Spring REST APIs](https://www.baeldung.com/spring-rest-json-patch) From 96c2e93de5b7c5b9f827b299acbee2c122221fd0 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:42:31 +0800 Subject: [PATCH 29/73] Update README.md --- spring-batch/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-batch/README.md b/spring-batch/README.md index 99ac9826bc..d637de269c 100644 --- a/spring-batch/README.md +++ b/spring-batch/README.md @@ -9,3 +9,4 @@ This module contains articles about Spring Batch - [How to Trigger and Stop a Scheduled Spring Batch Job](https://www.baeldung.com/spring-batch-start-stop-job) - [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) From fd4fce26775b4445b66e62b2b7412cf425187461 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:46:41 +0800 Subject: [PATCH 30/73] 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 404045e6b1..a5be14a349 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) +- [Introduction to the jcabi-aspects AOP Annotations Library](https://www.baeldung.com/java-jcabi-aspects) From 89e0499ea650bc043b284a6d57dc764e598a32a4 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:49:21 +0800 Subject: [PATCH 31/73] Update README.md --- spring-cloud/spring-cloud-zuul/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-cloud/spring-cloud-zuul/README.md b/spring-cloud/spring-cloud-zuul/README.md index b8e1773930..acd56a213c 100644 --- a/spring-cloud/spring-cloud-zuul/README.md +++ b/spring-cloud/spring-cloud-zuul/README.md @@ -5,3 +5,4 @@ This module contains articles about Spring with Netflix Zuul ### Relevant Articles: - [Rate Limiting in Spring Cloud Netflix Zuul](https://www.baeldung.com/spring-cloud-zuul-rate-limit) - [Spring REST with a Zuul Proxy](https://www.baeldung.com/spring-rest-with-zuul-proxy) +- [Modifying the Response Body in a Zuul Filter](https://www.baeldung.com/zuul-filter-modifying-response-body) From 7d7caec5bd212289533aa3b39f44727d7c3848dd Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:51:41 +0800 Subject: [PATCH 32/73] Update README.md --- spring-mvc-xml/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-mvc-xml/README.md b/spring-mvc-xml/README.md index 0adf127aaa..685e7686b1 100644 --- a/spring-mvc-xml/README.md +++ b/spring-mvc-xml/README.md @@ -17,6 +17,7 @@ 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 378c353c90a9420c564f1faa828e9e03fc531618 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:55:20 +0800 Subject: [PATCH 33/73] Create README.md --- core-java-modules/core-java-arrays-3/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 core-java-modules/core-java-arrays-3/README.md diff --git a/core-java-modules/core-java-arrays-3/README.md b/core-java-modules/core-java-arrays-3/README.md new file mode 100644 index 0000000000..255d3d097d --- /dev/null +++ b/core-java-modules/core-java-arrays-3/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Arrays.deepEquals](https://www.baeldung.com/java-arrays-deepequals) From e052b9e735f82300f41f217932351dcfc17ace8f Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 12:57:21 +0800 Subject: [PATCH 34/73] Update README.md --- core-java-modules/core-java-exceptions-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-exceptions-2/README.md b/core-java-modules/core-java-exceptions-2/README.md index 49ce897e60..7ad951f1de 100644 --- a/core-java-modules/core-java-exceptions-2/README.md +++ b/core-java-modules/core-java-exceptions-2/README.md @@ -7,3 +7,4 @@ This module contains articles about core java exceptions - [Is It a Bad Practice to Catch Throwable?](https://www.baeldung.com/java-catch-throwable-bad-practice) - [Wrapping vs Rethrowing Exceptions in Java](https://www.baeldung.com/java-wrapping-vs-rethrowing-exceptions) - [java.net.UnknownHostException: Invalid Hostname for Server](https://www.baeldung.com/java-unknownhostexception) +- [How to Handle Java SocketException](https://www.baeldung.com/java-socketexception) From dc7cf4dfe719e32a05ba4782c4b96cfcefa51410 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:00:00 +0800 Subject: [PATCH 35/73] Create README.md --- spring-mvc-java-2/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 spring-mvc-java-2/README.md diff --git a/spring-mvc-java-2/README.md b/spring-mvc-java-2/README.md new file mode 100644 index 0000000000..b5d5df3cd4 --- /dev/null +++ b/spring-mvc-java-2/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Cache Headers in Spring MVC](https://www.baeldung.com/spring-mvc-cache-headers) From 72c79a278d22b8cfbd5d625f1427e1078b93419a Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:03:55 +0800 Subject: [PATCH 36/73] 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 ae2d33c196..b064dc74d9 100644 --- a/spring-core-3/README.md +++ b/spring-core-3/README.md @@ -8,4 +8,5 @@ This module contains articles about core Spring functionality - [Guide to the Spring BeanFactory](https://www.baeldung.com/spring-beanfactory) - [How to use the Spring FactoryBean?](https://www.baeldung.com/spring-factorybean) - [Spring – Injecting Collections](https://www.baeldung.com/spring-injecting-collections) +- [Design Patterns in the Spring Framework](https://www.baeldung.com/spring-framework-design-patterns) - More articles: [[<-- prev]](/spring-core-2) From 5f7e961af1af2a9f266c39aec6b3ecfd631f3f27 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:10:33 +0800 Subject: [PATCH 37/73] 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 41d0ad63f8..a8539e644f 100644 --- a/persistence-modules/java-mongodb/README.md +++ b/persistence-modules/java-mongodb/README.md @@ -9,3 +9,4 @@ This module contains articles about MongoDB in Java. - [MongoDB BSON Guide](https://www.baeldung.com/mongodb-bson) - [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) From a5ea8c9d12a251c73fb77b3c3f5b51a2d99354c4 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:12:25 +0800 Subject: [PATCH 38/73] 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 a9604d1032..65d40c6a26 100644 --- a/core-java-modules/core-java-lang-2/README.md +++ b/core-java-modules/core-java-lang-2/README.md @@ -9,4 +9,5 @@ This module contains articles about core features in the Java language - [Java Default Parameters Using Method Overloading](https://www.baeldung.com/java-default-parameters-method-overloading) - [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) - [[<-- Prev]](/core-java-modules/core-java-lang) From 18fdd2b6aae8c0776ae54ea9558e5c14d9a13b9a Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:14:22 +0800 Subject: [PATCH 39/73] Update README.md --- spring-boot-modules/spring-boot-properties/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-properties/README.md b/spring-boot-modules/spring-boot-properties/README.md index daf7c55ab3..d8d9d0df48 100644 --- a/spring-boot-modules/spring-boot-properties/README.md +++ b/spring-boot-modules/spring-boot-properties/README.md @@ -12,3 +12,4 @@ This module contains articles about Properties in Spring Boot. - [Spring YAML Configuration](https://www.baeldung.com/spring-yaml) - [Using Spring @Value with Defaults](https://www.baeldung.com/spring-value-defaults) - [How to Inject a Property Value Into a Class Not Managed by Spring?](https://www.baeldung.com/inject-properties-value-non-spring-class) +- [Add Build Properties to a Spring Boot Application](https://www.baeldung.com/spring-boot-build-properties) From a3f198079de42bff1b4207250f23e4ef85d67939 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:16:03 +0800 Subject: [PATCH 40/73] Update README.md --- libraries-data-io/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries-data-io/README.md b/libraries-data-io/README.md index 550f353c97..3e68334ec9 100644 --- a/libraries-data-io/README.md +++ b/libraries-data-io/README.md @@ -9,3 +9,4 @@ This module contains articles about IO data processing libraries. - [Introduction To OpenCSV](https://www.baeldung.com/opencsv) - [Interact with Google Sheets from Java](https://www.baeldung.com/google-sheets-java-client) - [Introduction To Docx4J](https://www.baeldung.com/docx4j) +- [Breaking YAML Strings Over Multiple Lines](https://www.baeldung.com/yaml-multi-line) From 6fde5e9515f5fde06a599ed697c89e0ee3760550 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:18:19 +0800 Subject: [PATCH 41/73] Update README.md --- image-processing/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/image-processing/README.md b/image-processing/README.md index adb35c2318..4417f312d8 100644 --- a/image-processing/README.md +++ b/image-processing/README.md @@ -4,3 +4,4 @@ This module contains articles about image processing. ### Relevant Articles: - [Working with Images in Java](https://www.baeldung.com/java-images) +- [Intro to OpenCV with Java](https://www.baeldung.com/java-opencv) From c100729cda01a0defb17a0f0ce905d997c9d1ef1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:19:55 +0800 Subject: [PATCH 42/73] Update README.md --- data-structures/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/data-structures/README.md b/data-structures/README.md index e8fb374f6c..f9ca78679a 100644 --- a/data-structures/README.md +++ b/data-structures/README.md @@ -9,3 +9,4 @@ This module contains articles about data structures in Java - [Circular Linked List Java Implementation](https://www.baeldung.com/java-circular-linked-list) - [How to Print a Binary Tree Diagram](https://www.baeldung.com/java-print-binary-tree-diagram) - [Introduction to Big Queue](https://www.baeldung.com/java-big-queue) +- [Guide to AVL Trees in Java](https://www.baeldung.com/java-avl-trees) From b46622d258a291acbc874e758f7e7092afd6cfe4 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:23:13 +0800 Subject: [PATCH 43/73] 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 0648d087be..9ec20cd223 100644 --- a/core-java-modules/core-java-14/README.md +++ b/core-java-modules/core-java-14/README.md @@ -5,3 +5,4 @@ This module contains articles about Java 14. ### Relevant articles - [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) From c72530f3ffba5e03ac7f0bc376ceec0981d8aa3d Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:24:46 +0800 Subject: [PATCH 44/73] Create README.md --- gradle-6/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 gradle-6/README.md diff --git a/gradle-6/README.md b/gradle-6/README.md new file mode 100644 index 0000000000..a1ea96ad83 --- /dev/null +++ b/gradle-6/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [What’s New in Gradle 6.0](https://www.baeldung.com/gradle-6-features) From 37e2cdbbc230e8f835c0364faee081079fe63da1 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:26:35 +0800 Subject: [PATCH 45/73] Create README.md --- open-liberty/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 open-liberty/README.md diff --git a/open-liberty/README.md b/open-liberty/README.md new file mode 100644 index 0000000000..6a51d2c486 --- /dev/null +++ b/open-liberty/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Introduction to Open Liberty](https://www.baeldung.com/java-open-liberty) From 4616c3d389cae7e82ae5a4a36dbf85fe99f1099e Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:28:15 +0800 Subject: [PATCH 46/73] Update README.md --- spring-boot-modules/spring-boot-bootstrap/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-bootstrap/README.md b/spring-boot-modules/spring-boot-bootstrap/README.md index 5fb8fd4a84..146cd04551 100644 --- a/spring-boot-modules/spring-boot-bootstrap/README.md +++ b/spring-boot-modules/spring-boot-bootstrap/README.md @@ -10,3 +10,4 @@ This module contains articles about bootstrapping Spring Boot applications. - [Deploy a Spring Boot Application to OpenShift](https://www.baeldung.com/spring-boot-deploy-openshift) - [Deploy a Spring Boot Application to AWS Beanstalk](https://www.baeldung.com/spring-boot-deploy-aws-beanstalk) - [Guide to @SpringBootConfiguration in Spring Boot](https://www.baeldung.com/springbootconfiguration-annotation) +- [Implement Health Checks in OpenShift](https://www.baeldung.com/openshift-health-checks) From c6ada1f61c4ca0df8a0ad9ef35c0dcec258d187f Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:30:31 +0800 Subject: [PATCH 47/73] Update README.md --- spring-cloud/spring-cloud-gateway/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-cloud/spring-cloud-gateway/README.md b/spring-cloud/spring-cloud-gateway/README.md index d3323947e8..9c8e0d443a 100644 --- a/spring-cloud/spring-cloud-gateway/README.md +++ b/spring-cloud/spring-cloud-gateway/README.md @@ -5,3 +5,4 @@ This module contains articles about Spring Cloud Gateway ### Relevant Articles: - [Exploring the new Spring Cloud Gateway](http://www.baeldung.com/spring-cloud-gateway) - [Writing Custom Spring Cloud Gateway Filters](https://www.baeldung.com/spring-cloud-custom-gateway-filters) +- [Spring Cloud Gateway Routing Predicate Factories](https://www.baeldung.com/spring-cloud-gateway-routing-predicate-factories) From 36c745ceb54d09828edbe6d289cb27e8403c41cd Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:34:56 +0800 Subject: [PATCH 48/73] Update README.md --- core-java-modules/core-java-string-operations-2/README.md | 1 + 1 file changed, 1 insertion(+) 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 8687ac19ba..5e92738f5c 100644 --- a/core-java-modules/core-java-string-operations-2/README.md +++ b/core-java-modules/core-java-string-operations-2/README.md @@ -10,4 +10,5 @@ This module contains articles about string operations. - [Java String equalsIgnoreCase()](https://www.baeldung.com/java-string-equalsignorecase) - [Case-Insensitive String Matching in Java](https://www.baeldung.com/java-case-insensitive-string-matching) - [L-Trim and R-Trim 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) - More articles: [[<-- prev]](../core-java-string-operations) From 0af09bf2c113b9e3321a51a72db3137c36b42380 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:36:41 +0800 Subject: [PATCH 49/73] Update README.md --- spring-boot-modules/spring-boot-properties/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-properties/README.md b/spring-boot-modules/spring-boot-properties/README.md index d8d9d0df48..f861a01d10 100644 --- a/spring-boot-modules/spring-boot-properties/README.md +++ b/spring-boot-modules/spring-boot-properties/README.md @@ -13,3 +13,4 @@ This module contains articles about Properties in Spring Boot. - [Using Spring @Value with Defaults](https://www.baeldung.com/spring-value-defaults) - [How to Inject a Property Value Into a Class Not Managed by Spring?](https://www.baeldung.com/inject-properties-value-non-spring-class) - [Add Build Properties to a Spring Boot Application](https://www.baeldung.com/spring-boot-build-properties) +- [IntelliJ – Cannot Resolve Spring Boot Configuration Properties Error](https://www.baeldung.com/intellij-resolve-spring-boot-configuration-properties) From 5c6c706a17b8b8f77c24eafc20deb04531dbc245 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:38:24 +0800 Subject: [PATCH 50/73] Update README.md --- gson/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gson/README.md b/gson/README.md index df6ba0f516..4255e2ead9 100644 --- a/gson/README.md +++ b/gson/README.md @@ -13,4 +13,4 @@ This module contains articles about Gson - [Convert String to JsonObject with Gson](https://www.baeldung.com/gson-string-to-jsonobject) - [Mapping Multiple JSON Fields to a Single Java Field](https://www.baeldung.com/json-multiple-fields-single-java-field) - [Serializing and Deserializing a List with Gson](https://www.baeldung.com/gson-list) - +- [Compare Two JSON Objects with Gson](https://www.baeldung.com/gson-compare-json-objects) From 4051cdcf173a812fb732a9552aa5b44268e1a661 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 13:39:59 +0800 Subject: [PATCH 51/73] Update README.md --- image-processing/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/image-processing/README.md b/image-processing/README.md index 4417f312d8..50129bb994 100644 --- a/image-processing/README.md +++ b/image-processing/README.md @@ -5,3 +5,4 @@ This module contains articles about image processing. ### Relevant Articles: - [Working with Images in Java](https://www.baeldung.com/java-images) - [Intro to OpenCV with Java](https://www.baeldung.com/java-opencv) +- [Optical Character Recognition with Tesseract](https://www.baeldung.com/java-ocr-tesseract) From 53c9accfd679d26a59d56037b7090cbca35da2df Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:09:32 +0800 Subject: [PATCH 52/73] Create README.md --- core-java-modules/core-java-security-2/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 core-java-modules/core-java-security-2/README.md diff --git a/core-java-modules/core-java-security-2/README.md b/core-java-modules/core-java-security-2/README.md new file mode 100644 index 0000000000..c250e24078 --- /dev/null +++ b/core-java-modules/core-java-security-2/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Guide To The Java Authentication And Authorization Service (JAAS)](https://www.baeldung.com/java-authentication-authorization-service) From 087248c5e3c8922c54aa507072966ebde3367ceb Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:11:14 +0800 Subject: [PATCH 53/73] Update README.md --- persistence-modules/spring-data-redis/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/persistence-modules/spring-data-redis/README.md b/persistence-modules/spring-data-redis/README.md index e4a528ae91..175634376b 100644 --- a/persistence-modules/spring-data-redis/README.md +++ b/persistence-modules/spring-data-redis/README.md @@ -4,6 +4,7 @@ - [Introduction to Spring Data Redis](https://www.baeldung.com/spring-data-redis-tutorial) - [PubSub Messaging with Spring Data Redis](https://www.baeldung.com/spring-data-redis-pub-sub) - [An Introduction to Spring Data Redis Reactive](https://www.baeldung.com/spring-data-redis-reactive) +- [Delete Everything in Redis](https://www.baeldung.com/redis-delete-data) ### Build the Project with Tests Running ``` From ff4ac52b2ee71b2f9094428371d6bda192e26f6f Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:12:43 +0800 Subject: [PATCH 54/73] Update README.md --- libraries/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/README.md b/libraries/README.md index 79ba8fe55d..f439033730 100644 --- a/libraries/README.md +++ b/libraries/README.md @@ -45,4 +45,5 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [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) +- [Using NullAway to Avoid NullPointerExceptions](https://www.baeldung.com/java-nullaway) - More articles [[next -->]](/libraries-2) From f70e4a0563e6f766caa2978641b7ca00fa4e2681 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:14:13 +0800 Subject: [PATCH 55/73] 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 7a8f6d9293..21cd7a95a3 100644 --- a/core-java-modules/core-java-regex/README.md +++ b/core-java-modules/core-java-regex/README.md @@ -8,3 +8,4 @@ - [Guide to Escaping Characters in Java RegExps](http://www.baeldung.com/java-regexp-escape-char) - [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) From 6c32698f62e9f3042b0c2217643a608ad0a129d3 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:16:14 +0800 Subject: [PATCH 56/73] 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 b064dc74d9..b2c4f694a8 100644 --- a/spring-core-3/README.md +++ b/spring-core-3/README.md @@ -9,4 +9,5 @@ This module contains articles about core Spring functionality - [How to use the Spring FactoryBean?](https://www.baeldung.com/spring-factorybean) - [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) - More articles: [[<-- prev]](/spring-core-2) From eb8b2bb8b4fae22f1306e73454200f9b17f74781 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:17:32 +0800 Subject: [PATCH 57/73] Create README.md --- apache-beam/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 apache-beam/README.md diff --git a/apache-beam/README.md b/apache-beam/README.md new file mode 100644 index 0000000000..a71e5256a8 --- /dev/null +++ b/apache-beam/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Introduction to Apache Beam](https://www.baeldung.com/apache-beam) From 5b83d05a1fdfea16b9a333fc8f65a577c3c62cfa Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:19:41 +0800 Subject: [PATCH 58/73] Update README.md --- spring-5/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-5/README.md b/spring-5/README.md index 857b199562..d50f9c7544 100644 --- a/spring-5/README.md +++ b/spring-5/README.md @@ -16,3 +16,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring - [Spring Assert Statements](https://www.baeldung.com/spring-assert) - [Configuring a Hikari Connection Pool with Spring Boot](https://www.baeldung.com/spring-boot-hikari) - [Difference between \ vs \](https://www.baeldung.com/spring-contextannotation-contextcomponentscan) +- [Finding the Spring Version](https://www.baeldung.com/spring-find-version) From 0ea9f1644876d54d8436da5d626e070dcec282c8 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:21:53 +0800 Subject: [PATCH 59/73] Update README.md --- core-java-modules/core-java-perf/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-perf/README.md b/core-java-modules/core-java-perf/README.md index 4204c2b012..d52fd2d733 100644 --- a/core-java-modules/core-java-perf/README.md +++ b/core-java-modules/core-java-perf/README.md @@ -10,3 +10,4 @@ This module contains articles about performance of Java applications - [Basic Introduction to JMX](http://www.baeldung.com/java-management-extensions) - [Monitoring Java Applications with Flight Recorder](https://www.baeldung.com/java-flight-recorder-monitoring) - [Branch Prediction in Java](https://www.baeldung.com/java-branch-prediction) +- [Capturing a Java Thread Dump](https://www.baeldung.com/java-thread-dump) From 7494225aa8f284d1724a68943dbbf35b96495a95 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:23:00 +0800 Subject: [PATCH 60/73] 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 9ec20cd223..0e8278c4f6 100644 --- a/core-java-modules/core-java-14/README.md +++ b/core-java-modules/core-java-14/README.md @@ -6,3 +6,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) From 231a181804cf01ce979efd78b403aef7d3e428e5 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:24:22 +0800 Subject: [PATCH 61/73] Update README.md --- spring-boot-modules/spring-boot-testing/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/spring-boot-modules/spring-boot-testing/README.md b/spring-boot-modules/spring-boot-testing/README.md index 0b2533e6bc..882e2be766 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) +- [Testing Spring Boot @ConfigurationProperties](https://www.baeldung.com/spring-boot-testing-configurationproperties) From 9cda688213788e7caf4bdc603d5bbb30fc6b950e Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:25:35 +0800 Subject: [PATCH 62/73] Update README.md --- algorithms-searching/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/algorithms-searching/README.md b/algorithms-searching/README.md index 9b85995235..aed3c7d21f 100644 --- a/algorithms-searching/README.md +++ b/algorithms-searching/README.md @@ -10,3 +10,4 @@ This module contains articles about searching algorithms. - [String Search Algorithms for Large Texts](https://www.baeldung.com/java-full-text-search-algorithms) - [Monte Carlo Tree Search for Tic-Tac-Toe Game](https://www.baeldung.com/java-monte-carlo-tree-search) - [Range Search Algorithm in Java](https://www.baeldung.com/java-range-search) +- [Fast Pattern Matching of Strings Using Suffix Tree](https://www.baeldung.com/java-pattern-matching-suffix-tree) From 803c8ddc990105649c306a4d6995160a484a2875 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:27:33 +0800 Subject: [PATCH 63/73] Update README.md --- core-java-modules/core-java-exceptions-2/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/core-java-modules/core-java-exceptions-2/README.md b/core-java-modules/core-java-exceptions-2/README.md index 7ad951f1de..1b8457acc4 100644 --- a/core-java-modules/core-java-exceptions-2/README.md +++ b/core-java-modules/core-java-exceptions-2/README.md @@ -8,3 +8,4 @@ This module contains articles about core java exceptions - [Wrapping vs Rethrowing Exceptions in Java](https://www.baeldung.com/java-wrapping-vs-rethrowing-exceptions) - [java.net.UnknownHostException: Invalid Hostname for Server](https://www.baeldung.com/java-unknownhostexception) - [How to Handle Java SocketException](https://www.baeldung.com/java-socketexception) +- [Java Suppressed Exceptions](https://www.baeldung.com/java-suppressed-exceptions) From a494d8b0e5863c2005692a77cc9b57d74233a128 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:29:11 +0800 Subject: [PATCH 64/73] 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 a5be14a349..0a76c7ff6e 100644 --- a/libraries-3/README.md +++ b/libraries-3/README.md @@ -13,3 +13,4 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m - [Parsing Command-Line Parameters with Airline](https://www.baeldung.com/java-airline) - [Introduction to cache2k](https://www.baeldung.com/java-cache2k) - [Introduction to the jcabi-aspects AOP Annotations Library](https://www.baeldung.com/java-jcabi-aspects) +- [Introduction to Takes](https://www.baeldung.com/java-takes) From 3f1881176169f758c38cab8018bf2d6173a47139 Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:31:33 +0800 Subject: [PATCH 65/73] Create README.md --- spring-ejb/ejb-beans/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 spring-ejb/ejb-beans/README.md diff --git a/spring-ejb/ejb-beans/README.md b/spring-ejb/ejb-beans/README.md new file mode 100644 index 0000000000..f1af5a3a87 --- /dev/null +++ b/spring-ejb/ejb-beans/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Spring Bean vs. EJB – A Feature Comparison](https://www.baeldung.com/spring-bean-vs-ejb) From fa7b7266e6aadf8d2e43bca5e2b1470ee284db8b Mon Sep 17 00:00:00 2001 From: johnA1331 <53036378+johnA1331@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:33:15 +0800 Subject: [PATCH 66/73] Update README.md --- ddd-modules/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ddd-modules/README.md b/ddd-modules/README.md index 5616cce48b..ba6b8d5016 100644 --- a/ddd-modules/README.md +++ b/ddd-modules/README.md @@ -1 +1,3 @@ -## Relevant Articles +### Relevant Articles: + +- [DDD Bounded Contexts and Java Modules](https://www.baeldung.com/java-modules-ddd-bounded-contexts) From 932eba6929119547d1843ebf9a88702338d67f44 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Wed, 18 Mar 2020 07:44:23 +0100 Subject: [PATCH 67/73] BAEL-3921: Remove adding a redundant log handler (#8881) --- .../constructorsstaticfactorymethods/entities/User.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/patterns/design-patterns-creational/src/main/java/com/baeldung/constructorsstaticfactorymethods/entities/User.java b/patterns/design-patterns-creational/src/main/java/com/baeldung/constructorsstaticfactorymethods/entities/User.java index f05a3baaa3..a602d1c55d 100644 --- a/patterns/design-patterns-creational/src/main/java/com/baeldung/constructorsstaticfactorymethods/entities/User.java +++ b/patterns/design-patterns-creational/src/main/java/com/baeldung/constructorsstaticfactorymethods/entities/User.java @@ -19,8 +19,8 @@ public class User { } public static User createWithLoggedInstantiationTime(String name, String email, String country) { - setLoggerProperties(); LOGGER.log(Level.INFO, "Creating User instance at : {0}", LocalTime.now()); + return new User(name, email, country); } @@ -53,11 +53,4 @@ public class User { public String getCountry() { return country; } - - private static void setLoggerProperties() { - ConsoleHandler handler = new ConsoleHandler(); - handler.setLevel(Level.INFO); - handler.setFormatter(new SimpleFormatter()); - LOGGER.addHandler(handler); - } } From 52822b7c226f215b8790eae6776281f6a01a71be Mon Sep 17 00:00:00 2001 From: Donato Rimenti Date: Wed, 18 Mar 2020 11:41:11 +0100 Subject: [PATCH 68/73] [JAVA-963] Added parent pom to jhipster-5/bookstore-monolith and renamed tests according to conventions (*Test -> *UnitTest, *IntTest -> *IntegrationTest) --- jhipster-5/bookstore-monolith/pom.xml | 6 ++++++ ...bConfigurerTest.java => WebConfigurerUnitTest.java} | 10 +++++----- ...oller.java => WebConfigurerUnitTestController.java} | 2 +- ... => CustomAuditEventRepositoryIntegrationTest.java} | 2 +- ...va => DomainUserDetailsServiceIntegrationTest.java} | 2 +- .../jwt/{JWTFilterTest.java => JWTFilterUnitTest.java} | 2 +- ...kenProviderTest.java => TokenProviderUnitTest.java} | 2 +- ...iceIntTest.java => MailServiceIntegrationTest.java} | 2 +- ...iceIntTest.java => UserServiceIntegrationTest.java} | 2 +- .../{UserMapperTest.java => UserMapperUnitTest.java} | 2 +- ...ntTest.java => AccountResourceIntegrationTest.java} | 2 +- ...eIntTest.java => AuditResourceIntegrationTest.java} | 2 +- ...ceIntTest.java => BookResourceIntegrationTest.java} | 2 +- ...ceIntTest.java => LogsResourceIntegrationTest.java} | 2 +- ...Test.java => UserJWTControllerIntegrationTest.java} | 2 +- ...ceIntTest.java => UserResourceIntegrationTest.java} | 2 +- ...st.java => ExceptionTranslatorIntegrationTest.java} | 2 +- 17 files changed, 26 insertions(+), 20 deletions(-) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/config/{WebConfigurerTest.java => WebConfigurerUnitTest.java} (97%) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/config/{WebConfigurerTestController.java => WebConfigurerUnitTestController.java} (87%) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/repository/{CustomAuditEventRepositoryIntTest.java => CustomAuditEventRepositoryIntegrationTest.java} (99%) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/{DomainUserDetailsServiceIntTest.java => DomainUserDetailsServiceIntegrationTest.java} (98%) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/jwt/{JWTFilterTest.java => JWTFilterUnitTest.java} (99%) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/jwt/{TokenProviderTest.java => TokenProviderUnitTest.java} (99%) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/{MailServiceIntTest.java => MailServiceIntegrationTest.java} (99%) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/{UserServiceIntTest.java => UserServiceIntegrationTest.java} (99%) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/mapper/{UserMapperTest.java => UserMapperUnitTest.java} (99%) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/{AccountResourceIntTest.java => AccountResourceIntegrationTest.java} (99%) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/{AuditResourceIntTest.java => AuditResourceIntegrationTest.java} (99%) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/{BookResourceIntTest.java => BookResourceIntegrationTest.java} (99%) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/{LogsResourceIntTest.java => LogsResourceIntegrationTest.java} (98%) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/{UserJWTControllerIntTest.java => UserJWTControllerIntegrationTest.java} (99%) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/{UserResourceIntTest.java => UserResourceIntegrationTest.java} (99%) rename jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/errors/{ExceptionTranslatorIntTest.java => ExceptionTranslatorIntegrationTest.java} (99%) diff --git a/jhipster-5/bookstore-monolith/pom.xml b/jhipster-5/bookstore-monolith/pom.xml index 60fc1acf92..5eaf761921 100644 --- a/jhipster-5/bookstore-monolith/pom.xml +++ b/jhipster-5/bookstore-monolith/pom.xml @@ -7,6 +7,12 @@ 0.0.1-SNAPSHOT war Bookstore + + + jhipster-5 + com.baeldung.jhipster + 1.0.0-SNAPSHOT + diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/config/WebConfigurerTest.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/config/WebConfigurerUnitTest.java similarity index 97% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/config/WebConfigurerTest.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/config/WebConfigurerUnitTest.java index 670042d2df..764d6b3587 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/config/WebConfigurerTest.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/config/WebConfigurerUnitTest.java @@ -37,7 +37,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. * * @see WebConfigurer */ -public class WebConfigurerTest { +public class WebConfigurerUnitTest { private WebConfigurer webConfigurer; @@ -116,7 +116,7 @@ public class WebConfigurerTest { props.getCors().setMaxAge(1800L); props.getCors().setAllowCredentials(true); - MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController()) + MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerUnitTestController()) .addFilters(webConfigurer.corsFilter()) .build(); @@ -146,7 +146,7 @@ public class WebConfigurerTest { props.getCors().setMaxAge(1800L); props.getCors().setAllowCredentials(true); - MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController()) + MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerUnitTestController()) .addFilters(webConfigurer.corsFilter()) .build(); @@ -161,7 +161,7 @@ public class WebConfigurerTest { public void testCorsFilterDeactivated() throws Exception { props.getCors().setAllowedOrigins(null); - MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController()) + MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerUnitTestController()) .addFilters(webConfigurer.corsFilter()) .build(); @@ -176,7 +176,7 @@ public class WebConfigurerTest { public void testCorsFilterDeactivated2() throws Exception { props.getCors().setAllowedOrigins(new ArrayList<>()); - MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController()) + MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerUnitTestController()) .addFilters(webConfigurer.corsFilter()) .build(); diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/config/WebConfigurerTestController.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/config/WebConfigurerUnitTestController.java similarity index 87% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/config/WebConfigurerTestController.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/config/WebConfigurerUnitTestController.java index c19b28ea16..ee72e1c80e 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/config/WebConfigurerTestController.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/config/WebConfigurerUnitTestController.java @@ -4,7 +4,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController -public class WebConfigurerTestController { +public class WebConfigurerUnitTestController { @GetMapping("/api/test-cors") public void testCorsOnApiPath() { diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/repository/CustomAuditEventRepositoryIntTest.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/repository/CustomAuditEventRepositoryIntegrationTest.java similarity index 99% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/repository/CustomAuditEventRepositoryIntTest.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/repository/CustomAuditEventRepositoryIntegrationTest.java index eaf5c07504..948bf43f87 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/repository/CustomAuditEventRepositoryIntTest.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/repository/CustomAuditEventRepositoryIntegrationTest.java @@ -33,7 +33,7 @@ import static com.baeldung.jhipster5.repository.CustomAuditEventRepository.EVENT @RunWith(SpringRunner.class) @SpringBootTest(classes = BookstoreApp.class) @Transactional -public class CustomAuditEventRepositoryIntTest { +public class CustomAuditEventRepositoryIntegrationTest { @Autowired private PersistenceAuditEventRepository persistenceAuditEventRepository; diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/DomainUserDetailsServiceIntTest.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/DomainUserDetailsServiceIntegrationTest.java similarity index 98% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/DomainUserDetailsServiceIntTest.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/DomainUserDetailsServiceIntegrationTest.java index f11252de2b..11757f6516 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/DomainUserDetailsServiceIntTest.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/DomainUserDetailsServiceIntegrationTest.java @@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat; @RunWith(SpringRunner.class) @SpringBootTest(classes = BookstoreApp.class) @Transactional -public class DomainUserDetailsServiceIntTest { +public class DomainUserDetailsServiceIntegrationTest { private static final String USER_ONE_LOGIN = "test-user-one"; private static final String USER_ONE_EMAIL = "test-user-one@localhost"; diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/jwt/JWTFilterTest.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/jwt/JWTFilterUnitTest.java similarity index 99% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/jwt/JWTFilterTest.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/jwt/JWTFilterUnitTest.java index b3de21819b..2be8e6809a 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/jwt/JWTFilterTest.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/jwt/JWTFilterUnitTest.java @@ -20,7 +20,7 @@ import java.util.Collections; import static org.assertj.core.api.Assertions.assertThat; -public class JWTFilterTest { +public class JWTFilterUnitTest { private TokenProvider tokenProvider; diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/jwt/TokenProviderTest.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/jwt/TokenProviderUnitTest.java similarity index 99% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/jwt/TokenProviderTest.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/jwt/TokenProviderUnitTest.java index 11fcfddbf9..18da2eb875 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/jwt/TokenProviderTest.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/security/jwt/TokenProviderUnitTest.java @@ -22,7 +22,7 @@ import io.jsonwebtoken.security.Keys; import static org.assertj.core.api.Assertions.assertThat; -public class TokenProviderTest { +public class TokenProviderUnitTest { private final long ONE_MINUTE = 60000; private Key key; diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/MailServiceIntTest.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/MailServiceIntegrationTest.java similarity index 99% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/MailServiceIntTest.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/MailServiceIntegrationTest.java index 4bde3276f5..72592e1239 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/MailServiceIntTest.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/MailServiceIntegrationTest.java @@ -31,7 +31,7 @@ import static org.mockito.Mockito.*; @RunWith(SpringRunner.class) @SpringBootTest(classes = BookstoreApp.class) -public class MailServiceIntTest { +public class MailServiceIntegrationTest { @Autowired private JHipsterProperties jHipsterProperties; diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/UserServiceIntTest.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/UserServiceIntegrationTest.java similarity index 99% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/UserServiceIntTest.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/UserServiceIntegrationTest.java index 81034c2793..ca3608462d 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/UserServiceIntTest.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/UserServiceIntegrationTest.java @@ -38,7 +38,7 @@ import static org.mockito.Mockito.when; @RunWith(SpringRunner.class) @SpringBootTest(classes = BookstoreApp.class) @Transactional -public class UserServiceIntTest { +public class UserServiceIntegrationTest { @Autowired private UserRepository userRepository; diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/mapper/UserMapperTest.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/mapper/UserMapperUnitTest.java similarity index 99% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/mapper/UserMapperTest.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/mapper/UserMapperUnitTest.java index 3d66fa5813..cd6a326c06 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/mapper/UserMapperTest.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/service/mapper/UserMapperUnitTest.java @@ -26,7 +26,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ @RunWith(SpringRunner.class) @SpringBootTest(classes = BookstoreApp.class) -public class UserMapperTest { +public class UserMapperUnitTest { private static final String DEFAULT_LOGIN = "johndoe"; diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/AccountResourceIntTest.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/AccountResourceIntegrationTest.java similarity index 99% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/AccountResourceIntTest.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/AccountResourceIntegrationTest.java index 6db284a87f..f591b7ecbf 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/AccountResourceIntTest.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/AccountResourceIntegrationTest.java @@ -49,7 +49,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ @RunWith(SpringRunner.class) @SpringBootTest(classes = BookstoreApp.class) -public class AccountResourceIntTest { +public class AccountResourceIntegrationTest { @Autowired private UserRepository userRepository; diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/AuditResourceIntTest.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/AuditResourceIntegrationTest.java similarity index 99% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/AuditResourceIntTest.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/AuditResourceIntegrationTest.java index c3b91ab390..05d8f9d503 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/AuditResourceIntTest.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/AuditResourceIntegrationTest.java @@ -35,7 +35,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @RunWith(SpringRunner.class) @SpringBootTest(classes = BookstoreApp.class) @Transactional -public class AuditResourceIntTest { +public class AuditResourceIntegrationTest { private static final String SAMPLE_PRINCIPAL = "SAMPLE_PRINCIPAL"; private static final String SAMPLE_TYPE = "SAMPLE_TYPE"; diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/BookResourceIntTest.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/BookResourceIntegrationTest.java similarity index 99% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/BookResourceIntTest.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/BookResourceIntegrationTest.java index ef8f27ceea..4f5cb25cdb 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/BookResourceIntTest.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/BookResourceIntegrationTest.java @@ -43,7 +43,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ @RunWith(SpringRunner.class) @SpringBootTest(classes = BookstoreApp.class) -public class BookResourceIntTest { +public class BookResourceIntegrationTest { private static final String DEFAULT_TITLE = "AAAAAAAAAA"; private static final String UPDATED_TITLE = "BBBBBBBBBB"; diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/LogsResourceIntTest.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/LogsResourceIntegrationTest.java similarity index 98% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/LogsResourceIntTest.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/LogsResourceIntegrationTest.java index 62f7f3f17c..b045f52f87 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/LogsResourceIntTest.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/LogsResourceIntegrationTest.java @@ -27,7 +27,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ @RunWith(SpringRunner.class) @SpringBootTest(classes = BookstoreApp.class) -public class LogsResourceIntTest { +public class LogsResourceIntegrationTest { private MockMvc restLogsMockMvc; diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/UserJWTControllerIntTest.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/UserJWTControllerIntegrationTest.java similarity index 99% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/UserJWTControllerIntTest.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/UserJWTControllerIntegrationTest.java index 3886710438..7cfc0e19fc 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/UserJWTControllerIntTest.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/UserJWTControllerIntegrationTest.java @@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.not; */ @RunWith(SpringRunner.class) @SpringBootTest(classes = BookstoreApp.class) -public class UserJWTControllerIntTest { +public class UserJWTControllerIntegrationTest { @Autowired private TokenProvider tokenProvider; diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/UserResourceIntTest.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/UserResourceIntegrationTest.java similarity index 99% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/UserResourceIntTest.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/UserResourceIntegrationTest.java index d31df3b15c..c0abc042fb 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/UserResourceIntTest.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/UserResourceIntegrationTest.java @@ -42,7 +42,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ @RunWith(SpringRunner.class) @SpringBootTest(classes = BookstoreApp.class) -public class UserResourceIntTest { +public class UserResourceIntegrationTest { private static final String DEFAULT_LOGIN = "johndoe"; private static final String UPDATED_LOGIN = "jhipster"; diff --git a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/errors/ExceptionTranslatorIntTest.java b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/errors/ExceptionTranslatorIntegrationTest.java similarity index 99% rename from jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/errors/ExceptionTranslatorIntTest.java rename to jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/errors/ExceptionTranslatorIntegrationTest.java index a94d54063b..e5ef08ee9c 100644 --- a/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/errors/ExceptionTranslatorIntTest.java +++ b/jhipster-5/bookstore-monolith/src/test/java/com/baeldung/jhipster5/web/rest/errors/ExceptionTranslatorIntegrationTest.java @@ -25,7 +25,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. */ @RunWith(SpringRunner.class) @SpringBootTest(classes = BookstoreApp.class) -public class ExceptionTranslatorIntTest { +public class ExceptionTranslatorIntegrationTest { @Autowired private ExceptionTranslatorTestController controller; From 89e04a58fdc4238d49342ca7284a7a34f6284d1c Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Wed, 18 Mar 2020 15:05:59 +0100 Subject: [PATCH 69/73] BAEL-3931: Use httpS://repo.spring.io --- parent-kotlin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parent-kotlin/pom.xml b/parent-kotlin/pom.xml index e3d67eaaf2..52a753439c 100644 --- a/parent-kotlin/pom.xml +++ b/parent-kotlin/pom.xml @@ -31,7 +31,7 @@ spring-milestone Spring Milestone Repository - http://repo.spring.io/milestone + https://repo.spring.io/milestone From 9d2472839fc9a9e6e9f010eac0dc07a3dacd4008 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Wed, 18 Mar 2020 15:11:59 +0100 Subject: [PATCH 70/73] BAEL-3931: Migrate FuelHttpUnitTest to FuelHttpLiveTest --- .../fuel/{FuelHttpUnitTest.kt => FuelHttpLiveTest.kt} | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) rename kotlin-libraries-2/src/test/kotlin/com/baeldung/fuel/{FuelHttpUnitTest.kt => FuelHttpLiveTest.kt} (97%) diff --git a/kotlin-libraries-2/src/test/kotlin/com/baeldung/fuel/FuelHttpUnitTest.kt b/kotlin-libraries-2/src/test/kotlin/com/baeldung/fuel/FuelHttpLiveTest.kt similarity index 97% rename from kotlin-libraries-2/src/test/kotlin/com/baeldung/fuel/FuelHttpUnitTest.kt rename to kotlin-libraries-2/src/test/kotlin/com/baeldung/fuel/FuelHttpLiveTest.kt index b7993c5f43..69b6ae88c6 100644 --- a/kotlin-libraries-2/src/test/kotlin/com/baeldung/fuel/FuelHttpUnitTest.kt +++ b/kotlin-libraries-2/src/test/kotlin/com/baeldung/fuel/FuelHttpLiveTest.kt @@ -12,7 +12,11 @@ import org.junit.jupiter.api.Test import java.io.File import java.util.concurrent.CountDownLatch -internal class FuelHttpUnitTest { +/** + * These live tests make connections to the external systems: http://httpbin.org, https://jsonplaceholder.typicode.com + * Make sure these hosts are up and your internet connection is on before running the tests. + */ +internal class FuelHttpLiveTest { @Test fun whenMakingAsyncHttpGetRequest_thenResponseNotNullAndErrorNullAndStatusCode200() { From 89a3f70befcc878f747f62c8e9ca0a5db8c937cd Mon Sep 17 00:00:00 2001 From: Loredana Date: Wed, 18 Mar 2020 20:22:39 +0200 Subject: [PATCH 71/73] disable jee tests - fixing in BAEL-3812 --- .../baeldung/batch/understanding/CustomCheckPointUnitTest.java | 2 ++ .../com/baeldung/batch/understanding/JobSequenceUnitTest.java | 2 ++ .../com/baeldung/batch/understanding/SimpleChunkUnitTest.java | 2 ++ 3 files changed, 6 insertions(+) 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 dfea878a75..744bdfc8f5 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 @@ -12,7 +12,9 @@ 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 7c5e8d0b78..88b981df92 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 @@ -13,7 +13,9 @@ 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/SimpleChunkUnitTest.java b/jee-7/src/test/java/com/baeldung/batch/understanding/SimpleChunkUnitTest.java index 57c794ba00..5871143fa3 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 @@ -14,7 +14,9 @@ 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 { From cccec36753a22739b4af34d48da41d6c1f0a94a6 Mon Sep 17 00:00:00 2001 From: mikr Date: Wed, 18 Mar 2020 20:05:41 +0100 Subject: [PATCH 72/73] JAVA-841 Update commented section in pom file --- spring-security-modules/spring-security-mvc-boot-1/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-security-modules/spring-security-mvc-boot-1/pom.xml b/spring-security-modules/spring-security-mvc-boot-1/pom.xml index 476159f306..7ad18376ec 100644 --- a/spring-security-modules/spring-security-mvc-boot-1/pom.xml +++ b/spring-security-modules/spring-security-mvc-boot-1/pom.xml @@ -225,7 +225,7 @@ com.baeldung.roles.custom.Application - + 1.1.2 1.6.1 From a94b56c74eaac631cff61b372da9cf2ace69493b Mon Sep 17 00:00:00 2001 From: petershatunov Date: Thu, 19 Mar 2020 00:00:37 +0300 Subject: [PATCH 73/73] lazy_load_no_trans init commit (#8736) * lazy_load_no_trans init commit * refactoring * methods naming * Update persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/lazy_load_no_trans/LazyLoadNoTransPropertyOnIntegrationTest.java Co-Authored-By: KevinGilmore * Update persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/lazy_load_no_trans/LazyLoadNoTransPropertyOnIntegrationTest.java Co-Authored-By: KevinGilmore * Update persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/lazy_load_no_trans/LazyLoadNoTransPropertyOffIntegrationTest.java Co-Authored-By: KevinGilmore * naming * code readability Co-authored-by: admin Co-authored-by: KevinGilmore --- .../spring-boot-persistence-h2/pom.xml | 18 +++++ .../LazyLoadNoTransSpringBootApplication.java | 13 ++++ .../DatasourceProxyBeanPostProcessor.java | 67 +++++++++++++++++++ .../lazy_load_no_trans/entity/Document.java | 26 +++++++ .../h2db/lazy_load_no_trans/entity/User.java | 37 ++++++++++ .../repository/UserRepository.java | 9 +++ .../service/ServiceLayer.java | 34 ++++++++++ ...lication-lazy-load-no-trans-off.properties | 13 ++++ ...plication-lazy-load-no-trans-on.properties | 13 ++++ .../src/main/resources/data.sql | 15 ++++- ...LoadNoTransPropertyOffIntegrationTest.java | 41 ++++++++++++ ...yLoadNoTransPropertyOnIntegrationTest.java | 47 +++++++++++++ 12 files changed, 332 insertions(+), 1 deletion(-) create mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/LazyLoadNoTransSpringBootApplication.java create mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/config/DatasourceProxyBeanPostProcessor.java create mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/entity/Document.java create mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/entity/User.java create mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/repository/UserRepository.java create mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/service/ServiceLayer.java create mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties create mode 100644 persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties create mode 100644 persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/lazy_load_no_trans/LazyLoadNoTransPropertyOffIntegrationTest.java create mode 100644 persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/lazy_load_no_trans/LazyLoadNoTransPropertyOnIntegrationTest.java diff --git a/persistence-modules/spring-boot-persistence-h2/pom.xml b/persistence-modules/spring-boot-persistence-h2/pom.xml index 5b5e255211..777bc6cb2d 100644 --- a/persistence-modules/spring-boot-persistence-h2/pom.xml +++ b/persistence-modules/spring-boot-persistence-h2/pom.xml @@ -29,12 +29,30 @@ com.h2database h2 + + org.projectlombok + lombok + ${lombok.version} + compile + + + org.hibernate + hibernate-core + ${hibernate.version} + + + com.vladmihalcea + db-util + ${db-util.version} + com.baeldung.h2db.demo.server.SpringBootApp 2.0.4.RELEASE + 5.3.11.Final + 1.0.4 diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/LazyLoadNoTransSpringBootApplication.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/LazyLoadNoTransSpringBootApplication.java new file mode 100644 index 0000000000..a52d9fc2f9 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/LazyLoadNoTransSpringBootApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.h2db.lazy_load_no_trans; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +@SpringBootApplication +@EnableTransactionManagement +public class LazyLoadNoTransSpringBootApplication { + public static void main(String[] args) { + SpringApplication.run(LazyLoadNoTransSpringBootApplication.class, args); + } +} diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/config/DatasourceProxyBeanPostProcessor.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/config/DatasourceProxyBeanPostProcessor.java new file mode 100644 index 0000000000..c087427b65 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/config/DatasourceProxyBeanPostProcessor.java @@ -0,0 +1,67 @@ +package com.baeldung.h2db.lazy_load_no_trans.config; + +import net.ttddyy.dsproxy.listener.DataSourceQueryCountListener; +import net.ttddyy.dsproxy.listener.logging.CommonsQueryLoggingListener; +import net.ttddyy.dsproxy.listener.logging.DefaultQueryLogEntryCreator; +import net.ttddyy.dsproxy.listener.logging.SLF4JLogLevel; +import net.ttddyy.dsproxy.listener.logging.SLF4JQueryLoggingListener; +import net.ttddyy.dsproxy.support.ProxyDataSource; +import net.ttddyy.dsproxy.support.ProxyDataSourceBuilder; +import org.aopalliance.intercept.MethodInterceptor; +import org.aopalliance.intercept.MethodInvocation; +import org.springframework.aop.framework.ProxyFactory; +import org.springframework.beans.factory.config.BeanPostProcessor; +import org.springframework.stereotype.Component; +import org.springframework.util.ReflectionUtils; + +import javax.sql.DataSource; +import java.lang.reflect.Method; + +@Component +public class DatasourceProxyBeanPostProcessor implements BeanPostProcessor { + + @Override + public Object postProcessAfterInitialization(Object bean, String beanName) { + if (bean instanceof DataSource && !(bean instanceof ProxyDataSource)) { + // Instead of directly returning a less specific datasource bean + // (e.g.: HikariDataSource -> DataSource), return a proxy object. + // See following links for why: + // https://stackoverflow.com/questions/44237787/how-to-use-user-defined-database-proxy-in-datajpatest + // https://gitter.im/spring-projects/spring-boot?at=5983602d2723db8d5e70a904 + // http://blog.arnoldgalovics.com/2017/06/26/configuring-a-datasource-proxy-in-spring-boot/ + final ProxyFactory factory = new ProxyFactory(bean); + factory.setProxyTargetClass(true); + factory.addAdvice(new ProxyDataSourceInterceptor((DataSource) bean)); + return factory.getProxy(); + } + return bean; + } + + @Override + public Object postProcessBeforeInitialization(Object bean, String beanName) { + return bean; + } + + private static class ProxyDataSourceInterceptor implements MethodInterceptor { + private final DataSource dataSource; + + public ProxyDataSourceInterceptor(final DataSource dataSource) { + this.dataSource = ProxyDataSourceBuilder.create(dataSource) + .name("MyDS") + .multiline() + .logQueryBySlf4j(SLF4JLogLevel.INFO) + .listener(new DataSourceQueryCountListener()) + .build(); + } + + @Override + public Object invoke(final MethodInvocation invocation) throws Throwable { + final Method proxyMethod = ReflectionUtils.findMethod(this.dataSource.getClass(), + invocation.getMethod().getName()); + if (proxyMethod != null) { + return proxyMethod.invoke(this.dataSource, invocation.getArguments()); + } + return invocation.proceed(); + } + } +} diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/entity/Document.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/entity/Document.java new file mode 100644 index 0000000000..9d69e7eb58 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/entity/Document.java @@ -0,0 +1,26 @@ +package com.baeldung.h2db.lazy_load_no_trans.entity; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.hibernate.annotations.Immutable; + +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Immutable +public class Document { + + @Id + private Long id; + + private String title; + + private Long userId; +} diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/entity/User.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/entity/User.java new file mode 100644 index 0000000000..ae9cb9e4e8 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/entity/User.java @@ -0,0 +1,37 @@ +package com.baeldung.h2db.lazy_load_no_trans.entity; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; +import org.hibernate.annotations.Immutable; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; +import java.util.ArrayList; +import java.util.List; + +@Entity +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Immutable +public class User { + + @Id + @GeneratedValue + private Long id; + + private String name; + + private String comment; + + @OneToMany(mappedBy = "userId") + @Fetch(FetchMode.SUBSELECT) + private List docs = new ArrayList<>(); +} diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/repository/UserRepository.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/repository/UserRepository.java new file mode 100644 index 0000000000..bafe484163 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/repository/UserRepository.java @@ -0,0 +1,9 @@ +package com.baeldung.h2db.lazy_load_no_trans.repository; + +import com.baeldung.h2db.lazy_load_no_trans.entity.User; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface UserRepository extends JpaRepository { +} \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/service/ServiceLayer.java b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/service/ServiceLayer.java new file mode 100644 index 0000000000..ff3783fd9d --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/java/com/baeldung/h2db/lazy_load_no_trans/service/ServiceLayer.java @@ -0,0 +1,34 @@ +package com.baeldung.h2db.lazy_load_no_trans.service; + +import com.baeldung.h2db.lazy_load_no_trans.entity.User; +import com.baeldung.h2db.lazy_load_no_trans.repository.UserRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Collection; + +@Service +public class ServiceLayer { + + @Autowired + private UserRepository userRepository; + + @Transactional(readOnly = true) + public long countAllDocsTransactional() { + return countAllDocs(); + } + + public long countAllDocsNonTransactional() { + return countAllDocs(); + } + + private long countAllDocs() { + return userRepository.findAll() + .stream() + .map(User::getDocs) + .mapToLong(Collection::size) + .sum(); + } + +} diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties new file mode 100644 index 0000000000..b5fb841685 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-off.properties @@ -0,0 +1,13 @@ +spring.datasource.url=jdbc:h2:mem:mydb +spring.datasource.driverClassName=org.h2.Driver +spring.datasource.username=sa +spring.datasource.password= +spring.jpa.hibernate.ddl-auto=create-drop +spring.h2.console.enabled=true +spring.h2.console.path=/h2-console + +logging.level.org.hibernate.SQL=INFO +logging.level.org.hibernate.type=TRACE +spring.jpa.properties.hibernate.validator.apply_to_ddl=false +spring.jpa.properties.hibernate.enable_lazy_load_no_trans=false +spring.jpa.open-in-view=false \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties new file mode 100644 index 0000000000..04579e1dae --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/application-lazy-load-no-trans-on.properties @@ -0,0 +1,13 @@ +spring.datasource.url=jdbc:h2:mem:mydb +spring.datasource.driverClassName=org.h2.Driver +spring.datasource.username=sa +spring.datasource.password= +spring.jpa.hibernate.ddl-auto=create-drop +spring.h2.console.enabled=true +spring.h2.console.path=/h2-console + +logging.level.org.hibernate.SQL=INFO +logging.level.org.hibernate.type=TRACE +spring.jpa.properties.hibernate.validator.apply_to_ddl=false +spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true +spring.jpa.open-in-view=false \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-h2/src/main/resources/data.sql b/persistence-modules/spring-boot-persistence-h2/src/main/resources/data.sql index 2d7b446005..b8835e70cb 100644 --- a/persistence-modules/spring-boot-persistence-h2/src/main/resources/data.sql +++ b/persistence-modules/spring-boot-persistence-h2/src/main/resources/data.sql @@ -10,4 +10,17 @@ CREATE TABLE billionaires ( INSERT INTO billionaires (first_name, last_name, career) VALUES ('Aliko', 'Dangote', 'Billionaire Industrialist'), ('Bill', 'Gates', 'Billionaire Tech Entrepreneur'), -('Folrunsho', 'Alakija', 'Billionaire Oil Magnate'); \ No newline at end of file +('Folrunsho', 'Alakija', 'Billionaire Oil Magnate'); + +insert into USER values (101, 'user1', 'comment1'); +insert into USER values (102, 'user2', 'comment2'); +insert into USER values (103, 'user3', 'comment3'); +insert into USER values (104, 'user4', 'comment4'); +insert into USER values (105, 'user5', 'comment5'); + +insert into DOCUMENT values (1, 'doc1', 101); +insert into DOCUMENT values (2, 'doc2', 101); +insert into DOCUMENT values (3, 'doc3', 101); +insert into DOCUMENT values (4, 'doc4', 101); +insert into DOCUMENT values (5, 'doc5', 102); +insert into DOCUMENT values (6, 'doc6', 102); \ No newline at end of file diff --git a/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/lazy_load_no_trans/LazyLoadNoTransPropertyOffIntegrationTest.java b/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/lazy_load_no_trans/LazyLoadNoTransPropertyOffIntegrationTest.java new file mode 100644 index 0000000000..cb5063d8a4 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/lazy_load_no_trans/LazyLoadNoTransPropertyOffIntegrationTest.java @@ -0,0 +1,41 @@ +package com.baeldung.lazy_load_no_trans; + +import com.baeldung.h2db.lazy_load_no_trans.LazyLoadNoTransSpringBootApplication; +import com.baeldung.h2db.lazy_load_no_trans.service.ServiceLayer; +import com.vladmihalcea.sql.SQLStatementCountValidator; +import org.hibernate.LazyInitializationException; +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; + +import static org.junit.Assert.assertEquals; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = LazyLoadNoTransSpringBootApplication.class) +@ActiveProfiles("lazy-load-no-trans-off") +public class LazyLoadNoTransPropertyOffIntegrationTest { + + @Autowired + private ServiceLayer serviceLayer; + + private static final long EXPECTED_DOCS_COLLECTION_SIZE = 6; + + @Test(expected = LazyInitializationException.class) + public void whenCallNonTransactionalMethodWithPropertyOff_thenThrowException() { + serviceLayer.countAllDocsNonTransactional(); + } + + @Test + public void whenCallTransactionalMethodWithPropertyOff_thenTestPass() { + SQLStatementCountValidator.reset(); + + long docsCount = serviceLayer.countAllDocsTransactional(); + + assertEquals(EXPECTED_DOCS_COLLECTION_SIZE, docsCount); + + SQLStatementCountValidator.assertSelectCount(2); + } +} diff --git a/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/lazy_load_no_trans/LazyLoadNoTransPropertyOnIntegrationTest.java b/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/lazy_load_no_trans/LazyLoadNoTransPropertyOnIntegrationTest.java new file mode 100644 index 0000000000..5968fde7b7 --- /dev/null +++ b/persistence-modules/spring-boot-persistence-h2/src/test/java/com/baeldung/lazy_load_no_trans/LazyLoadNoTransPropertyOnIntegrationTest.java @@ -0,0 +1,47 @@ +package com.baeldung.lazy_load_no_trans; + +import com.baeldung.h2db.lazy_load_no_trans.LazyLoadNoTransSpringBootApplication; +import com.baeldung.h2db.lazy_load_no_trans.service.ServiceLayer; +import com.vladmihalcea.sql.SQLStatementCountValidator; +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; + +import static org.junit.Assert.assertEquals; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = LazyLoadNoTransSpringBootApplication.class) +@ActiveProfiles("lazy-load-no-trans-on") +public class LazyLoadNoTransPropertyOnIntegrationTest { + + @Autowired + private ServiceLayer serviceLayer; + + private static final long EXPECTED_DOCS_COLLECTION_SIZE = 6; + private static final long EXPECTED_USERS_COUNT = 5; + + @Test + public void whenCallNonTransactionalMethodWithPropertyOn_thenGetNplusOne() { + SQLStatementCountValidator.reset(); + + long docsCount = serviceLayer.countAllDocsNonTransactional(); + + assertEquals(EXPECTED_DOCS_COLLECTION_SIZE, docsCount); + + SQLStatementCountValidator.assertSelectCount(EXPECTED_USERS_COUNT + 1); + } + + @Test + public void whenCallTransactionalMethodWithPropertyOn_thenTestPass() { + SQLStatementCountValidator.reset(); + + long docsCount = serviceLayer.countAllDocsTransactional(); + + assertEquals(EXPECTED_DOCS_COLLECTION_SIZE, docsCount); + + SQLStatementCountValidator.assertSelectCount(2); + } +}