Remove unnecessary throws declaration in tests

See gh-26441
This commit is contained in:
weixsun
2021-05-13 00:22:53 +08:00
committed by Stephane Nicoll
parent 574655dc84
commit 8a2be288a3
129 changed files with 345 additions and 369 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@ class SimpleMainTests {
private static final String SPRING_STARTUP = "Started SpringApplication in";
@Test
void emptyApplicationContext() throws Exception {
void emptyApplicationContext() {
assertThatIllegalArgumentException().isThrownBy(() -> SpringApplication.main(getArgs()));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -112,7 +112,7 @@ class SpringApplicationAdminMXBeanRegistrarTests {
}
@Test
void shutdownApp() throws InstanceNotFoundException {
void shutdownApp() {
final ObjectName objectName = createObjectName(OBJECT_NAME);
SpringApplication application = new SpringApplication(Config.class);
application.setWebApplicationType(WebApplicationType.NONE);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -68,7 +68,7 @@ class ApplicationPidFileWriterTests {
}
@Test
void createPidFile() throws Exception {
void createPidFile() {
File file = new File(this.tempDir, "pid");
ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file);
listener.onApplicationEvent(EVENT);
@@ -76,7 +76,7 @@ class ApplicationPidFileWriterTests {
}
@Test
void overridePidFile() throws Exception {
void overridePidFile() {
File file = new File(this.tempDir, "pid");
System.setProperty("PIDFILE", new File(this.tempDir, "override").getAbsolutePath());
ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file);
@@ -85,7 +85,7 @@ class ApplicationPidFileWriterTests {
}
@Test
void overridePidFileWithSpring() throws Exception {
void overridePidFileWithSpring() {
File file = new File(this.tempDir, "pid");
SpringApplicationEvent event = createPreparedEvent("spring.pid.file", file.getAbsolutePath());
ApplicationPidFileWriter listener = new ApplicationPidFileWriter();
@@ -120,7 +120,7 @@ class ApplicationPidFileWriterTests {
}
@Test
void withNoEnvironment() throws Exception {
void withNoEnvironment() {
File file = new File(this.tempDir, "pid");
ApplicationPidFileWriter listener = new ApplicationPidFileWriter(file);
listener.setTriggerEventType(ApplicationStartingEvent.class);

View File

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

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ class LoggingApplicationListenerIntegrationTests {
}
@Test
void logFileRegisteredInTheContextWhenApplicable(@TempDir File tempDir) throws Exception {
void logFileRegisteredInTheContextWhenApplicable(@TempDir File tempDir) {
String logFile = new File(tempDir, "test.log").getAbsolutePath();
try (ConfigurableApplicationContext context = new SpringApplicationBuilder(SampleService.class)
.web(WebApplicationType.NONE).properties("logging.file.name=" + logFile).run()) {

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -153,7 +153,7 @@ class BindResultTests {
}
@Test
void orElseThrowWhenHasNoValueShouldThrowException() throws Exception {
void orElseThrowWhenHasNoValueShouldThrowException() {
BindResult<String> result = BindResult.of(null);
assertThatIOException().isThrownBy(() -> result.orElseThrow(IOException::new));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ class DataObjectPropertyNameTests {
}
@Test
void toDashedFormWhenContainsIndexedAddsNoDashToIndex() throws Exception {
void toDashedFormWhenContainsIndexedAddsNoDashToIndex() {
assertThat(DataObjectPropertyName.toDashedForm("test[fooBar]")).isEqualTo("test[fooBar]");
assertThat(DataObjectPropertyName.toDashedForm("testAgain[fooBar]")).isEqualTo("test-again[fooBar]");
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -218,7 +218,7 @@ class ValidationBindHandlerTests {
}
@Test
void validateMapValues() throws Exception {
void validateMapValues() {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("test.items.[itemOne].number", "one");
source.put("test.items.[ITEM2].number", "two");
@@ -229,7 +229,7 @@ class ValidationBindHandlerTests {
}
@Test
void validateMapValuesWithNonUniformSource() throws Exception {
void validateMapValuesWithNonUniformSource() {
Map<String, Object> map = new LinkedHashMap<>();
map.put("test.items.itemOne.number", "one");
map.put("test.items.ITEM2.number", "two");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ import static org.junit.jupiter.api.Assumptions.assumingThat;
class InetAddressFormatterTests {
@ConversionServiceTest
void convertFromInetAddressToStringShouldConvert(ConversionService conversionService) throws UnknownHostException {
void convertFromInetAddressToStringShouldConvert(ConversionService conversionService) {
assumingThat(isResolvable("example.com"), () -> {
InetAddress address = InetAddress.getByName("example.com");
String converted = conversionService.convert(address, String.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ class NoSnakeYamlPropertySourceLoaderTests {
private YamlPropertySourceLoader loader = new YamlPropertySourceLoader();
@Test
void load() throws Exception {
void load() {
ByteArrayResource resource = new ByteArrayResource("foo:\n bar: spam".getBytes());
assertThatIllegalStateException().isThrownBy(() -> this.loader.load("resource", resource))
.withMessageContaining("Attempted to load resource but snakeyaml was not found on the classpath");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -90,7 +90,7 @@ class OriginTrackedPropertiesLoaderTests {
}
@Test
void getMalformedUnicodeProperty() throws Exception {
void getMalformedUnicodeProperty() {
// gh-12716
ClassPathResource resource = new ClassPathResource("test-properties-malformed-unicode.properties", getClass());
assertThatIllegalStateException().isThrownBy(() -> new OriginTrackedPropertiesLoader(resource).load())

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -130,7 +130,7 @@ class OriginTrackedYamlLoaderTests {
}
@Test
void unsupportedType() throws Exception {
void unsupportedType() {
String yaml = "value: !!java.net.URL [!!java.lang.String [!!java.lang.StringBuilder [\"http://localhost:9000/\"]]]";
Resource resource = new ByteArrayResource(yaml.getBytes(StandardCharsets.UTF_8));
this.loader = new OriginTrackedYamlLoader(resource);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ public class YamlJsonParserTests extends AbstractJsonParserTests {
}
@Test
void customTypesAreNotLoaded() throws Exception {
void customTypesAreNotLoaded() {
assertThatExceptionOfType(ConstructorException.class)
.isThrownBy(() -> getParser().parseMap("{value: !!java.net.URL [\"http://localhost:9000/\"]}"))
.withCauseInstanceOf(IllegalStateException.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
package org.springframework.boot.web.client;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
@@ -48,14 +47,14 @@ public class RestTemplateBuilderClientHttpRequestInitializerTests {
private final MockClientHttpRequest request = new MockClientHttpRequest();
@Test
void createRequestWhenHasBasicAuthAndNoAuthHeaderAddsHeader() throws IOException {
void createRequestWhenHasBasicAuthAndNoAuthHeaderAddsHeader() {
new RestTemplateBuilderClientHttpRequestInitializer(new BasicAuthentication("spring", "boot", null),
Collections.emptyMap(), Collections.emptySet()).initialize(this.request);
assertThat(this.request.getHeaders().get(HttpHeaders.AUTHORIZATION)).containsExactly("Basic c3ByaW5nOmJvb3Q=");
}
@Test
void createRequestWhenHasBasicAuthAndExistingAuthHeaderDoesNotAddHeader() throws IOException {
void createRequestWhenHasBasicAuthAndExistingAuthHeaderDoesNotAddHeader() {
this.request.getHeaders().setBasicAuth("boot", "spring");
new RestTemplateBuilderClientHttpRequestInitializer(new BasicAuthentication("spring", "boot", null),
Collections.emptyMap(), Collections.emptySet()).initialize(this.request);
@@ -63,7 +62,7 @@ public class RestTemplateBuilderClientHttpRequestInitializerTests {
}
@Test
void createRequestWhenHasDefaultHeadersAddsMissing() throws IOException {
void createRequestWhenHasDefaultHeadersAddsMissing() {
this.request.getHeaders().add("one", "existing");
Map<String, List<String>> defaultHeaders = new LinkedHashMap<>();
defaultHeaders.put("one", Collections.singletonList("1"));
@@ -78,7 +77,7 @@ public class RestTemplateBuilderClientHttpRequestInitializerTests {
@Test
@SuppressWarnings("unchecked")
void createRequestWhenHasRequestCustomizersAppliesThemInOrder() throws IOException {
void createRequestWhenHasRequestCustomizersAppliesThemInOrder() {
Set<RestTemplateRequestCustomizer<?>> customizers = new LinkedHashSet<>();
customizers.add(mock(RestTemplateRequestCustomizer.class));
customizers.add(mock(RestTemplateRequestCustomizer.class));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
package org.springframework.boot.web.client;
import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
@@ -304,7 +303,7 @@ class RestTemplateBuilderTests {
}
@Test
void basicAuthenticationShouldApply() throws Exception {
void basicAuthenticationShouldApply() {
RestTemplate template = this.builder.basicAuthentication("spring", "boot", StandardCharsets.UTF_8).build();
ClientHttpRequest request = createRequest(template);
assertThat(request.getHeaders()).containsOnlyKeys(HttpHeaders.AUTHORIZATION);
@@ -312,14 +311,14 @@ class RestTemplateBuilderTests {
}
@Test
void defaultHeaderAddsHeader() throws IOException {
void defaultHeaderAddsHeader() {
RestTemplate template = this.builder.defaultHeader("spring", "boot").build();
ClientHttpRequest request = createRequest(template);
assertThat(request.getHeaders()).contains(entry("spring", Collections.singletonList("boot")));
}
@Test
void defaultHeaderAddsHeaderValues() throws IOException {
void defaultHeaderAddsHeaderValues() {
String name = HttpHeaders.ACCEPT;
String[] values = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE };
RestTemplate template = this.builder.defaultHeader(name, values).build();
@@ -328,7 +327,7 @@ class RestTemplateBuilderTests {
}
@Test // gh-17885
void defaultHeaderWhenUsingMockRestServiceServerAddsHeader() throws IOException {
void defaultHeaderWhenUsingMockRestServiceServerAddsHeader() {
RestTemplate template = this.builder.defaultHeader("spring", "boot").build();
MockRestServiceServer.bindTo(template).build();
ClientHttpRequest request = createRequest(template);
@@ -336,7 +335,7 @@ class RestTemplateBuilderTests {
}
@Test
void requestCustomizersAddsCustomizers() throws IOException {
void requestCustomizersAddsCustomizers() {
RestTemplate template = this.builder
.requestCustomizers((request) -> request.getHeaders().add("spring", "framework")).build();
ClientHttpRequest request = createRequest(template);
@@ -344,7 +343,7 @@ class RestTemplateBuilderTests {
}
@Test
void additionalRequestCustomizersAddsCustomizers() throws IOException {
void additionalRequestCustomizersAddsCustomizers() {
RestTemplate template = this.builder
.requestCustomizers((request) -> request.getHeaders().add("spring", "framework"))
.additionalRequestCustomizers((request) -> request.getHeaders().add("for", "java")).build();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ class WebServerPortFileWriterTests {
}
@Test
void createPortFile() throws Exception {
void createPortFile() {
File file = new File(this.tempDir, "port.file");
WebServerPortFileWriter listener = new WebServerPortFileWriter(file);
listener.onApplicationEvent(mockEvent("", 8080));
@@ -61,7 +61,7 @@ class WebServerPortFileWriterTests {
}
@Test
void overridePortFileWithDefault() throws Exception {
void overridePortFileWithDefault() {
System.setProperty("PORTFILE", new File(this.tempDir, "port.file").getAbsolutePath());
WebServerPortFileWriter listener = new WebServerPortFileWriter();
listener.onApplicationEvent(mockEvent("", 8080));
@@ -70,7 +70,7 @@ class WebServerPortFileWriterTests {
}
@Test
void overridePortFileWithExplicitFile() throws Exception {
void overridePortFileWithExplicitFile() {
File file = new File(this.tempDir, "port.file");
System.setProperty("PORTFILE", new File(this.tempDir, "override.file").getAbsolutePath());
WebServerPortFileWriter listener = new WebServerPortFileWriter(file);
@@ -80,7 +80,7 @@ class WebServerPortFileWriterTests {
}
@Test
void createManagementPortFile() throws Exception {
void createManagementPortFile() {
File file = new File(this.tempDir, "port.file");
WebServerPortFileWriter listener = new WebServerPortFileWriter(file);
listener.onApplicationEvent(mockEvent("", 8080));
@@ -96,7 +96,7 @@ class WebServerPortFileWriterTests {
}
@Test
void createUpperCaseManagementPortFile() throws Exception {
void createUpperCaseManagementPortFile() {
File file = new File(this.tempDir, "port.file");
file = new File(file.getParentFile(), file.getName().toUpperCase(Locale.ENGLISH));
WebServerPortFileWriter listener = new WebServerPortFileWriter(file);

View File

@@ -47,7 +47,7 @@ public class Jetty10ServletWebServerFactoryTests extends JettyServletWebServerFa
@Test
@Override
@Disabled("Jetty 10 adds methods to Configuration that we can't mock while compiling against 9")
protected void jettyConfigurations() throws Exception {
protected void jettyConfigurations() {
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -116,7 +116,7 @@ class JettyReactiveWebServerFactoryTests extends AbstractReactiveWebServerFactor
}
@Test
void whenServerIsShuttingDownGracefullyThenNewConnectionsCannotBeMade() throws Exception {
void whenServerIsShuttingDownGracefullyThenNewConnectionsCannotBeMade() {
JettyReactiveWebServerFactory factory = getFactory();
factory.setShutdown(Shutdown.GRACEFUL);
BlockingHandler blockingHandler = new BlockingHandler();

View File

@@ -384,7 +384,7 @@ class JettyServletWebServerFactoryTests extends AbstractJettyServletWebServerFac
}
@Test
void faultyListenerCausesStartFailure() throws Exception {
void faultyListenerCausesStartFailure() {
JettyServletWebServerFactory factory = getFactory();
factory.addServerCustomizers((JettyServerCustomizer) (server) -> {
Collection<WebAppContext> contexts = server.getBeans(WebAppContext.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -113,7 +113,7 @@ class NettyReactiveWebServerFactoryTests extends AbstractReactiveWebServerFactor
}
@Test
void whenServerIsShuttingDownGracefullyThenNewConnectionsCannotBeMade() throws Exception {
void whenServerIsShuttingDownGracefullyThenNewConnectionsCannotBeMade() {
NettyReactiveWebServerFactory factory = getFactory();
factory.setShutdown(Shutdown.GRACEFUL);
BlockingHandler blockingHandler = new BlockingHandler();

View File

@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
class SslServerCustomizerTests {
@Test
void keyStoreProviderIsUsedWhenCreatingKeyStore() throws Exception {
void keyStoreProviderIsUsedWhenCreatingKeyStore() {
Ssl ssl = new Ssl();
ssl.setKeyPassword("password");
ssl.setKeyStore("src/test/resources/test.jks");
@@ -47,7 +47,7 @@ class SslServerCustomizerTests {
}
@Test
void trustStoreProviderIsUsedWhenCreatingTrustStore() throws Exception {
void trustStoreProviderIsUsedWhenCreatingTrustStore() {
Ssl ssl = new Ssl();
ssl.setTrustStorePassword("password");
ssl.setTrustStore("src/test/resources/test.jks");
@@ -59,7 +59,7 @@ class SslServerCustomizerTests {
}
@Test
void getKeyManagerFactoryWhenSslIsEnabledWithNoKeyStoreThrowsWebServerException() throws Exception {
void getKeyManagerFactoryWhenSslIsEnabledWithNoKeyStoreThrowsWebServerException() {
Ssl ssl = new Ssl();
SslServerCustomizer customizer = new SslServerCustomizer(ssl, null, null);
assertThatIllegalStateException().isThrownBy(() -> customizer.getKeyManagerFactory(ssl, null))

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -242,7 +242,7 @@ class TomcatReactiveWebServerFactoryTests extends AbstractReactiveWebServerFacto
}
@Test
void whenServerIsShuttingDownGracefullyThenNewConnectionsCannotBeMade() throws Exception {
void whenServerIsShuttingDownGracefullyThenNewConnectionsCannotBeMade() {
TomcatReactiveWebServerFactory factory = getFactory();
factory.setShutdown(Shutdown.GRACEFUL);
BlockingHandler blockingHandler = new BlockingHandler();

View File

@@ -17,7 +17,6 @@
package org.springframework.boot.web.embedded.undertow;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -45,7 +44,7 @@ class FileSessionPersistenceTests {
private Date expiration = new Date(System.currentTimeMillis() + 10000);
@BeforeEach
void setup(@TempDir File tempDir) throws IOException {
void setup(@TempDir File tempDir) {
this.dir = tempDir;
this.dir.mkdir();
this.persistence = new FileSessionPersistence(this.dir);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,8 +17,6 @@
package org.springframework.boot.web.embedded.undertow;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.time.Duration;
import java.util.Arrays;
@@ -98,17 +96,17 @@ class UndertowReactiveWebServerFactoryTests extends AbstractReactiveWebServerFac
}
@Test
void accessLogCanBeEnabled() throws IOException, URISyntaxException, InterruptedException {
void accessLogCanBeEnabled() {
testAccessLog(null, null, "access_log.log");
}
@Test
void accessLogCanBeCustomized() throws IOException, URISyntaxException, InterruptedException {
void accessLogCanBeCustomized() {
testAccessLog("my_access.", "logz", "my_access.logz");
}
@Test
void whenServerIsShuttingDownGracefullyThenNewConnectionsAreRejectedWithServiceUnavailable() throws Exception {
void whenServerIsShuttingDownGracefullyThenNewConnectionsAreRejectedWithServiceUnavailable() {
UndertowReactiveWebServerFactory factory = getFactory();
factory.setShutdown(Shutdown.GRACEFUL);
BlockingHandler blockingHandler = new BlockingHandler();
@@ -130,8 +128,7 @@ class UndertowReactiveWebServerFactoryTests extends AbstractReactiveWebServerFac
this.webServer.stop();
}
private void testAccessLog(String prefix, String suffix, String expectedFile)
throws IOException, URISyntaxException, InterruptedException {
private void testAccessLog(String prefix, String suffix, String expectedFile) {
UndertowReactiveWebServerFactory factory = getFactory();
factory.setAccessLogEnabled(true);
factory.setAccessLogPrefix(prefix);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -177,12 +177,12 @@ class UndertowServletWebServerFactoryTests extends AbstractServletWebServerFacto
}
@Test
void accessLogCanBeEnabled() throws IOException, URISyntaxException, InterruptedException {
void accessLogCanBeEnabled() throws IOException, URISyntaxException {
testAccessLog(null, null, "access_log.log");
}
@Test
void accessLogCanBeCustomized() throws IOException, URISyntaxException, InterruptedException {
void accessLogCanBeCustomized() throws IOException, URISyntaxException {
testAccessLog("my_access.", "logz", "my_access.logz");
}
@@ -213,7 +213,7 @@ class UndertowServletWebServerFactoryTests extends AbstractServletWebServerFacto
}
private void testAccessLog(String prefix, String suffix, String expectedFile)
throws IOException, URISyntaxException, InterruptedException {
throws IOException, URISyntaxException {
UndertowServletWebServerFactory factory = getFactory();
factory.setAccessLogEnabled(true);
factory.setAccessLogPrefix(prefix);
@@ -236,7 +236,7 @@ class UndertowServletWebServerFactoryTests extends AbstractServletWebServerFacto
}
@Test
void sslRestrictedProtocolsEmptyCipherFailure() throws Exception {
void sslRestrictedProtocolsEmptyCipherFailure() {
assertThatIOException()
.isThrownBy(() -> testRestrictedSSLProtocolsAndCipherSuites(new String[] { "TLSv1.2" },
new String[] { "TLS_EMPTY_RENEGOTIATION_INFO_SCSV" }))
@@ -244,7 +244,7 @@ class UndertowServletWebServerFactoryTests extends AbstractServletWebServerFacto
}
@Test
void sslRestrictedProtocolsECDHETLS1Failure() throws Exception {
void sslRestrictedProtocolsECDHETLS1Failure() {
assertThatIOException()
.isThrownBy(() -> testRestrictedSSLProtocolsAndCipherSuites(new String[] { "TLSv1" },
new String[] { "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" }))
@@ -264,7 +264,7 @@ class UndertowServletWebServerFactoryTests extends AbstractServletWebServerFacto
}
@Test
void sslRestrictedProtocolsRSATLS11Failure() throws Exception {
void sslRestrictedProtocolsRSATLS11Failure() {
assertThatIOException()
.isThrownBy(() -> testRestrictedSSLProtocolsAndCipherSuites(new String[] { "TLSv1.1" },
new String[] { "TLS_RSA_WITH_AES_128_CBC_SHA256" }))

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -66,7 +66,7 @@ class FilterRegistrationBeanTests extends AbstractFilterRegistrationBeanTests {
}
@Test
void setFilterMustNotBeNull() throws Exception {
void setFilterMustNotBeNull() {
FilterRegistrationBean<Filter> bean = new FilterRegistrationBean<>();
assertThatIllegalArgumentException().isThrownBy(() -> bean.onStartup(this.servletContext))
.withMessageContaining("Filter must not be null");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -129,7 +129,7 @@ class ServletRegistrationBeanTests {
}
@Test
void setServletMustNotBeNull() throws Exception {
void setServletMustNotBeNull() {
ServletRegistrationBean<MockServlet> bean = new ServletRegistrationBean<>();
assertThatIllegalArgumentException().isThrownBy(() -> bean.onStartup(this.servletContext))
.withMessageContaining("Servlet must not be null");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -128,7 +128,7 @@ class WebFilterHandlerTests {
}
@Test
void urlPatternsDeclaredTwice() throws IOException {
void urlPatternsDeclaredTwice() {
assertThatIllegalStateException()
.isThrownBy(() -> handleBeanDefinitionForClass(UrlPatternsDeclaredTwiceFilter.class))
.withMessageContaining("The urlPatterns and value attributes are mutually exclusive.");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -103,7 +103,7 @@ class WebServletHandlerTests {
}
@Test
void urlPatternsDeclaredTwice() throws IOException {
void urlPatternsDeclaredTwice() {
assertThatIllegalStateException()
.isThrownBy(() -> handleBeanDefinitionForClass(UrlPatternsDeclaredTwiceServlet.class))
.withMessageContaining("The urlPatterns and value attributes are mutually exclusive.");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -395,7 +395,7 @@ class ServletWebServerApplicationContextTests {
}
@Test
void delegatingFilterProxyRegistrationBeansSkipsTargetBeanNames() throws Exception {
void delegatingFilterProxyRegistrationBeansSkipsTargetBeanNames() {
addWebServerFactoryBean();
DelegatingFilterProxyRegistrationBean initializer = new DelegatingFilterProxyRegistrationBean("filterBean");
this.context.registerBeanDefinition("initializerBean", beanDefinition(initializer));
@@ -444,7 +444,7 @@ class ServletWebServerApplicationContextTests {
}
@Test
void servletRequestCanBeInjectedEarly(CapturedOutput output) throws Exception {
void servletRequestCanBeInjectedEarly(CapturedOutput output) {
// gh-14990
int initialOutputLength = output.length();
addWebServerFactoryBean();
@@ -460,7 +460,7 @@ class ServletWebServerApplicationContextTests {
}
@Test
void webApplicationScopeIsRegistered() throws Exception {
void webApplicationScopeIsRegistered() {
addWebServerFactoryBean();
this.context.refresh();
assertThat(this.context.getBeanFactory().getRegisteredScope(WebApplicationContext.SCOPE_APPLICATION))

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@ class DocumentRootTests {
}
@Test
void explodedWarFileDocumentRootWhenRunningFromPackagedWar() throws Exception {
void explodedWarFileDocumentRootWhenRunningFromPackagedWar() {
File codeSourceFile = new File(this.tempDir, "test.war");
File directory = this.documentRoot.getExplodedWarFileDocumentRoot(codeSourceFile);
assertThat(directory).isNull();