Polish
This commit is contained in:
parent
97c91eee94
commit
23218add90
|
|
@ -40,14 +40,14 @@ public class RabbitHealthIndicatorAutoConfigurationTests {
|
|||
HealthIndicatorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void runShouldCreateIndicator() throws Exception {
|
||||
public void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.hasSingleBean(RabbitHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenDisabledShouldNotCreateIndicator() throws Exception {
|
||||
public void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.rabbit.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(RabbitHealthIndicator.class)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class AuditAutoConfigurationTests {
|
|||
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
||||
|
||||
@Test
|
||||
public void defaultConfiguration() throws Exception {
|
||||
public void defaultConfiguration() {
|
||||
registerAndRefresh(AuditAutoConfiguration.class);
|
||||
assertThat(this.context.getBean(AuditEventRepository.class)).isNotNull();
|
||||
assertThat(this.context.getBean(AuthenticationAuditListener.class)).isNotNull();
|
||||
|
|
@ -54,7 +54,7 @@ public class AuditAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void ownAuditEventRepository() throws Exception {
|
||||
public void ownAuditEventRepository() {
|
||||
registerAndRefresh(CustomAuditEventRepositoryConfiguration.class,
|
||||
AuditAutoConfiguration.class);
|
||||
assertThat(this.context.getBean(AuditEventRepository.class))
|
||||
|
|
@ -62,7 +62,7 @@ public class AuditAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void ownAuthenticationAuditListener() throws Exception {
|
||||
public void ownAuthenticationAuditListener() {
|
||||
registerAndRefresh(CustomAuthenticationAuditListenerConfiguration.class,
|
||||
AuditAutoConfiguration.class);
|
||||
assertThat(this.context.getBean(AbstractAuthenticationAuditListener.class))
|
||||
|
|
@ -70,7 +70,7 @@ public class AuditAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void ownAuthorizationAuditListener() throws Exception {
|
||||
public void ownAuthorizationAuditListener() {
|
||||
registerAndRefresh(CustomAuthorizationAuditListenerConfiguration.class,
|
||||
AuditAutoConfiguration.class);
|
||||
assertThat(this.context.getBean(AbstractAuthorizationAuditListener.class))
|
||||
|
|
@ -78,7 +78,7 @@ public class AuditAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void ownAuditListener() throws Exception {
|
||||
public void ownAuditListener() {
|
||||
registerAndRefresh(CustomAuditListenerConfiguration.class,
|
||||
AuditAutoConfiguration.class);
|
||||
assertThat(this.context.getBean(AbstractAuditListener.class))
|
||||
|
|
|
|||
|
|
@ -58,8 +58,7 @@ public class AuditEventsEndpointAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointOrExtensionBean()
|
||||
throws Exception {
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointOrExtensionBean() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoint.auditevents.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@ public class BeansEndpointAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean()
|
||||
throws Exception {
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.withPropertyValues("management.endpoint.beans.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(BeansEndpoint.class));
|
||||
|
|
|
|||
|
|
@ -44,14 +44,14 @@ public class CassandraHealthIndicatorAutoConfigurationTests {
|
|||
HealthIndicatorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void runShouldCreateIndicator() throws Exception {
|
||||
public void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.hasSingleBean(CassandraHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenDisabledShouldNotCreateIndicator() throws Exception {
|
||||
public void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.cassandra.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(CassandraHealthIndicator.class)
|
||||
|
|
|
|||
|
|
@ -28,25 +28,25 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class AccessLevelTests {
|
||||
|
||||
@Test
|
||||
public void accessToHealthEndpointShouldNotBeRestricted() throws Exception {
|
||||
public void accessToHealthEndpointShouldNotBeRestricted() {
|
||||
assertThat(AccessLevel.RESTRICTED.isAccessAllowed("health")).isTrue();
|
||||
assertThat(AccessLevel.FULL.isAccessAllowed("health")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void accessToInfoEndpointShouldNotBeRestricted() throws Exception {
|
||||
public void accessToInfoEndpointShouldNotBeRestricted() {
|
||||
assertThat(AccessLevel.RESTRICTED.isAccessAllowed("info")).isTrue();
|
||||
assertThat(AccessLevel.FULL.isAccessAllowed("info")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void accessToDiscoveryEndpointShouldNotBeRestricted() throws Exception {
|
||||
public void accessToDiscoveryEndpointShouldNotBeRestricted() {
|
||||
assertThat(AccessLevel.RESTRICTED.isAccessAllowed("")).isTrue();
|
||||
assertThat(AccessLevel.FULL.isAccessAllowed("")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void accessToAnyOtherEndpointShouldBeRestricted() throws Exception {
|
||||
public void accessToAnyOtherEndpointShouldBeRestricted() {
|
||||
assertThat(AccessLevel.RESTRICTED.isAccessAllowed("env")).isFalse();
|
||||
assertThat(AccessLevel.FULL.isAccessAllowed("")).isTrue();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,56 +31,55 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class CloudFoundryAuthorizationExceptionTests {
|
||||
|
||||
@Test
|
||||
public void statusCodeForInvalidTokenReasonShouldBe401() throws Exception {
|
||||
public void statusCodeForInvalidTokenReasonShouldBe401() {
|
||||
assertThat(createException(Reason.INVALID_TOKEN).getStatusCode())
|
||||
.isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statusCodeForInvalidIssuerReasonShouldBe401() throws Exception {
|
||||
public void statusCodeForInvalidIssuerReasonShouldBe401() {
|
||||
assertThat(createException(Reason.INVALID_ISSUER).getStatusCode())
|
||||
.isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statusCodeForInvalidAudienceReasonShouldBe401() throws Exception {
|
||||
public void statusCodeForInvalidAudienceReasonShouldBe401() {
|
||||
assertThat(createException(Reason.INVALID_AUDIENCE).getStatusCode())
|
||||
.isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statusCodeForInvalidSignatureReasonShouldBe401() throws Exception {
|
||||
public void statusCodeForInvalidSignatureReasonShouldBe401() {
|
||||
assertThat(createException(Reason.INVALID_SIGNATURE).getStatusCode())
|
||||
.isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statusCodeForMissingAuthorizationReasonShouldBe401() throws Exception {
|
||||
public void statusCodeForMissingAuthorizationReasonShouldBe401() {
|
||||
assertThat(createException(Reason.MISSING_AUTHORIZATION).getStatusCode())
|
||||
.isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statusCodeForUnsupportedSignatureAlgorithmReasonShouldBe401()
|
||||
throws Exception {
|
||||
public void statusCodeForUnsupportedSignatureAlgorithmReasonShouldBe401() {
|
||||
assertThat(createException(Reason.UNSUPPORTED_TOKEN_SIGNING_ALGORITHM)
|
||||
.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statusCodeForTokenExpiredReasonShouldBe401() throws Exception {
|
||||
public void statusCodeForTokenExpiredReasonShouldBe401() {
|
||||
assertThat(createException(Reason.TOKEN_EXPIRED).getStatusCode())
|
||||
.isEqualTo(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statusCodeForAccessDeniedReasonShouldBe403() throws Exception {
|
||||
public void statusCodeForAccessDeniedReasonShouldBe403() {
|
||||
assertThat(createException(Reason.ACCESS_DENIED).getStatusCode())
|
||||
.isEqualTo(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statusCodeForServiceUnavailableReasonShouldBe503() throws Exception {
|
||||
public void statusCodeForServiceUnavailableReasonShouldBe503() {
|
||||
assertThat(createException(Reason.SERVICE_UNAVAILABLE).getStatusCode())
|
||||
.isEqualTo(HttpStatus.SERVICE_UNAVAILABLE);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,19 +43,19 @@ public class CloudFoundryEndpointFilterTests {
|
|||
private CloudFoundryEndpointFilter filter;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
this.filter = new CloudFoundryEndpointFilter();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchIfDiscovererCloudFoundryShouldReturnFalse() throws Exception {
|
||||
public void matchIfDiscovererCloudFoundryShouldReturnFalse() {
|
||||
CloudFoundryWebAnnotationEndpointDiscoverer discoverer = Mockito
|
||||
.mock(CloudFoundryWebAnnotationEndpointDiscoverer.class);
|
||||
assertThat(this.filter.match(null, discoverer)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchIfDiscovererNotCloudFoundryShouldReturnFalse() throws Exception {
|
||||
public void matchIfDiscovererNotCloudFoundryShouldReturnFalse() {
|
||||
WebAnnotationEndpointDiscoverer discoverer = Mockito
|
||||
.mock(WebAnnotationEndpointDiscoverer.class);
|
||||
assertThat(this.filter.match(null, discoverer)).isFalse();
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class CloudFoundryWebAnnotationEndpointDiscovererTests {
|
||||
|
||||
@Test
|
||||
public void discovererShouldAddSuppliedExtensionForHealthEndpoint() throws Exception {
|
||||
public void discovererShouldAddSuppliedExtensionForHealthEndpoint() {
|
||||
load(TestConfiguration.class, (endpointDiscoverer) -> {
|
||||
Collection<EndpointInfo<WebOperation>> endpoints = endpointDiscoverer
|
||||
.discoverEndpoints();
|
||||
|
|
|
|||
|
|
@ -36,14 +36,14 @@ public class TokenTests {
|
|||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void invalidJwtShouldThrowException() throws Exception {
|
||||
public void invalidJwtShouldThrowException() {
|
||||
this.thrown
|
||||
.expect(AuthorizationExceptionMatcher.withReason(Reason.INVALID_TOKEN));
|
||||
new Token("invalid-token");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidJwtClaimsShouldThrowException() throws Exception {
|
||||
public void invalidJwtClaimsShouldThrowException() {
|
||||
String header = "{\"alg\": \"RS256\", \"kid\": \"key-id\", \"typ\": \"JWT\"}";
|
||||
String claims = "invalid-claims";
|
||||
this.thrown
|
||||
|
|
@ -53,7 +53,7 @@ public class TokenTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void invalidJwtHeaderShouldThrowException() throws Exception {
|
||||
public void invalidJwtHeaderShouldThrowException() {
|
||||
String header = "invalid-header";
|
||||
String claims = "{\"exp\": 2147483647, \"iss\": \"http://localhost:8080/uaa/oauth/token\"}";
|
||||
this.thrown
|
||||
|
|
@ -63,7 +63,7 @@ public class TokenTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void emptyJwtSignatureShouldThrowException() throws Exception {
|
||||
public void emptyJwtSignatureShouldThrowException() {
|
||||
String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ0b3B0YWwu"
|
||||
+ "Y29tIiwiZXhwIjoxNDI2NDIwODAwLCJhd2Vzb21lIjp0cnVlfQ.";
|
||||
this.thrown
|
||||
|
|
@ -72,7 +72,7 @@ public class TokenTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void validJwt() throws Exception {
|
||||
public void validJwt() {
|
||||
String header = "{\"alg\": \"RS256\", \"kid\": \"key-id\", \"typ\": \"JWT\"}";
|
||||
String claims = "{\"exp\": 2147483647, \"iss\": \"http://localhost:8080/uaa/oauth/token\"}";
|
||||
String content = Base64Utils.encodeToString(header.getBytes()) + "."
|
||||
|
|
@ -89,8 +89,7 @@ public class TokenTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getSignatureAlgorithmWhenAlgIsNullShouldThrowException()
|
||||
throws Exception {
|
||||
public void getSignatureAlgorithmWhenAlgIsNullShouldThrowException() {
|
||||
String header = "{\"kid\": \"key-id\", \"typ\": \"JWT\"}";
|
||||
String claims = "{\"exp\": 2147483647, \"iss\": \"http://localhost:8080/uaa/oauth/token\"}";
|
||||
Token token = createToken(header, claims);
|
||||
|
|
@ -100,7 +99,7 @@ public class TokenTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getIssuerWhenIssIsNullShouldThrowException() throws Exception {
|
||||
public void getIssuerWhenIssIsNullShouldThrowException() {
|
||||
String header = "{\"alg\": \"RS256\", \"kid\": \"key-id\", \"typ\": \"JWT\"}";
|
||||
String claims = "{\"exp\": 2147483647}";
|
||||
Token token = createToken(header, claims);
|
||||
|
|
@ -110,7 +109,7 @@ public class TokenTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getKidWhenKidIsNullShouldThrowException() throws Exception {
|
||||
public void getKidWhenKidIsNullShouldThrowException() {
|
||||
String header = "{\"alg\": \"RS256\", \"typ\": \"JWT\"}";
|
||||
String claims = "{\"exp\": 2147483647}";
|
||||
Token token = createToken(header, claims);
|
||||
|
|
@ -120,7 +119,7 @@ public class TokenTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getExpiryWhenExpIsNullShouldThrowException() throws Exception {
|
||||
public void getExpiryWhenExpIsNullShouldThrowException() {
|
||||
String header = "{\"alg\": \"RS256\", \"kid\": \"key-id\", \"typ\": \"JWT\"}";
|
||||
String claims = "{\"iss\": \"http://localhost:8080/uaa/oauth/token\"" + "}";
|
||||
Token token = createToken(header, claims);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public class CloudFoundryWebFluxEndpointIntegrationTests {
|
|||
ReactiveCloudFoundrySecurityService.class);
|
||||
|
||||
@Test
|
||||
public void operationWithSecurityInterceptorForbidden() throws Exception {
|
||||
public void operationWithSecurityInterceptorForbidden() {
|
||||
given(tokenValidator.validate(any())).willReturn(Mono.empty());
|
||||
given(securityService.getAccessLevel(any(), eq("app-id")))
|
||||
.willReturn(Mono.just(AccessLevel.RESTRICTED));
|
||||
|
|
@ -90,7 +90,7 @@ public class CloudFoundryWebFluxEndpointIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void operationWithSecurityInterceptorSuccess() throws Exception {
|
||||
public void operationWithSecurityInterceptorSuccess() {
|
||||
given(tokenValidator.validate(any())).willReturn(Mono.empty());
|
||||
given(securityService.getAccessLevel(any(), eq("app-id")))
|
||||
.willReturn(Mono.just(AccessLevel.FULL));
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cloudFoundryPlatformActive() throws Exception {
|
||||
public void cloudFoundryPlatformActive() {
|
||||
setupContextWithCloudEnabled();
|
||||
this.context.refresh();
|
||||
CloudFoundryWebFluxEndpointHandlerMapping handlerMapping = getHandlerMapping();
|
||||
|
|
@ -100,7 +100,7 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cloudfoundryapplicationProducesActuatorMediaType() throws Exception {
|
||||
public void cloudfoundryapplicationProducesActuatorMediaType() {
|
||||
setupContextWithCloudEnabled();
|
||||
this.context.refresh();
|
||||
WebTestClient webTestClient = WebTestClient.bindToApplicationContext(this.context)
|
||||
|
|
@ -110,7 +110,7 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cloudFoundryPlatformActiveSetsApplicationId() throws Exception {
|
||||
public void cloudFoundryPlatformActiveSetsApplicationId() {
|
||||
setupContextWithCloudEnabled();
|
||||
this.context.refresh();
|
||||
CloudFoundryWebFluxEndpointHandlerMapping handlerMapping = getHandlerMapping();
|
||||
|
|
@ -122,7 +122,7 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cloudFoundryPlatformActiveSetsCloudControllerUrl() throws Exception {
|
||||
public void cloudFoundryPlatformActiveSetsCloudControllerUrl() {
|
||||
setupContextWithCloudEnabled();
|
||||
this.context.refresh();
|
||||
CloudFoundryWebFluxEndpointHandlerMapping handlerMapping = getHandlerMapping();
|
||||
|
|
@ -136,8 +136,7 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cloudFoundryPlatformActiveAndCloudControllerUrlNotPresent()
|
||||
throws Exception {
|
||||
public void cloudFoundryPlatformActiveAndCloudControllerUrlNotPresent() {
|
||||
TestPropertyValues
|
||||
.of("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id")
|
||||
.applyTo(this.context);
|
||||
|
|
@ -155,7 +154,7 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void cloudFoundryPathsIgnoredBySpringSecurity() throws Exception {
|
||||
public void cloudFoundryPathsIgnoredBySpringSecurity() {
|
||||
setupContextWithCloudEnabled();
|
||||
this.context.refresh();
|
||||
WebFilterChainProxy chainProxy = this.context.getBean(WebFilterChainProxy.class);
|
||||
|
|
@ -178,7 +177,7 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cloudFoundryPlatformInactive() throws Exception {
|
||||
public void cloudFoundryPlatformInactive() {
|
||||
setupContext();
|
||||
this.context.refresh();
|
||||
assertThat(this.context.containsBean("cloudFoundryWebFluxEndpointHandlerMapping"))
|
||||
|
|
@ -186,7 +185,7 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cloudFoundryManagementEndpointsDisabled() throws Exception {
|
||||
public void cloudFoundryManagementEndpointsDisabled() {
|
||||
setupContextWithCloudEnabled();
|
||||
TestPropertyValues
|
||||
.of("VCAP_APPLICATION=---", "management.cloudfoundry.enabled:false")
|
||||
|
|
@ -197,8 +196,7 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void allEndpointsAvailableUnderCloudFoundryWithoutEnablingWebIncludes()
|
||||
throws Exception {
|
||||
public void allEndpointsAvailableUnderCloudFoundryWithoutEnablingWebIncludes() {
|
||||
setupContextWithCloudEnabled();
|
||||
this.context.register(TestConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
|
@ -211,7 +209,7 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void endpointPathCustomizationIsNotApplied() throws Exception {
|
||||
public void endpointPathCustomizationIsNotApplied() {
|
||||
setupContextWithCloudEnabled();
|
||||
this.context.register(TestConfiguration.class);
|
||||
this.context.refresh();
|
||||
|
|
@ -227,7 +225,7 @@ public class ReactiveCloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void healthEndpointInvokerShouldBeCloudFoundryWebExtension() throws Exception {
|
||||
public void healthEndpointInvokerShouldBeCloudFoundryWebExtension() {
|
||||
setupContextWithCloudEnabled();
|
||||
this.context.register(HealthEndpointAutoConfiguration.class,
|
||||
HealthWebEndpointManagementContextConfiguration.class,
|
||||
|
|
|
|||
|
|
@ -52,14 +52,14 @@ public class ReactiveCloudFoundrySecurityInterceptorTests {
|
|||
private ReactiveCloudFoundrySecurityInterceptor interceptor;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.interceptor = new ReactiveCloudFoundrySecurityInterceptor(
|
||||
this.tokenValidator, this.securityService, "my-app-id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void preHandleWhenRequestIsPreFlightShouldBeOk() throws Exception {
|
||||
public void preHandleWhenRequestIsPreFlightShouldBeOk() {
|
||||
MockServerWebExchange request = MockServerWebExchange.from(MockServerHttpRequest
|
||||
.options("/a").header(HttpHeaders.ORIGIN, "http://example.com")
|
||||
.header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET").build());
|
||||
|
|
@ -69,8 +69,7 @@ public class ReactiveCloudFoundrySecurityInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void preHandleWhenTokenIsMissingShouldReturnMissingAuthorization()
|
||||
throws Exception {
|
||||
public void preHandleWhenTokenIsMissingShouldReturnMissingAuthorization() {
|
||||
MockServerWebExchange request = MockServerWebExchange
|
||||
.from(MockServerHttpRequest.get("/a").build());
|
||||
StepVerifier.create(this.interceptor.preHandle(request, "/a"))
|
||||
|
|
@ -80,8 +79,7 @@ public class ReactiveCloudFoundrySecurityInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void preHandleWhenTokenIsNotBearerShouldReturnMissingAuthorization()
|
||||
throws Exception {
|
||||
public void preHandleWhenTokenIsNotBearerShouldReturnMissingAuthorization() {
|
||||
MockServerWebExchange request = MockServerWebExchange.from(MockServerHttpRequest
|
||||
.get("/a").header(HttpHeaders.AUTHORIZATION, mockAccessToken()).build());
|
||||
StepVerifier.create(this.interceptor.preHandle(request, "/a"))
|
||||
|
|
@ -91,7 +89,7 @@ public class ReactiveCloudFoundrySecurityInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void preHandleWhenApplicationIdIsNullShouldReturnError() throws Exception {
|
||||
public void preHandleWhenApplicationIdIsNullShouldReturnError() {
|
||||
this.interceptor = new ReactiveCloudFoundrySecurityInterceptor(
|
||||
this.tokenValidator, this.securityService, null);
|
||||
MockServerWebExchange request = MockServerWebExchange
|
||||
|
|
@ -106,8 +104,7 @@ public class ReactiveCloudFoundrySecurityInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void preHandleWhenCloudFoundrySecurityServiceIsNullShouldReturnError()
|
||||
throws Exception {
|
||||
public void preHandleWhenCloudFoundrySecurityServiceIsNullShouldReturnError() {
|
||||
this.interceptor = new ReactiveCloudFoundrySecurityInterceptor(
|
||||
this.tokenValidator, null, "my-app-id");
|
||||
MockServerWebExchange request = MockServerWebExchange.from(MockServerHttpRequest
|
||||
|
|
@ -120,8 +117,7 @@ public class ReactiveCloudFoundrySecurityInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void preHandleWhenAccessIsNotAllowedShouldReturnAccessDenied()
|
||||
throws Exception {
|
||||
public void preHandleWhenAccessIsNotAllowedShouldReturnAccessDenied() {
|
||||
given(this.securityService.getAccessLevel(mockAccessToken(), "my-app-id"))
|
||||
.willReturn(Mono.just(AccessLevel.RESTRICTED));
|
||||
given(this.tokenValidator.validate(any())).willReturn(Mono.empty());
|
||||
|
|
@ -136,7 +132,7 @@ public class ReactiveCloudFoundrySecurityInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void preHandleSuccessfulWithFullAccess() throws Exception {
|
||||
public void preHandleSuccessfulWithFullAccess() {
|
||||
String accessToken = mockAccessToken();
|
||||
given(this.securityService.getAccessLevel(accessToken, "my-app-id"))
|
||||
.willReturn(Mono.just(AccessLevel.FULL));
|
||||
|
|
@ -155,7 +151,7 @@ public class ReactiveCloudFoundrySecurityInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void preHandleSuccessfulWithRestrictedAccess() throws Exception {
|
||||
public void preHandleSuccessfulWithRestrictedAccess() {
|
||||
String accessToken = mockAccessToken();
|
||||
given(this.securityService.getAccessLevel(accessToken, "my-app-id"))
|
||||
.willReturn(Mono.just(AccessLevel.RESTRICTED));
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class ReactiveCloudFoundrySecurityServiceTests {
|
|||
private WebClient.Builder builder;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
public void setup() {
|
||||
this.server = new MockWebServer();
|
||||
this.builder = WebClient.builder().baseUrl(this.server.url("/").toString());
|
||||
this.securityService = new ReactiveCloudFoundrySecurityService(this.builder,
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public class ReactiveTokenValidatorTests {
|
|||
private static final Map<String, String> VALID_KEYS = new ConcurrentHashMap<>();
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
VALID_KEYS.put("valid-key", VALID_KEY);
|
||||
INVALID_KEYS.put("invalid-key", INVALID_KEY);
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ public class CloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cloudFoundryPlatformActive() throws Exception {
|
||||
public void cloudFoundryPlatformActive() {
|
||||
CloudFoundryWebEndpointServletHandlerMapping handlerMapping = getHandlerMapping();
|
||||
assertThat(handlerMapping.getEndpointMapping().getPath())
|
||||
.isEqualTo("/cloudfoundryapplication");
|
||||
|
|
@ -124,7 +124,7 @@ public class CloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cloudFoundryPlatformActiveSetsApplicationId() throws Exception {
|
||||
public void cloudFoundryPlatformActiveSetsApplicationId() {
|
||||
CloudFoundryWebEndpointServletHandlerMapping handlerMapping = getHandlerMapping();
|
||||
Object interceptor = ReflectionTestUtils.getField(handlerMapping,
|
||||
"securityInterceptor");
|
||||
|
|
@ -134,7 +134,7 @@ public class CloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cloudFoundryPlatformActiveSetsCloudControllerUrl() throws Exception {
|
||||
public void cloudFoundryPlatformActiveSetsCloudControllerUrl() {
|
||||
CloudFoundryWebEndpointServletHandlerMapping handlerMapping = getHandlerMapping();
|
||||
Object interceptor = ReflectionTestUtils.getField(handlerMapping,
|
||||
"securityInterceptor");
|
||||
|
|
@ -146,7 +146,7 @@ public class CloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void skipSslValidation() throws Exception {
|
||||
public void skipSslValidation() {
|
||||
TestPropertyValues.of("management.cloudfoundry.skipSslValidation:true")
|
||||
.applyTo(this.context);
|
||||
ConfigurationPropertySources.attach(this.context.getEnvironment());
|
||||
|
|
@ -163,8 +163,7 @@ public class CloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cloudFoundryPlatformActiveAndCloudControllerUrlNotPresent()
|
||||
throws Exception {
|
||||
public void cloudFoundryPlatformActiveAndCloudControllerUrlNotPresent() {
|
||||
TestPropertyValues
|
||||
.of("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id")
|
||||
.applyTo(this.context);
|
||||
|
|
@ -180,7 +179,7 @@ public class CloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cloudFoundryPathsIgnoredBySpringSecurity() throws Exception {
|
||||
public void cloudFoundryPathsIgnoredBySpringSecurity() {
|
||||
TestPropertyValues
|
||||
.of("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id")
|
||||
.applyTo(this.context);
|
||||
|
|
@ -197,7 +196,7 @@ public class CloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cloudFoundryPlatformInactive() throws Exception {
|
||||
public void cloudFoundryPlatformInactive() {
|
||||
this.context.refresh();
|
||||
assertThat(
|
||||
this.context.containsBean("cloudFoundryWebEndpointServletHandlerMapping"))
|
||||
|
|
@ -205,7 +204,7 @@ public class CloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void cloudFoundryManagementEndpointsDisabled() throws Exception {
|
||||
public void cloudFoundryManagementEndpointsDisabled() {
|
||||
TestPropertyValues
|
||||
.of("VCAP_APPLICATION=---", "management.cloudfoundry.enabled:false")
|
||||
.applyTo(this.context);
|
||||
|
|
@ -215,8 +214,7 @@ public class CloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void allEndpointsAvailableUnderCloudFoundryWithoutExposeAllOnWeb()
|
||||
throws Exception {
|
||||
public void allEndpointsAvailableUnderCloudFoundryWithoutExposeAllOnWeb() {
|
||||
this.context.register(TestConfiguration.class);
|
||||
this.context.refresh();
|
||||
CloudFoundryWebEndpointServletHandlerMapping handlerMapping = getHandlerMapping();
|
||||
|
|
@ -228,7 +226,7 @@ public class CloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void endpointPathCustomizationIsNotApplied() throws Exception {
|
||||
public void endpointPathCustomizationIsNotApplied() {
|
||||
TestPropertyValues.of("management.endpoints.web.path-mapping.test=custom")
|
||||
.applyTo(this.context);
|
||||
this.context.register(TestConfiguration.class);
|
||||
|
|
@ -246,7 +244,7 @@ public class CloudFoundryActuatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void healthEndpointInvokerShouldBeCloudFoundryWebExtension() throws Exception {
|
||||
public void healthEndpointInvokerShouldBeCloudFoundryWebExtension() {
|
||||
TestPropertyValues
|
||||
.of("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id",
|
||||
"vcap.application.cf_api:http://my-cloud-controller.com")
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class CloudFoundryMvcWebEndpointIntegrationTests {
|
|||
CloudFoundrySecurityService.class);
|
||||
|
||||
@Test
|
||||
public void operationWithSecurityInterceptorForbidden() throws Exception {
|
||||
public void operationWithSecurityInterceptorForbidden() {
|
||||
given(securityService.getAccessLevel(any(), eq("app-id")))
|
||||
.willReturn(AccessLevel.RESTRICTED);
|
||||
load(TestEndpointConfiguration.class,
|
||||
|
|
@ -84,7 +84,7 @@ public class CloudFoundryMvcWebEndpointIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void operationWithSecurityInterceptorSuccess() throws Exception {
|
||||
public void operationWithSecurityInterceptorSuccess() {
|
||||
given(securityService.getAccessLevel(any(), eq("app-id")))
|
||||
.willReturn(AccessLevel.FULL);
|
||||
load(TestEndpointConfiguration.class,
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class CloudFoundrySecurityInterceptorTests {
|
|||
private MockHttpServletRequest request;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.interceptor = new CloudFoundrySecurityInterceptor(this.tokenValidator,
|
||||
this.securityService, "my-app-id");
|
||||
|
|
@ -61,7 +61,7 @@ public class CloudFoundrySecurityInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void preHandleWhenRequestIsPreFlightShouldReturnTrue() throws Exception {
|
||||
public void preHandleWhenRequestIsPreFlightShouldReturnTrue() {
|
||||
this.request.setMethod("OPTIONS");
|
||||
this.request.addHeader(HttpHeaders.ORIGIN, "http://example.com");
|
||||
this.request.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET");
|
||||
|
|
@ -70,14 +70,14 @@ public class CloudFoundrySecurityInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void preHandleWhenTokenIsMissingShouldReturnFalse() throws Exception {
|
||||
public void preHandleWhenTokenIsMissingShouldReturnFalse() {
|
||||
SecurityResponse response = this.interceptor.preHandle(this.request, "/a");
|
||||
assertThat(response.getStatus())
|
||||
.isEqualTo(Reason.MISSING_AUTHORIZATION.getStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void preHandleWhenTokenIsNotBearerShouldReturnFalse() throws Exception {
|
||||
public void preHandleWhenTokenIsNotBearerShouldReturnFalse() {
|
||||
this.request.addHeader("Authorization", mockAccessToken());
|
||||
SecurityResponse response = this.interceptor.preHandle(this.request, "/a");
|
||||
assertThat(response.getStatus())
|
||||
|
|
@ -85,7 +85,7 @@ public class CloudFoundrySecurityInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void preHandleWhenApplicationIdIsNullShouldReturnFalse() throws Exception {
|
||||
public void preHandleWhenApplicationIdIsNullShouldReturnFalse() {
|
||||
this.interceptor = new CloudFoundrySecurityInterceptor(this.tokenValidator,
|
||||
this.securityService, null);
|
||||
this.request.addHeader("Authorization", "bearer " + mockAccessToken());
|
||||
|
|
@ -95,8 +95,7 @@ public class CloudFoundrySecurityInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void preHandleWhenCloudFoundrySecurityServiceIsNullShouldReturnFalse()
|
||||
throws Exception {
|
||||
public void preHandleWhenCloudFoundrySecurityServiceIsNullShouldReturnFalse() {
|
||||
this.interceptor = new CloudFoundrySecurityInterceptor(this.tokenValidator, null,
|
||||
"my-app-id");
|
||||
this.request.addHeader("Authorization", "bearer " + mockAccessToken());
|
||||
|
|
@ -106,7 +105,7 @@ public class CloudFoundrySecurityInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void preHandleWhenAccessIsNotAllowedShouldReturnFalse() throws Exception {
|
||||
public void preHandleWhenAccessIsNotAllowedShouldReturnFalse() {
|
||||
String accessToken = mockAccessToken();
|
||||
this.request.addHeader("Authorization", "bearer " + accessToken);
|
||||
given(this.securityService.getAccessLevel(accessToken, "my-app-id"))
|
||||
|
|
@ -116,7 +115,7 @@ public class CloudFoundrySecurityInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void preHandleSuccessfulWithFullAccess() throws Exception {
|
||||
public void preHandleSuccessfulWithFullAccess() {
|
||||
String accessToken = mockAccessToken();
|
||||
this.request.addHeader("Authorization", "Bearer " + accessToken);
|
||||
given(this.securityService.getAccessLevel(accessToken, "my-app-id"))
|
||||
|
|
@ -132,7 +131,7 @@ public class CloudFoundrySecurityInterceptorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void preHandleSuccessfulWithRestrictedAccess() throws Exception {
|
||||
public void preHandleSuccessfulWithRestrictedAccess() {
|
||||
String accessToken = mockAccessToken();
|
||||
this.request.addHeader("Authorization", "Bearer " + accessToken);
|
||||
given(this.securityService.getAccessLevel(accessToken, "my-app-id"))
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public class CloudFoundrySecurityServiceTests {
|
|||
private MockRestServiceServer server;
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
public void setup() {
|
||||
MockServerRestTemplateCustomizer mockServerCustomizer = new MockServerRestTemplateCustomizer();
|
||||
RestTemplateBuilder builder = new RestTemplateBuilder(mockServerCustomizer);
|
||||
this.securityService = new CloudFoundrySecurityService(builder, CLOUD_CONTROLLER,
|
||||
|
|
@ -73,7 +73,7 @@ public class CloudFoundrySecurityServiceTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void skipSslValidationWhenTrue() throws Exception {
|
||||
public void skipSslValidationWhenTrue() {
|
||||
RestTemplateBuilder builder = new RestTemplateBuilder();
|
||||
this.securityService = new CloudFoundrySecurityService(builder, CLOUD_CONTROLLER,
|
||||
true);
|
||||
|
|
@ -84,7 +84,7 @@ public class CloudFoundrySecurityServiceTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void doNotskipSslValidationWhenFalse() throws Exception {
|
||||
public void doNotskipSslValidationWhenFalse() {
|
||||
RestTemplateBuilder builder = new RestTemplateBuilder();
|
||||
this.securityService = new CloudFoundrySecurityService(builder, CLOUD_CONTROLLER,
|
||||
false);
|
||||
|
|
@ -95,7 +95,7 @@ public class CloudFoundrySecurityServiceTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getAccessLevelWhenSpaceDeveloperShouldReturnFull() throws Exception {
|
||||
public void getAccessLevelWhenSpaceDeveloperShouldReturnFull() {
|
||||
String responseBody = "{\"read_sensitive_data\": true,\"read_basic_data\": true}";
|
||||
this.server.expect(requestTo(CLOUD_CONTROLLER_PERMISSIONS))
|
||||
.andExpect(header("Authorization", "bearer my-access-token"))
|
||||
|
|
@ -107,8 +107,7 @@ public class CloudFoundrySecurityServiceTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getAccessLevelWhenNotSpaceDeveloperShouldReturnRestricted()
|
||||
throws Exception {
|
||||
public void getAccessLevelWhenNotSpaceDeveloperShouldReturnRestricted() {
|
||||
String responseBody = "{\"read_sensitive_data\": false,\"read_basic_data\": true}";
|
||||
this.server.expect(requestTo(CLOUD_CONTROLLER_PERMISSIONS))
|
||||
.andExpect(header("Authorization", "bearer my-access-token"))
|
||||
|
|
@ -120,7 +119,7 @@ public class CloudFoundrySecurityServiceTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getAccessLevelWhenTokenIsNotValidShouldThrowException() throws Exception {
|
||||
public void getAccessLevelWhenTokenIsNotValidShouldThrowException() {
|
||||
this.server.expect(requestTo(CLOUD_CONTROLLER_PERMISSIONS))
|
||||
.andExpect(header("Authorization", "bearer my-access-token"))
|
||||
.andRespond(withUnauthorizedRequest());
|
||||
|
|
@ -130,7 +129,7 @@ public class CloudFoundrySecurityServiceTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getAccessLevelWhenForbiddenShouldThrowException() throws Exception {
|
||||
public void getAccessLevelWhenForbiddenShouldThrowException() {
|
||||
this.server.expect(requestTo(CLOUD_CONTROLLER_PERMISSIONS))
|
||||
.andExpect(header("Authorization", "bearer my-access-token"))
|
||||
.andRespond(withStatus(HttpStatus.FORBIDDEN));
|
||||
|
|
@ -140,8 +139,7 @@ public class CloudFoundrySecurityServiceTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getAccessLevelWhenCloudControllerIsNotReachableThrowsException()
|
||||
throws Exception {
|
||||
public void getAccessLevelWhenCloudControllerIsNotReachableThrowsException() {
|
||||
this.server.expect(requestTo(CLOUD_CONTROLLER_PERMISSIONS))
|
||||
.andExpect(header("Authorization", "bearer my-access-token"))
|
||||
.andRespond(withServerError());
|
||||
|
|
@ -151,8 +149,7 @@ public class CloudFoundrySecurityServiceTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fetchTokenKeysWhenSuccessfulShouldReturnListOfKeysFromUAA()
|
||||
throws Exception {
|
||||
public void fetchTokenKeysWhenSuccessfulShouldReturnListOfKeysFromUAA() {
|
||||
this.server.expect(requestTo(CLOUD_CONTROLLER + "/info"))
|
||||
.andRespond(withSuccess("{\"token_endpoint\":\"http://my-uaa.com\"}",
|
||||
MediaType.APPLICATION_JSON));
|
||||
|
|
@ -174,7 +171,7 @@ public class CloudFoundrySecurityServiceTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fetchTokenKeysWhenNoKeysReturnedFromUAA() throws Exception {
|
||||
public void fetchTokenKeysWhenNoKeysReturnedFromUAA() {
|
||||
this.server.expect(requestTo(CLOUD_CONTROLLER + "/info")).andRespond(withSuccess(
|
||||
"{\"token_endpoint\":\"" + UAA_URL + "\"}", MediaType.APPLICATION_JSON));
|
||||
String responseBody = "{\"keys\": []}";
|
||||
|
|
@ -186,7 +183,7 @@ public class CloudFoundrySecurityServiceTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void fetchTokenKeysWhenUnsuccessfulShouldThrowException() throws Exception {
|
||||
public void fetchTokenKeysWhenUnsuccessfulShouldThrowException() {
|
||||
this.server.expect(requestTo(CLOUD_CONTROLLER + "/info")).andRespond(withSuccess(
|
||||
"{\"token_endpoint\":\"" + UAA_URL + "\"}", MediaType.APPLICATION_JSON));
|
||||
this.server.expect(requestTo(UAA_URL + "/token_keys"))
|
||||
|
|
@ -197,7 +194,7 @@ public class CloudFoundrySecurityServiceTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getUaaUrlShouldCallCloudControllerInfoOnlyOnce() throws Exception {
|
||||
public void getUaaUrlShouldCallCloudControllerInfoOnlyOnce() {
|
||||
this.server.expect(requestTo(CLOUD_CONTROLLER + "/info")).andRespond(withSuccess(
|
||||
"{\"token_endpoint\":\"" + UAA_URL + "\"}", MediaType.APPLICATION_JSON));
|
||||
String uaaUrl = this.securityService.getUaaUrl();
|
||||
|
|
@ -209,8 +206,7 @@ public class CloudFoundrySecurityServiceTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getUaaUrlWhenCloudControllerUrlIsNotReachableShouldThrowException()
|
||||
throws Exception {
|
||||
public void getUaaUrlWhenCloudControllerUrlIsNotReachableShouldThrowException() {
|
||||
this.server.expect(requestTo(CLOUD_CONTROLLER + "/info"))
|
||||
.andRespond(withServerError());
|
||||
this.thrown.expect(
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class SkipSslVerificationHttpRequestFactoryTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void restCallToSelfSignedServerShouldNotThrowSslException() throws Exception {
|
||||
public void restCallToSelfSignedServerShouldNotThrowSslException() {
|
||||
String httpsUrl = getHttpsUrl();
|
||||
SkipSslVerificationHttpRequestFactory requestFactory = new SkipSslVerificationHttpRequestFactory();
|
||||
RestTemplate restTemplate = new RestTemplate(requestFactory);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class TokenValidatorTests {
|
|||
.singletonMap("valid-key", VALID_KEY);
|
||||
|
||||
@Before
|
||||
public void setup() throws Exception {
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.tokenValidator = new TokenValidator(this.securityService);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ public class ConditionsReportEndpointAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean()
|
||||
throws Exception {
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoint.conditions.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ import static org.mockito.Mockito.mock;
|
|||
public class ConditionsReportEndpointTests {
|
||||
|
||||
@Test
|
||||
public void invoke() throws Exception {
|
||||
public void invoke() {
|
||||
new ApplicationContextRunner().withUserConfiguration(Config.class)
|
||||
.run((context) -> {
|
||||
Report report = context.getBean(ConditionsReportEndpoint.class)
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@ public class ShutdownEndpointAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean()
|
||||
throws Exception {
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoint.shutdown.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
|
|
|
|||
|
|
@ -51,8 +51,7 @@ public class ConfigurationPropertiesReportEndpointAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean()
|
||||
throws Exception {
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoint.configprops.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
|
|
@ -60,7 +59,7 @@ public class ConfigurationPropertiesReportEndpointAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void keysToSanitizeCanBeConfiguredViaTheEnvironment() throws Exception {
|
||||
public void keysToSanitizeCanBeConfiguredViaTheEnvironment() {
|
||||
this.contextRunner.withUserConfiguration(Config.class)
|
||||
.withPropertyValues(
|
||||
"management.endpoint.configprops.keys-to-sanitize: .*pass.*, property")
|
||||
|
|
|
|||
|
|
@ -44,14 +44,14 @@ public class CouchbaseHealthIndicatorAutoConfigurationTests {
|
|||
HealthIndicatorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void runShouldCreateIndicator() throws Exception {
|
||||
public void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.hasSingleBean(CouchbaseHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenDisabledShouldNotCreateIndicator() throws Exception {
|
||||
public void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.couchbase.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(CouchbaseHealthIndicator.class)
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class ElasticsearchHealthIndicatorAutoConfigurationTests {
|
|||
HealthIndicatorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void runShouldCreateIndicator() throws Exception {
|
||||
public void runShouldCreateIndicator() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("spring.data.elasticsearch.cluster-nodes:localhost:0")
|
||||
.withSystemProperties("es.set.netty.runtime.available.processors=false")
|
||||
|
|
@ -58,7 +58,7 @@ public class ElasticsearchHealthIndicatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenUsingJestClientShouldCreateIndicator() throws Exception {
|
||||
public void runWhenUsingJestClientShouldCreateIndicator() {
|
||||
this.contextRunner.withUserConfiguration(JestClientConfiguration.class)
|
||||
.withSystemProperties("es.set.netty.runtime.available.processors=false")
|
||||
.run((context) -> assertThat(context)
|
||||
|
|
@ -68,7 +68,7 @@ public class ElasticsearchHealthIndicatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenDisabledShouldNotCreateIndicator() throws Exception {
|
||||
public void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.health.elasticsearch.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
|
|
|
|||
|
|
@ -56,14 +56,14 @@ public class ExposeExcludePropertyEndpointFilterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createWhenDiscovererTypeIsNullShouldThrowException() throws Exception {
|
||||
public void createWhenDiscovererTypeIsNullShouldThrowException() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Discoverer Type must not be null");
|
||||
new ExposeExcludePropertyEndpointFilter<>(null, this.environment, "foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createWhenEnvironmentIsNullShouldThrowException() throws Exception {
|
||||
public void createWhenEnvironmentIsNullShouldThrowException() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Environment must not be null");
|
||||
new ExposeExcludePropertyEndpointFilter<>(TestEndpointDiscoverer.class, null,
|
||||
|
|
@ -71,7 +71,7 @@ public class ExposeExcludePropertyEndpointFilterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createWhenPrefixIsNullShouldThrowException() throws Exception {
|
||||
public void createWhenPrefixIsNullShouldThrowException() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Prefix must not be empty");
|
||||
new ExposeExcludePropertyEndpointFilter<Operation>(TestEndpointDiscoverer.class,
|
||||
|
|
@ -79,7 +79,7 @@ public class ExposeExcludePropertyEndpointFilterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createWhenPrefixIsEmptyShouldThrowException() throws Exception {
|
||||
public void createWhenPrefixIsEmptyShouldThrowException() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Prefix must not be empty");
|
||||
new ExposeExcludePropertyEndpointFilter<Operation>(TestEndpointDiscoverer.class,
|
||||
|
|
@ -87,53 +87,49 @@ public class ExposeExcludePropertyEndpointFilterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void matchWhenExposeIsEmptyAndExcludeIsEmptyAndInDefaultShouldMatch()
|
||||
throws Exception {
|
||||
public void matchWhenExposeIsEmptyAndExcludeIsEmptyAndInDefaultShouldMatch() {
|
||||
setupFilter("", "");
|
||||
assertThat(match("def")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchWhenExposeIsEmptyAndExcludeIsEmptyAndNotInDefaultShouldNotMatch()
|
||||
throws Exception {
|
||||
public void matchWhenExposeIsEmptyAndExcludeIsEmptyAndNotInDefaultShouldNotMatch() {
|
||||
setupFilter("", "");
|
||||
assertThat(match("bar")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchWhenExposeMatchesAndExcludeIsEmptyShouldMatch() throws Exception {
|
||||
public void matchWhenExposeMatchesAndExcludeIsEmptyShouldMatch() {
|
||||
setupFilter("bar", "");
|
||||
assertThat(match("bar")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchWhenExposeDoesNotMatchAndExcludeIsEmptyShouldNotMatch()
|
||||
throws Exception {
|
||||
public void matchWhenExposeDoesNotMatchAndExcludeIsEmptyShouldNotMatch() {
|
||||
setupFilter("bar", "");
|
||||
assertThat(match("baz")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchWhenExposeMatchesAndExcludeMatchesShouldNotMatch() throws Exception {
|
||||
public void matchWhenExposeMatchesAndExcludeMatchesShouldNotMatch() {
|
||||
setupFilter("bar,baz", "baz");
|
||||
assertThat(match("baz")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchWhenExposeMatchesAndExcludeDoesNotMatchShouldMatch()
|
||||
throws Exception {
|
||||
public void matchWhenExposeMatchesAndExcludeDoesNotMatchShouldMatch() {
|
||||
setupFilter("bar,baz", "buz");
|
||||
assertThat(match("baz")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchWhenExposeMatchesWithDifferentCaseShouldMatch() throws Exception {
|
||||
public void matchWhenExposeMatchesWithDifferentCaseShouldMatch() {
|
||||
setupFilter("bar", "");
|
||||
assertThat(match("bAr")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchWhenDiscovererDoesNotMatchShouldMatch() throws Exception {
|
||||
public void matchWhenDiscovererDoesNotMatchShouldMatch() {
|
||||
this.environment.setProperty("foo.expose", "bar");
|
||||
this.environment.setProperty("foo.exclude", "");
|
||||
this.filter = new ExposeExcludePropertyEndpointFilter<>(
|
||||
|
|
@ -142,7 +138,7 @@ public class ExposeExcludePropertyEndpointFilterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void matchWhenIncludeIsAsteriskShouldMatchAll() throws Exception {
|
||||
public void matchWhenIncludeIsAsteriskShouldMatchAll() {
|
||||
setupFilter("*", "buz");
|
||||
assertThat(match("bar")).isTrue();
|
||||
assertThat(match("baz")).isTrue();
|
||||
|
|
@ -150,7 +146,7 @@ public class ExposeExcludePropertyEndpointFilterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void matchWhenExcludeIsAsteriskShouldMatchNone() throws Exception {
|
||||
public void matchWhenExcludeIsAsteriskShouldMatchNone() {
|
||||
setupFilter("bar,baz,buz", "*");
|
||||
assertThat(match("bar")).isFalse();
|
||||
assertThat(match("baz")).isFalse();
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class ConditionalOnEnabledEndpointTests {
|
|||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();
|
||||
|
||||
@Test
|
||||
public void outcomeWhenEndpointEnabledPropertyIsTrueShouldMatch() throws Exception {
|
||||
public void outcomeWhenEndpointEnabledPropertyIsTrueShouldMatch() {
|
||||
this.contextRunner.withPropertyValues("management.endpoint.foo.enabled=true")
|
||||
.withUserConfiguration(
|
||||
FooEndpointEnabledByDefaultFalseConfiguration.class)
|
||||
|
|
@ -49,16 +49,14 @@ public class ConditionalOnEnabledEndpointTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void outcomeWhenEndpointEnabledPropertyIsFalseShouldNotMatch()
|
||||
throws Exception {
|
||||
public void outcomeWhenEndpointEnabledPropertyIsFalseShouldNotMatch() {
|
||||
this.contextRunner.withPropertyValues("management.endpoint.foo.enabled=false")
|
||||
.withUserConfiguration(FooEndpointEnabledByDefaultTrueConfiguration.class)
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void outcomeWhenNoEndpointPropertyAndUserDefinedDefaultIsTrueShouldMatch()
|
||||
throws Exception {
|
||||
public void outcomeWhenNoEndpointPropertyAndUserDefinedDefaultIsTrueShouldMatch() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoints.enabled-by-default=true")
|
||||
.withUserConfiguration(
|
||||
|
|
@ -67,8 +65,7 @@ public class ConditionalOnEnabledEndpointTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void outcomeWhenNoEndpointPropertyAndUserDefinedDefaultIsFalseShouldNotMatch()
|
||||
throws Exception {
|
||||
public void outcomeWhenNoEndpointPropertyAndUserDefinedDefaultIsFalseShouldNotMatch() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoints.enabled-by-default=false")
|
||||
.withUserConfiguration(FooEndpointEnabledByDefaultTrueConfiguration.class)
|
||||
|
|
@ -76,16 +73,14 @@ public class ConditionalOnEnabledEndpointTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void outcomeWhenNoPropertiesAndAnnotationIsEnabledByDefaultShouldMatch()
|
||||
throws Exception {
|
||||
public void outcomeWhenNoPropertiesAndAnnotationIsEnabledByDefaultShouldMatch() {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(FooEndpointEnabledByDefaultTrueConfiguration.class)
|
||||
.run((context) -> assertThat(context).hasBean("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void outcomeWhenNoPropertiesAndAnnotationIsNotEnabledByDefaultShouldNotMatch()
|
||||
throws Exception {
|
||||
public void outcomeWhenNoPropertiesAndAnnotationIsNotEnabledByDefaultShouldNotMatch() {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(
|
||||
FooEndpointEnabledByDefaultFalseConfiguration.class)
|
||||
|
|
@ -93,8 +88,7 @@ public class ConditionalOnEnabledEndpointTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void outcomeWhenNoPropertiesAndExtensionAnnotationIsEnabledByDefaultShouldMatch()
|
||||
throws Exception {
|
||||
public void outcomeWhenNoPropertiesAndExtensionAnnotationIsEnabledByDefaultShouldMatch() {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(
|
||||
FooEndpointAndExtensionEnabledByDefaultTrueConfiguration.class)
|
||||
|
|
@ -102,8 +96,7 @@ public class ConditionalOnEnabledEndpointTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void outcomeWhenNoPropertiesAndExtensionAnnotationIsNotEnabledByDefaultShouldNotMatch()
|
||||
throws Exception {
|
||||
public void outcomeWhenNoPropertiesAndExtensionAnnotationIsNotEnabledByDefaultShouldNotMatch() {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(
|
||||
FooEndpointAndExtensionEnabledByDefaultFalseConfiguration.class)
|
||||
|
|
|
|||
|
|
@ -48,32 +48,31 @@ public class DefaultEndpointPathProviderTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getPathsShouldReturnAllPaths() throws Exception {
|
||||
public void getPathsShouldReturnAllPaths() {
|
||||
DefaultEndpointPathProvider provider = createProvider("");
|
||||
assertThat(provider.getPaths()).containsOnly("/foo", "/bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPathsWhenHasContextPathShouldReturnAllPathsWithContext()
|
||||
throws Exception {
|
||||
public void getPathsWhenHasContextPathShouldReturnAllPathsWithContext() {
|
||||
DefaultEndpointPathProvider provider = createProvider("/actuator");
|
||||
assertThat(provider.getPaths()).containsOnly("/actuator/foo", "/actuator/bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPathWhenEndpointIdIsKnownShouldReturnPath() throws Exception {
|
||||
public void getPathWhenEndpointIdIsKnownShouldReturnPath() {
|
||||
DefaultEndpointPathProvider provider = createProvider("");
|
||||
assertThat(provider.getPath("foo")).isEqualTo("/foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPathWhenEndpointIdIsUnknownShouldReturnNull() throws Exception {
|
||||
public void getPathWhenEndpointIdIsUnknownShouldReturnNull() {
|
||||
DefaultEndpointPathProvider provider = createProvider("");
|
||||
assertThat(provider.getPath("baz")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPathWhenHasContextPathReturnPath() throws Exception {
|
||||
public void getPathWhenHasContextPathReturnPath() {
|
||||
DefaultEndpointPathProvider provider = createProvider("/actuator");
|
||||
assertThat(provider.getPath("foo")).isEqualTo("/actuator/foo");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class WebEndpointPropertiesTests {
|
||||
|
||||
@Test
|
||||
public void defaultBasePathShouldBeApplication() throws Exception {
|
||||
public void defaultBasePathShouldBeApplication() {
|
||||
WebEndpointProperties properties = new WebEndpointProperties();
|
||||
assertThat(properties.getBasePath()).isEqualTo("/actuator");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basePathShouldBeCleaned() throws Exception {
|
||||
public void basePathShouldBeCleaned() {
|
||||
WebEndpointProperties properties = new WebEndpointProperties();
|
||||
properties.setBasePath("/");
|
||||
assertThat(properties.getBasePath()).isEqualTo("");
|
||||
|
|
|
|||
|
|
@ -49,15 +49,14 @@ public class EnvironmentEndpointAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean()
|
||||
throws Exception {
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.withPropertyValues("management.endpoint.env.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(EnvironmentEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void keysToSanitizeCanBeConfiguredViaTheEnvironment() throws Exception {
|
||||
public void keysToSanitizeCanBeConfiguredViaTheEnvironment() {
|
||||
this.contextRunner.withSystemProperties("dbPassword=123456", "apiKey=123456")
|
||||
.withPropertyValues("management.endpoint.env.keys-to-sanitize=.*pass.*")
|
||||
.run(validateSystemProperties("******", "123456"));
|
||||
|
|
|
|||
|
|
@ -47,8 +47,7 @@ public class FlywayEndpointAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean()
|
||||
throws Exception {
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.withPropertyValues("management.endpoint.flyway.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(FlywayEndpoint.class));
|
||||
|
|
|
|||
|
|
@ -47,24 +47,21 @@ public class HealthIndicatorAutoConfigurationTests {
|
|||
AutoConfigurations.of(HealthIndicatorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void runWhenNoOtherIndicatorsShouldCreateDefaultApplicationHealthIndicator()
|
||||
throws Exception {
|
||||
public void runWhenNoOtherIndicatorsShouldCreateDefaultApplicationHealthIndicator() {
|
||||
this.contextRunner
|
||||
.run((context) -> assertThat(context).getBean(HealthIndicator.class)
|
||||
.isInstanceOf(ApplicationHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenHasDefinedIndicatorShouldNotCreateDefaultApplicationHealthIndicator()
|
||||
throws Exception {
|
||||
public void runWhenHasDefinedIndicatorShouldNotCreateDefaultApplicationHealthIndicator() {
|
||||
this.contextRunner.withUserConfiguration(CustomHealthIndicatorConfiguration.class)
|
||||
.run((context) -> assertThat(context).getBean(HealthIndicator.class)
|
||||
.isInstanceOf(CustomHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenHasDefaultsDisabledAndNoSingleIndicatorEnabledShouldCreateDefaultApplicationHealthIndicator()
|
||||
throws Exception {
|
||||
public void runWhenHasDefaultsDisabledAndNoSingleIndicatorEnabledShouldCreateDefaultApplicationHealthIndicator() {
|
||||
this.contextRunner.withUserConfiguration(CustomHealthIndicatorConfiguration.class)
|
||||
.withPropertyValues("management.health.defaults.enabled:false")
|
||||
.run((context) -> assertThat(context).getBean(HealthIndicator.class)
|
||||
|
|
@ -73,8 +70,7 @@ public class HealthIndicatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenHasDefaultsDisabledAndSingleIndicatorEnabledShouldCreateEnabledIndicator()
|
||||
throws Exception {
|
||||
public void runWhenHasDefaultsDisabledAndSingleIndicatorEnabledShouldCreateEnabledIndicator() {
|
||||
this.contextRunner.withUserConfiguration(CustomHealthIndicatorConfiguration.class)
|
||||
.withPropertyValues("management.health.defaults.enabled:false",
|
||||
"management.health.custom.enabled:true")
|
||||
|
|
@ -84,15 +80,14 @@ public class HealthIndicatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runShouldCreateOrderedHealthAggregator() throws Exception {
|
||||
public void runShouldCreateOrderedHealthAggregator() {
|
||||
this.contextRunner
|
||||
.run((context) -> assertThat(context).getBean(HealthAggregator.class)
|
||||
.isInstanceOf(OrderedHealthAggregator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenHasCustomOrderPropertyShouldCreateOrderedHealthAggregator()
|
||||
throws Exception {
|
||||
public void runWhenHasCustomOrderPropertyShouldCreateOrderedHealthAggregator() {
|
||||
this.contextRunner.withPropertyValues("management.health.status.order:UP,DOWN")
|
||||
.run((context) -> {
|
||||
OrderedHealthAggregator aggregator = context
|
||||
|
|
@ -106,8 +101,7 @@ public class HealthIndicatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenHasCustomHealthAggregatorShouldNotCreateOrderedHealthAggregator()
|
||||
throws Exception {
|
||||
public void runWhenHasCustomHealthAggregatorShouldNotCreateOrderedHealthAggregator() {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(CustomHealthAggregatorConfiguration.class)
|
||||
.run((context) -> assertThat(context).getBean(HealthAggregator.class)
|
||||
|
|
|
|||
|
|
@ -50,21 +50,20 @@ public class HealthWebEndpointReactiveManagementContextConfigurationTests {
|
|||
HealthWebEndpointManagementContextConfiguration.class);
|
||||
|
||||
@Test
|
||||
public void runShouldCreateExtensionBeans() throws Exception {
|
||||
public void runShouldCreateExtensionBeans() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.hasSingleBean(ReactiveHealthEndpointWebExtension.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenHealthEndpointIsDisabledShouldNotCreateExtensionBeans()
|
||||
throws Exception {
|
||||
public void runWhenHealthEndpointIsDisabledShouldNotCreateExtensionBeans() {
|
||||
this.contextRunner.withPropertyValues("management.endpoint.health.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(ReactiveHealthEndpointWebExtension.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWithCustomHealthMappingShouldMapStatusCode() throws Exception {
|
||||
public void runWithCustomHealthMappingShouldMapStatusCode() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.health.status.http-mapping.CUSTOM=500")
|
||||
.run((context) -> {
|
||||
|
|
|
|||
|
|
@ -43,21 +43,20 @@ public class HealthWebEndpointServletManagementContextConfigurationTests {
|
|||
HealthWebEndpointManagementContextConfiguration.class);
|
||||
|
||||
@Test
|
||||
public void runShouldCreateExtensionBeans() throws Exception {
|
||||
public void runShouldCreateExtensionBeans() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.hasSingleBean(HealthEndpointWebExtension.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenHealthEndpointIsDisabledShouldNotCreateExtensionBeans()
|
||||
throws Exception {
|
||||
public void runWhenHealthEndpointIsDisabledShouldNotCreateExtensionBeans() {
|
||||
this.contextRunner.withPropertyValues("management.endpoint.health.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(HealthEndpointWebExtension.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWithCustomHealthMappingShouldMapStatusCode() throws Exception {
|
||||
public void runWithCustomHealthMappingShouldMapStatusCode() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.health.status.http-mapping.CUSTOM=500")
|
||||
.run((context) -> {
|
||||
|
|
|
|||
|
|
@ -49,8 +49,7 @@ public class InfoEndpointAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean()
|
||||
throws Exception {
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.withPropertyValues("management.endpoint.info.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(InfoEndpoint.class));
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class WebFluxEndpointCorsIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void corsIsDisabledByDefault() throws Exception {
|
||||
public void corsIsDisabledByDefault() {
|
||||
WebTestClient client = createWebTestClient();
|
||||
System.out.println(new ConditionEvaluationReportMessage(
|
||||
this.context.getBean(ConditionEvaluationReport.class)));
|
||||
|
|
@ -106,7 +106,7 @@ public class WebFluxEndpointCorsIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void requestsWithDisallowedHeadersAreRejected() throws Exception {
|
||||
public void requestsWithDisallowedHeadersAreRejected() {
|
||||
TestPropertyValues
|
||||
.of("management.endpoints.web.cors.allowed-origins:spring.example.org")
|
||||
.applyTo(this.context);
|
||||
|
|
@ -120,7 +120,7 @@ public class WebFluxEndpointCorsIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void allowedHeadersCanBeConfigured() throws Exception {
|
||||
public void allowedHeadersCanBeConfigured() {
|
||||
TestPropertyValues
|
||||
.of("management.endpoints.web.cors.allowed-origins:spring.example.org",
|
||||
"management.endpoints.web.cors.allowed-headers:Alpha,Bravo")
|
||||
|
|
@ -136,7 +136,7 @@ public class WebFluxEndpointCorsIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void requestsWithDisallowedMethodsAreRejected() throws Exception {
|
||||
public void requestsWithDisallowedMethodsAreRejected() {
|
||||
TestPropertyValues
|
||||
.of("management.endpoints.web.cors.allowed-origins:spring.example.org")
|
||||
.applyTo(this.context);
|
||||
|
|
@ -149,7 +149,7 @@ public class WebFluxEndpointCorsIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void allowedMethodsCanBeConfigured() throws Exception {
|
||||
public void allowedMethodsCanBeConfigured() {
|
||||
TestPropertyValues
|
||||
.of("management.endpoints.web.cors.allowed-origins:spring.example.org",
|
||||
"management.endpoints.web.cors.allowed-methods:GET,HEAD")
|
||||
|
|
@ -190,7 +190,7 @@ public class WebFluxEndpointCorsIntegrationTests {
|
|||
.configureClient().baseUrl("https://spring.example.org").build();
|
||||
}
|
||||
|
||||
private WebTestClient.ResponseSpec performAcceptedCorsRequest(String url) throws Exception {
|
||||
private WebTestClient.ResponseSpec performAcceptedCorsRequest(String url) {
|
||||
return createWebTestClient()
|
||||
.options().uri(url)
|
||||
.header(HttpHeaders.ORIGIN, "spring.example.org")
|
||||
|
|
|
|||
|
|
@ -63,8 +63,7 @@ public class DataSourceHealthIndicatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenMultipleDataSourceBeansShouldCreateCompositeIndicator()
|
||||
throws Exception {
|
||||
public void runWhenMultipleDataSourceBeansShouldCreateCompositeIndicator() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class,
|
||||
DataSourceConfig.class).run((context) -> {
|
||||
assertThat(context).hasSingleBean(HealthIndicator.class);
|
||||
|
|
@ -76,7 +75,7 @@ public class DataSourceHealthIndicatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runShouldFilterRoutingDataSource() throws Exception {
|
||||
public void runShouldFilterRoutingDataSource() {
|
||||
this.contextRunner
|
||||
.withUserConfiguration(EmbeddedDataSourceConfiguration.class,
|
||||
RoutingDatasourceConfig.class)
|
||||
|
|
@ -101,7 +100,7 @@ public class DataSourceHealthIndicatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenDisabledShouldNotCreateIndicator() throws Exception {
|
||||
public void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
.withPropertyValues("management.health.db.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
|
|
|
|||
|
|
@ -41,14 +41,14 @@ public class JmsHealthIndicatorAutoConfigurationTests {
|
|||
HealthIndicatorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void runShouldCreateIndicator() throws Exception {
|
||||
public void runShouldCreateIndicator() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).hasSingleBean(JmsHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenDisabledShouldNotCreateIndicator() throws Exception {
|
||||
public void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.jms.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(LdapHealthIndicator.class)
|
||||
|
|
|
|||
|
|
@ -45,14 +45,14 @@ public class LdapHealthIndicatorAutoConfigurationTests {
|
|||
HealthIndicatorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void runShouldCreateIndicator() throws Exception {
|
||||
public void runShouldCreateIndicator() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).hasSingleBean(LdapHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenDisabledShouldNotCreateIndicator() throws Exception {
|
||||
public void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.ldap.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(LdapHealthIndicator.class)
|
||||
|
|
|
|||
|
|
@ -47,8 +47,7 @@ public class LiquibaseEndpointAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean()
|
||||
throws Exception {
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoint.liquibase.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
|
|
|
|||
|
|
@ -47,8 +47,7 @@ public class LoggersEndpointAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean()
|
||||
throws Exception {
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.withPropertyValues("management.endpoint.loggers.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(LoggersEndpoint.class));
|
||||
|
|
|
|||
|
|
@ -41,14 +41,14 @@ public class MailHealthIndicatorAutoConfigurationTests {
|
|||
.withPropertyValues("spring.mail.host:smtp.example.com");
|
||||
|
||||
@Test
|
||||
public void runShouldCreateIndicator() throws Exception {
|
||||
public void runShouldCreateIndicator() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).hasSingleBean(MailHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenDisabledShouldNotCreateIndicator() throws Exception {
|
||||
public void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.mail.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(MailHealthIndicator.class)
|
||||
|
|
|
|||
|
|
@ -36,13 +36,13 @@ public class HeapDumpWebEndpointAutoConfigurationTests {
|
|||
HeapDumpWebEndpointAutoConfiguration.class);
|
||||
|
||||
@Test
|
||||
public void runShouldCreateIndicator() throws Exception {
|
||||
public void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.hasSingleBean(HeapDumpWebEndpoint.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenDisabledShouldNotCreateIndicator() throws Exception {
|
||||
public void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoint.heapdump.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@ public class ThreadDumpEndpointAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean()
|
||||
throws Exception {
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoint.threaddump.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@ public class MongoHealthIndicatorAutoConfigurationTests {
|
|||
HealthIndicatorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void runShouldCreateIndicator() throws Exception {
|
||||
public void runShouldCreateIndicator() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).hasSingleBean(MongoHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenDisabledShouldNotCreateIndicator() throws Exception {
|
||||
public void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.mongo.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(MongoHealthIndicator.class)
|
||||
|
|
|
|||
|
|
@ -44,14 +44,14 @@ public class Neo4jHealthIndicatorAutoConfigurationTests {
|
|||
HealthIndicatorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void runShouldCreateIndicator() throws Exception {
|
||||
public void runShouldCreateIndicator() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).hasSingleBean(Neo4jHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenDisabledShouldNotCreateIndicator() throws Exception {
|
||||
public void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.neo4j.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(Neo4jHealthIndicator.class)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class RedisHealthIndicatorAutoConfigurationTests {
|
|||
HealthIndicatorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void runShouldCreateIndicator() throws Exception {
|
||||
public void runShouldCreateIndicator() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).hasSingleBean(RedisHealthIndicator.class)
|
||||
.doesNotHaveBean(RedisReactiveHealthIndicator.class)
|
||||
|
|
@ -54,7 +54,7 @@ public class RedisHealthIndicatorAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenDisabledShouldNotCreateIndicator() throws Exception {
|
||||
public void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.redis.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(RedisHealthIndicator.class)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class RedisReactiveHealthIndicatorConfigurationTests {
|
|||
HealthIndicatorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void runShouldCreateIndicator() throws Exception {
|
||||
public void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.hasSingleBean(RedisReactiveHealthIndicatorConfiguration.class)
|
||||
.doesNotHaveBean(RedisHealthIndicator.class)
|
||||
|
|
@ -49,7 +49,7 @@ public class RedisReactiveHealthIndicatorConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenDisabledShouldNotCreateIndicator() throws Exception {
|
||||
public void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.redis.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(RedisReactiveHealthIndicator.class)
|
||||
|
|
|
|||
|
|
@ -42,44 +42,44 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class EndpointRequestTests {
|
||||
|
||||
@Test
|
||||
public void toAnyEndpointShouldMatchEndpointPath() throws Exception {
|
||||
public void toAnyEndpointShouldMatchEndpointPath() {
|
||||
RequestMatcher matcher = EndpointRequest.toAnyEndpoint();
|
||||
assertMatcher(matcher).matches("/actuator/foo");
|
||||
assertMatcher(matcher).matches("/actuator/bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toAnyEndpointShouldNotMatchOtherPath() throws Exception {
|
||||
public void toAnyEndpointShouldNotMatchOtherPath() {
|
||||
RequestMatcher matcher = EndpointRequest.toAnyEndpoint();
|
||||
assertMatcher(matcher).doesNotMatch("/actuator/baz");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toEndpointClassShouldMatchEndpointPath() throws Exception {
|
||||
public void toEndpointClassShouldMatchEndpointPath() {
|
||||
RequestMatcher matcher = EndpointRequest.to(FooEndpoint.class);
|
||||
assertMatcher(matcher).matches("/actuator/foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toEndpointClassShouldNotMatchOtherPath() throws Exception {
|
||||
public void toEndpointClassShouldNotMatchOtherPath() {
|
||||
RequestMatcher matcher = EndpointRequest.to(FooEndpoint.class);
|
||||
assertMatcher(matcher).doesNotMatch("/actuator/bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toEndpointIdShouldMatchEndpointPath() throws Exception {
|
||||
public void toEndpointIdShouldMatchEndpointPath() {
|
||||
RequestMatcher matcher = EndpointRequest.to("foo");
|
||||
assertMatcher(matcher).matches("/actuator/foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toEndpointIdShouldNotMatchOtherPath() throws Exception {
|
||||
public void toEndpointIdShouldNotMatchOtherPath() {
|
||||
RequestMatcher matcher = EndpointRequest.to("foo");
|
||||
assertMatcher(matcher).doesNotMatch("/actuator/bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excludeByClassShouldNotMatchExcluded() throws Exception {
|
||||
public void excludeByClassShouldNotMatchExcluded() {
|
||||
RequestMatcher matcher = EndpointRequest.toAnyEndpoint()
|
||||
.excluding(FooEndpoint.class);
|
||||
assertMatcher(matcher).doesNotMatch("/actuator/foo");
|
||||
|
|
@ -87,7 +87,7 @@ public class EndpointRequestTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void excludeByIdShouldNotMatchExcluded() throws Exception {
|
||||
public void excludeByIdShouldNotMatchExcluded() {
|
||||
RequestMatcher matcher = EndpointRequest.toAnyEndpoint().excluding("foo");
|
||||
assertMatcher(matcher).doesNotMatch("/actuator/foo");
|
||||
assertMatcher(matcher).matches("/actuator/bar");
|
||||
|
|
|
|||
|
|
@ -47,8 +47,7 @@ public class SessionsEndpointAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean()
|
||||
throws Exception {
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||
this.contextRunner
|
||||
.withPropertyValues("management.endpoint.sessions.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
|
|
|
|||
|
|
@ -40,14 +40,14 @@ public class SolrHealthIndicatorAutoConfigurationTests {
|
|||
HealthIndicatorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void runShouldCreateIndicator() throws Exception {
|
||||
public void runShouldCreateIndicator() {
|
||||
this.contextRunner.run(
|
||||
(context) -> assertThat(context).hasSingleBean(SolrHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenDisabledShouldNotCreateIndicator() throws Exception {
|
||||
public void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.solr.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(SolrHealthIndicator.class)
|
||||
|
|
|
|||
|
|
@ -39,14 +39,14 @@ public class DiskSpaceHealthIndicatorAutoConfigurationTests {
|
|||
HealthIndicatorAutoConfiguration.class));
|
||||
|
||||
@Test
|
||||
public void runShouldCreateIndicator() throws Exception {
|
||||
public void runShouldCreateIndicator() {
|
||||
this.contextRunner.run((context) -> assertThat(context)
|
||||
.hasSingleBean(DiskSpaceHealthIndicator.class)
|
||||
.doesNotHaveBean(ApplicationHealthIndicator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runWhenDisabledShouldNotCreateIndicator() throws Exception {
|
||||
public void runWhenDisabledShouldNotCreateIndicator() {
|
||||
this.contextRunner.withPropertyValues("management.health.diskspace.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(DiskSpaceHealthIndicator.class)
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@ public class TraceEndpointAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean()
|
||||
throws Exception {
|
||||
public void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||
this.contextRunner.withPropertyValues("management.endpoint.trace.enabled:false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(TraceEndpoint.class));
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import static org.mockito.Mockito.mock;
|
|||
public class TraceRepositoryAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void configuresInMemoryTraceRepository() throws Exception {
|
||||
public void configuresInMemoryTraceRepository() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
TraceRepositoryAutoConfiguration.class);
|
||||
assertThat(context.getBean(InMemoryTraceRepository.class)).isNotNull();
|
||||
|
|
@ -43,7 +43,7 @@ public class TraceRepositoryAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void skipsIfRepositoryExists() throws Exception {
|
||||
public void skipsIfRepositoryExists() {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
|
||||
Config.class, TraceRepositoryAutoConfiguration.class);
|
||||
assertThat(context.getBeansOfType(InMemoryTraceRepository.class)).isEmpty();
|
||||
|
|
|
|||
|
|
@ -55,14 +55,14 @@ public class TraceWebFilterAutoConfigurationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void overrideTraceFilter() throws Exception {
|
||||
public void overrideTraceFilter() {
|
||||
load(CustomTraceFilterConfig.class);
|
||||
WebRequestTraceFilter filter = this.context.getBean(WebRequestTraceFilter.class);
|
||||
assertThat(filter).isInstanceOf(TestWebRequestTraceFilter.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void skipsFilterIfPropertyDisabled() throws Exception {
|
||||
public void skipsFilterIfPropertyDisabled() {
|
||||
load("management.trace.filter.enabled:false");
|
||||
assertThat(this.context.getBeansOfType(WebRequestTraceFilter.class).size())
|
||||
.isEqualTo(0);
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ public class ReactiveManagementContextFactoryTests {
|
|||
private AnnotationConfigReactiveWebServerApplicationContext parent = new AnnotationConfigReactiveWebServerApplicationContext();
|
||||
|
||||
@Test
|
||||
public void createManagementContextShouldCreateChildContextWithConfigClasses()
|
||||
throws Exception {
|
||||
public void createManagementContextShouldCreateChildContextWithConfigClasses() {
|
||||
this.parent.register(ParentConfiguration.class);
|
||||
this.parent.refresh();
|
||||
AnnotationConfigReactiveWebServerApplicationContext childContext = (AnnotationConfigReactiveWebServerApplicationContext) this.factory
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class ManagementContextConfigurationImportSelectorTests {
|
||||
|
||||
@Test
|
||||
public void selectImportsShouldOrderResult() throws Exception {
|
||||
public void selectImportsShouldOrderResult() {
|
||||
String[] imports = new TestManagementContextConfigurationsImportSelector(C.class,
|
||||
A.class, D.class, B.class).selectImports(
|
||||
new StandardAnnotationMetadata(EnableChildContext.class));
|
||||
|
|
@ -47,8 +47,7 @@ public class ManagementContextConfigurationImportSelectorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void selectImportsFiltersChildOnlyConfigurationWhenUsingSameContext()
|
||||
throws Exception {
|
||||
public void selectImportsFiltersChildOnlyConfigurationWhenUsingSameContext() {
|
||||
String[] imports = new TestManagementContextConfigurationsImportSelector(
|
||||
ChildOnly.class, SameOnly.class, A.class).selectImports(
|
||||
new StandardAnnotationMetadata(EnableSameContext.class));
|
||||
|
|
@ -57,8 +56,7 @@ public class ManagementContextConfigurationImportSelectorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void selectImportsFiltersSameOnlyConfigurationWhenUsingChildContext()
|
||||
throws Exception {
|
||||
public void selectImportsFiltersSameOnlyConfigurationWhenUsingChildContext() {
|
||||
String[] imports = new TestManagementContextConfigurationsImportSelector(
|
||||
ChildOnly.class, SameOnly.class, A.class).selectImports(
|
||||
new StandardAnnotationMetadata(EnableChildContext.class));
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class CompositeHandlerExceptionResolverTests {
|
|||
private MockHttpServletResponse response = new MockHttpServletResponse();
|
||||
|
||||
@Test
|
||||
public void resolverShouldDelegateToOtherResolversInContext() throws Exception {
|
||||
public void resolverShouldDelegateToOtherResolversInContext() {
|
||||
load(TestConfiguration.class);
|
||||
CompositeHandlerExceptionResolver resolver = (CompositeHandlerExceptionResolver) this.context
|
||||
.getBean(DispatcherServlet.HANDLER_EXCEPTION_RESOLVER_BEAN_NAME);
|
||||
|
|
@ -58,7 +58,7 @@ public class CompositeHandlerExceptionResolverTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void resolverShouldAddDefaultResolverIfNonePresent() throws Exception {
|
||||
public void resolverShouldAddDefaultResolverIfNonePresent() {
|
||||
load(BaseConfiguration.class);
|
||||
CompositeHandlerExceptionResolver resolver = (CompositeHandlerExceptionResolver) this.context
|
||||
.getBean(DispatcherServlet.HANDLER_EXCEPTION_RESOLVER_BEAN_NAME);
|
||||
|
|
|
|||
|
|
@ -63,14 +63,14 @@ public class RabbitHealthIndicatorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createWhenRabbitTemplateIsNullShouldThrowException() throws Exception {
|
||||
public void createWhenRabbitTemplateIsNullShouldThrowException() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("RabbitTemplate must not be null");
|
||||
new RabbitHealthIndicator(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthWhenConnectionSucceedsShouldReturnUpWithVersion() throws Exception {
|
||||
public void healthWhenConnectionSucceedsShouldReturnUpWithVersion() {
|
||||
Connection connection = mock(Connection.class);
|
||||
given(this.channel.getConnection()).willReturn(connection);
|
||||
given(connection.getServerProperties())
|
||||
|
|
@ -81,7 +81,7 @@ public class RabbitHealthIndicatorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void healthWhenConnectionFailsShouldReturnDown() throws Exception {
|
||||
public void healthWhenConnectionFailsShouldReturnDown() {
|
||||
given(this.channel.getConnection()).willThrow(new RuntimeException());
|
||||
Health health = new RabbitHealthIndicator(this.rabbitTemplate).health();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class AuditEventTests {
|
|||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void nowEvent() throws Exception {
|
||||
public void nowEvent() {
|
||||
AuditEvent event = new AuditEvent("phil", "UNKNOWN",
|
||||
Collections.singletonMap("a", (Object) "b"));
|
||||
assertThat(event.getData().get("a")).isEqualTo("b");
|
||||
|
|
@ -49,7 +49,7 @@ public class AuditEventTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void convertStringsToData() throws Exception {
|
||||
public void convertStringsToData() {
|
||||
AuditEvent event = new AuditEvent("phil", "UNKNOWN", "a=b", "c=d");
|
||||
assertThat(event.getData().get("a")).isEqualTo("b");
|
||||
assertThat(event.getData().get("c")).isEqualTo("d");
|
||||
|
|
@ -63,7 +63,7 @@ public class AuditEventTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void nullTimestamp() throws Exception {
|
||||
public void nullTimestamp() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Timestamp must not be null");
|
||||
new AuditEvent(null, "phil", "UNKNOWN",
|
||||
|
|
@ -71,7 +71,7 @@ public class AuditEventTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void nullType() throws Exception {
|
||||
public void nullType() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Type must not be null");
|
||||
new AuditEvent("phil", null, Collections.singletonMap("a", (Object) "b"));
|
||||
|
|
|
|||
|
|
@ -42,13 +42,13 @@ public class AuditEventsEndpointWebIntegrationTests {
|
|||
private static WebTestClient client;
|
||||
|
||||
@Test
|
||||
public void eventsWithoutParams() throws Exception {
|
||||
public void eventsWithoutParams() {
|
||||
client.get().uri((builder) -> builder.path("/actuator/auditevents").build())
|
||||
.exchange().expectStatus().isBadRequest();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void eventsWithDateAfter() throws Exception {
|
||||
public void eventsWithDateAfter() {
|
||||
client.get()
|
||||
.uri((builder) -> builder.path("/actuator/auditevents")
|
||||
.queryParam("after", "2016-11-01T13:00:00%2B00:00").build())
|
||||
|
|
@ -57,7 +57,7 @@ public class AuditEventsEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void eventsWithPrincipalAndDateAfter() throws Exception {
|
||||
public void eventsWithPrincipalAndDateAfter() {
|
||||
client.get()
|
||||
.uri((builder) -> builder.path("/actuator/auditevents")
|
||||
.queryParam("after", "2016-11-01T10:00:00%2B00:00")
|
||||
|
|
@ -68,7 +68,7 @@ public class AuditEventsEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void eventsWithPrincipalDateAfterAndType() throws Exception {
|
||||
public void eventsWithPrincipalDateAfterAndType() {
|
||||
client.get()
|
||||
.uri((builder) -> builder.path("/actuator/auditevents")
|
||||
.queryParam("after", "2016-11-01T10:00:00%2B00:00")
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class InMemoryAuditEventRepositoryTests {
|
|||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void lessThanCapacity() throws Exception {
|
||||
public void lessThanCapacity() {
|
||||
InMemoryAuditEventRepository repository = new InMemoryAuditEventRepository();
|
||||
repository.add(new AuditEvent("dave", "a"));
|
||||
repository.add(new AuditEvent("dave", "b"));
|
||||
|
|
@ -52,7 +52,7 @@ public class InMemoryAuditEventRepositoryTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void capacity() throws Exception {
|
||||
public void capacity() {
|
||||
InMemoryAuditEventRepository repository = new InMemoryAuditEventRepository(2);
|
||||
repository.add(new AuditEvent("dave", "a"));
|
||||
repository.add(new AuditEvent("dave", "b"));
|
||||
|
|
@ -64,7 +64,7 @@ public class InMemoryAuditEventRepositoryTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void addNullAuditEvent() throws Exception {
|
||||
public void addNullAuditEvent() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("AuditEvent must not be null");
|
||||
InMemoryAuditEventRepository repository = new InMemoryAuditEventRepository();
|
||||
|
|
@ -72,7 +72,7 @@ public class InMemoryAuditEventRepositoryTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void findByPrincipal() throws Exception {
|
||||
public void findByPrincipal() {
|
||||
InMemoryAuditEventRepository repository = new InMemoryAuditEventRepository();
|
||||
repository.add(new AuditEvent("dave", "a"));
|
||||
repository.add(new AuditEvent("phil", "b"));
|
||||
|
|
@ -85,7 +85,7 @@ public class InMemoryAuditEventRepositoryTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void findByPrincipalAndType() throws Exception {
|
||||
public void findByPrincipalAndType() {
|
||||
InMemoryAuditEventRepository repository = new InMemoryAuditEventRepository();
|
||||
repository.add(new AuditEvent("dave", "a"));
|
||||
repository.add(new AuditEvent("phil", "b"));
|
||||
|
|
@ -98,7 +98,7 @@ public class InMemoryAuditEventRepositoryTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void findByDate() throws Exception {
|
||||
public void findByDate() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(2000, 1, 1, 0, 0, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class ShutdownEndpointTests {
|
||||
|
||||
@Test
|
||||
public void shutdown() throws Exception {
|
||||
public void shutdown() {
|
||||
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(EndpointConfig.class);
|
||||
contextRunner.run((context) -> {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class ConfigurationPropertiesReportEndpointParentTests {
|
||||
|
||||
@Test
|
||||
public void configurationPropertiesClass() throws Exception {
|
||||
public void configurationPropertiesClass() {
|
||||
new ApplicationContextRunner().withUserConfiguration(Parent.class)
|
||||
.run((parent) -> {
|
||||
new ApplicationContextRunner()
|
||||
|
|
@ -56,7 +56,7 @@ public class ConfigurationPropertiesReportEndpointParentTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void configurationPropertiesBeanMethod() throws Exception {
|
||||
public void configurationPropertiesBeanMethod() {
|
||||
new ApplicationContextRunner().withUserConfiguration(Parent.class)
|
||||
.run((parent) -> {
|
||||
new ApplicationContextRunner()
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class ConfigurationPropertiesReportEndpointProxyTests {
|
||||
|
||||
@Test
|
||||
public void testWithProxyClass() throws Exception {
|
||||
public void testWithProxyClass() {
|
||||
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(Config.class, SqlExecutor.class);
|
||||
contextRunner.run((context) -> {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.entry;
|
|||
public class ConfigurationPropertiesReportEndpointSerializationTests {
|
||||
|
||||
@Test
|
||||
public void testNaming() throws Exception {
|
||||
public void testNaming() {
|
||||
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(FooConfig.class)
|
||||
.withPropertyValues("foo.name:foo");
|
||||
|
|
@ -69,7 +69,7 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testNestedNaming() throws Exception {
|
||||
public void testNestedNaming() {
|
||||
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(FooConfig.class)
|
||||
.withPropertyValues("foo.bar.name:foo");
|
||||
|
|
@ -90,7 +90,7 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSelfReferentialProperty() throws Exception {
|
||||
public void testSelfReferentialProperty() {
|
||||
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(SelfReferentialConfig.class)
|
||||
.withPropertyValues("foo.name:foo");
|
||||
|
|
@ -133,7 +133,7 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testMap() throws Exception {
|
||||
public void testMap() {
|
||||
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(MapConfig.class)
|
||||
.withPropertyValues("foo.map.name:foo");
|
||||
|
|
@ -155,7 +155,7 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyMapIsNotAdded() throws Exception {
|
||||
public void testEmptyMapIsNotAdded() {
|
||||
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(MapConfig.class);
|
||||
contextRunner.run((context) -> {
|
||||
|
|
@ -175,7 +175,7 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testList() throws Exception {
|
||||
public void testList() {
|
||||
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(ListConfig.class)
|
||||
.withPropertyValues("foo.list[0]:foo");
|
||||
|
|
@ -195,7 +195,7 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testInetAddress() throws Exception {
|
||||
public void testInetAddress() {
|
||||
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(AddressedConfig.class)
|
||||
.withPropertyValues("foo.address:192.168.1.10");
|
||||
|
|
@ -216,7 +216,7 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testInitializedMapAndList() throws Exception {
|
||||
public void testInitializedMapAndList() {
|
||||
ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withUserConfiguration(InitializedMapAndListPropertiesConfig.class)
|
||||
.withPropertyValues("foo.map.entryOne:true", "foo.list[0]:abc");
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class ConfigurationPropertiesReportEndpointTests {
|
||||
|
||||
@Test
|
||||
public void configurationPropertiesAreReturned() throws Exception {
|
||||
public void configurationPropertiesAreReturned() {
|
||||
load((context, properties) -> {
|
||||
assertThat(properties.getContextId()).isEqualTo(context.getId());
|
||||
assertThat(properties.getBeans().size()).isGreaterThan(0);
|
||||
|
|
@ -69,7 +69,7 @@ public class ConfigurationPropertiesReportEndpointTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void defaultKeySanitization() throws Exception {
|
||||
public void defaultKeySanitization() {
|
||||
load((context, properties) -> {
|
||||
Map<String, Object> nestedProperties = properties.getBeans()
|
||||
.get("testProperties").getProperties();
|
||||
|
|
@ -80,7 +80,7 @@ public class ConfigurationPropertiesReportEndpointTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void customKeySanitization() throws Exception {
|
||||
public void customKeySanitization() {
|
||||
load("property", (context, properties) -> {
|
||||
Map<String, Object> nestedProperties = properties.getBeans()
|
||||
.get("testProperties").getProperties();
|
||||
|
|
@ -91,7 +91,7 @@ public class ConfigurationPropertiesReportEndpointTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void customPatternKeySanitization() throws Exception {
|
||||
public void customPatternKeySanitization() {
|
||||
load(".*pass.*", (context, properties) -> {
|
||||
Map<String, Object> nestedProperties = properties.getBeans()
|
||||
.get("testProperties").getProperties();
|
||||
|
|
@ -103,7 +103,7 @@ public class ConfigurationPropertiesReportEndpointTests {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void keySanitizationWithCustomPatternUsingCompositeKeys() throws Exception {
|
||||
public void keySanitizationWithCustomPatternUsingCompositeKeys() {
|
||||
// gh-4415
|
||||
load(Arrays.asList(".*\\.secrets\\..*", ".*\\.hidden\\..*"),
|
||||
(context, properties) -> {
|
||||
|
|
@ -121,7 +121,7 @@ public class ConfigurationPropertiesReportEndpointTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void mixedBoolean() throws Exception {
|
||||
public void mixedBoolean() {
|
||||
load((context, properties) -> {
|
||||
Map<String, Object> nestedProperties = properties.getBeans()
|
||||
.get("testProperties").getProperties();
|
||||
|
|
@ -131,7 +131,7 @@ public class ConfigurationPropertiesReportEndpointTests {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void listsAreSanitized() throws Exception {
|
||||
public void listsAreSanitized() {
|
||||
load((context, properties) -> {
|
||||
Map<String, Object> nestedProperties = properties.getBeans()
|
||||
.get("testProperties").getProperties();
|
||||
|
|
@ -145,7 +145,7 @@ public class ConfigurationPropertiesReportEndpointTests {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void listsOfListsAreSanitized() throws Exception {
|
||||
public void listsOfListsAreSanitized() {
|
||||
load((context, properties) -> {
|
||||
Map<String, Object> nestedProperties = properties.getBeans()
|
||||
.get("testProperties").getProperties();
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class ElasticsearchHealthIndicatorTests {
|
|||
private ElasticsearchHealthIndicator indicator;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
given(this.client.admin()).willReturn(this.admin);
|
||||
given(this.admin.cluster()).willReturn(this.cluster);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class NamePatternFilterTests {
|
||||
|
||||
@Test
|
||||
public void nonRegex() throws Exception {
|
||||
public void nonRegex() {
|
||||
MockNamePatternFilter filter = new MockNamePatternFilter();
|
||||
assertThat(filter.getResults("not.a.regex")).containsEntry("not.a.regex",
|
||||
"not.a.regex");
|
||||
|
|
@ -40,7 +40,7 @@ public class NamePatternFilterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void nonRegexThatContainsRegexPart() throws Exception {
|
||||
public void nonRegexThatContainsRegexPart() {
|
||||
MockNamePatternFilter filter = new MockNamePatternFilter();
|
||||
assertThat(filter.getResults("*")).containsEntry("*", "*");
|
||||
assertThat(filter.isGetNamesCalled()).isFalse();
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class SanitizerTests {
|
||||
|
||||
@Test
|
||||
public void defaults() throws Exception {
|
||||
public void defaults() {
|
||||
Sanitizer sanitizer = new Sanitizer();
|
||||
assertThat(sanitizer.sanitize("password", "secret")).isEqualTo("******");
|
||||
assertThat(sanitizer.sanitize("my-password", "secret")).isEqualTo("******");
|
||||
|
|
@ -42,7 +42,7 @@ public class SanitizerTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void regex() throws Exception {
|
||||
public void regex() {
|
||||
Sanitizer sanitizer = new Sanitizer(".*lock.*");
|
||||
assertThat(sanitizer.sanitize("verylOCkish", "secret")).isEqualTo("******");
|
||||
assertThat(sanitizer.sanitize("veryokish", "secret")).isEqualTo("secret");
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ public class AnnotationEndpointDiscovererTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void specializedEndpointsAreFilteredFromRegular() throws Exception {
|
||||
public void specializedEndpointsAreFilteredFromRegular() {
|
||||
load(TestEndpointsConfiguration.class, (context) -> {
|
||||
Map<String, EndpointInfo<TestEndpointOperation>> endpoints = mapEndpoints(
|
||||
new TestAnnotationEndpointDiscoverer(context).discoverEndpoints());
|
||||
|
|
@ -202,7 +202,7 @@ public class AnnotationEndpointDiscovererTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void specializedEndpointsAreNotFilteredFromSpecialized() throws Exception {
|
||||
public void specializedEndpointsAreNotFilteredFromSpecialized() {
|
||||
load(TestEndpointsConfiguration.class, (context) -> {
|
||||
Map<String, EndpointInfo<SpecializedTestEndpointOperation>> endpoints = mapEndpoints(
|
||||
new SpecializedTestAnnotationEndpointDiscoverer(context)
|
||||
|
|
@ -212,7 +212,7 @@ public class AnnotationEndpointDiscovererTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void extensionsAreApplied() throws Exception {
|
||||
public void extensionsAreApplied() {
|
||||
load(TestEndpointsConfiguration.class, (context) -> {
|
||||
Map<String, EndpointInfo<SpecializedTestEndpointOperation>> endpoints = mapEndpoints(
|
||||
new SpecializedTestAnnotationEndpointDiscoverer(context)
|
||||
|
|
@ -225,7 +225,7 @@ public class AnnotationEndpointDiscovererTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void filtersAreApplied() throws Exception {
|
||||
public void filtersAreApplied() {
|
||||
load(TestEndpointsConfiguration.class, (context) -> {
|
||||
EndpointFilter<SpecializedTestEndpointOperation> filter = (info,
|
||||
discoverer) -> !(info.getId().equals("specialized"));
|
||||
|
|
|
|||
|
|
@ -58,14 +58,14 @@ public class CachingOperationInvokerAdvisorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void applyWhenOperationIsNotReadShouldNotAddAdvise() throws Exception {
|
||||
public void applyWhenOperationIsNotReadShouldNotAddAdvise() {
|
||||
OperationMethodInfo info = mockInfo(OperationType.WRITE, "get");
|
||||
OperationInvoker advised = this.advisor.apply("foo", info, this.invoker);
|
||||
assertThat(advised).isSameAs(this.invoker);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applyWhenHasParametersShouldNotAddAdvise() throws Exception {
|
||||
public void applyWhenHasParametersShouldNotAddAdvise() {
|
||||
OperationMethodInfo info = mockInfo(OperationType.READ, "getWithParameter",
|
||||
String.class);
|
||||
OperationInvoker advised = this.advisor.apply("foo", info, this.invoker);
|
||||
|
|
@ -73,7 +73,7 @@ public class CachingOperationInvokerAdvisorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void applyWhenTimeToLiveReturnsNullShouldNotAddAdvise() throws Exception {
|
||||
public void applyWhenTimeToLiveReturnsNullShouldNotAddAdvise() {
|
||||
OperationMethodInfo info = mockInfo(OperationType.READ, "get");
|
||||
given(this.timeToLive.apply(any())).willReturn(null);
|
||||
OperationInvoker advised = this.advisor.apply("foo", info, this.invoker);
|
||||
|
|
@ -82,7 +82,7 @@ public class CachingOperationInvokerAdvisorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void applyWhenTimeToLiveIsZeroShouldNotAddAdvise() throws Exception {
|
||||
public void applyWhenTimeToLiveIsZeroShouldNotAddAdvise() {
|
||||
OperationMethodInfo info = mockInfo(OperationType.READ, "get");
|
||||
given(this.timeToLive.apply(any())).willReturn(0L);
|
||||
OperationInvoker advised = this.advisor.apply("foo", info, this.invoker);
|
||||
|
|
@ -91,7 +91,7 @@ public class CachingOperationInvokerAdvisorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void applyShouldAddCacheAdvise() throws Exception {
|
||||
public void applyShouldAddCacheAdvise() {
|
||||
OperationMethodInfo info = mockInfo(OperationType.READ, "get");
|
||||
given(this.timeToLive.apply(any())).willReturn(100L);
|
||||
OperationInvoker advised = this.advisor.apply("foo", info, this.invoker);
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class ConversionServiceParameterMapperTests {
|
|||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void mapParameterShouldDelegateToConversionService() throws Exception {
|
||||
public void mapParameterShouldDelegateToConversionService() {
|
||||
DefaultFormattingConversionService conversionService = spy(
|
||||
new DefaultFormattingConversionService());
|
||||
ConversionServiceParameterMapper mapper = new ConversionServiceParameterMapper(
|
||||
|
|
@ -57,8 +57,7 @@ public class ConversionServiceParameterMapperTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void mapParameterWhenConversionServiceFailsShouldThrowParameterMappingException()
|
||||
throws Exception {
|
||||
public void mapParameterWhenConversionServiceFailsShouldThrowParameterMappingException() {
|
||||
ConversionService conversionService = mock(ConversionService.class);
|
||||
RuntimeException error = new RuntimeException();
|
||||
given(conversionService.convert(any(), any())).willThrow(error);
|
||||
|
|
@ -76,15 +75,14 @@ public class ConversionServiceParameterMapperTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createShouldRegisterIsoOffsetDateTimeConverter() throws Exception {
|
||||
public void createShouldRegisterIsoOffsetDateTimeConverter() {
|
||||
ConversionServiceParameterMapper mapper = new ConversionServiceParameterMapper();
|
||||
Date mapped = mapper.mapParameter("2011-12-03T10:15:30+01:00", Date.class);
|
||||
assertThat(mapped).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createWithConversionServiceShouldNotRegisterIsoOffsetDateTimeConverter()
|
||||
throws Exception {
|
||||
public void createWithConversionServiceShouldNotRegisterIsoOffsetDateTimeConverter() {
|
||||
ConversionService conversionService = new DefaultConversionService();
|
||||
ConversionServiceParameterMapper mapper = new ConversionServiceParameterMapper(
|
||||
conversionService);
|
||||
|
|
|
|||
|
|
@ -32,14 +32,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class IsoOffsetDateTimeConverterTests {
|
||||
|
||||
@Test
|
||||
public void convertShouldConvertIsoDate() throws Exception {
|
||||
public void convertShouldConvertIsoDate() {
|
||||
IsoOffsetDateTimeConverter converter = new IsoOffsetDateTimeConverter();
|
||||
Date date = converter.convert("2011-12-03T10:15:30+01:00");
|
||||
assertThat(date).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerConverterShouldRegister() throws Exception {
|
||||
public void registerConverterShouldRegister() {
|
||||
DefaultConversionService service = new DefaultConversionService();
|
||||
IsoOffsetDateTimeConverter.registerConverter(service);
|
||||
Date date = service.convert("2011-12-03T10:15:30+01:00", Date.class);
|
||||
|
|
|
|||
|
|
@ -266,8 +266,7 @@ public class EndpointMBeanTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void invokeWithParameterMappingExceptionMapsToIllegalArgumentException()
|
||||
throws Exception {
|
||||
public void invokeWithParameterMappingExceptionMapsToIllegalArgumentException() {
|
||||
load(FooEndpoint.class, (discoverer) -> {
|
||||
ObjectName objectName = registerEndpoint(discoverer, "foo");
|
||||
try {
|
||||
|
|
@ -285,8 +284,7 @@ public class EndpointMBeanTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void invokeWithMissingRequiredParameterExceptionMapsToIllegalArgumentException()
|
||||
throws Exception {
|
||||
public void invokeWithMissingRequiredParameterExceptionMapsToIllegalArgumentException() {
|
||||
load(RequiredParametersEndpoint.class, (discoverer) -> {
|
||||
ObjectName objectName = registerEndpoint(discoverer, "requiredparameters");
|
||||
try {
|
||||
|
|
@ -304,7 +302,7 @@ public class EndpointMBeanTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void invokeWithMissingNullableParameter() throws Exception {
|
||||
public void invokeWithMissingNullableParameter() {
|
||||
load(RequiredParametersEndpoint.class, (discoverer) -> {
|
||||
ObjectName objectName = registerEndpoint(discoverer, "requiredparameters");
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -273,14 +273,13 @@ public abstract class AbstractWebEndpointIntegrationTests<T extends Configurable
|
|||
}
|
||||
|
||||
@Test
|
||||
public void readOperationWithMissingRequiredParametersReturnsBadRequestResponse()
|
||||
throws Exception {
|
||||
public void readOperationWithMissingRequiredParametersReturnsBadRequestResponse() {
|
||||
load(RequiredParameterEndpointConfiguration.class, (client) -> client.get()
|
||||
.uri("/requiredparameters").exchange().expectStatus().isBadRequest());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void readOperationWithMissingNullableParametersIsOk() throws Exception {
|
||||
public void readOperationWithMissingNullableParametersIsOk() {
|
||||
load(RequiredParameterEndpointConfiguration.class, (client) -> client.get()
|
||||
.uri("/requiredparameters?foo=hello").exchange().expectStatus().isOk());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,20 +45,20 @@ public class EnvironmentEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void home() throws Exception {
|
||||
public void home() {
|
||||
client.get().uri("/actuator/env").exchange().expectStatus().isOk().expectBody()
|
||||
.jsonPath("propertySources[?(@.name=='systemProperties')]").exists();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sub() throws Exception {
|
||||
public void sub() {
|
||||
client.get().uri("/actuator/env/foo").exchange().expectStatus().isOk()
|
||||
.expectBody().jsonPath("property.source").isEqualTo("test")
|
||||
.jsonPath("property.value").isEqualTo("bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void regex() throws Exception {
|
||||
public void regex() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("food", null);
|
||||
EnvironmentEndpointWebIntegrationTests.context.getEnvironment()
|
||||
|
|
@ -69,8 +69,7 @@ public class EnvironmentEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty()
|
||||
throws Exception {
|
||||
public void nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("my.foo", "${my.bar}");
|
||||
context.getEnvironment().getPropertySources()
|
||||
|
|
@ -82,7 +81,7 @@ public class EnvironmentEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void nestedPathWithSensitivePlaceholderShouldSanitize() throws Exception {
|
||||
public void nestedPathWithSensitivePlaceholderShouldSanitize() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("my.foo", "${my.password}");
|
||||
map.put("my.password", "hello");
|
||||
|
|
@ -94,7 +93,7 @@ public class EnvironmentEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void nestedPathForUnknownKeyShouldReturn404AndBody() throws Exception {
|
||||
public void nestedPathForUnknownKeyShouldReturn404AndBody() {
|
||||
client.get().uri("/actuator/env/this.does.not.exist").exchange().expectStatus()
|
||||
.isNotFound().expectBody().jsonPath("property").doesNotExist()
|
||||
.jsonPath("propertySources[?(@.name=='test')]").exists()
|
||||
|
|
@ -103,8 +102,7 @@ public class EnvironmentEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void nestedPathMatchedByRegexWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty()
|
||||
throws Exception {
|
||||
public void nestedPathMatchedByRegexWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("my.foo", "${my.bar}");
|
||||
context.getEnvironment().getPropertySources()
|
||||
|
|
@ -117,8 +115,7 @@ public class EnvironmentEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void nestedPathMatchedByRegexWithSensitivePlaceholderShouldSanitize()
|
||||
throws Exception {
|
||||
public void nestedPathMatchedByRegexWithSensitivePlaceholderShouldSanitize() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("my.foo", "${my.password}");
|
||||
map.put("my.password", "hello");
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class FlywayEndpointTests {
|
||||
|
||||
@Test
|
||||
public void flywayReportIsProduced() throws Exception {
|
||||
public void flywayReportIsProduced() {
|
||||
new ApplicationContextRunner().withUserConfiguration(Config.class)
|
||||
.run((context) -> assertThat(
|
||||
context.getBean(FlywayEndpoint.class).flywayReports())
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class ApplicationHealthIndicatorTests {
|
||||
|
||||
@Test
|
||||
public void indicatesUp() throws Exception {
|
||||
public void indicatesUp() {
|
||||
ApplicationHealthIndicator healthIndicator = new ApplicationHealthIndicator();
|
||||
assertThat(healthIndicator.health().getStatus()).isEqualTo(Status.UP);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class CompositeHealthIndicatorFactoryTests {
|
||||
|
||||
@Test
|
||||
public void upAndUpIsAggregatedToUp() throws Exception {
|
||||
public void upAndUpIsAggregatedToUp() {
|
||||
Map<String, HealthIndicator> healthIndicators = new HashMap<>();
|
||||
healthIndicators.put("up", () -> new Health.Builder().status(Status.UP).build());
|
||||
healthIndicators.put("upAgain",
|
||||
|
|
@ -43,7 +43,7 @@ public class CompositeHealthIndicatorFactoryTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void upAndDownIsAggregatedToDown() throws Exception {
|
||||
public void upAndDownIsAggregatedToDown() {
|
||||
Map<String, HealthIndicator> healthIndicators = new HashMap<>();
|
||||
healthIndicators.put("up", () -> new Health.Builder().status(Status.UP).build());
|
||||
healthIndicators.put("down",
|
||||
|
|
@ -53,7 +53,7 @@ public class CompositeHealthIndicatorFactoryTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void unknownStatusMapsToUnknown() throws Exception {
|
||||
public void unknownStatusMapsToUnknown() {
|
||||
Map<String, HealthIndicator> healthIndicators = new HashMap<>();
|
||||
healthIndicators.put("status", () -> new Health.Builder().status("FINE").build());
|
||||
HealthIndicator healthIndicator = createHealthIndicator(healthIndicators);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class CompositeHealthIndicatorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createWithIndicators() throws Exception {
|
||||
public void createWithIndicators() {
|
||||
Map<String, HealthIndicator> indicators = new HashMap<>();
|
||||
indicators.put("one", this.one);
|
||||
indicators.put("two", this.two);
|
||||
|
|
@ -77,7 +77,7 @@ public class CompositeHealthIndicatorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createWithIndicatorsAndAdd() throws Exception {
|
||||
public void createWithIndicatorsAndAdd() {
|
||||
Map<String, HealthIndicator> indicators = new HashMap<>();
|
||||
indicators.put("one", this.one);
|
||||
indicators.put("two", this.two);
|
||||
|
|
@ -95,7 +95,7 @@ public class CompositeHealthIndicatorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void createWithoutAndAdd() throws Exception {
|
||||
public void createWithoutAndAdd() {
|
||||
CompositeHealthIndicator composite = new CompositeHealthIndicator(
|
||||
this.healthAggregator);
|
||||
composite.addHealthIndicator("one", this.one);
|
||||
|
|
|
|||
|
|
@ -42,14 +42,14 @@ public class HealthEndpointWebIntegrationTests {
|
|||
private static ConfigurableApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void whenHealthIsUp200ResponseIsReturned() throws Exception {
|
||||
public void whenHealthIsUp200ResponseIsReturned() {
|
||||
client.get().uri("/actuator/health").exchange().expectStatus().isOk().expectBody()
|
||||
.jsonPath("status").isEqualTo("UP").jsonPath("details.alpha.status")
|
||||
.isEqualTo("UP").jsonPath("details.bravo.status").isEqualTo("UP");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenHealthIsDown503ResponseIsReturned() throws Exception {
|
||||
public void whenHealthIsDown503ResponseIsReturned() {
|
||||
context.getBean("alphaHealthIndicator", TestHealthIndicator.class)
|
||||
.setHealth(Health.down().build());
|
||||
client.get().uri("/actuator/health").exchange().expectStatus()
|
||||
|
|
|
|||
|
|
@ -35,21 +35,21 @@ public class HealthTests {
|
|||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void statusMustNotBeNull() throws Exception {
|
||||
public void statusMustNotBeNull() {
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage("Status must not be null");
|
||||
new Health.Builder(null, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createWithStatus() throws Exception {
|
||||
public void createWithStatus() {
|
||||
Health health = Health.status(Status.UP).build();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(health.getDetails()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createWithDetails() throws Exception {
|
||||
public void createWithDetails() {
|
||||
Health health = new Health.Builder(Status.UP, Collections.singletonMap("a", "b"))
|
||||
.build();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
|
|
@ -57,7 +57,7 @@ public class HealthTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void equalsAndHashCode() throws Exception {
|
||||
public void equalsAndHashCode() {
|
||||
Health h1 = new Health.Builder(Status.UP, Collections.singletonMap("a", "b"))
|
||||
.build();
|
||||
Health h2 = new Health.Builder(Status.UP, Collections.singletonMap("a", "b"))
|
||||
|
|
@ -72,7 +72,7 @@ public class HealthTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void withException() throws Exception {
|
||||
public void withException() {
|
||||
RuntimeException ex = new RuntimeException("bang");
|
||||
Health health = new Health.Builder(Status.UP, Collections.singletonMap("a", "b"))
|
||||
.withException(ex).build();
|
||||
|
|
@ -82,7 +82,7 @@ public class HealthTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void withDetails() throws Exception {
|
||||
public void withDetails() {
|
||||
Health health = new Health.Builder(Status.UP, Collections.singletonMap("a", "b"))
|
||||
.withDetail("c", "d").build();
|
||||
assertThat(health.getDetails().get("a")).isEqualTo("b");
|
||||
|
|
@ -90,35 +90,35 @@ public class HealthTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void unknownWithDetails() throws Exception {
|
||||
public void unknownWithDetails() {
|
||||
Health health = new Health.Builder().unknown().withDetail("a", "b").build();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
|
||||
assertThat(health.getDetails().get("a")).isEqualTo("b");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unknown() throws Exception {
|
||||
public void unknown() {
|
||||
Health health = new Health.Builder().unknown().build();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
|
||||
assertThat(health.getDetails()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void upWithDetails() throws Exception {
|
||||
public void upWithDetails() {
|
||||
Health health = new Health.Builder().up().withDetail("a", "b").build();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(health.getDetails().get("a")).isEqualTo("b");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void up() throws Exception {
|
||||
public void up() {
|
||||
Health health = new Health.Builder().up().build();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(health.getDetails()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void downWithException() throws Exception {
|
||||
public void downWithException() {
|
||||
RuntimeException ex = new RuntimeException("bang");
|
||||
Health health = Health.down(ex).build();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||
|
|
@ -127,28 +127,28 @@ public class HealthTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void down() throws Exception {
|
||||
public void down() {
|
||||
Health health = Health.down().build();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.DOWN);
|
||||
assertThat(health.getDetails()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void outOfService() throws Exception {
|
||||
public void outOfService() {
|
||||
Health health = Health.outOfService().build();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.OUT_OF_SERVICE);
|
||||
assertThat(health.getDetails()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statusCode() throws Exception {
|
||||
public void statusCode() {
|
||||
Health health = Health.status("UP").build();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(health.getDetails()).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void status() throws Exception {
|
||||
public void status() {
|
||||
Health health = Health.status(Status.UP).build();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
assertThat(health.getDetails()).isEmpty();
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class EnvironmentInfoContributorTests {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void propertiesFromEnvironmentShouldBindCorrectly() throws Exception {
|
||||
public void propertiesFromEnvironmentShouldBindCorrectly() {
|
||||
TestPropertyValues.of("INFO_ENVIRONMENT_FOO=green").applyTo(this.environment,
|
||||
Type.SYSTEM_ENVIRONMENT);
|
||||
Info actual = contributeFrom(this.environment);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class InfoEndpointWebIntegrationTests {
|
|||
private static WebTestClient client;
|
||||
|
||||
@Test
|
||||
public void info() throws Exception {
|
||||
public void info() {
|
||||
client.get().uri("/actuator/info").accept(MediaType.APPLICATION_JSON).exchange()
|
||||
.expectStatus().isOk().expectBody().jsonPath("beanName1.key11")
|
||||
.isEqualTo("value11").jsonPath("beanName1.key12").isEqualTo("value12")
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class LiquibaseEndpointTests {
|
|||
.withPropertyValues("spring.datasource.generate-unique-name=true");
|
||||
|
||||
@Test
|
||||
public void liquibaseReportIsReturned() throws Exception {
|
||||
public void liquibaseReportIsReturned() {
|
||||
this.contextRunner.withUserConfiguration(Config.class)
|
||||
.run((context) -> assertThat(
|
||||
context.getBean(LiquibaseEndpoint.class).liquibaseReports())
|
||||
|
|
@ -53,7 +53,7 @@ public class LiquibaseEndpointTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void invokeWithCustomSchema() throws Exception {
|
||||
public void invokeWithCustomSchema() {
|
||||
this.contextRunner.withUserConfiguration(Config.class)
|
||||
.withPropertyValues("spring.liquibase.default-schema=CUSTOMSCHEMA",
|
||||
"spring.datasource.schema=classpath:/db/create-custom-schema.sql")
|
||||
|
|
|
|||
|
|
@ -57,12 +57,12 @@ public class LogFileWebEndpointTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void nullResponseWithoutLogFile() throws Exception {
|
||||
public void nullResponseWithoutLogFile() {
|
||||
assertThat(this.endpoint.logFile()).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullResponseWithMissingLogFile() throws Exception {
|
||||
public void nullResponseWithMissingLogFile() {
|
||||
this.environment.setProperty("logging.file", "no_test.log");
|
||||
assertThat(this.endpoint.logFile()).isNull();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,12 +59,12 @@ public class LogFileWebEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getRequestProduces404ResponseWhenLogFileNotFound() throws Exception {
|
||||
public void getRequestProduces404ResponseWhenLogFileNotFound() {
|
||||
client.get().uri("/actuator/logfile").exchange().expectStatus().isNotFound();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRequestProducesResponseWithLogFile() throws Exception {
|
||||
public void getRequestProducesResponseWithLogFile() {
|
||||
TestPropertyValues.of("logging.file:" + this.logFile.getAbsolutePath())
|
||||
.applyTo(context);
|
||||
client.get().uri("/actuator/logfile").exchange().expectStatus().isOk()
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ public class LoggersEndpointTests {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void loggersShouldReturnLoggerConfigurations() throws Exception {
|
||||
public void loggersShouldReturnLoggerConfigurations() {
|
||||
given(this.loggingSystem.getLoggerConfigurations()).willReturn(Collections
|
||||
.singletonList(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG)));
|
||||
given(this.loggingSystem.getSupportedLogLevels())
|
||||
|
|
@ -62,7 +62,7 @@ public class LoggersEndpointTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void loggerLevelsWhenNameSpecifiedShouldReturnLevels() throws Exception {
|
||||
public void loggerLevelsWhenNameSpecifiedShouldReturnLevels() {
|
||||
given(this.loggingSystem.getLoggerConfiguration("ROOT"))
|
||||
.willReturn(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG));
|
||||
LoggerLevels levels = new LoggersEndpoint(this.loggingSystem)
|
||||
|
|
@ -72,7 +72,7 @@ public class LoggersEndpointTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void configureLogLevelShouldSetLevelOnLoggingSystem() throws Exception {
|
||||
public void configureLogLevelShouldSetLevelOnLoggingSystem() {
|
||||
new LoggersEndpoint(this.loggingSystem).configureLogLevel("ROOT", LogLevel.DEBUG);
|
||||
verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public class LoggersEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getLoggerShouldReturnAllLoggerConfigurations() throws Exception {
|
||||
public void getLoggerShouldReturnAllLoggerConfigurations() {
|
||||
given(this.loggingSystem.getLoggerConfigurations()).willReturn(Collections
|
||||
.singletonList(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG)));
|
||||
client.get().uri("/actuator/loggers").exchange().expectStatus().isOk()
|
||||
|
|
@ -86,7 +86,7 @@ public class LoggersEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getLoggerShouldReturnLogLevels() throws Exception {
|
||||
public void getLoggerShouldReturnLogLevels() {
|
||||
given(this.loggingSystem.getLoggerConfiguration("ROOT"))
|
||||
.willReturn(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG));
|
||||
client.get().uri("/actuator/loggers/ROOT").exchange().expectStatus().isOk()
|
||||
|
|
@ -96,13 +96,13 @@ public class LoggersEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getLoggersWhenLoggerNotFoundShouldReturnNotFound() throws Exception {
|
||||
public void getLoggersWhenLoggerNotFoundShouldReturnNotFound() {
|
||||
client.get().uri("/actuator/loggers/com.does.not.exist").exchange().expectStatus()
|
||||
.isNotFound();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setLoggerUsingApplicationJsonShouldSetLogLevel() throws Exception {
|
||||
public void setLoggerUsingApplicationJsonShouldSetLogLevel() {
|
||||
client.post().uri("/actuator/loggers/ROOT")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.syncBody(Collections.singletonMap("configuredLevel", "debug")).exchange()
|
||||
|
|
@ -111,7 +111,7 @@ public class LoggersEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setLoggerUsingActuatorV2JsonShouldSetLogLevel() throws Exception {
|
||||
public void setLoggerUsingActuatorV2JsonShouldSetLogLevel() {
|
||||
client.post().uri("/actuator/loggers/ROOT")
|
||||
.contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON))
|
||||
.syncBody(Collections.singletonMap("configuredLevel", "debug")).exchange()
|
||||
|
|
@ -120,7 +120,7 @@ public class LoggersEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setLoggerWithWrongLogLevelResultInBadRequestResponse() throws Exception {
|
||||
public void setLoggerWithWrongLogLevelResultInBadRequestResponse() {
|
||||
client.post().uri("/actuator/loggers/ROOT")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.syncBody(Collections.singletonMap("configuredLevel", "other")).exchange()
|
||||
|
|
@ -129,7 +129,7 @@ public class LoggersEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setLoggerWithNullLogLevel() throws Exception {
|
||||
public void setLoggerWithNullLogLevel() {
|
||||
client.post().uri("/actuator/loggers/ROOT")
|
||||
.contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON))
|
||||
.syncBody(Collections.singletonMap("configuredLevel", null)).exchange()
|
||||
|
|
@ -138,7 +138,7 @@ public class LoggersEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void setLoggerWithNoLogLevel() throws Exception {
|
||||
public void setLoggerWithNoLogLevel() {
|
||||
client.post().uri("/actuator/loggers/ROOT")
|
||||
.contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON))
|
||||
.syncBody(Collections.emptyMap()).exchange().expectStatus().isNoContent();
|
||||
|
|
@ -146,8 +146,7 @@ public class LoggersEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void logLevelForLoggerWithNameThatCouldBeMistakenForAPathExtension()
|
||||
throws Exception {
|
||||
public void logLevelForLoggerWithNameThatCouldBeMistakenForAPathExtension() {
|
||||
given(this.loggingSystem.getLoggerConfiguration("com.png"))
|
||||
.willReturn(new LoggerConfiguration("com.png", null, LogLevel.DEBUG));
|
||||
client.get().uri("/actuator/loggers/com.png").exchange().expectStatus().isOk()
|
||||
|
|
|
|||
|
|
@ -90,13 +90,11 @@ public class MailHealthIndicatorTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void connect(String host, int port, String user, String password)
|
||||
throws MessagingException {
|
||||
public void connect(String host, int port, String user, String password) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(Message msg, Address[] addresses)
|
||||
throws MessagingException {
|
||||
public void sendMessage(Message msg, Address[] addresses) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,8 +58,7 @@ public class HeapDumpWebEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void invokeWhenNotAvailableShouldReturnServiceUnavailableStatus()
|
||||
throws Exception {
|
||||
public void invokeWhenNotAvailableShouldReturnServiceUnavailableStatus() {
|
||||
this.endpoint.setAvailable(false);
|
||||
client.get().uri("/actuator/heapdump").exchange().expectStatus()
|
||||
.isEqualTo(HttpStatus.SERVICE_UNAVAILABLE);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class ThreadDumpEndpointTests {
|
||||
|
||||
@Test
|
||||
public void dumpThreads() throws Exception {
|
||||
public void dumpThreads() {
|
||||
assertThat(new ThreadDumpEndpoint().threadDump().getThreads().size())
|
||||
.isGreaterThan(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class MetricsEndpointWebIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void selectByName() throws IOException {
|
||||
public void selectByName() {
|
||||
MockClock.clock(registry).add(SimpleConfig.DEFAULT_STEP);
|
||||
client.get().uri("/actuator/metrics/jvm.memory.used").exchange().expectStatus()
|
||||
.isOk().expectBody().jsonPath("$.name").isEqualTo("jvm.memory.used");
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.boot.actuate.metrics.jdbc;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
|
|
@ -44,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class DataSourcePoolMetricsTests {
|
||||
|
||||
@Test
|
||||
public void dataSourceIsInstrumented() throws SQLException, InterruptedException {
|
||||
public void dataSourceIsInstrumented() {
|
||||
new ApplicationContextRunner()
|
||||
.withUserConfiguration(DataSourceConfig.class, MetricsApp.class)
|
||||
.withConfiguration(
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ public class WebMvcMetricsFilterTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void unhandledError() throws Exception {
|
||||
public void unhandledError() {
|
||||
assertThatCode(() -> this.mvc.perform(get("/api/c1/unhandledError/10"))
|
||||
.andExpect(status().isOk()))
|
||||
.hasRootCauseInstanceOf(RuntimeException.class);
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class WebMvcMetricsIntegrationTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void rethrownExceptionIsRecordedInMetricTag() throws Exception {
|
||||
public void rethrownExceptionIsRecordedInMetricTag() {
|
||||
assertThatCode(() -> this.mvc.perform(get("/api/rethrownError"))
|
||||
.andExpect(status().is5xxServerError()));
|
||||
this.clock.add(SimpleConfig.DEFAULT_STEP);
|
||||
|
|
@ -163,14 +163,14 @@ public class WebMvcMetricsIntegrationTests {
|
|||
WebMvcMetrics metrics;
|
||||
|
||||
@ExceptionHandler
|
||||
ResponseEntity<String> handleError(Exception1 ex) throws Throwable {
|
||||
ResponseEntity<String> handleError(Exception1 ex) {
|
||||
this.metrics.tagWithException(ex);
|
||||
return new ResponseEntity<>("this is a custom exception body",
|
||||
HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
@ExceptionHandler
|
||||
ResponseEntity<String> rethrowError(Exception2 ex) throws Throwable {
|
||||
ResponseEntity<String> rethrowError(Exception2 ex) {
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class MongoHealthIndicatorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void mongoIsUp() throws Exception {
|
||||
public void mongoIsUp() {
|
||||
Document commandResult = mock(Document.class);
|
||||
given(commandResult.getString("version")).willReturn("2.6.4");
|
||||
MongoTemplate mongoTemplate = mock(MongoTemplate.class);
|
||||
|
|
@ -62,7 +62,7 @@ public class MongoHealthIndicatorTests {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void mongoIsDown() throws Exception {
|
||||
public void mongoIsDown() {
|
||||
MongoTemplate mongoTemplate = mock(MongoTemplate.class);
|
||||
given(mongoTemplate.executeCommand("{ buildInfo: 1 }"))
|
||||
.willThrow(new MongoException("Connection failed"));
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue