From 84d820a594f0f8cbee34f4f72096770bf30ac62b Mon Sep 17 00:00:00 2001 From: Cicio Flaviu Date: Wed, 10 Jun 2020 21:39:36 +0300 Subject: [PATCH 01/42] BAEL-4018 Spring Security - Already logged in user redirect from the login page --- .../loginredirect/LoginPageFilter.java | 39 ++++++++++++++++ .../loginredirect/LoginPageInterceptor.java | 39 ++++++++++++++++ .../LoginRedirectApplication.java | 12 +++++ .../loginredirect/LoginRedirectMvcConfig.java | 14 ++++++ .../LoginRedirectSecurityConfig.java | 43 +++++++++++++++++ .../loginredirect/UsersController.java | 32 +++++++++++++ .../spring-security-login-redirect.xml | 46 +++++++++++++++++++ .../resources/templates/userMainPage.html | 10 ++++ 8 files changed, 235 insertions(+) create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageFilter.java create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageInterceptor.java create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectApplication.java create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectMvcConfig.java create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectSecurityConfig.java create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/UsersController.java create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/main/resources/spring-security-login-redirect.xml create mode 100644 spring-security-modules/spring-security-mvc-boot-2/src/main/resources/templates/userMainPage.html diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageFilter.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageFilter.java new file mode 100644 index 0000000000..635f811e7a --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageFilter.java @@ -0,0 +1,39 @@ +package com.baeldung.loginredirect; + +import org.apache.http.HttpStatus; +import org.springframework.security.authentication.AnonymousAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.web.filter.GenericFilterBean; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +class LoginPageFilter extends GenericFilterBean { + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + if (isAuthenticated() && ((HttpServletRequest) request).getRequestURI().equals("/loginUser")) { + + String encodedRedirectURL = ((HttpServletResponse) response).encodeRedirectURL( + ((HttpServletRequest) request).getContextPath() + "/userMainPage"); + + ((HttpServletResponse) response).setStatus(HttpStatus.SC_TEMPORARY_REDIRECT); + ((HttpServletResponse) response).setHeader("Location", encodedRedirectURL); + } + chain.doFilter(request, response); + } + + private boolean isAuthenticated() { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + if (authentication == null || authentication instanceof AnonymousAuthenticationToken) { + return false; + } + return authentication.isAuthenticated(); + } +} \ No newline at end of file diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageInterceptor.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageInterceptor.java new file mode 100644 index 0000000000..f8fbe76b61 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageInterceptor.java @@ -0,0 +1,39 @@ +package com.baeldung.loginredirect; + +import org.apache.http.HttpStatus; +import org.springframework.security.authentication.AnonymousAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; +import org.springframework.web.util.UrlPathHelper; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +class LoginPageInterceptor extends HandlerInterceptorAdapter { + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { + + UrlPathHelper urlPathHelper = new UrlPathHelper(); + if (urlPathHelper.getLookupPathForRequest(request).equals("/loginUser") && isAuthenticated()) { + + String encodedRedirectURL = response.encodeRedirectURL( + request.getContextPath() + "/userMainPage"); + response.setStatus(HttpStatus.SC_TEMPORARY_REDIRECT); + response.setHeader("Location", encodedRedirectURL); + + return false; + } else { + return true; + } + } + + private boolean isAuthenticated() { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + if (authentication == null || authentication instanceof AnonymousAuthenticationToken) { + return false; + } + return authentication.isAuthenticated(); + } +} diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectApplication.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectApplication.java new file mode 100644 index 0000000000..b7f9863775 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.loginredirect; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +//@ImportResource({"classpath*:spring-security-login-redirect.xml"}) +class LoginRedirectApplication { + public static void main(String[] args) { + SpringApplication.run(LoginRedirectApplication.class, args); + } +} \ No newline at end of file diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectMvcConfig.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectMvcConfig.java new file mode 100644 index 0000000000..ca2ddcb020 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectMvcConfig.java @@ -0,0 +1,14 @@ +package com.baeldung.loginredirect; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +class LoginRedirectMvcConfig implements WebMvcConfigurer { + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(new LoginPageInterceptor()); + } +} \ No newline at end of file diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectSecurityConfig.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectSecurityConfig.java new file mode 100644 index 0000000000..8bd3200608 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectSecurityConfig.java @@ -0,0 +1,43 @@ +package com.baeldung.loginredirect; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; + +@Configuration +@EnableWebSecurity +class LoginRedirectSecurityConfig extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + auth.inMemoryAuthentication().withUser("user").password(encoder().encode("user")).roles("USER"); + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + + http + .addFilterAfter(new LoginPageFilter(), UsernamePasswordAuthenticationFilter.class) + + .authorizeRequests() + .antMatchers("/loginUser").permitAll() + .antMatchers("/user*").hasRole("USER") + + .and().formLogin().loginPage("/loginUser").loginProcessingUrl("/user_login") + .failureUrl("/loginUser?error=loginError").defaultSuccessUrl("/userMainPage").permitAll() + + .and().logout().logoutUrl("/user_logout").logoutSuccessUrl("/loginUser").deleteCookies("JSESSIONID") + .and().csrf().disable(); + } + + @Bean + public static PasswordEncoder encoder() { + return new BCryptPasswordEncoder(); + } +} diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/UsersController.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/UsersController.java new file mode 100644 index 0000000000..cfe87d9c21 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/UsersController.java @@ -0,0 +1,32 @@ +package com.baeldung.loginredirect; + +import org.springframework.security.authentication.AnonymousAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +class UsersController { + + @GetMapping("/userMainPage") + public String getUserPage() { + return "userMainPage"; + } + + @GetMapping("/loginUser") + public String getUserLoginPage() { + if (isAuthenticated()) { + return "redirect:userMainPage"; + } + return "loginUser"; + } + + private boolean isAuthenticated() { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + if (authentication == null || authentication instanceof AnonymousAuthenticationToken) { + return false; + } + return authentication.isAuthenticated(); + } +} diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/spring-security-login-redirect.xml b/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/spring-security-login-redirect.xml new file mode 100644 index 0000000000..e711abce1f --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/spring-security-login-redirect.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/templates/userMainPage.html b/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/templates/userMainPage.html new file mode 100644 index 0000000000..501d019790 --- /dev/null +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/resources/templates/userMainPage.html @@ -0,0 +1,10 @@ + + + + +Baeldung Login Redirect + + +Welcome user! Logout + + \ No newline at end of file From 3311856604a9836cbd9b49a0f458ce0e6aa0ff27 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Thu, 11 Jun 2020 14:32:12 +0200 Subject: [PATCH 02/42] Extract guava-2 --- guava-2/.gitignore | 13 +++++ guava-2/README.md | 6 +++ guava-2/pom.xml | 48 ++++++++++++++++++ .../guava/throwables}/ThrowablesUnitTest.java | 2 +- guava-2/src/test/resources/.gitignore | 13 +++++ guava-2/src/test/resources/test.out | 1 + guava-2/src/test/resources/test1.in | 1 + guava-2/src/test/resources/test1_1.in | 1 + guava-2/src/test/resources/test2.in | 4 ++ guava-2/src/test/resources/test_copy.in | 1 + guava-2/src/test/resources/test_le.txt | Bin 0 -> 4 bytes guava/README.md | 1 - pom.xml | 1 + 13 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 guava-2/.gitignore create mode 100644 guava-2/README.md create mode 100644 guava-2/pom.xml rename {guava/src/test/java/com/baeldung/guava => guava-2/src/test/java/com/baeldung/guava/throwables}/ThrowablesUnitTest.java (97%) create mode 100644 guava-2/src/test/resources/.gitignore create mode 100644 guava-2/src/test/resources/test.out create mode 100644 guava-2/src/test/resources/test1.in create mode 100644 guava-2/src/test/resources/test1_1.in create mode 100644 guava-2/src/test/resources/test2.in create mode 100644 guava-2/src/test/resources/test_copy.in create mode 100644 guava-2/src/test/resources/test_le.txt diff --git a/guava-2/.gitignore b/guava-2/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/guava-2/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/guava-2/README.md b/guava-2/README.md new file mode 100644 index 0000000000..c20fc3e7bd --- /dev/null +++ b/guava-2/README.md @@ -0,0 +1,6 @@ +## Guava + +This module contains articles a Google Guava + +### Relevant Articles: +- [Introduction to Guava Throwables](https://www.baeldung.com/guava-throwables) diff --git a/guava-2/pom.xml b/guava-2/pom.xml new file mode 100644 index 0000000000..df6d57bd09 --- /dev/null +++ b/guava-2/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + guava + 0.1.0-SNAPSHOT + guava + + + com.baeldung + parent-java + 0.0.1-SNAPSHOT + ../parent-java + + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + guava + + + src/main/resources + true + + + + + + + 3.6.1 + + + \ No newline at end of file diff --git a/guava/src/test/java/com/baeldung/guava/ThrowablesUnitTest.java b/guava-2/src/test/java/com/baeldung/guava/throwables/ThrowablesUnitTest.java similarity index 97% rename from guava/src/test/java/com/baeldung/guava/ThrowablesUnitTest.java rename to guava-2/src/test/java/com/baeldung/guava/throwables/ThrowablesUnitTest.java index 7d33b38a0e..c1707f8903 100644 --- a/guava/src/test/java/com/baeldung/guava/ThrowablesUnitTest.java +++ b/guava-2/src/test/java/com/baeldung/guava/throwables/ThrowablesUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.guava; +package com.baeldung.guava.throwables; import com.google.common.base.Throwables; import org.junit.Test; diff --git a/guava-2/src/test/resources/.gitignore b/guava-2/src/test/resources/.gitignore new file mode 100644 index 0000000000..83c05e60c8 --- /dev/null +++ b/guava-2/src/test/resources/.gitignore @@ -0,0 +1,13 @@ +*.class + +#folders# +/target +/neoDb* +/data +/src/main/webapp/WEB-INF/classes +*/META-INF/* + +# Packaged files # +*.jar +*.war +*.ear \ No newline at end of file diff --git a/guava-2/src/test/resources/test.out b/guava-2/src/test/resources/test.out new file mode 100644 index 0000000000..7a79da3803 --- /dev/null +++ b/guava-2/src/test/resources/test.out @@ -0,0 +1 @@ +John Jane Adam Tom \ No newline at end of file diff --git a/guava-2/src/test/resources/test1.in b/guava-2/src/test/resources/test1.in new file mode 100644 index 0000000000..70c379b63f --- /dev/null +++ b/guava-2/src/test/resources/test1.in @@ -0,0 +1 @@ +Hello world \ No newline at end of file diff --git a/guava-2/src/test/resources/test1_1.in b/guava-2/src/test/resources/test1_1.in new file mode 100644 index 0000000000..8318c86b35 --- /dev/null +++ b/guava-2/src/test/resources/test1_1.in @@ -0,0 +1 @@ +Test \ No newline at end of file diff --git a/guava-2/src/test/resources/test2.in b/guava-2/src/test/resources/test2.in new file mode 100644 index 0000000000..622efea9e6 --- /dev/null +++ b/guava-2/src/test/resources/test2.in @@ -0,0 +1,4 @@ +John +Jane +Adam +Tom \ No newline at end of file diff --git a/guava-2/src/test/resources/test_copy.in b/guava-2/src/test/resources/test_copy.in new file mode 100644 index 0000000000..70c379b63f --- /dev/null +++ b/guava-2/src/test/resources/test_copy.in @@ -0,0 +1 @@ +Hello world \ No newline at end of file diff --git a/guava-2/src/test/resources/test_le.txt b/guava-2/src/test/resources/test_le.txt new file mode 100644 index 0000000000000000000000000000000000000000..f7cc484bf45e18b3fe4dea78290abf122bedbad1 GIT binary patch literal 4 LcmYdcU|;|M0h9n` literal 0 HcmV?d00001 diff --git a/guava/README.md b/guava/README.md index 9c650dbc1d..720aba274d 100644 --- a/guava/README.md +++ b/guava/README.md @@ -12,5 +12,4 @@ This module contains articles a Google Guava - [Guide to Mathematical Utilities in Guava](https://www.baeldung.com/guava-math) - [Bloom Filter in Java using Guava](https://www.baeldung.com/guava-bloom-filter) - [Quick Guide to the Guava RateLimiter](https://www.baeldung.com/guava-rate-limiter) -- [Introduction to Guava Throwables](https://www.baeldung.com/guava-throwables) - [Guava Cache](https://www.baeldung.com/guava-cache) diff --git a/pom.xml b/pom.xml index 20adc4bfef..1c4401750e 100644 --- a/pom.xml +++ b/pom.xml @@ -425,6 +425,7 @@ grpc gson guava + guava-2 guava-collections guava-collections-map guava-collections-set From 99e0c207218244067d589b466b48d4d3a0673b4d Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Thu, 11 Jun 2020 14:37:27 +0200 Subject: [PATCH 03/42] Update pom.xml --- guava-2/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/guava-2/pom.xml b/guava-2/pom.xml index df6d57bd09..b19f59a9b4 100644 --- a/guava-2/pom.xml +++ b/guava-2/pom.xml @@ -4,9 +4,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - guava + guava-2 0.1.0-SNAPSHOT - guava + guava-2 com.baeldung @@ -45,4 +45,4 @@ 3.6.1 - \ No newline at end of file + From ec6e0cf7890c9658f3994588a16c4261c6172b9f Mon Sep 17 00:00:00 2001 From: Cicio Flaviu Date: Mon, 15 Jun 2020 10:06:37 +0300 Subject: [PATCH 04/42] BAEL-4018 Improved login redirect classes. --- .../baeldung/loginredirect/LoginPageFilter.java | 16 ++++++++++------ .../loginredirect/LoginPageInterceptor.java | 4 ++-- .../loginredirect/LoginRedirectApplication.java | 3 ++- .../baeldung/loginredirect/UsersController.java | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageFilter.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageFilter.java index 635f811e7a..3c6d076756 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageFilter.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageFilter.java @@ -18,20 +18,24 @@ class LoginPageFilter extends GenericFilterBean { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - if (isAuthenticated() && ((HttpServletRequest) request).getRequestURI().equals("/loginUser")) { + HttpServletRequest servletRequest = (HttpServletRequest) request; + HttpServletResponse servletResponse = (HttpServletResponse) response; + + if (isAuthenticated() && "/loginUser".equals(servletRequest.getRequestURI())) { String encodedRedirectURL = ((HttpServletResponse) response).encodeRedirectURL( - ((HttpServletRequest) request).getContextPath() + "/userMainPage"); + servletRequest.getContextPath() + "/userMainPage"); - ((HttpServletResponse) response).setStatus(HttpStatus.SC_TEMPORARY_REDIRECT); - ((HttpServletResponse) response).setHeader("Location", encodedRedirectURL); + servletResponse.setStatus(HttpStatus.SC_TEMPORARY_REDIRECT); + servletResponse.setHeader("Location", encodedRedirectURL); } - chain.doFilter(request, response); + + chain.doFilter(servletRequest, servletResponse); } private boolean isAuthenticated() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - if (authentication == null || authentication instanceof AnonymousAuthenticationToken) { + if (authentication == null || AnonymousAuthenticationToken.class.isAssignableFrom(authentication.getClass())) { return false; } return authentication.isAuthenticated(); diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageInterceptor.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageInterceptor.java index f8fbe76b61..aa93201f37 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageInterceptor.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginPageInterceptor.java @@ -16,7 +16,7 @@ class LoginPageInterceptor extends HandlerInterceptorAdapter { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { UrlPathHelper urlPathHelper = new UrlPathHelper(); - if (urlPathHelper.getLookupPathForRequest(request).equals("/loginUser") && isAuthenticated()) { + if ("/loginUser".equals(urlPathHelper.getLookupPathForRequest(request)) && isAuthenticated()) { String encodedRedirectURL = response.encodeRedirectURL( request.getContextPath() + "/userMainPage"); @@ -31,7 +31,7 @@ class LoginPageInterceptor extends HandlerInterceptorAdapter { private boolean isAuthenticated() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - if (authentication == null || authentication instanceof AnonymousAuthenticationToken) { + if (authentication == null || AnonymousAuthenticationToken.class.isAssignableFrom(authentication.getClass())) { return false; } return authentication.isAuthenticated(); diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectApplication.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectApplication.java index b7f9863775..1e44240449 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectApplication.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/LoginRedirectApplication.java @@ -2,9 +2,10 @@ package com.baeldung.loginredirect; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ImportResource; @SpringBootApplication -//@ImportResource({"classpath*:spring-security-login-redirect.xml"}) +@ImportResource({"classpath*:spring-security-login-redirect.xml"}) class LoginRedirectApplication { public static void main(String[] args) { SpringApplication.run(LoginRedirectApplication.class, args); diff --git a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/UsersController.java b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/UsersController.java index cfe87d9c21..308495d2ab 100644 --- a/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/UsersController.java +++ b/spring-security-modules/spring-security-mvc-boot-2/src/main/java/com/baeldung/loginredirect/UsersController.java @@ -24,7 +24,7 @@ class UsersController { private boolean isAuthenticated() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - if (authentication == null || authentication instanceof AnonymousAuthenticationToken) { + if (authentication == null || AnonymousAuthenticationToken.class.isAssignableFrom(authentication.getClass())) { return false; } return authentication.isAuthenticated(); From c4ca7c2989c94db3535f059150a0c83fcab4f643 Mon Sep 17 00:00:00 2001 From: Graham Cox Date: Sun, 21 Jun 2020 10:10:24 +0100 Subject: [PATCH 05/42] Moved the 2048 game into algorithms-miscellaneous-6 --- .../src/main/java/com/baeldung/algorithms/play2048/Board.java | 0 .../src/main/java/com/baeldung/algorithms/play2048/Cell.java | 0 .../main/java/com/baeldung/algorithms/play2048/Computer.java | 0 .../src/main/java/com/baeldung/algorithms/play2048/Human.java | 0 .../src/main/java/com/baeldung/algorithms/play2048/Move.java | 0 .../main/java/com/baeldung/algorithms/play2048/Play2048.java | 2 +- 6 files changed, 1 insertion(+), 1 deletion(-) rename {algorithms-miscellaneous-2 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/play2048/Board.java (100%) rename {algorithms-miscellaneous-2 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/play2048/Cell.java (100%) rename {algorithms-miscellaneous-2 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/play2048/Computer.java (100%) rename {algorithms-miscellaneous-2 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/play2048/Human.java (100%) rename {algorithms-miscellaneous-2 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/play2048/Move.java (100%) rename {algorithms-miscellaneous-2 => algorithms-miscellaneous-6}/src/main/java/com/baeldung/algorithms/play2048/Play2048.java (98%) diff --git a/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/play2048/Board.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/play2048/Board.java similarity index 100% rename from algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/play2048/Board.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/play2048/Board.java diff --git a/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/play2048/Cell.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/play2048/Cell.java similarity index 100% rename from algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/play2048/Cell.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/play2048/Cell.java diff --git a/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/play2048/Computer.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/play2048/Computer.java similarity index 100% rename from algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/play2048/Computer.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/play2048/Computer.java diff --git a/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/play2048/Human.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/play2048/Human.java similarity index 100% rename from algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/play2048/Human.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/play2048/Human.java diff --git a/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/play2048/Move.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/play2048/Move.java similarity index 100% rename from algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/play2048/Move.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/play2048/Move.java diff --git a/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/play2048/Play2048.java b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/play2048/Play2048.java similarity index 98% rename from algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/play2048/Play2048.java rename to algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/play2048/Play2048.java index ec5b3dca40..2f7c4d254c 100644 --- a/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/play2048/Play2048.java +++ b/algorithms-miscellaneous-6/src/main/java/com/baeldung/algorithms/play2048/Play2048.java @@ -1,7 +1,7 @@ package com.baeldung.algorithms.play2048; public class Play2048 { - private static final int SIZE = 3; + private static final int SIZE = 4; private static final int INITIAL_NUMBERS = 2; public static void main(String[] args) { From d9f00b70046f15e54e5072b764c7037282751dd4 Mon Sep 17 00:00:00 2001 From: Ali Dehghani Date: Wed, 24 Jun 2020 02:14:24 +0430 Subject: [PATCH 06/42] The Stack-Walking API for Currently Executing Method --- .../CurrentExecutingMethodUnitTest.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 core-java-modules/core-java-9-new-features/src/test/java/com/baeldung/java9/currentmethod/CurrentExecutingMethodUnitTest.java diff --git a/core-java-modules/core-java-9-new-features/src/test/java/com/baeldung/java9/currentmethod/CurrentExecutingMethodUnitTest.java b/core-java-modules/core-java-9-new-features/src/test/java/com/baeldung/java9/currentmethod/CurrentExecutingMethodUnitTest.java new file mode 100644 index 0000000000..6a130834e0 --- /dev/null +++ b/core-java-modules/core-java-9-new-features/src/test/java/com/baeldung/java9/currentmethod/CurrentExecutingMethodUnitTest.java @@ -0,0 +1,23 @@ +package com.baeldung.java9.currentmethod; + +import org.junit.Test; + +import java.util.Optional; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +public class CurrentExecutingMethodUnitTest { + + @Test + public void givenJava9_whenWalkingTheStack_thenFindMethod() { + StackWalker walker = StackWalker.getInstance(); + Optional methodName = walker.walk(frames -> frames + .findFirst() + .map(StackWalker.StackFrame::getMethodName) + ); + + assertTrue(methodName.isPresent()); + assertEquals("givenJava9_whenWalkingTheStack_thenFindMethod", methodName.get()); + } +} From ac98a2f029014c700fa272f82b7a57bf60e68a35 Mon Sep 17 00:00:00 2001 From: Loredana Date: Thu, 25 Jun 2020 10:03:34 +0300 Subject: [PATCH 07/42] BAEL-4088 move code to spring-mvc-java-2 module --- spring-framework-web/README.md | 7 --- spring-framework-web/pom.xml | 55 ------------------- spring-mvc-java-2/README.md | 3 +- spring-mvc-java-2/pom.xml | 7 ++- .../src/main/resources/targetFile.tmp | 1 + .../file/ConvertMultipartFileUnitTest.java | 0 6 files changed, 9 insertions(+), 64 deletions(-) delete mode 100644 spring-framework-web/README.md delete mode 100644 spring-framework-web/pom.xml create mode 100644 spring-mvc-java-2/src/main/resources/targetFile.tmp rename {spring-framework-web => spring-mvc-java-2}/src/test/java/com/baeldung/multipart/file/ConvertMultipartFileUnitTest.java (100%) diff --git a/spring-framework-web/README.md b/spring-framework-web/README.md deleted file mode 100644 index 9c21e93b83..0000000000 --- a/spring-framework-web/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## Spring Framework Web - -This module contains articles about the Spring Framework for the Web. - -### Relevant Articles - -- [Converting a Spring MultipartFile to a File](https://www.baeldung.com/converting-spring-multipartfile-to-a-file) diff --git a/spring-framework-web/pom.xml b/spring-framework-web/pom.xml deleted file mode 100644 index 50029b4ba8..0000000000 --- a/spring-framework-web/pom.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - 4.0.0 - spring-framework-web - 0.0.1-SNAPSHOT - spring-framework-web - - - com.baeldung - parent-spring-5 - 0.0.1-SNAPSHOT - ../parent-spring-5 - - - - 2.6 - 4.12 - 3.15.0 - 2.0.8 - - - - - commons-io - commons-io - ${commons-io.version} - - - org.assertj - assertj-core - ${org.assertj.assertj-core.version} - test - - - org.springframework - spring-web - ${spring.version} - - - org.springframework - spring-mock - ${org.springframework.spring-mock.version} - test - - - junit - junit - ${junit.version} - test - - - - diff --git a/spring-mvc-java-2/README.md b/spring-mvc-java-2/README.md index 09c8d8b294..525f5a276f 100644 --- a/spring-mvc-java-2/README.md +++ b/spring-mvc-java-2/README.md @@ -3,4 +3,5 @@ - [Cache Headers in Spring MVC](https://www.baeldung.com/spring-mvc-cache-headers) - [Working with Date Parameters in Spring](https://www.baeldung.com/spring-date-parameters) - [Spring MVC @PathVariable with a dot (.) gets truncated](https://www.baeldung.com/spring-mvc-pathvariable-dot) -- [A Quick Guide to Spring MVC Matrix Variables](https://www.baeldung.com/spring-mvc-matrix-variables) \ No newline at end of file +- [A Quick Guide to Spring MVC Matrix Variables](https://www.baeldung.com/spring-mvc-matrix-variables) +- [Converting a Spring MultipartFile to a File](https://www.baeldung.com/converting-spring-multipartfile-to-a-file) diff --git a/spring-mvc-java-2/pom.xml b/spring-mvc-java-2/pom.xml index af622321cb..533a24771a 100644 --- a/spring-mvc-java-2/pom.xml +++ b/spring-mvc-java-2/pom.xml @@ -31,6 +31,11 @@ jackson-databind ${jackson.version} + + commons-io + commons-io + ${commons-io.version} + @@ -49,4 +54,4 @@ - \ No newline at end of file + diff --git a/spring-mvc-java-2/src/main/resources/targetFile.tmp b/spring-mvc-java-2/src/main/resources/targetFile.tmp new file mode 100644 index 0000000000..5e1c309dae --- /dev/null +++ b/spring-mvc-java-2/src/main/resources/targetFile.tmp @@ -0,0 +1 @@ +Hello World \ No newline at end of file diff --git a/spring-framework-web/src/test/java/com/baeldung/multipart/file/ConvertMultipartFileUnitTest.java b/spring-mvc-java-2/src/test/java/com/baeldung/multipart/file/ConvertMultipartFileUnitTest.java similarity index 100% rename from spring-framework-web/src/test/java/com/baeldung/multipart/file/ConvertMultipartFileUnitTest.java rename to spring-mvc-java-2/src/test/java/com/baeldung/multipart/file/ConvertMultipartFileUnitTest.java From 4ceb18d44501ca0dd7f5d68ff3e37d086d26cf79 Mon Sep 17 00:00:00 2001 From: Ali Dehghani Date: Fri, 26 Jun 2020 04:08:27 +0430 Subject: [PATCH 08/42] When Does Java Throw the ExceptionInInitializerError? --- .../ExceptionInInitializerErrorUnitTest.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 core-java-modules/core-java-exceptions-2/src/test/java/com/baeldung/exceptionininitializererror/ExceptionInInitializerErrorUnitTest.java diff --git a/core-java-modules/core-java-exceptions-2/src/test/java/com/baeldung/exceptionininitializererror/ExceptionInInitializerErrorUnitTest.java b/core-java-modules/core-java-exceptions-2/src/test/java/com/baeldung/exceptionininitializererror/ExceptionInInitializerErrorUnitTest.java new file mode 100644 index 0000000000..352d5ab50e --- /dev/null +++ b/core-java-modules/core-java-exceptions-2/src/test/java/com/baeldung/exceptionininitializererror/ExceptionInInitializerErrorUnitTest.java @@ -0,0 +1,55 @@ +package com.baeldung.exceptionininitializererror; + +import org.junit.Test; + +import java.lang.reflect.Constructor; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class ExceptionInInitializerErrorUnitTest { + + @Test + public void givenStaticVar_whenThrows_thenWrapsItInAnExceptionInInitializerError() { + assertThatThrownBy(StaticVar::new) + .isInstanceOf(ExceptionInInitializerError.class) + .hasCauseInstanceOf(RuntimeException.class); + } + + @Test + public void givenStaticBlock_whenThrows_thenWrapsItInAnExceptionInInitializerError() { + assertThatThrownBy(StaticBlock::new) + .isInstanceOf(ExceptionInInitializerError.class) + .hasCauseInstanceOf(ArithmeticException.class); + } + + private static class CheckedConvention { + + private static Constructor constructor; + + static { + try { + constructor = CheckedConvention.class.getDeclaredConstructor(); + } catch (NoSuchMethodException e) { + throw new ExceptionInInitializerError(e); + } + } + } + + private static class StaticVar { + + private static int state = initializeState(); + + private static int initializeState() { + throw new RuntimeException(); + } + } + + private static class StaticBlock { + + private static int state; + + static { + state = 42 / 0; + } + } +} From 7ac0bd7ca7eb0c5f35d093eeb6ed862399e98f09 Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Sun, 28 Jun 2020 01:10:13 +0530 Subject: [PATCH 09/42] Align module names, folder names and artifact id --- apache-libraries/pom.xml | 2 +- cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml | 2 +- core-java-modules/core-java-8-datetime-2/pom.xml | 2 +- machine-learning/pom.xml | 2 +- persistence-modules/persistence-libraries/pom.xml | 2 +- persistence-modules/sirix/pom.xml | 2 +- persistence-modules/spring-boot-persistence-2/pom.xml | 2 +- spring-cloud/spring-cloud-circuit-breaker/pom.xml | 2 +- spring-ejb/ejb-beans/pom.xml | 2 +- spring-mvc-crash/pom.xml | 2 +- spring-resttemplate-2/pom.xml | 2 +- twitter4j/pom.xml | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apache-libraries/pom.xml b/apache-libraries/pom.xml index fc655967ed..9f800f1e0b 100644 --- a/apache-libraries/pom.xml +++ b/apache-libraries/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - apache-miscellaneous-1 + apache-libraries 0.0.1-SNAPSHOT apache-libraries diff --git a/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml b/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml index 8706bd3b53..4d64307558 100644 --- a/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml +++ b/cloud-foundry-uaa/cf-uaa-oauth2-client/pom.xml @@ -6,7 +6,7 @@ 4.0.0 com.example cf-uaa-oauth2-client - uaa-client-webapp + cf-uaa-oauth2-client Demo project for Spring Boot diff --git a/core-java-modules/core-java-8-datetime-2/pom.xml b/core-java-modules/core-java-8-datetime-2/pom.xml index f66a89ca55..0e60941cc7 100644 --- a/core-java-modules/core-java-8-datetime-2/pom.xml +++ b/core-java-modules/core-java-8-datetime-2/pom.xml @@ -6,7 +6,7 @@ 4.0.0 core-java-8-datetime-2 ${project.parent.version} - core-java-8-datetime + core-java-8-datetime-2 jar com.baeldung.core-java-modules diff --git a/machine-learning/pom.xml b/machine-learning/pom.xml index 99b7e33579..842e488985 100644 --- a/machine-learning/pom.xml +++ b/machine-learning/pom.xml @@ -6,7 +6,7 @@ 4.0.0 machine-learning 1.0-SNAPSHOT - Supervised Learning + machine-learning jar diff --git a/persistence-modules/persistence-libraries/pom.xml b/persistence-modules/persistence-libraries/pom.xml index a72654f2aa..42f3a33a40 100644 --- a/persistence-modules/persistence-libraries/pom.xml +++ b/persistence-modules/persistence-libraries/pom.xml @@ -4,7 +4,7 @@ 4.0.0 persistence-libraries 1.0-SNAPSHOT - java-sql2o + persistence-libraries com.baeldung diff --git a/persistence-modules/sirix/pom.xml b/persistence-modules/sirix/pom.xml index 0f114966f7..67de507cca 100644 --- a/persistence-modules/sirix/pom.xml +++ b/persistence-modules/sirix/pom.xml @@ -6,7 +6,7 @@ io.sirix sirix 1.0-SNAPSHOT - core-api-tutorial + sirix jar http://maven.apache.org diff --git a/persistence-modules/spring-boot-persistence-2/pom.xml b/persistence-modules/spring-boot-persistence-2/pom.xml index f36d8fc43f..e90d61fda3 100644 --- a/persistence-modules/spring-boot-persistence-2/pom.xml +++ b/persistence-modules/spring-boot-persistence-2/pom.xml @@ -6,7 +6,7 @@ com.baeldung.boot.persistence spring-boot-persistence-2 0.0.1-SNAPSHOT - spring-boot-jdbi + spring-boot-persistence-2 Sample SpringBoot JDBI Project diff --git a/spring-cloud/spring-cloud-circuit-breaker/pom.xml b/spring-cloud/spring-cloud-circuit-breaker/pom.xml index a179f3c831..494bd916fe 100644 --- a/spring-cloud/spring-cloud-circuit-breaker/pom.xml +++ b/spring-cloud/spring-cloud-circuit-breaker/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 spring-cloud-circuit-breaker - spring-cloud-gateway + spring-cloud-circuit-breaker jar diff --git a/spring-ejb/ejb-beans/pom.xml b/spring-ejb/ejb-beans/pom.xml index c9edfc21f8..feb212b5a6 100644 --- a/spring-ejb/ejb-beans/pom.xml +++ b/spring-ejb/ejb-beans/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.baeldung.singletonsession ejb-beans - spring-ejb-beans + ejb-beans com.baeldung.spring.ejb diff --git a/spring-mvc-crash/pom.xml b/spring-mvc-crash/pom.xml index d23e18361b..8a902d4937 100644 --- a/spring-mvc-crash/pom.xml +++ b/spring-mvc-crash/pom.xml @@ -5,7 +5,7 @@ 4.0.0 spring-mvc-crash 0.1-SNAPSHOT - spring-mvc-xml + spring-mvc-crash war diff --git a/spring-resttemplate-2/pom.xml b/spring-resttemplate-2/pom.xml index 1a594fd21e..b1d6f60c53 100644 --- a/spring-resttemplate-2/pom.xml +++ b/spring-resttemplate-2/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - spring-resttemplate + spring-resttemplate-2 0.1-SNAPSHOT spring-resttemplate-2 war diff --git a/twitter4j/pom.xml b/twitter4j/pom.xml index 0c36e72892..e2579bf73e 100644 --- a/twitter4j/pom.xml +++ b/twitter4j/pom.xml @@ -3,7 +3,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 twitter4j - twitter4J + twitter4j jar From d1244f83309bbbfb26a56c1752e55b4f7f54a569 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 28 Jun 2020 13:45:05 +0530 Subject: [PATCH 10/42] JAVA-49: Removed module maven-all, to be replaced with maven-modules --- maven-all/README.md | 8 - maven-all/compiler-plugin-java-9/README.md | 3 - maven-all/compiler-plugin-java-9/pom.xml | 30 -- .../maven/java9/MavenCompilerPlugin.java | 9 - .../src/main/java/module-info.java | 3 - maven-all/maven-custom-plugin/README.md | 3 - .../counter-maven-plugin/pom.xml | 80 ----- .../validator/DependencyCounterMojo.java | 45 --- .../maven-custom-plugin/usage-example/pom.xml | 51 --- maven-all/maven-unused-dependencies/pom.xml | 47 --- .../UnusedDependenciesExample.java | 17 - maven-all/maven-war-plugin/README.md | 7 - maven-all/maven-war-plugin/pom.xml | 32 -- maven-all/maven/.gitignore | 2 - maven-all/maven/README.md | 18 - maven-all/maven/custom-rule/pom.xml | 68 ---- .../com/baeldung/enforcer/MyCustomRule.java | 43 --- maven-all/maven/input-resources/baeldung.png | Bin 4318 -> 0 bytes maven-all/maven/input-resources/baeldung.txt | 1 - .../maven/input-resources/verifications.xml | 9 - maven-all/maven/maven-enforcer/README.md | 3 - maven-all/maven/maven-enforcer/pom.xml | 75 ----- maven-all/maven/pom.xml | 314 ------------------ maven-all/maven/proxy/README.md | 3 - maven-all/maven/proxy/settings.xml | 43 --- .../security/redirect/settings-security.xml | 6 - .../maven/security/settings-security.xml | 7 - .../com/baeldung/maven/it/RestITCase.java | 24 -- .../com/baeldung/maven/plugins/Foo.java | 10 - .../com/baeldung/maven/it/EndpointConfig.java | 9 - .../com/baeldung/maven/it/RestEndpoint.java | 12 - .../java/com/baeldung/maven/plugins/Data.java | 16 - .../maven/plugins/MultipleSrcFolders.java | 9 - .../maven/src/main/resources/logback.xml | 13 - .../maven/src/main/webapp/WEB-INF/web.xml | 17 - .../com/baeldung/maven/it/Integration.java | 4 - .../java/com/baeldung/maven/it/RestIT.java | 24 -- .../maven/it/RestIntegrationTest.java | 24 -- .../com/baeldung/maven/it/RestJUnitTest.java | 26 -- .../com/baeldung/maven/plugins/DataCheck.java | 15 - .../baeldung/maven/plugins/DataUnitTest.java | 15 - .../src/test/java/testfail/TestFail.java | 18 - maven-all/pom.xml | 25 -- maven-all/profiles/README.md | 7 - maven-all/profiles/pom.xml | 94 ------ maven-all/versions-maven-plugin/README.md | 7 - .../versions-maven-plugin/original/pom.xml | 82 ----- maven-all/versions-maven-plugin/pom.xml | 81 ----- .../versions-maven-plugin/run-the-demo.sh | 74 ----- 49 files changed, 1533 deletions(-) delete mode 100644 maven-all/README.md delete mode 100644 maven-all/compiler-plugin-java-9/README.md delete mode 100644 maven-all/compiler-plugin-java-9/pom.xml delete mode 100644 maven-all/compiler-plugin-java-9/src/main/java/com/baeldung/maven/java9/MavenCompilerPlugin.java delete mode 100644 maven-all/compiler-plugin-java-9/src/main/java/module-info.java delete mode 100644 maven-all/maven-custom-plugin/README.md delete mode 100644 maven-all/maven-custom-plugin/counter-maven-plugin/pom.xml delete mode 100644 maven-all/maven-custom-plugin/counter-maven-plugin/src/main/java/com/baeldung/maven/plugin/validator/DependencyCounterMojo.java delete mode 100644 maven-all/maven-custom-plugin/usage-example/pom.xml delete mode 100644 maven-all/maven-unused-dependencies/pom.xml delete mode 100644 maven-all/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java delete mode 100644 maven-all/maven-war-plugin/README.md delete mode 100644 maven-all/maven-war-plugin/pom.xml delete mode 100644 maven-all/maven/.gitignore delete mode 100644 maven-all/maven/README.md delete mode 100644 maven-all/maven/custom-rule/pom.xml delete mode 100644 maven-all/maven/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java delete mode 100644 maven-all/maven/input-resources/baeldung.png delete mode 100644 maven-all/maven/input-resources/baeldung.txt delete mode 100644 maven-all/maven/input-resources/verifications.xml delete mode 100644 maven-all/maven/maven-enforcer/README.md delete mode 100644 maven-all/maven/maven-enforcer/pom.xml delete mode 100644 maven-all/maven/pom.xml delete mode 100644 maven-all/maven/proxy/README.md delete mode 100644 maven-all/maven/proxy/settings.xml delete mode 100644 maven-all/maven/security/redirect/settings-security.xml delete mode 100644 maven-all/maven/security/settings-security.xml delete mode 100644 maven-all/maven/src/integration-test/java/com/baeldung/maven/it/RestITCase.java delete mode 100644 maven-all/maven/src/main/another-src/com/baeldung/maven/plugins/Foo.java delete mode 100644 maven-all/maven/src/main/java/com/baeldung/maven/it/EndpointConfig.java delete mode 100644 maven-all/maven/src/main/java/com/baeldung/maven/it/RestEndpoint.java delete mode 100644 maven-all/maven/src/main/java/com/baeldung/maven/plugins/Data.java delete mode 100644 maven-all/maven/src/main/java/com/baeldung/maven/plugins/MultipleSrcFolders.java delete mode 100644 maven-all/maven/src/main/resources/logback.xml delete mode 100644 maven-all/maven/src/main/webapp/WEB-INF/web.xml delete mode 100644 maven-all/maven/src/test/java/com/baeldung/maven/it/Integration.java delete mode 100644 maven-all/maven/src/test/java/com/baeldung/maven/it/RestIT.java delete mode 100644 maven-all/maven/src/test/java/com/baeldung/maven/it/RestIntegrationTest.java delete mode 100644 maven-all/maven/src/test/java/com/baeldung/maven/it/RestJUnitTest.java delete mode 100644 maven-all/maven/src/test/java/com/baeldung/maven/plugins/DataCheck.java delete mode 100644 maven-all/maven/src/test/java/com/baeldung/maven/plugins/DataUnitTest.java delete mode 100644 maven-all/maven/src/test/java/testfail/TestFail.java delete mode 100644 maven-all/pom.xml delete mode 100644 maven-all/profiles/README.md delete mode 100644 maven-all/profiles/pom.xml delete mode 100644 maven-all/versions-maven-plugin/README.md delete mode 100644 maven-all/versions-maven-plugin/original/pom.xml delete mode 100644 maven-all/versions-maven-plugin/pom.xml delete mode 100644 maven-all/versions-maven-plugin/run-the-demo.sh diff --git a/maven-all/README.md b/maven-all/README.md deleted file mode 100644 index b448be2cd0..0000000000 --- a/maven-all/README.md +++ /dev/null @@ -1,8 +0,0 @@ -## Apache Maven - -This module contains articles about Apache Maven. Please refer to its submodules. - -### Relevant Articles - -- [Apache Maven Tutorial](https://www.baeldung.com/maven) -- [Find Unused Maven Dependencies](https://www.baeldung.com/maven-unused-dependencies) diff --git a/maven-all/compiler-plugin-java-9/README.md b/maven-all/compiler-plugin-java-9/README.md deleted file mode 100644 index 0e02d56946..0000000000 --- a/maven-all/compiler-plugin-java-9/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles - -- [Maven Compiler Plugin](https://www.baeldung.com/maven-compiler-plugin) diff --git a/maven-all/compiler-plugin-java-9/pom.xml b/maven-all/compiler-plugin-java-9/pom.xml deleted file mode 100644 index 6baadb451c..0000000000 --- a/maven-all/compiler-plugin-java-9/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - 4.0.0 - com.baeldung - compiler-plugin-java-9 - 0.0.1-SNAPSHOT - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${compiler.plugin.version} - - ${source.version} - ${target.version} - - - - - - - 3.8.0 - 9 - 9 - - - \ No newline at end of file diff --git a/maven-all/compiler-plugin-java-9/src/main/java/com/baeldung/maven/java9/MavenCompilerPlugin.java b/maven-all/compiler-plugin-java-9/src/main/java/com/baeldung/maven/java9/MavenCompilerPlugin.java deleted file mode 100644 index b460d6e38c..0000000000 --- a/maven-all/compiler-plugin-java-9/src/main/java/com/baeldung/maven/java9/MavenCompilerPlugin.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.maven.java9; - -import static javax.xml.XMLConstants.XML_NS_PREFIX; - -public class MavenCompilerPlugin { - public static void main(String[] args) { - System.out.println("The XML namespace prefix is: " + XML_NS_PREFIX); - } -} diff --git a/maven-all/compiler-plugin-java-9/src/main/java/module-info.java b/maven-all/compiler-plugin-java-9/src/main/java/module-info.java deleted file mode 100644 index afc1d45e71..0000000000 --- a/maven-all/compiler-plugin-java-9/src/main/java/module-info.java +++ /dev/null @@ -1,3 +0,0 @@ -module com.baeldung.maven.java9 { - requires java.xml; -} \ No newline at end of file diff --git a/maven-all/maven-custom-plugin/README.md b/maven-all/maven-custom-plugin/README.md deleted file mode 100644 index 55d147c337..0000000000 --- a/maven-all/maven-custom-plugin/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: - -- [How to Create a Maven Plugin](https://www.baeldung.com/maven-plugin) diff --git a/maven-all/maven-custom-plugin/counter-maven-plugin/pom.xml b/maven-all/maven-custom-plugin/counter-maven-plugin/pom.xml deleted file mode 100644 index 7ddf5b739c..0000000000 --- a/maven-all/maven-custom-plugin/counter-maven-plugin/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - 4.0.0 - com.baeldung - counter-maven-plugin - 0.0.1-SNAPSHOT - counter-maven-plugin Maven Mojo - maven-plugin - http://maven.apache.org - - - Baeldung - https://www.baeldung.com/ - - - - - org.apache.maven - maven-plugin-api - ${maven-plugin-api.version} - - - org.apache.maven.plugin-tools - maven-plugin-annotations - ${maven-plugin-annotations.version} - provided - - - org.apache.maven - maven-project - ${maven-project.version} - - - - - - - - org.apache.maven.plugins - maven-plugin-plugin - ${maven-plugin-plugin.version} - - - org.apache.maven.plugins - maven-site-plugin - ${maven-site-plugin.version} - - - - - - - - - org.apache.maven.plugins - maven-plugin-plugin - - - - report - - - - - - - - - 1.8 - 1.8 - 3.6.2 - 3.6.0 - 2.2.1 - 3.6.0 - 3.8.2 - - - \ No newline at end of file diff --git a/maven-all/maven-custom-plugin/counter-maven-plugin/src/main/java/com/baeldung/maven/plugin/validator/DependencyCounterMojo.java b/maven-all/maven-custom-plugin/counter-maven-plugin/src/main/java/com/baeldung/maven/plugin/validator/DependencyCounterMojo.java deleted file mode 100644 index 4bb53b20cf..0000000000 --- a/maven-all/maven-custom-plugin/counter-maven-plugin/src/main/java/com/baeldung/maven/plugin/validator/DependencyCounterMojo.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.baeldung.maven.plugin.validator; - -import java.util.List; - -import org.apache.maven.model.Dependency; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; - -/** - * Counts the number of maven dependencies of a project. - * - * It can be filtered by scope. - * - */ -@Mojo(name = "dependency-counter", defaultPhase = LifecyclePhase.COMPILE) -public class DependencyCounterMojo extends AbstractMojo { - - /** - * Scope to filter the dependencies. - */ - @Parameter(property = "scope") - String scope; - - /** - * Gives access to the Maven project information. - */ - @Parameter(defaultValue = "${project}", required = true, readonly = true) - MavenProject project; - - public void execute() throws MojoExecutionException, MojoFailureException { - List dependencies = project.getDependencies(); - - long numDependencies = dependencies.stream() - .filter(d -> (scope == null || scope.isEmpty()) || scope.equals(d.getScope())) - .count(); - - getLog().info("Number of dependencies: " + numDependencies); - } - -} diff --git a/maven-all/maven-custom-plugin/usage-example/pom.xml b/maven-all/maven-custom-plugin/usage-example/pom.xml deleted file mode 100644 index ef6f08a3fb..0000000000 --- a/maven-all/maven-custom-plugin/usage-example/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - 4.0.0 - com.baeldung - example - 0.0.1-SNAPSHOT - pom - - - - org.apache.commons - commons-lang3 - ${commons.lang3.version} - - - junit - junit - ${junit.version} - test - - - - - - - com.baeldung - counter-maven-plugin - 0.0.1-SNAPSHOT - - - - dependency-counter - - - - - test - - - - - - - 3.9 - 4.12 - - - diff --git a/maven-all/maven-unused-dependencies/pom.xml b/maven-all/maven-unused-dependencies/pom.xml deleted file mode 100644 index 825858e481..0000000000 --- a/maven-all/maven-unused-dependencies/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - 4.0.0 - com.baeldung - maven-unused-dependencies - 0.0.1-SNAPSHOT - - - 3.2.2 - 1.7.25 - 3.1.2 - 3.1 - - - - - commons-collections - commons-collections - ${commons-collections.version} - - - org.slf4j - slf4j-api - ${slf4j-api.version} - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - 1.8 - 1.8 - - - - maven-dependency-plugin - ${maven-dependency-plugin.version} - - - - - \ No newline at end of file diff --git a/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java b/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java deleted file mode 100644 index c9390880ed..0000000000 --- a/maven-all/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.baeldung.mavendependencyplugin; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class UnusedDependenciesExample { - - /** - * When the Maven dependency analyzer analyzes the code, it will see that the slf4j dependency is being used in this method. - * - * @return the slf4j {@link Logger}. - */ - public Logger getLogger() { - return LoggerFactory.getLogger(UnusedDependenciesExample.class); - } - -} diff --git a/maven-all/maven-war-plugin/README.md b/maven-all/maven-war-plugin/README.md deleted file mode 100644 index 09d33772f0..0000000000 --- a/maven-all/maven-war-plugin/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## Maven WAR Plugin - -This module contains articles about the Maven WAR Plugin. - -### Relevant Articles - -- [Eclipse Error: web.xml is missing and failOnMissingWebXml is set to true](https://www.baeldung.com/eclipse-error-web-xml-missing) diff --git a/maven-all/maven-war-plugin/pom.xml b/maven-all/maven-war-plugin/pom.xml deleted file mode 100644 index 915be306ca..0000000000 --- a/maven-all/maven-war-plugin/pom.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - 4.0.0 - com.baeldung - maven-war-plugin - 0.0.1-SNAPSHOT - maven-war-plugin - war - - - - - maven-war-plugin - - ${war.plugin.version} - - - false - - - - - - - - false - 3.1.0 - - - \ No newline at end of file diff --git a/maven-all/maven/.gitignore b/maven-all/maven/.gitignore deleted file mode 100644 index bae0b0d7ce..0000000000 --- a/maven-all/maven/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/output-resources -/.idea/ diff --git a/maven-all/maven/README.md b/maven-all/maven/README.md deleted file mode 100644 index c5f46ca184..0000000000 --- a/maven-all/maven/README.md +++ /dev/null @@ -1,18 +0,0 @@ -## Apache Maven - -This module contains articles about core Apache Maven. Articles about other Maven plugins (such as the Maven WAR Plugin) -have their own dedicated modules. - -### Relevant Articles - -- [Guide to the Core Maven Plugins](https://www.baeldung.com/core-maven-plugins) -- [Maven Resources Plugin](https://www.baeldung.com/maven-resources-plugin) -- [Quick Guide to the Maven Surefire Plugin](https://www.baeldung.com/maven-surefire-plugin) -- [The Maven Failsafe Plugin](https://www.baeldung.com/maven-failsafe-plugin) -- [The Maven Verifier Plugin](https://www.baeldung.com/maven-verifier-plugin) -- [The Maven Clean Plugin](https://www.baeldung.com/maven-clean-plugin) -- [Build a Jar with Maven and Ignore the Test Results](https://www.baeldung.com/maven-ignore-test-results) -- [Maven Project with Multiple Source Directories](https://www.baeldung.com/maven-project-multiple-src-directories) -- [Integration Testing with Maven](https://www.baeldung.com/maven-integration-test) -- [Apache Maven Standard Directory Layout](https://www.baeldung.com/maven-directory-structure) -- [Multi-Module Project with Maven](https://www.baeldung.com/maven-multi-module) diff --git a/maven-all/maven/custom-rule/pom.xml b/maven-all/maven/custom-rule/pom.xml deleted file mode 100644 index 6ff984cb85..0000000000 --- a/maven-all/maven/custom-rule/pom.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - 4.0.0 - custom-rule - custom-rule - - - com.baeldung - maven - 0.0.1-SNAPSHOT - - - - - - org.apache.maven.enforcer - enforcer-api - ${api.version} - - - org.apache.maven - maven-project - ${maven.version} - - - org.apache.maven - maven-core - ${maven.version} - - - org.apache.maven - maven-artifact - ${maven.version} - - - org.apache.maven - maven-plugin-api - ${maven.version} - - - org.codehaus.plexus - plexus-container-default - ${plexus-container-default.version} - - - - - - - maven-verifier-plugin - ${maven.verifier.version} - - ../input-resources/verifications.xml - false - - - - - - - 3.0.0-M2 - 2.0.9 - 1.0-alpha-9 - - - diff --git a/maven-all/maven/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java b/maven-all/maven/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java deleted file mode 100644 index db636c2308..0000000000 --- a/maven-all/maven/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2019 PloyRef - * Created by Seun Matt - * on 19 - 2 - 2019 - */ - -package com.baeldung.enforcer; - -import org.apache.maven.enforcer.rule.api.EnforcerRule; -import org.apache.maven.enforcer.rule.api.EnforcerRuleException; -import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; - -public class MyCustomRule implements EnforcerRule { - - public void execute(EnforcerRuleHelper enforcerRuleHelper) throws EnforcerRuleException { - - try { - - String groupId = (String) enforcerRuleHelper.evaluate("${project.groupId}"); - - if (groupId == null || !groupId.startsWith("com.baeldung")) { - throw new EnforcerRuleException("Project group id does not start with com.baeldung"); - } - - } - catch (ExpressionEvaluationException ex ) { - throw new EnforcerRuleException( "Unable to lookup an expression " + ex.getLocalizedMessage(), ex ); - } - } - - public boolean isCacheable() { - return false; - } - - public boolean isResultValid(EnforcerRule enforcerRule) { - return false; - } - - public String getCacheId() { - return null; - } -} diff --git a/maven-all/maven/input-resources/baeldung.png b/maven-all/maven/input-resources/baeldung.png deleted file mode 100644 index 488f52e56e45d7b2b64cd688138f85f6a7dcc0e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4318 zcmV<45Fzi0P)foQgqP5Mp zsKlyDj8On=0L9qHn!cV^kz9?3s|u#h=NMJwO{A`pKiG2N>HFWwwO4vS=G-;(rt8X6iJ z8XEtXI6k`re+$#yvwQHD5F69cv-|Le@P@4D*?ss!*Z>3R>3%Q7u3-Sze|9(i3f7ik z7e=2Mqj>-f8G&}(J7KxTR)x%TZ4aN_v0n&(_xY|OQ!CGw@Z-T?`)XjQB-1eL%d>m< zJK&7s@H~%_sp(-*)tLm^F}evS-kmQC!$qbIuP|A_)O22fANJ=cNQu13V~If1S%+{B zQYP!vq#CaFi&St1(G=r`Lz07zf+!H5H!f_?WeTk8L1e_ArrC*0LuWWDi045&bt%Bo z5qTcY`dyA|XgWLN0LCbAaA}}8Aqt}1 zC|=ukJ@tXEN=z}i$tJ|X{Hxa+EL?S#s07mS&J?q&9HnFii(@+O!sJHyQzthvjEt+A z)3#27l%~VNyA>Rga&JePbYeI|Qcn~NW|LkPX=*^GUf2uN z+MK|RUa|(e;D&N75j^`%egZ}{bOMy*MKbYc!>o}#d-kjR1bnGgrwz9GI=wTR4b4<_ z>cm@$ttylR(5XoB&Kd_n0nlbrPfe%o79;J&XdY;?bcIp|1)V4=HVN&$7V&vFdGd?= z3{>cZR*^3E*KH!odLb$x(`mjA^4~j)R`GeP2WJk6PBbf4l+mW?ik?Gj&JqHhz$^0; z2iU570bsqX7ua)lCxE5x7`7}@3Upa~iP)v2z-g%f!+yCa;9rGc^q;_(z}#<)&?zCAr$G&ZUV+Bf8MYp zWqCc-Ap;;?`5|F#8ieHnmEoJJhGs zs4yV=f!><32`u+@rE5N}W71?%2LK|pxeW9)zlDvk3;}4HIV=c4hV*BIu(4U}CwgGs z#u=3p86!6cg6V9&%5jNiuhSH#`7sPby-~0k2Jh*BG`;stfBU6p@(uXTXf(PuN1YA! zz^wmrHzu7H8e#csw1*R(=by9al#IvYP4sz;Yxr7CFX8fj{^D|&jAsq2Y{FkeV3Qz1_NL>J8UIHY3D5KHz?)9d&TyF=znlB`6Ulifkp=g z6b8kwIFI^WX*ve;2d_1x+8#BiQG6-PGcbK@m+pZ>%~m!ud2Cc|P+G7}Nm}2Qttm9oxpme`uyv30xv)y2t2m^A3rjT z{>SMA(}|N|aIuKt1WylKjs7^Dkghx--J*&fSfusG>9ptcS4UEl8cib3~PG zRo>K9Iwc8rpwnN*H~r%_?^Oo{oj#fFs(mZF^Y}e*JvXo}w^n{ zR01XvzDwt%ze%4M1h4&iw?FK^7E;Zd?{y6-IwN9Y%iE=wD~w4w4X|-=EI#;PgHR&( zbTacWQ^Ob~;J4_YktOdBCp`z1YS4-_7JcxA0MUbIlcEm+tnq8Ef6g$S# zzxa^Lsm!sQT~$c6jY)4+q#jsGyd#}HDe-c7I-N+B#00^C1T#F=_Cvin1_VqkDd_ao z65NSE=c-&NO-UPb zD*m8H^hCbrSqnQg3ej_lT7DDNv9It8~d}*I;k{g+lfvvJ&c^x zI*W(IiU$U#WWHDhvH>9WJP%n?j|rU?pP%R;+)9*khFw=)| zvmT7;Uu`|HndemsfjiM@05naa1hB&=JkI{&tL7}@v>yxx;cz2r`I1hDZP$h{IUdrc z`x9H4$jt^ao&4b~H4?hgi8pC44)Zb7B{ZcnVP6d3%_{5cIg!3%H#+m`4ekrN{ESG(zO)SG|v-$Z)7F~l`_;3TSo3fXXcKTeC~w+XDMfLJt#9UCtc`rIsPpf#jS7O(zF18H` z6FHqEdV&=d8;;98Mx>L(u#^%=iEbAit|(&S!5) zrz<`%CXd?m*pV?XQVFHAy_?T|qQ7!Dy|Ln7cB6a((MK7bY>F6J`4|s&NNTRC1UjAT z5=vFjfle?L=_Jb`cv;eIz>TQKggo8C<9( za78uWq;sR76DzYByZh1E815Wf zs@es9%kI23I!QoSxl-%}uZY-K=B<04L^|i?H-V~wvggfs+F|KL|CoCA*#K`xr%HKF zXe{C$OA(0`nOoV6 zPHJB(A_W&3SpH_}Eq@qM96>g9SRkuf;r+pa@7a$&^@HE!mLfztsRU37mG!pN2+rvw z)#tzv!UCUU21OY)&FG}z2D4Ind0@G*?|MaC(U*bqx1&K#BuD6C7LG6CokUBhj)?ai z#+4NBq+=Y(T4F-ose(>wJP6JVwd{)LHKUVB4ZehCy_n05b<1Qjcli*}SacaKJklX3 zW-QWfvpuf`on+Fb9*#7FoW2`abTO0Yq(hKP#mg^N7S&MWfsazsR8tX=Ye*-3F93w- z&WNRjyM{nu5@vW?Anv^KGWyP?8BxS_@B?vT%hVf9WZF}{i~i9~C4qM`3?w=^3EphU zOW?AB1)Wq8aUtq6`x>Jbbh2Cm@VFf$U&3AJ9RqX_<#r;!#hM!KEIn!1#xc(4?C7u% z^0p@j4Nll4#2<`Ld$E@O^j1D!VlTYrO zNtl0$2Bd;0~6cM;Wn}ZY@9wXpV3%go|P?}IqJR5ENwbVAfbh-Xqirj%Z%4Z zDCu;#R5l*Z(stb8%igXPo&0?b5RIc$Y9im?eK$Hy7WAKRRUk$Yd6TOp2%Y}P5}Mk4 zQ<_<;RDld633f#SsqdT%&llPO&}&EMh`(GZms+XDxfh)lAIv?vwav=^(i$bF{%9b3 zLDu$ajnYjCgwFaqD*(xUV0l}HHr%gwo z<}yua&{gI|$SLL+s`oQe3AC7dTSGiRB+*9cl&V0<+QV7dF;aefbc~38YQbi2sodh4 z9ld>)4C=M&96xA=e$hof^c${pqP)_SJsb0i>598()`7e zolIg1yjwYWRZLJkrzw?IbgGV-0ssNUX8e6+&;j%>ZC2F&2q6h)s5p@lC;YT2RxE&d zYyShtBL$$-i$cOyakMQSb6q~>BOL_tL_HTXK=}P=E|(tzG^8tD%YDkrsT4m;SGLzL z<&L6wfrL79WaLB3k357tDX~5nW08Dpu7%<5oYKESP;^I934)=9Kq29uEFn%zVFCbb zu6Q-+M=myzS-D!ypCM!-S8~0+EMZ=t>y%FGCs%5%ve)$D)M;?2Njlb)!=h1B4-#6IM^s-v7XHm57A6u-BnS@LBNBdj* zsz%3t`uMaj$2*+OmOd<%I_$5Cu7)%T|M+v?{1%%v{Wgu;OX&1;4)KKh((GY08m&&k zYbY_Ar+Q+pm^w71qHnBf4kyXh8_TPNJE@TklLk6XqX1Em*b;)>qZ12A>MNF-gVj7^ zcs!JA&fv_9H6f_3aRb~Hi`n+qQxrv~#N?bL_cxq`^ - - - input-resources/baeldung.txt - Welcome - - - \ No newline at end of file diff --git a/maven-all/maven/maven-enforcer/README.md b/maven-all/maven/maven-enforcer/README.md deleted file mode 100644 index 7515647a3d..0000000000 --- a/maven-all/maven/maven-enforcer/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles - -- [Maven Enforcer Plugin](https://www.baeldung.com/maven-enforcer-plugin) \ No newline at end of file diff --git a/maven-all/maven/maven-enforcer/pom.xml b/maven-all/maven/maven-enforcer/pom.xml deleted file mode 100644 index cde37eabd1..0000000000 --- a/maven-all/maven/maven-enforcer/pom.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - 4.0.0 - maven-enforcer - maven-enforcer - - - com.baeldung - maven - 0.0.1-SNAPSHOT - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - 3.0.0-M2 - - - - - - - - - - enforce - - enforce - - - - - - 3.0 - Invalid Maven version. It should, at least, be 3.0 - - - 1.8 - - - ui - WARN - - - cook - WARN - - - local,base - Missing active profiles - WARN - - - - - - - - - - maven-verifier-plugin - ${maven.verifier.version} - - ../input-resources/verifications.xml - false - - - - - - \ No newline at end of file diff --git a/maven-all/maven/pom.xml b/maven-all/maven/pom.xml deleted file mode 100644 index 0220cf8dfc..0000000000 --- a/maven-all/maven/pom.xml +++ /dev/null @@ -1,314 +0,0 @@ - - - 4.0.0 - maven - 0.0.1-SNAPSHOT - maven - pom - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - ../.. - - - - custom-rule - maven-enforcer - - - - - org.glassfish.jersey.containers - jersey-container-servlet-core - ${jersey.version} - - - org.glassfish.jersey.inject - jersey-hk2 - ${jersey.version} - - - junit - junit - ${junit.version} - test - - - - - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty.version} - - - 8999 - - quit - 9000 - - - - start-jetty - pre-integration-test - - start - - - - stop-jetty - post-integration-test - - stop - - - - - - maven-resources-plugin - ${maven.resources.version} - - output-resources - - - input-resources - - *.png - - true - - - - - - maven-compiler-plugin - ${maven.compiler.version} - - ${java.version} - ${java.version} - - -Xlint:unchecked - - - - - maven-surefire-plugin - ${maven.surefire.version} - - - DataTest.java - **/*IntegrationTest - - com.baeldung.maven.it.Integration - - TestFail.java - DataCheck.java - - true - - - - maven-failsafe-plugin - ${maven.failsafe.version} - - - - integration-test - verify - - - - - - - - - maven-verifier-plugin - ${maven.verifier.version} - - input-resources/verifications.xml - - - - - verify - - - - - - maven-clean-plugin - ${maven.clean.version} - - - - output-resources - - - - - - org.codehaus.mojo - build-helper-maven-plugin - ${maven.build.helper.version} - - - generate-sources - - add-source - - - - src/main/another-src - - - - - add-integration-test-source - generate-test-sources - - add-test-source - - - - src/integration-test/java - - - - - add-integration-test-resource - generate-test-resources - - add-test-resource - - - - - src/integration-test/resources - - - - - - - - - - - - default - - - - maven-surefire-plugin - ${maven.surefire.version} - - - DataTest.java - - - TestFail.java - DataCheck.java - - true - - - - - - - failsafe - - - - maven-failsafe-plugin - ${maven.failsafe.version} - - - **/*RestIT - **/RestITCase - - - - - - integration-test - verify - - - - - - - - - surefire - - - - maven-surefire-plugin - ${maven.surefire.version} - - - integration-test - - test - - - - none - - - **/*IntegrationTest - - - - - - - - - - category - - - - maven-failsafe-plugin - ${maven.failsafe.version} - - - **/* - - com.baeldung.maven.it.Integration - - - - - integration-test - verify - - - - - - - - - - - 3.0.2 - 3.8.0 - 2.22.0 - 2.22.0 - 1.1 - 3.0.0 - 3.0.0 - 9.4.11.v20180605 - 2.27 - - - \ No newline at end of file diff --git a/maven-all/maven/proxy/README.md b/maven-all/maven/proxy/README.md deleted file mode 100644 index 9ae1fd6ad5..0000000000 --- a/maven-all/maven/proxy/README.md +++ /dev/null @@ -1,3 +0,0 @@ -### Relevant Articles: - -- [Using Maven Behind a Proxy](https://www.baeldung.com/maven-behind-proxy) diff --git a/maven-all/maven/proxy/settings.xml b/maven-all/maven/proxy/settings.xml deleted file mode 100644 index 55a850a6bc..0000000000 --- a/maven-all/maven/proxy/settings.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - BaeldungProxy_Encrypted - true - http - proxy.baeldung.com - 80 - baeldung - {U2iMf+7aJXQHRquuQq6MX+n7GOeh97zB9/4e7kkEQYs=} - internal.baeldung.com|localhost|127.*|[::1] - - - - BaeldungProxy_Authenticated - true - http - proxy.baeldung.com - 80 - baeldung - changeme - internal.baeldung.com|localhost|127.*|[::1] - - - - BaeldungProxy - proxy.baeldung.com - 80 - internal.baeldung.com|localhost|127.*|[::1] - - - - - \ No newline at end of file diff --git a/maven-all/maven/security/redirect/settings-security.xml b/maven-all/maven/security/redirect/settings-security.xml deleted file mode 100644 index 37e91bd1a4..0000000000 --- a/maven-all/maven/security/redirect/settings-security.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - R:\config\settings-security.xml - diff --git a/maven-all/maven/security/settings-security.xml b/maven-all/maven/security/settings-security.xml deleted file mode 100644 index 3ac258e8a5..0000000000 --- a/maven-all/maven/security/settings-security.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - {QFMlh/6WjF8H9po9UD\}0Nv18e527jqWb6mUgIB798n4=} - diff --git a/maven-all/maven/src/integration-test/java/com/baeldung/maven/it/RestITCase.java b/maven-all/maven/src/integration-test/java/com/baeldung/maven/it/RestITCase.java deleted file mode 100644 index aaeeedb661..0000000000 --- a/maven-all/maven/src/integration-test/java/com/baeldung/maven/it/RestITCase.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.maven.it; - -import org.junit.Test; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; -import java.util.Scanner; - -import static org.junit.Assert.assertEquals; - -public class RestITCase { - @Test - public void whenSendingGet_thenMessageIsReturned() throws IOException { - String url = "http://localhost:8999"; - URLConnection connection = new URL(url).openConnection(); - try (InputStream response = connection.getInputStream(); - Scanner scanner = new Scanner(response)) { - String responseBody = scanner.nextLine(); - assertEquals("Welcome to Baeldung!", responseBody); - } - } -} diff --git a/maven-all/maven/src/main/another-src/com/baeldung/maven/plugins/Foo.java b/maven-all/maven/src/main/another-src/com/baeldung/maven/plugins/Foo.java deleted file mode 100644 index f8a6fe9853..0000000000 --- a/maven-all/maven/src/main/another-src/com/baeldung/maven/plugins/Foo.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.baeldung.maven.plugins; - -public class Foo { - - public static String foo() { - return "foo"; - } - -} - diff --git a/maven-all/maven/src/main/java/com/baeldung/maven/it/EndpointConfig.java b/maven-all/maven/src/main/java/com/baeldung/maven/it/EndpointConfig.java deleted file mode 100644 index 919210ccff..0000000000 --- a/maven-all/maven/src/main/java/com/baeldung/maven/it/EndpointConfig.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.maven.it; - -import org.glassfish.jersey.server.ResourceConfig; - -public class EndpointConfig extends ResourceConfig { - public EndpointConfig() { - register(RestEndpoint.class); - } -} diff --git a/maven-all/maven/src/main/java/com/baeldung/maven/it/RestEndpoint.java b/maven-all/maven/src/main/java/com/baeldung/maven/it/RestEndpoint.java deleted file mode 100644 index c234891865..0000000000 --- a/maven-all/maven/src/main/java/com/baeldung/maven/it/RestEndpoint.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.baeldung.maven.it; - -import javax.ws.rs.GET; -import javax.ws.rs.Path; - -@Path("/") -public class RestEndpoint { - @GET - public String hello() { - return "Welcome to Baeldung!"; - } -} diff --git a/maven-all/maven/src/main/java/com/baeldung/maven/plugins/Data.java b/maven-all/maven/src/main/java/com/baeldung/maven/plugins/Data.java deleted file mode 100644 index 6ac6f9ab46..0000000000 --- a/maven-all/maven/src/main/java/com/baeldung/maven/plugins/Data.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.maven.plugins; - -import java.util.ArrayList; -import java.util.List; - -public class Data { - List textList = new ArrayList(); - - public void addText(String text) { - textList.add(text); - } - - public List getTextList() { - return this.textList; - } -} diff --git a/maven-all/maven/src/main/java/com/baeldung/maven/plugins/MultipleSrcFolders.java b/maven-all/maven/src/main/java/com/baeldung/maven/plugins/MultipleSrcFolders.java deleted file mode 100644 index d403918dd3..0000000000 --- a/maven-all/maven/src/main/java/com/baeldung/maven/plugins/MultipleSrcFolders.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.maven.plugins; - -public class MultipleSrcFolders { - - public static void callFoo() { - Foo.foo(); - } - -} diff --git a/maven-all/maven/src/main/resources/logback.xml b/maven-all/maven/src/main/resources/logback.xml deleted file mode 100644 index 7d900d8ea8..0000000000 --- a/maven-all/maven/src/main/resources/logback.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - \ No newline at end of file diff --git a/maven-all/maven/src/main/webapp/WEB-INF/web.xml b/maven-all/maven/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index 1751ad17a5..0000000000 --- a/maven-all/maven/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - rest-servlet - org.glassfish.jersey.servlet.ServletContainer - - javax.ws.rs.Application - com.baeldung.maven.it.EndpointConfig - - - - rest-servlet - /* - - \ No newline at end of file diff --git a/maven-all/maven/src/test/java/com/baeldung/maven/it/Integration.java b/maven-all/maven/src/test/java/com/baeldung/maven/it/Integration.java deleted file mode 100644 index 112ce178ce..0000000000 --- a/maven-all/maven/src/test/java/com/baeldung/maven/it/Integration.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.baeldung.maven.it; - -public interface Integration { -} diff --git a/maven-all/maven/src/test/java/com/baeldung/maven/it/RestIT.java b/maven-all/maven/src/test/java/com/baeldung/maven/it/RestIT.java deleted file mode 100644 index 0115d34f1e..0000000000 --- a/maven-all/maven/src/test/java/com/baeldung/maven/it/RestIT.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.maven.it; - -import org.junit.Test; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; -import java.util.Scanner; - -import static org.junit.Assert.assertEquals; - -public class RestIT { - @Test - public void whenSendingGet_thenMessageIsReturned() throws IOException { - String url = "http://localhost:8999"; - URLConnection connection = new URL(url).openConnection(); - try (InputStream response = connection.getInputStream(); - Scanner scanner = new Scanner(response)) { - String responseBody = scanner.nextLine(); - assertEquals("Welcome to Baeldung!", responseBody); - } - } -} diff --git a/maven-all/maven/src/test/java/com/baeldung/maven/it/RestIntegrationTest.java b/maven-all/maven/src/test/java/com/baeldung/maven/it/RestIntegrationTest.java deleted file mode 100644 index 2f913c8429..0000000000 --- a/maven-all/maven/src/test/java/com/baeldung/maven/it/RestIntegrationTest.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.maven.it; - -import org.junit.Test; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; -import java.util.Scanner; - -import static org.junit.Assert.assertEquals; - -public class RestIntegrationTest { - @Test - public void whenSendingGet_thenMessageIsReturned() throws IOException { - String url = "http://localhost:8999"; - URLConnection connection = new URL(url).openConnection(); - try (InputStream response = connection.getInputStream(); - Scanner scanner = new Scanner(response)) { - String responseBody = scanner.nextLine(); - assertEquals("Welcome to Baeldung!", responseBody); - } - } -} diff --git a/maven-all/maven/src/test/java/com/baeldung/maven/it/RestJUnitTest.java b/maven-all/maven/src/test/java/com/baeldung/maven/it/RestJUnitTest.java deleted file mode 100644 index 60995d75bd..0000000000 --- a/maven-all/maven/src/test/java/com/baeldung/maven/it/RestJUnitTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.baeldung.maven.it; - -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; -import java.util.Scanner; - -import static org.junit.Assert.assertEquals; - -@Category(Integration.class) -public class RestJUnitTest { - @Test - public void whenSendingGet_thenMessageIsReturned() throws IOException { - String url = "http://localhost:8999"; - URLConnection connection = new URL(url).openConnection(); - try (InputStream response = connection.getInputStream(); - Scanner scanner = new Scanner(response)) { - String responseBody = scanner.nextLine(); - assertEquals("Welcome to Baeldung!", responseBody); - } - } -} diff --git a/maven-all/maven/src/test/java/com/baeldung/maven/plugins/DataCheck.java b/maven-all/maven/src/test/java/com/baeldung/maven/plugins/DataCheck.java deleted file mode 100644 index 9aaf0fb071..0000000000 --- a/maven-all/maven/src/test/java/com/baeldung/maven/plugins/DataCheck.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.maven.plugins; - -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -import com.baeldung.maven.plugins.Data; - -public class DataCheck { - @Test - public void whenDataObjectIsCreated_thenItIsNotNull() { - Data data = new Data(); - assertNotNull(data); - } -} diff --git a/maven-all/maven/src/test/java/com/baeldung/maven/plugins/DataUnitTest.java b/maven-all/maven/src/test/java/com/baeldung/maven/plugins/DataUnitTest.java deleted file mode 100644 index 197f977fec..0000000000 --- a/maven-all/maven/src/test/java/com/baeldung/maven/plugins/DataUnitTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.maven.plugins; - -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -import com.baeldung.maven.plugins.Data; - -public class DataUnitTest { - @Test - public void whenDataObjectIsNotCreated_thenItIsNull() { - Data data = null; - assertNull(data); - } -} diff --git a/maven-all/maven/src/test/java/testfail/TestFail.java b/maven-all/maven/src/test/java/testfail/TestFail.java deleted file mode 100644 index 3febd21031..0000000000 --- a/maven-all/maven/src/test/java/testfail/TestFail.java +++ /dev/null @@ -1,18 +0,0 @@ -package testfail; - -import org.junit.Test; -import org.junit.Ignore; - -import static org.junit.Assert.assertNotNull; - -public class TestFail { - - @Ignore //ignored so the entire tutorials build passes - @Test - public void whenMessageAssigned_thenItIsNotNull() { - String message = "hello there"; - message = null; - assertNotNull(message); - } - -} diff --git a/maven-all/pom.xml b/maven-all/pom.xml deleted file mode 100644 index 3a79a2a686..0000000000 --- a/maven-all/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - 4.0.0 - maven-all - 0.0.1-SNAPSHOT - maven-all - pom - - - com.baeldung - parent-modules - 1.0.0-SNAPSHOT - - - - - maven - maven-custom-plugin/counter-maven-plugin - maven-war-plugin - profiles - versions-maven-plugin - - - diff --git a/maven-all/profiles/README.md b/maven-all/profiles/README.md deleted file mode 100644 index cfbe5c397f..0000000000 --- a/maven-all/profiles/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## Maven Profiles - -This module contains articles about Maven profiles. - -### Relevant Articles - -- [Guide to Maven Profiles](https://www.baeldung.com/maven-profiles) diff --git a/maven-all/profiles/pom.xml b/maven-all/profiles/pom.xml deleted file mode 100644 index 4ae6d1ee40..0000000000 --- a/maven-all/profiles/pom.xml +++ /dev/null @@ -1,94 +0,0 @@ - - - 4.0.0 - com.baeldung - profiles - 0.0.1-SNAPSHOT - profiles - - - - no-tests - - true - - - - integration-tests - - true - - - - mutation-tests - - - active-on-jdk-11 - - 11 - - - - active-on-windows-10 - - - windows 10 - Windows - amd64 - 10.0 - - - - - active-on-property-environment - - - environment - !test - - - - - active-on-missing-file - - - target/testreport.html - - - - - active-on-present-file - - - target/artifact.jar - - - - - - - - - org.apache.maven.plugins - maven-help-plugin - ${help.plugin.version} - - - show-profiles - compile - - active-profiles - - - - - - - - - 3.2.0 - - - \ No newline at end of file diff --git a/maven-all/versions-maven-plugin/README.md b/maven-all/versions-maven-plugin/README.md deleted file mode 100644 index 19414a2a4b..0000000000 --- a/maven-all/versions-maven-plugin/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## Versions Maven Plugin - -This module contains articles about the Versions Maven Plugin. - -### Relevant Articles - -- [Use the Latest Version of a Dependency in Maven](https://www.baeldung.com/maven-dependency-latest-version) diff --git a/maven-all/versions-maven-plugin/original/pom.xml b/maven-all/versions-maven-plugin/original/pom.xml deleted file mode 100644 index f81596661e..0000000000 --- a/maven-all/versions-maven-plugin/original/pom.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - 4.0.0 - com.baeldung - original - 0.0.1-SNAPSHOT - - - - - commons-io - commons-io - ${commons-io.version} - - - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - - org.apache.commons - commons-compress - ${commons-compress-version} - - - - commons-beanutils - commons-beanutils - ${commons-beanutils.version} - - - - - - - - org.codehaus.mojo - versions-maven-plugin - ${versions.plugin.version} - - - org.apache.commons:commons-collections4 - - - - - - - - - apache.snapshots - Apache Development Snapshot Repository - https://repository.apache.org/content/repositories/snapshots/ - - false - - - true - - - - - - 1.15 - 2.3 - 4.0 - 3.0 - 1.9.1 - 2.7 - - - \ No newline at end of file diff --git a/maven-all/versions-maven-plugin/pom.xml b/maven-all/versions-maven-plugin/pom.xml deleted file mode 100644 index 9793f55b28..0000000000 --- a/maven-all/versions-maven-plugin/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - 4.0.0 - com.baeldung - versions-maven-plugin - 0.0.1-SNAPSHOT - versions-maven-plugin - - - - commons-io - commons-io - ${commons.io.version} - - - - org.apache.commons - commons-collections4 - ${commons.collections4.version} - - - - org.apache.commons - commons-lang3 - ${commons.lang3.version} - - - - org.apache.commons - commons-compress - ${commons-compress-version} - - - - commons-beanutils - commons-beanutils - ${commons.beanutils.version} - - - - - - - org.codehaus.mojo - versions-maven-plugin - ${versions.plugin.version} - - - org.apache.commons:commons-collections4 - - - - - - - - - apache.snapshots - Apache Development Snapshot Repository - https://repository.apache.org/content/repositories/snapshots/ - - false - - - true - - - - - - 1.15 - 2.3 - 2.7 - 1.9.1 - 3.0 - 4.0 - - - \ No newline at end of file diff --git a/maven-all/versions-maven-plugin/run-the-demo.sh b/maven-all/versions-maven-plugin/run-the-demo.sh deleted file mode 100644 index 89ca871e01..0000000000 --- a/maven-all/versions-maven-plugin/run-the-demo.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -#function to display commands -exe() { echo -e "\$ $@\n" ; "$@" ; } - -TEXT_COLOR='\033[1;33m' #Yellow -NO_COLOR='\033[0m' # No Color - -clear - -echo -e "======================================================================================" -echo -e " Showcase for the BAELDUNG tutorial \"Use the latest version of a dependency in Maven\"" -echo -e " Author: Andrea Ligios" -echo -e "======================================================================================" - -echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" -echo -e " Resetting the demo environment (which will be altered during the run): " -echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" -rm -f pom.xml.versionsBackup -cp original/pom.xml pom.xml -ls -lt pom.* -echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" -echo -e " Checking for newer versions of the Maven dependencies:" -echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" -exe mvn versions:display-dependency-updates -echo -read -p "Press enter to continue" - -echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" -echo -e " Updating SNAPSHOT dependencies to their RELEASE version, if any:" -echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" -exe mvn versions:use-releases -echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" -echo -e " A backup has been created automatically:" -echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" -ls -lt pom.* -echo -read -p "Press enter to continue" - -echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" -echo -e " Updating RELEASE dependencies to their *next* RELEASE version:" -echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" -exe mvn versions:use-next-releases -echo -read -p "Press enter to continue" - -echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" -echo -e " Reverting every modification made since the beginning:" -echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" -exe mvn versions:revert -echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" -echo -e " The backup is gone, and the pom.xml contains the initial dependencies:" -echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" -ls -lt pom.* -echo -read -p "Press enter to continue" - -echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" -echo -e " Updating RELEASE dependencies to their *latest* RELEASE version:" -echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" -exe mvn versions:use-latest-releases -echo -read -p "Press enter to continue" - -echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" -echo -e " Committing the modifications to pom.xml:" -echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" -exe mvn versions:commit -echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" -echo -e " The backup is gone, and the pom.xml contains the latest dependencies:" -echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" -ls -lt pom.* -echo - -echo -e "${TEXT_COLOR}\nThat's all folks!${NO_COLOR}\n" From 2b3869871321fccff472a55812a28b7c386e8976 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 28 Jun 2020 13:45:54 +0530 Subject: [PATCH 11/42] JAVA-49: main pom changes corresponding to module renaming --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 7958b31a31..4848b563c6 100644 --- a/pom.xml +++ b/pom.xml @@ -517,7 +517,7 @@ machine-learning mapstruct - maven-all + maven-modules maven-archetype maven-polyglot @@ -1036,7 +1036,7 @@ machine-learning mapstruct - maven-all + maven-modules maven-archetype maven-polyglot From ad9e01c2de48b37e5d35a9013b9c70123049a97c Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 28 Jun 2020 13:46:38 +0530 Subject: [PATCH 12/42] JAVA-49: Moved compiler-plugin-java-9 to maven-modules --- .../compiler-plugin-java-9/README.md | 3 ++ maven-modules/compiler-plugin-java-9/pom.xml | 30 +++++++++++++++++++ .../maven/java9/MavenCompilerPlugin.java | 9 ++++++ .../src/main/java/module-info.java | 3 ++ 4 files changed, 45 insertions(+) create mode 100644 maven-modules/compiler-plugin-java-9/README.md create mode 100644 maven-modules/compiler-plugin-java-9/pom.xml create mode 100644 maven-modules/compiler-plugin-java-9/src/main/java/com/baeldung/maven/java9/MavenCompilerPlugin.java create mode 100644 maven-modules/compiler-plugin-java-9/src/main/java/module-info.java diff --git a/maven-modules/compiler-plugin-java-9/README.md b/maven-modules/compiler-plugin-java-9/README.md new file mode 100644 index 0000000000..0e02d56946 --- /dev/null +++ b/maven-modules/compiler-plugin-java-9/README.md @@ -0,0 +1,3 @@ +### Relevant Articles + +- [Maven Compiler Plugin](https://www.baeldung.com/maven-compiler-plugin) diff --git a/maven-modules/compiler-plugin-java-9/pom.xml b/maven-modules/compiler-plugin-java-9/pom.xml new file mode 100644 index 0000000000..6baadb451c --- /dev/null +++ b/maven-modules/compiler-plugin-java-9/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + com.baeldung + compiler-plugin-java-9 + 0.0.1-SNAPSHOT + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${compiler.plugin.version} + + ${source.version} + ${target.version} + + + + + + + 3.8.0 + 9 + 9 + + + \ No newline at end of file diff --git a/maven-modules/compiler-plugin-java-9/src/main/java/com/baeldung/maven/java9/MavenCompilerPlugin.java b/maven-modules/compiler-plugin-java-9/src/main/java/com/baeldung/maven/java9/MavenCompilerPlugin.java new file mode 100644 index 0000000000..b460d6e38c --- /dev/null +++ b/maven-modules/compiler-plugin-java-9/src/main/java/com/baeldung/maven/java9/MavenCompilerPlugin.java @@ -0,0 +1,9 @@ +package com.baeldung.maven.java9; + +import static javax.xml.XMLConstants.XML_NS_PREFIX; + +public class MavenCompilerPlugin { + public static void main(String[] args) { + System.out.println("The XML namespace prefix is: " + XML_NS_PREFIX); + } +} diff --git a/maven-modules/compiler-plugin-java-9/src/main/java/module-info.java b/maven-modules/compiler-plugin-java-9/src/main/java/module-info.java new file mode 100644 index 0000000000..afc1d45e71 --- /dev/null +++ b/maven-modules/compiler-plugin-java-9/src/main/java/module-info.java @@ -0,0 +1,3 @@ +module com.baeldung.maven.java9 { + requires java.xml; +} \ No newline at end of file From dbb25da0b078a1550b0ed0e717bd1626079007ef Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 28 Jun 2020 13:47:27 +0530 Subject: [PATCH 13/42] JAVA-49: Moved maven-custom-plugin to maven-modules --- maven-modules/maven-custom-plugin/README.md | 7 ++ .../counter-maven-plugin/pom.xml | 80 +++++++++++++++++++ .../validator/DependencyCounterMojo.java | 45 +++++++++++ maven-modules/maven-custom-plugin/pom.xml | 21 +++++ .../maven-custom-plugin/usage-example/pom.xml | 51 ++++++++++++ 5 files changed, 204 insertions(+) create mode 100644 maven-modules/maven-custom-plugin/README.md create mode 100644 maven-modules/maven-custom-plugin/counter-maven-plugin/pom.xml create mode 100644 maven-modules/maven-custom-plugin/counter-maven-plugin/src/main/java/com/baeldung/maven/plugin/validator/DependencyCounterMojo.java create mode 100644 maven-modules/maven-custom-plugin/pom.xml create mode 100644 maven-modules/maven-custom-plugin/usage-example/pom.xml diff --git a/maven-modules/maven-custom-plugin/README.md b/maven-modules/maven-custom-plugin/README.md new file mode 100644 index 0000000000..1889036ce3 --- /dev/null +++ b/maven-modules/maven-custom-plugin/README.md @@ -0,0 +1,7 @@ +## Apache Maven + +This module contains articles about creating a custom plugin in Maven. + +### Relevant Articles + +- [How to Create a Maven Plugin](https://www.baeldung.com/maven-plugin) diff --git a/maven-modules/maven-custom-plugin/counter-maven-plugin/pom.xml b/maven-modules/maven-custom-plugin/counter-maven-plugin/pom.xml new file mode 100644 index 0000000000..7ddf5b739c --- /dev/null +++ b/maven-modules/maven-custom-plugin/counter-maven-plugin/pom.xml @@ -0,0 +1,80 @@ + + + 4.0.0 + com.baeldung + counter-maven-plugin + 0.0.1-SNAPSHOT + counter-maven-plugin Maven Mojo + maven-plugin + http://maven.apache.org + + + Baeldung + https://www.baeldung.com/ + + + + + org.apache.maven + maven-plugin-api + ${maven-plugin-api.version} + + + org.apache.maven.plugin-tools + maven-plugin-annotations + ${maven-plugin-annotations.version} + provided + + + org.apache.maven + maven-project + ${maven-project.version} + + + + + + + + org.apache.maven.plugins + maven-plugin-plugin + ${maven-plugin-plugin.version} + + + org.apache.maven.plugins + maven-site-plugin + ${maven-site-plugin.version} + + + + + + + + + org.apache.maven.plugins + maven-plugin-plugin + + + + report + + + + + + + + + 1.8 + 1.8 + 3.6.2 + 3.6.0 + 2.2.1 + 3.6.0 + 3.8.2 + + + \ No newline at end of file diff --git a/maven-modules/maven-custom-plugin/counter-maven-plugin/src/main/java/com/baeldung/maven/plugin/validator/DependencyCounterMojo.java b/maven-modules/maven-custom-plugin/counter-maven-plugin/src/main/java/com/baeldung/maven/plugin/validator/DependencyCounterMojo.java new file mode 100644 index 0000000000..4bb53b20cf --- /dev/null +++ b/maven-modules/maven-custom-plugin/counter-maven-plugin/src/main/java/com/baeldung/maven/plugin/validator/DependencyCounterMojo.java @@ -0,0 +1,45 @@ +package com.baeldung.maven.plugin.validator; + +import java.util.List; + +import org.apache.maven.model.Dependency; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; + +/** + * Counts the number of maven dependencies of a project. + * + * It can be filtered by scope. + * + */ +@Mojo(name = "dependency-counter", defaultPhase = LifecyclePhase.COMPILE) +public class DependencyCounterMojo extends AbstractMojo { + + /** + * Scope to filter the dependencies. + */ + @Parameter(property = "scope") + String scope; + + /** + * Gives access to the Maven project information. + */ + @Parameter(defaultValue = "${project}", required = true, readonly = true) + MavenProject project; + + public void execute() throws MojoExecutionException, MojoFailureException { + List dependencies = project.getDependencies(); + + long numDependencies = dependencies.stream() + .filter(d -> (scope == null || scope.isEmpty()) || scope.equals(d.getScope())) + .count(); + + getLog().info("Number of dependencies: " + numDependencies); + } + +} diff --git a/maven-modules/maven-custom-plugin/pom.xml b/maven-modules/maven-custom-plugin/pom.xml new file mode 100644 index 0000000000..ad22c735ff --- /dev/null +++ b/maven-modules/maven-custom-plugin/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + maven-custom-plugin + 0.0.1-SNAPSHOT + maven-custom-plugin + pom + + + com.baeldung + maven-modules + 0.0.1-SNAPSHOT + + + + counter-maven-plugin + usage-example + + + \ No newline at end of file diff --git a/maven-modules/maven-custom-plugin/usage-example/pom.xml b/maven-modules/maven-custom-plugin/usage-example/pom.xml new file mode 100644 index 0000000000..f512fc104d --- /dev/null +++ b/maven-modules/maven-custom-plugin/usage-example/pom.xml @@ -0,0 +1,51 @@ + + + 4.0.0 + com.baeldung + usage-example + 0.0.1-SNAPSHOT + pom + + + + org.apache.commons + commons-lang3 + ${commons.lang3.version} + + + junit + junit + ${junit.version} + test + + + + + + + com.baeldung + counter-maven-plugin + 0.0.1-SNAPSHOT + + + + dependency-counter + + + + + test + + + + + + + 3.9 + 4.12 + + + From d9c46907d853c0616ba485dfe5663cb33abb5213 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 28 Jun 2020 13:48:07 +0530 Subject: [PATCH 14/42] JAVA-49: Moved maven-unused-dependencies to maven-modules --- .../maven-unused-dependencies/README.md | 7 +++ .../maven-unused-dependencies/pom.xml | 47 +++++++++++++++++++ .../UnusedDependenciesExample.java | 17 +++++++ 3 files changed, 71 insertions(+) create mode 100644 maven-modules/maven-unused-dependencies/README.md create mode 100644 maven-modules/maven-unused-dependencies/pom.xml create mode 100644 maven-modules/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java diff --git a/maven-modules/maven-unused-dependencies/README.md b/maven-modules/maven-unused-dependencies/README.md new file mode 100644 index 0000000000..53897e8227 --- /dev/null +++ b/maven-modules/maven-unused-dependencies/README.md @@ -0,0 +1,7 @@ +## Apache Maven + +This module contains articles about Unused Maven Dependencies. + +### Relevant Articles + +- [Find Unused Maven Dependencies](https://www.baeldung.com/maven-unused-dependencies) diff --git a/maven-modules/maven-unused-dependencies/pom.xml b/maven-modules/maven-unused-dependencies/pom.xml new file mode 100644 index 0000000000..825858e481 --- /dev/null +++ b/maven-modules/maven-unused-dependencies/pom.xml @@ -0,0 +1,47 @@ + + 4.0.0 + com.baeldung + maven-unused-dependencies + 0.0.1-SNAPSHOT + + + 3.2.2 + 1.7.25 + 3.1.2 + 3.1 + + + + + commons-collections + commons-collections + ${commons-collections.version} + + + org.slf4j + slf4j-api + ${slf4j-api.version} + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven-compiler-plugin.version} + + 1.8 + 1.8 + + + + maven-dependency-plugin + ${maven-dependency-plugin.version} + + + + + \ No newline at end of file diff --git a/maven-modules/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java b/maven-modules/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java new file mode 100644 index 0000000000..c9390880ed --- /dev/null +++ b/maven-modules/maven-unused-dependencies/src/main/java/com/baeldung/mavendependencyplugin/UnusedDependenciesExample.java @@ -0,0 +1,17 @@ +package com.baeldung.mavendependencyplugin; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class UnusedDependenciesExample { + + /** + * When the Maven dependency analyzer analyzes the code, it will see that the slf4j dependency is being used in this method. + * + * @return the slf4j {@link Logger}. + */ + public Logger getLogger() { + return LoggerFactory.getLogger(UnusedDependenciesExample.class); + } + +} From b15fc50991291257d553db881c472bad75f845ea Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 28 Jun 2020 13:49:24 +0530 Subject: [PATCH 15/42] JAVA-49: Moved maven-war-plugin to maven-modules --- maven-modules/maven-war-plugin/README.md | 7 ++++++ maven-modules/maven-war-plugin/pom.xml | 32 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 maven-modules/maven-war-plugin/README.md create mode 100644 maven-modules/maven-war-plugin/pom.xml diff --git a/maven-modules/maven-war-plugin/README.md b/maven-modules/maven-war-plugin/README.md new file mode 100644 index 0000000000..09d33772f0 --- /dev/null +++ b/maven-modules/maven-war-plugin/README.md @@ -0,0 +1,7 @@ +## Maven WAR Plugin + +This module contains articles about the Maven WAR Plugin. + +### Relevant Articles + +- [Eclipse Error: web.xml is missing and failOnMissingWebXml is set to true](https://www.baeldung.com/eclipse-error-web-xml-missing) diff --git a/maven-modules/maven-war-plugin/pom.xml b/maven-modules/maven-war-plugin/pom.xml new file mode 100644 index 0000000000..915be306ca --- /dev/null +++ b/maven-modules/maven-war-plugin/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + com.baeldung + maven-war-plugin + 0.0.1-SNAPSHOT + maven-war-plugin + war + + + + + maven-war-plugin + + ${war.plugin.version} + + + false + + + + + + + + false + 3.1.0 + + + \ No newline at end of file From 33e15c0a63ef6ee785663529990909a3e981fe69 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 28 Jun 2020 13:49:57 +0530 Subject: [PATCH 16/42] JAVA-49: Moved versions-maven-plugin to maven-modules --- maven-modules/versions-maven-plugin/README.md | 7 ++ .../versions-maven-plugin/original/pom.xml | 82 +++++++++++++++++++ maven-modules/versions-maven-plugin/pom.xml | 81 ++++++++++++++++++ .../versions-maven-plugin/run-the-demo.sh | 74 +++++++++++++++++ 4 files changed, 244 insertions(+) create mode 100644 maven-modules/versions-maven-plugin/README.md create mode 100644 maven-modules/versions-maven-plugin/original/pom.xml create mode 100644 maven-modules/versions-maven-plugin/pom.xml create mode 100644 maven-modules/versions-maven-plugin/run-the-demo.sh diff --git a/maven-modules/versions-maven-plugin/README.md b/maven-modules/versions-maven-plugin/README.md new file mode 100644 index 0000000000..19414a2a4b --- /dev/null +++ b/maven-modules/versions-maven-plugin/README.md @@ -0,0 +1,7 @@ +## Versions Maven Plugin + +This module contains articles about the Versions Maven Plugin. + +### Relevant Articles + +- [Use the Latest Version of a Dependency in Maven](https://www.baeldung.com/maven-dependency-latest-version) diff --git a/maven-modules/versions-maven-plugin/original/pom.xml b/maven-modules/versions-maven-plugin/original/pom.xml new file mode 100644 index 0000000000..f81596661e --- /dev/null +++ b/maven-modules/versions-maven-plugin/original/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + com.baeldung + original + 0.0.1-SNAPSHOT + + + + + commons-io + commons-io + ${commons-io.version} + + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + org.apache.commons + commons-compress + ${commons-compress-version} + + + + commons-beanutils + commons-beanutils + ${commons-beanutils.version} + + + + + + + + org.codehaus.mojo + versions-maven-plugin + ${versions.plugin.version} + + + org.apache.commons:commons-collections4 + + + + + + + + + apache.snapshots + Apache Development Snapshot Repository + https://repository.apache.org/content/repositories/snapshots/ + + false + + + true + + + + + + 1.15 + 2.3 + 4.0 + 3.0 + 1.9.1 + 2.7 + + + \ No newline at end of file diff --git a/maven-modules/versions-maven-plugin/pom.xml b/maven-modules/versions-maven-plugin/pom.xml new file mode 100644 index 0000000000..9793f55b28 --- /dev/null +++ b/maven-modules/versions-maven-plugin/pom.xml @@ -0,0 +1,81 @@ + + + 4.0.0 + com.baeldung + versions-maven-plugin + 0.0.1-SNAPSHOT + versions-maven-plugin + + + + commons-io + commons-io + ${commons.io.version} + + + + org.apache.commons + commons-collections4 + ${commons.collections4.version} + + + + org.apache.commons + commons-lang3 + ${commons.lang3.version} + + + + org.apache.commons + commons-compress + ${commons-compress-version} + + + + commons-beanutils + commons-beanutils + ${commons.beanutils.version} + + + + + + + org.codehaus.mojo + versions-maven-plugin + ${versions.plugin.version} + + + org.apache.commons:commons-collections4 + + + + + + + + + apache.snapshots + Apache Development Snapshot Repository + https://repository.apache.org/content/repositories/snapshots/ + + false + + + true + + + + + + 1.15 + 2.3 + 2.7 + 1.9.1 + 3.0 + 4.0 + + + \ No newline at end of file diff --git a/maven-modules/versions-maven-plugin/run-the-demo.sh b/maven-modules/versions-maven-plugin/run-the-demo.sh new file mode 100644 index 0000000000..89ca871e01 --- /dev/null +++ b/maven-modules/versions-maven-plugin/run-the-demo.sh @@ -0,0 +1,74 @@ +#!/bin/bash +#function to display commands +exe() { echo -e "\$ $@\n" ; "$@" ; } + +TEXT_COLOR='\033[1;33m' #Yellow +NO_COLOR='\033[0m' # No Color + +clear + +echo -e "======================================================================================" +echo -e " Showcase for the BAELDUNG tutorial \"Use the latest version of a dependency in Maven\"" +echo -e " Author: Andrea Ligios" +echo -e "======================================================================================" + +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " Resetting the demo environment (which will be altered during the run): " +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +rm -f pom.xml.versionsBackup +cp original/pom.xml pom.xml +ls -lt pom.* +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " Checking for newer versions of the Maven dependencies:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +exe mvn versions:display-dependency-updates +echo +read -p "Press enter to continue" + +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " Updating SNAPSHOT dependencies to their RELEASE version, if any:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +exe mvn versions:use-releases +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " A backup has been created automatically:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +ls -lt pom.* +echo +read -p "Press enter to continue" + +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " Updating RELEASE dependencies to their *next* RELEASE version:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +exe mvn versions:use-next-releases +echo +read -p "Press enter to continue" + +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " Reverting every modification made since the beginning:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +exe mvn versions:revert +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " The backup is gone, and the pom.xml contains the initial dependencies:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +ls -lt pom.* +echo +read -p "Press enter to continue" + +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " Updating RELEASE dependencies to their *latest* RELEASE version:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +exe mvn versions:use-latest-releases +echo +read -p "Press enter to continue" + +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " Committing the modifications to pom.xml:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +exe mvn versions:commit +echo -e "${TEXT_COLOR}\n--------------------------------------------------------------------------------------" +echo -e " The backup is gone, and the pom.xml contains the latest dependencies:" +echo -e "--------------------------------------------------------------------------------------${NO_COLOR}" +ls -lt pom.* +echo + +echo -e "${TEXT_COLOR}\nThat's all folks!${NO_COLOR}\n" From 3d1290bec63cc44652da5a4b45a2161025bb33e1 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 28 Jun 2020 16:16:16 +0530 Subject: [PATCH 17/42] JAVA-49: Renamed proxy to maven-proxy and moved to maven-modules --- maven-modules/maven-proxy/README.md | 3 ++ maven-modules/maven-proxy/proxy/settings.xml | 43 +++++++++++++++++++ .../security/redirect/settings-security.xml | 6 +++ .../security/settings-security.xml | 7 +++ 4 files changed, 59 insertions(+) create mode 100644 maven-modules/maven-proxy/README.md create mode 100644 maven-modules/maven-proxy/proxy/settings.xml create mode 100644 maven-modules/maven-proxy/security/redirect/settings-security.xml create mode 100644 maven-modules/maven-proxy/security/settings-security.xml diff --git a/maven-modules/maven-proxy/README.md b/maven-modules/maven-proxy/README.md new file mode 100644 index 0000000000..9ae1fd6ad5 --- /dev/null +++ b/maven-modules/maven-proxy/README.md @@ -0,0 +1,3 @@ +### Relevant Articles: + +- [Using Maven Behind a Proxy](https://www.baeldung.com/maven-behind-proxy) diff --git a/maven-modules/maven-proxy/proxy/settings.xml b/maven-modules/maven-proxy/proxy/settings.xml new file mode 100644 index 0000000000..55a850a6bc --- /dev/null +++ b/maven-modules/maven-proxy/proxy/settings.xml @@ -0,0 +1,43 @@ + + + + + + + BaeldungProxy_Encrypted + true + http + proxy.baeldung.com + 80 + baeldung + {U2iMf+7aJXQHRquuQq6MX+n7GOeh97zB9/4e7kkEQYs=} + internal.baeldung.com|localhost|127.*|[::1] + + + + BaeldungProxy_Authenticated + true + http + proxy.baeldung.com + 80 + baeldung + changeme + internal.baeldung.com|localhost|127.*|[::1] + + + + BaeldungProxy + proxy.baeldung.com + 80 + internal.baeldung.com|localhost|127.*|[::1] + + + + + \ No newline at end of file diff --git a/maven-modules/maven-proxy/security/redirect/settings-security.xml b/maven-modules/maven-proxy/security/redirect/settings-security.xml new file mode 100644 index 0000000000..37e91bd1a4 --- /dev/null +++ b/maven-modules/maven-proxy/security/redirect/settings-security.xml @@ -0,0 +1,6 @@ + + + R:\config\settings-security.xml + diff --git a/maven-modules/maven-proxy/security/settings-security.xml b/maven-modules/maven-proxy/security/settings-security.xml new file mode 100644 index 0000000000..3ac258e8a5 --- /dev/null +++ b/maven-modules/maven-proxy/security/settings-security.xml @@ -0,0 +1,7 @@ + + + {QFMlh/6WjF8H9po9UD\}0Nv18e527jqWb6mUgIB798n4=} + From 25d14b9f04e95c711df5e8d0e74524e3efced542 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 28 Jun 2020 16:17:23 +0530 Subject: [PATCH 18/42] JAVA-49: Renamed profiles to maven-profiles and moved to maven-modules --- maven-modules/maven-profiles/README.md | 7 ++ maven-modules/maven-profiles/pom.xml | 94 ++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 maven-modules/maven-profiles/README.md create mode 100644 maven-modules/maven-profiles/pom.xml diff --git a/maven-modules/maven-profiles/README.md b/maven-modules/maven-profiles/README.md new file mode 100644 index 0000000000..cfbe5c397f --- /dev/null +++ b/maven-modules/maven-profiles/README.md @@ -0,0 +1,7 @@ +## Maven Profiles + +This module contains articles about Maven profiles. + +### Relevant Articles + +- [Guide to Maven Profiles](https://www.baeldung.com/maven-profiles) diff --git a/maven-modules/maven-profiles/pom.xml b/maven-modules/maven-profiles/pom.xml new file mode 100644 index 0000000000..4937bc7c5d --- /dev/null +++ b/maven-modules/maven-profiles/pom.xml @@ -0,0 +1,94 @@ + + + 4.0.0 + com.baeldung + maven-profiles + 0.0.1-SNAPSHOT + maven-profiles + + + + no-tests + + true + + + + integration-tests + + true + + + + mutation-tests + + + active-on-jdk-11 + + 11 + + + + active-on-windows-10 + + + windows 10 + Windows + amd64 + 10.0 + + + + + active-on-property-environment + + + environment + !test + + + + + active-on-missing-file + + + target/testreport.html + + + + + active-on-present-file + + + target/artifact.jar + + + + + + + + + org.apache.maven.plugins + maven-help-plugin + ${help.plugin.version} + + + show-profiles + compile + + active-profiles + + + + + + + + + 3.2.0 + + + \ No newline at end of file From a794bcf0d15573821a64b2e51b014de0f3d16109 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 28 Jun 2020 16:18:00 +0530 Subject: [PATCH 19/42] JAVA-49: new module for core maven plugins --- maven-modules/maven-plugins/.gitignore | 2 + maven-modules/maven-plugins/README.md | 11 ++ .../maven-plugins/custom-rule/pom.xml | 54 +++++++ .../com/baeldung/enforcer/MyCustomRule.java | 43 ++++++ .../input-resources/baeldung.png | Bin 0 -> 4318 bytes .../input-resources/baeldung.txt | 1 + .../input-resources/verifications.xml | 9 ++ .../maven-plugins/maven-enforcer/pom.xml | 75 ++++++++++ maven-modules/maven-plugins/pom.xml | 135 ++++++++++++++++++ 9 files changed, 330 insertions(+) create mode 100644 maven-modules/maven-plugins/.gitignore create mode 100644 maven-modules/maven-plugins/README.md create mode 100644 maven-modules/maven-plugins/custom-rule/pom.xml create mode 100644 maven-modules/maven-plugins/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java create mode 100644 maven-modules/maven-plugins/input-resources/baeldung.png create mode 100644 maven-modules/maven-plugins/input-resources/baeldung.txt create mode 100644 maven-modules/maven-plugins/input-resources/verifications.xml create mode 100644 maven-modules/maven-plugins/maven-enforcer/pom.xml create mode 100644 maven-modules/maven-plugins/pom.xml diff --git a/maven-modules/maven-plugins/.gitignore b/maven-modules/maven-plugins/.gitignore new file mode 100644 index 0000000000..bae0b0d7ce --- /dev/null +++ b/maven-modules/maven-plugins/.gitignore @@ -0,0 +1,2 @@ +/output-resources +/.idea/ diff --git a/maven-modules/maven-plugins/README.md b/maven-modules/maven-plugins/README.md new file mode 100644 index 0000000000..4210a3bb20 --- /dev/null +++ b/maven-modules/maven-plugins/README.md @@ -0,0 +1,11 @@ +## Apache Maven + +This module contains articles about the core Maven plugins. Other Maven plugins (such as the Maven WAR Plugin) have their own dedicated modules. + +### Relevant Articles + +- [Guide to the Core Maven Plugins](https://www.baeldung.com/core-maven-plugins) +- [Maven Resources Plugin](https://www.baeldung.com/maven-resources-plugin) +- [The Maven Verifier Plugin](https://www.baeldung.com/maven-verifier-plugin) +- [The Maven Clean Plugin](https://www.baeldung.com/maven-clean-plugin) +- [Maven Enforcer Plugin](https://www.baeldung.com/maven-enforcer-plugin) diff --git a/maven-modules/maven-plugins/custom-rule/pom.xml b/maven-modules/maven-plugins/custom-rule/pom.xml new file mode 100644 index 0000000000..0fb551e71b --- /dev/null +++ b/maven-modules/maven-plugins/custom-rule/pom.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + custom-rule + custom-rule + + + com.baeldung + maven-plugins + 0.0.1-SNAPSHOT + + + + + + org.apache.maven.enforcer + enforcer-api + ${api.version} + + + org.apache.maven + maven-project + ${maven.version} + + + org.apache.maven + maven-core + ${maven.version} + + + org.apache.maven + maven-artifact + ${maven.version} + + + org.apache.maven + maven-plugin-api + ${maven.version} + + + org.codehaus.plexus + plexus-container-default + ${plexus-container-default.version} + + + + + 3.0.0-M2 + 2.0.9 + 1.0-alpha-9 + + + diff --git a/maven-modules/maven-plugins/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java b/maven-modules/maven-plugins/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java new file mode 100644 index 0000000000..db636c2308 --- /dev/null +++ b/maven-modules/maven-plugins/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2019 PloyRef + * Created by Seun Matt + * on 19 - 2 - 2019 + */ + +package com.baeldung.enforcer; + +import org.apache.maven.enforcer.rule.api.EnforcerRule; +import org.apache.maven.enforcer.rule.api.EnforcerRuleException; +import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; + +public class MyCustomRule implements EnforcerRule { + + public void execute(EnforcerRuleHelper enforcerRuleHelper) throws EnforcerRuleException { + + try { + + String groupId = (String) enforcerRuleHelper.evaluate("${project.groupId}"); + + if (groupId == null || !groupId.startsWith("com.baeldung")) { + throw new EnforcerRuleException("Project group id does not start with com.baeldung"); + } + + } + catch (ExpressionEvaluationException ex ) { + throw new EnforcerRuleException( "Unable to lookup an expression " + ex.getLocalizedMessage(), ex ); + } + } + + public boolean isCacheable() { + return false; + } + + public boolean isResultValid(EnforcerRule enforcerRule) { + return false; + } + + public String getCacheId() { + return null; + } +} diff --git a/maven-modules/maven-plugins/input-resources/baeldung.png b/maven-modules/maven-plugins/input-resources/baeldung.png new file mode 100644 index 0000000000000000000000000000000000000000..488f52e56e45d7b2b64cd688138f85f6a7dcc0e1 GIT binary patch literal 4318 zcmV<45Fzi0P)foQgqP5Mp zsKlyDj8On=0L9qHn!cV^kz9?3s|u#h=NMJwO{A`pKiG2N>HFWwwO4vS=G-;(rt8X6iJ z8XEtXI6k`re+$#yvwQHD5F69cv-|Le@P@4D*?ss!*Z>3R>3%Q7u3-Sze|9(i3f7ik z7e=2Mqj>-f8G&}(J7KxTR)x%TZ4aN_v0n&(_xY|OQ!CGw@Z-T?`)XjQB-1eL%d>m< zJK&7s@H~%_sp(-*)tLm^F}evS-kmQC!$qbIuP|A_)O22fANJ=cNQu13V~If1S%+{B zQYP!vq#CaFi&St1(G=r`Lz07zf+!H5H!f_?WeTk8L1e_ArrC*0LuWWDi045&bt%Bo z5qTcY`dyA|XgWLN0LCbAaA}}8Aqt}1 zC|=ukJ@tXEN=z}i$tJ|X{Hxa+EL?S#s07mS&J?q&9HnFii(@+O!sJHyQzthvjEt+A z)3#27l%~VNyA>Rga&JePbYeI|Qcn~NW|LkPX=*^GUf2uN z+MK|RUa|(e;D&N75j^`%egZ}{bOMy*MKbYc!>o}#d-kjR1bnGgrwz9GI=wTR4b4<_ z>cm@$ttylR(5XoB&Kd_n0nlbrPfe%o79;J&XdY;?bcIp|1)V4=HVN&$7V&vFdGd?= z3{>cZR*^3E*KH!odLb$x(`mjA^4~j)R`GeP2WJk6PBbf4l+mW?ik?Gj&JqHhz$^0; z2iU570bsqX7ua)lCxE5x7`7}@3Upa~iP)v2z-g%f!+yCa;9rGc^q;_(z}#<)&?zCAr$G&ZUV+Bf8MYp zWqCc-Ap;;?`5|F#8ieHnmEoJJhGs zs4yV=f!><32`u+@rE5N}W71?%2LK|pxeW9)zlDvk3;}4HIV=c4hV*BIu(4U}CwgGs z#u=3p86!6cg6V9&%5jNiuhSH#`7sPby-~0k2Jh*BG`;stfBU6p@(uXTXf(PuN1YA! zz^wmrHzu7H8e#csw1*R(=by9al#IvYP4sz;Yxr7CFX8fj{^D|&jAsq2Y{FkeV3Qz1_NL>J8UIHY3D5KHz?)9d&TyF=znlB`6Ulifkp=g z6b8kwIFI^WX*ve;2d_1x+8#BiQG6-PGcbK@m+pZ>%~m!ud2Cc|P+G7}Nm}2Qttm9oxpme`uyv30xv)y2t2m^A3rjT z{>SMA(}|N|aIuKt1WylKjs7^Dkghx--J*&fSfusG>9ptcS4UEl8cib3~PG zRo>K9Iwc8rpwnN*H~r%_?^Oo{oj#fFs(mZF^Y}e*JvXo}w^n{ zR01XvzDwt%ze%4M1h4&iw?FK^7E;Zd?{y6-IwN9Y%iE=wD~w4w4X|-=EI#;PgHR&( zbTacWQ^Ob~;J4_YktOdBCp`z1YS4-_7JcxA0MUbIlcEm+tnq8Ef6g$S# zzxa^Lsm!sQT~$c6jY)4+q#jsGyd#}HDe-c7I-N+B#00^C1T#F=_Cvin1_VqkDd_ao z65NSE=c-&NO-UPb zD*m8H^hCbrSqnQg3ej_lT7DDNv9It8~d}*I;k{g+lfvvJ&c^x zI*W(IiU$U#WWHDhvH>9WJP%n?j|rU?pP%R;+)9*khFw=)| zvmT7;Uu`|HndemsfjiM@05naa1hB&=JkI{&tL7}@v>yxx;cz2r`I1hDZP$h{IUdrc z`x9H4$jt^ao&4b~H4?hgi8pC44)Zb7B{ZcnVP6d3%_{5cIg!3%H#+m`4ekrN{ESG(zO)SG|v-$Z)7F~l`_;3TSo3fXXcKTeC~w+XDMfLJt#9UCtc`rIsPpf#jS7O(zF18H` z6FHqEdV&=d8;;98Mx>L(u#^%=iEbAit|(&S!5) zrz<`%CXd?m*pV?XQVFHAy_?T|qQ7!Dy|Ln7cB6a((MK7bY>F6J`4|s&NNTRC1UjAT z5=vFjfle?L=_Jb`cv;eIz>TQKggo8C<9( za78uWq;sR76DzYByZh1E815Wf zs@es9%kI23I!QoSxl-%}uZY-K=B<04L^|i?H-V~wvggfs+F|KL|CoCA*#K`xr%HKF zXe{C$OA(0`nOoV6 zPHJB(A_W&3SpH_}Eq@qM96>g9SRkuf;r+pa@7a$&^@HE!mLfztsRU37mG!pN2+rvw z)#tzv!UCUU21OY)&FG}z2D4Ind0@G*?|MaC(U*bqx1&K#BuD6C7LG6CokUBhj)?ai z#+4NBq+=Y(T4F-ose(>wJP6JVwd{)LHKUVB4ZehCy_n05b<1Qjcli*}SacaKJklX3 zW-QWfvpuf`on+Fb9*#7FoW2`abTO0Yq(hKP#mg^N7S&MWfsazsR8tX=Ye*-3F93w- z&WNRjyM{nu5@vW?Anv^KGWyP?8BxS_@B?vT%hVf9WZF}{i~i9~C4qM`3?w=^3EphU zOW?AB1)Wq8aUtq6`x>Jbbh2Cm@VFf$U&3AJ9RqX_<#r;!#hM!KEIn!1#xc(4?C7u% z^0p@j4Nll4#2<`Ld$E@O^j1D!VlTYrO zNtl0$2Bd;0~6cM;Wn}ZY@9wXpV3%go|P?}IqJR5ENwbVAfbh-Xqirj%Z%4Z zDCu;#R5l*Z(stb8%igXPo&0?b5RIc$Y9im?eK$Hy7WAKRRUk$Yd6TOp2%Y}P5}Mk4 zQ<_<;RDld633f#SsqdT%&llPO&}&EMh`(GZms+XDxfh)lAIv?vwav=^(i$bF{%9b3 zLDu$ajnYjCgwFaqD*(xUV0l}HHr%gwo z<}yua&{gI|$SLL+s`oQe3AC7dTSGiRB+*9cl&V0<+QV7dF;aefbc~38YQbi2sodh4 z9ld>)4C=M&96xA=e$hof^c${pqP)_SJsb0i>598()`7e zolIg1yjwYWRZLJkrzw?IbgGV-0ssNUX8e6+&;j%>ZC2F&2q6h)s5p@lC;YT2RxE&d zYyShtBL$$-i$cOyakMQSb6q~>BOL_tL_HTXK=}P=E|(tzG^8tD%YDkrsT4m;SGLzL z<&L6wfrL79WaLB3k357tDX~5nW08Dpu7%<5oYKESP;^I934)=9Kq29uEFn%zVFCbb zu6Q-+M=myzS-D!ypCM!-S8~0+EMZ=t>y%FGCs%5%ve)$D)M;?2Njlb)!=h1B4-#6IM^s-v7XHm57A6u-BnS@LBNBdj* zsz%3t`uMaj$2*+OmOd<%I_$5Cu7)%T|M+v?{1%%v{Wgu;OX&1;4)KKh((GY08m&&k zYbY_Ar+Q+pm^w71qHnBf4kyXh8_TPNJE@TklLk6XqX1Em*b;)>qZ12A>MNF-gVj7^ zcs!JA&fv_9H6f_3aRb~Hi`n+qQxrv~#N?bL_cxq`^ + + + input-resources/baeldung.txt + Welcome + + + \ No newline at end of file diff --git a/maven-modules/maven-plugins/maven-enforcer/pom.xml b/maven-modules/maven-plugins/maven-enforcer/pom.xml new file mode 100644 index 0000000000..01f97a061e --- /dev/null +++ b/maven-modules/maven-plugins/maven-enforcer/pom.xml @@ -0,0 +1,75 @@ + + + 4.0.0 + maven-enforcer + maven-enforcer + + + com.baeldung + maven-plugins + 0.0.1-SNAPSHOT + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M2 + + + + + + + + + + enforce + + enforce + + + + + + 3.0 + Invalid Maven version. It should, at least, be 3.0 + + + 1.8 + + + ui + WARN + + + cook + WARN + + + local,base + Missing active profiles + WARN + + + + + + + + + + maven-verifier-plugin + ${maven.verifier.version} + + ../input-resources/verifications.xml + false + + + + + + \ No newline at end of file diff --git a/maven-modules/maven-plugins/pom.xml b/maven-modules/maven-plugins/pom.xml new file mode 100644 index 0000000000..43bcf1f422 --- /dev/null +++ b/maven-modules/maven-plugins/pom.xml @@ -0,0 +1,135 @@ + + + 4.0.0 + maven-plugins + 0.0.1-SNAPSHOT + maven-plugins + pom + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../.. + + + + + + maven-resources-plugin + ${maven.resources.version} + + output-resources + + + input-resources + + *.png + + true + + + + + + maven-compiler-plugin + ${maven.compiler.version} + + ${java.version} + ${java.version} + + -Xlint:unchecked + + + + + maven-verifier-plugin + ${maven.verifier.version} + + input-resources/verifications.xml + + + + + verify + + + + + + maven-clean-plugin + ${maven.clean.version} + + + + output-resources + + + + + + + + + + default + + + + maven-surefire-plugin + ${maven.surefire.version} + + + DataTest.java + + + TestFail.java + DataCheck.java + + true + + + + + + + surefire + + + + maven-surefire-plugin + ${maven.surefire.version} + + + integration-test + + test + + + + none + + + **/*IntegrationTest + + + + + + + + + + + + 3.0.2 + 3.8.0 + 2.22.0 + 2.22.0 + 1.1 + 3.0.0 + 3.0.0 + + + \ No newline at end of file From 3d2c0cddc0133e3e206149b9fd7a7f8d3aa5dd54 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 28 Jun 2020 16:19:06 +0530 Subject: [PATCH 20/42] JAVA-49: new module for maven integration testing & related plugins --- .../maven-integration-test/.gitignore | 2 + .../maven-integration-test/README.md | 10 + maven-modules/maven-integration-test/pom.xml | 283 ++++++++++++++++++ .../com/baeldung/maven/it/RestITCase.java | 24 ++ .../com/baeldung/maven/it/EndpointConfig.java | 9 + .../com/baeldung/maven/it/RestEndpoint.java | 12 + .../java/com/baeldung/maven/plugins/Data.java | 16 + .../src/main/resources/logback.xml | 13 + .../src/main/webapp/WEB-INF/web.xml | 17 ++ .../com/baeldung/maven/it/Integration.java | 4 + .../java/com/baeldung/maven/it/RestIT.java | 24 ++ .../maven/it/RestIntegrationTest.java | 24 ++ .../com/baeldung/maven/it/RestJUnitTest.java | 26 ++ .../com/baeldung/maven/plugins/DataCheck.java | 15 + .../baeldung/maven/plugins/DataUnitTest.java | 15 + .../src/test/java/testfail/TestFail.java | 18 ++ 16 files changed, 512 insertions(+) create mode 100644 maven-modules/maven-integration-test/.gitignore create mode 100644 maven-modules/maven-integration-test/README.md create mode 100644 maven-modules/maven-integration-test/pom.xml create mode 100644 maven-modules/maven-integration-test/src/integration-test/java/com/baeldung/maven/it/RestITCase.java create mode 100644 maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/it/EndpointConfig.java create mode 100644 maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/it/RestEndpoint.java create mode 100644 maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/plugins/Data.java create mode 100644 maven-modules/maven-integration-test/src/main/resources/logback.xml create mode 100644 maven-modules/maven-integration-test/src/main/webapp/WEB-INF/web.xml create mode 100644 maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/Integration.java create mode 100644 maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestIT.java create mode 100644 maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestIntegrationTest.java create mode 100644 maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestJUnitTest.java create mode 100644 maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/plugins/DataCheck.java create mode 100644 maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/plugins/DataUnitTest.java create mode 100644 maven-modules/maven-integration-test/src/test/java/testfail/TestFail.java diff --git a/maven-modules/maven-integration-test/.gitignore b/maven-modules/maven-integration-test/.gitignore new file mode 100644 index 0000000000..bae0b0d7ce --- /dev/null +++ b/maven-modules/maven-integration-test/.gitignore @@ -0,0 +1,2 @@ +/output-resources +/.idea/ diff --git a/maven-modules/maven-integration-test/README.md b/maven-modules/maven-integration-test/README.md new file mode 100644 index 0000000000..e73a73e61e --- /dev/null +++ b/maven-modules/maven-integration-test/README.md @@ -0,0 +1,10 @@ +## Apache Maven + +This module contains articles about Integration Testing with Maven and related plugins. + +### Relevant Articles + +- [Integration Testing with Maven](https://www.baeldung.com/maven-integration-test) +- [Build a Jar with Maven and Ignore the Test Results](https://www.baeldung.com/maven-ignore-test-results) +- [Quick Guide to the Maven Surefire Plugin](https://www.baeldung.com/maven-surefire-plugin) +- [The Maven Failsafe Plugin](https://www.baeldung.com/maven-failsafe-plugin) \ No newline at end of file diff --git a/maven-modules/maven-integration-test/pom.xml b/maven-modules/maven-integration-test/pom.xml new file mode 100644 index 0000000000..0031230bb1 --- /dev/null +++ b/maven-modules/maven-integration-test/pom.xml @@ -0,0 +1,283 @@ + + + 4.0.0 + maven-integration-test + 0.0.1-SNAPSHOT + maven-integration-test + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../.. + + + + + org.glassfish.jersey.containers + jersey-container-servlet-core + ${jersey.version} + + + org.glassfish.jersey.inject + jersey-hk2 + ${jersey.version} + + + junit + junit + ${junit.version} + test + + + + + + + org.eclipse.jetty + jetty-maven-plugin + ${jetty.version} + + + 8999 + + quit + 9000 + + + + start-jetty + pre-integration-test + + start + + + + stop-jetty + post-integration-test + + stop + + + + + + maven-resources-plugin + ${maven.resources.version} + + output-resources + + + input-resources + + *.png + + true + + + + + + maven-compiler-plugin + ${maven.compiler.version} + + ${java.version} + ${java.version} + + -Xlint:unchecked + + + + + maven-surefire-plugin + ${maven.surefire.version} + + + DataTest.java + **/*IntegrationTest + + com.baeldung.maven.it.Integration + + TestFail.java + DataCheck.java + + true + + + + maven-failsafe-plugin + ${maven.failsafe.version} + + + + integration-test + verify + + + + + + + + + maven-clean-plugin + ${maven.clean.version} + + + + output-resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + ${maven.build.helper.version} + + + add-integration-test-source + generate-test-sources + + add-test-source + + + + src/integration-test/java + + + + + add-integration-test-resource + generate-test-resources + + add-test-resource + + + + + src/integration-test/resources + + + + + + + + + + + + default + + + + maven-surefire-plugin + ${maven.surefire.version} + + + DataTest.java + + + TestFail.java + DataCheck.java + + true + + + + + + + failsafe + + + + maven-failsafe-plugin + ${maven.failsafe.version} + + + **/*RestIT + **/RestITCase + + + + + + integration-test + verify + + + + + + + + + surefire + + + + maven-surefire-plugin + ${maven.surefire.version} + + + integration-test + + test + + + + none + + + **/*IntegrationTest + + + + + + + + + + category + + + + maven-failsafe-plugin + ${maven.failsafe.version} + + + **/* + + com.baeldung.maven.it.Integration + + + + + integration-test + verify + + + + + + + + + + + 3.0.2 + 3.8.0 + 2.22.0 + 2.22.0 + 1.1 + 3.0.0 + 3.0.0 + 9.4.11.v20180605 + 2.27 + + + \ No newline at end of file diff --git a/maven-modules/maven-integration-test/src/integration-test/java/com/baeldung/maven/it/RestITCase.java b/maven-modules/maven-integration-test/src/integration-test/java/com/baeldung/maven/it/RestITCase.java new file mode 100644 index 0000000000..aaeeedb661 --- /dev/null +++ b/maven-modules/maven-integration-test/src/integration-test/java/com/baeldung/maven/it/RestITCase.java @@ -0,0 +1,24 @@ +package com.baeldung.maven.it; + +import org.junit.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.net.URLConnection; +import java.util.Scanner; + +import static org.junit.Assert.assertEquals; + +public class RestITCase { + @Test + public void whenSendingGet_thenMessageIsReturned() throws IOException { + String url = "http://localhost:8999"; + URLConnection connection = new URL(url).openConnection(); + try (InputStream response = connection.getInputStream(); + Scanner scanner = new Scanner(response)) { + String responseBody = scanner.nextLine(); + assertEquals("Welcome to Baeldung!", responseBody); + } + } +} diff --git a/maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/it/EndpointConfig.java b/maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/it/EndpointConfig.java new file mode 100644 index 0000000000..919210ccff --- /dev/null +++ b/maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/it/EndpointConfig.java @@ -0,0 +1,9 @@ +package com.baeldung.maven.it; + +import org.glassfish.jersey.server.ResourceConfig; + +public class EndpointConfig extends ResourceConfig { + public EndpointConfig() { + register(RestEndpoint.class); + } +} diff --git a/maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/it/RestEndpoint.java b/maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/it/RestEndpoint.java new file mode 100644 index 0000000000..c234891865 --- /dev/null +++ b/maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/it/RestEndpoint.java @@ -0,0 +1,12 @@ +package com.baeldung.maven.it; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +@Path("/") +public class RestEndpoint { + @GET + public String hello() { + return "Welcome to Baeldung!"; + } +} diff --git a/maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/plugins/Data.java b/maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/plugins/Data.java new file mode 100644 index 0000000000..6ac6f9ab46 --- /dev/null +++ b/maven-modules/maven-integration-test/src/main/java/com/baeldung/maven/plugins/Data.java @@ -0,0 +1,16 @@ +package com.baeldung.maven.plugins; + +import java.util.ArrayList; +import java.util.List; + +public class Data { + List textList = new ArrayList(); + + public void addText(String text) { + textList.add(text); + } + + public List getTextList() { + return this.textList; + } +} diff --git a/maven-modules/maven-integration-test/src/main/resources/logback.xml b/maven-modules/maven-integration-test/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/maven-modules/maven-integration-test/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file diff --git a/maven-modules/maven-integration-test/src/main/webapp/WEB-INF/web.xml b/maven-modules/maven-integration-test/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..1751ad17a5 --- /dev/null +++ b/maven-modules/maven-integration-test/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,17 @@ + + + rest-servlet + org.glassfish.jersey.servlet.ServletContainer + + javax.ws.rs.Application + com.baeldung.maven.it.EndpointConfig + + + + rest-servlet + /* + + \ No newline at end of file diff --git a/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/Integration.java b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/Integration.java new file mode 100644 index 0000000000..112ce178ce --- /dev/null +++ b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/Integration.java @@ -0,0 +1,4 @@ +package com.baeldung.maven.it; + +public interface Integration { +} diff --git a/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestIT.java b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestIT.java new file mode 100644 index 0000000000..0115d34f1e --- /dev/null +++ b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestIT.java @@ -0,0 +1,24 @@ +package com.baeldung.maven.it; + +import org.junit.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.net.URLConnection; +import java.util.Scanner; + +import static org.junit.Assert.assertEquals; + +public class RestIT { + @Test + public void whenSendingGet_thenMessageIsReturned() throws IOException { + String url = "http://localhost:8999"; + URLConnection connection = new URL(url).openConnection(); + try (InputStream response = connection.getInputStream(); + Scanner scanner = new Scanner(response)) { + String responseBody = scanner.nextLine(); + assertEquals("Welcome to Baeldung!", responseBody); + } + } +} diff --git a/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestIntegrationTest.java b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestIntegrationTest.java new file mode 100644 index 0000000000..2f913c8429 --- /dev/null +++ b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestIntegrationTest.java @@ -0,0 +1,24 @@ +package com.baeldung.maven.it; + +import org.junit.Test; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.net.URLConnection; +import java.util.Scanner; + +import static org.junit.Assert.assertEquals; + +public class RestIntegrationTest { + @Test + public void whenSendingGet_thenMessageIsReturned() throws IOException { + String url = "http://localhost:8999"; + URLConnection connection = new URL(url).openConnection(); + try (InputStream response = connection.getInputStream(); + Scanner scanner = new Scanner(response)) { + String responseBody = scanner.nextLine(); + assertEquals("Welcome to Baeldung!", responseBody); + } + } +} diff --git a/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestJUnitTest.java b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestJUnitTest.java new file mode 100644 index 0000000000..60995d75bd --- /dev/null +++ b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/it/RestJUnitTest.java @@ -0,0 +1,26 @@ +package com.baeldung.maven.it; + +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.net.URLConnection; +import java.util.Scanner; + +import static org.junit.Assert.assertEquals; + +@Category(Integration.class) +public class RestJUnitTest { + @Test + public void whenSendingGet_thenMessageIsReturned() throws IOException { + String url = "http://localhost:8999"; + URLConnection connection = new URL(url).openConnection(); + try (InputStream response = connection.getInputStream(); + Scanner scanner = new Scanner(response)) { + String responseBody = scanner.nextLine(); + assertEquals("Welcome to Baeldung!", responseBody); + } + } +} diff --git a/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/plugins/DataCheck.java b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/plugins/DataCheck.java new file mode 100644 index 0000000000..9aaf0fb071 --- /dev/null +++ b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/plugins/DataCheck.java @@ -0,0 +1,15 @@ +package com.baeldung.maven.plugins; + +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +import com.baeldung.maven.plugins.Data; + +public class DataCheck { + @Test + public void whenDataObjectIsCreated_thenItIsNotNull() { + Data data = new Data(); + assertNotNull(data); + } +} diff --git a/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/plugins/DataUnitTest.java b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/plugins/DataUnitTest.java new file mode 100644 index 0000000000..197f977fec --- /dev/null +++ b/maven-modules/maven-integration-test/src/test/java/com/baeldung/maven/plugins/DataUnitTest.java @@ -0,0 +1,15 @@ +package com.baeldung.maven.plugins; + +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +import com.baeldung.maven.plugins.Data; + +public class DataUnitTest { + @Test + public void whenDataObjectIsNotCreated_thenItIsNull() { + Data data = null; + assertNull(data); + } +} diff --git a/maven-modules/maven-integration-test/src/test/java/testfail/TestFail.java b/maven-modules/maven-integration-test/src/test/java/testfail/TestFail.java new file mode 100644 index 0000000000..3febd21031 --- /dev/null +++ b/maven-modules/maven-integration-test/src/test/java/testfail/TestFail.java @@ -0,0 +1,18 @@ +package testfail; + +import org.junit.Test; +import org.junit.Ignore; + +import static org.junit.Assert.assertNotNull; + +public class TestFail { + + @Ignore //ignored so the entire tutorials build passes + @Test + public void whenMessageAssigned_thenItIsNotNull() { + String message = "hello there"; + message = null; + assertNotNull(message); + } + +} From e84dd497a51338b3467a58dc1a76bb50e304c30f Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 28 Jun 2020 16:19:51 +0530 Subject: [PATCH 21/42] JAVA-49: new module for multiple source directories with Maven --- maven-modules/maven-multi-source/.gitignore | 2 + maven-modules/maven-multi-source/README.md | 7 ++ maven-modules/maven-multi-source/pom.xml | 92 +++++++++++++++++++ .../com/baeldung/maven/plugins/Foo.java | 10 ++ .../maven/plugins/MultipleSrcFolders.java | 9 ++ .../src/main/resources/logback.xml | 13 +++ 6 files changed, 133 insertions(+) create mode 100644 maven-modules/maven-multi-source/.gitignore create mode 100644 maven-modules/maven-multi-source/README.md create mode 100644 maven-modules/maven-multi-source/pom.xml create mode 100644 maven-modules/maven-multi-source/src/main/another-src/com/baeldung/maven/plugins/Foo.java create mode 100644 maven-modules/maven-multi-source/src/main/java/com/baeldung/maven/plugins/MultipleSrcFolders.java create mode 100644 maven-modules/maven-multi-source/src/main/resources/logback.xml diff --git a/maven-modules/maven-multi-source/.gitignore b/maven-modules/maven-multi-source/.gitignore new file mode 100644 index 0000000000..bae0b0d7ce --- /dev/null +++ b/maven-modules/maven-multi-source/.gitignore @@ -0,0 +1,2 @@ +/output-resources +/.idea/ diff --git a/maven-modules/maven-multi-source/README.md b/maven-modules/maven-multi-source/README.md new file mode 100644 index 0000000000..8298332c04 --- /dev/null +++ b/maven-modules/maven-multi-source/README.md @@ -0,0 +1,7 @@ +## Apache Maven - Multiple Source Directories + +This module contains articles about how to use multiple source directories with Maven. + +### Relevant Articles + +- [Maven Project with Multiple Source Directories](https://www.baeldung.com/maven-project-multiple-src-directories) \ No newline at end of file diff --git a/maven-modules/maven-multi-source/pom.xml b/maven-modules/maven-multi-source/pom.xml new file mode 100644 index 0000000000..0c85049df7 --- /dev/null +++ b/maven-modules/maven-multi-source/pom.xml @@ -0,0 +1,92 @@ + + + 4.0.0 + maven-multi-source + 0.0.1-SNAPSHOT + maven-multi-source + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + ../.. + + + + + + maven-compiler-plugin + ${maven.compiler.version} + + ${java.version} + ${java.version} + + -Xlint:unchecked + + + + + org.codehaus.mojo + build-helper-maven-plugin + ${maven.build.helper.version} + + + generate-sources + + add-source + + + + src/main/another-src + + + + + + + + + + + surefire + + + + maven-surefire-plugin + ${maven.surefire.version} + + + integration-test + + test + + + + none + + + **/*IntegrationTest + + + + + + + + + + + + 3.0.2 + 3.8.0 + 2.22.0 + 2.22.0 + 1.1 + 3.0.0 + 3.0.0 + 9.4.11.v20180605 + 2.27 + + + \ No newline at end of file diff --git a/maven-modules/maven-multi-source/src/main/another-src/com/baeldung/maven/plugins/Foo.java b/maven-modules/maven-multi-source/src/main/another-src/com/baeldung/maven/plugins/Foo.java new file mode 100644 index 0000000000..f8a6fe9853 --- /dev/null +++ b/maven-modules/maven-multi-source/src/main/another-src/com/baeldung/maven/plugins/Foo.java @@ -0,0 +1,10 @@ +package com.baeldung.maven.plugins; + +public class Foo { + + public static String foo() { + return "foo"; + } + +} + diff --git a/maven-modules/maven-multi-source/src/main/java/com/baeldung/maven/plugins/MultipleSrcFolders.java b/maven-modules/maven-multi-source/src/main/java/com/baeldung/maven/plugins/MultipleSrcFolders.java new file mode 100644 index 0000000000..d403918dd3 --- /dev/null +++ b/maven-modules/maven-multi-source/src/main/java/com/baeldung/maven/plugins/MultipleSrcFolders.java @@ -0,0 +1,9 @@ +package com.baeldung.maven.plugins; + +public class MultipleSrcFolders { + + public static void callFoo() { + Foo.foo(); + } + +} diff --git a/maven-modules/maven-multi-source/src/main/resources/logback.xml b/maven-modules/maven-multi-source/src/main/resources/logback.xml new file mode 100644 index 0000000000..7d900d8ea8 --- /dev/null +++ b/maven-modules/maven-multi-source/src/main/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + \ No newline at end of file From 405da9801f0ab27b8dc9263eba8609c4ad5e51b2 Mon Sep 17 00:00:00 2001 From: sampadawagde Date: Sun, 28 Jun 2020 16:20:50 +0530 Subject: [PATCH 22/42] JAVA-49: maven-all restructuring --- maven-modules/README.md | 9 +++++++++ maven-modules/pom.xml | 28 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 maven-modules/README.md create mode 100644 maven-modules/pom.xml diff --git a/maven-modules/README.md b/maven-modules/README.md new file mode 100644 index 0000000000..1ef664f879 --- /dev/null +++ b/maven-modules/README.md @@ -0,0 +1,9 @@ +## Apache Maven + +This module contains articles about Apache Maven. Please refer to its submodules. + +### Relevant Articles + +- [Apache Maven Tutorial](https://www.baeldung.com/maven) +- [Apache Maven Standard Directory Layout](https://www.baeldung.com/maven-directory-structure) +- [Multi-Module Project with Maven](https://www.baeldung.com/maven-multi-module) diff --git a/maven-modules/pom.xml b/maven-modules/pom.xml new file mode 100644 index 0000000000..56e0bd2bdc --- /dev/null +++ b/maven-modules/pom.xml @@ -0,0 +1,28 @@ + + + 4.0.0 + maven-modules + 0.0.1-SNAPSHOT + maven-modules + pom + + + com.baeldung + parent-modules + 1.0.0-SNAPSHOT + + + + + maven-custom-plugin + maven-integration-test + maven-multi-source + maven-plugins + maven-unused-dependencies + maven-war-plugin + maven-profiles + versions-maven-plugin + + + From 7466f04ee995853e29b4df75a3a0e3e8d96be5a4 Mon Sep 17 00:00:00 2001 From: Ali Dehghani Date: Mon, 29 Jun 2020 02:45:30 +0430 Subject: [PATCH 23/42] Added the Rest Assured Example --- .../GreetControllerRealIntegrationTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerRealIntegrationTest.java diff --git a/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerRealIntegrationTest.java b/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerRealIntegrationTest.java new file mode 100644 index 0000000000..05c6313e76 --- /dev/null +++ b/spring-mvc-java/src/test/java/com/baeldung/web/controller/GreetControllerRealIntegrationTest.java @@ -0,0 +1,34 @@ +package com.baeldung.web.controller; + +import io.restassured.RestAssured; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; + +import static io.restassured.RestAssured.given; +import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = RANDOM_PORT) +@TestPropertySource(properties = {"spring.main.allow-bean-definition-overriding=true", "server.servlet.context-path=/"}) +public class GreetControllerRealIntegrationTest { + + @LocalServerPort + private int port; + + @Before + public void setUp() { + RestAssured.port = port; + } + + @Test + public void givenGreetURI_whenSendingReq_thenVerifyResponse() { + given().get("/greet") + .then() + .statusCode(200); + } +} From a135fa09987bba9f137168c113534309f13f0e56 Mon Sep 17 00:00:00 2001 From: Sampada <46674082+sampada07@users.noreply.github.com> Date: Tue, 30 Jun 2020 22:11:42 +0530 Subject: [PATCH 24/42] JAVA-1555: Update "Spring Boot multi-module" article (#9609) * JAVA-1555: Modified parent's pom to include new module * JAVA-1555: Added missing module parent-multi-module --- .../parent-multi-module/application/pom.xml | 36 +++++++++++++++++++ .../application/EvenOddApplication.java | 30 ++++++++++++++++ .../parent-multi-module/library/pom.xml | 23 ++++++++++++ .../library/service/EvenOddService.java | 11 ++++++ .../parent-multi-module/pom.xml | 15 ++++++++ .../spring-boot-custom-starter/pom.xml | 1 + 6 files changed, 116 insertions(+) create mode 100644 spring-boot-modules/spring-boot-custom-starter/parent-multi-module/application/pom.xml create mode 100644 spring-boot-modules/spring-boot-custom-starter/parent-multi-module/application/src/main/java/com/baeldung/application/EvenOddApplication.java create mode 100644 spring-boot-modules/spring-boot-custom-starter/parent-multi-module/library/pom.xml create mode 100644 spring-boot-modules/spring-boot-custom-starter/parent-multi-module/library/src/main/java/com/baeldung/library/service/EvenOddService.java create mode 100644 spring-boot-modules/spring-boot-custom-starter/parent-multi-module/pom.xml diff --git a/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/application/pom.xml b/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/application/pom.xml new file mode 100644 index 0000000000..fb235bc479 --- /dev/null +++ b/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/application/pom.xml @@ -0,0 +1,36 @@ + + + 4.0.0 + com.baeldung.example + application + jar + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../../../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter-web + + + com.baeldung.example + library + ${project.version} + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/application/src/main/java/com/baeldung/application/EvenOddApplication.java b/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/application/src/main/java/com/baeldung/application/EvenOddApplication.java new file mode 100644 index 0000000000..49b5b87037 --- /dev/null +++ b/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/application/src/main/java/com/baeldung/application/EvenOddApplication.java @@ -0,0 +1,30 @@ +package com.baeldung.application; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.baeldung.library.service.EvenOddService; + +@SpringBootApplication(scanBasePackages = "com.baeldung") +@RestController +public class EvenOddApplication { + + private EvenOddService evenOddService; + + public EvenOddApplication(EvenOddService evenOddService) { + this.evenOddService = evenOddService; + } + + @GetMapping("/validate/") + public String isEvenOrOdd( + @RequestParam("number") Integer number) { + return evenOddService.isEvenOrOdd(number); + } + + public static void main(String[] args) { + SpringApplication.run(EvenOddApplication.class, args); + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/library/pom.xml b/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/library/pom.xml new file mode 100644 index 0000000000..d979f1d9bf --- /dev/null +++ b/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/library/pom.xml @@ -0,0 +1,23 @@ + + + 4.0.0 + com.baeldung.example + library + jar + + + com.baeldung + parent-boot-2 + 0.0.1-SNAPSHOT + ../../../../parent-boot-2 + + + + + org.springframework.boot + spring-boot-starter + + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/library/src/main/java/com/baeldung/library/service/EvenOddService.java b/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/library/src/main/java/com/baeldung/library/service/EvenOddService.java new file mode 100644 index 0000000000..77631943b6 --- /dev/null +++ b/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/library/src/main/java/com/baeldung/library/service/EvenOddService.java @@ -0,0 +1,11 @@ +package com.baeldung.library.service; + +import org.springframework.stereotype.Service; + +@Service +public class EvenOddService { + + public String isEvenOrOdd(Integer number) { + return number % 2 == 0 ? "Even" : "Odd"; + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/pom.xml b/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/pom.xml new file mode 100644 index 0000000000..75ff927789 --- /dev/null +++ b/spring-boot-modules/spring-boot-custom-starter/parent-multi-module/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + com.baeldung + parent-multi-module + 0.0.1-SNAPSHOT + pom + + + library + application + + + \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-custom-starter/pom.xml b/spring-boot-modules/spring-boot-custom-starter/pom.xml index 596b993f81..1a13e2ba9b 100644 --- a/spring-boot-modules/spring-boot-custom-starter/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/pom.xml @@ -18,6 +18,7 @@ greeter-spring-boot-autoconfigure greeter-spring-boot-starter greeter-spring-boot-sample-app + parent-multi-module \ No newline at end of file From 1ff6672223e7a897c5f2eda80a47d2c7daae7124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Dupire?= Date: Tue, 30 Jun 2020 18:55:30 +0200 Subject: [PATCH 25/42] =?UTF-8?q?[JAVA-1670]=20Upgraded=20JUnit=20and=20Ma?= =?UTF-8?q?ven=20Surefire=20Plugin=20in=20spring-boot-m=E2=80=A6=20(#9509)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [JAVA-1670] Upgraded JUnit and Maven Surefire Plugin in spring-boot-modules * Upgraded Maven Surefire Plugin version to 2.22.2 * Upgraded JUnit version to 5.6.2 * [JAVA-1670] Phasing upgrade - Inheriting form parent-boot-2 * Reverted JUnit version upgrade for now (will focus on parent/child relationships first) * Changed parent pom of spring-boot-modules to parent-boot-2 * Upgraded JUnit version to 5.6.2 in spring-boot-modules --- spring-boot-modules/pom.xml | 20 +++++++++++++++++-- spring-boot-modules/spring-boot-camel/pom.xml | 7 ++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 14f071b5e5..50059fe383 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -2,15 +2,18 @@ 4.0.0 + com.baeldung.spring-boot-modules spring-boot-modules + 1.0.0-SNAPSHOT spring-boot-modules pom com.baeldung - parent-modules - 1.0.0-SNAPSHOT + parent-boot-2 + 0.0.1-SNAPSHOT + ../parent-boot-2 @@ -60,4 +63,17 @@ spring-boot-actuator + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + + + 5.6.2 + diff --git a/spring-boot-modules/spring-boot-camel/pom.xml b/spring-boot-modules/spring-boot-camel/pom.xml index 7c1e28b3ee..881b021b96 100644 --- a/spring-boot-modules/spring-boot-camel/pom.xml +++ b/spring-boot-modules/spring-boot-camel/pom.xml @@ -8,9 +8,10 @@ spring-boot-camel - com.baeldung.spring-boot-modules - spring-boot-modules - 1.0.0-SNAPSHOT + com.baeldung + parent-boot-1 + 0.0.1-SNAPSHOT + ../../parent-boot-1 From eff6ed12e6cce9afa5cfb1b7d8c4bb0aac66e46f Mon Sep 17 00:00:00 2001 From: vatsalgosar Date: Wed, 1 Jul 2020 01:41:39 +0530 Subject: [PATCH 26/42] BAEL-4142 (#9622) - Code snippets for Integer to binary string conversion --- .../integerToBinary/IntegerToBinary.java | 17 ++++++++++++ .../IntegerToBinaryUnitTest.java | 27 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 java-numbers-3/src/main/java/com/baeldung/integerToBinary/IntegerToBinary.java create mode 100644 java-numbers-3/src/test/java/com/baeldung/integerToBinary/IntegerToBinaryUnitTest.java diff --git a/java-numbers-3/src/main/java/com/baeldung/integerToBinary/IntegerToBinary.java b/java-numbers-3/src/main/java/com/baeldung/integerToBinary/IntegerToBinary.java new file mode 100644 index 0000000000..bd888da9a6 --- /dev/null +++ b/java-numbers-3/src/main/java/com/baeldung/integerToBinary/IntegerToBinary.java @@ -0,0 +1,17 @@ +package com.baeldung.integerToBinary; + +public class IntegerToBinary { + public static String convertIntegerToBinary(int n) { + if(n == 0) { + return "0"; + } + StringBuilder binaryNumber = new StringBuilder(); + while (n > 0) { + int remainder = n % 2; + binaryNumber.append(remainder); + n /= 2; + } + binaryNumber = binaryNumber.reverse(); + return binaryNumber.toString(); + } +} diff --git a/java-numbers-3/src/test/java/com/baeldung/integerToBinary/IntegerToBinaryUnitTest.java b/java-numbers-3/src/test/java/com/baeldung/integerToBinary/IntegerToBinaryUnitTest.java new file mode 100644 index 0000000000..38ae79f2f5 --- /dev/null +++ b/java-numbers-3/src/test/java/com/baeldung/integerToBinary/IntegerToBinaryUnitTest.java @@ -0,0 +1,27 @@ +package com.baeldung.integerToBinary; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; + +public class IntegerToBinaryUnitTest { + @Test + public void givenAnInteger_whenConvertToBinary_thenGetBinaryString() { + int n = 7; + String binaryString = IntegerToBinary.convertIntegerToBinary(n); + assertEquals("111", binaryString); + } + + @Test + public void givenAnInteger_whenToBinaryStringCalled_thenGetBinaryString() { + int n = 7; + String binaryString = Integer.toBinaryString(n); + assertEquals("111", binaryString); + } + + @Test + public void givenAnInteger_whenToStringCalled_thenGetBinaryString() { + int n = 7; + String binaryString = Integer.toString(n, 2); + assertEquals("111", binaryString); + } +} From d1d4495ade47e6f27eff52c3970c6e3eeaa49d58 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Wed, 1 Jul 2020 22:11:33 +0200 Subject: [PATCH 27/42] BAEL-3265: Change port number to 8032 (#9618) * BAEL-3265-PoC: Change port number to 8032 * BAEL-3265-PoC: Change the way the default port is set --- .../src/main/java/com/baeldung/client/BurlapClient.java | 2 +- .../src/main/java/com/baeldung/client/HessianClient.java | 2 +- .../src/main/java/com/baeldung/server/Server.java | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-client/src/main/java/com/baeldung/client/BurlapClient.java b/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-client/src/main/java/com/baeldung/client/BurlapClient.java index 477c29eb26..1079c4163f 100644 --- a/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-client/src/main/java/com/baeldung/client/BurlapClient.java +++ b/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-client/src/main/java/com/baeldung/client/BurlapClient.java @@ -15,7 +15,7 @@ public class BurlapClient { @Bean public BurlapProxyFactoryBean burlapInvoker() { BurlapProxyFactoryBean invoker = new BurlapProxyFactoryBean(); - invoker.setServiceUrl("http://localhost:8080/b_booking"); + invoker.setServiceUrl("http://localhost:8032/b_booking"); invoker.setServiceInterface(CabBookingService.class); return invoker; } diff --git a/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-client/src/main/java/com/baeldung/client/HessianClient.java b/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-client/src/main/java/com/baeldung/client/HessianClient.java index b5f366094e..b2a2f4ffae 100644 --- a/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-client/src/main/java/com/baeldung/client/HessianClient.java +++ b/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-client/src/main/java/com/baeldung/client/HessianClient.java @@ -15,7 +15,7 @@ public class HessianClient { @Bean public HessianProxyFactoryBean hessianInvoker() { HessianProxyFactoryBean invoker = new HessianProxyFactoryBean(); - invoker.setServiceUrl("http://localhost:8080/booking"); + invoker.setServiceUrl("http://localhost:8032/booking"); invoker.setServiceInterface(CabBookingService.class); return invoker; } diff --git a/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-server/src/main/java/com/baeldung/server/Server.java b/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-server/src/main/java/com/baeldung/server/Server.java index 9b7e463871..9c825a2a80 100644 --- a/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-server/src/main/java/com/baeldung/server/Server.java +++ b/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-server/src/main/java/com/baeldung/server/Server.java @@ -10,6 +10,8 @@ import org.springframework.remoting.caucho.BurlapServiceExporter; import org.springframework.remoting.caucho.HessianServiceExporter; import org.springframework.remoting.support.RemoteExporter; +import java.util.Collections; + @Configuration @ComponentScan @EnableAutoConfiguration public class Server { @Bean CabBookingService bookingService() { @@ -31,7 +33,9 @@ import org.springframework.remoting.support.RemoteExporter; } public static void main(String[] args) { - SpringApplication.run(Server.class, args); + SpringApplication app = new SpringApplication(Server.class); + app.setDefaultProperties(Collections.singletonMap("server.port", "8032")); + app.run(args); } } \ No newline at end of file From 0f02de64a28fb208d9ad98673a4e6f0b262ad1f3 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Wed, 1 Jul 2020 22:23:06 +0200 Subject: [PATCH 28/42] BAEL-3782: Fix project's pom.xml (#9615) --- jee-7/pom.xml | 98 +++++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 53 deletions(-) diff --git a/jee-7/pom.xml b/jee-7/pom.xml index 9077aae1a6..a59733fe6e 100644 --- a/jee-7/pom.xml +++ b/jee-7/pom.xml @@ -243,12 +243,12 @@ - + org.codehaus.mojo jaxws-maven-plugin 2.6 - - + + wsimport-from-jdk wsimport @@ -259,8 +259,8 @@ http://localhost:8888/ws/country?wsdl - true - com.baeldung.soap.ws.client.generated + true + com.baeldung.soap.ws.client.generated src/main/java @@ -276,7 +276,7 @@ standalone-full.xml - ${project.build.directory}/wildfly-${version.wildfly} + ${project.build.directory}/wildfly-${wildfly.version} @@ -318,53 +318,45 @@ - - - - maven-dependency-plugin - ${maven-dependency-plugin.version} - - ${maven.test.skip} - - - - unpack - process-test-classes - - unpack - - - - - org.wildfly - wildfly-dist - ${wildfly.version} - zip - false - ${project.build.directory} - - - sun.jdk - jconsole - - - - - - - - - - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - ${project.build.directory}/wildfly-${wildfly.version} - - - - - + + + maven-dependency-plugin + ${maven-dependency-plugin.version} + + ${maven.test.skip} + + + + unpack + process-test-classes + + unpack + + + + + org.wildfly + wildfly-dist + ${wildfly.version} + zip + false + ${project.build.directory} + + + + + + + + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + ${project.build.directory}/wildfly-${wildfly.version} + + + + From 70fe4a3ca9007f7b075e8a2a47e76aeaf48b8673 Mon Sep 17 00:00:00 2001 From: Dhrubajyoti Bhattacharjee Date: Thu, 2 Jul 2020 07:04:41 +0200 Subject: [PATCH 29/42] BAEL-4007 Interface Segregation Principle (#9579) Co-authored-by: Dhrubajyoti Bhattacharjee --- .../main/java/com/baeldung/i/fixed/Bank.java | 5 +++ .../com/baeldung/i/fixed/BankPayment.java | 21 ++++++++++++ .../main/java/com/baeldung/i/fixed/Loan.java | 6 ++++ .../com/baeldung/i/fixed/LoanPayment.java | 26 +++++++++++++++ .../java/com/baeldung/i/fixed/Payment.java | 8 +++++ .../com/baeldung/i/polluted/BankPayment.java | 32 +++++++++++++++++++ .../com/baeldung/i/polluted/LoanPayment.java | 31 ++++++++++++++++++ .../java/com/baeldung/i/polluted/Payment.java | 13 ++++++++ 8 files changed, 142 insertions(+) create mode 100644 patterns/solid/src/main/java/com/baeldung/i/fixed/Bank.java create mode 100644 patterns/solid/src/main/java/com/baeldung/i/fixed/BankPayment.java create mode 100644 patterns/solid/src/main/java/com/baeldung/i/fixed/Loan.java create mode 100644 patterns/solid/src/main/java/com/baeldung/i/fixed/LoanPayment.java create mode 100644 patterns/solid/src/main/java/com/baeldung/i/fixed/Payment.java create mode 100644 patterns/solid/src/main/java/com/baeldung/i/polluted/BankPayment.java create mode 100644 patterns/solid/src/main/java/com/baeldung/i/polluted/LoanPayment.java create mode 100644 patterns/solid/src/main/java/com/baeldung/i/polluted/Payment.java diff --git a/patterns/solid/src/main/java/com/baeldung/i/fixed/Bank.java b/patterns/solid/src/main/java/com/baeldung/i/fixed/Bank.java new file mode 100644 index 0000000000..7d1c93e83f --- /dev/null +++ b/patterns/solid/src/main/java/com/baeldung/i/fixed/Bank.java @@ -0,0 +1,5 @@ +package com.baeldung.i.fixed; + +public interface Bank extends Payment { + void initiatePayments(); +} diff --git a/patterns/solid/src/main/java/com/baeldung/i/fixed/BankPayment.java b/patterns/solid/src/main/java/com/baeldung/i/fixed/BankPayment.java new file mode 100644 index 0000000000..f077a6772b --- /dev/null +++ b/patterns/solid/src/main/java/com/baeldung/i/fixed/BankPayment.java @@ -0,0 +1,21 @@ +package com.baeldung.i.fixed; + +import java.util.List; + +public class BankPayment implements Bank { + + @Override + public void initiatePayments() { + + } + + @Override + public Object status() { + return null; + } + + @Override + public List getPayments() { + return null; + } +} diff --git a/patterns/solid/src/main/java/com/baeldung/i/fixed/Loan.java b/patterns/solid/src/main/java/com/baeldung/i/fixed/Loan.java new file mode 100644 index 0000000000..74141113db --- /dev/null +++ b/patterns/solid/src/main/java/com/baeldung/i/fixed/Loan.java @@ -0,0 +1,6 @@ +package com.baeldung.i.fixed; + +public interface Loan extends Payment { + void intiateLoanSettlement(); + void initiateRePayment(); +} diff --git a/patterns/solid/src/main/java/com/baeldung/i/fixed/LoanPayment.java b/patterns/solid/src/main/java/com/baeldung/i/fixed/LoanPayment.java new file mode 100644 index 0000000000..b6c32d7730 --- /dev/null +++ b/patterns/solid/src/main/java/com/baeldung/i/fixed/LoanPayment.java @@ -0,0 +1,26 @@ +package com.baeldung.i.fixed; + +import java.util.List; + +public class LoanPayment implements Loan { + + @Override + public void intiateLoanSettlement() { + + } + + @Override + public void initiateRePayment() { + + } + + @Override + public Object status() { + return null; + } + + @Override + public List getPayments() { + return null; + } +} diff --git a/patterns/solid/src/main/java/com/baeldung/i/fixed/Payment.java b/patterns/solid/src/main/java/com/baeldung/i/fixed/Payment.java new file mode 100644 index 0000000000..620c944944 --- /dev/null +++ b/patterns/solid/src/main/java/com/baeldung/i/fixed/Payment.java @@ -0,0 +1,8 @@ +package com.baeldung.i.fixed; + +import java.util.List; + +public interface Payment { + Object status(); + List getPayments(); +} diff --git a/patterns/solid/src/main/java/com/baeldung/i/polluted/BankPayment.java b/patterns/solid/src/main/java/com/baeldung/i/polluted/BankPayment.java new file mode 100644 index 0000000000..c8f667c25f --- /dev/null +++ b/patterns/solid/src/main/java/com/baeldung/i/polluted/BankPayment.java @@ -0,0 +1,32 @@ +package com.baeldung.i.polluted; + +import java.util.Collections; +import java.util.List; + +public class BankPayment implements Payment { + + @Override + public void initiatePayments() { + + } + + @Override + public Object status() { + return null; + } + + @Override + public List getPayments() { + return Collections.emptyList(); + } + + @Override + public void intiateLoanSettlement() { + throw new UnsupportedOperationException("This is not a loan payment"); + } + + @Override + public void initiateRePayment() { + throw new UnsupportedOperationException("This is not a loan payment"); + } +} diff --git a/patterns/solid/src/main/java/com/baeldung/i/polluted/LoanPayment.java b/patterns/solid/src/main/java/com/baeldung/i/polluted/LoanPayment.java new file mode 100644 index 0000000000..8535d7ad0a --- /dev/null +++ b/patterns/solid/src/main/java/com/baeldung/i/polluted/LoanPayment.java @@ -0,0 +1,31 @@ +package com.baeldung.i.polluted; + +import java.util.List; + +public class LoanPayment implements Payment { + + @Override + public void initiatePayments() { + + } + + @Override + public Object status() { + return null; + } + + @Override + public List getPayments() { + return null; + } + + @Override + public void intiateLoanSettlement() { + + } + + @Override + public void initiateRePayment() { + + } +} diff --git a/patterns/solid/src/main/java/com/baeldung/i/polluted/Payment.java b/patterns/solid/src/main/java/com/baeldung/i/polluted/Payment.java new file mode 100644 index 0000000000..987b4cee33 --- /dev/null +++ b/patterns/solid/src/main/java/com/baeldung/i/polluted/Payment.java @@ -0,0 +1,13 @@ +package com.baeldung.i.polluted; + +import java.util.List; + +public interface Payment { + void initiatePayments(); + Object status(); + List getPayments(); + + //Loan related methods + void intiateLoanSettlement(); + void initiateRePayment(); +} From d9e6fdf735689c4cf01645abc9519f54afed291e Mon Sep 17 00:00:00 2001 From: Amy DeGregorio Date: Thu, 2 Jul 2020 02:27:30 -0400 Subject: [PATCH 30/42] BAEL-4157 Examples (#9596) --- .../IsoscelesTriangle.java | 5 ++ .../isinstancevsisassignablefrom/Shape.java | 5 ++ .../Triangle.java | 5 ++ .../IsInstanceIsAssignableFromUnitTest.java | 67 +++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/IsoscelesTriangle.java create mode 100644 core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/Shape.java create mode 100644 core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/Triangle.java create mode 100644 core-java-modules/core-java-lang-2/src/test/java/com/baeldung/isinstancevsisassignablefrom/IsInstanceIsAssignableFromUnitTest.java diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/IsoscelesTriangle.java b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/IsoscelesTriangle.java new file mode 100644 index 0000000000..25392320fe --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/IsoscelesTriangle.java @@ -0,0 +1,5 @@ +package com.baeldung.isinstancevsisassignablefrom; + +public class IsoscelesTriangle extends Triangle { + +} diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/Shape.java b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/Shape.java new file mode 100644 index 0000000000..c83626a3b6 --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/Shape.java @@ -0,0 +1,5 @@ +package com.baeldung.isinstancevsisassignablefrom; + +public interface Shape { + +} diff --git a/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/Triangle.java b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/Triangle.java new file mode 100644 index 0000000000..c35dfd9eca --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/main/java/com/baeldung/isinstancevsisassignablefrom/Triangle.java @@ -0,0 +1,5 @@ +package com.baeldung.isinstancevsisassignablefrom; + +public class Triangle implements Shape { + +} diff --git a/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/isinstancevsisassignablefrom/IsInstanceIsAssignableFromUnitTest.java b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/isinstancevsisassignablefrom/IsInstanceIsAssignableFromUnitTest.java new file mode 100644 index 0000000000..e0ad264797 --- /dev/null +++ b/core-java-modules/core-java-lang-2/src/test/java/com/baeldung/isinstancevsisassignablefrom/IsInstanceIsAssignableFromUnitTest.java @@ -0,0 +1,67 @@ +package com.baeldung.isinstancevsisassignablefrom; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class IsInstanceIsAssignableFromUnitTest { + + @Test + public void whenUsingIsInstanceProperly_desiredResultsHappen() { + Shape shape = new Triangle(); + Triangle triangle = new Triangle(); + IsoscelesTriangle isoscelesTriangle = new IsoscelesTriangle(); + Triangle isoscelesTriangle2 = new IsoscelesTriangle(); + Shape nonspecificShape = null; + + assertTrue(Shape.class.isInstance(shape)); + assertTrue(Shape.class.isInstance(triangle)); + assertTrue(Shape.class.isInstance(isoscelesTriangle)); + assertTrue(Shape.class.isInstance(isoscelesTriangle2)); + assertFalse(Shape.class.isInstance(nonspecificShape)); + + assertTrue(Triangle.class.isInstance(shape)); + assertTrue(Triangle.class.isInstance(triangle)); + assertTrue(Triangle.class.isInstance(isoscelesTriangle)); + assertTrue(Triangle.class.isInstance(isoscelesTriangle2)); + + assertFalse(IsoscelesTriangle.class.isInstance(shape)); + assertFalse(IsoscelesTriangle.class.isInstance(triangle)); + assertTrue(IsoscelesTriangle.class.isInstance(isoscelesTriangle)); + assertTrue(IsoscelesTriangle.class.isInstance(isoscelesTriangle2)); + } + + @Test + public void whenUsingIsAssignableFromProperly_desiredResultsHappen() { + Shape shape = new Triangle(); + Triangle triangle = new Triangle(); + IsoscelesTriangle isoscelesTriangle = new IsoscelesTriangle(); + Triangle isoscelesTriangle2 = new IsoscelesTriangle(); + + assertFalse(shape.getClass().isAssignableFrom(Shape.class)); + assertTrue(shape.getClass().isAssignableFrom(shape.getClass())); + assertTrue(shape.getClass().isAssignableFrom(triangle.getClass())); + assertTrue(shape.getClass().isAssignableFrom(isoscelesTriangle.getClass())); + assertTrue(shape.getClass().isAssignableFrom(isoscelesTriangle2.getClass())); + + assertFalse(triangle.getClass().isAssignableFrom(Shape.class)); + assertTrue(triangle.getClass().isAssignableFrom(shape.getClass())); + assertTrue(triangle.getClass().isAssignableFrom(triangle.getClass())); + assertTrue(triangle.getClass().isAssignableFrom(isoscelesTriangle.getClass())); + assertTrue(triangle.getClass().isAssignableFrom(isoscelesTriangle2.getClass())); + + assertFalse(isoscelesTriangle.getClass().isAssignableFrom(Shape.class)); + assertFalse(isoscelesTriangle.getClass().isAssignableFrom(shape.getClass())); + assertFalse(isoscelesTriangle.getClass().isAssignableFrom(triangle.getClass())); + assertTrue(isoscelesTriangle.getClass().isAssignableFrom(isoscelesTriangle.getClass())); + assertTrue(isoscelesTriangle.getClass().isAssignableFrom(isoscelesTriangle2.getClass())); + + assertFalse(isoscelesTriangle2.getClass().isAssignableFrom(Shape.class)); + assertFalse(isoscelesTriangle2.getClass().isAssignableFrom(shape.getClass())); + assertFalse(isoscelesTriangle2.getClass().isAssignableFrom(triangle.getClass())); + assertTrue(isoscelesTriangle2.getClass().isAssignableFrom(isoscelesTriangle.getClass())); + assertTrue(isoscelesTriangle2.getClass().isAssignableFrom(isoscelesTriangle2.getClass())); + } + +} From 4671770740b462ff010e8d53f6d386630f135476 Mon Sep 17 00:00:00 2001 From: Mona Mohamadinia Date: Thu, 2 Jul 2020 22:43:50 +0430 Subject: [PATCH 31/42] BAEL-4217: Added Thread Pool Aware MDC (#9554) * Added Thread Pool Aware MDC * Fixed Thread Pool --- .../java/com/baeldung/mdc/TransferDemo.java | 18 ++++++----- .../mdc/pool/MdcAwareThreadPoolExecutor.java | 31 +++++++++++++++++++ .../com/baeldung/mdc/slf4j/Slf4jRunnable.java | 2 +- 3 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 logging-modules/log-mdc/src/main/java/com/baeldung/mdc/pool/MdcAwareThreadPoolExecutor.java diff --git a/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/TransferDemo.java b/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/TransferDemo.java index 259e9a8c5c..0cc9dee2b9 100644 --- a/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/TransferDemo.java +++ b/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/TransferDemo.java @@ -1,19 +1,21 @@ package com.baeldung.mdc; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import org.apache.log4j.Logger; - -import com.baeldung.mdc.log4j.Log4JRunnable; -import com.baeldung.mdc.log4j2.Log4J2Runnable; +import com.baeldung.mdc.pool.MdcAwareThreadPoolExecutor; import com.baeldung.mdc.slf4j.Slf4jRunnable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor.AbortPolicy; + +import static java.util.concurrent.TimeUnit.MINUTES; + public class TransferDemo { public static void main(String[] args) { - ExecutorService executor = Executors.newFixedThreadPool(3); + ExecutorService executor = new MdcAwareThreadPoolExecutor(3, 3, 0, MINUTES, + new LinkedBlockingQueue<>(), Thread::new, new AbortPolicy()); + TransactionFactory transactionFactory = new TransactionFactory(); for (int i = 0; i < 10; i++) { diff --git a/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/pool/MdcAwareThreadPoolExecutor.java b/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/pool/MdcAwareThreadPoolExecutor.java new file mode 100644 index 0000000000..71463fe116 --- /dev/null +++ b/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/pool/MdcAwareThreadPoolExecutor.java @@ -0,0 +1,31 @@ +package com.baeldung.mdc.pool; + +import org.apache.logging.log4j.ThreadContext; +import org.slf4j.MDC; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.RejectedExecutionHandler; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +public class MdcAwareThreadPoolExecutor extends ThreadPoolExecutor { + + public MdcAwareThreadPoolExecutor(int corePoolSize, + int maximumPoolSize, + long keepAliveTime, + TimeUnit unit, + BlockingQueue workQueue, + ThreadFactory threadFactory, + RejectedExecutionHandler handler) { + super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler); + } + + @Override + protected void afterExecute(Runnable r, Throwable t) { + System.out.println("Cleaning the MDC context"); + MDC.clear(); + org.apache.log4j.MDC.clear(); + ThreadContext.clearAll(); + } +} diff --git a/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/slf4j/Slf4jRunnable.java b/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/slf4j/Slf4jRunnable.java index e30a28a3c7..f49640c527 100644 --- a/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/slf4j/Slf4jRunnable.java +++ b/logging-modules/log-mdc/src/main/java/com/baeldung/mdc/slf4j/Slf4jRunnable.java @@ -18,7 +18,7 @@ public class Slf4jRunnable implements Runnable { new Slf4TransferService().transfer(tx.getAmount()); - MDC.clear(); + // MDC.clear(); We don't need this with MdcAwareThreadPoolExecutor } } \ No newline at end of file From d5b2dd83bc0e5fc34f91d4397a519f13d52b475c Mon Sep 17 00:00:00 2001 From: Ali Dehghani Date: Fri, 3 Jul 2020 01:54:45 +0430 Subject: [PATCH 32/42] Fixing the Concurrency Issue --- .../main/java/com/baeldung/serenity/spring/AdderService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries-testing/src/main/java/com/baeldung/serenity/spring/AdderService.java b/libraries-testing/src/main/java/com/baeldung/serenity/spring/AdderService.java index 756c05bc2c..8e645ccff5 100644 --- a/libraries-testing/src/main/java/com/baeldung/serenity/spring/AdderService.java +++ b/libraries-testing/src/main/java/com/baeldung/serenity/spring/AdderService.java @@ -1,8 +1,10 @@ package com.baeldung.serenity.spring; +import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Service; @Service +@Scope("prototype") public class AdderService { private int num; From 3d220068f329cae4bfe5a7cff5238f4fa6789d3a Mon Sep 17 00:00:00 2001 From: kwoyke Date: Fri, 3 Jul 2020 07:03:45 +0200 Subject: [PATCH 33/42] BAEL-3265: Properly set non-default port for the managed WildFly (#9630) * BAEL-3265: Change the default port number * BAEL-3265: Properly set non-default port for the managed WildFly instance --- jee-7/pom.xml | 13 ------------- jee-7/src/test/resources/arquillian.xml | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 jee-7/src/test/resources/arquillian.xml diff --git a/jee-7/pom.xml b/jee-7/pom.xml index a59733fe6e..b0e10c1580 100644 --- a/jee-7/pom.xml +++ b/jee-7/pom.xml @@ -274,10 +274,6 @@ true - - standalone-full.xml - ${project.build.directory}/wildfly-${wildfly.version} - io.undertow @@ -347,15 +343,6 @@ - - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - ${project.build.directory}/wildfly-${wildfly.version} - - - diff --git a/jee-7/src/test/resources/arquillian.xml b/jee-7/src/test/resources/arquillian.xml new file mode 100644 index 0000000000..f4274877fd --- /dev/null +++ b/jee-7/src/test/resources/arquillian.xml @@ -0,0 +1,23 @@ + + + + + target/wildfly-8.2.1.Final + standalone.xml + true + 9990 + -Djboss.http.port=8639 + + + + + + 127.0.0.1 + 9990 + admin + pass + true + + + + \ No newline at end of file From c9465691255e61ea016cff660b7037f87446c489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Dupire?= Date: Fri, 3 Jul 2020 10:51:51 +0200 Subject: [PATCH 34/42] [JAVA-1670] Upgrade JUnit and Maven Surefire Plugin in spring-boot-modules - Changed sub-modules inheritance (first batch) (#9629) * [JAVA-1670] Upgraded JUnit and Maven Surefire Plugin in spring-boot-modules * Upgraded Maven Surefire Plugin version to 2.22.2 * Upgraded JUnit version to 5.6.2 * [JAVA-1670] Phasing upgrade - Inheriting form parent-boot-2 * Reverted JUnit version upgrade for now (will focus on parent/child relationships first) * Changed parent pom of spring-boot-modules to parent-boot-2 * Upgraded JUnit version to 5.6.2 in spring-boot-modules * [JAVA-1670] Phasing upgrade - Inheriting from spring-boot-modules instead of parent-boot-2 (first batch) * Changed spring-boot parent * Changed spring-boot-admin * Deleted exclusions in spring-boot * Changed spring-boot-angular * Changed spring-boot-annotations * Changed spring-boot-artifacts * Changed spring-boot-autoconfiguration * Changed spring-boot-basic-customization * Changed spring-boot-bootstrap * Changed spring-boot-client * Changed spring-boot-config-jpa-error * Changed spring-boot-ctx-fluent * Changed spring-boot-deployment * Changed spring-boot-di * Changed spring-boot-ci-cd * Changed spring-boot-custom-starter * Changed spring-boot-crud * Changed spring-boot-data * Changed spring-boot-environment * Changed spring-boot-exceptions * Changed spring-boot-flowable * Changed spring-boot-jasypt * Changed spring-boot-keycloak --- spring-boot-modules/pom.xml | 16 +++++++- spring-boot-modules/spring-boot-admin/pom.xml | 19 ++++----- .../spring-boot-admin-client/pom.xml | 16 ++++---- .../spring-boot-admin-server/pom.xml | 16 ++++---- .../spring-boot-angular/pom.xml | 16 ++++---- .../spring-boot-annotations/pom.xml | 16 ++++---- .../spring-boot-artifacts/pom.xml | 19 ++++----- .../spring-boot-autoconfiguration/pom.xml | 20 +++++----- .../spring-boot-basic-customization/pom.xml | 18 +++++---- .../spring-boot-bootstrap/pom.xml | 18 +++++---- spring-boot-modules/spring-boot-ci-cd/pom.xml | 18 +++++---- .../spring-boot-client/pom.xml | 40 +++++-------------- .../spring-boot-config-jpa-error/pom.xml | 15 +++---- spring-boot-modules/spring-boot-crud/pom.xml | 14 ++++--- .../spring-boot-ctx-fluent/pom.xml | 18 +++++---- .../greeter-spring-boot-sample-app/pom.xml | 6 +-- .../spring-boot-custom-starter/pom.xml | 12 +++--- spring-boot-modules/spring-boot-data/pom.xml | 18 +++++---- .../spring-boot-deployment/pom.xml | 9 ++--- spring-boot-modules/spring-boot-di/pom.xml | 18 +++++---- .../spring-boot-environment/pom.xml | 19 ++++----- .../spring-boot-exceptions/pom.xml | 18 +++++---- .../spring-boot-flowable/pom.xml | 18 +++++---- .../spring-boot-jasypt/pom.xml | 20 +++++----- .../spring-boot-keycloak/pom.xml | 18 +++++---- spring-boot-modules/spring-boot/pom.xml | 40 +++++-------------- 26 files changed, 245 insertions(+), 230 deletions(-) diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 50059fe383..5add26a527 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -6,9 +6,10 @@ com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT - spring-boot-modules pom + spring-boot-modules + com.baeldung parent-boot-2 @@ -73,6 +74,19 @@ + + + org.junit.jupiter + junit-jupiter + test + + + org.junit.vintage + junit-vintage-engine + test + + + 5.6.2 diff --git a/spring-boot-modules/spring-boot-admin/pom.xml b/spring-boot-modules/spring-boot-admin/pom.xml index f7dc98770a..6109081723 100644 --- a/spring-boot-modules/spring-boot-admin/pom.xml +++ b/spring-boot-modules/spring-boot-admin/pom.xml @@ -2,21 +2,22 @@ 4.0.0 - spring-boot-admin - 0.0.1-SNAPSHOT - spring-boot-admin - pom - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-admin + 0.0.1-SNAPSHOT + pom + + spring-boot-admin + spring-boot-admin-server spring-boot-admin-client - diff --git a/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml index 8bb8c7bac3..eb40bfe8ea 100644 --- a/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml +++ b/spring-boot-modules/spring-boot-admin/spring-boot-admin-client/pom.xml @@ -2,18 +2,21 @@ 4.0.0 - spring-boot-admin-client - 0.0.1-SNAPSHOT - spring-boot-admin-client - jar - Spring Boot Admin Client - com.baeldung + com.baeldung.spring-boot-modules spring-boot-admin 0.0.1-SNAPSHOT + ../ + spring-boot-admin-client + 0.0.1-SNAPSHOT + jar + + spring-boot-admin-client + Spring Boot Admin Client + org.springframework.boot @@ -61,5 +64,4 @@ 2.2.2 2.0.4.RELEASE - diff --git a/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml index 118b270812..4c1dcdef6b 100644 --- a/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml +++ b/spring-boot-modules/spring-boot-admin/spring-boot-admin-server/pom.xml @@ -2,18 +2,21 @@ 4.0.0 - spring-boot-admin-server - 0.0.1-SNAPSHOT - spring-boot-admin-server - Spring Boot Admin Server - jar - com.baeldung + com.baeldung.spring-boot-modules spring-boot-admin 0.0.1-SNAPSHOT + ../ + spring-boot-admin-server + 0.0.1-SNAPSHOT + jar + + spring-boot-admin-server + Spring Boot Admin Server + org.springframework.boot @@ -84,5 +87,4 @@ 1.5.7 2.0.4.RELEASE - diff --git a/spring-boot-modules/spring-boot-angular/pom.xml b/spring-boot-modules/spring-boot-angular/pom.xml index e8082656ad..4b3ac27834 100644 --- a/spring-boot-modules/spring-boot-angular/pom.xml +++ b/spring-boot-modules/spring-boot-angular/pom.xml @@ -2,18 +2,20 @@ 4.0.0 + + + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + + com.baeldung.springbootangular spring-boot-angular 1.0 - spring-boot-angular jar - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 - + spring-boot-angular diff --git a/spring-boot-modules/spring-boot-annotations/pom.xml b/spring-boot-modules/spring-boot-annotations/pom.xml index da2c46ca92..799692d51b 100644 --- a/spring-boot-modules/spring-boot-annotations/pom.xml +++ b/spring-boot-modules/spring-boot-annotations/pom.xml @@ -2,17 +2,19 @@ 4.0.0 - spring-boot-annotations - spring-boot-annotations - war - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-annotations + war + + spring-boot-annotations + org.aspectj diff --git a/spring-boot-modules/spring-boot-artifacts/pom.xml b/spring-boot-modules/spring-boot-artifacts/pom.xml index de9f6ab635..2704b71bd6 100644 --- a/spring-boot-modules/spring-boot-artifacts/pom.xml +++ b/spring-boot-modules/spring-boot-artifacts/pom.xml @@ -2,20 +2,21 @@ 4.0.0 - spring-boot-artifacts - spring-boot-artifacts - war - Demo project for Spring Boot - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ - + spring-boot-artifacts + war + spring-boot-artifacts + Demo project for Spring Boot + + org.springframework.boot spring-boot-starter-web diff --git a/spring-boot-modules/spring-boot-autoconfiguration/pom.xml b/spring-boot-modules/spring-boot-autoconfiguration/pom.xml index 34db784176..5709d1d796 100644 --- a/spring-boot-modules/spring-boot-autoconfiguration/pom.xml +++ b/spring-boot-modules/spring-boot-autoconfiguration/pom.xml @@ -2,19 +2,21 @@ 4.0.0 - spring-boot-autoconfiguration - 0.0.1-SNAPSHOT - spring-boot-autoconfiguration - war - This is simple boot application demonstrating a custom auto-configuration - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-autoconfiguration + 0.0.1-SNAPSHOT + war + + spring-boot-autoconfiguration + This is simple boot application demonstrating a custom auto-configuration + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-basic-customization/pom.xml b/spring-boot-modules/spring-boot-basic-customization/pom.xml index 7c2c89def4..fc34994a85 100644 --- a/spring-boot-modules/spring-boot-basic-customization/pom.xml +++ b/spring-boot-modules/spring-boot-basic-customization/pom.xml @@ -3,18 +3,20 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - spring-boot-basic-customization - spring-boot-basic-customization - jar - Module For Spring Boot Basic Customization - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-basic-customization + jar + + spring-boot-basic-customization + Module For Spring Boot Basic Customization + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-bootstrap/pom.xml b/spring-boot-modules/spring-boot-bootstrap/pom.xml index 1dc75c7e61..6a1be7a2c8 100644 --- a/spring-boot-modules/spring-boot-bootstrap/pom.xml +++ b/spring-boot-modules/spring-boot-bootstrap/pom.xml @@ -2,18 +2,20 @@ 4.0.0 - spring-boot-bootstrap - spring-boot-bootstrap - jar - Demo project for Spring Boot - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-bootstrap + jar + + spring-boot-bootstrap + Demo project for Spring Boot + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-ci-cd/pom.xml b/spring-boot-modules/spring-boot-ci-cd/pom.xml index 25e45d56f3..61a2e299fb 100644 --- a/spring-boot-modules/spring-boot-ci-cd/pom.xml +++ b/spring-boot-modules/spring-boot-ci-cd/pom.xml @@ -3,18 +3,20 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - spring-boot-ci-cd - 0.0.1-SNAPSHOT - spring-boot-ci-cd - jar - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-ci-cd + 0.0.1-SNAPSHOT + jar + + spring-boot-ci-cd + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-client/pom.xml b/spring-boot-modules/spring-boot-client/pom.xml index 40a8690953..a7737be106 100644 --- a/spring-boot-modules/spring-boot-client/pom.xml +++ b/spring-boot-modules/spring-boot-client/pom.xml @@ -2,40 +2,22 @@ 4.0.0 - spring-boot-client - 0.0.1-SNAPSHOT - spring-boot-client - war - This is simple boot client application for Spring boot actuator test - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-client + 0.0.1-SNAPSHOT + war + + spring-boot-client + This is simple boot client application for Spring boot actuator test + - - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - - - org.junit.platform - junit-platform-launcher - ${junit-platform.version} - test - org.springframework.boot spring-boot-starter-web diff --git a/spring-boot-modules/spring-boot-config-jpa-error/pom.xml b/spring-boot-modules/spring-boot-config-jpa-error/pom.xml index f578957a1a..d236a581d8 100644 --- a/spring-boot-modules/spring-boot-config-jpa-error/pom.xml +++ b/spring-boot-modules/spring-boot-config-jpa-error/pom.xml @@ -2,18 +2,19 @@ 4.0.0 + + + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + + com.baeldung.spring-boot-config-jpa-error spring-boot-config-jpa-error 0.0.1-SNAPSHOT pom - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2/pom.xml - - data-jpa-library data-jpa-application diff --git a/spring-boot-modules/spring-boot-crud/pom.xml b/spring-boot-modules/spring-boot-crud/pom.xml index 676d522f84..c27afe3926 100644 --- a/spring-boot-modules/spring-boot-crud/pom.xml +++ b/spring-boot-modules/spring-boot-crud/pom.xml @@ -3,16 +3,18 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 4.0.0 - spring-boot-crud - spring-boot-crud - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-crud + + spring-boot-crud + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-ctx-fluent/pom.xml b/spring-boot-modules/spring-boot-ctx-fluent/pom.xml index 872e15d307..cfbc6ffac0 100644 --- a/spring-boot-modules/spring-boot-ctx-fluent/pom.xml +++ b/spring-boot-modules/spring-boot-ctx-fluent/pom.xml @@ -2,18 +2,20 @@ 4.0.0 - spring-boot-ctx-fluent - 0.0.1-SNAPSHOT - spring-boot-ctx-fluent - jar - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-ctx-fluent + 0.0.1-SNAPSHOT + jar + + spring-boot-ctx-fluent + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml index 8d328b88be..6291756d21 100644 --- a/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/greeter-spring-boot-sample-app/pom.xml @@ -7,10 +7,10 @@ greeter-spring-boot-sample-app - com.baeldung - parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-custom-starter 0.0.1-SNAPSHOT - ../../../parent-boot-2 + ../ diff --git a/spring-boot-modules/spring-boot-custom-starter/pom.xml b/spring-boot-modules/spring-boot-custom-starter/pom.xml index 1a13e2ba9b..17f9fdc2cc 100644 --- a/spring-boot-modules/spring-boot-custom-starter/pom.xml +++ b/spring-boot-modules/spring-boot-custom-starter/pom.xml @@ -2,17 +2,20 @@ 4.0.0 - spring-boot-custom-starter - 0.0.1-SNAPSHOT - spring-boot-custom-starter - pom com.baeldung.spring-boot-modules spring-boot-modules 1.0.0-SNAPSHOT + ../ + spring-boot-custom-starter + 0.0.1-SNAPSHOT + pom + + spring-boot-custom-starter + greeter-library greeter-spring-boot-autoconfigure @@ -20,5 +23,4 @@ greeter-spring-boot-sample-app parent-multi-module - \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-data/pom.xml b/spring-boot-modules/spring-boot-data/pom.xml index f25b4ee472..fe64b07379 100644 --- a/spring-boot-modules/spring-boot-data/pom.xml +++ b/spring-boot-modules/spring-boot-data/pom.xml @@ -2,18 +2,20 @@ 4.0.0 - spring-boot-data - spring-boot-data - war - Spring Boot Data Module - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-data + war + + spring-boot-data + Spring Boot Data Module + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-deployment/pom.xml b/spring-boot-modules/spring-boot-deployment/pom.xml index b3fc3eabd1..6b5e75bd62 100644 --- a/spring-boot-modules/spring-boot-deployment/pom.xml +++ b/spring-boot-modules/spring-boot-deployment/pom.xml @@ -8,14 +8,13 @@ Demo project for Spring Boot - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ - org.springframework.boot spring-boot-starter-web diff --git a/spring-boot-modules/spring-boot-di/pom.xml b/spring-boot-modules/spring-boot-di/pom.xml index b24e4a9037..87a0ad2937 100644 --- a/spring-boot-modules/spring-boot-di/pom.xml +++ b/spring-boot-modules/spring-boot-di/pom.xml @@ -3,18 +3,20 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - spring-boot-di - spring-boot-di - jar - Module For Spring Boot DI - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-di + jar + + spring-boot-di + Module For Spring Boot DI + org.aspectj diff --git a/spring-boot-modules/spring-boot-environment/pom.xml b/spring-boot-modules/spring-boot-environment/pom.xml index 138c59847d..694e17fd72 100644 --- a/spring-boot-modules/spring-boot-environment/pom.xml +++ b/spring-boot-modules/spring-boot-environment/pom.xml @@ -2,20 +2,21 @@ 4.0.0 - spring-boot-environment - spring-boot-environment - war - Demo project for Spring Boot - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ - + spring-boot-environment + war + spring-boot-environment + Demo project for Spring Boot + + org.springframework.boot spring-boot-starter-web diff --git a/spring-boot-modules/spring-boot-exceptions/pom.xml b/spring-boot-modules/spring-boot-exceptions/pom.xml index 6ef7e66770..4b9d787b61 100644 --- a/spring-boot-modules/spring-boot-exceptions/pom.xml +++ b/spring-boot-modules/spring-boot-exceptions/pom.xml @@ -2,18 +2,20 @@ 4.0.0 - spring-boot-exceptions - spring-boot-exceptions - jar - Demo project for working with Spring Boot exceptions - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-exceptions + jar + + spring-boot-exceptions + Demo project for working with Spring Boot exceptions + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-flowable/pom.xml b/spring-boot-modules/spring-boot-flowable/pom.xml index 7d9fb97cba..f1121ea6a0 100644 --- a/spring-boot-modules/spring-boot-flowable/pom.xml +++ b/spring-boot-modules/spring-boot-flowable/pom.xml @@ -3,18 +3,20 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - spring-boot-flowable - spring-boot-flowable - war - Spring Boot Flowable Module - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot-flowable + war + + spring-boot-flowable + Spring Boot Flowable Module + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-jasypt/pom.xml b/spring-boot-modules/spring-boot-jasypt/pom.xml index e63a02729f..2f0c8a27b4 100644 --- a/spring-boot-modules/spring-boot-jasypt/pom.xml +++ b/spring-boot-modules/spring-boot-jasypt/pom.xml @@ -2,19 +2,21 @@ 4.0.0 - com.example.jasypt - spring-boot-jasypt - spring-boot-jasypt - jar - Demo project for Spring Boot - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + com.example.jasypt + spring-boot-jasypt + jar + + spring-boot-jasypt + Demo project for Spring Boot + org.springframework.boot diff --git a/spring-boot-modules/spring-boot-keycloak/pom.xml b/spring-boot-modules/spring-boot-keycloak/pom.xml index 68d4ec4b8f..6208fbe305 100644 --- a/spring-boot-modules/spring-boot-keycloak/pom.xml +++ b/spring-boot-modules/spring-boot-keycloak/pom.xml @@ -2,19 +2,21 @@ 4.0.0 + + + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + + com.baeldung.keycloak spring-boot-keycloak 0.0.1 - spring-boot-keycloak jar - This is a simple application demonstrating integration between Keycloak and Spring Boot. - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 - + spring-boot-keycloak + This is a simple application demonstrating integration between Keycloak and Spring Boot. diff --git a/spring-boot-modules/spring-boot/pom.xml b/spring-boot-modules/spring-boot/pom.xml index e0ff9ae2f9..e1299a6a16 100644 --- a/spring-boot-modules/spring-boot/pom.xml +++ b/spring-boot-modules/spring-boot/pom.xml @@ -3,40 +3,22 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - spring-boot - spring-boot - war - This is simple boot application for Spring boot actuator test - 0.0.1-SNAPSHOT - parent-boot-2 - com.baeldung - 0.0.1-SNAPSHOT - ../../parent-boot-2 + com.baeldung.spring-boot-modules + spring-boot-modules + 1.0.0-SNAPSHOT + ../ + spring-boot + 0.0.1-SNAPSHOT + war + + spring-boot + This is simple boot application for Spring boot actuator test + - - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - - - org.junit.platform - junit-platform-launcher - ${junit-platform.version} - test - org.springframework.boot spring-boot-starter-thymeleaf From 78cacb4d2e223744bf829fa743e886463f38575d Mon Sep 17 00:00:00 2001 From: Mona Mohamadinia Date: Fri, 3 Jul 2020 18:59:56 +0430 Subject: [PATCH 35/42] Code Samples for BAEL-4130 (#9513) --- spring-aop/pom.xml | 5 ++ .../undeclared/SomeCheckedException.java | 7 +++ .../baeldung/undeclared/ThrowUndeclared.java | 11 +++++ .../undeclared/UndeclaredApplication.java | 12 +++++ .../baeldung/undeclared/UndeclaredAspect.java | 16 +++++++ .../undeclared/UndeclaredService.java | 10 ++++ ...aredThrowableExceptionIntegrationTest.java | 25 ++++++++++ .../UndeclaredThrowableExceptionUnitTest.java | 48 +++++++++++++++++++ 8 files changed, 134 insertions(+) create mode 100644 spring-aop/src/test/java/com/baeldung/undeclared/SomeCheckedException.java create mode 100644 spring-aop/src/test/java/com/baeldung/undeclared/ThrowUndeclared.java create mode 100644 spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredApplication.java create mode 100644 spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredAspect.java create mode 100644 spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredService.java create mode 100644 spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredThrowableExceptionIntegrationTest.java create mode 100644 spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredThrowableExceptionUnitTest.java diff --git a/spring-aop/pom.xml b/spring-aop/pom.xml index 69de2d66fd..74b6f48b46 100644 --- a/spring-aop/pom.xml +++ b/spring-aop/pom.xml @@ -18,6 +18,11 @@ org.springframework.boot spring-boot-starter-aop + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/spring-aop/src/test/java/com/baeldung/undeclared/SomeCheckedException.java b/spring-aop/src/test/java/com/baeldung/undeclared/SomeCheckedException.java new file mode 100644 index 0000000000..bbb28681fa --- /dev/null +++ b/spring-aop/src/test/java/com/baeldung/undeclared/SomeCheckedException.java @@ -0,0 +1,7 @@ +package com.baeldung.undeclared; + +public class SomeCheckedException extends Exception { + public SomeCheckedException(String message) { + super(message); + } +} diff --git a/spring-aop/src/test/java/com/baeldung/undeclared/ThrowUndeclared.java b/spring-aop/src/test/java/com/baeldung/undeclared/ThrowUndeclared.java new file mode 100644 index 0000000000..dd6436e722 --- /dev/null +++ b/spring-aop/src/test/java/com/baeldung/undeclared/ThrowUndeclared.java @@ -0,0 +1,11 @@ +package com.baeldung.undeclared; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface ThrowUndeclared { +} diff --git a/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredApplication.java b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredApplication.java new file mode 100644 index 0000000000..37a0ec89b5 --- /dev/null +++ b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredApplication.java @@ -0,0 +1,12 @@ +package com.baeldung.undeclared; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class UndeclaredApplication { + + public static void main(String[] args) { + SpringApplication.run(UndeclaredApplication.class, args); + } +} diff --git a/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredAspect.java b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredAspect.java new file mode 100644 index 0000000000..076fdff66c --- /dev/null +++ b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredAspect.java @@ -0,0 +1,16 @@ +package com.baeldung.undeclared; + +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.stereotype.Component; + +@Aspect +@Component +public class UndeclaredAspect { + + @Around("@annotation(undeclared)") + public Object advise(ProceedingJoinPoint pjp, ThrowUndeclared undeclared) throws Throwable { + throw new SomeCheckedException("AOP Checked Exception"); + } +} diff --git a/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredService.java b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredService.java new file mode 100644 index 0000000000..6cc16c1ceb --- /dev/null +++ b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredService.java @@ -0,0 +1,10 @@ +package com.baeldung.undeclared; + +import org.springframework.stereotype.Service; + +@Service +public class UndeclaredService { + + @ThrowUndeclared + public void doSomething() {} +} diff --git a/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredThrowableExceptionIntegrationTest.java b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredThrowableExceptionIntegrationTest.java new file mode 100644 index 0000000000..e64a45d418 --- /dev/null +++ b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredThrowableExceptionIntegrationTest.java @@ -0,0 +1,25 @@ +package com.baeldung.undeclared; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import java.lang.reflect.UndeclaredThrowableException; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = UndeclaredApplication.class) +public class UndeclaredThrowableExceptionIntegrationTest { + + @Autowired private UndeclaredService service; + + @Test + public void givenAnAspect_whenCallingAdvisedMethod_thenShouldWrapTheException() { + assertThatThrownBy(service::doSomething) + .isInstanceOf(UndeclaredThrowableException.class) + .hasCauseInstanceOf(SomeCheckedException.class); + } +} diff --git a/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredThrowableExceptionUnitTest.java b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredThrowableExceptionUnitTest.java new file mode 100644 index 0000000000..464239d12d --- /dev/null +++ b/spring-aop/src/test/java/com/baeldung/undeclared/UndeclaredThrowableExceptionUnitTest.java @@ -0,0 +1,48 @@ +package com.baeldung.undeclared; + +import org.junit.Test; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.lang.reflect.UndeclaredThrowableException; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +public class UndeclaredThrowableExceptionUnitTest { + + @Test + @SuppressWarnings("unchecked") + public void givenAProxy_whenProxyUndeclaredThrowsCheckedException_thenShouldBeWrapped() { + ClassLoader classLoader = getClass().getClassLoader(); + InvocationHandler invocationHandler = new ExceptionalInvocationHandler(); + List proxy = (List) Proxy.newProxyInstance(classLoader, new Class[] { List.class }, invocationHandler); + + assertThatThrownBy(proxy::size) + .isInstanceOf(UndeclaredThrowableException.class) + .hasCauseInstanceOf(SomeCheckedException.class); + } + + @Test + @SuppressWarnings("unchecked") + public void givenAProxy_whenProxyThrowsUncheckedException_thenShouldBeThrownAsIs() { + ClassLoader classLoader = getClass().getClassLoader(); + InvocationHandler invocationHandler = new ExceptionalInvocationHandler(); + List proxy = (List) Proxy.newProxyInstance(classLoader, new Class[] { List.class }, invocationHandler); + + assertThatThrownBy(proxy::isEmpty).isInstanceOf(RuntimeException.class); + } + + private static class ExceptionalInvocationHandler implements InvocationHandler { + + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + if ("size".equals(method.getName())) { + throw new SomeCheckedException("Always fails"); + } + + throw new RuntimeException(); + } + } +} From 535c88153d975fad774bfd3a7a7cb502fe1fbbee Mon Sep 17 00:00:00 2001 From: Roque Santos Date: Sat, 4 Jul 2020 06:29:58 -0300 Subject: [PATCH 36/42] BAEL-4163 - Counting matches for a regex (#9466) * BAEL-4163 - Counting matches for a regex * BAEL-4163 - Fixing build problemns * BAEL-4163 : Adding more test to assure quality of the examples * BAEL-4163 : Fixing request changes * BAEL-4163 : Minor adjustements to give more context about the commented out tests * BAEL-4163 : Tests for overlap example --- .../countmatches/CountMatchesUnitTest.java | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/countmatches/CountMatchesUnitTest.java diff --git a/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/countmatches/CountMatchesUnitTest.java b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/countmatches/CountMatchesUnitTest.java new file mode 100644 index 0000000000..6427d11dd6 --- /dev/null +++ b/core-java-modules/core-java-regex/src/test/java/com/baeldung/regex/countmatches/CountMatchesUnitTest.java @@ -0,0 +1,110 @@ +package com.baeldung.regex.countmatches; + +import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.junit.Test; + +/** + * Unit Test intended to count number of matches of a RegEx using Java 8 and 9. + * + * Java 9 is needed to run the commented out tests. + */ +public class CountMatchesUnitTest { + + private static final Pattern EMAIL_ADDRESS_PATTERN = Pattern.compile("([a-z0-9_.-]+)@([a-z0-9_.-]+[a-z])"); + private static final String TEXT_CONTAINING_EMAIL_ADDRESSES = "You can contact me through: writer@baeldung.com, editor@baeldung.com and team@bealdung.com"; + private static final String TEXT_CONTAINING_FIVE_EMAIL_ADDRESSES = "Valid emails are: me@gmail.com, you@baeldung.com, contact@hotmail.com, press@anysite.com and support@bealdung.com"; + private static final String TEXT_CONTAINING_OVERLAP_EMAIL_ADDRESSES = "Try to contact us at team@baeldung.comeditor@baeldung.com, support@baeldung.com."; + + @Test + public void givenContainingEmailString_whenJava8Match_thenCountMacthesFound() { + Matcher countEmailMatcher = EMAIL_ADDRESS_PATTERN.matcher(TEXT_CONTAINING_EMAIL_ADDRESSES); + + int count = 0; + while (countEmailMatcher.find()) { + count++; + } + + assertEquals(3, count); + } + + @Test + public void givenContainingFiveEmailsString_whenJava8Match_thenCountMacthesFound() { + Matcher countFiveEmailsMatcher = EMAIL_ADDRESS_PATTERN.matcher(TEXT_CONTAINING_FIVE_EMAIL_ADDRESSES); + + int count = 0; + while (countFiveEmailsMatcher.find()) { + count++; + } + + assertEquals(5, count); + } + + @Test + public void givenStringWithoutEmails_whenJava8Match_thenCountMacthesNotFound() { + Matcher noEmailMatcher = EMAIL_ADDRESS_PATTERN.matcher("Simple text without emails."); + + int count = 0; + while (noEmailMatcher.find()) { + count++; + } + + assertEquals(0, count); + } + + @Test + public void givenStringWithOverlappingEmails_whenJava8Match_thenCountWrongMatches() { + Matcher countOverlappingEmailsMatcher = EMAIL_ADDRESS_PATTERN.matcher(TEXT_CONTAINING_OVERLAP_EMAIL_ADDRESSES); + + int count = 0; + while (countOverlappingEmailsMatcher.find()) { + count++; + } + + assertNotEquals(3, count); + } + + @Test + public void givenContainingEmailString_whenStartingInJava9Match_thenCountMacthesFound() { + // uncomment to try with Java 9 + // Matcher countEmailMatcher = EMAIL_ADDRESS_PATTERN.matcher(TEXT_CONTAINING_EMAIL_ADDRESSES); + + // long count = countEmailMatcher.results().count(); + + // assertEquals(3, count); + } + + @Test + public void givenContainingFiveEmailsString_whenStartingInJava9Match_thenCountMacthesFound() { + // uncomment to try with Java 9 + // Matcher countFiveEmailsMatcher = EMAIL_ADDRESS_PATTERN.matcher(TEXT_CONTAINING_FIVE_EMAIL_ADDRESSES); + + // long count = countFiveEmailsMatcher.results().count(); + + // assertEquals(5, count); + } + + @Test + public void givenStringWithoutEmails_whenJava9Match_thenCountMacthesNotFound() { + // uncomment to try with Java 9 + // Matcher noEmailMatcher = EMAIL_ADDRESS_PATTERN.matcher("Simple text without emails."); + + // long count = noEmailMatcher.results().count(); + + // assertEquals(0, count); + } + + @Test + public void givenStringWithOverlappingEmails_whenJava9Match_thenCountWrongMatches() { + // uncomment to try with Java 9 + // Matcher countOverlappingEmailsMatcher = EMAIL_ADDRESS_PATTERN.matcher(TEXT_CONTAINING_OVERLAP_EMAIL_ADDRESSES); + + // long count = countOverlappingEmailsMatcher.results().count(); + + // assertNotEquals(3, count); + } +} From 38de853a5907003158b09c3cfe346f601d6d8427 Mon Sep 17 00:00:00 2001 From: Loredana Date: Sat, 4 Jul 2020 13:02:35 +0300 Subject: [PATCH 37/42] BAEL-4011 remove shared-dto module --- spring-cloud/spring-cloud-bootstrap/pom.xml | 3 +- .../spring-cloud-bootstrap/shared-dto/pom.xml | 60 ------------------- .../com/baeldung/deliverydto/CustomerDTO.java | 16 ----- .../java/com/baeldung/shared/CustomerDTO.java | 15 ----- .../java/com/baeldung/shared/OrderDTO.java | 16 ----- 5 files changed, 1 insertion(+), 109 deletions(-) delete mode 100644 spring-cloud/spring-cloud-bootstrap/shared-dto/pom.xml delete mode 100644 spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/deliverydto/CustomerDTO.java delete mode 100644 spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/shared/CustomerDTO.java delete mode 100644 spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/shared/OrderDTO.java diff --git a/spring-cloud/spring-cloud-bootstrap/pom.xml b/spring-cloud/spring-cloud-bootstrap/pom.xml index ed9b148564..eb1a55c2a9 100644 --- a/spring-cloud/spring-cloud-bootstrap/pom.xml +++ b/spring-cloud/spring-cloud-bootstrap/pom.xml @@ -22,7 +22,6 @@ zipkin customer-service order-service - shared-dto - \ No newline at end of file + diff --git a/spring-cloud/spring-cloud-bootstrap/shared-dto/pom.xml b/spring-cloud/spring-cloud-bootstrap/shared-dto/pom.xml deleted file mode 100644 index 59dde717b5..0000000000 --- a/spring-cloud/spring-cloud-bootstrap/shared-dto/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - 4.0.0 - com.baeldung - shared-dto - 1.0.0-SNAPSHOT - shared-dto - - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../../parent-boot-2 - - - - - UTF-8 - 1.8 - 1.8 - 0.0.2 - - - - - org.qunix - structure-maven-plugin - ${structure-maven.version} - - - org.projectlombok - lombok - true - - - - - - - - org.qunix - structure-maven-plugin - ${structure-maven.version} - false - - - compile - - files - - - - - - - - diff --git a/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/deliverydto/CustomerDTO.java b/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/deliverydto/CustomerDTO.java deleted file mode 100644 index aa6b3ceac8..0000000000 --- a/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/deliverydto/CustomerDTO.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.deliverydto; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@AllArgsConstructor -public class CustomerDTO { - private String firstName; - private String lastName; - private String homeAddress; - private String contactNumber; - // constructor, getters, setters -} diff --git a/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/shared/CustomerDTO.java b/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/shared/CustomerDTO.java deleted file mode 100644 index 905773609d..0000000000 --- a/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/shared/CustomerDTO.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.baeldung.shared; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@AllArgsConstructor -public class CustomerDTO { - private String firstName; - private String lastName; - private String cardNumber; - // constructor, getters, setters -} diff --git a/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/shared/OrderDTO.java b/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/shared/OrderDTO.java deleted file mode 100644 index 0640b84291..0000000000 --- a/spring-cloud/spring-cloud-bootstrap/shared-dto/src/main/java/com/baeldung/shared/OrderDTO.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.baeldung.shared; - - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Data -@NoArgsConstructor -@AllArgsConstructor -public class OrderDTO { - - private int customerId; - private String itemId; - -} From a593cfc3ef11a849a7c294b809a0c48510326488 Mon Sep 17 00:00:00 2001 From: Sampada <46674082+sampada07@users.noreply.github.com> Date: Sat, 4 Jul 2020 17:04:02 +0530 Subject: [PATCH 38/42] JAVA-1808: Added passwordEncoder bean (#9637) * JAVA-1808: Added passwordEncoder bean * JAVA-1808: renamed bean to encoder --- .../src/main/resources/webSecurityConfig.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-security-modules/spring-security-rest/src/main/resources/webSecurityConfig.xml b/spring-security-modules/spring-security-rest/src/main/resources/webSecurityConfig.xml index 2c0a0bc774..b20151b8f4 100644 --- a/spring-security-modules/spring-security-rest/src/main/resources/webSecurityConfig.xml +++ b/spring-security-modules/spring-security-rest/src/main/resources/webSecurityConfig.xml @@ -33,6 +33,8 @@ class="com.baeldung.security.MySavedRequestAwareAuthenticationSuccessHandler" /> + From 15c11266ad220b66a6ab1c13164438a21cf77d74 Mon Sep 17 00:00:00 2001 From: kwoyke Date: Sat, 4 Jul 2020 20:31:08 +0200 Subject: [PATCH 39/42] BAEL-3267: Convert the integration tests to Live tests (#9634) --- ...etupIntegrationTest.java => EJBSetupLiveTest.java} | 7 ++++++- ...egrationTest.java => TextApplicationLiveTest.java} | 9 +++++++-- .../SpringEjbClientApplicationIntegrationTest.java | 11 ----------- 3 files changed, 13 insertions(+), 14 deletions(-) rename spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/setup/test/{EJBSetupIntegrationTest.java => EJBSetupLiveTest.java} (69%) rename spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/wildfly/{TextApplicationIntegrationTest.java => TextApplicationLiveTest.java} (74%) delete mode 100644 spring-ejb/spring-ejb-client/src/test/java/com/baeldung/springejbclient/SpringEjbClientApplicationIntegrationTest.java diff --git a/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/setup/test/EJBSetupIntegrationTest.java b/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/setup/test/EJBSetupLiveTest.java similarity index 69% rename from spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/setup/test/EJBSetupIntegrationTest.java rename to spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/setup/test/EJBSetupLiveTest.java index c04a649d26..e85d2f155a 100644 --- a/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/setup/test/EJBSetupIntegrationTest.java +++ b/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/setup/test/EJBSetupLiveTest.java @@ -6,7 +6,12 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class EJBSetupIntegrationTest { +/** + * This Live Test requires: + * * run the `spring-ejb-remote` module with the following command: `mvn clean package cargo:run -Pwildfly-standalone` + * + */ +public class EJBSetupLiveTest { @Test public void EJBClientTest() { diff --git a/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/wildfly/TextApplicationIntegrationTest.java b/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/wildfly/TextApplicationLiveTest.java similarity index 74% rename from spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/wildfly/TextApplicationIntegrationTest.java rename to spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/wildfly/TextApplicationLiveTest.java index 8dff116ca1..616811eae6 100644 --- a/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/wildfly/TextApplicationIntegrationTest.java +++ b/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/ejb/wildfly/TextApplicationLiveTest.java @@ -8,7 +8,12 @@ import java.io.ByteArrayOutputStream; import java.io.PrintStream; import static org.junit.Assert.*; -public class TextApplicationIntegrationTest { +/** + * This Live Test requires: + * * run the `spring-ejb-remote` module with the following command: `mvn clean package cargo:run -Pwildfly-standalone` + * + */ +public class TextApplicationLiveTest { private static ByteArrayOutputStream outContent; @@ -26,6 +31,6 @@ public class TextApplicationIntegrationTest { @Test public void givenInputString_whenCompareTtoStringPrintedToConsole_thenSuccessful() throws NamingException { TextApplication.main(new String[]{}); - assertEquals("SAMPLE TEXT", outContent.toString()); + assertTrue(outContent.toString().contains("SAMPLE TEXT")); } } \ No newline at end of file diff --git a/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/springejbclient/SpringEjbClientApplicationIntegrationTest.java b/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/springejbclient/SpringEjbClientApplicationIntegrationTest.java deleted file mode 100644 index 89c88fe5a5..0000000000 --- a/spring-ejb/spring-ejb-client/src/test/java/com/baeldung/springejbclient/SpringEjbClientApplicationIntegrationTest.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.baeldung.springejbclient; - -import org.junit.Test; - -public class SpringEjbClientApplicationIntegrationTest { - - @Test - public void contextLoads() { - } - -} From 9de9692083e08b81b4c5262bd98ce082c2b31f46 Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Mon, 6 Jul 2020 13:57:22 +0530 Subject: [PATCH 40/42] updated unit test cases so that build doesn't generate un-committed files --- .gitignore | 2 + .../jgrapht/GraphImageGenerationUnitTest.java | 15 ++++- .../com/baeldung/jackson/csv/CsvUnitTest.java | 59 +++++++++++-------- .../baeldung/jackson/yaml/YamlUnitTest.java | 12 +++- .../univocity/ParsingServiceUnitTest.java | 11 ++++ 5 files changed, 71 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 78125cc3ee..c54117203f 100644 --- a/.gitignore +++ b/.gitignore @@ -85,3 +85,5 @@ transaction.log *-shell.log apache-cxf/cxf-aegis/baeldung.xml + +libraries-2/*.db \ No newline at end of file diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/jgrapht/GraphImageGenerationUnitTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/jgrapht/GraphImageGenerationUnitTest.java index 3b841d574a..a0d7523f48 100644 --- a/algorithms-miscellaneous-2/src/test/java/com/baeldung/jgrapht/GraphImageGenerationUnitTest.java +++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/jgrapht/GraphImageGenerationUnitTest.java @@ -1,16 +1,21 @@ package com.baeldung.jgrapht; import static org.junit.Assert.assertTrue; + import java.awt.Color; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; + import javax.imageio.ImageIO; + import org.jgrapht.ext.JGraphXAdapter; import org.jgrapht.graph.DefaultDirectedGraph; import org.jgrapht.graph.DefaultEdge; +import org.junit.After; import org.junit.Before; import org.junit.Test; + import com.mxgraph.layout.mxCircleLayout; import com.mxgraph.layout.mxIGraphLayout; import com.mxgraph.util.mxCellRenderer; @@ -20,7 +25,7 @@ public class GraphImageGenerationUnitTest { @Before public void createGraph() throws IOException { - File imgFile = new File("src/test/resources/graph.png"); + File imgFile = new File("src/test/resources/graph1.png"); imgFile.createNewFile(); g = new DefaultDirectedGraph(DefaultEdge.class); String x1 = "x1"; @@ -34,12 +39,18 @@ public class GraphImageGenerationUnitTest { g.addEdge(x3, x1); } + @After + public void cleanup() { + File imgFile = new File("src/test/resources/graph1.png"); + imgFile.deleteOnExit(); + } + @Test public void givenAdaptedGraph_whenWriteBufferedImage_ThenFileShouldExist() throws IOException { JGraphXAdapter graphAdapter = new JGraphXAdapter(g); mxIGraphLayout layout = new mxCircleLayout(graphAdapter); layout.execute(graphAdapter.getDefaultParent()); - File imgFile = new File("src/test/resources/graph.png"); + File imgFile = new File("src/test/resources/graph1.png"); BufferedImage image = mxCellRenderer.createBufferedImage(graphAdapter, null, 2, Color.WHITE, true, null); ImageIO.write(image, "PNG", imgFile); assertTrue(imgFile.exists()); diff --git a/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/csv/CsvUnitTest.java b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/csv/CsvUnitTest.java index c257cb7dc9..7226eaf27d 100644 --- a/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/csv/CsvUnitTest.java +++ b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/csv/CsvUnitTest.java @@ -7,48 +7,59 @@ import java.io.IOException; import java.nio.charset.Charset; import java.util.List; +import org.junit.After; +import org.junit.Before; import org.junit.Test; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; import com.google.common.io.Files; - public class CsvUnitTest { + private File csvFromJson; + private File jsonFromCsv; + private File formattedCsvFromJson; + + @Before + public void setup() { + csvFromJson = new File("src/main/resources/csv/csvFromJson.csv"); + jsonFromCsv = new File("src/main/resources/csv/jsonFromCsv.json"); + formattedCsvFromJson = new File("src/main/resources/csv/formattedCsvFromJson.csv"); + } + + @After + public void cleanup() { + csvFromJson.deleteOnExit(); + jsonFromCsv.deleteOnExit(); + formattedCsvFromJson.deleteOnExit(); + } + @Test public void givenJsonInput_thenWriteCsv() throws JsonParseException, JsonMappingException, IOException { - JsonCsvConverter.JsonToCsv(new File("src/main/resources/csv/orderLines.json"), - new File("src/main/resources/csv/csvFromJson.csv")); - - assertEquals(readFile("src/main/resources/csv/csvFromJson.csv"), - readFile("src/test/resources/csv/expectedCsvFromJson.csv")); + JsonCsvConverter.JsonToCsv(new File("src/main/resources/csv/orderLines.json"), csvFromJson); + + assertEquals(readFile(csvFromJson.getAbsolutePath()), readFile("src/test/resources/csv/expectedCsvFromJson.csv")); } - + @Test public void givenCsvInput_thenWritesJson() throws JsonParseException, JsonMappingException, IOException { - JsonCsvConverter.csvToJson(new File("src/main/resources/csv/orderLines.csv"), - new File("src/main/resources/csv/jsonFromCsv.json")); - - assertEquals(readFile("src/main/resources/csv/jsonFromCsv.json"), - readFile("src/test/resources/csv/expectedJsonFromCsv.json")); - + JsonCsvConverter.csvToJson(new File("src/main/resources/csv/orderLines.csv"), jsonFromCsv); + + assertEquals(readFile(jsonFromCsv.getAbsolutePath()), readFile("src/test/resources/csv/expectedJsonFromCsv.json")); + } - + @Test public void givenJsonInput_thenWriteFormattedCsvOutput() throws JsonParseException, JsonMappingException, IOException { - JsonCsvConverter.JsonToFormattedCsv(new File("src/main/resources/csv/orderLines.json"), - new File("src/main/resources/csv/formattedCsvFromJson.csv")); + JsonCsvConverter.JsonToFormattedCsv(new File("src/main/resources/csv/orderLines.json"), formattedCsvFromJson); + + assertEquals(readFile(formattedCsvFromJson.getAbsolutePath()), readFile("src/test/resources/csv/expectedFormattedCsvFromJson.csv")); - assertEquals(readFile("src/main/resources/csv/formattedCsvFromJson.csv"), - readFile("src/test/resources/csv/expectedFormattedCsvFromJson.csv")); - } - + private List readFile(String filename) throws IOException { return Files.readLines(new File(filename), Charset.forName("utf-8")); } - - -} -; \ No newline at end of file + +}; \ No newline at end of file diff --git a/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/yaml/YamlUnitTest.java b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/yaml/YamlUnitTest.java index 17c487ff26..cfa5afec0d 100644 --- a/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/yaml/YamlUnitTest.java +++ b/jackson-modules/jackson-conversions-2/src/test/java/com/baeldung/jackson/yaml/YamlUnitTest.java @@ -12,6 +12,7 @@ import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; +import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -25,12 +26,19 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator.Feature; public class YamlUnitTest { private ObjectMapper mapper; + private File orderOutput; @Before public void setup() { mapper = new ObjectMapper(new YAMLFactory().disable(Feature.WRITE_DOC_START_MARKER)); mapper.findAndRegisterModules(); mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + orderOutput = new File("src/test/resources/yaml/orderOutput.yaml"); + } + + @After + public void cleanup() { + orderOutput.deleteOnExit(); } @Test @@ -53,9 +61,9 @@ public class YamlUnitTest { LocalDate.parse("2019-04-18", DateTimeFormatter.ISO_DATE), "Customer, Jane", lines); - mapper.writeValue(new File("src/test/resources/yaml/orderOutput.yaml"), order); + mapper.writeValue(orderOutput, order); - File outputYaml = new File("src/test/resources/yaml/orderOutput.yaml"); + File outputYaml = new File(orderOutput.getAbsolutePath()); assertTrue(outputYaml.exists()); } } diff --git a/libraries-data-2/src/test/java/com/baeldung/univocity/ParsingServiceUnitTest.java b/libraries-data-2/src/test/java/com/baeldung/univocity/ParsingServiceUnitTest.java index 8cac0bc4b8..c1321ef675 100644 --- a/libraries-data-2/src/test/java/com/baeldung/univocity/ParsingServiceUnitTest.java +++ b/libraries-data-2/src/test/java/com/baeldung/univocity/ParsingServiceUnitTest.java @@ -2,15 +2,26 @@ package com.baeldung.univocity; import static org.junit.Assert.assertEquals; +import java.io.File; import java.util.ArrayList; import java.util.List; +import org.junit.After; import org.junit.Test; import com.baeldung.univocity.model.Product; public class ParsingServiceUnitTest { + @After + public void cleanup() { + File csvFile = new File("src/test/resources/outputProductList.csv"); + csvFile.deleteOnExit(); + + File textFile = new File("src/test/resources/outputProductList.txt"); + textFile.deleteOnExit(); + } + @Test public void givenCsvFile_thenParsedResultsShouldBeReturned() { ParsingService parsingService = new ParsingService(); From ce9f854790d46e04c9c6a66e07b738b85708d46f Mon Sep 17 00:00:00 2001 From: Eugen Date: Mon, 6 Jul 2020 14:07:31 +0300 Subject: [PATCH 41/42] Delete .gitignore --- guava-2/.gitignore | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 guava-2/.gitignore diff --git a/guava-2/.gitignore b/guava-2/.gitignore deleted file mode 100644 index 83c05e60c8..0000000000 --- a/guava-2/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.class - -#folders# -/target -/neoDb* -/data -/src/main/webapp/WEB-INF/classes -*/META-INF/* - -# Packaged files # -*.jar -*.war -*.ear \ No newline at end of file From 424fe87a4a738f1b67a7a2663383c0319219febf Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Mon, 6 Jul 2020 17:36:09 +0530 Subject: [PATCH 42/42] pom formatting - arrang tags as per standard order --- aws-app-sync/pom.xml | 7 +- .../core-java-arrays-operations-basic/pom.xml | 52 ++--- .../core-java-arrays-sorting/pom.xml | 52 ++--- core-java-modules/pom.xml | 24 +-- ddd/pom.xml | 20 +- guava-collections-map/pom.xml | 30 +-- guava-collections-set/pom.xml | 24 +-- guava-collections/pom.xml | 38 ++-- guava-io/pom.xml | 29 +-- guava-modules/pom.xml | 21 +- guava/pom.xml | 38 ++-- jackson-modules/pom.xml | 20 +- jackson-simple/pom.xml | 38 ++-- libraries-data-2/pom.xml | 35 ++-- .../maven-unused-dependencies/pom.xml | 14 +- patterns/cqrs-es/pom.xml | 18 +- performance-tests/pom.xml | 77 ++++---- spring-boot-modules/pom.xml | 19 +- .../customer-service/pom.xml | 14 +- .../order-service/pom.xml | 20 +- .../spring-cloud-open-service-broker/pom.xml | 12 +- .../spring-security-kotlin-dsl/pom.xml | 11 +- .../spring-security-mvc/pom.xml | 10 +- .../spring-security-sso-kerberos/pom.xml | 50 ++--- .../pom.xml | 181 +++++++++--------- webrtc/pom.xml | 8 +- 26 files changed, 436 insertions(+), 426 deletions(-) diff --git a/aws-app-sync/pom.xml b/aws-app-sync/pom.xml index 4c55d38d77..700ffad735 100644 --- a/aws-app-sync/pom.xml +++ b/aws-app-sync/pom.xml @@ -13,10 +13,6 @@ ../parent-boot-2 - - 1.8 - - @@ -50,4 +46,7 @@ + + 1.8 + diff --git a/core-java-modules/core-java-arrays-operations-basic/pom.xml b/core-java-modules/core-java-arrays-operations-basic/pom.xml index 73588d662a..64856d9b39 100644 --- a/core-java-modules/core-java-arrays-operations-basic/pom.xml +++ b/core-java-modules/core-java-arrays-operations-basic/pom.xml @@ -13,32 +13,6 @@ core-java-arrays-operations-basic jar - - - - org.apache.maven.plugins - maven-shade-plugin - ${shade.plugin.version} - - - package - - shade - - - benchmarks - - - org.openjdk.jmh.Main - - - - - - - - - org.apache.commons @@ -66,6 +40,32 @@ + + + + org.apache.maven.plugins + maven-shade-plugin + ${shade.plugin.version} + + + package + + shade + + + benchmarks + + + org.openjdk.jmh.Main + + + + + + + + + 3.2.0 diff --git a/core-java-modules/core-java-arrays-sorting/pom.xml b/core-java-modules/core-java-arrays-sorting/pom.xml index d5e2beaac4..9b307870a1 100644 --- a/core-java-modules/core-java-arrays-sorting/pom.xml +++ b/core-java-modules/core-java-arrays-sorting/pom.xml @@ -14,32 +14,6 @@ core-java-arrays-sorting jar - - - - org.apache.maven.plugins - maven-shade-plugin - ${shade.plugin.version} - - - package - - shade - - - benchmarks - - - org.openjdk.jmh.Main - - - - - - - - - @@ -74,6 +48,32 @@ + + + + org.apache.maven.plugins + maven-shade-plugin + ${shade.plugin.version} + + + package + + shade + + + benchmarks + + + org.openjdk.jmh.Main + + + + + + + + + 3.2.0 diff --git a/core-java-modules/pom.xml b/core-java-modules/pom.xml index 76fed91251..d01a7cc792 100644 --- a/core-java-modules/pom.xml +++ b/core-java-modules/pom.xml @@ -134,18 +134,6 @@ pre-jpms - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - @@ -163,6 +151,18 @@ + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + 2.22.2 5.6.2 diff --git a/ddd/pom.xml b/ddd/pom.xml index 422f9ccd15..9f960502a3 100644 --- a/ddd/pom.xml +++ b/ddd/pom.xml @@ -17,16 +17,6 @@ ../parent-boot-2 - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - @@ -105,6 +95,16 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + 2.22.2 diff --git a/guava-collections-map/pom.xml b/guava-collections-map/pom.xml index 06537d26bd..4a95234d5c 100644 --- a/guava-collections-map/pom.xml +++ b/guava-collections-map/pom.xml @@ -14,6 +14,21 @@ ../parent-java + + + org.junit.jupiter + junit-jupiter + ${junit-jupiter.version} + test + + + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} + test + + + guava-collections-map @@ -33,21 +48,6 @@ - - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - - - 5.6.2 diff --git a/guava-collections-set/pom.xml b/guava-collections-set/pom.xml index 49d96965a7..af46400555 100644 --- a/guava-collections-set/pom.xml +++ b/guava-collections-set/pom.xml @@ -13,18 +13,6 @@ ../parent-java - - guava-collections-set - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - - - @@ -47,6 +35,18 @@ + + guava-collections-set + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + 3.6.1 diff --git a/guava-collections/pom.xml b/guava-collections/pom.xml index 744eba1a38..238ab60f84 100644 --- a/guava-collections/pom.xml +++ b/guava-collections/pom.xml @@ -15,25 +15,6 @@ ../parent-java - - guava-collections - - - - src/main/resources - true - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - - - @@ -76,6 +57,25 @@ + + guava-collections + + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + 4.1 diff --git a/guava-io/pom.xml b/guava-io/pom.xml index fd637f2474..e01f76e2e3 100644 --- a/guava-io/pom.xml +++ b/guava-io/pom.xml @@ -16,6 +16,21 @@ ../parent-java + + + org.junit.jupiter + junit-jupiter + ${junit-jupiter.version} + test + + + org.junit.vintage + junit-vintage-engine + ${junit-jupiter.version} + test + + + guava-io @@ -35,18 +50,4 @@ - - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - - - org.junit.vintage - junit-vintage-engine - ${junit-jupiter.version} - test - - \ No newline at end of file diff --git a/guava-modules/pom.xml b/guava-modules/pom.xml index 4e7282364d..d1a2bbc16e 100644 --- a/guava-modules/pom.xml +++ b/guava-modules/pom.xml @@ -22,16 +22,6 @@ guava-21 - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - - - org.junit.jupiter @@ -46,4 +36,15 @@ test + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + diff --git a/guava/pom.xml b/guava/pom.xml index 881390ae73..2c4ff07c84 100644 --- a/guava/pom.xml +++ b/guava/pom.xml @@ -15,25 +15,6 @@ ../parent-java - - guava - - - - src/main/resources - true - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - - - org.apache.commons @@ -62,6 +43,25 @@ + + guava + + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + 5.6.2 diff --git a/jackson-modules/pom.xml b/jackson-modules/pom.xml index 00722510af..70b10e9554 100644 --- a/jackson-modules/pom.xml +++ b/jackson-modules/pom.xml @@ -23,16 +23,6 @@ jackson-exceptions - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - - - com.fasterxml.jackson.core @@ -60,6 +50,16 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + 5.6.2 diff --git a/jackson-simple/pom.xml b/jackson-simple/pom.xml index 1f838bbed0..761dca6afa 100644 --- a/jackson-simple/pom.xml +++ b/jackson-simple/pom.xml @@ -13,25 +13,6 @@ ../parent-java - - jackson-simple - - - - src/main/resources - true - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - - - @@ -61,6 +42,25 @@ + + jackson-simple + + + + src/main/resources + true + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + 5.6.2 diff --git a/libraries-data-2/pom.xml b/libraries-data-2/pom.xml index be776282e9..93a2f28167 100644 --- a/libraries-data-2/pom.xml +++ b/libraries-data-2/pom.xml @@ -184,6 +184,24 @@ + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + com/baeldung/r/FastRMean.java + + + com/baeldung/r/FastRMeanUnitTest.java + + + + + + 1.5.0 1.6.0 @@ -205,21 +223,4 @@ 2.5.0 - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - com/baeldung/r/FastRMean.java - - - com/baeldung/r/FastRMeanUnitTest.java - - - - - \ No newline at end of file diff --git a/maven-modules/maven-unused-dependencies/pom.xml b/maven-modules/maven-unused-dependencies/pom.xml index 825858e481..d98fe83a0e 100644 --- a/maven-modules/maven-unused-dependencies/pom.xml +++ b/maven-modules/maven-unused-dependencies/pom.xml @@ -6,13 +6,6 @@ maven-unused-dependencies 0.0.1-SNAPSHOT - - 3.2.2 - 1.7.25 - 3.1.2 - 3.1 - - commons-collections @@ -44,4 +37,11 @@ + + 3.2.2 + 1.7.25 + 3.1.2 + 3.1 + + \ No newline at end of file diff --git a/patterns/cqrs-es/pom.xml b/patterns/cqrs-es/pom.xml index 67665a2d32..0829e35f34 100644 --- a/patterns/cqrs-es/pom.xml +++ b/patterns/cqrs-es/pom.xml @@ -1,21 +1,17 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 cqrs-es 1.0-SNAPSHOT cqrs-es + com.baeldung patterns 1.0.0-SNAPSHOT - - 1.8 - 1.8 - 4.13 - 1.18.12 - + org.projectlombok @@ -29,4 +25,12 @@ test + + + 1.8 + 1.8 + 4.13 + 1.18.12 + + \ No newline at end of file diff --git a/performance-tests/pom.xml b/performance-tests/pom.xml index c8cebd8a11..8c66794cfc 100644 --- a/performance-tests/pom.xml +++ b/performance-tests/pom.xml @@ -65,44 +65,6 @@ - - UTF-8 - - - 1.21 - 1.5.2 - 5.5.1 - 1.0.2 - 1.2.0.Final - 1.1.0 - 1.6.0.1 - 1.8 - 1.2.0.Final - 1.21 - 1.21 - 3.7.0 - - - 1.8 - - - benchmarks - 3.1 - 2.2 - 2.5.1 - 2.4 - 2.9.1 - 2.6 - 3.3 - 2.2.1 - 2.17 - @@ -201,4 +163,43 @@ + + UTF-8 + + + 1.21 + 1.5.2 + 5.5.1 + 1.0.2 + 1.2.0.Final + 1.1.0 + 1.6.0.1 + 1.8 + 1.2.0.Final + 1.21 + 1.21 + 3.7.0 + + + 1.8 + + + benchmarks + 3.1 + 2.2 + 2.5.1 + 2.4 + 2.9.1 + 2.6 + 3.3 + 2.2.1 + 2.17 + + diff --git a/spring-boot-modules/pom.xml b/spring-boot-modules/pom.xml index 5add26a527..e1198dec98 100644 --- a/spring-boot-modules/pom.xml +++ b/spring-boot-modules/pom.xml @@ -64,15 +64,6 @@ spring-boot-actuator - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - - @@ -87,6 +78,16 @@ + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + + + 5.6.2 diff --git a/spring-cloud/spring-cloud-bootstrap/customer-service/pom.xml b/spring-cloud/spring-cloud-bootstrap/customer-service/pom.xml index 3e33e27c6c..35f8aceb8d 100644 --- a/spring-cloud/spring-cloud-bootstrap/customer-service/pom.xml +++ b/spring-cloud/spring-cloud-bootstrap/customer-service/pom.xml @@ -16,13 +16,6 @@ ../../../parent-boot-2 - - 1.8 - 1.8 - 1.8 - UTF-8 - - org.springframework.boot @@ -81,4 +74,11 @@ + + + 1.8 + 1.8 + 1.8 + UTF-8 + diff --git a/spring-cloud/spring-cloud-bootstrap/order-service/pom.xml b/spring-cloud/spring-cloud-bootstrap/order-service/pom.xml index 8f3c9ceaff..b626c3b81b 100644 --- a/spring-cloud/spring-cloud-bootstrap/order-service/pom.xml +++ b/spring-cloud/spring-cloud-bootstrap/order-service/pom.xml @@ -21,16 +21,6 @@ order-server - - 1.8 - 2.6 - 0.0.2 - 1.8 - 1.8 - UTF-8 - com.baeldung.orderservice.OrderApplication - - @@ -120,4 +110,14 @@ + + + 1.8 + 2.6 + 0.0.2 + 1.8 + 1.8 + UTF-8 + com.baeldung.orderservice.OrderApplication + diff --git a/spring-cloud/spring-cloud-open-service-broker/pom.xml b/spring-cloud/spring-cloud-open-service-broker/pom.xml index 7acd302dc1..42e90402e5 100644 --- a/spring-cloud/spring-cloud-open-service-broker/pom.xml +++ b/spring-cloud/spring-cloud-open-service-broker/pom.xml @@ -13,12 +13,6 @@ 1.0.0-SNAPSHOT - - 3.1.1.RELEASE - 2.2.7.RELEASE - 3.3.5.RELEASE - - org.springframework.cloud @@ -38,4 +32,10 @@ + + 3.1.1.RELEASE + 2.2.7.RELEASE + 3.3.5.RELEASE + + diff --git a/spring-security-modules/spring-security-kotlin-dsl/pom.xml b/spring-security-modules/spring-security-kotlin-dsl/pom.xml index 2c53d19c2c..24e99decfb 100644 --- a/spring-security-modules/spring-security-kotlin-dsl/pom.xml +++ b/spring-security-modules/spring-security-kotlin-dsl/pom.xml @@ -15,11 +15,6 @@ spring-security-kotlin-dsl Spring Security Kotlin DSL - - 11 - 1.3.72 - - org.springframework.boot @@ -83,4 +78,10 @@ + + + 11 + 1.3.72 + + diff --git a/spring-security-modules/spring-security-mvc/pom.xml b/spring-security-modules/spring-security-mvc/pom.xml index 517aa83270..d97825975f 100644 --- a/spring-security-modules/spring-security-mvc/pom.xml +++ b/spring-security-modules/spring-security-mvc/pom.xml @@ -89,11 +89,6 @@ - - 5.2.2.RELEASE - 4.0.1 - - @@ -108,4 +103,9 @@ + + 5.2.2.RELEASE + 4.0.1 + + diff --git a/spring-security-modules/spring-security-sso/spring-security-sso-kerberos/pom.xml b/spring-security-modules/spring-security-sso/spring-security-sso-kerberos/pom.xml index 0864ead1c4..a67cc4af83 100644 --- a/spring-security-modules/spring-security-sso/spring-security-sso-kerberos/pom.xml +++ b/spring-security-modules/spring-security-sso/spring-security-sso-kerberos/pom.xml @@ -11,31 +11,6 @@ 1.0.0-SNAPSHOT - - - - ${basedir}/src/main/resources - true - - **/* - - - - - - org.apache.maven.plugins - maven-resources-plugin - 2.7 - - - @ - - false - - - - - org.springframework.boot @@ -92,4 +67,29 @@ + + + + ${basedir}/src/main/resources + true + + **/* + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.7 + + + @ + + false + + + + + \ No newline at end of file diff --git a/spring-swagger-codegen/spring-openapi-generator-api-client/pom.xml b/spring-swagger-codegen/spring-openapi-generator-api-client/pom.xml index cc70a9f654..7f4a02eb0d 100644 --- a/spring-swagger-codegen/spring-openapi-generator-api-client/pom.xml +++ b/spring-swagger-codegen/spring-openapi-generator-api-client/pom.xml @@ -31,6 +31,97 @@ + + + sign-artifacts + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + + + + + + + io.swagger + swagger-annotations + ${swagger-annotations-version} + + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + + + org.springframework + spring-web + ${spring-web-version} + + + + + com.fasterxml.jackson.core + jackson-core + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson-version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson-databind-version} + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + ${jackson-version} + + + org.openapitools + jackson-databind-nullable + ${jackson-databind-nullable-version} + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson-version} + + + com.github.joschi.jackson + jackson-datatype-threetenbp + ${jackson-threetenbp-version} + + + + + junit + junit + ${junit-version} + test + + + @@ -170,96 +261,6 @@ - - - sign-artifacts - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - - - - - - - - - io.swagger - swagger-annotations - ${swagger-annotations-version} - - - - - com.google.code.findbugs - jsr305 - 3.0.2 - - - - - org.springframework - spring-web - ${spring-web-version} - - - - - com.fasterxml.jackson.core - jackson-core - ${jackson-version} - - - com.fasterxml.jackson.core - jackson-annotations - ${jackson-version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson-databind-version} - - - com.fasterxml.jackson.jaxrs - jackson-jaxrs-json-provider - ${jackson-version} - - - org.openapitools - jackson-databind-nullable - ${jackson-databind-nullable-version} - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - ${jackson-version} - - - com.github.joschi.jackson - jackson-datatype-threetenbp - ${jackson-threetenbp-version} - - - - - junit - junit - ${junit-version} - test - - UTF-8 1.5.22 diff --git a/webrtc/pom.xml b/webrtc/pom.xml index 6dc98afb1c..f302ae97a2 100644 --- a/webrtc/pom.xml +++ b/webrtc/pom.xml @@ -22,10 +22,6 @@ - - 1.8 - - @@ -35,4 +31,8 @@ + + 1.8 + +