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

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

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.
@@ -60,22 +60,22 @@ class BatchAutoConfigurationWithoutJdbcTests {
static class BatchConfiguration implements BatchConfigurer {
@Override
public JobRepository getJobRepository() throws Exception {
public JobRepository getJobRepository() {
return mock(JobRepository.class);
}
@Override
public PlatformTransactionManager getTransactionManager() throws Exception {
public PlatformTransactionManager getTransactionManager() {
return mock(PlatformTransactionManager.class);
}
@Override
public JobLauncher getJobLauncher() throws Exception {
public JobLauncher getJobLauncher() {
return mock(JobLauncher.class);
}
@Override
public JobExplorer getJobExplorer() throws Exception {
public JobExplorer getJobExplorer() {
return mock(JobExplorer.class);
}

View File

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

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.
@@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.jdbc;
import java.util.Set;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.sql.DataSource;
import org.apache.commons.dbcp2.BasicDataSource;
@@ -80,7 +79,7 @@ class JndiDataSourceAutoConfigurationTests {
}
@Test
void dataSourceIsAvailableFromJndi() throws IllegalStateException, NamingException {
void dataSourceIsAvailableFromJndi() {
DataSource dataSource = new BasicDataSource();
configureJndi("foo", dataSource);
@@ -94,7 +93,7 @@ class JndiDataSourceAutoConfigurationTests {
@SuppressWarnings("unchecked")
@Test
void mbeanDataSourceIsExcludedFromExport() throws IllegalStateException, NamingException {
void mbeanDataSourceIsExcludedFromExport() throws IllegalStateException {
DataSource dataSource = new BasicDataSource();
configureJndi("foo", dataSource);
@@ -111,7 +110,7 @@ class JndiDataSourceAutoConfigurationTests {
@SuppressWarnings("unchecked")
@Test
void mbeanDataSourceIsExcludedFromExportByAllExporters() throws IllegalStateException, NamingException {
void mbeanDataSourceIsExcludedFromExportByAllExporters() throws IllegalStateException {
DataSource dataSource = new BasicDataSource();
configureJndi("foo", dataSource);
this.context = new AnnotationConfigApplicationContext();
@@ -128,7 +127,7 @@ class JndiDataSourceAutoConfigurationTests {
@SuppressWarnings("unchecked")
@Test
void standardDataSourceIsNotExcludedFromExport() throws IllegalStateException, NamingException {
void standardDataSourceIsNotExcludedFromExport() throws IllegalStateException {
DataSource dataSource = mock(DataSource.class);
configureJndi("foo", dataSource);

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

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,7 +17,6 @@
package org.springframework.boot.autoconfigure.mongo.embedded;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.util.EnumSet;
import java.util.Map;
@@ -150,7 +149,7 @@ class EmbeddedMongoAutoConfigurationTests {
}
@Test
void mongoWritesToCustomDatabaseDir(@TempDir Path temp) throws IOException {
void mongoWritesToCustomDatabaseDir(@TempDir Path temp) {
File customDatabaseDir = new File(temp.toFile(), "custom-database-dir");
FileSystemUtils.deleteRecursively(customDatabaseDir);
load("spring.mongodb.embedded.storage.databaseDir=" + customDatabaseDir.getPath());

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.
@@ -54,7 +54,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class RSocketWebSocketNettyRouteProviderTests {
@Test
void webEndpointsShouldWork() throws Exception {
void webEndpointsShouldWork() {
new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebServerApplicationContext::new)
.withConfiguration(
AutoConfigurations.of(HttpHandlerAutoConfiguration.class, WebFluxAutoConfiguration.class,

View File

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

View File

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

View File

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

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.
@@ -98,7 +98,7 @@ class ServletWebServerFactoryCustomizerTests {
}
@Test
void customizeSessionProperties() throws Exception {
void customizeSessionProperties() {
Map<String, String> map = new HashMap<>();
map.put("server.servlet.session.timeout", "123");
map.put("server.servlet.session.tracking-modes", "cookie,url");

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.
@@ -98,7 +98,7 @@ class BasicErrorControllerDirectMockMvcTests {
}
@Test
void errorPageNotAvailableWithWhitelabelDisabled() throws Exception {
void errorPageNotAvailableWithWhitelabelDisabled() {
setup((ConfigurableWebApplicationContext) new SpringApplication(WebMvcIncludedConfiguration.class)
.run("--server.port=0", "--server.error.whitelabel.enabled=false"));
assertThatExceptionOfType(ServletException.class)

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.
@@ -180,7 +180,7 @@ class BasicErrorControllerMockMvcTests {
}
@RequestMapping("/noContent")
void noContent() throws Exception {
void noContent() {
throw new NoContentException("Expected!");
}

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.
@@ -69,7 +69,7 @@ class ErrorMvcAutoConfigurationTests {
}
@Test
void renderCanUseJavaTimeTypeAsTimestamp() throws Exception { // gh-23256
void renderCanUseJavaTimeTypeAsTimestamp() { // gh-23256
this.contextRunner.run((context) -> {
View errorView = context.getBean("error", View.class);
ErrorAttributes errorAttributes = context.getBean(ErrorAttributes.class);