Merge pull request #26441 from weixsun

* pr/26441:
  Polish "Remove unnecessary throws declaration in tests"
  Remove unnecessary throws declaration in tests

Closes gh-26441
pull/26586/head
Stephane Nicoll 4 years ago
commit 21a3f03d20

@ -96,7 +96,7 @@ class CloudFoundryActuatorAutoConfigurationTests {
} }
@Test @Test
void cloudfoundryapplicationProducesActuatorMediaType() throws Exception { void cloudfoundryapplicationProducesActuatorMediaType() {
this.contextRunner.withPropertyValues("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id", this.contextRunner.withPropertyValues("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id",
"vcap.application.cf_api:https://my-cloud-controller.com").run((context) -> { "vcap.application.cf_api:https://my-cloud-controller.com").run((context) -> {
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(context).build(); MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(context).build();

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -91,7 +91,7 @@ class TokenValidatorTests {
} }
@Test @Test
void validateTokenWhenKidValidationFailsTwiceShouldThrowException() throws Exception { void validateTokenWhenKidValidationFailsTwiceShouldThrowException() {
ReflectionTestUtils.setField(this.tokenValidator, "tokenKeys", INVALID_KEYS); ReflectionTestUtils.setField(this.tokenValidator, "tokenKeys", INVALID_KEYS);
given(this.securityService.fetchTokenKeys()).willReturn(INVALID_KEYS); given(this.securityService.fetchTokenKeys()).willReturn(INVALID_KEYS);
String header = "{\"alg\": \"RS256\", \"kid\": \"valid-key\",\"typ\": \"JWT\"}"; String header = "{\"alg\": \"RS256\", \"kid\": \"valid-key\",\"typ\": \"JWT\"}";
@ -133,7 +133,7 @@ class TokenValidatorTests {
} }
@Test @Test
void validateTokenWhenSignatureInvalidShouldThrowException() throws Exception { void validateTokenWhenSignatureInvalidShouldThrowException() {
ReflectionTestUtils.setField(this.tokenValidator, "tokenKeys", ReflectionTestUtils.setField(this.tokenValidator, "tokenKeys",
Collections.singletonMap("valid-key", INVALID_KEY)); Collections.singletonMap("valid-key", INVALID_KEY));
String header = "{ \"alg\": \"RS256\", \"kid\": \"valid-key\",\"typ\": \"JWT\"}"; String header = "{ \"alg\": \"RS256\", \"kid\": \"valid-key\",\"typ\": \"JWT\"}";
@ -144,7 +144,7 @@ class TokenValidatorTests {
} }
@Test @Test
void validateTokenWhenTokenAlgorithmIsNotRS256ShouldThrowException() throws Exception { void validateTokenWhenTokenAlgorithmIsNotRS256ShouldThrowException() {
String header = "{ \"alg\": \"HS256\", \"typ\": \"JWT\"}"; String header = "{ \"alg\": \"HS256\", \"typ\": \"JWT\"}";
String claims = "{ \"exp\": 2147483647, \"iss\": \"http://localhost:8080/uaa/oauth/token\", \"scope\": [\"actuator.read\"]}"; String claims = "{ \"exp\": 2147483647, \"iss\": \"http://localhost:8080/uaa/oauth/token\", \"scope\": [\"actuator.read\"]}";
assertThatExceptionOfType(CloudFoundryAuthorizationException.class).isThrownBy( assertThatExceptionOfType(CloudFoundryAuthorizationException.class).isThrownBy(
@ -153,7 +153,7 @@ class TokenValidatorTests {
} }
@Test @Test
void validateTokenWhenExpiredShouldThrowException() throws Exception { void validateTokenWhenExpiredShouldThrowException() {
given(this.securityService.fetchTokenKeys()).willReturn(VALID_KEYS); given(this.securityService.fetchTokenKeys()).willReturn(VALID_KEYS);
given(this.securityService.fetchTokenKeys()).willReturn(VALID_KEYS); given(this.securityService.fetchTokenKeys()).willReturn(VALID_KEYS);
String header = "{ \"alg\": \"RS256\", \"kid\": \"valid-key\", \"typ\": \"JWT\"}"; String header = "{ \"alg\": \"RS256\", \"kid\": \"valid-key\", \"typ\": \"JWT\"}";
@ -164,7 +164,7 @@ class TokenValidatorTests {
} }
@Test @Test
void validateTokenWhenIssuerIsNotValidShouldThrowException() throws Exception { void validateTokenWhenIssuerIsNotValidShouldThrowException() {
given(this.securityService.fetchTokenKeys()).willReturn(VALID_KEYS); given(this.securityService.fetchTokenKeys()).willReturn(VALID_KEYS);
given(this.securityService.getUaaUrl()).willReturn("https://other-uaa.com"); given(this.securityService.getUaaUrl()).willReturn("https://other-uaa.com");
String header = "{ \"alg\": \"RS256\", \"kid\": \"valid-key\", \"typ\": \"JWT\", \"scope\": [\"actuator.read\"]}"; String header = "{ \"alg\": \"RS256\", \"kid\": \"valid-key\", \"typ\": \"JWT\", \"scope\": [\"actuator.read\"]}";
@ -175,7 +175,7 @@ class TokenValidatorTests {
} }
@Test @Test
void validateTokenWhenAudienceIsNotValidShouldThrowException() throws Exception { void validateTokenWhenAudienceIsNotValidShouldThrowException() {
given(this.securityService.fetchTokenKeys()).willReturn(VALID_KEYS); given(this.securityService.fetchTokenKeys()).willReturn(VALID_KEYS);
given(this.securityService.getUaaUrl()).willReturn("http://localhost:8080/uaa"); given(this.securityService.getUaaUrl()).willReturn("http://localhost:8080/uaa");
String header = "{ \"alg\": \"RS256\", \"kid\": \"valid-key\", \"typ\": \"JWT\"}"; String header = "{ \"alg\": \"RS256\", \"kid\": \"valid-key\", \"typ\": \"JWT\"}";

@ -183,14 +183,14 @@ class ConditionalOnAvailableEndpointTests {
} }
@Test // gh-21044 @Test // gh-21044
void outcomeWhenIncludeAllShouldMatchDashedEndpoint() throws Exception { void outcomeWhenIncludeAllShouldMatchDashedEndpoint() {
this.contextRunner.withUserConfiguration(DashedEndpointConfiguration.class) this.contextRunner.withUserConfiguration(DashedEndpointConfiguration.class)
.withPropertyValues("management.endpoints.web.exposure.include=*") .withPropertyValues("management.endpoints.web.exposure.include=*")
.run((context) -> assertThat(context).hasSingleBean(DashedEndpoint.class)); .run((context) -> assertThat(context).hasSingleBean(DashedEndpoint.class));
} }
@Test // gh-21044 @Test // gh-21044
void outcomeWhenIncludeDashedShouldMatchDashedEndpoint() throws Exception { void outcomeWhenIncludeDashedShouldMatchDashedEndpoint() {
this.contextRunner.withUserConfiguration(DashedEndpointConfiguration.class) this.contextRunner.withUserConfiguration(DashedEndpointConfiguration.class)
.withPropertyValues("management.endpoints.web.exposure.include=test-dashed") .withPropertyValues("management.endpoints.web.exposure.include=test-dashed")
.run((context) -> assertThat(context).hasSingleBean(DashedEndpoint.class)); .run((context) -> assertThat(context).hasSingleBean(DashedEndpoint.class));

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -145,7 +145,7 @@ class IncludeExcludeEndpointFilterTests {
} }
@Test // gh-20997 @Test // gh-20997
void matchWhenDashInName() throws Exception { void matchWhenDashInName() {
setupFilter("bus-refresh", ""); setupFilter("bus-refresh", "");
assertThat(match(EndpointId.of("bus-refresh"))).isTrue(); assertThat(match(EndpointId.of("bus-refresh"))).isTrue();
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -65,7 +65,7 @@ class HeapDumpWebEndpointDocumentationTests extends MockMvcEndpointDocumentation
return new HeapDumpWebEndpoint() { return new HeapDumpWebEndpoint() {
@Override @Override
protected HeapDumper createHeapDumper() throws HeapDumperUnavailableException { protected HeapDumper createHeapDumper() {
return (file, live) -> FileCopyUtils.copy("<<binary content>>", new FileWriter(file)); return (file, live) -> FileCopyUtils.copy("<<binary content>>", new FileWriter(file));
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -77,7 +77,7 @@ class MappingsEndpointReactiveDocumentationTests extends AbstractEndpointDocumen
} }
@Test @Test
void mappings() throws Exception { void mappings() {
List<FieldDescriptor> requestMappingConditions = Arrays.asList( List<FieldDescriptor> requestMappingConditions = Arrays.asList(
requestMappingConditionField("").description("Details of the request mapping conditions.").optional(), requestMappingConditionField("").description("Details of the request mapping conditions.").optional(),
requestMappingConditionField(".consumes").description("Details of the consumes condition"), requestMappingConditionField(".consumes").description("Details of the consumes condition"),

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -76,7 +76,7 @@ class MappingsEndpointServletDocumentationTests extends AbstractEndpointDocument
} }
@Test @Test
void mappings() throws Exception { void mappings() {
ResponseFieldsSnippet commonResponseFields = responseFields( ResponseFieldsSnippet commonResponseFields = responseFields(
fieldWithPath("contexts").description("Application contexts keyed by id."), fieldWithPath("contexts").description("Application contexts keyed by id."),
fieldWithPath("contexts.*.mappings").description("Mappings in the context, keyed by mapping type."), fieldWithPath("contexts.*.mappings").description("Mappings in the context, keyed by mapping type."),

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -56,7 +56,7 @@ class ControllerEndpointWebFluxIntegrationTests {
} }
@Test @Test
void endpointsCanBeAccessed() throws Exception { void endpointsCanBeAccessed() {
TestSecurityContextHolder.getContext() TestSecurityContextHolder.getContext()
.setAuthentication(new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR")); .setAuthentication(new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR"));
this.context = new AnnotationConfigReactiveWebApplicationContext(); this.context = new AnnotationConfigReactiveWebApplicationContext();

@ -51,7 +51,7 @@ class WebFluxEndpointIntegrationTests {
.withUserConfiguration(EndpointsConfiguration.class); .withUserConfiguration(EndpointsConfiguration.class);
@Test @Test
void linksAreProvidedToAllEndpointTypes() throws Exception { void linksAreProvidedToAllEndpointTypes() {
this.contextRunner.withPropertyValues("management.endpoints.web.exposure.include:*").run((context) -> { this.contextRunner.withPropertyValues("management.endpoints.web.exposure.include:*").run((context) -> {
WebTestClient client = createWebTestClient(context); WebTestClient client = createWebTestClient(context);
client.get().uri("/actuator").exchange().expectStatus().isOk().expectBody().jsonPath("_links.beans") client.get().uri("/actuator").exchange().expectStatus().isOk().expectBody().jsonPath("_links.beans")
@ -61,7 +61,7 @@ class WebFluxEndpointIntegrationTests {
} }
@Test @Test
void linksPageIsNotAvailableWhenDisabled() throws Exception { void linksPageIsNotAvailableWhenDisabled() {
this.contextRunner.withPropertyValues("management.endpoints.web.discovery.enabled=false").run((context) -> { this.contextRunner.withPropertyValues("management.endpoints.web.discovery.enabled=false").run((context) -> {
WebTestClient client = createWebTestClient(context); WebTestClient client = createWebTestClient(context);
client.get().uri("/actuator").exchange().expectStatus().isNotFound(); client.get().uri("/actuator").exchange().expectStatus().isNotFound();

@ -171,7 +171,7 @@ class WebMvcEndpointExposureIntegrationTests {
.build(); .build();
} }
private boolean isExposed(WebTestClient client, HttpMethod method, String path) throws Exception { private boolean isExposed(WebTestClient client, HttpMethod method, String path) {
path = "/actuator/" + path; path = "/actuator/" + path;
EntityExchangeResult<byte[]> result = client.method(method).uri(path).exchange().expectBody().returnResult(); EntityExchangeResult<byte[]> result = client.method(method).uri(path).exchange().expectBody().returnResult();
if (result.getStatus() == HttpStatus.OK) { if (result.getStatus() == HttpStatus.OK) {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,7 +26,6 @@ import io.micrometer.core.instrument.composite.CompositeMeterRegistry;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.slf4j.impl.StaticLoggerBinder; import org.slf4j.impl.StaticLoggerBinder;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.actuate.autoconfigure.metrics.export.atlas.AtlasMetricsExportAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.metrics.export.atlas.AtlasMetricsExportAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.metrics.export.jmx.JmxMetricsExportAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.metrics.export.jmx.JmxMetricsExportAutoConfiguration;
@ -134,7 +133,7 @@ class MeterRegistryConfigurerIntegrationTests {
return new BeanPostProcessor() { return new BeanPostProcessor() {
@Override @Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { public Object postProcessAfterInitialization(Object bean, String beanName) {
if (bean instanceof Bravo) { if (bean instanceof Bravo) {
MeterRegistry meterRegistry = context.getBean(MeterRegistry.class); MeterRegistry meterRegistry = context.getBean(MeterRegistry.class);
meterRegistry.gauge("test", 1); meterRegistry.gauge("test", 1);

@ -28,7 +28,6 @@ import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun; import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
@ -312,7 +311,7 @@ class DataSourcePoolMetricsAutoConfigurationTests {
} }
@Override @Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { public Object postProcessAfterInitialization(Object bean, String beanName) {
if (bean instanceof HikariDataSource) { if (bean instanceof HikariDataSource) {
try { try {
((HikariDataSource) bean).getConnection().close(); ((HikariDataSource) bean).getConnection().close();

@ -24,7 +24,6 @@ import java.util.List;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import org.springframework.beans.BeansException;
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration;
import org.springframework.boot.actuate.autoconfigure.env.EnvironmentEndpointAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.env.EnvironmentEndpointAutoConfiguration;
@ -159,7 +158,7 @@ class ReactiveManagementWebSecurityAutoConfigurationTests {
static class CustomSecurityConfiguration { static class CustomSecurityConfiguration {
@Bean @Bean
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) throws Exception { SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http.authorizeExchange((exchanges) -> { http.authorizeExchange((exchanges) -> {
exchanges.pathMatchers("/foo").permitAll(); exchanges.pathMatchers("/foo").permitAll();
exchanges.anyExchange().authenticated(); exchanges.anyExchange().authenticated();
@ -179,7 +178,7 @@ class ReactiveManagementWebSecurityAutoConfigurationTests {
} }
@Bean @Bean
WebFilterChainProxy webFilterChainProxy(ServerHttpSecurity http) throws Exception { WebFilterChainProxy webFilterChainProxy(ServerHttpSecurity http) {
return new WebFilterChainProxy(getFilterChains(http)); return new WebFilterChainProxy(getFilterChains(http));
} }
@ -190,7 +189,7 @@ class ReactiveManagementWebSecurityAutoConfigurationTests {
return httpSecurity; return httpSecurity;
} }
private List<SecurityWebFilterChain> getFilterChains(ServerHttpSecurity http) throws Exception { private List<SecurityWebFilterChain> getFilterChains(ServerHttpSecurity http) {
http.authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated()); http.authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated());
http.formLogin(Customizer.withDefaults()); http.formLogin(Customizer.withDefaults());
return Collections.singletonList(http.build()); return Collections.singletonList(http.build());
@ -199,7 +198,7 @@ class ReactiveManagementWebSecurityAutoConfigurationTests {
static class TestServerHttpSecurity extends ServerHttpSecurity implements ApplicationContextAware { static class TestServerHttpSecurity extends ServerHttpSecurity implements ApplicationContextAware {
@Override @Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { public void setApplicationContext(ApplicationContext applicationContext) {
super.setApplicationContext(applicationContext); super.setApplicationContext(applicationContext);
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,7 +21,6 @@ import java.util.Map;
import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactory; import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactory;
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory; import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
import org.springframework.boot.web.server.WebServer; import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.server.WebServerException;
import org.springframework.http.server.reactive.HttpHandler; import org.springframework.http.server.reactive.HttpHandler;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
@ -72,12 +71,12 @@ class MockReactiveWebServerFactory extends AbstractReactiveWebServerFactory {
} }
@Override @Override
public void start() throws WebServerException { public void start() {
} }
@Override @Override
public void stop() throws WebServerException { public void stop() {
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +23,6 @@ import javax.servlet.ServletContext;
import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredFilter; import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredFilter;
import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredServlet; import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredServlet;
import org.springframework.boot.web.server.WebServer; import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.server.WebServerException;
import org.springframework.boot.web.servlet.ServletContextInitializer; import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory; import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
@ -71,7 +70,7 @@ public class MockServletWebServerFactory extends AbstractServletWebServerFactory
} }
@Override @Override
public void start() throws WebServerException { public void start() {
} }
} }

@ -31,7 +31,6 @@ import org.springframework.boot.actuate.endpoint.ApiVersion;
import org.springframework.boot.actuate.endpoint.InvocationContext; import org.springframework.boot.actuate.endpoint.InvocationContext;
import org.springframework.boot.actuate.endpoint.OperationArgumentResolver; import org.springframework.boot.actuate.endpoint.OperationArgumentResolver;
import org.springframework.boot.actuate.endpoint.SecurityContext; import org.springframework.boot.actuate.endpoint.SecurityContext;
import org.springframework.boot.actuate.endpoint.invoke.MissingParametersException;
import org.springframework.boot.actuate.endpoint.invoke.OperationInvoker; import org.springframework.boot.actuate.endpoint.invoke.OperationInvoker;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -221,7 +220,7 @@ class CachingOperationInvokerTests {
static AtomicInteger invocations = new AtomicInteger(); static AtomicInteger invocations = new AtomicInteger();
@Override @Override
public Mono<String> invoke(InvocationContext context) throws MissingParametersException { public Mono<String> invoke(InvocationContext context) {
return Mono.fromCallable(() -> { return Mono.fromCallable(() -> {
invocations.incrementAndGet(); invocations.incrementAndGet();
return "test"; return "test";
@ -235,7 +234,7 @@ class CachingOperationInvokerTests {
static AtomicInteger invocations = new AtomicInteger(); static AtomicInteger invocations = new AtomicInteger();
@Override @Override
public Flux<String> invoke(InvocationContext context) throws MissingParametersException { public Flux<String> invoke(InvocationContext context) {
return Flux.just("spring", "boot").hide().doFirst(invocations::incrementAndGet); return Flux.just("spring", "boot").hide().doFirst(invocations::incrementAndGet);
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import java.net.URLClassLoader;
import javax.management.Attribute; import javax.management.Attribute;
import javax.management.AttributeList; import javax.management.AttributeList;
import javax.management.AttributeNotFoundException; import javax.management.AttributeNotFoundException;
import javax.management.InvalidAttributeValueException;
import javax.management.MBeanException; import javax.management.MBeanException;
import javax.management.MBeanInfo; import javax.management.MBeanInfo;
import javax.management.ReflectionException; import javax.management.ReflectionException;
@ -87,7 +86,7 @@ class EndpointMBeanTests {
} }
@Test @Test
void invokeWhenOperationFailedShouldTranslateException() throws MBeanException, ReflectionException { void invokeWhenOperationFailedShouldTranslateException() {
TestExposableJmxEndpoint endpoint = new TestExposableJmxEndpoint(new TestJmxOperation((arguments) -> { TestExposableJmxEndpoint endpoint = new TestExposableJmxEndpoint(new TestJmxOperation((arguments) -> {
throw new FatalBeanException("test failure"); throw new FatalBeanException("test failure");
})); }));
@ -99,7 +98,7 @@ class EndpointMBeanTests {
} }
@Test @Test
void invokeWhenOperationFailedWithJdkExceptionShouldReuseException() throws MBeanException, ReflectionException { void invokeWhenOperationFailedWithJdkExceptionShouldReuseException() {
TestExposableJmxEndpoint endpoint = new TestExposableJmxEndpoint(new TestJmxOperation((arguments) -> { TestExposableJmxEndpoint endpoint = new TestExposableJmxEndpoint(new TestJmxOperation((arguments) -> {
throw new UnsupportedOperationException("test failure"); throw new UnsupportedOperationException("test failure");
})); }));
@ -110,7 +109,7 @@ class EndpointMBeanTests {
} }
@Test @Test
void invokeWhenActionNameIsNotAnOperationShouldThrowException() throws MBeanException, ReflectionException { void invokeWhenActionNameIsNotAnOperationShouldThrowException() {
EndpointMBean bean = createEndpointMBean(); EndpointMBean bean = createEndpointMBean();
assertThatExceptionOfType(ReflectionException.class) assertThatExceptionOfType(ReflectionException.class)
.isThrownBy(() -> bean.invoke("missingOperation", NO_PARAMS, NO_SIGNATURE)) .isThrownBy(() -> bean.invoke("missingOperation", NO_PARAMS, NO_SIGNATURE))
@ -131,7 +130,7 @@ class EndpointMBeanTests {
} }
@Test @Test
void invokeWhenOperationIsInvalidShouldThrowException() throws MBeanException, ReflectionException { void invokeWhenOperationIsInvalidShouldThrowException() {
TestJmxOperation operation = new TestJmxOperation() { TestJmxOperation operation = new TestJmxOperation() {
@Override @Override
@ -166,15 +165,14 @@ class EndpointMBeanTests {
} }
@Test @Test
void getAttributeShouldThrowException() throws AttributeNotFoundException, MBeanException, ReflectionException { void getAttributeShouldThrowException() {
EndpointMBean bean = createEndpointMBean(); EndpointMBean bean = createEndpointMBean();
assertThatExceptionOfType(AttributeNotFoundException.class).isThrownBy(() -> bean.getAttribute("test")) assertThatExceptionOfType(AttributeNotFoundException.class).isThrownBy(() -> bean.getAttribute("test"))
.withMessageContaining("EndpointMBeans do not support attributes"); .withMessageContaining("EndpointMBeans do not support attributes");
} }
@Test @Test
void setAttributeShouldThrowException() void setAttributeShouldThrowException() {
throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
EndpointMBean bean = createEndpointMBean(); EndpointMBean bean = createEndpointMBean();
assertThatExceptionOfType(AttributeNotFoundException.class) assertThatExceptionOfType(AttributeNotFoundException.class)
.isThrownBy(() -> bean.setAttribute(new Attribute("test", "test"))) .isThrownBy(() -> bean.setAttribute(new Attribute("test", "test")))

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -51,7 +51,7 @@ class ControllerEndpointHandlerMappingTests {
private final StaticApplicationContext context = new StaticApplicationContext(); private final StaticApplicationContext context = new StaticApplicationContext();
@Test @Test
void mappingWithNoPrefix() throws Exception { void mappingWithNoPrefix() {
ExposableControllerEndpoint first = firstEndpoint(); ExposableControllerEndpoint first = firstEndpoint();
ExposableControllerEndpoint second = secondEndpoint(); ExposableControllerEndpoint second = secondEndpoint();
ControllerEndpointHandlerMapping mapping = createMapping("", first, second); ControllerEndpointHandlerMapping mapping = createMapping("", first, second);
@ -62,7 +62,7 @@ class ControllerEndpointHandlerMappingTests {
} }
@Test @Test
void mappingWithPrefix() throws Exception { void mappingWithPrefix() {
ExposableControllerEndpoint first = firstEndpoint(); ExposableControllerEndpoint first = firstEndpoint();
ExposableControllerEndpoint second = secondEndpoint(); ExposableControllerEndpoint second = secondEndpoint();
ControllerEndpointHandlerMapping mapping = createMapping("actuator", first, second); ControllerEndpointHandlerMapping mapping = createMapping("actuator", first, second);
@ -75,7 +75,7 @@ class ControllerEndpointHandlerMappingTests {
} }
@Test @Test
void mappingWithNoPath() throws Exception { void mappingWithNoPath() {
ExposableControllerEndpoint pathless = pathlessEndpoint(); ExposableControllerEndpoint pathless = pathlessEndpoint();
ControllerEndpointHandlerMapping mapping = createMapping("actuator", pathless); ControllerEndpointHandlerMapping mapping = createMapping("actuator", pathless);
assertThat(getHandler(mapping, HttpMethod.GET, "/actuator/pathless")) assertThat(getHandler(mapping, HttpMethod.GET, "/actuator/pathless"))
@ -85,7 +85,7 @@ class ControllerEndpointHandlerMappingTests {
} }
@Test @Test
void mappingNarrowedToMethod() throws Exception { void mappingNarrowedToMethod() {
ExposableControllerEndpoint first = firstEndpoint(); ExposableControllerEndpoint first = firstEndpoint();
ControllerEndpointHandlerMapping mapping = createMapping("actuator", first); ControllerEndpointHandlerMapping mapping = createMapping("actuator", first);
assertThatExceptionOfType(MethodNotAllowedException.class) assertThatExceptionOfType(MethodNotAllowedException.class)

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -73,7 +73,7 @@ class ControllerEndpointHandlerMappingTests {
} }
@Test @Test
void mappingNarrowedToMethod() throws Exception { void mappingNarrowedToMethod() {
ExposableControllerEndpoint first = firstEndpoint(); ExposableControllerEndpoint first = firstEndpoint();
ControllerEndpointHandlerMapping mapping = createMapping("actuator", first); ControllerEndpointHandlerMapping mapping = createMapping("actuator", first);
assertThatExceptionOfType(HttpRequestMethodNotSupportedException.class) assertThatExceptionOfType(HttpRequestMethodNotSupportedException.class)

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -32,7 +32,6 @@ import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.Extension; import org.junit.jupiter.api.extension.Extension;
import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ParameterContext; import org.junit.jupiter.api.extension.ParameterContext;
import org.junit.jupiter.api.extension.ParameterResolutionException;
import org.junit.jupiter.api.extension.ParameterResolver; import org.junit.jupiter.api.extension.ParameterResolver;
import org.junit.jupiter.api.extension.TestTemplateInvocationContext; import org.junit.jupiter.api.extension.TestTemplateInvocationContext;
import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider; import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider;
@ -161,15 +160,13 @@ class WebEndpointTestInvocationContextProvider implements TestTemplateInvocation
} }
@Override @Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
throws ParameterResolutionException {
Class<?> type = parameterContext.getParameter().getType(); Class<?> type = parameterContext.getParameter().getType();
return type.equals(WebTestClient.class) || type.isAssignableFrom(ConfigurableApplicationContext.class); return type.equals(WebTestClient.class) || type.isAssignableFrom(ConfigurableApplicationContext.class);
} }
@Override @Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
throws ParameterResolutionException {
Class<?> type = parameterContext.getParameter().getType(); Class<?> type = parameterContext.getParameter().getType();
if (type.equals(WebTestClient.class)) { if (type.equals(WebTestClient.class)) {
return createWebTestClient(); return createWebTestClient();

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -227,7 +227,7 @@ class EnvironmentEndpointTests {
} }
@Test @Test
void propertyWithCharSequenceTypeIsConvertedToString() throws Exception { void propertyWithCharSequenceTypeIsConvertedToString() {
ConfigurableEnvironment environment = emptyEnvironment(); ConfigurableEnvironment environment = emptyEnvironment();
environment.getPropertySources().addFirst(singleKeyPropertySource("test", "foo", new CharSequenceProperty())); environment.getPropertySources().addFirst(singleKeyPropertySource("test", "foo", new CharSequenceProperty()));
EnvironmentDescriptor descriptor = new EnvironmentEndpoint(environment).environment(null); EnvironmentDescriptor descriptor = new EnvironmentEndpoint(environment).environment(null);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -50,7 +50,7 @@ class LogFileWebEndpointWebIntegrationTests {
} }
@BeforeAll @BeforeAll
static void setup(@TempDir File temp) throws IOException { static void setup(@TempDir File temp) {
tempFile = temp; tempFile = temp;
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -36,7 +36,7 @@ class HeapDumpWebEndpointTests {
HeapDumpWebEndpoint slowEndpoint = new HeapDumpWebEndpoint(2500) { HeapDumpWebEndpoint slowEndpoint = new HeapDumpWebEndpoint(2500) {
@Override @Override
protected HeapDumper createHeapDumper() throws HeapDumperUnavailableException { protected HeapDumper createHeapDumper() {
return (file, live) -> { return (file, live) -> {
dumpingLatch.countDown(); dumpingLatch.countDown();
blockingLatch.await(); blockingLatch.await();

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -59,13 +59,13 @@ class HeapDumpWebEndpointWebIntegrationTests {
} }
@WebEndpointTest @WebEndpointTest
void getRequestShouldReturnHeapDumpInResponseBody(WebTestClient client) throws Exception { void getRequestShouldReturnHeapDumpInResponseBody(WebTestClient client) {
client.get().uri("/actuator/heapdump").exchange().expectStatus().isOk().expectHeader() client.get().uri("/actuator/heapdump").exchange().expectStatus().isOk().expectHeader()
.contentType(MediaType.APPLICATION_OCTET_STREAM).expectBody(String.class).isEqualTo("HEAPDUMP"); .contentType(MediaType.APPLICATION_OCTET_STREAM).expectBody(String.class).isEqualTo("HEAPDUMP");
assertHeapDumpFileIsDeleted(); assertHeapDumpFileIsDeleted();
} }
private void assertHeapDumpFileIsDeleted() throws InterruptedException { private void assertHeapDumpFileIsDeleted() {
Awaitility.waitAtMost(Duration.ofSeconds(5)).until(this.endpoint.file::exists, is(false)); Awaitility.waitAtMost(Duration.ofSeconds(5)).until(this.endpoint.file::exists, is(false));
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -33,13 +33,13 @@ import static org.assertj.core.api.Assertions.assertThat;
class ThreadDumpEndpointWebIntegrationTests { class ThreadDumpEndpointWebIntegrationTests {
@WebEndpointTest @WebEndpointTest
void getRequestWithJsonAcceptHeaderShouldProduceJsonThreadDumpResponse(WebTestClient client) throws Exception { void getRequestWithJsonAcceptHeaderShouldProduceJsonThreadDumpResponse(WebTestClient client) {
client.get().uri("/actuator/threaddump").accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk() client.get().uri("/actuator/threaddump").accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_JSON); .expectHeader().contentType(MediaType.APPLICATION_JSON);
} }
@WebEndpointTest @WebEndpointTest
void getRequestWithTextPlainAcceptHeaderShouldProduceTextPlainResponse(WebTestClient client) throws Exception { void getRequestWithTextPlainAcceptHeaderShouldProduceTextPlainResponse(WebTestClient client) {
String response = client.get().uri("/actuator/threaddump").accept(MediaType.TEXT_PLAIN).exchange() String response = client.get().uri("/actuator/threaddump").accept(MediaType.TEXT_PLAIN).exchange()
.expectStatus().isOk().expectHeader().contentType("text/plain;charset=UTF-8").expectBody(String.class) .expectStatus().isOk().expectHeader().contentType("text/plain;charset=UTF-8").expectBody(String.class)
.returnResult().getResponseBody(); .returnResult().getResponseBody();

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -85,7 +85,7 @@ class WebMvcMetricsIntegrationTests {
} }
@Test @Test
void rethrownExceptionIsRecordedInMetricTag() throws Exception { void rethrownExceptionIsRecordedInMetricTag() {
assertThatExceptionOfType(NestedServletException.class) assertThatExceptionOfType(NestedServletException.class)
.isThrownBy(() -> this.mvc.perform(get("/api/rethrownError")).andReturn()); .isThrownBy(() -> this.mvc.perform(get("/api/rethrownError")).andReturn());
assertThat(this.registry.get("http.server.requests").tags("exception", "Exception2", "status", "500").timer() assertThat(this.registry.get("http.server.requests").tags("exception", "Exception2", "status", "500").timer()

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -99,7 +99,7 @@ class HttpTraceFilterTests {
} }
@Test @Test
void statusIsAssumedToBe500WhenChainFails() throws ServletException, IOException { void statusIsAssumedToBe500WhenChainFails() {
assertThatIOException().isThrownBy(() -> this.filter.doFilter(new MockHttpServletRequest(), assertThatIOException().isThrownBy(() -> this.filter.doFilter(new MockHttpServletRequest(),
new MockHttpServletResponse(), new MockFilterChain(new HttpServlet() { new MockHttpServletResponse(), new MockFilterChain(new HttpServlet() {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,7 +25,6 @@ import java.util.Set;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
@ -260,7 +259,7 @@ class AutoConfigurationImportSelectorTests {
} }
@Override @Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException { public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory; this.beanFactory = beanFactory;
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,7 +21,6 @@ import java.util.List;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.AbstractBeanDefinition;
@ -106,11 +105,11 @@ class SharedMetadataReaderFactoryContextInitializerTests {
static class PostProcessor implements BeanDefinitionRegistryPostProcessor { static class PostProcessor implements BeanDefinitionRegistryPostProcessor {
@Override @Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
} }
@Override @Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) {
for (String name : registry.getBeanDefinitionNames()) { for (String name : registry.getBeanDefinitionNames()) {
BeanDefinition definition = registry.getBeanDefinition(name); BeanDefinition definition = registry.getBeanDefinition(name);
definition.setAttribute("seen", true); definition.setAttribute("seen", true);

@ -722,7 +722,7 @@ class RabbitAutoConfigurationTests {
} }
@Test @Test
void enableSslWithValidateServerCertificateFalse() throws Exception { void enableSslWithValidateServerCertificateFalse() {
this.contextRunner.withUserConfiguration(TestConfiguration.class) this.contextRunner.withUserConfiguration(TestConfiguration.class)
.withPropertyValues("spring.rabbitmq.ssl.enabled:true", .withPropertyValues("spring.rabbitmq.ssl.enabled:true",
"spring.rabbitmq.ssl.validateServerCertificate=false") "spring.rabbitmq.ssl.validateServerCertificate=false")
@ -734,7 +734,7 @@ class RabbitAutoConfigurationTests {
} }
@Test @Test
void enableSslWithValidateServerCertificateDefault() throws Exception { void enableSslWithValidateServerCertificateDefault() {
this.contextRunner.withUserConfiguration(TestConfiguration.class) this.contextRunner.withUserConfiguration(TestConfiguration.class)
.withPropertyValues("spring.rabbitmq.ssl.enabled:true").run((context) -> { .withPropertyValues("spring.rabbitmq.ssl.enabled:true").run((context) -> {
com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory = getTargetConnectionFactory(context); com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory = getTargetConnectionFactory(context);
@ -785,43 +785,42 @@ class RabbitAutoConfigurationTests {
} }
@Test @Test
void whenACredentialsProviderIsAvailableThenConnectionFactoryIsConfiguredToUseIt() throws Exception { void whenACredentialsProviderIsAvailableThenConnectionFactoryIsConfiguredToUseIt() {
this.contextRunner.withUserConfiguration(CredentialsProviderConfiguration.class) this.contextRunner.withUserConfiguration(CredentialsProviderConfiguration.class)
.run((context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsProvider()) .run((context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsProvider())
.isEqualTo(CredentialsProviderConfiguration.credentialsProvider)); .isEqualTo(CredentialsProviderConfiguration.credentialsProvider));
} }
@Test @Test
void whenAPrimaryCredentialsProviderIsAvailableThenConnectionFactoryIsConfiguredToUseIt() throws Exception { void whenAPrimaryCredentialsProviderIsAvailableThenConnectionFactoryIsConfiguredToUseIt() {
this.contextRunner.withUserConfiguration(PrimaryCredentialsProviderConfiguration.class) this.contextRunner.withUserConfiguration(PrimaryCredentialsProviderConfiguration.class)
.run((context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsProvider()) .run((context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsProvider())
.isEqualTo(PrimaryCredentialsProviderConfiguration.credentialsProvider)); .isEqualTo(PrimaryCredentialsProviderConfiguration.credentialsProvider));
} }
@Test @Test
void whenMultipleCredentialsProvidersAreAvailableThenConnectionFactoryUsesDefaultProvider() throws Exception { void whenMultipleCredentialsProvidersAreAvailableThenConnectionFactoryUsesDefaultProvider() {
this.contextRunner.withUserConfiguration(MultipleCredentialsProvidersConfiguration.class) this.contextRunner.withUserConfiguration(MultipleCredentialsProvidersConfiguration.class)
.run((context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsProvider()) .run((context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsProvider())
.isInstanceOf(DefaultCredentialsProvider.class)); .isInstanceOf(DefaultCredentialsProvider.class));
} }
@Test @Test
void whenACredentialsRefreshServiceIsAvailableThenConnectionFactoryIsConfiguredToUseIt() throws Exception { void whenACredentialsRefreshServiceIsAvailableThenConnectionFactoryIsConfiguredToUseIt() {
this.contextRunner.withUserConfiguration(CredentialsRefreshServiceConfiguration.class).run( this.contextRunner.withUserConfiguration(CredentialsRefreshServiceConfiguration.class).run(
(context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsRefreshService()) (context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsRefreshService())
.isEqualTo(CredentialsRefreshServiceConfiguration.credentialsRefreshService)); .isEqualTo(CredentialsRefreshServiceConfiguration.credentialsRefreshService));
} }
@Test @Test
void whenAPrimaryCredentialsRefreshServiceIsAvailableThenConnectionFactoryIsConfiguredToUseIt() throws Exception { void whenAPrimaryCredentialsRefreshServiceIsAvailableThenConnectionFactoryIsConfiguredToUseIt() {
this.contextRunner.withUserConfiguration(PrimaryCredentialsRefreshServiceConfiguration.class).run( this.contextRunner.withUserConfiguration(PrimaryCredentialsRefreshServiceConfiguration.class).run(
(context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsRefreshService()) (context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsRefreshService())
.isEqualTo(PrimaryCredentialsRefreshServiceConfiguration.credentialsRefreshService)); .isEqualTo(PrimaryCredentialsRefreshServiceConfiguration.credentialsRefreshService));
} }
@Test @Test
void whenMultipleCredentialsRefreshServiceAreAvailableThenConnectionFactoryHasNoCredentialsRefreshService() void whenMultipleCredentialsRefreshServiceAreAvailableThenConnectionFactoryHasNoCredentialsRefreshService() {
throws Exception {
this.contextRunner.withUserConfiguration(MultipleCredentialsRefreshServicesConfiguration.class).run( this.contextRunner.withUserConfiguration(MultipleCredentialsRefreshServicesConfiguration.class).run(
(context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsRefreshService()) (context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsRefreshService())
.isNull()); .isNull());

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -60,22 +60,22 @@ class BatchAutoConfigurationWithoutJdbcTests {
static class BatchConfiguration implements BatchConfigurer { static class BatchConfiguration implements BatchConfigurer {
@Override @Override
public JobRepository getJobRepository() throws Exception { public JobRepository getJobRepository() {
return mock(JobRepository.class); return mock(JobRepository.class);
} }
@Override @Override
public PlatformTransactionManager getTransactionManager() throws Exception { public PlatformTransactionManager getTransactionManager() {
return mock(PlatformTransactionManager.class); return mock(PlatformTransactionManager.class);
} }
@Override @Override
public JobLauncher getJobLauncher() throws Exception { public JobLauncher getJobLauncher() {
return mock(JobLauncher.class); return mock(JobLauncher.class);
} }
@Override @Override
public JobExplorer getJobExplorer() throws Exception { public JobExplorer getJobExplorer() {
return mock(JobExplorer.class); return mock(JobExplorer.class);
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -127,8 +127,7 @@ public class MockCachingProvider implements CachingProvider {
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <K, V, C extends Configuration<K, V>> Cache<K, V> createCache(String cacheName, C configuration) public <K, V, C extends Configuration<K, V>> Cache<K, V> createCache(String cacheName, C configuration) {
throws IllegalArgumentException {
this.configurations.put(cacheName, configuration); this.configurations.put(cacheName, configuration);
Cache<K, V> cache = mock(Cache.class); Cache<K, V> cache = mock(Cache.class);
given(cache.getName()).willReturn(cacheName); given(cache.getName()).willReturn(cacheName);

@ -25,7 +25,6 @@ import org.testcontainers.containers.CassandraContainer;
import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.junit.jupiter.Testcontainers;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
@ -78,7 +77,7 @@ class CassandraAutoConfigurationIntegrationTests {
return new BeanPostProcessor() { return new BeanPostProcessor() {
@Override @Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { public Object postProcessAfterInitialization(Object bean, String beanName) {
if (bean instanceof DriverConfigLoader) { if (bean instanceof DriverConfigLoader) {
return spy(bean); return spy(bean);
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,6 @@ import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ContextConsumer; import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceResolvable; import org.springframework.context.MessageSourceResolvable;
import org.springframework.context.NoSuchMessageException;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySource;
@ -223,12 +222,12 @@ class MessageSourceAutoConfigurationTests {
} }
@Override @Override
public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException { public String getMessage(String code, Object[] args, Locale locale) {
return code; return code;
} }
@Override @Override
public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException { public String getMessage(MessageSourceResolvable resolvable, Locale locale) {
return resolvable.getCodes()[0]; return resolvable.getCodes()[0];
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.data.redis;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ApplicationContextRunner;
@ -233,7 +232,7 @@ class RedisAutoConfigurationJedisTests {
static JedisConnectionFactory connectionFactory; static JedisConnectionFactory connectionFactory;
@Override @Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { public Object postProcessBeforeInitialization(Object bean, String beanName) {
if (bean instanceof JedisConnectionFactory) { if (bean instanceof JedisConnectionFactory) {
connectionFactory = (JedisConnectionFactory) bean; connectionFactory = (JedisConnectionFactory) bean;
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +24,6 @@ import javax.sql.DataSource;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@ -115,7 +114,7 @@ class H2ConsoleAutoConfigurationTests {
@Test @Test
@ExtendWith(OutputCaptureExtension.class) @ExtendWith(OutputCaptureExtension.class)
void dataSourceUrlIsLoggedWhenAvailable(CapturedOutput output) throws BeansException { void dataSourceUrlIsLoggedWhenAvailable(CapturedOutput output) {
this.contextRunner.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)) this.contextRunner.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class))
.withPropertyValues("spring.h2.console.enabled=true").run((context) -> { .withPropertyValues("spring.h2.console.enabled=true").run((context) -> {
try (Connection connection = context.getBean(DataSource.class).getConnection()) { try (Connection connection = context.getBean(DataSource.class).getConnection()) {

@ -33,7 +33,6 @@ import javax.sql.DataSource;
import com.zaxxer.hikari.HikariDataSource; import com.zaxxer.hikari.HikariDataSource;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor;
@ -348,7 +347,7 @@ class DataSourceInitializationIntegrationTests {
return new BeanPostProcessor() { return new BeanPostProcessor() {
@Override @Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { public Object postProcessAfterInitialization(Object bean, String beanName) {
if (bean instanceof DataSource) { if (bean instanceof DataSource) {
return new DataSourceProxy((DataSource) bean); return new DataSourceProxy((DataSource) bean);
} }

@ -79,7 +79,7 @@ class DataSourcePropertiesTests {
} }
@Test @Test
void whenEmbeddedConnectionIsNoneAndNoUrlIsConfiguredThenDetermineUrlThrows() throws Exception { void whenEmbeddedConnectionIsNoneAndNoUrlIsConfiguredThenDetermineUrlThrows() {
DataSourceProperties properties = new DataSourceProperties(); DataSourceProperties properties = new DataSourceProperties();
properties.setGenerateUniqueName(false); properties.setGenerateUniqueName(false);
properties.setEmbeddedDatabaseConnection(EmbeddedDatabaseConnection.NONE); properties.setEmbeddedDatabaseConnection(EmbeddedDatabaseConnection.NONE);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.jdbc;
import java.util.Set; import java.util.Set;
import javax.naming.Context; import javax.naming.Context;
import javax.naming.NamingException;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.apache.commons.dbcp2.BasicDataSource; import org.apache.commons.dbcp2.BasicDataSource;
@ -80,7 +79,7 @@ class JndiDataSourceAutoConfigurationTests {
} }
@Test @Test
void dataSourceIsAvailableFromJndi() throws IllegalStateException, NamingException { void dataSourceIsAvailableFromJndi() {
DataSource dataSource = new BasicDataSource(); DataSource dataSource = new BasicDataSource();
configureJndi("foo", dataSource); configureJndi("foo", dataSource);
@ -94,7 +93,7 @@ class JndiDataSourceAutoConfigurationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
void mbeanDataSourceIsExcludedFromExport() throws IllegalStateException, NamingException { void mbeanDataSourceIsExcludedFromExport() {
DataSource dataSource = new BasicDataSource(); DataSource dataSource = new BasicDataSource();
configureJndi("foo", dataSource); configureJndi("foo", dataSource);
@ -111,7 +110,7 @@ class JndiDataSourceAutoConfigurationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
void mbeanDataSourceIsExcludedFromExportByAllExporters() throws IllegalStateException, NamingException { void mbeanDataSourceIsExcludedFromExportByAllExporters() {
DataSource dataSource = new BasicDataSource(); DataSource dataSource = new BasicDataSource();
configureJndi("foo", dataSource); configureJndi("foo", dataSource);
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
@ -128,7 +127,7 @@ class JndiDataSourceAutoConfigurationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
void standardDataSourceIsNotExcludedFromExport() throws IllegalStateException, NamingException { void standardDataSourceIsNotExcludedFromExport() {
DataSource dataSource = mock(DataSource.class); DataSource dataSource = mock(DataSource.class);
configureJndi("foo", dataSource); configureJndi("foo", dataSource);
@ -143,7 +142,7 @@ class JndiDataSourceAutoConfigurationTests {
assertThat(excludedBeans).isEmpty(); assertThat(excludedBeans).isEmpty();
} }
private void configureJndi(String name, DataSource dataSource) throws IllegalStateException { private void configureJndi(String name, DataSource dataSource) {
TestableInitialContextFactory.bind(name, dataSource); TestableInitialContextFactory.bind(name, dataSource);
} }

@ -24,7 +24,6 @@ import org.apache.activemq.ActiveMQConnectionFactory;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.messaginghub.pooled.jms.JmsPoolConnectionFactory; import org.messaginghub.pooled.jms.JmsPoolConnectionFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration; import org.springframework.boot.autoconfigure.jms.activemq.ActiveMQAutoConfiguration;
@ -440,7 +439,7 @@ class JmsAutoConfigurationTests {
static class TestConfiguration4 implements BeanPostProcessor { static class TestConfiguration4 implements BeanPostProcessor {
@Override @Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { public Object postProcessAfterInitialization(Object bean, String beanName) {
if (bean.getClass().isAssignableFrom(JmsTemplate.class)) { if (bean.getClass().isAssignableFrom(JmsTemplate.class)) {
JmsTemplate jmsTemplate = (JmsTemplate) bean; JmsTemplate jmsTemplate = (JmsTemplate) bean;
jmsTemplate.setPubSubDomain(true); jmsTemplate.setPubSubDomain(true);
@ -449,7 +448,7 @@ class JmsAutoConfigurationTests {
} }
@Override @Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { public Object postProcessBeforeInitialization(Object bean, String beanName) {
return bean; return bean;
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -35,7 +35,7 @@ public class TestableInitialContextFactory implements InitialContextFactory {
private static TestableContext context; private static TestableContext context;
@Override @Override
public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException { public Context getInitialContext(Hashtable<?, ?> environment) {
return getContext(); return getContext();
} }
@ -78,7 +78,7 @@ public class TestableInitialContextFactory implements InitialContextFactory {
} }
@Override @Override
public Object lookup(String name) throws NamingException { public Object lookup(String name) {
return this.bindings.get(name); return this.bindings.get(name);
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -238,7 +238,7 @@ class MailSenderAutoConfigurationTests {
}); });
} }
private Session configureJndiSession(String name) throws IllegalStateException { private Session configureJndiSession(String name) {
Properties properties = new Properties(); Properties properties = new Properties();
Session session = Session.getDefaultInstance(properties); Session session = Session.getDefaultInstance(properties);
TestableInitialContextFactory.bind(name, session); TestableInitialContextFactory.bind(name, session);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@
package org.springframework.boot.autoconfigure.mongo.embedded; package org.springframework.boot.autoconfigure.mongo.embedded;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Map; import java.util.Map;
@ -150,7 +149,7 @@ class EmbeddedMongoAutoConfigurationTests {
} }
@Test @Test
void mongoWritesToCustomDatabaseDir(@TempDir Path temp) throws IOException { void mongoWritesToCustomDatabaseDir(@TempDir Path temp) {
File customDatabaseDir = new File(temp.toFile(), "custom-database-dir"); File customDatabaseDir = new File(temp.toFile(), "custom-database-dir");
FileSystemUtils.deleteRecursively(customDatabaseDir); FileSystemUtils.deleteRecursively(customDatabaseDir);
load("spring.mongodb.embedded.storage.databaseDir=" + customDatabaseDir.getPath()); load("spring.mongodb.embedded.storage.databaseDir=" + customDatabaseDir.getPath());

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -54,7 +54,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class RSocketWebSocketNettyRouteProviderTests { class RSocketWebSocketNettyRouteProviderTests {
@Test @Test
void webEndpointsShouldWork() throws Exception { void webEndpointsShouldWork() {
new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebServerApplicationContext::new) new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebServerApplicationContext::new)
.withConfiguration( .withConfiguration(
AutoConfigurations.of(HttpHandlerAutoConfiguration.class, WebFluxAutoConfiguration.class, AutoConfigurations.of(HttpHandlerAutoConfiguration.class, WebFluxAutoConfiguration.class,

@ -23,7 +23,6 @@ import java.util.List;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import org.springframework.beans.BeansException;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration; import org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration;
import org.springframework.boot.test.context.FilteredClassLoader; import org.springframework.boot.test.context.FilteredClassLoader;
@ -253,7 +252,7 @@ class ReactiveOAuth2ClientAutoConfigurationTests {
static class TestServerHttpSecurity extends ServerHttpSecurity implements ApplicationContextAware { static class TestServerHttpSecurity extends ServerHttpSecurity implements ApplicationContextAware {
@Override @Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { public void setApplicationContext(ApplicationContext applicationContext) {
super.setApplicationContext(applicationContext); super.setApplicationContext(applicationContext);
} }

@ -469,7 +469,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
static class SecurityWebFilterChainConfig { static class SecurityWebFilterChainConfig {
@Bean @Bean
SecurityWebFilterChain testSpringSecurityFilterChain(ServerHttpSecurity http) throws Exception { SecurityWebFilterChain testSpringSecurityFilterChain(ServerHttpSecurity http) {
http.authorizeExchange((exchanges) -> { http.authorizeExchange((exchanges) -> {
exchanges.pathMatchers("/message/**").hasRole("ADMIN"); exchanges.pathMatchers("/message/**").hasRole("ADMIN");
exchanges.anyExchange().authenticated(); exchanges.anyExchange().authenticated();

@ -17,7 +17,6 @@
package org.springframework.boot.autoconfigure.transaction.jta; package org.springframework.boot.autoconfigure.transaction.jta;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import javax.jms.ConnectionFactory; import javax.jms.ConnectionFactory;
@ -115,7 +114,7 @@ class JtaAutoConfigurationTests {
} }
@Test @Test
void defaultAtomikosTransactionManagerName(@TempDir Path dir) throws IOException { void defaultAtomikosTransactionManagerName(@TempDir Path dir) {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
File logs = new File(dir.toFile(), "jta"); File logs = new File(dir.toFile(), "jta");
TestPropertyValues.of("spring.jta.logDir:" + logs.getAbsolutePath()).applyTo(this.context); TestPropertyValues.of("spring.jta.logDir:" + logs.getAbsolutePath()).applyTo(this.context);

@ -433,7 +433,7 @@ class ServerPropertiesTests {
} }
@Test @Test
void jettyMaxHttpFormPostSizeMatchesDefault() throws Exception { void jettyMaxHttpFormPostSizeMatchesDefault() {
JettyServletWebServerFactory jettyFactory = new JettyServletWebServerFactory(0); JettyServletWebServerFactory jettyFactory = new JettyServletWebServerFactory(0);
JettyWebServer jetty = (JettyWebServer) jettyFactory JettyWebServer jetty = (JettyWebServer) jettyFactory
.getWebServer((ServletContextInitializer) (servletContext) -> servletContext .getWebServer((ServletContextInitializer) (servletContext) -> servletContext
@ -527,7 +527,7 @@ class ServerPropertiesTests {
.isEqualTo(HttpDecoderSpec.DEFAULT_INITIAL_BUFFER_SIZE); .isEqualTo(HttpDecoderSpec.DEFAULT_INITIAL_BUFFER_SIZE);
} }
private Connector getDefaultConnector() throws Exception { private Connector getDefaultConnector() {
return new Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL); return new Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL);
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,7 +21,6 @@ import java.util.Map;
import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactory; import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactory;
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory; import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
import org.springframework.boot.web.server.WebServer; import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.server.WebServerException;
import org.springframework.http.server.reactive.HttpHandler; import org.springframework.http.server.reactive.HttpHandler;
import static org.mockito.Mockito.spy; import static org.mockito.Mockito.spy;
@ -72,12 +71,12 @@ public class MockReactiveWebServerFactory extends AbstractReactiveWebServerFacto
} }
@Override @Override
public void start() throws WebServerException { public void start() {
} }
@Override @Override
public void stop() throws WebServerException { public void stop() {
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,7 +29,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent; import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.util.unit.DataSize; import org.springframework.util.unit.DataSize;
import org.springframework.web.multipart.MultipartException;
import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartResolver; import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.servlet.DispatcherServlet; import org.springframework.web.servlet.DispatcherServlet;
@ -273,7 +272,7 @@ class DispatcherServletAutoConfigurationTests {
} }
@Override @Override
public MultipartHttpServletRequest resolveMultipart(HttpServletRequest request) throws MultipartException { public MultipartHttpServletRequest resolveMultipart(HttpServletRequest request) {
return null; return null;
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +23,6 @@ import javax.servlet.ServletContext;
import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredFilter; import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredFilter;
import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredServlet; import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredServlet;
import org.springframework.boot.web.server.WebServer; import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.server.WebServerException;
import org.springframework.boot.web.servlet.ServletContextInitializer; import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory; import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
@ -71,7 +70,7 @@ public class MockServletWebServerFactory extends AbstractServletWebServerFactory
} }
@Override @Override
public void start() throws WebServerException { public void start() {
} }
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -31,7 +31,6 @@ import org.eclipse.jetty.server.Server;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import reactor.netty.http.server.HttpServer; import reactor.netty.http.server.HttpServer;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
@ -455,7 +454,7 @@ class ServletWebServerFactoryAutoConfigurationTests {
static class EnsureWebServerHasNoServletContext implements BeanPostProcessor { static class EnsureWebServerHasNoServletContext implements BeanPostProcessor {
@Override @Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { public Object postProcessBeforeInitialization(Object bean, String beanName) {
if (bean instanceof ConfigurableServletWebServerFactory) { if (bean instanceof ConfigurableServletWebServerFactory) {
MockServletWebServerFactory webServerFactory = (MockServletWebServerFactory) bean; MockServletWebServerFactory webServerFactory = (MockServletWebServerFactory) bean;
assertThat(webServerFactory.getServletContext()).isNull(); assertThat(webServerFactory.getServletContext()).isNull();

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -98,7 +98,7 @@ class ServletWebServerFactoryCustomizerTests {
} }
@Test @Test
void customizeSessionProperties() throws Exception { void customizeSessionProperties() {
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("server.servlet.session.timeout", "123"); map.put("server.servlet.session.timeout", "123");
map.put("server.servlet.session.tracking-modes", "cookie,url"); map.put("server.servlet.session.tracking-modes", "cookie,url");

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -98,7 +98,7 @@ class BasicErrorControllerDirectMockMvcTests {
} }
@Test @Test
void errorPageNotAvailableWithWhitelabelDisabled() throws Exception { void errorPageNotAvailableWithWhitelabelDisabled() {
setup((ConfigurableWebApplicationContext) new SpringApplication(WebMvcIncludedConfiguration.class) setup((ConfigurableWebApplicationContext) new SpringApplication(WebMvcIncludedConfiguration.class)
.run("--server.port=0", "--server.error.whitelabel.enabled=false")); .run("--server.port=0", "--server.error.whitelabel.enabled=false"));
assertThatExceptionOfType(ServletException.class) assertThatExceptionOfType(ServletException.class)

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -180,7 +180,7 @@ class BasicErrorControllerMockMvcTests {
} }
@RequestMapping("/noContent") @RequestMapping("/noContent")
void noContent() throws Exception { void noContent() {
throw new NoContentException("Expected!"); throw new NoContentException("Expected!");
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -69,7 +69,7 @@ class ErrorMvcAutoConfigurationTests {
} }
@Test @Test
void renderCanUseJavaTimeTypeAsTimestamp() throws Exception { // gh-23256 void renderCanUseJavaTimeTypeAsTimestamp() { // gh-23256
this.contextRunner.run((context) -> { this.contextRunner.run((context) -> {
View errorView = context.getBean("error", View.class); View errorView = context.getBean("error", View.class);
ErrorAttributes errorAttributes = context.getBean(ErrorAttributes.class); ErrorAttributes errorAttributes = context.getBean(ErrorAttributes.class);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -64,7 +64,7 @@ class ReproIntegrationTests {
} }
@Test @Test
void jarFileExtensionNeeded() throws Exception { void jarFileExtensionNeeded() {
assertThatExceptionOfType(ExecutionException.class) assertThatExceptionOfType(ExecutionException.class)
.isThrownBy(() -> this.cli.jar("secure.groovy", "data-jpa.groovy")) .isThrownBy(() -> this.cli.jar("secure.groovy", "data-jpa.groovy"))
.withMessageContaining("is not a JAR file"); .withMessageContaining("is not a JAR file");

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -94,7 +94,7 @@ class CommandRunnerTests {
} }
@Test @Test
void runWithoutArguments() throws Exception { void runWithoutArguments() {
assertThatExceptionOfType(NoArgumentsException.class).isThrownBy(this.commandRunner::run); assertThatExceptionOfType(NoArgumentsException.class).isThrownBy(this.commandRunner::run);
} }
@ -105,7 +105,7 @@ class CommandRunnerTests {
} }
@Test @Test
void missingCommand() throws Exception { void missingCommand() {
assertThatExceptionOfType(NoSuchCommandException.class).isThrownBy(() -> this.commandRunner.run("missing")); assertThatExceptionOfType(NoSuchCommandException.class).isThrownBy(() -> this.commandRunner.run("missing"));
} }
@ -170,13 +170,13 @@ class CommandRunnerTests {
} }
@Test @Test
void helpNoCommand() throws Exception { void helpNoCommand() {
assertThatExceptionOfType(NoHelpCommandArgumentsException.class) assertThatExceptionOfType(NoHelpCommandArgumentsException.class)
.isThrownBy(() -> this.commandRunner.run("help")); .isThrownBy(() -> this.commandRunner.run("help"));
} }
@Test @Test
void helpUnknownCommand() throws Exception { void helpUnknownCommand() {
assertThatExceptionOfType(NoSuchCommandException.class) assertThatExceptionOfType(NoSuchCommandException.class)
.isThrownBy(() -> this.commandRunner.run("help", "missing")); .isThrownBy(() -> this.commandRunner.run("help", "missing"));
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -199,7 +199,7 @@ class ProjectGenerationRequestTests {
} }
@Test @Test
void noTypeAndNoDefault() throws Exception { void noTypeAndNoDefault() {
assertThatExceptionOfType(ReportableException.class) assertThatExceptionOfType(ReportableException.class)
.isThrownBy(() -> this.request.generateUrl(readMetadata("types-conflict"))) .isThrownBy(() -> this.request.generateUrl(readMetadata("types-conflict")))
.withMessageContaining("no default is defined"); .withMessageContaining("no default is defined");

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -32,7 +32,7 @@ import static org.mockito.Mockito.mock;
class SpringApplicationRunnerTests { class SpringApplicationRunnerTests {
@Test @Test
void exceptionMessageWhenSourcesContainsNoClasses() throws Exception { void exceptionMessageWhenSourcesContainsNoClasses() {
SpringApplicationRunnerConfiguration configuration = mock(SpringApplicationRunnerConfiguration.class); SpringApplicationRunnerConfiguration configuration = mock(SpringApplicationRunnerConfiguration.class);
given(configuration.getClasspath()).willReturn(new String[] { "foo", "bar" }); given(configuration.getClasspath()).willReturn(new String[] { "foo", "bar" });
given(configuration.getLogLevel()).willReturn(Level.INFO); given(configuration.getLogLevel()).willReturn(Level.INFO);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,6 @@
package org.springframework.boot.devtools.tests; package org.springframework.boot.devtools.tests;
import java.io.IOException;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
@ -49,7 +47,7 @@ class DevToolsWithLazyInitializationIntegrationTests extends AbstractDevToolsInt
assertThat(template.getForObject(urlBase + "/two", String.class)).isEqualTo("two"); assertThat(template.getForObject(urlBase + "/two", String.class)).isEqualTo("two");
} }
static Object[] parameters() throws IOException { static Object[] parameters() {
Directories directories = new Directories(buildOutput, temp); Directories directories = new Directories(buildOutput, temp);
return new Object[] { new Object[] { new LocalApplicationLauncher(directories) }, return new Object[] { new Object[] { new LocalApplicationLauncher(directories) },
new Object[] { new ExplodedRemoteApplicationLauncher(directories) }, new Object[] { new ExplodedRemoteApplicationLauncher(directories) },

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -100,13 +100,13 @@ abstract class RemoteApplicationLauncher extends AbstractApplicationLauncher {
return StringUtils.collectionToDelimitedString(entries, File.pathSeparator); return StringUtils.collectionToDelimitedString(entries, File.pathSeparator);
} }
private int awaitServerPort(LaunchedJvm jvm, File serverPortFile) throws Exception { private int awaitServerPort(LaunchedJvm jvm, File serverPortFile) {
return Awaitility.waitAtMost(Duration.ofMinutes(3)) return Awaitility.waitAtMost(Duration.ofMinutes(3))
.until(() -> new ApplicationState(serverPortFile, jvm), ApplicationState::hasServerPort) .until(() -> new ApplicationState(serverPortFile, jvm), ApplicationState::hasServerPort)
.getServerPort(); .getServerPort();
} }
private void awaitRemoteSpringApplication(LaunchedJvm launchedJvm) throws Exception { private void awaitRemoteSpringApplication(LaunchedJvm launchedJvm) {
FileContents contents = new FileContents(launchedJvm.getStandardOut()); FileContents contents = new FileContents(launchedJvm.getStandardOut());
try { try {
Awaitility.waitAtMost(Duration.ofMinutes(3)).until(contents::get, Awaitility.waitAtMost(Duration.ofMinutes(3)).until(contents::get,

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,6 @@ import javax.sql.DataSource;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition;
import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.boot.test.util.TestPropertyValues;
@ -161,7 +160,7 @@ abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
static class DataSourceSpyBeanPostProcessor implements BeanPostProcessor { static class DataSourceSpyBeanPostProcessor implements BeanPostProcessor {
@Override @Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { public Object postProcessBeforeInitialization(Object bean, String beanName) {
if (bean instanceof DataSource) { if (bean instanceof DataSource) {
bean = spy(bean); bean = spy(bean);
} }
@ -169,7 +168,7 @@ abstract class AbstractDevToolsDataSourceAutoConfigurationTests {
} }
@Override @Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { public Object postProcessAfterInitialization(Object bean, String beanName) {
return bean; return bean;
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@
package org.springframework.boot.devtools.autoconfigure; package org.springframework.boot.devtools.autoconfigure;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.time.Duration; import java.time.Duration;
@ -52,7 +51,7 @@ import static org.mockito.Mockito.verify;
class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDataSourceAutoConfigurationTests { class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDataSourceAutoConfigurationTests {
@BeforeEach @BeforeEach
void before(@TempDir File tempDir) throws IOException { void before(@TempDir File tempDir) {
System.setProperty("derby.stream.error.file", new File(tempDir, "derby.log").getAbsolutePath()); System.setProperty("derby.stream.error.file", new File(tempDir, "derby.log").getAbsolutePath());
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -37,42 +37,42 @@ class ChangedFileTests {
File tempDir; File tempDir;
@Test @Test
void sourceDirectoryMustNotBeNull() throws Exception { void sourceDirectoryMustNotBeNull() {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> new ChangedFile(null, new File(this.tempDir, "file"), Type.ADD)) .isThrownBy(() -> new ChangedFile(null, new File(this.tempDir, "file"), Type.ADD))
.withMessageContaining("SourceDirectory must not be null"); .withMessageContaining("SourceDirectory must not be null");
} }
@Test @Test
void fileMustNotBeNull() throws Exception { void fileMustNotBeNull() {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> new ChangedFile(new File(this.tempDir, "directory"), null, Type.ADD)) .isThrownBy(() -> new ChangedFile(new File(this.tempDir, "directory"), null, Type.ADD))
.withMessageContaining("File must not be null"); .withMessageContaining("File must not be null");
} }
@Test @Test
void typeMustNotBeNull() throws Exception { void typeMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy( assertThatIllegalArgumentException().isThrownBy(
() -> new ChangedFile(new File(this.tempDir, "file"), new File(this.tempDir, "directory"), null)) () -> new ChangedFile(new File(this.tempDir, "file"), new File(this.tempDir, "directory"), null))
.withMessageContaining("Type must not be null"); .withMessageContaining("Type must not be null");
} }
@Test @Test
void getFile() throws Exception { void getFile() {
File file = new File(this.tempDir, "file"); File file = new File(this.tempDir, "file");
ChangedFile changedFile = new ChangedFile(new File(this.tempDir, "directory"), file, Type.ADD); ChangedFile changedFile = new ChangedFile(new File(this.tempDir, "directory"), file, Type.ADD);
assertThat(changedFile.getFile()).isEqualTo(file); assertThat(changedFile.getFile()).isEqualTo(file);
} }
@Test @Test
void getType() throws Exception { void getType() {
ChangedFile changedFile = new ChangedFile(new File(this.tempDir, "directory"), new File(this.tempDir, "file"), ChangedFile changedFile = new ChangedFile(new File(this.tempDir, "directory"), new File(this.tempDir, "file"),
Type.DELETE); Type.DELETE);
assertThat(changedFile.getType()).isEqualTo(Type.DELETE); assertThat(changedFile.getType()).isEqualTo(Type.DELETE);
} }
@Test @Test
void getRelativeName() throws Exception { void getRelativeName() {
File subDirectory = new File(this.tempDir, "A"); File subDirectory = new File(this.tempDir, "A");
File file = new File(subDirectory, "B.txt"); File file = new File(subDirectory, "B.txt");
ChangedFile changedFile = new ChangedFile(this.tempDir, file, Type.ADD); ChangedFile changedFile = new ChangedFile(this.tempDir, file, Type.ADD);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -65,7 +65,7 @@ class DirectorySnapshotTests {
} }
@Test @Test
void directoryDoesNotHaveToExist() throws Exception { void directoryDoesNotHaveToExist() {
File file = new File(this.tempDir, "does/not/exist"); File file = new File(this.tempDir, "does/not/exist");
DirectorySnapshot snapshot = new DirectorySnapshot(file); DirectorySnapshot snapshot = new DirectorySnapshot(file);
assertThat(snapshot).isEqualTo(new DirectorySnapshot(file)); assertThat(snapshot).isEqualTo(new DirectorySnapshot(file));
@ -107,7 +107,7 @@ class DirectorySnapshotTests {
} }
@Test @Test
void getChangedFilesSnapshotMustBeTheSameSourceDirectory() throws Exception { void getChangedFilesSnapshotMustBeTheSameSourceDirectory() {
assertThatIllegalArgumentException().isThrownBy( assertThatIllegalArgumentException().isThrownBy(
() -> this.initialSnapshot.getChangedFiles(new DirectorySnapshot(createTestDirectoryStructure()), null)) () -> this.initialSnapshot.getChangedFiles(new DirectorySnapshot(createTestDirectoryStructure()), null))
.withMessageContaining("Snapshot source directory must be '" + this.directory + "'"); .withMessageContaining("Snapshot source directory must be '" + this.directory + "'");

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -51,7 +51,7 @@ class FileSnapshotTests {
} }
@Test @Test
void fileMustNotBeADirectory() throws Exception { void fileMustNotBeADirectory() {
File file = new File(this.tempDir, "file"); File file = new File(this.tempDir, "file");
file.mkdir(); file.mkdir();
assertThatIllegalArgumentException().isThrownBy(() -> new FileSnapshot(file)) assertThatIllegalArgumentException().isThrownBy(() -> new FileSnapshot(file))

@ -110,7 +110,7 @@ class FileSystemWatcherTests {
} }
@Test @Test
void cannotAddSourceDirectoryToStartedListener() throws Exception { void cannotAddSourceDirectoryToStartedListener() {
this.watcher.start(); this.watcher.start();
assertThatIllegalStateException().isThrownBy(() -> this.watcher.addSourceDirectory(this.tempDir)) assertThatIllegalStateException().isThrownBy(() -> this.watcher.addSourceDirectory(this.tempDir))
.withMessageContaining("FileSystemWatcher already started"); .withMessageContaining("FileSystemWatcher already started");
@ -300,7 +300,7 @@ class FileSystemWatcherTests {
this.watcher.addListener((changeSet) -> FileSystemWatcherTests.this.changes.add(changeSet)); this.watcher.addListener((changeSet) -> FileSystemWatcherTests.this.changes.add(changeSet));
} }
private File startWithNewDirectory() throws IOException { private File startWithNewDirectory() {
File directory = new File(this.tempDir, UUID.randomUUID().toString()); File directory = new File(this.tempDir, UUID.randomUUID().toString());
directory.mkdir(); directory.mkdir();
this.watcher.addSourceDirectory(directory); this.watcher.addSourceDirectory(directory);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -58,13 +58,13 @@ class ConnectionInputStreamTests {
} }
@Test @Test
void checkedRead() throws Exception { void checkedRead() {
ConnectionInputStream inputStream = new ConnectionInputStream(new ByteArrayInputStream(NO_BYTES)); ConnectionInputStream inputStream = new ConnectionInputStream(new ByteArrayInputStream(NO_BYTES));
assertThatIOException().isThrownBy(inputStream::checkedRead).withMessageContaining("End of stream"); assertThatIOException().isThrownBy(inputStream::checkedRead).withMessageContaining("End of stream");
} }
@Test @Test
void checkedReadArray() throws Exception { void checkedReadArray() {
byte[] buffer = new byte[100]; byte[] buffer = new byte[100];
ConnectionInputStream inputStream = new ConnectionInputStream(new ByteArrayInputStream(NO_BYTES)); ConnectionInputStream inputStream = new ConnectionInputStream(new ByteArrayInputStream(NO_BYTES));
assertThatIOException().isThrownBy(() -> inputStream.checkedRead(buffer, 0, buffer.length)) assertThatIOException().isThrownBy(() -> inputStream.checkedRead(buffer, 0, buffer.length))

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -85,14 +85,14 @@ class FrameTests {
} }
@Test @Test
void readFragmentedNotSupported() throws Exception { void readFragmentedNotSupported() {
byte[] bytes = new byte[] { 0x0F }; byte[] bytes = new byte[] { 0x0F };
assertThatIllegalStateException().isThrownBy(() -> Frame.read(newConnectionInputStream(bytes))) assertThatIllegalStateException().isThrownBy(() -> Frame.read(newConnectionInputStream(bytes)))
.withMessageContaining("Fragmented frames are not supported"); .withMessageContaining("Fragmented frames are not supported");
} }
@Test @Test
void readLargeFramesNotSupported() throws Exception { void readLargeFramesNotSupported() {
byte[] bytes = new byte[] { (byte) 0x80, (byte) 0xFF }; byte[] bytes = new byte[] { (byte) 0x80, (byte) 0xFF };
assertThatIllegalStateException().isThrownBy(() -> Frame.read(newConnectionInputStream(bytes))) assertThatIllegalStateException().isThrownBy(() -> Frame.read(newConnectionInputStream(bytes)))
.withMessageContaining("Large frames are not supported"); .withMessageContaining("Large frames are not supported");

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -112,7 +112,7 @@ class LiveReloadServerTests {
assertThat(this.server.getClosedExceptions().size()).isGreaterThan(0); assertThat(this.server.getClosedExceptions().size()).isGreaterThan(0);
} }
private void awaitClosedException() throws InterruptedException { private void awaitClosedException() {
Awaitility.waitAtMost(Duration.ofSeconds(10)).until(this.server::getClosedExceptions, is(not(empty()))); Awaitility.waitAtMost(Duration.ofSeconds(10)).until(this.server::getClosedExceptions, is(not(empty())));
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -69,7 +69,7 @@ class DelayedLiveReloadTriggerTests {
private DelayedLiveReloadTrigger trigger; private DelayedLiveReloadTrigger trigger;
@BeforeEach @BeforeEach
void setup() throws IOException { void setup() {
this.trigger = new DelayedLiveReloadTrigger(this.liveReloadServer, this.requestFactory, URL); this.trigger = new DelayedLiveReloadTrigger(this.liveReloadServer, this.requestFactory, URL);
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -62,7 +62,7 @@ class HttpHeaderInterceptorTests {
private MockHttpServletRequest httpRequest; private MockHttpServletRequest httpRequest;
@BeforeEach @BeforeEach
void setup() throws Exception { void setup() {
this.body = new byte[] {}; this.body = new byte[] {};
this.httpRequest = new MockHttpServletRequest(); this.httpRequest = new MockHttpServletRequest();
this.request = new ServletServerHttpRequest(this.httpRequest); this.request = new ServletServerHttpRequest(this.httpRequest);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -57,13 +57,13 @@ class MainMethodTests {
} }
@Test @Test
void missingArgsMainMethod() throws Exception { void missingArgsMainMethod() {
assertThatIllegalStateException().isThrownBy(() -> new TestThread(MissingArgs::main).test()) assertThatIllegalStateException().isThrownBy(() -> new TestThread(MissingArgs::main).test())
.withMessageContaining("Unable to find main method"); .withMessageContaining("Unable to find main method");
} }
@Test @Test
void nonStatic() throws Exception { void nonStatic() {
assertThatIllegalStateException().isThrownBy(() -> new TestThread(() -> new NonStaticMain().main()).test()) assertThatIllegalStateException().isThrownBy(() -> new TestThread(() -> new NonStaticMain().main()).test())
.withMessageContaining("Unable to find main method"); .withMessageContaining("Unable to find main method");
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +24,6 @@ import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback; import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.ParameterContext; import org.junit.jupiter.api.extension.ParameterContext;
import org.junit.jupiter.api.extension.ParameterResolutionException;
import org.junit.jupiter.api.extension.ParameterResolver; import org.junit.jupiter.api.extension.ParameterResolver;
import org.springframework.beans.factory.ObjectFactory; import org.springframework.beans.factory.ObjectFactory;
@ -73,14 +72,12 @@ public class MockRestarter implements BeforeEachCallback, AfterEachCallback, Par
} }
@Override @Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
throws ParameterResolutionException {
return parameterContext.getParameter().getType().equals(Restarter.class); return parameterContext.getParameter().getType().equals(Restarter.class);
} }
@Override @Override
public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
throws ParameterResolutionException {
return this.mock; return this.mock;
} }

@ -185,7 +185,7 @@ class RestartClassLoaderTests {
} }
@Test @Test
void getDeletedClass() throws Exception { void getDeletedClass() {
String name = PACKAGE_PATH + "/Sample.class"; String name = PACKAGE_PATH + "/Sample.class";
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.DELETED, null)); this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.DELETED, null));
assertThatExceptionOfType(ClassNotFoundException.class) assertThatExceptionOfType(ClassNotFoundException.class)
@ -193,7 +193,7 @@ class RestartClassLoaderTests {
} }
@Test @Test
void getUpdatedClass() throws Exception { void getUpdatedClass() {
String name = PACKAGE_PATH + "/Sample.class"; String name = PACKAGE_PATH + "/Sample.class";
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.MODIFIED, new byte[10])); this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.MODIFIED, new byte[10]));
assertThatExceptionOfType(ClassFormatError.class) assertThatExceptionOfType(ClassFormatError.class)

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -63,7 +63,7 @@ class HttpTunnelPayloadForwarderTests {
} }
@Test @Test
void overflow() throws Exception { void overflow() {
WritableByteChannel channel = Channels.newChannel(new ByteArrayOutputStream()); WritableByteChannel channel = Channels.newChannel(new ByteArrayOutputStream());
HttpTunnelPayloadForwarder forwarder = new HttpTunnelPayloadForwarder(channel); HttpTunnelPayloadForwarder forwarder = new HttpTunnelPayloadForwarder(channel);
assertThatIllegalStateException().isThrownBy(() -> { assertThatIllegalStateException().isThrownBy(() -> {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -93,7 +93,7 @@ class HttpTunnelPayloadTests {
} }
@Test @Test
void getWithMissingHeader() throws Exception { void getWithMissingHeader() {
MockHttpServletRequest servletRequest = new MockHttpServletRequest(); MockHttpServletRequest servletRequest = new MockHttpServletRequest();
servletRequest.setContent("hello".getBytes()); servletRequest.setContent("hello".getBytes());
HttpInputMessage request = new ServletServerHttpRequest(servletRequest); HttpInputMessage request = new ServletServerHttpRequest(servletRequest);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -83,7 +83,7 @@ class HttpTunnelServerTests {
private MockServerChannel serverChannel; private MockServerChannel serverChannel;
@BeforeEach @BeforeEach
void setup() throws Exception { void setup() {
this.server = new HttpTunnelServer(this.serverConnection); this.server = new HttpTunnelServer(this.serverConnection);
this.servletRequest = new MockHttpServletRequest(); this.servletRequest = new MockHttpServletRequest();
this.servletRequest.setAsyncSupported(true); this.servletRequest.setAsyncSupported(true);

@ -47,7 +47,7 @@ class MetricsHealthMicrometerExportTests {
private MeterRegistry registry; private MeterRegistry registry;
@Test @Test
void registryExportsHealth() throws Exception { void registryExportsHealth() {
Gauge gauge = this.registry.get("health").gauge(); Gauge gauge = this.registry.get("health").gauge();
assertThat(gauge.value()).isEqualTo(2); assertThat(gauge.value()).isEqualTo(2);
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -61,7 +61,7 @@ class WebTestClientRestDocsAutoConfigurationAdvancedConfigurationIntegrationTest
} }
@Test @Test
void defaultSnippetsAreWritten() throws Exception { void defaultSnippetsAreWritten() {
this.webTestClient.get().uri("/").exchange().expectStatus().is2xxSuccessful().expectBody() this.webTestClient.get().uri("/").exchange().expectStatus().is2xxSuccessful().expectBody()
.consumeWith(document("default-snippets")); .consumeWith(document("default-snippets"));
File defaultSnippetsDir = new File(this.generatedSnippets, "default-snippets"); File defaultSnippetsDir = new File(this.generatedSnippets, "default-snippets");

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -54,7 +54,7 @@ class WebTestClientRestDocsAutoConfigurationIntegrationTests {
} }
@Test @Test
void defaultSnippetsAreWritten() throws Exception { void defaultSnippetsAreWritten() {
this.webTestClient.get().uri("/").exchange().expectStatus().is2xxSuccessful().expectBody() this.webTestClient.get().uri("/").exchange().expectStatus().is2xxSuccessful().expectBody()
.consumeWith(document("default-snippets")); .consumeWith(document("default-snippets"));
File defaultSnippetsDir = new File(this.generatedSnippets, "default-snippets"); File defaultSnippetsDir = new File(this.generatedSnippets, "default-snippets");

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -67,7 +67,7 @@ class WebTestClientSpringBootTestIntegrationTests {
static class TestConfiguration { static class TestConfiguration {
@Bean @Bean
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) throws Exception { SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http.authorizeExchange((exchanges) -> exchanges.anyExchange().permitAll()); http.authorizeExchange((exchanges) -> exchanges.anyExchange().permitAll());
return http.build(); return http.build();
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -70,7 +70,7 @@ class WebMvcTestAllControllersIntegrationTests {
} }
@Test @Test
void shouldRunValidationFailure() throws Exception { void shouldRunValidationFailure() {
assertThatExceptionOfType(NestedServletException.class) assertThatExceptionOfType(NestedServletException.class)
.isThrownBy(() -> this.mvc.perform(get("/three/invalid"))) .isThrownBy(() -> this.mvc.perform(get("/three/invalid")))
.withCauseInstanceOf(ConstraintViolationException.class); .withCauseInstanceOf(ConstraintViolationException.class);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -116,7 +116,7 @@ class JsonContentAssertTests {
} }
@Test @Test
void isEqualToWhenFileIsNotMatchingShouldFail() throws Exception { void isEqualToWhenFileIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class) assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(createFile(DIFFERENT))); .isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(createFile(DIFFERENT)));
} }
@ -199,7 +199,7 @@ class JsonContentAssertTests {
} }
@Test @Test
void isEqualToJsonWhenFileIsNotMatchingShouldFail() throws Exception { void isEqualToJsonWhenFileIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class) assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT))); .isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT)));
} }
@ -276,7 +276,7 @@ class JsonContentAssertTests {
} }
@Test @Test
void isStrictlyEqualToJsonWhenFileIsNotMatchingShouldFail() throws Exception { void isStrictlyEqualToJsonWhenFileIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class) assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createFile(LENIENT_SAME))); .isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createFile(LENIENT_SAME)));
} }
@ -430,7 +430,7 @@ class JsonContentAssertTests {
} }
@Test @Test
void isEqualToJsonWhenFileIsNotMatchingAndComparatorShouldFail() throws Exception { void isEqualToJsonWhenFileIsNotMatchingAndComparatorShouldFail() {
assertThatExceptionOfType(AssertionError.class) assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT), COMPARATOR)); .isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT), COMPARATOR));
} }
@ -496,7 +496,7 @@ class JsonContentAssertTests {
} }
@Test @Test
void isNotEqualToWhenFileIsMatchingShouldFail() throws Exception { void isNotEqualToWhenFileIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class) assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(createFile(LENIENT_SAME))); .isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(createFile(LENIENT_SAME)));
} }
@ -578,7 +578,7 @@ class JsonContentAssertTests {
} }
@Test @Test
void isNotEqualToJsonWhenFileIsMatchingShouldFail() throws Exception { void isNotEqualToJsonWhenFileIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class) assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME))); .isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME)));
} }
@ -655,7 +655,7 @@ class JsonContentAssertTests {
} }
@Test @Test
void isNotStrictlyEqualToJsonWhenFileIsMatchingShouldFail() throws Exception { void isNotStrictlyEqualToJsonWhenFileIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class) assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createFile(SOURCE))); .isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createFile(SOURCE)));
} }
@ -732,7 +732,7 @@ class JsonContentAssertTests {
} }
@Test @Test
void isNotEqualToJsonWhenFileIsMatchingAndLenientShouldFail() throws Exception { void isNotEqualToJsonWhenFileIsMatchingAndLenientShouldFail() {
assertThatExceptionOfType(AssertionError.class).isThrownBy( assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME), JSONCompareMode.LENIENT)); () -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME), JSONCompareMode.LENIENT));
} }
@ -809,7 +809,7 @@ class JsonContentAssertTests {
} }
@Test @Test
void isNotEqualToJsonWhenFileIsMatchingAndComparatorShouldFail() throws Exception { void isNotEqualToJsonWhenFileIsMatchingAndComparatorShouldFail() {
assertThatExceptionOfType(AssertionError.class) assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME), COMPARATOR)); .isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME), COMPARATOR));
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package org.springframework.boot.test.mock.mockito;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.MockBeanOnContextHierarchyIntegrationTests.ChildConfig; import org.springframework.boot.test.mock.mockito.MockBeanOnContextHierarchyIntegrationTests.ChildConfig;
import org.springframework.boot.test.mock.mockito.MockBeanOnContextHierarchyIntegrationTests.ParentConfig; import org.springframework.boot.test.mock.mockito.MockBeanOnContextHierarchyIntegrationTests.ParentConfig;
@ -73,7 +72,7 @@ class MockBeanOnContextHierarchyIntegrationTests {
private ApplicationContext context; private ApplicationContext context;
@Override @Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { public void setApplicationContext(ApplicationContext applicationContext) {
this.context = applicationContext; this.context = applicationContext;
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,7 +22,6 @@ import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.beans.BeanWrapper; import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
@ -309,7 +308,7 @@ class MockitoPostProcessorTests {
static class FactoryBeanRegisteringPostProcessor implements BeanFactoryPostProcessor, Ordered { static class FactoryBeanRegisteringPostProcessor implements BeanFactoryPostProcessor, Ordered {
@Override @Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
RootBeanDefinition beanDefinition = new RootBeanDefinition(TestFactoryBean.class); RootBeanDefinition beanDefinition = new RootBeanDefinition(TestFactoryBean.class);
((BeanDefinitionRegistry) beanFactory).registerBeanDefinition("test", beanDefinition); ((BeanDefinitionRegistry) beanFactory).registerBeanDefinition("test", beanDefinition);
} }
@ -325,7 +324,7 @@ class MockitoPostProcessorTests {
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
Map<String, BeanWrapper> cache = (Map<String, BeanWrapper>) ReflectionTestUtils.getField(beanFactory, Map<String, BeanWrapper> cache = (Map<String, BeanWrapper>) ReflectionTestUtils.getField(beanFactory,
"factoryBeanInstanceCache"); "factoryBeanInstanceCache");
Assert.isTrue(cache.isEmpty(), "Early initialization of factory bean triggered."); Assert.isTrue(cache.isEmpty(), "Early initialization of factory bean triggered.");

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package org.springframework.boot.test.mock.mockito;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.mock.mockito.SpyBeanOnContextHierarchyIntegrationTests.ChildConfig; import org.springframework.boot.test.mock.mockito.SpyBeanOnContextHierarchyIntegrationTests.ChildConfig;
import org.springframework.boot.test.mock.mockito.SpyBeanOnContextHierarchyIntegrationTests.ParentConfig; import org.springframework.boot.test.mock.mockito.SpyBeanOnContextHierarchyIntegrationTests.ParentConfig;
@ -74,7 +73,7 @@ class SpyBeanOnContextHierarchyIntegrationTests {
private ApplicationContext context; private ApplicationContext context;
@Override @Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { public void setApplicationContext(ApplicationContext applicationContext) {
this.context = applicationContext; this.context = applicationContext;
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.boot.test.web.client; package org.springframework.boot.test.web.client;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.BeanFactoryUtils;
@ -33,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class NoTestRestTemplateBeanChecker implements ImportSelector, BeanFactoryAware { class NoTestRestTemplateBeanChecker implements ImportSelector, BeanFactoryAware {
@Override @Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException { public void setBeanFactory(BeanFactory beanFactory) {
assertThat(BeanFactoryUtils.beanNamesForTypeIncludingAncestors((ListableBeanFactory) beanFactory, assertThat(BeanFactoryUtils.beanNamesForTypeIncludingAncestors((ListableBeanFactory) beanFactory,
TestRestTemplate.class)).isEmpty(); TestRestTemplate.class)).isEmpty();
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package org.springframework.boot.test.web.client;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@ -58,7 +57,7 @@ class TestRestTemplateContextCustomizerTests {
private final ConfigurableListableBeanFactory beanFactory = new DefaultListableBeanFactory(); private final ConfigurableListableBeanFactory beanFactory = new DefaultListableBeanFactory();
@Override @Override
protected void refreshBeanFactory() throws BeansException, IllegalStateException { protected void refreshBeanFactory() {
} }
@Override @Override
@ -67,7 +66,7 @@ class TestRestTemplateContextCustomizerTests {
} }
@Override @Override
public ConfigurableListableBeanFactory getBeanFactory() throws IllegalStateException { public ConfigurableListableBeanFactory getBeanFactory() {
return this.beanFactory; return this.beanFactory;
} }

@ -125,7 +125,7 @@ class TestRestTemplateTests {
} }
@Test @Test
void authenticated() throws Exception { void authenticated() {
TestRestTemplate restTemplate = new TestRestTemplate("user", "password"); TestRestTemplate restTemplate = new TestRestTemplate("user", "password");
assertBasicAuthorizationCredentials(restTemplate, "user", "password"); assertBasicAuthorizationCredentials(restTemplate, "user", "password");
} }
@ -150,7 +150,7 @@ class TestRestTemplateTests {
ReflectionUtils.doWithMethods(RestOperations.class, new MethodCallback() { ReflectionUtils.doWithMethods(RestOperations.class, new MethodCallback() {
@Override @Override
public void doWith(Method method) throws IllegalArgumentException { public void doWith(Method method) {
Method equivalent = ReflectionUtils.findMethod(TestRestTemplate.class, method.getName(), Method equivalent = ReflectionUtils.findMethod(TestRestTemplate.class, method.getName(),
method.getParameterTypes()); method.getParameterTypes());
assertThat(equivalent).as("Method %s not found", method).isNotNull(); assertThat(equivalent).as("Method %s not found", method).isNotNull();
@ -200,7 +200,7 @@ class TestRestTemplateTests {
} }
@Test @Test
void withBasicAuthAddsBasicAuthWhenNotAlreadyPresent() throws Exception { void withBasicAuthAddsBasicAuthWhenNotAlreadyPresent() {
TestRestTemplate original = new TestRestTemplate(); TestRestTemplate original = new TestRestTemplate();
TestRestTemplate basicAuth = original.withBasicAuth("user", "password"); TestRestTemplate basicAuth = original.withBasicAuth("user", "password");
assertThat(getConverterClasses(original)).containsExactlyElementsOf(getConverterClasses(basicAuth)); assertThat(getConverterClasses(original)).containsExactlyElementsOf(getConverterClasses(basicAuth));
@ -210,7 +210,7 @@ class TestRestTemplateTests {
} }
@Test @Test
void withBasicAuthReplacesBasicAuthWhenAlreadyPresent() throws Exception { void withBasicAuthReplacesBasicAuthWhenAlreadyPresent() {
TestRestTemplate original = new TestRestTemplate("foo", "bar").withBasicAuth("replace", "replace"); TestRestTemplate original = new TestRestTemplate("foo", "bar").withBasicAuth("replace", "replace");
TestRestTemplate basicAuth = original.withBasicAuth("user", "password"); TestRestTemplate basicAuth = original.withBasicAuth("user", "password");
assertThat(getConverterClasses(basicAuth)).containsExactlyElementsOf(getConverterClasses(original)); assertThat(getConverterClasses(basicAuth)).containsExactlyElementsOf(getConverterClasses(original));
@ -366,7 +366,7 @@ class TestRestTemplateTests {
} }
private void assertBasicAuthorizationCredentials(TestRestTemplate testRestTemplate, String username, private void assertBasicAuthorizationCredentials(TestRestTemplate testRestTemplate, String username,
String password) throws Exception { String password) {
ClientHttpRequest request = ReflectionTestUtils.invokeMethod(testRestTemplate.getRestTemplate(), ClientHttpRequest request = ReflectionTestUtils.invokeMethod(testRestTemplate.getRestTemplate(),
"createRequest", URI.create("http://localhost"), HttpMethod.POST); "createRequest", URI.create("http://localhost"), HttpMethod.POST);
if (username == null) { if (username == null) {

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.boot.test.web.reactive.server; package org.springframework.boot.test.web.reactive.server;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.BeanFactoryUtils;
@ -34,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class NoWebTestClientBeanChecker implements ImportSelector, BeanFactoryAware { class NoWebTestClientBeanChecker implements ImportSelector, BeanFactoryAware {
@Override @Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException { public void setBeanFactory(BeanFactory beanFactory) {
assertThat(BeanFactoryUtils.beanNamesForTypeIncludingAncestors((ListableBeanFactory) beanFactory, assertThat(BeanFactoryUtils.beanNamesForTypeIncludingAncestors((ListableBeanFactory) beanFactory,
WebTestClient.class)).isEmpty(); WebTestClient.class)).isEmpty();
} }

@ -53,7 +53,7 @@ class BuildpackResolversTests extends AbstractJsonTests {
} }
@Test @Test
void resolveAllWithBuilderBuildpackReferenceReturnsExpectedBuildpack() throws IOException { void resolveAllWithBuilderBuildpackReferenceReturnsExpectedBuildpack() {
BuildpackReference reference = BuildpackReference.of("urn:cnb:builder:paketo-buildpacks/spring-boot@3.5.0"); BuildpackReference reference = BuildpackReference.of("urn:cnb:builder:paketo-buildpacks/spring-boot@3.5.0");
Buildpacks buildpacks = BuildpackResolvers.resolveAll(this.resolverContext, Collections.singleton(reference)); Buildpacks buildpacks = BuildpackResolvers.resolveAll(this.resolverContext, Collections.singleton(reference));
assertThat(buildpacks.getBuildpacks()).hasSize(1); assertThat(buildpacks.getBuildpacks()).hasSize(1);
@ -92,7 +92,7 @@ class BuildpackResolversTests extends AbstractJsonTests {
} }
@Test @Test
void resolveAllWithInvalidLocatorThrowsException() throws IOException { void resolveAllWithInvalidLocatorThrowsException() {
BuildpackReference reference = BuildpackReference.of("unknown-buildpack@0.0.1"); BuildpackReference reference = BuildpackReference.of("unknown-buildpack@0.0.1");
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> BuildpackResolvers.resolveAll(this.resolverContext, Collections.singleton(reference))) .isThrownBy(() -> BuildpackResolvers.resolveAll(this.resolverContext, Collections.singleton(reference)))

@ -105,7 +105,7 @@ class ImageBuildpackTests extends AbstractJsonTests {
} }
@Test @Test
void resolveWhenFullyQualifiedReferenceWithInvalidImageReferenceThrowsException() throws Exception { void resolveWhenFullyQualifiedReferenceWithInvalidImageReferenceThrowsException() {
BuildpackReference reference = BuildpackReference.of("docker://buildpack@0.0.1"); BuildpackReference reference = BuildpackReference.of("docker://buildpack@0.0.1");
BuildpackResolverContext resolverContext = mock(BuildpackResolverContext.class); BuildpackResolverContext resolverContext = mock(BuildpackResolverContext.class);
assertThatIllegalArgumentException().isThrownBy(() -> ImageBuildpack.resolve(resolverContext, reference)) assertThatIllegalArgumentException().isThrownBy(() -> ImageBuildpack.resolve(resolverContext, reference))
@ -113,7 +113,7 @@ class ImageBuildpackTests extends AbstractJsonTests {
} }
@Test @Test
void resolveWhenUnqualifiedReferenceWithInvalidImageReferenceReturnsNull() throws Exception { void resolveWhenUnqualifiedReferenceWithInvalidImageReferenceReturnsNull() {
BuildpackReference reference = BuildpackReference.of("buildpack@0.0.1"); BuildpackReference reference = BuildpackReference.of("buildpack@0.0.1");
BuildpackResolverContext resolverContext = mock(BuildpackResolverContext.class); BuildpackResolverContext resolverContext = mock(BuildpackResolverContext.class);
Buildpack buildpack = ImageBuildpack.resolve(resolverContext, reference); Buildpack buildpack = ImageBuildpack.resolve(resolverContext, reference);

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -41,7 +41,7 @@ class MappedObjectTests extends AbstractJsonTests {
} }
@Test @Test
void ofReadsJson() throws Exception { void ofReadsJson() {
assertThat(this.mapped.getNode()).isNotNull(); assertThat(this.mapped.getNode()).isNotNull();
} }

@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurationMetadataTests { class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurationMetadataTests {
@Test @Test
void nullResource() throws IOException { void nullResource() {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> ConfigurationMetadataRepositoryJsonBuilder.create().withJsonResource(null)); .isThrownBy(() -> ConfigurationMetadataRepositoryJsonBuilder.create().withJsonResource(null));
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -46,7 +46,7 @@ class JsonReaderTests extends AbstractConfigurationMetadataTests {
} }
@Test @Test
void invalidMetadata() throws IOException { void invalidMetadata() {
assertThatIllegalStateException().isThrownBy(() -> readFor("invalid")).withCauseInstanceOf(JSONException.class); assertThatIllegalStateException().isThrownBy(() -> readFor("invalid")).withCauseInstanceOf(JSONException.class);
} }

@ -243,7 +243,7 @@ class ConfigurationMetadataAnnotationProcessorTests extends AbstractMetadataGene
} }
@Test @Test
void parseArrayConfig() throws Exception { void parseArrayConfig() {
ConfigurationMetadata metadata = compile(SimpleArrayProperties.class); ConfigurationMetadata metadata = compile(SimpleArrayProperties.class);
assertThat(metadata).has(Metadata.withGroup("array").ofType(SimpleArrayProperties.class)); assertThat(metadata).has(Metadata.withGroup("array").ofType(SimpleArrayProperties.class));
assertThat(metadata).has(Metadata.withProperty("array.primitive", "java.lang.Integer[]")); assertThat(metadata).has(Metadata.withProperty("array.primitive", "java.lang.Integer[]"));

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -41,14 +41,14 @@ class IntegratingWithActuatorDocumentationTests {
GradleBuild gradleBuild; GradleBuild gradleBuild;
@TestTemplate @TestTemplate
void basicBuildInfo() throws IOException { void basicBuildInfo() {
this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-basic").build("bootBuildInfo"); this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-basic").build("bootBuildInfo");
assertThat(new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties")) assertThat(new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties"))
.isFile(); .isFile();
} }
@TestTemplate @TestTemplate
void buildInfoCustomValues() throws IOException { void buildInfoCustomValues() {
this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-custom-values") this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-custom-values")
.build("bootBuildInfo"); .build("bootBuildInfo");
File file = new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties"); File file = new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties");
@ -61,7 +61,7 @@ class IntegratingWithActuatorDocumentationTests {
} }
@TestTemplate @TestTemplate
void buildInfoAdditional() throws IOException { void buildInfoAdditional() {
this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-additional") this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-additional")
.build("bootBuildInfo"); .build("bootBuildInfo");
File file = new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties"); File file = new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties");

@ -16,8 +16,6 @@
package org.springframework.boot.gradle.docs; package org.springframework.boot.gradle.docs;
import java.io.IOException;
import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.condition.DisabledForJreRange; import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.junit.jupiter.api.condition.JRE; import org.junit.jupiter.api.condition.JRE;
@ -41,14 +39,14 @@ class PublishingDocumentationTests {
@DisabledForJreRange(min = JRE.JAVA_16) @DisabledForJreRange(min = JRE.JAVA_16)
@TestTemplate @TestTemplate
void mavenUpload() throws IOException { void mavenUpload() {
assertThat(this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("5.6") assertThat(this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("5.6")
.script("src/docs/gradle/publishing/maven").build("deployerRepository").getOutput()) .script("src/docs/gradle/publishing/maven").build("deployerRepository").getOutput())
.contains("https://repo.example.com"); .contains("https://repo.example.com");
} }
@TestTemplate @TestTemplate
void mavenPublish() throws IOException { void mavenPublish() {
assertThat(this.gradleBuild.script("src/docs/gradle/publishing/maven-publish").build("publishingConfiguration") assertThat(this.gradleBuild.script("src/docs/gradle/publishing/maven-publish").build("publishingConfiguration")
.getOutput()).contains("MavenPublication").contains("https://repo.example.com"); .getOutput()).contains("MavenPublication").contains("https://repo.example.com");
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save