From aa80328881546ff41c9ea43f30c179b93394f340 Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 23 Jun 2019 17:22:18 +0530 Subject: [PATCH 01/12] [BAEL-14274] - Fixed article code for https://www.baeldung.com/rest-template --- .../java/org/baeldung/client/RestTemplateBasicLiveTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-resttemplate/src/test/java/org/baeldung/client/RestTemplateBasicLiveTest.java b/spring-resttemplate/src/test/java/org/baeldung/client/RestTemplateBasicLiveTest.java index a54c124d5f..ff3034a50d 100644 --- a/spring-resttemplate/src/test/java/org/baeldung/client/RestTemplateBasicLiveTest.java +++ b/spring-resttemplate/src/test/java/org/baeldung/client/RestTemplateBasicLiveTest.java @@ -188,7 +188,7 @@ public class RestTemplateBasicLiveTest { final String resourceUrl = fooResourceUrl + '/' + createResponse.getBody() .getId(); final HttpEntity requestUpdate = new HttpEntity<>(updatedResource, headers); - final ClientHttpRequestFactory requestFactory = getSimpleClientHttpRequestFactory(); + final ClientHttpRequestFactory requestFactory = getClientHttpRequestFactory(); final RestTemplate template = new RestTemplate(requestFactory); template.setMessageConverters(Arrays.asList(new MappingJackson2HttpMessageConverter())); template.patchForObject(resourceUrl, requestUpdate, Void.class); @@ -262,7 +262,7 @@ public class RestTemplateBasicLiveTest { // Simply setting restTemplate timeout using ClientHttpRequestFactory - ClientHttpRequestFactory getSimpleClientHttpRequestFactory() { + ClientHttpRequestFactory getClientHttpRequestFactory() { final int timeout = 5; final HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory(); clientHttpRequestFactory.setConnectTimeout(timeout * 1000); From 559de5cfd6373f81804f31324d676694597e1235 Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 23 Jun 2019 17:55:03 +0530 Subject: [PATCH 02/12] [BAEL-14274] - Fixed article code for https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api --- .../baeldung/web/controller/CustomController.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 spring-security-rest/src/main/java/org/baeldung/web/controller/CustomController.java diff --git a/spring-security-rest/src/main/java/org/baeldung/web/controller/CustomController.java b/spring-security-rest/src/main/java/org/baeldung/web/controller/CustomController.java new file mode 100644 index 0000000000..7d40b9bb8d --- /dev/null +++ b/spring-security-rest/src/main/java/org/baeldung/web/controller/CustomController.java @@ -0,0 +1,14 @@ +package org.baeldung.web.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +@Controller +public class CustomController { + + @RequestMapping(value = "/custom", method = RequestMethod.POST) + public String custom() { + return "custom"; + } +} \ No newline at end of file From 57fa2baf7215b417c58bc67235e71cb25d6e188a Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 23 Jun 2019 20:30:38 +0530 Subject: [PATCH 03/12] [BAEL-14274] - Fixed article code for https://www.baeldung.com/spring-requestmapping --- .../org/baeldung/config/{WebConfig.java => MvcConfig.java} | 4 ++-- .../controller/status/ExampleControllerIntegrationTest.java | 4 ++-- .../web/test/BazzNewMappingsExampleIntegrationTest.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) rename spring-rest-simple/src/main/java/org/baeldung/config/{WebConfig.java => MvcConfig.java} (97%) diff --git a/spring-rest-simple/src/main/java/org/baeldung/config/WebConfig.java b/spring-rest-simple/src/main/java/org/baeldung/config/MvcConfig.java similarity index 97% rename from spring-rest-simple/src/main/java/org/baeldung/config/WebConfig.java rename to spring-rest-simple/src/main/java/org/baeldung/config/MvcConfig.java index 191b87a8f2..66bb3eabce 100644 --- a/spring-rest-simple/src/main/java/org/baeldung/config/WebConfig.java +++ b/spring-rest-simple/src/main/java/org/baeldung/config/MvcConfig.java @@ -25,9 +25,9 @@ import java.util.List; @Configuration @EnableWebMvc @ComponentScan({ "org.baeldung.web" }) -public class WebConfig implements WebMvcConfigurer { +public class MvcConfig implements WebMvcConfigurer { - public WebConfig() { + public MvcConfig() { super(); } diff --git a/spring-rest-simple/src/test/java/org/baeldung/web/controller/status/ExampleControllerIntegrationTest.java b/spring-rest-simple/src/test/java/org/baeldung/web/controller/status/ExampleControllerIntegrationTest.java index 7f78146b84..12fa00eed3 100644 --- a/spring-rest-simple/src/test/java/org/baeldung/web/controller/status/ExampleControllerIntegrationTest.java +++ b/spring-rest-simple/src/test/java/org/baeldung/web/controller/status/ExampleControllerIntegrationTest.java @@ -3,7 +3,7 @@ package org.baeldung.web.controller.status; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import org.baeldung.config.WebConfig; +import org.baeldung.config.MvcConfig; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -17,7 +17,7 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = WebConfig.class) +@ContextConfiguration(classes = MvcConfig.class) @WebAppConfiguration @AutoConfigureWebClient public class ExampleControllerIntegrationTest { diff --git a/spring-rest-simple/src/test/java/org/baeldung/web/test/BazzNewMappingsExampleIntegrationTest.java b/spring-rest-simple/src/test/java/org/baeldung/web/test/BazzNewMappingsExampleIntegrationTest.java index dfb3ff7a38..25429bcc7a 100644 --- a/spring-rest-simple/src/test/java/org/baeldung/web/test/BazzNewMappingsExampleIntegrationTest.java +++ b/spring-rest-simple/src/test/java/org/baeldung/web/test/BazzNewMappingsExampleIntegrationTest.java @@ -10,7 +10,7 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import org.baeldung.config.WebConfig; +import org.baeldung.config.MvcConfig; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -25,7 +25,7 @@ import org.springframework.web.context.WebApplicationContext; @RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(classes = WebConfig.class) +@ContextConfiguration(classes = MvcConfig.class) @WebAppConfiguration @AutoConfigureWebClient public class BazzNewMappingsExampleIntegrationTest { From badc9eb5626d00a0a2fb996f44780b2e3debd9ef Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 23 Jun 2019 20:55:07 +0530 Subject: [PATCH 04/12] [BAEL-14274] - Fixed article code for https://www.baeldung.com/spring-boot-actuators --- ...althIndicator.java => DownstreamServiceHealthIndicator.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/{DownstreamServiceReactiveHealthIndicator.java => DownstreamServiceHealthIndicator.java} (87%) diff --git a/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/DownstreamServiceReactiveHealthIndicator.java b/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/DownstreamServiceHealthIndicator.java similarity index 87% rename from spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/DownstreamServiceReactiveHealthIndicator.java rename to spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/DownstreamServiceHealthIndicator.java index 7360def71e..81e77d9c61 100644 --- a/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/DownstreamServiceReactiveHealthIndicator.java +++ b/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/DownstreamServiceHealthIndicator.java @@ -6,7 +6,7 @@ import org.springframework.stereotype.Component; import reactor.core.publisher.Mono; @Component -public class DownstreamServiceReactiveHealthIndicator implements ReactiveHealthIndicator { +public class DownstreamServiceHealthIndicator implements ReactiveHealthIndicator { @Override public Mono health() { From 74f46ef95a78c64c0ba53237f9048f68544d3d2e Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 23 Jun 2019 21:05:41 +0530 Subject: [PATCH 05/12] [BAEL-14274] - Fixed article code for https://www.baeldung.com/java-optional --- .../com/baeldung/java8/optional/OptionalUnitTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/optional/OptionalUnitTest.java b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/optional/OptionalUnitTest.java index bd7943c77b..bf594610bb 100644 --- a/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/optional/OptionalUnitTest.java +++ b/core-java-modules/core-java-8/src/test/java/com/baeldung/java8/optional/OptionalUnitTest.java @@ -259,4 +259,15 @@ public class OptionalUnitTest { LOG.debug("Getting default value..."); return "Default Value"; } + +// Uncomment code when code base is compatiable with Java 11 +// @Test +// public void givenAnEmptyOptional_thenIsEmptyBehavesAsExpected() { +// Optional opt = Optional.of("Baeldung"); +// assertFalse(opt.isEmpty()); +// +// opt = Optional.ofNullable(null); +// assertTrue(opt.isEmpty()); +// } + } \ No newline at end of file From b1ff8e6289108e6af544026e853fc0a0e7281877 Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 23 Jun 2019 23:06:32 +0530 Subject: [PATCH 06/12] [BAEL-14274] - Fixed article code for https://www.baeldung.com/spring-profiles --- .../org/baeldung/startup/ProfileManager.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 spring-all/src/main/java/org/baeldung/startup/ProfileManager.java diff --git a/spring-all/src/main/java/org/baeldung/startup/ProfileManager.java b/spring-all/src/main/java/org/baeldung/startup/ProfileManager.java new file mode 100644 index 0000000000..41db539265 --- /dev/null +++ b/spring-all/src/main/java/org/baeldung/startup/ProfileManager.java @@ -0,0 +1,18 @@ +package org.baeldung.startup; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +@Component +public class ProfileManager { + + @Autowired + private Environment environment; + + public void getActiveProfiles() { + for (final String profileName : environment.getActiveProfiles()) { + System.out.println("Currently active profile - " + profileName); + } + } +} From 69d6c80a49921bcee01a220e80a7ed32dc6c424a Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 23 Jun 2019 23:32:05 +0530 Subject: [PATCH 07/12] [BAEL-14274] - Fixed article code for https://www.baeldung.com/transaction-configuration-with-jpa-and-spring --- .../src/main/java/com/baeldung/config/PersistenceJPAConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java index 9fae34d99e..e202e45b32 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java @@ -39,7 +39,7 @@ public class PersistenceJPAConfig { // beans @Bean - public LocalContainerEntityManagerFactoryBean entityManagerFactory() { + public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() { final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); em.setDataSource(dataSource()); em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" }); From 0dc22fbc7af524f051316a158d345332bfc35492 Mon Sep 17 00:00:00 2001 From: amit2103 Date: Mon, 24 Jun 2019 00:16:24 +0530 Subject: [PATCH 08/12] [BAEL-14274] - Fixed article code for https://www.baeldung.com/spring-jdbc-jdbctemplate --- .../java/com/baeldung/jdbc/EmployeeDAO.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/EmployeeDAO.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/EmployeeDAO.java index 9ba4ebdb6d..eef085f386 100644 --- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/EmployeeDAO.java +++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/EmployeeDAO.java @@ -16,6 +16,7 @@ import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.jdbc.core.namedparam.SqlParameterSource; import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils; +import org.springframework.jdbc.core.simple.SimpleJdbcCall; import org.springframework.jdbc.core.simple.SimpleJdbcInsert; import org.springframework.stereotype.Repository; @@ -27,6 +28,8 @@ public class EmployeeDAO { private NamedParameterJdbcTemplate namedParameterJdbcTemplate; private SimpleJdbcInsert simpleJdbcInsert; + + private SimpleJdbcCall simpleJdbcCall; @Autowired public void setDataSource(final DataSource dataSource) { @@ -36,7 +39,9 @@ public class EmployeeDAO { namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); simpleJdbcInsert = new SimpleJdbcInsert(dataSource).withTableName("EMPLOYEE"); - + + // Commented as the database is H2, change the database and create procedure READ_EMPLOYEE before calling getEmployeeUsingSimpleJdbcCall + //simpleJdbcCall = new SimpleJdbcCall(dataSource).withProcedureName("READ_EMPLOYEE"); } public int getCountOfEmployees() { @@ -110,4 +115,15 @@ public class EmployeeDAO { final int[] updateCounts = namedParameterJdbcTemplate.batchUpdate("INSERT INTO EMPLOYEE VALUES (:id, :firstName, :lastName, :address)", batch); return updateCounts; } + + public Employee getEmployeeUsingSimpleJdbcCall(int id) { + SqlParameterSource in = new MapSqlParameterSource().addValue("in_id", id); + Map out = simpleJdbcCall.execute(in); + + Employee emp = new Employee(); + emp.setFirstName((String) out.get("FIRST_NAME")); + emp.setLastName((String) out.get("LAST_NAME")); + + return emp; + } } From 0423f598485e8353c0a3014bb19585549207ec49 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 17 Jul 2019 11:08:25 +0300 Subject: [PATCH 09/12] Update README.md --- spring-core/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-core/README.md b/spring-core/README.md index 74f86ef49e..18d14b7ecf 100644 --- a/spring-core/README.md +++ b/spring-core/README.md @@ -8,7 +8,6 @@ - [Spring YAML Configuration](http://www.baeldung.com/spring-yaml) - [Introduction to Spring’s StreamUtils](http://www.baeldung.com/spring-stream-utils) - [Using Spring @Value with Defaults](http://www.baeldung.com/spring-value-defaults) -- [Groovy Bean Definitions](http://www.baeldung.com/spring-groovy-beans) - [XML-Based Injection in Spring](http://www.baeldung.com/spring-xml-injection) - [A Quick Guide to the Spring @Lazy Annotation](http://www.baeldung.com/spring-lazy-annotation) - [Injecting Prototype Beans into a Singleton Instance in Spring](http://www.baeldung.com/spring-inject-prototype-bean-into-singleton) From 8449e11424bcd07b08333411f2bf5fca11c54b56 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 17 Jul 2019 11:16:57 +0300 Subject: [PATCH 10/12] Update README.md --- spring-security-angular/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/spring-security-angular/README.md b/spring-security-angular/README.md index 49cd8dd62d..80312c4bab 100644 --- a/spring-security-angular/README.md +++ b/spring-security-angular/README.md @@ -1,3 +1,2 @@ ### Relevant Articles: - [Spring Security Login Page with Angular](https://www.baeldung.com/spring-security-login-angular) -- [Fixing 401s with CORS Preflights and Spring Security](https://www.baeldung.com/spring-security-cors-preflight) From 980b18f438cf749212f0948f6e3e070d06ca4176 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 17 Jul 2019 11:30:29 +0300 Subject: [PATCH 11/12] Create README.md --- testing-modules/junit5-migration/README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 testing-modules/junit5-migration/README.md diff --git a/testing-modules/junit5-migration/README.md b/testing-modules/junit5-migration/README.md new file mode 100644 index 0000000000..b97ff8255c --- /dev/null +++ b/testing-modules/junit5-migration/README.md @@ -0,0 +1,2 @@ + +This is the code for the Junit 4 - Junit 5 Migration E-book. From 6d5e2d15f7a43928228a92b9bda694c2846c7b03 Mon Sep 17 00:00:00 2001 From: Loredana Crusoveanu Date: Wed, 17 Jul 2019 11:31:26 +0300 Subject: [PATCH 12/12] Update README.md --- testing-modules/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/testing-modules/README.md b/testing-modules/README.md index d69f07215e..b269f547ec 100644 --- a/testing-modules/README.md +++ b/testing-modules/README.md @@ -13,5 +13,3 @@ - [Headers, Cookies and Parameters with REST-assured](http://www.baeldung.com/rest-assured-header-cookie-parameter) - [JSON Schema Validation with REST-assured](http://www.baeldung.com/rest-assured-json-schema) - [Testing Callbacks with Mockito](http://www.baeldung.com/mockito-callbacks) -- [Running JUnit Tests in Parallel with Maven](https://www.baeldung.com/maven-junit-parallel-tests) -- [Gatling vs JMeter vs The Grinder: Comparing Load Test Tools](https://www.baeldung.com/gatling-jmeter-grinder-comparison)