Remove unnecessary throws declaration in tests

See gh-26441
pull/26586/head
weixsun 4 years ago committed by Stephane Nicoll
parent 574655dc84
commit 8a2be288a3

@ -96,7 +96,7 @@ class CloudFoundryActuatorAutoConfigurationTests {
}
@Test
void cloudfoundryapplicationProducesActuatorMediaType() throws Exception {
void cloudfoundryapplicationProducesActuatorMediaType() {
this.contextRunner.withPropertyValues("VCAP_APPLICATION:---", "vcap.application.application_id:my-app-id",
"vcap.application.cf_api:https://my-cloud-controller.com").run((context) -> {
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");
* you may not use this file except in compliance with the License.
@ -91,7 +91,7 @@ class TokenValidatorTests {
}
@Test
void validateTokenWhenKidValidationFailsTwiceShouldThrowException() throws Exception {
void validateTokenWhenKidValidationFailsTwiceShouldThrowException() {
ReflectionTestUtils.setField(this.tokenValidator, "tokenKeys", INVALID_KEYS);
given(this.securityService.fetchTokenKeys()).willReturn(INVALID_KEYS);
String header = "{\"alg\": \"RS256\", \"kid\": \"valid-key\",\"typ\": \"JWT\"}";
@ -133,7 +133,7 @@ class TokenValidatorTests {
}
@Test
void validateTokenWhenSignatureInvalidShouldThrowException() throws Exception {
void validateTokenWhenSignatureInvalidShouldThrowException() {
ReflectionTestUtils.setField(this.tokenValidator, "tokenKeys",
Collections.singletonMap("valid-key", INVALID_KEY));
String header = "{ \"alg\": \"RS256\", \"kid\": \"valid-key\",\"typ\": \"JWT\"}";
@ -144,7 +144,7 @@ class TokenValidatorTests {
}
@Test
void validateTokenWhenTokenAlgorithmIsNotRS256ShouldThrowException() throws Exception {
void validateTokenWhenTokenAlgorithmIsNotRS256ShouldThrowException() {
String header = "{ \"alg\": \"HS256\", \"typ\": \"JWT\"}";
String claims = "{ \"exp\": 2147483647, \"iss\": \"http://localhost:8080/uaa/oauth/token\", \"scope\": [\"actuator.read\"]}";
assertThatExceptionOfType(CloudFoundryAuthorizationException.class).isThrownBy(
@ -153,7 +153,7 @@ class TokenValidatorTests {
}
@Test
void validateTokenWhenExpiredShouldThrowException() throws Exception {
void validateTokenWhenExpiredShouldThrowException() {
given(this.securityService.fetchTokenKeys()).willReturn(VALID_KEYS);
given(this.securityService.fetchTokenKeys()).willReturn(VALID_KEYS);
String header = "{ \"alg\": \"RS256\", \"kid\": \"valid-key\", \"typ\": \"JWT\"}";
@ -164,7 +164,7 @@ class TokenValidatorTests {
}
@Test
void validateTokenWhenIssuerIsNotValidShouldThrowException() throws Exception {
void validateTokenWhenIssuerIsNotValidShouldThrowException() {
given(this.securityService.fetchTokenKeys()).willReturn(VALID_KEYS);
given(this.securityService.getUaaUrl()).willReturn("https://other-uaa.com");
String header = "{ \"alg\": \"RS256\", \"kid\": \"valid-key\", \"typ\": \"JWT\", \"scope\": [\"actuator.read\"]}";
@ -175,7 +175,7 @@ class TokenValidatorTests {
}
@Test
void validateTokenWhenAudienceIsNotValidShouldThrowException() throws Exception {
void validateTokenWhenAudienceIsNotValidShouldThrowException() {
given(this.securityService.fetchTokenKeys()).willReturn(VALID_KEYS);
given(this.securityService.getUaaUrl()).willReturn("http://localhost:8080/uaa");
String header = "{ \"alg\": \"RS256\", \"kid\": \"valid-key\", \"typ\": \"JWT\"}";

@ -183,14 +183,14 @@ class ConditionalOnAvailableEndpointTests {
}
@Test // gh-21044
void outcomeWhenIncludeAllShouldMatchDashedEndpoint() throws Exception {
void outcomeWhenIncludeAllShouldMatchDashedEndpoint() {
this.contextRunner.withUserConfiguration(DashedEndpointConfiguration.class)
.withPropertyValues("management.endpoints.web.exposure.include=*")
.run((context) -> assertThat(context).hasSingleBean(DashedEndpoint.class));
}
@Test // gh-21044
void outcomeWhenIncludeDashedShouldMatchDashedEndpoint() throws Exception {
void outcomeWhenIncludeDashedShouldMatchDashedEndpoint() {
this.contextRunner.withUserConfiguration(DashedEndpointConfiguration.class)
.withPropertyValues("management.endpoints.web.exposure.include=test-dashed")
.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");
* you may not use this file except in compliance with the License.
@ -145,7 +145,7 @@ class IncludeExcludeEndpointFilterTests {
}
@Test // gh-20997
void matchWhenDashInName() throws Exception {
void matchWhenDashInName() {
setupFilter("bus-refresh", "");
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");
* you may not use this file except in compliance with the License.
@ -77,7 +77,7 @@ class MappingsEndpointReactiveDocumentationTests extends AbstractEndpointDocumen
}
@Test
void mappings() throws Exception {
void mappings() {
List<FieldDescriptor> requestMappingConditions = Arrays.asList(
requestMappingConditionField("").description("Details of the request mapping conditions.").optional(),
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");
* you may not use this file except in compliance with the License.
@ -76,7 +76,7 @@ class MappingsEndpointServletDocumentationTests extends AbstractEndpointDocument
}
@Test
void mappings() throws Exception {
void mappings() {
ResponseFieldsSnippet commonResponseFields = responseFields(
fieldWithPath("contexts").description("Application contexts keyed by id."),
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");
* you may not use this file except in compliance with the License.
@ -56,7 +56,7 @@ class ControllerEndpointWebFluxIntegrationTests {
}
@Test
void endpointsCanBeAccessed() throws Exception {
void endpointsCanBeAccessed() {
TestSecurityContextHolder.getContext()
.setAuthentication(new TestingAuthenticationToken("user", "N/A", "ROLE_ACTUATOR"));
this.context = new AnnotationConfigReactiveWebApplicationContext();

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

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

@ -159,7 +159,7 @@ class ReactiveManagementWebSecurityAutoConfigurationTests {
static class CustomSecurityConfiguration {
@Bean
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) throws Exception {
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http.authorizeExchange((exchanges) -> {
exchanges.pathMatchers("/foo").permitAll();
exchanges.anyExchange().authenticated();
@ -179,7 +179,7 @@ class ReactiveManagementWebSecurityAutoConfigurationTests {
}
@Bean
WebFilterChainProxy webFilterChainProxy(ServerHttpSecurity http) throws Exception {
WebFilterChainProxy webFilterChainProxy(ServerHttpSecurity http) {
return new WebFilterChainProxy(getFilterChains(http));
}
@ -190,7 +190,7 @@ class ReactiveManagementWebSecurityAutoConfigurationTests {
return httpSecurity;
}
private List<SecurityWebFilterChain> getFilterChains(ServerHttpSecurity http) throws Exception {
private List<SecurityWebFilterChain> getFilterChains(ServerHttpSecurity http) {
http.authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated());
http.formLogin(Customizer.withDefaults());
return Collections.singletonList(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");
* 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.AttributeList;
import javax.management.AttributeNotFoundException;
import javax.management.InvalidAttributeValueException;
import javax.management.MBeanException;
import javax.management.MBeanInfo;
import javax.management.ReflectionException;
@ -87,7 +86,7 @@ class EndpointMBeanTests {
}
@Test
void invokeWhenOperationFailedShouldTranslateException() throws MBeanException, ReflectionException {
void invokeWhenOperationFailedShouldTranslateException() {
TestExposableJmxEndpoint endpoint = new TestExposableJmxEndpoint(new TestJmxOperation((arguments) -> {
throw new FatalBeanException("test failure");
}));
@ -99,7 +98,7 @@ class EndpointMBeanTests {
}
@Test
void invokeWhenOperationFailedWithJdkExceptionShouldReuseException() throws MBeanException, ReflectionException {
void invokeWhenOperationFailedWithJdkExceptionShouldReuseException() {
TestExposableJmxEndpoint endpoint = new TestExposableJmxEndpoint(new TestJmxOperation((arguments) -> {
throw new UnsupportedOperationException("test failure");
}));
@ -110,7 +109,7 @@ class EndpointMBeanTests {
}
@Test
void invokeWhenActionNameIsNotAnOperationShouldThrowException() throws MBeanException, ReflectionException {
void invokeWhenActionNameIsNotAnOperationShouldThrowException() {
EndpointMBean bean = createEndpointMBean();
assertThatExceptionOfType(ReflectionException.class)
.isThrownBy(() -> bean.invoke("missingOperation", NO_PARAMS, NO_SIGNATURE))
@ -131,7 +130,7 @@ class EndpointMBeanTests {
}
@Test
void invokeWhenOperationIsInvalidShouldThrowException() throws MBeanException, ReflectionException {
void invokeWhenOperationIsInvalidShouldThrowException() {
TestJmxOperation operation = new TestJmxOperation() {
@Override
@ -166,15 +165,14 @@ class EndpointMBeanTests {
}
@Test
void getAttributeShouldThrowException() throws AttributeNotFoundException, MBeanException, ReflectionException {
void getAttributeShouldThrowException() {
EndpointMBean bean = createEndpointMBean();
assertThatExceptionOfType(AttributeNotFoundException.class).isThrownBy(() -> bean.getAttribute("test"))
.withMessageContaining("EndpointMBeans do not support attributes");
}
@Test
void setAttributeShouldThrowException()
throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
void setAttributeShouldThrowException() {
EndpointMBean bean = createEndpointMBean();
assertThatExceptionOfType(AttributeNotFoundException.class)
.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");
* you may not use this file except in compliance with the License.
@ -51,7 +51,7 @@ class ControllerEndpointHandlerMappingTests {
private final StaticApplicationContext context = new StaticApplicationContext();
@Test
void mappingWithNoPrefix() throws Exception {
void mappingWithNoPrefix() {
ExposableControllerEndpoint first = firstEndpoint();
ExposableControllerEndpoint second = secondEndpoint();
ControllerEndpointHandlerMapping mapping = createMapping("", first, second);
@ -62,7 +62,7 @@ class ControllerEndpointHandlerMappingTests {
}
@Test
void mappingWithPrefix() throws Exception {
void mappingWithPrefix() {
ExposableControllerEndpoint first = firstEndpoint();
ExposableControllerEndpoint second = secondEndpoint();
ControllerEndpointHandlerMapping mapping = createMapping("actuator", first, second);
@ -75,7 +75,7 @@ class ControllerEndpointHandlerMappingTests {
}
@Test
void mappingWithNoPath() throws Exception {
void mappingWithNoPath() {
ExposableControllerEndpoint pathless = pathlessEndpoint();
ControllerEndpointHandlerMapping mapping = createMapping("actuator", pathless);
assertThat(getHandler(mapping, HttpMethod.GET, "/actuator/pathless"))
@ -85,7 +85,7 @@ class ControllerEndpointHandlerMappingTests {
}
@Test
void mappingNarrowedToMethod() throws Exception {
void mappingNarrowedToMethod() {
ExposableControllerEndpoint first = firstEndpoint();
ControllerEndpointHandlerMapping mapping = createMapping("actuator", first);
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");
* you may not use this file except in compliance with the License.
@ -73,7 +73,7 @@ class ControllerEndpointHandlerMappingTests {
}
@Test
void mappingNarrowedToMethod() throws Exception {
void mappingNarrowedToMethod() {
ExposableControllerEndpoint first = firstEndpoint();
ControllerEndpointHandlerMapping mapping = createMapping("actuator", first);
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");
* you may not use this file except in compliance with the License.
@ -227,7 +227,7 @@ class EnvironmentEndpointTests {
}
@Test
void propertyWithCharSequenceTypeIsConvertedToString() throws Exception {
void propertyWithCharSequenceTypeIsConvertedToString() {
ConfigurableEnvironment environment = emptyEnvironment();
environment.getPropertySources().addFirst(singleKeyPropertySource("test", "foo", new CharSequenceProperty()));
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");
* you may not use this file except in compliance with the License.
@ -50,7 +50,7 @@ class LogFileWebEndpointWebIntegrationTests {
}
@BeforeAll
static void setup(@TempDir File temp) throws IOException {
static void setup(@TempDir File 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");
* you may not use this file except in compliance with the License.
@ -59,13 +59,13 @@ class HeapDumpWebEndpointWebIntegrationTests {
}
@WebEndpointTest
void getRequestShouldReturnHeapDumpInResponseBody(WebTestClient client) throws Exception {
void getRequestShouldReturnHeapDumpInResponseBody(WebTestClient client) {
client.get().uri("/actuator/heapdump").exchange().expectStatus().isOk().expectHeader()
.contentType(MediaType.APPLICATION_OCTET_STREAM).expectBody(String.class).isEqualTo("HEAPDUMP");
assertHeapDumpFileIsDeleted();
}
private void assertHeapDumpFileIsDeleted() throws InterruptedException {
private void assertHeapDumpFileIsDeleted() {
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");
* 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 {
@WebEndpointTest
void getRequestWithJsonAcceptHeaderShouldProduceJsonThreadDumpResponse(WebTestClient client) throws Exception {
void getRequestWithJsonAcceptHeaderShouldProduceJsonThreadDumpResponse(WebTestClient client) {
client.get().uri("/actuator/threaddump").accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk()
.expectHeader().contentType(MediaType.APPLICATION_JSON);
}
@WebEndpointTest
void getRequestWithTextPlainAcceptHeaderShouldProduceTextPlainResponse(WebTestClient client) throws Exception {
void getRequestWithTextPlainAcceptHeaderShouldProduceTextPlainResponse(WebTestClient client) {
String response = client.get().uri("/actuator/threaddump").accept(MediaType.TEXT_PLAIN).exchange()
.expectStatus().isOk().expectHeader().contentType("text/plain;charset=UTF-8").expectBody(String.class)
.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");
* you may not use this file except in compliance with the License.
@ -85,7 +85,7 @@ class WebMvcMetricsIntegrationTests {
}
@Test
void rethrownExceptionIsRecordedInMetricTag() throws Exception {
void rethrownExceptionIsRecordedInMetricTag() {
assertThatExceptionOfType(NestedServletException.class)
.isThrownBy(() -> this.mvc.perform(get("/api/rethrownError")).andReturn());
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");
* you may not use this file except in compliance with the License.
@ -99,7 +99,7 @@ class HttpTraceFilterTests {
}
@Test
void statusIsAssumedToBe500WhenChainFails() throws ServletException, IOException {
void statusIsAssumedToBe500WhenChainFails() {
assertThatIOException().isThrownBy(() -> this.filter.doFilter(new MockHttpServletRequest(),
new MockHttpServletResponse(), new MockFilterChain(new HttpServlet() {

@ -722,7 +722,7 @@ class RabbitAutoConfigurationTests {
}
@Test
void enableSslWithValidateServerCertificateFalse() throws Exception {
void enableSslWithValidateServerCertificateFalse() {
this.contextRunner.withUserConfiguration(TestConfiguration.class)
.withPropertyValues("spring.rabbitmq.ssl.enabled:true",
"spring.rabbitmq.ssl.validateServerCertificate=false")
@ -734,7 +734,7 @@ class RabbitAutoConfigurationTests {
}
@Test
void enableSslWithValidateServerCertificateDefault() throws Exception {
void enableSslWithValidateServerCertificateDefault() {
this.contextRunner.withUserConfiguration(TestConfiguration.class)
.withPropertyValues("spring.rabbitmq.ssl.enabled:true").run((context) -> {
com.rabbitmq.client.ConnectionFactory rabbitConnectionFactory = getTargetConnectionFactory(context);
@ -785,43 +785,42 @@ class RabbitAutoConfigurationTests {
}
@Test
void whenACredentialsProviderIsAvailableThenConnectionFactoryIsConfiguredToUseIt() throws Exception {
void whenACredentialsProviderIsAvailableThenConnectionFactoryIsConfiguredToUseIt() {
this.contextRunner.withUserConfiguration(CredentialsProviderConfiguration.class)
.run((context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsProvider())
.isEqualTo(CredentialsProviderConfiguration.credentialsProvider));
}
@Test
void whenAPrimaryCredentialsProviderIsAvailableThenConnectionFactoryIsConfiguredToUseIt() throws Exception {
void whenAPrimaryCredentialsProviderIsAvailableThenConnectionFactoryIsConfiguredToUseIt() {
this.contextRunner.withUserConfiguration(PrimaryCredentialsProviderConfiguration.class)
.run((context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsProvider())
.isEqualTo(PrimaryCredentialsProviderConfiguration.credentialsProvider));
}
@Test
void whenMultipleCredentialsProvidersAreAvailableThenConnectionFactoryUsesDefaultProvider() throws Exception {
void whenMultipleCredentialsProvidersAreAvailableThenConnectionFactoryUsesDefaultProvider() {
this.contextRunner.withUserConfiguration(MultipleCredentialsProvidersConfiguration.class)
.run((context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsProvider())
.isInstanceOf(DefaultCredentialsProvider.class));
}
@Test
void whenACredentialsRefreshServiceIsAvailableThenConnectionFactoryIsConfiguredToUseIt() throws Exception {
void whenACredentialsRefreshServiceIsAvailableThenConnectionFactoryIsConfiguredToUseIt() {
this.contextRunner.withUserConfiguration(CredentialsRefreshServiceConfiguration.class).run(
(context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsRefreshService())
.isEqualTo(CredentialsRefreshServiceConfiguration.credentialsRefreshService));
}
@Test
void whenAPrimaryCredentialsRefreshServiceIsAvailableThenConnectionFactoryIsConfiguredToUseIt() throws Exception {
void whenAPrimaryCredentialsRefreshServiceIsAvailableThenConnectionFactoryIsConfiguredToUseIt() {
this.contextRunner.withUserConfiguration(PrimaryCredentialsRefreshServiceConfiguration.class).run(
(context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsRefreshService())
.isEqualTo(PrimaryCredentialsRefreshServiceConfiguration.credentialsRefreshService));
}
@Test
void whenMultipleCredentialsRefreshServiceAreAvailableThenConnectionFactoryHasNoCredentialsRefreshService()
throws Exception {
void whenMultipleCredentialsRefreshServiceAreAvailableThenConnectionFactoryHasNoCredentialsRefreshService() {
this.contextRunner.withUserConfiguration(MultipleCredentialsRefreshServicesConfiguration.class).run(
(context) -> assertThat(getTargetConnectionFactory(context).params(null).getCredentialsRefreshService())
.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");
* you may not use this file except in compliance with the License.
@ -60,22 +60,22 @@ class BatchAutoConfigurationWithoutJdbcTests {
static class BatchConfiguration implements BatchConfigurer {
@Override
public JobRepository getJobRepository() throws Exception {
public JobRepository getJobRepository() {
return mock(JobRepository.class);
}
@Override
public PlatformTransactionManager getTransactionManager() throws Exception {
public PlatformTransactionManager getTransactionManager() {
return mock(PlatformTransactionManager.class);
}
@Override
public JobLauncher getJobLauncher() throws Exception {
public JobLauncher getJobLauncher() {
return mock(JobLauncher.class);
}
@Override
public JobExplorer getJobExplorer() throws Exception {
public JobExplorer getJobExplorer() {
return mock(JobExplorer.class);
}

@ -79,7 +79,7 @@ class DataSourcePropertiesTests {
}
@Test
void whenEmbeddedConnectionIsNoneAndNoUrlIsConfiguredThenDetermineUrlThrows() throws Exception {
void whenEmbeddedConnectionIsNoneAndNoUrlIsConfiguredThenDetermineUrlThrows() {
DataSourceProperties properties = new DataSourceProperties();
properties.setGenerateUniqueName(false);
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");
* 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 javax.naming.Context;
import javax.naming.NamingException;
import javax.sql.DataSource;
import org.apache.commons.dbcp2.BasicDataSource;
@ -80,7 +79,7 @@ class JndiDataSourceAutoConfigurationTests {
}
@Test
void dataSourceIsAvailableFromJndi() throws IllegalStateException, NamingException {
void dataSourceIsAvailableFromJndi() {
DataSource dataSource = new BasicDataSource();
configureJndi("foo", dataSource);
@ -94,7 +93,7 @@ class JndiDataSourceAutoConfigurationTests {
@SuppressWarnings("unchecked")
@Test
void mbeanDataSourceIsExcludedFromExport() throws IllegalStateException, NamingException {
void mbeanDataSourceIsExcludedFromExport() throws IllegalStateException {
DataSource dataSource = new BasicDataSource();
configureJndi("foo", dataSource);
@ -111,7 +110,7 @@ class JndiDataSourceAutoConfigurationTests {
@SuppressWarnings("unchecked")
@Test
void mbeanDataSourceIsExcludedFromExportByAllExporters() throws IllegalStateException, NamingException {
void mbeanDataSourceIsExcludedFromExportByAllExporters() throws IllegalStateException {
DataSource dataSource = new BasicDataSource();
configureJndi("foo", dataSource);
this.context = new AnnotationConfigApplicationContext();
@ -128,7 +127,7 @@ class JndiDataSourceAutoConfigurationTests {
@SuppressWarnings("unchecked")
@Test
void standardDataSourceIsNotExcludedFromExport() throws IllegalStateException, NamingException {
void standardDataSourceIsNotExcludedFromExport() throws IllegalStateException {
DataSource dataSource = mock(DataSource.class);
configureJndi("foo", dataSource);

@ -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");
* 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;
@Override
public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException {
public Context getInitialContext(Hashtable<?, ?> environment) {
return getContext();
}
@ -78,7 +78,7 @@ public class TestableInitialContextFactory implements InitialContextFactory {
}
@Override
public Object lookup(String name) throws NamingException {
public Object lookup(String name) {
return this.bindings.get(name);
}

@ -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");
* you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@
package org.springframework.boot.autoconfigure.mongo.embedded;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.EnumSet;
import java.util.Map;
@ -150,7 +149,7 @@ class EmbeddedMongoAutoConfigurationTests {
}
@Test
void mongoWritesToCustomDatabaseDir(@TempDir Path temp) throws IOException {
void mongoWritesToCustomDatabaseDir(@TempDir Path temp) {
File customDatabaseDir = new File(temp.toFile(), "custom-database-dir");
FileSystemUtils.deleteRecursively(customDatabaseDir);
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");
* 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 {
@Test
void webEndpointsShouldWork() throws Exception {
void webEndpointsShouldWork() {
new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebServerApplicationContext::new)
.withConfiguration(
AutoConfigurations.of(HttpHandlerAutoConfiguration.class, WebFluxAutoConfiguration.class,

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

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

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

@ -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");
* you may not use this file except in compliance with the License.
@ -98,7 +98,7 @@ class ServletWebServerFactoryCustomizerTests {
}
@Test
void customizeSessionProperties() throws Exception {
void customizeSessionProperties() {
Map<String, String> map = new HashMap<>();
map.put("server.servlet.session.timeout", "123");
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");
* you may not use this file except in compliance with the License.
@ -98,7 +98,7 @@ class BasicErrorControllerDirectMockMvcTests {
}
@Test
void errorPageNotAvailableWithWhitelabelDisabled() throws Exception {
void errorPageNotAvailableWithWhitelabelDisabled() {
setup((ConfigurableWebApplicationContext) new SpringApplication(WebMvcIncludedConfiguration.class)
.run("--server.port=0", "--server.error.whitelabel.enabled=false"));
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");
* you may not use this file except in compliance with the License.
@ -180,7 +180,7 @@ class BasicErrorControllerMockMvcTests {
}
@RequestMapping("/noContent")
void noContent() throws Exception {
void noContent() {
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");
* you may not use this file except in compliance with the License.
@ -69,7 +69,7 @@ class ErrorMvcAutoConfigurationTests {
}
@Test
void renderCanUseJavaTimeTypeAsTimestamp() throws Exception { // gh-23256
void renderCanUseJavaTimeTypeAsTimestamp() { // gh-23256
this.contextRunner.run((context) -> {
View errorView = context.getBean("error", View.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");
* you may not use this file except in compliance with the License.
@ -64,7 +64,7 @@ class ReproIntegrationTests {
}
@Test
void jarFileExtensionNeeded() throws Exception {
void jarFileExtensionNeeded() {
assertThatExceptionOfType(ExecutionException.class)
.isThrownBy(() -> this.cli.jar("secure.groovy", "data-jpa.groovy"))
.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");
* you may not use this file except in compliance with the License.
@ -94,7 +94,7 @@ class CommandRunnerTests {
}
@Test
void runWithoutArguments() throws Exception {
void runWithoutArguments() {
assertThatExceptionOfType(NoArgumentsException.class).isThrownBy(this.commandRunner::run);
}
@ -105,7 +105,7 @@ class CommandRunnerTests {
}
@Test
void missingCommand() throws Exception {
void missingCommand() {
assertThatExceptionOfType(NoSuchCommandException.class).isThrownBy(() -> this.commandRunner.run("missing"));
}
@ -170,13 +170,13 @@ class CommandRunnerTests {
}
@Test
void helpNoCommand() throws Exception {
void helpNoCommand() {
assertThatExceptionOfType(NoHelpCommandArgumentsException.class)
.isThrownBy(() -> this.commandRunner.run("help"));
}
@Test
void helpUnknownCommand() throws Exception {
void helpUnknownCommand() {
assertThatExceptionOfType(NoSuchCommandException.class)
.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");
* you may not use this file except in compliance with the License.
@ -199,7 +199,7 @@ class ProjectGenerationRequestTests {
}
@Test
void noTypeAndNoDefault() throws Exception {
void noTypeAndNoDefault() {
assertThatExceptionOfType(ReportableException.class)
.isThrownBy(() -> this.request.generateUrl(readMetadata("types-conflict")))
.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");
* you may not use this file except in compliance with the License.
@ -32,7 +32,7 @@ import static org.mockito.Mockito.mock;
class SpringApplicationRunnerTests {
@Test
void exceptionMessageWhenSourcesContainsNoClasses() throws Exception {
void exceptionMessageWhenSourcesContainsNoClasses() {
SpringApplicationRunnerConfiguration configuration = mock(SpringApplicationRunnerConfiguration.class);
given(configuration.getClasspath()).willReturn(new String[] { "foo", "bar" });
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");
* you may not use this file except in compliance with the License.
@ -16,8 +16,6 @@
package org.springframework.boot.devtools.tests;
import java.io.IOException;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@ -49,7 +47,7 @@ class DevToolsWithLazyInitializationIntegrationTests extends AbstractDevToolsInt
assertThat(template.getForObject(urlBase + "/two", String.class)).isEqualTo("two");
}
static Object[] parameters() throws IOException {
static Object[] parameters() {
Directories directories = new Directories(buildOutput, temp);
return new Object[] { new Object[] { new LocalApplicationLauncher(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");
* 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);
}
private int awaitServerPort(LaunchedJvm jvm, File serverPortFile) throws Exception {
private int awaitServerPort(LaunchedJvm jvm, File serverPortFile) {
return Awaitility.waitAtMost(Duration.ofMinutes(3))
.until(() -> new ApplicationState(serverPortFile, jvm), ApplicationState::hasServerPort)
.getServerPort();
}
private void awaitRemoteSpringApplication(LaunchedJvm launchedJvm) throws Exception {
private void awaitRemoteSpringApplication(LaunchedJvm launchedJvm) {
FileContents contents = new FileContents(launchedJvm.getStandardOut());
try {
Awaitility.waitAtMost(Duration.ofMinutes(3)).until(contents::get,

@ -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");
* you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@
package org.springframework.boot.devtools.autoconfigure;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.Duration;
@ -52,7 +51,7 @@ import static org.mockito.Mockito.verify;
class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevToolsDataSourceAutoConfigurationTests {
@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());
}

@ -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");
* you may not use this file except in compliance with the License.
@ -37,42 +37,42 @@ class ChangedFileTests {
File tempDir;
@Test
void sourceDirectoryMustNotBeNull() throws Exception {
void sourceDirectoryMustNotBeNull() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new ChangedFile(null, new File(this.tempDir, "file"), Type.ADD))
.withMessageContaining("SourceDirectory must not be null");
}
@Test
void fileMustNotBeNull() throws Exception {
void fileMustNotBeNull() {
assertThatIllegalArgumentException()
.isThrownBy(() -> new ChangedFile(new File(this.tempDir, "directory"), null, Type.ADD))
.withMessageContaining("File must not be null");
}
@Test
void typeMustNotBeNull() throws Exception {
void typeMustNotBeNull() {
assertThatIllegalArgumentException().isThrownBy(
() -> new ChangedFile(new File(this.tempDir, "file"), new File(this.tempDir, "directory"), null))
.withMessageContaining("Type must not be null");
}
@Test
void getFile() throws Exception {
void getFile() {
File file = new File(this.tempDir, "file");
ChangedFile changedFile = new ChangedFile(new File(this.tempDir, "directory"), file, Type.ADD);
assertThat(changedFile.getFile()).isEqualTo(file);
}
@Test
void getType() throws Exception {
void getType() {
ChangedFile changedFile = new ChangedFile(new File(this.tempDir, "directory"), new File(this.tempDir, "file"),
Type.DELETE);
assertThat(changedFile.getType()).isEqualTo(Type.DELETE);
}
@Test
void getRelativeName() throws Exception {
void getRelativeName() {
File subDirectory = new File(this.tempDir, "A");
File file = new File(subDirectory, "B.txt");
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");
* you may not use this file except in compliance with the License.
@ -65,7 +65,7 @@ class DirectorySnapshotTests {
}
@Test
void directoryDoesNotHaveToExist() throws Exception {
void directoryDoesNotHaveToExist() {
File file = new File(this.tempDir, "does/not/exist");
DirectorySnapshot snapshot = new DirectorySnapshot(file);
assertThat(snapshot).isEqualTo(new DirectorySnapshot(file));
@ -107,7 +107,7 @@ class DirectorySnapshotTests {
}
@Test
void getChangedFilesSnapshotMustBeTheSameSourceDirectory() throws Exception {
void getChangedFilesSnapshotMustBeTheSameSourceDirectory() {
assertThatIllegalArgumentException().isThrownBy(
() -> this.initialSnapshot.getChangedFiles(new DirectorySnapshot(createTestDirectoryStructure()), null))
.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");
* you may not use this file except in compliance with the License.
@ -51,7 +51,7 @@ class FileSnapshotTests {
}
@Test
void fileMustNotBeADirectory() throws Exception {
void fileMustNotBeADirectory() {
File file = new File(this.tempDir, "file");
file.mkdir();
assertThatIllegalArgumentException().isThrownBy(() -> new FileSnapshot(file))

@ -110,7 +110,7 @@ class FileSystemWatcherTests {
}
@Test
void cannotAddSourceDirectoryToStartedListener() throws Exception {
void cannotAddSourceDirectoryToStartedListener() {
this.watcher.start();
assertThatIllegalStateException().isThrownBy(() -> this.watcher.addSourceDirectory(this.tempDir))
.withMessageContaining("FileSystemWatcher already started");
@ -300,7 +300,7 @@ class FileSystemWatcherTests {
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());
directory.mkdir();
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");
* you may not use this file except in compliance with the License.
@ -58,13 +58,13 @@ class ConnectionInputStreamTests {
}
@Test
void checkedRead() throws Exception {
void checkedRead() {
ConnectionInputStream inputStream = new ConnectionInputStream(new ByteArrayInputStream(NO_BYTES));
assertThatIOException().isThrownBy(inputStream::checkedRead).withMessageContaining("End of stream");
}
@Test
void checkedReadArray() throws Exception {
void checkedReadArray() {
byte[] buffer = new byte[100];
ConnectionInputStream inputStream = new ConnectionInputStream(new ByteArrayInputStream(NO_BYTES));
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");
* you may not use this file except in compliance with the License.
@ -85,14 +85,14 @@ class FrameTests {
}
@Test
void readFragmentedNotSupported() throws Exception {
void readFragmentedNotSupported() {
byte[] bytes = new byte[] { 0x0F };
assertThatIllegalStateException().isThrownBy(() -> Frame.read(newConnectionInputStream(bytes)))
.withMessageContaining("Fragmented frames are not supported");
}
@Test
void readLargeFramesNotSupported() throws Exception {
void readLargeFramesNotSupported() {
byte[] bytes = new byte[] { (byte) 0x80, (byte) 0xFF };
assertThatIllegalStateException().isThrownBy(() -> Frame.read(newConnectionInputStream(bytes)))
.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");
* 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);
}
private void awaitClosedException() throws InterruptedException {
private void awaitClosedException() {
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");
* you may not use this file except in compliance with the License.
@ -69,7 +69,7 @@ class DelayedLiveReloadTriggerTests {
private DelayedLiveReloadTrigger trigger;
@BeforeEach
void setup() throws IOException {
void setup() {
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");
* you may not use this file except in compliance with the License.
@ -62,7 +62,7 @@ class HttpHeaderInterceptorTests {
private MockHttpServletRequest httpRequest;
@BeforeEach
void setup() throws Exception {
void setup() {
this.body = new byte[] {};
this.httpRequest = new MockHttpServletRequest();
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");
* you may not use this file except in compliance with the License.
@ -57,13 +57,13 @@ class MainMethodTests {
}
@Test
void missingArgsMainMethod() throws Exception {
void missingArgsMainMethod() {
assertThatIllegalStateException().isThrownBy(() -> new TestThread(MissingArgs::main).test())
.withMessageContaining("Unable to find main method");
}
@Test
void nonStatic() throws Exception {
void nonStatic() {
assertThatIllegalStateException().isThrownBy(() -> new TestThread(() -> new NonStaticMain().main()).test())
.withMessageContaining("Unable to find main method");
}

@ -185,7 +185,7 @@ class RestartClassLoaderTests {
}
@Test
void getDeletedClass() throws Exception {
void getDeletedClass() {
String name = PACKAGE_PATH + "/Sample.class";
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.DELETED, null));
assertThatExceptionOfType(ClassNotFoundException.class)
@ -193,7 +193,7 @@ class RestartClassLoaderTests {
}
@Test
void getUpdatedClass() throws Exception {
void getUpdatedClass() {
String name = PACKAGE_PATH + "/Sample.class";
this.updatedFiles.addFile(name, new ClassLoaderFile(Kind.MODIFIED, new byte[10]));
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");
* you may not use this file except in compliance with the License.
@ -63,7 +63,7 @@ class HttpTunnelPayloadForwarderTests {
}
@Test
void overflow() throws Exception {
void overflow() {
WritableByteChannel channel = Channels.newChannel(new ByteArrayOutputStream());
HttpTunnelPayloadForwarder forwarder = new HttpTunnelPayloadForwarder(channel);
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");
* you may not use this file except in compliance with the License.
@ -93,7 +93,7 @@ class HttpTunnelPayloadTests {
}
@Test
void getWithMissingHeader() throws Exception {
void getWithMissingHeader() {
MockHttpServletRequest servletRequest = new MockHttpServletRequest();
servletRequest.setContent("hello".getBytes());
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");
* you may not use this file except in compliance with the License.
@ -83,7 +83,7 @@ class HttpTunnelServerTests {
private MockServerChannel serverChannel;
@BeforeEach
void setup() throws Exception {
void setup() {
this.server = new HttpTunnelServer(this.serverConnection);
this.servletRequest = new MockHttpServletRequest();
this.servletRequest.setAsyncSupported(true);

@ -47,7 +47,7 @@ class MetricsHealthMicrometerExportTests {
private MeterRegistry registry;
@Test
void registryExportsHealth() throws Exception {
void registryExportsHealth() {
Gauge gauge = this.registry.get("health").gauge();
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");
* you may not use this file except in compliance with the License.
@ -61,7 +61,7 @@ class WebTestClientRestDocsAutoConfigurationAdvancedConfigurationIntegrationTest
}
@Test
void defaultSnippetsAreWritten() throws Exception {
void defaultSnippetsAreWritten() {
this.webTestClient.get().uri("/").exchange().expectStatus().is2xxSuccessful().expectBody()
.consumeWith(document("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");
* you may not use this file except in compliance with the License.
@ -54,7 +54,7 @@ class WebTestClientRestDocsAutoConfigurationIntegrationTests {
}
@Test
void defaultSnippetsAreWritten() throws Exception {
void defaultSnippetsAreWritten() {
this.webTestClient.get().uri("/").exchange().expectStatus().is2xxSuccessful().expectBody()
.consumeWith(document("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");
* you may not use this file except in compliance with the License.
@ -67,7 +67,7 @@ class WebTestClientSpringBootTestIntegrationTests {
static class TestConfiguration {
@Bean
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) throws Exception {
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http.authorizeExchange((exchanges) -> exchanges.anyExchange().permitAll());
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");
* you may not use this file except in compliance with the License.
@ -70,7 +70,7 @@ class WebMvcTestAllControllersIntegrationTests {
}
@Test
void shouldRunValidationFailure() throws Exception {
void shouldRunValidationFailure() {
assertThatExceptionOfType(NestedServletException.class)
.isThrownBy(() -> this.mvc.perform(get("/three/invalid")))
.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");
* you may not use this file except in compliance with the License.
@ -116,7 +116,7 @@ class JsonContentAssertTests {
}
@Test
void isEqualToWhenFileIsNotMatchingShouldFail() throws Exception {
void isEqualToWhenFileIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualTo(createFile(DIFFERENT)));
}
@ -199,7 +199,7 @@ class JsonContentAssertTests {
}
@Test
void isEqualToJsonWhenFileIsNotMatchingShouldFail() throws Exception {
void isEqualToJsonWhenFileIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT)));
}
@ -276,7 +276,7 @@ class JsonContentAssertTests {
}
@Test
void isStrictlyEqualToJsonWhenFileIsNotMatchingShouldFail() throws Exception {
void isStrictlyEqualToJsonWhenFileIsNotMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isStrictlyEqualToJson(createFile(LENIENT_SAME)));
}
@ -430,7 +430,7 @@ class JsonContentAssertTests {
}
@Test
void isEqualToJsonWhenFileIsNotMatchingAndComparatorShouldFail() throws Exception {
void isEqualToJsonWhenFileIsNotMatchingAndComparatorShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isEqualToJson(createFile(DIFFERENT), COMPARATOR));
}
@ -496,7 +496,7 @@ class JsonContentAssertTests {
}
@Test
void isNotEqualToWhenFileIsMatchingShouldFail() throws Exception {
void isNotEqualToWhenFileIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualTo(createFile(LENIENT_SAME)));
}
@ -578,7 +578,7 @@ class JsonContentAssertTests {
}
@Test
void isNotEqualToJsonWhenFileIsMatchingShouldFail() throws Exception {
void isNotEqualToJsonWhenFileIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME)));
}
@ -655,7 +655,7 @@ class JsonContentAssertTests {
}
@Test
void isNotStrictlyEqualToJsonWhenFileIsMatchingShouldFail() throws Exception {
void isNotStrictlyEqualToJsonWhenFileIsMatchingShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotStrictlyEqualToJson(createFile(SOURCE)));
}
@ -732,7 +732,7 @@ class JsonContentAssertTests {
}
@Test
void isNotEqualToJsonWhenFileIsMatchingAndLenientShouldFail() throws Exception {
void isNotEqualToJsonWhenFileIsMatchingAndLenientShouldFail() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(
() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME), JSONCompareMode.LENIENT));
}
@ -809,7 +809,7 @@ class JsonContentAssertTests {
}
@Test
void isNotEqualToJsonWhenFileIsMatchingAndComparatorShouldFail() throws Exception {
void isNotEqualToJsonWhenFileIsMatchingAndComparatorShouldFail() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(forJson(SOURCE)).isNotEqualToJson(createFile(LENIENT_SAME), COMPARATOR));
}

@ -125,7 +125,7 @@ class TestRestTemplateTests {
}
@Test
void authenticated() throws Exception {
void authenticated() {
TestRestTemplate restTemplate = new TestRestTemplate("user", "password");
assertBasicAuthorizationCredentials(restTemplate, "user", "password");
}
@ -200,7 +200,7 @@ class TestRestTemplateTests {
}
@Test
void withBasicAuthAddsBasicAuthWhenNotAlreadyPresent() throws Exception {
void withBasicAuthAddsBasicAuthWhenNotAlreadyPresent() {
TestRestTemplate original = new TestRestTemplate();
TestRestTemplate basicAuth = original.withBasicAuth("user", "password");
assertThat(getConverterClasses(original)).containsExactlyElementsOf(getConverterClasses(basicAuth));
@ -210,7 +210,7 @@ class TestRestTemplateTests {
}
@Test
void withBasicAuthReplacesBasicAuthWhenAlreadyPresent() throws Exception {
void withBasicAuthReplacesBasicAuthWhenAlreadyPresent() {
TestRestTemplate original = new TestRestTemplate("foo", "bar").withBasicAuth("replace", "replace");
TestRestTemplate basicAuth = original.withBasicAuth("user", "password");
assertThat(getConverterClasses(basicAuth)).containsExactlyElementsOf(getConverterClasses(original));
@ -366,7 +366,7 @@ class TestRestTemplateTests {
}
private void assertBasicAuthorizationCredentials(TestRestTemplate testRestTemplate, String username,
String password) throws Exception {
String password) {
ClientHttpRequest request = ReflectionTestUtils.invokeMethod(testRestTemplate.getRestTemplate(),
"createRequest", URI.create("http://localhost"), HttpMethod.POST);
if (username == null) {

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

@ -105,7 +105,7 @@ class ImageBuildpackTests extends AbstractJsonTests {
}
@Test
void resolveWhenFullyQualifiedReferenceWithInvalidImageReferenceThrowsException() throws Exception {
void resolveWhenFullyQualifiedReferenceWithInvalidImageReferenceThrowsException() {
BuildpackReference reference = BuildpackReference.of("docker://buildpack@0.0.1");
BuildpackResolverContext resolverContext = mock(BuildpackResolverContext.class);
assertThatIllegalArgumentException().isThrownBy(() -> ImageBuildpack.resolve(resolverContext, reference))
@ -113,7 +113,7 @@ class ImageBuildpackTests extends AbstractJsonTests {
}
@Test
void resolveWhenUnqualifiedReferenceWithInvalidImageReferenceReturnsNull() throws Exception {
void resolveWhenUnqualifiedReferenceWithInvalidImageReferenceReturnsNull() {
BuildpackReference reference = BuildpackReference.of("buildpack@0.0.1");
BuildpackResolverContext resolverContext = mock(BuildpackResolverContext.class);
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");
* you may not use this file except in compliance with the License.
@ -41,7 +41,7 @@ class MappedObjectTests extends AbstractJsonTests {
}
@Test
void ofReadsJson() throws Exception {
void ofReadsJson() {
assertThat(this.mapped.getNode()).isNotNull();
}

@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
class ConfigurationMetadataRepositoryJsonBuilderTests extends AbstractConfigurationMetadataTests {
@Test
void nullResource() throws IOException {
void nullResource() {
assertThatIllegalArgumentException()
.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");
* you may not use this file except in compliance with the License.
@ -46,7 +46,7 @@ class JsonReaderTests extends AbstractConfigurationMetadataTests {
}
@Test
void invalidMetadata() throws IOException {
void invalidMetadata() {
assertThatIllegalStateException().isThrownBy(() -> readFor("invalid")).withCauseInstanceOf(JSONException.class);
}

@ -243,7 +243,7 @@ class ConfigurationMetadataAnnotationProcessorTests extends AbstractMetadataGene
}
@Test
void parseArrayConfig() throws Exception {
void parseArrayConfig() {
ConfigurationMetadata metadata = compile(SimpleArrayProperties.class);
assertThat(metadata).has(Metadata.withGroup("array").ofType(SimpleArrayProperties.class));
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");
* you may not use this file except in compliance with the License.
@ -41,14 +41,14 @@ class IntegratingWithActuatorDocumentationTests {
GradleBuild gradleBuild;
@TestTemplate
void basicBuildInfo() throws IOException {
void basicBuildInfo() {
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"))
.isFile();
}
@TestTemplate
void buildInfoCustomValues() throws IOException {
void buildInfoCustomValues() {
this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-custom-values")
.build("bootBuildInfo");
File file = new File(this.gradleBuild.getProjectDir(), "build/resources/main/META-INF/build-info.properties");
@ -61,7 +61,7 @@ class IntegratingWithActuatorDocumentationTests {
}
@TestTemplate
void buildInfoAdditional() throws IOException {
void buildInfoAdditional() {
this.gradleBuild.script("src/docs/gradle/integrating-with-actuator/build-info-additional")
.build("bootBuildInfo");
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;
import java.io.IOException;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
@ -41,14 +39,14 @@ class PublishingDocumentationTests {
@DisabledForJreRange(min = JRE.JAVA_16)
@TestTemplate
void mavenUpload() throws IOException {
void mavenUpload() {
assertThat(this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("5.6")
.script("src/docs/gradle/publishing/maven").build("deployerRepository").getOutput())
.contains("https://repo.example.com");
}
@TestTemplate
void mavenPublish() throws IOException {
void mavenPublish() {
assertThat(this.gradleBuild.script("src/docs/gradle/publishing/maven-publish").build("publishingConfiguration")
.getOutput()).contains("MavenPublication").contains("https://repo.example.com");
}

@ -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");
* you may not use this file except in compliance with the License.
@ -65,25 +65,25 @@ class RunningDocumentationTests {
}
@TestTemplate
void bootRunSourceResources() throws IOException {
void bootRunSourceResources() {
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-source-resources")
.build("configuredClasspath").getOutput()).contains(new File("src/main/resources").getPath());
}
@TestTemplate
void bootRunDisableOptimizedLaunch() throws IOException {
void bootRunDisableOptimizedLaunch() {
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-disable-optimized-launch")
.build("optimizedLaunch").getOutput()).contains("false");
}
@TestTemplate
void bootRunSystemPropertyDefaultValue() throws IOException {
void bootRunSystemPropertyDefaultValue() {
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-system-property")
.build("configuredSystemProperties").getOutput()).contains("com.example.property = default");
}
@TestTemplate
void bootRunSystemPropetry() throws IOException {
void bootRunSystemPropetry() {
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-system-property")
.build("-Pexample=custom", "configuredSystemProperties").getOutput())
.contains("com.example.property = custom");

@ -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");
* you may not use this file except in compliance with the License.
@ -42,7 +42,7 @@ class BuildInfoDslIntegrationTests {
GradleBuild gradleBuild;
@TestTemplate
void basicJar() throws IOException {
void basicJar() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties();
@ -53,7 +53,7 @@ class BuildInfoDslIntegrationTests {
}
@TestTemplate
void jarWithCustomName() throws IOException {
void jarWithCustomName() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties();
@ -64,7 +64,7 @@ class BuildInfoDslIntegrationTests {
}
@TestTemplate
void basicWar() throws IOException {
void basicWar() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties();
@ -75,7 +75,7 @@ class BuildInfoDslIntegrationTests {
}
@TestTemplate
void warWithCustomName() throws IOException {
void warWithCustomName() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties();
@ -86,7 +86,7 @@ class BuildInfoDslIntegrationTests {
}
@TestTemplate
void additionalProperties() throws IOException {
void additionalProperties() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties();
@ -99,7 +99,7 @@ class BuildInfoDslIntegrationTests {
}
@TestTemplate
void classesDependency() throws IOException {
void classesDependency() {
assertThat(this.gradleBuild.build("classes", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
}

@ -92,7 +92,7 @@ class BuildInfoIntegrationTests {
}
@TestTemplate
void notUpToDateWhenExecutedTwiceWithFixedTimeAndChangedProjectVersion() throws IOException {
void notUpToDateWhenExecutedTwiceWithFixedTimeAndChangedProjectVersion() {
assertThat(this.gradleBuild.scriptProperty("projectVersion", "0.1.0").build("buildInfo").task(":buildInfo")
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.scriptProperty("projectVersion", "0.2.0").build("buildInfo").task(":buildInfo")

@ -86,7 +86,7 @@ abstract class AbstractBootArchiveIntegrationTests {
}
@TestTemplate
void basicBuild() throws InvalidRunnerConfigurationException, UnexpectedBuildFailure, IOException {
void basicBuild() {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
}
@ -106,7 +106,7 @@ abstract class AbstractBootArchiveIntegrationTests {
}
@TestTemplate
void upToDateWhenBuiltTwice() throws InvalidRunnerConfigurationException, UnexpectedBuildFailure, IOException {
void upToDateWhenBuiltTwice() {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
@ -114,8 +114,7 @@ abstract class AbstractBootArchiveIntegrationTests {
}
@TestTemplate
void upToDateWhenBuiltTwiceWithLaunchScriptIncluded()
throws InvalidRunnerConfigurationException, UnexpectedBuildFailure, IOException {
void upToDateWhenBuiltTwiceWithLaunchScriptIncluded() {
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName).task(":" + this.taskName)
.getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(this.gradleBuild.build("-PincludeLaunchScript=true", this.taskName).task(":" + this.taskName)
@ -167,7 +166,7 @@ abstract class AbstractBootArchiveIntegrationTests {
}
@TestTemplate
void duplicatesAreHandledGracefully() throws IOException {
void duplicatesAreHandledGracefully() {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
}
@ -257,7 +256,7 @@ abstract class AbstractBootArchiveIntegrationTests {
}
@TestTemplate
void layersWithCustomSourceSet() throws IOException {
void layersWithCustomSourceSet() {
assertThat(this.gradleBuild.build(this.taskName).task(":" + this.taskName).getOutcome())
.isEqualTo(TaskOutcome.SUCCESS);
}

@ -66,7 +66,7 @@ public class BootBuildImageRegistryIntegrationTests {
}
@TestTemplate
void buildsImageAndPublishesToRegistry() throws IOException, InterruptedException {
void buildsImageAndPublishesToRegistry() throws IOException {
writeMainClass();
String repoName = "test-image";
String imageName = this.registryAddress + "/" + repoName;

@ -17,8 +17,6 @@
package org.springframework.boot.gradle.tasks.bundling;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.TaskOutcome;
@ -43,7 +41,7 @@ class MavenIntegrationTests {
GradleBuild gradleBuild;
@TestTemplate
void bootJarCanBeUploaded() throws FileNotFoundException, IOException {
void bootJarCanBeUploaded() {
BuildResult result = this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("6.0.0")
.build("uploadBootArchives");
assertThat(result.task(":uploadBootArchives").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
@ -53,7 +51,7 @@ class MavenIntegrationTests {
}
@TestTemplate
void bootWarCanBeUploaded() throws IOException {
void bootWarCanBeUploaded() {
BuildResult result = this.gradleBuild.expectDeprecationWarningsWithAtLeastVersion("6.0.0")
.build("uploadBootArchives");
assertThat(result.task(":uploadBootArchives").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);

@ -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");
* you may not use this file except in compliance with the License.
@ -17,8 +17,6 @@
package org.springframework.boot.gradle.tasks.bundling;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.TaskOutcome;
@ -41,7 +39,7 @@ class MavenPublishingIntegrationTests {
GradleBuild gradleBuild;
@TestTemplate
void bootJarCanBePublished() throws FileNotFoundException, IOException {
void bootJarCanBePublished() {
BuildResult result = this.gradleBuild.build("publish");
assertThat(result.task(":publish").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(artifactWithSuffix("jar")).isFile();
@ -50,7 +48,7 @@ class MavenPublishingIntegrationTests {
}
@TestTemplate
void bootWarCanBePublished() throws IOException {
void bootWarCanBePublished() {
BuildResult result = this.gradleBuild.build("publish");
assertThat(result.task(":publish").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(artifactWithSuffix("war")).isFile();

@ -75,7 +75,7 @@ class ExtractCommandTests {
}
@Test
void runExtractsLayers() throws Exception {
void runExtractsLayers() {
given(this.context.getArchiveFile()).willReturn(this.jarFile);
given(this.context.getWorkingDir()).willReturn(this.extract);
this.command.run(Collections.emptyMap(), Collections.emptyList());

@ -51,7 +51,7 @@ class IndexedLayersTests {
}
@Test
void createWhenIndexFileIsMalformedThrowsException() throws Exception {
void createWhenIndexFileIsMalformedThrowsException() {
assertThatIllegalStateException().isThrownBy(() -> new IndexedLayers("test"))
.withMessage("Layer index file is malformed");
}

@ -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");
* you may not use this file except in compliance with the License.
@ -43,7 +43,7 @@ class FileUtilsTests {
private File originDirectory;
@BeforeEach
void init() throws IOException {
void init() {
this.outputDirectory = new File(this.tempDir, "remove");
this.originDirectory = new File(this.tempDir, "keep");
this.outputDirectory.mkdirs();

@ -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");
* you may not use this file except in compliance with the License.
@ -52,7 +52,7 @@ class LayersIndexTests {
}
@Test
void writeToWhenSimpleNamesSortsAlphabetically() throws Exception {
void writeToWhenSimpleNamesSortsAlphabetically() {
LayersIndex index = new LayersIndex(LAYER_A);
index.add(LAYER_A, "cat");
index.add(LAYER_A, "dog");

@ -42,7 +42,7 @@ class ClassPathIndexFileTests {
File temp;
@Test
void loadIfPossibleWhenRootIsNotFileReturnsNull() throws IOException {
void loadIfPossibleWhenRootIsNotFileReturnsNull() {
assertThatIllegalArgumentException()
.isThrownBy(() -> ClassPathIndexFile.loadIfPossible(new URL("https://example.com/file"), "test.idx"))
.withMessage("URL does not reference a file");
@ -95,7 +95,7 @@ class ClassPathIndexFileTests {
}
}
private ClassPathIndexFile copyAndLoadTestIndexFile() throws IOException, MalformedURLException {
private ClassPathIndexFile copyAndLoadTestIndexFile() throws IOException {
copyTestIndexFile();
ClassPathIndexFile indexFile = ClassPathIndexFile.loadIfPossible(this.temp.toURI().toURL(), "test.idx");
return indexFile;

@ -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");
* you may not use this file except in compliance with the License.
@ -401,7 +401,7 @@ class PropertiesLauncherTests {
assertThat(bytes).isNotEmpty();
}
private void waitFor(String value) throws Exception {
private void waitFor(String value) {
Awaitility.waitAtMost(Duration.ofSeconds(5)).until(this.output::toString, containsString(value));
}

@ -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");
* you may not use this file except in compliance with the License.
@ -96,23 +96,23 @@ class RandomAccessDataFileTests {
}
@Test
void readWhenOffsetIsBeyondEOFShouldThrowException() throws Exception {
void readWhenOffsetIsBeyondEOFShouldThrowException() {
assertThatExceptionOfType(IndexOutOfBoundsException.class).isThrownBy(() -> this.file.read(257, 0));
}
@Test
void readWhenOffsetIsBeyondEndOfSubsectionShouldThrowException() throws Exception {
void readWhenOffsetIsBeyondEndOfSubsectionShouldThrowException() {
RandomAccessData subsection = this.file.getSubsection(0, 10);
assertThatExceptionOfType(IndexOutOfBoundsException.class).isThrownBy(() -> subsection.read(11, 0));
}
@Test
void readWhenOffsetPlusLengthGreaterThanEOFShouldThrowException() throws Exception {
void readWhenOffsetPlusLengthGreaterThanEOFShouldThrowException() {
assertThatExceptionOfType(EOFException.class).isThrownBy(() -> this.file.read(256, 1));
}
@Test
void readWhenOffsetPlusLengthGreaterThanEndOfSubsectionShouldThrowException() throws Exception {
void readWhenOffsetPlusLengthGreaterThanEndOfSubsectionShouldThrowException() {
RandomAccessData subsection = this.file.getSubsection(0, 10);
assertThatExceptionOfType(EOFException.class).isThrownBy(() -> subsection.read(10, 1));
}
@ -125,13 +125,13 @@ class RandomAccessDataFileTests {
}
@Test
void inputStreamReadNullBytes() throws Exception {
void inputStreamReadNullBytes() {
assertThatNullPointerException().isThrownBy(() -> this.inputStream.read(null))
.withMessage("Bytes must not be null");
}
@Test
void inputStreamReadNullBytesWithOffset() throws Exception {
void inputStreamReadNullBytesWithOffset() {
assertThatNullPointerException().isThrownBy(() -> this.inputStream.read(null, 0, 1))
.withMessage("Bytes must not be 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");
* you may not use this file except in compliance with the License.
@ -44,7 +44,7 @@ class SimpleMainTests {
private static final String SPRING_STARTUP = "Started SpringApplication in";
@Test
void emptyApplicationContext() throws Exception {
void emptyApplicationContext() {
assertThatIllegalArgumentException().isThrownBy(() -> SpringApplication.main(getArgs()));
}

@ -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");
* you may not use this file except in compliance with the License.
@ -112,7 +112,7 @@ class SpringApplicationAdminMXBeanRegistrarTests {
}
@Test
void shutdownApp() throws InstanceNotFoundException {
void shutdownApp() {
final ObjectName objectName = createObjectName(OBJECT_NAME);
SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE);

@ -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");
* you may not use this file except in compliance with the License.
@ -68,7 +68,7 @@ class ApplicationPidFileWriterTests {
}
@Test
void createPidFile() throws Exception {
void createPidFile() {
File file = new File(this.tempDir, "pid");
ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file);
listener.onApplicationEvent(EVENT);
@ -76,7 +76,7 @@ class ApplicationPidFileWriterTests {
}
@Test
void overridePidFile() throws Exception {
void overridePidFile() {
File file = new File(this.tempDir, "pid");
System.setProperty("PIDFILE", new File(this.tempDir, "override").getAbsolutePath());
ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file);
@ -85,7 +85,7 @@ class ApplicationPidFileWriterTests {
}
@Test
void overridePidFileWithSpring() throws Exception {
void overridePidFileWithSpring() {
File file = new File(this.tempDir, "pid");
SpringApplicationEvent event = createPreparedEvent("spring.pid.file", file.getAbsolutePath());
ApplicationPidFileWriter listener = new ApplicationPidFileWriter();
@ -120,7 +120,7 @@ class ApplicationPidFileWriterTests {
}
@Test
void withNoEnvironment() throws Exception {
void withNoEnvironment() {
File file = new File(this.tempDir, "pid");
ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file);
listener.setTriggerEventType(ApplicationStartingEvent.class);

@ -88,7 +88,7 @@ class ConfigDataLoadersTests {
}
@Test
void loadWhenMultipleLoadersSupportLocationThrowsException() throws Exception {
void loadWhenMultipleLoadersSupportLocationThrowsException() {
TestConfigDataResource location = new TestConfigDataResource("test");
ConfigDataLoaders loaders = new ConfigDataLoaders(this.logFactory, this.bootstrapContext,
Arrays.asList(LoggingConfigDataLoader.class.getName(), TestConfigDataLoader.class.getName()));

@ -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");
* you may not use this file except in compliance with the License.
@ -57,7 +57,7 @@ class LoggingApplicationListenerIntegrationTests {
}
@Test
void logFileRegisteredInTheContextWhenApplicable(@TempDir File tempDir) throws Exception {
void logFileRegisteredInTheContextWhenApplicable(@TempDir File tempDir) {
String logFile = new File(tempDir, "test.log").getAbsolutePath();
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(SampleService.class)
.web(WebApplicationType.NONE).properties("logging.file.name=" + logFile).run()) {

@ -129,7 +129,7 @@ class LoggingApplicationListenerTests {
}
@AfterEach
void clear() throws IOException {
void clear() {
LoggingSystem loggingSystem = LoggingSystem.get(getClass().getClassLoader());
loggingSystem.setLogLevel("ROOT", LogLevel.INFO);
loggingSystem.cleanUp();
@ -420,7 +420,7 @@ class LoggingApplicationListenerTests {
}
@Test
void shutdownHookRegistrationCanBeDisabled() throws Exception {
void shutdownHookRegistrationCanBeDisabled() {
TestLoggingApplicationListener listener = new TestLoggingApplicationListener();
Object registered = ReflectionTestUtils.getField(listener, TestLoggingApplicationListener.class,
"shutdownHookRegistered");

@ -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");
* you may not use this file except in compliance with the License.
@ -16,8 +16,6 @@
package org.springframework.boot.context.properties;
import java.io.IOException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -53,7 +51,7 @@ class EnableConfigurationPropertiesRegistrarTests {
}
@Test
void typeWithDefaultConstructorShouldRegisterGenericBeanDefinition() throws Exception {
void typeWithDefaultConstructorShouldRegisterGenericBeanDefinition() {
register(TestConfiguration.class);
BeanDefinition beanDefinition = this.beanFactory
.getBeanDefinition("foo-" + getClass().getName() + "$FooProperties");
@ -61,7 +59,7 @@ class EnableConfigurationPropertiesRegistrarTests {
}
@Test
void typeWithConstructorBindingShouldRegisterConfigurationPropertiesBeanDefinition() throws Exception {
void typeWithConstructorBindingShouldRegisterConfigurationPropertiesBeanDefinition() {
register(TestConfiguration.class);
BeanDefinition beanDefinition = this.beanFactory
.getBeanDefinition("bar-" + getClass().getName() + "$BarProperties");
@ -69,7 +67,7 @@ class EnableConfigurationPropertiesRegistrarTests {
}
@Test
void typeWithMultipleConstructorsShouldRegisterGenericBeanDefinition() throws Exception {
void typeWithMultipleConstructorsShouldRegisterGenericBeanDefinition() {
register(TestConfiguration.class);
BeanDefinition beanDefinition = this.beanFactory
.getBeanDefinition("bing-" + getClass().getName() + "$BingProperties");
@ -84,14 +82,14 @@ class EnableConfigurationPropertiesRegistrarTests {
}
@Test
void registrationWithDuplicatedTypeShouldRegisterSingleBeanDefinition() throws IOException {
void registrationWithDuplicatedTypeShouldRegisterSingleBeanDefinition() {
register(DuplicateConfiguration.class);
String name = "foo-" + getClass().getName() + "$FooProperties";
verify(this.beanFactory, times(1)).registerBeanDefinition(eq(name), any());
}
@Test
void registrationWithNoTypeShouldNotRegisterAnything() throws IOException {
void registrationWithNoTypeShouldNotRegisterAnything() {
register(EmptyConfiguration.class);
String[] names = this.beanFactory.getBeanNamesForType(Object.class);
for (String name : names) {

@ -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");
* you may not use this file except in compliance with the License.
@ -153,7 +153,7 @@ class BindResultTests {
}
@Test
void orElseThrowWhenHasNoValueShouldThrowException() throws Exception {
void orElseThrowWhenHasNoValueShouldThrowException() {
BindResult<String> result = BindResult.of(null);
assertThatIOException().isThrownBy(() -> result.orElseThrow(IOException::new));
}

@ -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");
* you may not use this file except in compliance with the License.
@ -39,7 +39,7 @@ class DataObjectPropertyNameTests {
}
@Test
void toDashedFormWhenContainsIndexedAddsNoDashToIndex() throws Exception {
void toDashedFormWhenContainsIndexedAddsNoDashToIndex() {
assertThat(DataObjectPropertyName.toDashedForm("test[fooBar]")).isEqualTo("test[fooBar]");
assertThat(DataObjectPropertyName.toDashedForm("testAgain[fooBar]")).isEqualTo("test-again[fooBar]");
}

@ -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");
* you may not use this file except in compliance with the License.
@ -218,7 +218,7 @@ class ValidationBindHandlerTests {
}
@Test
void validateMapValues() throws Exception {
void validateMapValues() {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("test.items.[itemOne].number", "one");
source.put("test.items.[ITEM2].number", "two");
@ -229,7 +229,7 @@ class ValidationBindHandlerTests {
}
@Test
void validateMapValuesWithNonUniformSource() throws Exception {
void validateMapValuesWithNonUniformSource() {
Map<String, Object> map = new LinkedHashMap<>();
map.put("test.items.itemOne.number", "one");
map.put("test.items.ITEM2.number", "two");

@ -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");
* you may not use this file except in compliance with the License.
@ -37,7 +37,7 @@ import static org.junit.jupiter.api.Assumptions.assumingThat;
class InetAddressFormatterTests {
@ConversionServiceTest
void convertFromInetAddressToStringShouldConvert(ConversionService conversionService) throws UnknownHostException {
void convertFromInetAddressToStringShouldConvert(ConversionService conversionService) {
assumingThat(isResolvable("example.com"), () -> {
InetAddress address = InetAddress.getByName("example.com");
String converted = conversionService.convert(address, String.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");
* you may not use this file except in compliance with the License.
@ -34,7 +34,7 @@ class NoSnakeYamlPropertySourceLoaderTests {
private YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
@Test
void load() throws Exception {
void load() {
ByteArrayResource resource = new ByteArrayResource("foo:\n bar: spam".getBytes());
assertThatIllegalStateException().isThrownBy(() -> this.loader.load("resource", resource))
.withMessageContaining("Attempted to load resource but snakeyaml was not found on the classpath");

@ -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");
* you may not use this file except in compliance with the License.
@ -90,7 +90,7 @@ class OriginTrackedPropertiesLoaderTests {
}
@Test
void getMalformedUnicodeProperty() throws Exception {
void getMalformedUnicodeProperty() {
// gh-12716
ClassPathResource resource = new ClassPathResource("test-properties-malformed-unicode.properties", getClass());
assertThatIllegalStateException().isThrownBy(() -> new OriginTrackedPropertiesLoader(resource).load())

@ -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");
* you may not use this file except in compliance with the License.
@ -130,7 +130,7 @@ class OriginTrackedYamlLoaderTests {
}
@Test
void unsupportedType() throws Exception {
void unsupportedType() {
String yaml = "value: !!java.net.URL [!!java.lang.String [!!java.lang.StringBuilder [\"http://localhost:9000/\"]]]";
Resource resource = new ByteArrayResource(yaml.getBytes(StandardCharsets.UTF_8));
this.loader = new OriginTrackedYamlLoader(resource);

@ -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");
* you may not use this file except in compliance with the License.
@ -34,7 +34,7 @@ public class YamlJsonParserTests extends AbstractJsonParserTests {
}
@Test
void customTypesAreNotLoaded() throws Exception {
void customTypesAreNotLoaded() {
assertThatExceptionOfType(ConstructorException.class)
.isThrownBy(() -> getParser().parseMap("{value: !!java.net.URL [\"http://localhost:9000/\"]}"))
.withCauseInstanceOf(IllegalStateException.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");
* you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.boot.web.client;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
@ -48,14 +47,14 @@ public class RestTemplateBuilderClientHttpRequestInitializerTests {
private final MockClientHttpRequest request = new MockClientHttpRequest();
@Test
void createRequestWhenHasBasicAuthAndNoAuthHeaderAddsHeader() throws IOException {
void createRequestWhenHasBasicAuthAndNoAuthHeaderAddsHeader() {
new RestTemplateBuilderClientHttpRequestInitializer(new BasicAuthentication("spring", "boot", null),
Collections.emptyMap(), Collections.emptySet()).initialize(this.request);
assertThat(this.request.getHeaders().get(HttpHeaders.AUTHORIZATION)).containsExactly("Basic c3ByaW5nOmJvb3Q=");
}
@Test
void createRequestWhenHasBasicAuthAndExistingAuthHeaderDoesNotAddHeader() throws IOException {
void createRequestWhenHasBasicAuthAndExistingAuthHeaderDoesNotAddHeader() {
this.request.getHeaders().setBasicAuth("boot", "spring");
new RestTemplateBuilderClientHttpRequestInitializer(new BasicAuthentication("spring", "boot", null),
Collections.emptyMap(), Collections.emptySet()).initialize(this.request);
@ -63,7 +62,7 @@ public class RestTemplateBuilderClientHttpRequestInitializerTests {
}
@Test
void createRequestWhenHasDefaultHeadersAddsMissing() throws IOException {
void createRequestWhenHasDefaultHeadersAddsMissing() {
this.request.getHeaders().add("one", "existing");
Map<String, List<String>> defaultHeaders = new LinkedHashMap<>();
defaultHeaders.put("one", Collections.singletonList("1"));
@ -78,7 +77,7 @@ public class RestTemplateBuilderClientHttpRequestInitializerTests {
@Test
@SuppressWarnings("unchecked")
void createRequestWhenHasRequestCustomizersAppliesThemInOrder() throws IOException {
void createRequestWhenHasRequestCustomizersAppliesThemInOrder() {
Set<RestTemplateRequestCustomizer<?>> customizers = new LinkedHashSet<>();
customizers.add(mock(RestTemplateRequestCustomizer.class));
customizers.add(mock(RestTemplateRequestCustomizer.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");
* you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.boot.web.client;
import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
@ -304,7 +303,7 @@ class RestTemplateBuilderTests {
}
@Test
void basicAuthenticationShouldApply() throws Exception {
void basicAuthenticationShouldApply() {
RestTemplate template = this.builder.basicAuthentication("spring", "boot", StandardCharsets.UTF_8).build();
ClientHttpRequest request = createRequest(template);
assertThat(request.getHeaders()).containsOnlyKeys(HttpHeaders.AUTHORIZATION);
@ -312,14 +311,14 @@ class RestTemplateBuilderTests {
}
@Test
void defaultHeaderAddsHeader() throws IOException {
void defaultHeaderAddsHeader() {
RestTemplate template = this.builder.defaultHeader("spring", "boot").build();
ClientHttpRequest request = createRequest(template);
assertThat(request.getHeaders()).contains(entry("spring", Collections.singletonList("boot")));
}
@Test
void defaultHeaderAddsHeaderValues() throws IOException {
void defaultHeaderAddsHeaderValues() {
String name = HttpHeaders.ACCEPT;
String[] values = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE };
RestTemplate template = this.builder.defaultHeader(name, values).build();
@ -328,7 +327,7 @@ class RestTemplateBuilderTests {
}
@Test // gh-17885
void defaultHeaderWhenUsingMockRestServiceServerAddsHeader() throws IOException {
void defaultHeaderWhenUsingMockRestServiceServerAddsHeader() {
RestTemplate template = this.builder.defaultHeader("spring", "boot").build();
MockRestServiceServer.bindTo(template).build();
ClientHttpRequest request = createRequest(template);
@ -336,7 +335,7 @@ class RestTemplateBuilderTests {
}
@Test
void requestCustomizersAddsCustomizers() throws IOException {
void requestCustomizersAddsCustomizers() {
RestTemplate template = this.builder
.requestCustomizers((request) -> request.getHeaders().add("spring", "framework")).build();
ClientHttpRequest request = createRequest(template);
@ -344,7 +343,7 @@ class RestTemplateBuilderTests {
}
@Test
void additionalRequestCustomizersAddsCustomizers() throws IOException {
void additionalRequestCustomizersAddsCustomizers() {
RestTemplate template = this.builder
.requestCustomizers((request) -> request.getHeaders().add("spring", "framework"))
.additionalRequestCustomizers((request) -> request.getHeaders().add("for", "java")).build();

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

Loading…
Cancel
Save