fix conflict
This commit is contained in:
commit
3aeb26a67f
|
@ -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<String> opt = Optional.of("Baeldung");
|
||||
// assertFalse(opt.isEmpty());
|
||||
//
|
||||
// opt = Optional.ofNullable(null);
|
||||
// assertTrue(opt.isEmpty());
|
||||
// }
|
||||
|
||||
}
|
|
@ -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" });
|
||||
|
|
|
@ -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<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;
|
||||
|
||||
@Component
|
||||
public class DownstreamServiceReactiveHealthIndicator implements ReactiveHealthIndicator {
|
||||
public class DownstreamServiceHealthIndicator implements ReactiveHealthIndicator {
|
||||
|
||||
@Override
|
||||
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)
|
||||
- [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)
|
||||
|
|
|
@ -27,9 +27,9 @@ import java.util.List;
|
|||
@Configuration
|
||||
@EnableWebMvc
|
||||
@ComponentScan({ "com.baeldung.web" })
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
public class MvcConfig implements WebMvcConfigurer {
|
||||
|
||||
public WebConfig() {
|
||||
public MvcConfig() {
|
||||
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.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
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.web.context.WebApplicationContext;
|
||||
|
||||
import com.baeldung.config.WebConfig;
|
||||
import com.baeldung.config.MvcConfig;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = WebConfig.class)
|
||||
@ContextConfiguration(classes = MvcConfig.class)
|
||||
@WebAppConfiguration
|
||||
@AutoConfigureWebClient
|
||||
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.result.MockMvcResultMatchers.jsonPath;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
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.web.context.WebApplicationContext;
|
||||
|
||||
import com.baeldung.config.WebConfig;
|
||||
import com.baeldung.config.MvcConfig;
|
||||
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = WebConfig.class)
|
||||
@ContextConfiguration(classes = MvcConfig.class)
|
||||
@WebAppConfiguration
|
||||
@AutoConfigureWebClient
|
||||
public class BazzNewMappingsExampleIntegrationTest {
|
||||
|
|
|
@ -188,7 +188,7 @@ public class RestTemplateBasicLiveTest {
|
|||
final String resourceUrl = fooResourceUrl + '/' + createResponse.getBody()
|
||||
.getId();
|
||||
final HttpEntity<Foo> 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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
- [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)
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
This is the code for the Junit 4 - Junit 5 Migration E-book.
|
Loading…
Reference in New Issue