fix conflict
This commit is contained in:
commit
3aeb26a67f
@ -259,4 +259,15 @@ public class OptionalUnitTest {
|
|||||||
LOG.debug("Getting default value...");
|
LOG.debug("Getting default value...");
|
||||||
return "Default Value";
|
return "Default Value";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Uncomment code when code base is compatiable with Java 11
|
||||||
|
// @Test
|
||||||
|
// public void givenAnEmptyOptional_thenIsEmptyBehavesAsExpected() {
|
||||||
|
// Optional<String> opt = Optional.of("Baeldung");
|
||||||
|
// assertFalse(opt.isEmpty());
|
||||||
|
//
|
||||||
|
// opt = Optional.ofNullable(null);
|
||||||
|
// assertTrue(opt.isEmpty());
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
@ -39,7 +39,7 @@ public class PersistenceJPAConfig {
|
|||||||
// beans
|
// beans
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
|
||||||
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
||||||
em.setDataSource(dataSource());
|
em.setDataSource(dataSource());
|
||||||
em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" });
|
em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" });
|
||||||
|
@ -16,6 +16,7 @@ import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
|
|||||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||||
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
|
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
|
||||||
|
import org.springframework.jdbc.core.simple.SimpleJdbcCall;
|
||||||
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
|
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@ -27,6 +28,8 @@ public class EmployeeDAO {
|
|||||||
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
|
||||||
|
|
||||||
private SimpleJdbcInsert simpleJdbcInsert;
|
private SimpleJdbcInsert simpleJdbcInsert;
|
||||||
|
|
||||||
|
private SimpleJdbcCall simpleJdbcCall;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public void setDataSource(final DataSource dataSource) {
|
public void setDataSource(final DataSource dataSource) {
|
||||||
@ -36,7 +39,9 @@ public class EmployeeDAO {
|
|||||||
|
|
||||||
namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
|
namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
|
||||||
simpleJdbcInsert = new SimpleJdbcInsert(dataSource).withTableName("EMPLOYEE");
|
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() {
|
public int getCountOfEmployees() {
|
||||||
@ -110,4 +115,15 @@ public class EmployeeDAO {
|
|||||||
final int[] updateCounts = namedParameterJdbcTemplate.batchUpdate("INSERT INTO EMPLOYEE VALUES (:id, :firstName, :lastName, :address)", batch);
|
final int[] updateCounts = namedParameterJdbcTemplate.batchUpdate("INSERT INTO EMPLOYEE VALUES (:id, :firstName, :lastName, :address)", batch);
|
||||||
return updateCounts;
|
return updateCounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Employee getEmployeeUsingSimpleJdbcCall(int id) {
|
||||||
|
SqlParameterSource in = new MapSqlParameterSource().addValue("in_id", id);
|
||||||
|
Map<String, Object> out = simpleJdbcCall.execute(in);
|
||||||
|
|
||||||
|
Employee emp = new Employee();
|
||||||
|
emp.setFirstName((String) out.get("FIRST_NAME"));
|
||||||
|
emp.setLastName((String) out.get("LAST_NAME"));
|
||||||
|
|
||||||
|
return emp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DownstreamServiceReactiveHealthIndicator implements ReactiveHealthIndicator {
|
public class DownstreamServiceHealthIndicator implements ReactiveHealthIndicator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mono<Health> health() {
|
public Mono<Health> health() {
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,6 @@
|
|||||||
- [Spring YAML Configuration](http://www.baeldung.com/spring-yaml)
|
- [Spring YAML Configuration](http://www.baeldung.com/spring-yaml)
|
||||||
- [Introduction to Spring’s StreamUtils](http://www.baeldung.com/spring-stream-utils)
|
- [Introduction to Spring’s StreamUtils](http://www.baeldung.com/spring-stream-utils)
|
||||||
- [Using Spring @Value with Defaults](http://www.baeldung.com/spring-value-defaults)
|
- [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)
|
- [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)
|
- [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)
|
- [Injecting Prototype Beans into a Singleton Instance in Spring](http://www.baeldung.com/spring-inject-prototype-bean-into-singleton)
|
||||||
|
@ -27,9 +27,9 @@ import java.util.List;
|
|||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
@ComponentScan({ "com.baeldung.web" })
|
@ComponentScan({ "com.baeldung.web" })
|
||||||
public class WebConfig implements WebMvcConfigurer {
|
public class MvcConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
public WebConfig() {
|
public MvcConfig() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
@ -2,7 +2,6 @@ package com.baeldung.web.controller.status;
|
|||||||
|
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@ -15,10 +14,10 @@ import org.springframework.test.web.servlet.MockMvc;
|
|||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
import com.baeldung.config.WebConfig;
|
import com.baeldung.config.MvcConfig;
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = WebConfig.class)
|
@ContextConfiguration(classes = MvcConfig.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
@AutoConfigureWebClient
|
@AutoConfigureWebClient
|
||||||
public class ExampleControllerIntegrationTest {
|
public class ExampleControllerIntegrationTest {
|
||||||
|
@ -9,7 +9,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
|
|||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@ -22,11 +21,11 @@ import org.springframework.test.web.servlet.MockMvc;
|
|||||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
import com.baeldung.config.WebConfig;
|
import com.baeldung.config.MvcConfig;
|
||||||
|
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(classes = WebConfig.class)
|
@ContextConfiguration(classes = MvcConfig.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
@AutoConfigureWebClient
|
@AutoConfigureWebClient
|
||||||
public class BazzNewMappingsExampleIntegrationTest {
|
public class BazzNewMappingsExampleIntegrationTest {
|
||||||
|
@ -188,7 +188,7 @@ public class RestTemplateBasicLiveTest {
|
|||||||
final String resourceUrl = fooResourceUrl + '/' + createResponse.getBody()
|
final String resourceUrl = fooResourceUrl + '/' + createResponse.getBody()
|
||||||
.getId();
|
.getId();
|
||||||
final HttpEntity<Foo> requestUpdate = new HttpEntity<>(updatedResource, headers);
|
final HttpEntity<Foo> requestUpdate = new HttpEntity<>(updatedResource, headers);
|
||||||
final ClientHttpRequestFactory requestFactory = getSimpleClientHttpRequestFactory();
|
final ClientHttpRequestFactory requestFactory = getClientHttpRequestFactory();
|
||||||
final RestTemplate template = new RestTemplate(requestFactory);
|
final RestTemplate template = new RestTemplate(requestFactory);
|
||||||
template.setMessageConverters(Arrays.asList(new MappingJackson2HttpMessageConverter()));
|
template.setMessageConverters(Arrays.asList(new MappingJackson2HttpMessageConverter()));
|
||||||
template.patchForObject(resourceUrl, requestUpdate, Void.class);
|
template.patchForObject(resourceUrl, requestUpdate, Void.class);
|
||||||
@ -262,7 +262,7 @@ public class RestTemplateBasicLiveTest {
|
|||||||
|
|
||||||
// Simply setting restTemplate timeout using ClientHttpRequestFactory
|
// Simply setting restTemplate timeout using ClientHttpRequestFactory
|
||||||
|
|
||||||
ClientHttpRequestFactory getSimpleClientHttpRequestFactory() {
|
ClientHttpRequestFactory getClientHttpRequestFactory() {
|
||||||
final int timeout = 5;
|
final int timeout = 5;
|
||||||
final HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory();
|
final HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory();
|
||||||
clientHttpRequestFactory.setConnectTimeout(timeout * 1000);
|
clientHttpRequestFactory.setConnectTimeout(timeout * 1000);
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
### Relevant Articles:
|
### Relevant Articles:
|
||||||
- [Spring Security Login Page with Angular](https://www.baeldung.com/spring-security-login-angular)
|
- [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)
|
|
||||||
|
@ -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";
|
||||||
|
}
|
||||||
|
}
|
@ -13,5 +13,3 @@
|
|||||||
- [Headers, Cookies and Parameters with REST-assured](http://www.baeldung.com/rest-assured-header-cookie-parameter)
|
- [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)
|
- [JSON Schema Validation with REST-assured](http://www.baeldung.com/rest-assured-json-schema)
|
||||||
- [Testing Callbacks with Mockito](http://www.baeldung.com/mockito-callbacks)
|
- [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)
|
|
||||||
|
2
testing-modules/junit5-migration/README.md
Normal file
2
testing-modules/junit5-migration/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
This is the code for the Junit 4 - Junit 5 Migration E-book.
|
Loading…
x
Reference in New Issue
Block a user