Validate our own tests work with JUnit5 and the vintage engine
Closes gh-14737 Co-authored-by: Stephane Nicoll <snicoll@pivotal.io>
This commit is contained in:
committed by
Stephane Nicoll
parent
d9f339a1b6
commit
1db1c8b03c
@@ -18,8 +18,7 @@ package sample.actuator;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -28,7 +27,6 @@ import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -37,16 +35,15 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
@ActiveProfiles("endpoints")
|
||||
public class EndpointsPropertiesSampleActuatorApplicationTests {
|
||||
class EndpointsPropertiesSampleActuatorApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
@Test
|
||||
public void testCustomErrorPath() {
|
||||
void testCustomErrorPath() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword()).getForEntity("/oops", Map.class);
|
||||
@@ -58,7 +55,7 @@ public class EndpointsPropertiesSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCustomContextPath() {
|
||||
void testCustomContextPath() {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/admin/health", String.class);
|
||||
|
||||
@@ -18,8 +18,7 @@ package sample.actuator;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -28,7 +27,6 @@ import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -37,11 +35,10 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
|
||||
properties = { "management.server.port=0", "management.server.address=127.0.0.1",
|
||||
"management.server.servlet.context-path:/admin" })
|
||||
public class ManagementAddressActuatorApplicationTests {
|
||||
class ManagementAddressActuatorApplicationTests {
|
||||
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
@@ -50,7 +47,7 @@ public class ManagementAddressActuatorApplicationTests {
|
||||
private int managementPort;
|
||||
|
||||
@Test
|
||||
public void testHome() {
|
||||
void testHome() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = new TestRestTemplate()
|
||||
.getForEntity("http://localhost:" + this.port, Map.class);
|
||||
@@ -58,7 +55,7 @@ public class ManagementAddressActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHealth() {
|
||||
void testHealth() {
|
||||
ResponseEntity<String> entity = new TestRestTemplate()
|
||||
.withBasicAuth("user", getPassword()).getForEntity("http://localhost:"
|
||||
+ this.managementPort + "/admin/actuator/health", String.class);
|
||||
|
||||
@@ -18,8 +18,7 @@ package sample.actuator;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -27,7 +26,6 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -36,16 +34,15 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
|
||||
properties = { "management.endpoints.web.base-path=/admin" })
|
||||
public class ManagementPathSampleActuatorApplicationTests {
|
||||
class ManagementPathSampleActuatorApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
@Test
|
||||
public void testHealth() {
|
||||
void testHealth() {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/admin/health", String.class);
|
||||
@@ -54,7 +51,7 @@ public class ManagementPathSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHomeIsSecure() {
|
||||
void testHomeIsSecure() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
|
||||
@@ -18,8 +18,7 @@ package sample.actuator;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort;
|
||||
@@ -30,7 +29,6 @@ import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -39,12 +37,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
|
||||
properties = { "management.server.port=0",
|
||||
"management.endpoints.web.base-path=/admin",
|
||||
"management.endpoint.health.show-details=never" })
|
||||
public class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||
class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
@@ -56,7 +53,7 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||
private Environment environment;
|
||||
|
||||
@Test
|
||||
public void testHome() {
|
||||
void testHome() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword())
|
||||
.getForEntity("http://localhost:" + this.port, Map.class);
|
||||
@@ -67,7 +64,7 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetrics() {
|
||||
void testMetrics() {
|
||||
testHome(); // makes sure some requests have been made
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
|
||||
@@ -76,7 +73,7 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHealth() {
|
||||
void testHealth() {
|
||||
ResponseEntity<String> entity = new TestRestTemplate()
|
||||
.withBasicAuth("user", getPassword())
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/admin/health",
|
||||
@@ -86,7 +83,7 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnvNotFound() {
|
||||
void testEnvNotFound() {
|
||||
String unknownProperty = "test-does-not-exist";
|
||||
assertThat(this.environment.containsProperty(unknownProperty)).isFalse();
|
||||
ResponseEntity<String> entity = new TestRestTemplate()
|
||||
@@ -97,7 +94,7 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMissing() {
|
||||
void testMissing() {
|
||||
ResponseEntity<String> entity = new TestRestTemplate("user", getPassword())
|
||||
.getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/admin/missing",
|
||||
@@ -107,7 +104,7 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorPage() {
|
||||
void testErrorPage() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword())
|
||||
.getForEntity("http://localhost:" + this.port + "/error", Map.class);
|
||||
@@ -118,7 +115,7 @@ public class ManagementPortAndPathSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManagementErrorPage() {
|
||||
void testManagementErrorPage() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword())
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/error",
|
||||
|
||||
@@ -18,8 +18,7 @@ package sample.actuator;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -28,7 +27,6 @@ import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -37,10 +35,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
|
||||
"management.server.port=0", "management.endpoint.health.show-details=always" })
|
||||
public class ManagementPortSampleActuatorApplicationTests {
|
||||
class ManagementPortSampleActuatorApplicationTests {
|
||||
|
||||
@LocalServerPort
|
||||
private int port;
|
||||
@@ -49,7 +46,7 @@ public class ManagementPortSampleActuatorApplicationTests {
|
||||
private int managementPort;
|
||||
|
||||
@Test
|
||||
public void testHome() {
|
||||
void testHome() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword())
|
||||
.getForEntity("http://localhost:" + this.port, Map.class);
|
||||
@@ -60,7 +57,7 @@ public class ManagementPortSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetrics() {
|
||||
void testMetrics() {
|
||||
testHome(); // makes sure some requests have been made
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = new TestRestTemplate().getForEntity(
|
||||
@@ -70,7 +67,7 @@ public class ManagementPortSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHealth() {
|
||||
void testHealth() {
|
||||
ResponseEntity<String> entity = new TestRestTemplate()
|
||||
.withBasicAuth("user", getPassword()).getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/actuator/health",
|
||||
@@ -82,7 +79,7 @@ public class ManagementPortSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorPage() {
|
||||
void testErrorPage() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword())
|
||||
.getForEntity("http://localhost:" + this.managementPort + "/error",
|
||||
|
||||
@@ -16,15 +16,13 @@
|
||||
|
||||
package sample.actuator;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -34,16 +32,15 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Madhura Bhave
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {
|
||||
"management.server.port=0", "spring.main.lazy-initialization=true" })
|
||||
public class ManagementPortWithLazyInitializationTests {
|
||||
class ManagementPortWithLazyInitializationTests {
|
||||
|
||||
@LocalManagementPort
|
||||
private int managementPort;
|
||||
|
||||
@Test
|
||||
public void testHealth() {
|
||||
void testHealth() {
|
||||
ResponseEntity<String> entity = new TestRestTemplate()
|
||||
.withBasicAuth("user", "password").getForEntity(
|
||||
"http://localhost:" + this.managementPort + "/actuator/health",
|
||||
|
||||
@@ -18,8 +18,7 @@ package sample.actuator;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -27,7 +26,6 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -36,16 +34,15 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
|
||||
properties = { "management.server.port=-1" })
|
||||
public class NoManagementSampleActuatorApplicationTests {
|
||||
class NoManagementSampleActuatorApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
@Test
|
||||
public void testHome() {
|
||||
void testHome() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword()).getForEntity("/", Map.class);
|
||||
@@ -56,7 +53,7 @@ public class NoManagementSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetricsNotAvailable() {
|
||||
void testMetricsNotAvailable() {
|
||||
testHome(); // makes sure some requests have been made
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
|
||||
@@ -20,8 +20,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
|
||||
@@ -35,7 +34,6 @@ import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -45,9 +43,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Dave Syer
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
public class SampleActuatorApplicationTests {
|
||||
class SampleActuatorApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
@@ -56,7 +53,7 @@ public class SampleActuatorApplicationTests {
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Test
|
||||
public void testHomeIsSecure() {
|
||||
void testHomeIsSecure() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/", Map.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
@@ -67,7 +64,7 @@ public class SampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMetricsIsSecure() {
|
||||
void testMetricsIsSecure() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/actuator/metrics",
|
||||
Map.class);
|
||||
@@ -81,7 +78,7 @@ public class SampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHome() {
|
||||
void testHome() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword()).getForEntity("/", Map.class);
|
||||
@@ -93,7 +90,7 @@ public class SampleActuatorApplicationTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testMetrics() {
|
||||
void testMetrics() {
|
||||
testHome(); // makes sure some requests have been made
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
@@ -107,7 +104,7 @@ public class SampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnv() {
|
||||
void testEnv() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
@@ -119,7 +116,7 @@ public class SampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthInsecureByDefault() {
|
||||
void healthInsecureByDefault() {
|
||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/actuator/health",
|
||||
String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@@ -128,7 +125,7 @@ public class SampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void infoInsecureByDefault() {
|
||||
void infoInsecureByDefault() {
|
||||
ResponseEntity<String> entity = this.restTemplate.getForEntity("/actuator/info",
|
||||
String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
@@ -142,7 +139,7 @@ public class SampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorPage() {
|
||||
void testErrorPage() {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword()).getForEntity("/foo", String.class);
|
||||
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
@@ -151,7 +148,7 @@ public class SampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHtmlErrorPage() {
|
||||
void testHtmlErrorPage() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML));
|
||||
HttpEntity<?> request = new HttpEntity<Void>(headers);
|
||||
@@ -165,7 +162,7 @@ public class SampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testErrorPageDirectAccess() {
|
||||
void testErrorPageDirectAccess() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword()).getForEntity("/error", Map.class);
|
||||
@@ -189,7 +186,7 @@ public class SampleActuatorApplicationTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testConfigProps() {
|
||||
void testConfigProps() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
|
||||
@@ -18,8 +18,7 @@ package sample.actuator;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -27,7 +26,6 @@ import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -36,16 +34,15 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
|
||||
properties = { "spring.mvc.servlet.path=/spring" })
|
||||
public class ServletPathSampleActuatorApplicationTests {
|
||||
class ServletPathSampleActuatorApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
@Test
|
||||
public void testErrorPath() {
|
||||
void testErrorPath() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
@@ -58,7 +55,7 @@ public class ServletPathSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHealth() {
|
||||
void testHealth() {
|
||||
ResponseEntity<String> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword())
|
||||
.getForEntity("/spring/actuator/health", String.class);
|
||||
@@ -67,7 +64,7 @@ public class ServletPathSampleActuatorApplicationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHomeIsSecure() {
|
||||
void testHomeIsSecure() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate.getForEntity("/spring/",
|
||||
Map.class);
|
||||
|
||||
@@ -18,8 +18,7 @@ package sample.actuator;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -31,7 +30,6 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -40,18 +38,17 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(
|
||||
classes = { ShutdownSampleActuatorApplicationTests.SecurityConfiguration.class,
|
||||
SampleActuatorApplication.class },
|
||||
webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
public class ShutdownSampleActuatorApplicationTests {
|
||||
class ShutdownSampleActuatorApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate restTemplate;
|
||||
|
||||
@Test
|
||||
public void testHome() {
|
||||
void testHome() {
|
||||
@SuppressWarnings("rawtypes")
|
||||
ResponseEntity<Map> entity = this.restTemplate
|
||||
.withBasicAuth("user", getPassword()).getForEntity("/", Map.class);
|
||||
|
||||
Reference in New Issue
Block a user