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

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

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

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

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

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

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

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

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

@ -159,7 +159,7 @@ class ReactiveManagementWebSecurityAutoConfigurationTests {
static class CustomSecurityConfiguration { static class CustomSecurityConfiguration {
@Bean @Bean
SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) throws Exception { SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
http.authorizeExchange((exchanges) -> { http.authorizeExchange((exchanges) -> {
exchanges.pathMatchers("/foo").permitAll(); exchanges.pathMatchers("/foo").permitAll();
exchanges.anyExchange().authenticated(); exchanges.anyExchange().authenticated();
@ -179,7 +179,7 @@ class ReactiveManagementWebSecurityAutoConfigurationTests {
} }
@Bean @Bean
WebFilterChainProxy webFilterChainProxy(ServerHttpSecurity http) throws Exception { WebFilterChainProxy webFilterChainProxy(ServerHttpSecurity http) {
return new WebFilterChainProxy(getFilterChains(http)); return new WebFilterChainProxy(getFilterChains(http));
} }
@ -190,7 +190,7 @@ class ReactiveManagementWebSecurityAutoConfigurationTests {
return httpSecurity; return httpSecurity;
} }
private List<SecurityWebFilterChain> getFilterChains(ServerHttpSecurity http) throws Exception { private List<SecurityWebFilterChain> getFilterChains(ServerHttpSecurity http) {
http.authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated()); http.authorizeExchange((exchanges) -> exchanges.anyExchange().authenticated());
http.formLogin(Customizer.withDefaults()); http.formLogin(Customizer.withDefaults());
return Collections.singletonList(http.build()); return Collections.singletonList(http.build());

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.jdbc;
import java.util.Set; import java.util.Set;
import javax.naming.Context; import javax.naming.Context;
import javax.naming.NamingException;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.apache.commons.dbcp2.BasicDataSource; import org.apache.commons.dbcp2.BasicDataSource;
@ -80,7 +79,7 @@ class JndiDataSourceAutoConfigurationTests {
} }
@Test @Test
void dataSourceIsAvailableFromJndi() throws IllegalStateException, NamingException { void dataSourceIsAvailableFromJndi() {
DataSource dataSource = new BasicDataSource(); DataSource dataSource = new BasicDataSource();
configureJndi("foo", dataSource); configureJndi("foo", dataSource);
@ -94,7 +93,7 @@ class JndiDataSourceAutoConfigurationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
void mbeanDataSourceIsExcludedFromExport() throws IllegalStateException, NamingException { void mbeanDataSourceIsExcludedFromExport() throws IllegalStateException {
DataSource dataSource = new BasicDataSource(); DataSource dataSource = new BasicDataSource();
configureJndi("foo", dataSource); configureJndi("foo", dataSource);
@ -111,7 +110,7 @@ class JndiDataSourceAutoConfigurationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
void mbeanDataSourceIsExcludedFromExportByAllExporters() throws IllegalStateException, NamingException { void mbeanDataSourceIsExcludedFromExportByAllExporters() throws IllegalStateException {
DataSource dataSource = new BasicDataSource(); DataSource dataSource = new BasicDataSource();
configureJndi("foo", dataSource); configureJndi("foo", dataSource);
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
@ -128,7 +127,7 @@ class JndiDataSourceAutoConfigurationTests {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
void standardDataSourceIsNotExcludedFromExport() throws IllegalStateException, NamingException { void standardDataSourceIsNotExcludedFromExport() throws IllegalStateException {
DataSource dataSource = mock(DataSource.class); DataSource dataSource = mock(DataSource.class);
configureJndi("foo", dataSource); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -35,7 +35,7 @@ public class TestableInitialContextFactory implements InitialContextFactory {
private static TestableContext context; private static TestableContext context;
@Override @Override
public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException { public Context getInitialContext(Hashtable<?, ?> environment) {
return getContext(); return getContext();
} }
@ -78,7 +78,7 @@ public class TestableInitialContextFactory implements InitialContextFactory {
} }
@Override @Override
public Object lookup(String name) throws NamingException { public Object lookup(String name) {
return this.bindings.get(name); return this.bindings.get(name);
} }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -65,25 +65,25 @@ class RunningDocumentationTests {
} }
@TestTemplate @TestTemplate
void bootRunSourceResources() throws IOException { void bootRunSourceResources() {
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-source-resources") assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-source-resources")
.build("configuredClasspath").getOutput()).contains(new File("src/main/resources").getPath()); .build("configuredClasspath").getOutput()).contains(new File("src/main/resources").getPath());
} }
@TestTemplate @TestTemplate
void bootRunDisableOptimizedLaunch() throws IOException { void bootRunDisableOptimizedLaunch() {
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-disable-optimized-launch") assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-disable-optimized-launch")
.build("optimizedLaunch").getOutput()).contains("false"); .build("optimizedLaunch").getOutput()).contains("false");
} }
@TestTemplate @TestTemplate
void bootRunSystemPropertyDefaultValue() throws IOException { void bootRunSystemPropertyDefaultValue() {
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-system-property") assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-system-property")
.build("configuredSystemProperties").getOutput()).contains("com.example.property = default"); .build("configuredSystemProperties").getOutput()).contains("com.example.property = default");
} }
@TestTemplate @TestTemplate
void bootRunSystemPropetry() throws IOException { void bootRunSystemPropetry() {
assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-system-property") assertThat(this.gradleBuild.script("src/docs/gradle/running/boot-run-system-property")
.build("-Pexample=custom", "configuredSystemProperties").getOutput()) .build("-Pexample=custom", "configuredSystemProperties").getOutput())
.contains("com.example.property = custom"); .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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -42,7 +42,7 @@ class BuildInfoDslIntegrationTests {
GradleBuild gradleBuild; GradleBuild gradleBuild;
@TestTemplate @TestTemplate
void basicJar() throws IOException { void basicJar() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome()) assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS); .isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties(); Properties properties = buildInfoProperties();
@ -53,7 +53,7 @@ class BuildInfoDslIntegrationTests {
} }
@TestTemplate @TestTemplate
void jarWithCustomName() throws IOException { void jarWithCustomName() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome()) assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS); .isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties(); Properties properties = buildInfoProperties();
@ -64,7 +64,7 @@ class BuildInfoDslIntegrationTests {
} }
@TestTemplate @TestTemplate
void basicWar() throws IOException { void basicWar() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome()) assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS); .isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties(); Properties properties = buildInfoProperties();
@ -75,7 +75,7 @@ class BuildInfoDslIntegrationTests {
} }
@TestTemplate @TestTemplate
void warWithCustomName() throws IOException { void warWithCustomName() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome()) assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS); .isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties(); Properties properties = buildInfoProperties();
@ -86,7 +86,7 @@ class BuildInfoDslIntegrationTests {
} }
@TestTemplate @TestTemplate
void additionalProperties() throws IOException { void additionalProperties() {
assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome()) assertThat(this.gradleBuild.build("bootBuildInfo", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS); .isEqualTo(TaskOutcome.SUCCESS);
Properties properties = buildInfoProperties(); Properties properties = buildInfoProperties();
@ -99,7 +99,7 @@ class BuildInfoDslIntegrationTests {
} }
@TestTemplate @TestTemplate
void classesDependency() throws IOException { void classesDependency() {
assertThat(this.gradleBuild.build("classes", "--stacktrace").task(":bootBuildInfo").getOutcome()) assertThat(this.gradleBuild.build("classes", "--stacktrace").task(":bootBuildInfo").getOutcome())
.isEqualTo(TaskOutcome.SUCCESS); .isEqualTo(TaskOutcome.SUCCESS);
} }

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

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

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

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

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

@ -51,7 +51,7 @@ class IndexedLayersTests {
} }
@Test @Test
void createWhenIndexFileIsMalformedThrowsException() throws Exception { void createWhenIndexFileIsMalformedThrowsException() {
assertThatIllegalStateException().isThrownBy(() -> new IndexedLayers("test")) assertThatIllegalStateException().isThrownBy(() -> new IndexedLayers("test"))
.withMessage("Layer index file is malformed"); .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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -43,7 +43,7 @@ class FileUtilsTests {
private File originDirectory; private File originDirectory;
@BeforeEach @BeforeEach
void init() throws IOException { void init() {
this.outputDirectory = new File(this.tempDir, "remove"); this.outputDirectory = new File(this.tempDir, "remove");
this.originDirectory = new File(this.tempDir, "keep"); this.originDirectory = new File(this.tempDir, "keep");
this.outputDirectory.mkdirs(); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -52,7 +52,7 @@ class LayersIndexTests {
} }
@Test @Test
void writeToWhenSimpleNamesSortsAlphabetically() throws Exception { void writeToWhenSimpleNamesSortsAlphabetically() {
LayersIndex index = new LayersIndex(LAYER_A); LayersIndex index = new LayersIndex(LAYER_A);
index.add(LAYER_A, "cat"); index.add(LAYER_A, "cat");
index.add(LAYER_A, "dog"); index.add(LAYER_A, "dog");

@ -42,7 +42,7 @@ class ClassPathIndexFileTests {
File temp; File temp;
@Test @Test
void loadIfPossibleWhenRootIsNotFileReturnsNull() throws IOException { void loadIfPossibleWhenRootIsNotFileReturnsNull() {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> ClassPathIndexFile.loadIfPossible(new URL("https://example.com/file"), "test.idx")) .isThrownBy(() -> ClassPathIndexFile.loadIfPossible(new URL("https://example.com/file"), "test.idx"))
.withMessage("URL does not reference a file"); .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(); copyTestIndexFile();
ClassPathIndexFile indexFile = ClassPathIndexFile.loadIfPossible(this.temp.toURI().toURL(), "test.idx"); ClassPathIndexFile indexFile = ClassPathIndexFile.loadIfPossible(this.temp.toURI().toURL(), "test.idx");
return indexFile; 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -401,7 +401,7 @@ class PropertiesLauncherTests {
assertThat(bytes).isNotEmpty(); 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)); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -96,23 +96,23 @@ class RandomAccessDataFileTests {
} }
@Test @Test
void readWhenOffsetIsBeyondEOFShouldThrowException() throws Exception { void readWhenOffsetIsBeyondEOFShouldThrowException() {
assertThatExceptionOfType(IndexOutOfBoundsException.class).isThrownBy(() -> this.file.read(257, 0)); assertThatExceptionOfType(IndexOutOfBoundsException.class).isThrownBy(() -> this.file.read(257, 0));
} }
@Test @Test
void readWhenOffsetIsBeyondEndOfSubsectionShouldThrowException() throws Exception { void readWhenOffsetIsBeyondEndOfSubsectionShouldThrowException() {
RandomAccessData subsection = this.file.getSubsection(0, 10); RandomAccessData subsection = this.file.getSubsection(0, 10);
assertThatExceptionOfType(IndexOutOfBoundsException.class).isThrownBy(() -> subsection.read(11, 0)); assertThatExceptionOfType(IndexOutOfBoundsException.class).isThrownBy(() -> subsection.read(11, 0));
} }
@Test @Test
void readWhenOffsetPlusLengthGreaterThanEOFShouldThrowException() throws Exception { void readWhenOffsetPlusLengthGreaterThanEOFShouldThrowException() {
assertThatExceptionOfType(EOFException.class).isThrownBy(() -> this.file.read(256, 1)); assertThatExceptionOfType(EOFException.class).isThrownBy(() -> this.file.read(256, 1));
} }
@Test @Test
void readWhenOffsetPlusLengthGreaterThanEndOfSubsectionShouldThrowException() throws Exception { void readWhenOffsetPlusLengthGreaterThanEndOfSubsectionShouldThrowException() {
RandomAccessData subsection = this.file.getSubsection(0, 10); RandomAccessData subsection = this.file.getSubsection(0, 10);
assertThatExceptionOfType(EOFException.class).isThrownBy(() -> subsection.read(10, 1)); assertThatExceptionOfType(EOFException.class).isThrownBy(() -> subsection.read(10, 1));
} }
@ -125,13 +125,13 @@ class RandomAccessDataFileTests {
} }
@Test @Test
void inputStreamReadNullBytes() throws Exception { void inputStreamReadNullBytes() {
assertThatNullPointerException().isThrownBy(() -> this.inputStream.read(null)) assertThatNullPointerException().isThrownBy(() -> this.inputStream.read(null))
.withMessage("Bytes must not be null"); .withMessage("Bytes must not be null");
} }
@Test @Test
void inputStreamReadNullBytesWithOffset() throws Exception { void inputStreamReadNullBytesWithOffset() {
assertThatNullPointerException().isThrownBy(() -> this.inputStream.read(null, 0, 1)) assertThatNullPointerException().isThrownBy(() -> this.inputStream.read(null, 0, 1))
.withMessage("Bytes must not be null"); .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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -44,7 +44,7 @@ class SimpleMainTests {
private static final String SPRING_STARTUP = "Started SpringApplication in"; private static final String SPRING_STARTUP = "Started SpringApplication in";
@Test @Test
void emptyApplicationContext() throws Exception { void emptyApplicationContext() {
assertThatIllegalArgumentException().isThrownBy(() -> SpringApplication.main(getArgs())); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -112,7 +112,7 @@ class SpringApplicationAdminMXBeanRegistrarTests {
} }
@Test @Test
void shutdownApp() throws InstanceNotFoundException { void shutdownApp() {
final ObjectName objectName = createObjectName(OBJECT_NAME); final ObjectName objectName = createObjectName(OBJECT_NAME);
SpringApplication application = new SpringApplication(Config.class); SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -68,7 +68,7 @@ class ApplicationPidFileWriterTests {
} }
@Test @Test
void createPidFile() throws Exception { void createPidFile() {
File file = new File(this.tempDir, "pid"); File file = new File(this.tempDir, "pid");
ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file); ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file);
listener.onApplicationEvent(EVENT); listener.onApplicationEvent(EVENT);
@ -76,7 +76,7 @@ class ApplicationPidFileWriterTests {
} }
@Test @Test
void overridePidFile() throws Exception { void overridePidFile() {
File file = new File(this.tempDir, "pid"); File file = new File(this.tempDir, "pid");
System.setProperty("PIDFILE", new File(this.tempDir, "override").getAbsolutePath()); System.setProperty("PIDFILE", new File(this.tempDir, "override").getAbsolutePath());
ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file); ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file);
@ -85,7 +85,7 @@ class ApplicationPidFileWriterTests {
} }
@Test @Test
void overridePidFileWithSpring() throws Exception { void overridePidFileWithSpring() {
File file = new File(this.tempDir, "pid"); File file = new File(this.tempDir, "pid");
SpringApplicationEvent event = createPreparedEvent("spring.pid.file", file.getAbsolutePath()); SpringApplicationEvent event = createPreparedEvent("spring.pid.file", file.getAbsolutePath());
ApplicationPidFileWriter listener = new ApplicationPidFileWriter(); ApplicationPidFileWriter listener = new ApplicationPidFileWriter();
@ -120,7 +120,7 @@ class ApplicationPidFileWriterTests {
} }
@Test @Test
void withNoEnvironment() throws Exception { void withNoEnvironment() {
File file = new File(this.tempDir, "pid"); File file = new File(this.tempDir, "pid");
ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file); ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file);
listener.setTriggerEventType(ApplicationStartingEvent.class); listener.setTriggerEventType(ApplicationStartingEvent.class);

@ -88,7 +88,7 @@ class ConfigDataLoadersTests {
} }
@Test @Test
void loadWhenMultipleLoadersSupportLocationThrowsException() throws Exception { void loadWhenMultipleLoadersSupportLocationThrowsException() {
TestConfigDataResource location = new TestConfigDataResource("test"); TestConfigDataResource location = new TestConfigDataResource("test");
ConfigDataLoaders loaders = new ConfigDataLoaders(this.logFactory, this.bootstrapContext, ConfigDataLoaders loaders = new ConfigDataLoaders(this.logFactory, this.bootstrapContext,
Arrays.asList(LoggingConfigDataLoader.class.getName(), TestConfigDataLoader.class.getName())); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -57,7 +57,7 @@ class LoggingApplicationListenerIntegrationTests {
} }
@Test @Test
void logFileRegisteredInTheContextWhenApplicable(@TempDir File tempDir) throws Exception { void logFileRegisteredInTheContextWhenApplicable(@TempDir File tempDir) {
String logFile = new File(tempDir, "test.log").getAbsolutePath(); String logFile = new File(tempDir, "test.log").getAbsolutePath();
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(SampleService.class) try (ConfigurableApplicationContext context = new SpringApplicationBuilder(SampleService.class)
.web(WebApplicationType.NONE).properties("logging.file.name=" + logFile).run()) { .web(WebApplicationType.NONE).properties("logging.file.name=" + logFile).run()) {

@ -129,7 +129,7 @@ class LoggingApplicationListenerTests {
} }
@AfterEach @AfterEach
void clear() throws IOException { void clear() {
LoggingSystem loggingSystem = LoggingSystem.get(getClass().getClassLoader()); LoggingSystem loggingSystem = LoggingSystem.get(getClass().getClassLoader());
loggingSystem.setLogLevel("ROOT", LogLevel.INFO); loggingSystem.setLogLevel("ROOT", LogLevel.INFO);
loggingSystem.cleanUp(); loggingSystem.cleanUp();
@ -420,7 +420,7 @@ class LoggingApplicationListenerTests {
} }
@Test @Test
void shutdownHookRegistrationCanBeDisabled() throws Exception { void shutdownHookRegistrationCanBeDisabled() {
TestLoggingApplicationListener listener = new TestLoggingApplicationListener(); TestLoggingApplicationListener listener = new TestLoggingApplicationListener();
Object registered = ReflectionTestUtils.getField(listener, TestLoggingApplicationListener.class, Object registered = ReflectionTestUtils.getField(listener, TestLoggingApplicationListener.class,
"shutdownHookRegistered"); "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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,8 +16,6 @@
package org.springframework.boot.context.properties; package org.springframework.boot.context.properties;
import java.io.IOException;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -53,7 +51,7 @@ class EnableConfigurationPropertiesRegistrarTests {
} }
@Test @Test
void typeWithDefaultConstructorShouldRegisterGenericBeanDefinition() throws Exception { void typeWithDefaultConstructorShouldRegisterGenericBeanDefinition() {
register(TestConfiguration.class); register(TestConfiguration.class);
BeanDefinition beanDefinition = this.beanFactory BeanDefinition beanDefinition = this.beanFactory
.getBeanDefinition("foo-" + getClass().getName() + "$FooProperties"); .getBeanDefinition("foo-" + getClass().getName() + "$FooProperties");
@ -61,7 +59,7 @@ class EnableConfigurationPropertiesRegistrarTests {
} }
@Test @Test
void typeWithConstructorBindingShouldRegisterConfigurationPropertiesBeanDefinition() throws Exception { void typeWithConstructorBindingShouldRegisterConfigurationPropertiesBeanDefinition() {
register(TestConfiguration.class); register(TestConfiguration.class);
BeanDefinition beanDefinition = this.beanFactory BeanDefinition beanDefinition = this.beanFactory
.getBeanDefinition("bar-" + getClass().getName() + "$BarProperties"); .getBeanDefinition("bar-" + getClass().getName() + "$BarProperties");
@ -69,7 +67,7 @@ class EnableConfigurationPropertiesRegistrarTests {
} }
@Test @Test
void typeWithMultipleConstructorsShouldRegisterGenericBeanDefinition() throws Exception { void typeWithMultipleConstructorsShouldRegisterGenericBeanDefinition() {
register(TestConfiguration.class); register(TestConfiguration.class);
BeanDefinition beanDefinition = this.beanFactory BeanDefinition beanDefinition = this.beanFactory
.getBeanDefinition("bing-" + getClass().getName() + "$BingProperties"); .getBeanDefinition("bing-" + getClass().getName() + "$BingProperties");
@ -84,14 +82,14 @@ class EnableConfigurationPropertiesRegistrarTests {
} }
@Test @Test
void registrationWithDuplicatedTypeShouldRegisterSingleBeanDefinition() throws IOException { void registrationWithDuplicatedTypeShouldRegisterSingleBeanDefinition() {
register(DuplicateConfiguration.class); register(DuplicateConfiguration.class);
String name = "foo-" + getClass().getName() + "$FooProperties"; String name = "foo-" + getClass().getName() + "$FooProperties";
verify(this.beanFactory, times(1)).registerBeanDefinition(eq(name), any()); verify(this.beanFactory, times(1)).registerBeanDefinition(eq(name), any());
} }
@Test @Test
void registrationWithNoTypeShouldNotRegisterAnything() throws IOException { void registrationWithNoTypeShouldNotRegisterAnything() {
register(EmptyConfiguration.class); register(EmptyConfiguration.class);
String[] names = this.beanFactory.getBeanNamesForType(Object.class); String[] names = this.beanFactory.getBeanNamesForType(Object.class);
for (String name : names) { 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -153,7 +153,7 @@ class BindResultTests {
} }
@Test @Test
void orElseThrowWhenHasNoValueShouldThrowException() throws Exception { void orElseThrowWhenHasNoValueShouldThrowException() {
BindResult<String> result = BindResult.of(null); BindResult<String> result = BindResult.of(null);
assertThatIOException().isThrownBy(() -> result.orElseThrow(IOException::new)); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -39,7 +39,7 @@ class DataObjectPropertyNameTests {
} }
@Test @Test
void toDashedFormWhenContainsIndexedAddsNoDashToIndex() throws Exception { void toDashedFormWhenContainsIndexedAddsNoDashToIndex() {
assertThat(DataObjectPropertyName.toDashedForm("test[fooBar]")).isEqualTo("test[fooBar]"); assertThat(DataObjectPropertyName.toDashedForm("test[fooBar]")).isEqualTo("test[fooBar]");
assertThat(DataObjectPropertyName.toDashedForm("testAgain[fooBar]")).isEqualTo("test-again[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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -218,7 +218,7 @@ class ValidationBindHandlerTests {
} }
@Test @Test
void validateMapValues() throws Exception { void validateMapValues() {
MockConfigurationPropertySource source = new MockConfigurationPropertySource(); MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("test.items.[itemOne].number", "one"); source.put("test.items.[itemOne].number", "one");
source.put("test.items.[ITEM2].number", "two"); source.put("test.items.[ITEM2].number", "two");
@ -229,7 +229,7 @@ class ValidationBindHandlerTests {
} }
@Test @Test
void validateMapValuesWithNonUniformSource() throws Exception { void validateMapValuesWithNonUniformSource() {
Map<String, Object> map = new LinkedHashMap<>(); Map<String, Object> map = new LinkedHashMap<>();
map.put("test.items.itemOne.number", "one"); map.put("test.items.itemOne.number", "one");
map.put("test.items.ITEM2.number", "two"); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -37,7 +37,7 @@ import static org.junit.jupiter.api.Assumptions.assumingThat;
class InetAddressFormatterTests { class InetAddressFormatterTests {
@ConversionServiceTest @ConversionServiceTest
void convertFromInetAddressToStringShouldConvert(ConversionService conversionService) throws UnknownHostException { void convertFromInetAddressToStringShouldConvert(ConversionService conversionService) {
assumingThat(isResolvable("example.com"), () -> { assumingThat(isResolvable("example.com"), () -> {
InetAddress address = InetAddress.getByName("example.com"); InetAddress address = InetAddress.getByName("example.com");
String converted = conversionService.convert(address, String.class); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -34,7 +34,7 @@ class NoSnakeYamlPropertySourceLoaderTests {
private YamlPropertySourceLoader loader = new YamlPropertySourceLoader(); private YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
@Test @Test
void load() throws Exception { void load() {
ByteArrayResource resource = new ByteArrayResource("foo:\n bar: spam".getBytes()); ByteArrayResource resource = new ByteArrayResource("foo:\n bar: spam".getBytes());
assertThatIllegalStateException().isThrownBy(() -> this.loader.load("resource", resource)) assertThatIllegalStateException().isThrownBy(() -> this.loader.load("resource", resource))
.withMessageContaining("Attempted to load resource but snakeyaml was not found on the classpath"); .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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -90,7 +90,7 @@ class OriginTrackedPropertiesLoaderTests {
} }
@Test @Test
void getMalformedUnicodeProperty() throws Exception { void getMalformedUnicodeProperty() {
// gh-12716 // gh-12716
ClassPathResource resource = new ClassPathResource("test-properties-malformed-unicode.properties", getClass()); ClassPathResource resource = new ClassPathResource("test-properties-malformed-unicode.properties", getClass());
assertThatIllegalStateException().isThrownBy(() -> new OriginTrackedPropertiesLoader(resource).load()) 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -130,7 +130,7 @@ class OriginTrackedYamlLoaderTests {
} }
@Test @Test
void unsupportedType() throws Exception { void unsupportedType() {
String yaml = "value: !!java.net.URL [!!java.lang.String [!!java.lang.StringBuilder [\"http://localhost:9000/\"]]]"; String yaml = "value: !!java.net.URL [!!java.lang.String [!!java.lang.StringBuilder [\"http://localhost:9000/\"]]]";
Resource resource = new ByteArrayResource(yaml.getBytes(StandardCharsets.UTF_8)); Resource resource = new ByteArrayResource(yaml.getBytes(StandardCharsets.UTF_8));
this.loader = new OriginTrackedYamlLoader(resource); 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -34,7 +34,7 @@ public class YamlJsonParserTests extends AbstractJsonParserTests {
} }
@Test @Test
void customTypesAreNotLoaded() throws Exception { void customTypesAreNotLoaded() {
assertThatExceptionOfType(ConstructorException.class) assertThatExceptionOfType(ConstructorException.class)
.isThrownBy(() -> getParser().parseMap("{value: !!java.net.URL [\"http://localhost:9000/\"]}")) .isThrownBy(() -> getParser().parseMap("{value: !!java.net.URL [\"http://localhost:9000/\"]}"))
.withCauseInstanceOf(IllegalStateException.class); .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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.boot.web.client; package org.springframework.boot.web.client;
import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -48,14 +47,14 @@ public class RestTemplateBuilderClientHttpRequestInitializerTests {
private final MockClientHttpRequest request = new MockClientHttpRequest(); private final MockClientHttpRequest request = new MockClientHttpRequest();
@Test @Test
void createRequestWhenHasBasicAuthAndNoAuthHeaderAddsHeader() throws IOException { void createRequestWhenHasBasicAuthAndNoAuthHeaderAddsHeader() {
new RestTemplateBuilderClientHttpRequestInitializer(new BasicAuthentication("spring", "boot", null), new RestTemplateBuilderClientHttpRequestInitializer(new BasicAuthentication("spring", "boot", null),
Collections.emptyMap(), Collections.emptySet()).initialize(this.request); Collections.emptyMap(), Collections.emptySet()).initialize(this.request);
assertThat(this.request.getHeaders().get(HttpHeaders.AUTHORIZATION)).containsExactly("Basic c3ByaW5nOmJvb3Q="); assertThat(this.request.getHeaders().get(HttpHeaders.AUTHORIZATION)).containsExactly("Basic c3ByaW5nOmJvb3Q=");
} }
@Test @Test
void createRequestWhenHasBasicAuthAndExistingAuthHeaderDoesNotAddHeader() throws IOException { void createRequestWhenHasBasicAuthAndExistingAuthHeaderDoesNotAddHeader() {
this.request.getHeaders().setBasicAuth("boot", "spring"); this.request.getHeaders().setBasicAuth("boot", "spring");
new RestTemplateBuilderClientHttpRequestInitializer(new BasicAuthentication("spring", "boot", null), new RestTemplateBuilderClientHttpRequestInitializer(new BasicAuthentication("spring", "boot", null),
Collections.emptyMap(), Collections.emptySet()).initialize(this.request); Collections.emptyMap(), Collections.emptySet()).initialize(this.request);
@ -63,7 +62,7 @@ public class RestTemplateBuilderClientHttpRequestInitializerTests {
} }
@Test @Test
void createRequestWhenHasDefaultHeadersAddsMissing() throws IOException { void createRequestWhenHasDefaultHeadersAddsMissing() {
this.request.getHeaders().add("one", "existing"); this.request.getHeaders().add("one", "existing");
Map<String, List<String>> defaultHeaders = new LinkedHashMap<>(); Map<String, List<String>> defaultHeaders = new LinkedHashMap<>();
defaultHeaders.put("one", Collections.singletonList("1")); defaultHeaders.put("one", Collections.singletonList("1"));
@ -78,7 +77,7 @@ public class RestTemplateBuilderClientHttpRequestInitializerTests {
@Test @Test
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
void createRequestWhenHasRequestCustomizersAppliesThemInOrder() throws IOException { void createRequestWhenHasRequestCustomizersAppliesThemInOrder() {
Set<RestTemplateRequestCustomizer<?>> customizers = new LinkedHashSet<>(); Set<RestTemplateRequestCustomizer<?>> customizers = new LinkedHashSet<>();
customizers.add(mock(RestTemplateRequestCustomizer.class)); customizers.add(mock(RestTemplateRequestCustomizer.class));
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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
package org.springframework.boot.web.client; package org.springframework.boot.web.client;
import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.Duration; import java.time.Duration;
@ -304,7 +303,7 @@ class RestTemplateBuilderTests {
} }
@Test @Test
void basicAuthenticationShouldApply() throws Exception { void basicAuthenticationShouldApply() {
RestTemplate template = this.builder.basicAuthentication("spring", "boot", StandardCharsets.UTF_8).build(); RestTemplate template = this.builder.basicAuthentication("spring", "boot", StandardCharsets.UTF_8).build();
ClientHttpRequest request = createRequest(template); ClientHttpRequest request = createRequest(template);
assertThat(request.getHeaders()).containsOnlyKeys(HttpHeaders.AUTHORIZATION); assertThat(request.getHeaders()).containsOnlyKeys(HttpHeaders.AUTHORIZATION);
@ -312,14 +311,14 @@ class RestTemplateBuilderTests {
} }
@Test @Test
void defaultHeaderAddsHeader() throws IOException { void defaultHeaderAddsHeader() {
RestTemplate template = this.builder.defaultHeader("spring", "boot").build(); RestTemplate template = this.builder.defaultHeader("spring", "boot").build();
ClientHttpRequest request = createRequest(template); ClientHttpRequest request = createRequest(template);
assertThat(request.getHeaders()).contains(entry("spring", Collections.singletonList("boot"))); assertThat(request.getHeaders()).contains(entry("spring", Collections.singletonList("boot")));
} }
@Test @Test
void defaultHeaderAddsHeaderValues() throws IOException { void defaultHeaderAddsHeaderValues() {
String name = HttpHeaders.ACCEPT; String name = HttpHeaders.ACCEPT;
String[] values = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE }; String[] values = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE };
RestTemplate template = this.builder.defaultHeader(name, values).build(); RestTemplate template = this.builder.defaultHeader(name, values).build();
@ -328,7 +327,7 @@ class RestTemplateBuilderTests {
} }
@Test // gh-17885 @Test // gh-17885
void defaultHeaderWhenUsingMockRestServiceServerAddsHeader() throws IOException { void defaultHeaderWhenUsingMockRestServiceServerAddsHeader() {
RestTemplate template = this.builder.defaultHeader("spring", "boot").build(); RestTemplate template = this.builder.defaultHeader("spring", "boot").build();
MockRestServiceServer.bindTo(template).build(); MockRestServiceServer.bindTo(template).build();
ClientHttpRequest request = createRequest(template); ClientHttpRequest request = createRequest(template);
@ -336,7 +335,7 @@ class RestTemplateBuilderTests {
} }
@Test @Test
void requestCustomizersAddsCustomizers() throws IOException { void requestCustomizersAddsCustomizers() {
RestTemplate template = this.builder RestTemplate template = this.builder
.requestCustomizers((request) -> request.getHeaders().add("spring", "framework")).build(); .requestCustomizers((request) -> request.getHeaders().add("spring", "framework")).build();
ClientHttpRequest request = createRequest(template); ClientHttpRequest request = createRequest(template);
@ -344,7 +343,7 @@ class RestTemplateBuilderTests {
} }
@Test @Test
void additionalRequestCustomizersAddsCustomizers() throws IOException { void additionalRequestCustomizersAddsCustomizers() {
RestTemplate template = this.builder RestTemplate template = this.builder
.requestCustomizers((request) -> request.getHeaders().add("spring", "framework")) .requestCustomizers((request) -> request.getHeaders().add("spring", "framework"))
.additionalRequestCustomizers((request) -> request.getHeaders().add("for", "java")).build(); .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