Integrate @ConfigurationProperties @Beans with DataSource configuration
We now have a much simpler DataSourceAutoConfiguration that binds to whatever DataSource concrete type it finds at runtime. To be able to quickly switch between Hikari and the other types of DataSource there's a minute shim for translating the common properties (username, password, url, driverClassName), but actually only url is different. The shim and also DataSource initialization is supported through DataSourceProperties, but the other native properties get bound directly through the concrete runtime type of the DataSource. The /configprops endpoint works (and is exposed in the actuator sample). Fixes gh-840, fixes gh-477, see also gh-808.
This commit is contained in:
@@ -32,6 +32,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Integration tests for endpoints configuration.
|
||||
@@ -66,7 +67,6 @@ public class EndpointsPropertiesSampleActuatorApplicationTests {
|
||||
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
|
||||
"http://localhost:" + this.port + "/admin/health", String.class);
|
||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||
String body = entity.getBody();
|
||||
assertEquals("{\"status\":\"ok\"}", body);
|
||||
assertTrue("Wrong body: " + entity.getBody(), entity.getBody().contains("\"status\":\"ok\""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Integration tests for separate management and main service ports.
|
||||
@@ -71,7 +72,7 @@ public class ManagementAddressActuatorApplicationTests {
|
||||
"http://localhost:" + this.managementPort + "/admin/health",
|
||||
String.class);
|
||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||
assertEquals("{\"status\":\"ok\"}", entity.getBody());
|
||||
assertTrue("Wrong body: " + entity.getBody(), entity.getBody().contains("\"status\":\"ok\""));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Integration tests for separate management and main service ports.
|
||||
@@ -80,7 +81,7 @@ public class ManagementPortSampleActuatorApplicationTests {
|
||||
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/health", String.class);
|
||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||
assertEquals("{\"status\":\"ok\"}", entity.getBody());
|
||||
assertTrue("Wrong body: " + entity.getBody(), entity.getBody().contains("\"status\":\"ok\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -130,7 +130,7 @@ public class SampleActuatorApplicationTests {
|
||||
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(
|
||||
"http://localhost:" + this.port + "/health", String.class);
|
||||
assertEquals(HttpStatus.OK, entity.getStatusCode());
|
||||
assertEquals("{\"status\":\"ok\"}", entity.getBody());
|
||||
assertTrue("Wrong body: " + entity.getBody(), entity.getBody().contains("\"status\":\"ok\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user