Polish "Remove unnecessary throws declaration in tests"

See gh-26441
This commit is contained in:
Stephane Nicoll
2021-05-17 09:32:04 +02:00
parent 8a2be288a3
commit d3c817b7ba
49 changed files with 106 additions and 164 deletions

View File

@@ -40,7 +40,6 @@ import org.mockito.InOrder;
import org.mockito.Mockito;
import reactor.core.publisher.Mono;
import org.springframework.beans.BeansException;
import org.springframework.beans.CachedIntrospectionResults;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
@@ -1659,7 +1658,7 @@ class SpringApplicationTests {
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}

View File

@@ -82,14 +82,13 @@ class ConfigDataEnvironmentPostProcessorImportCombinedWithProfileSpecificIntegra
}
@Override
public List<Resource> resolve(ConfigDataLocationResolverContext context, ConfigDataLocation location)
throws ConfigDataLocationNotFoundException, ConfigDataResourceNotFoundException {
public List<Resource> resolve(ConfigDataLocationResolverContext context, ConfigDataLocation location) {
return Collections.emptyList();
}
@Override
public List<Resource> resolveProfileSpecific(ConfigDataLocationResolverContext context,
ConfigDataLocation location, Profiles profiles) throws ConfigDataLocationNotFoundException {
ConfigDataLocation location, Profiles profiles) {
return Collections.singletonList(new Resource(profiles));
}
@@ -98,8 +97,7 @@ class ConfigDataEnvironmentPostProcessorImportCombinedWithProfileSpecificIntegra
static class Loader implements ConfigDataLoader<Resource> {
@Override
public ConfigData load(ConfigDataLoaderContext context, Resource resource)
throws IOException, ConfigDataResourceNotFoundException {
public ConfigData load(ConfigDataLoaderContext context, Resource resource) throws IOException {
List<PropertySource<?>> propertySources = new ArrayList<>();
Map<PropertySource<?>, Options> propertySourceOptions = new HashMap<>();
propertySources.add(new MapPropertySource("icwps1", Collections.singletonMap("prop", "fromicwps1")));

View File

@@ -179,14 +179,13 @@ class ConfigDataLocationResolversTests {
@Override
public List<TestConfigDataResource> resolve(ConfigDataLocationResolverContext context,
ConfigDataLocation location)
throws ConfigDataLocationNotFoundException, ConfigDataResourceNotFoundException {
ConfigDataLocation location) {
return Collections.singletonList(new TestConfigDataResource(this, location, false));
}
@Override
public List<TestConfigDataResource> resolveProfileSpecific(ConfigDataLocationResolverContext context,
ConfigDataLocation location, Profiles profiles) throws ConfigDataLocationNotFoundException {
ConfigDataLocation location, Profiles profiles) {
return Collections.singletonList(new TestConfigDataResource(this, location, true));
}

View File

@@ -117,7 +117,7 @@ class LoggingApplicationListenerTests {
private CapturedOutput output;
@BeforeEach
void init(CapturedOutput output) throws SecurityException, IOException {
void init(CapturedOutput output) throws IOException {
this.systemPropertyNames = new HashSet<>(System.getProperties().keySet());
this.output = output;
this.logFile = new File(this.tempDir.toFile(), "foo.log");

View File

@@ -41,7 +41,6 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
@@ -382,7 +381,7 @@ class ConfigurationPropertiesTests {
this.context = new AnnotationConfigApplicationContext() {
@Override
protected void onRefresh() throws BeansException {
protected void onRefresh() {
assertThat(WithFactoryBeanConfiguration.factoryBeanInitialized).as("Initialized too early").isFalse();
super.onRefresh();
}
@@ -2298,7 +2297,7 @@ class ConfigurationPropertiesTests {
static class PersonPropertyEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) throws IllegalArgumentException {
public void setAsText(String text) {
String[] content = text.split(",");
setValue(new Person(content[1], content[0]));
}

View File

@@ -206,7 +206,7 @@ class BindConverterTests {
static class SampleTypePropertyEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) throws IllegalArgumentException {
public void setAsText(String text) {
SampleType value = new SampleType();
value.text = text;
setValue(value);
@@ -238,7 +238,7 @@ class BindConverterTests {
static class ConventionTypeEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) throws IllegalArgumentException {
public void setAsText(String text) {
ConventionType value = new ConventionType();
value.text = text;
setValue(value);

View File

@@ -461,7 +461,7 @@ class BinderTests {
static class JavaBeanPropertyEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) throws IllegalArgumentException {
public void setAsText(String text) {
JavaBean value = new JavaBean();
value.setValue(text);
setValue(value);

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.
@@ -23,7 +23,6 @@ import java.util.Enumeration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.context.EnvironmentAware;
@@ -146,7 +145,7 @@ class FailureAnalyzersTests {
}
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
public void setBeanFactory(BeanFactory beanFactory) {
failureAnalyzer.setBeanFactory(beanFactory);
}

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.
@@ -61,7 +61,7 @@ class JavaLoggingSystemTests extends AbstractLoggingSystemTests {
private Locale defaultLocale;
@BeforeEach
void init() throws SecurityException {
void init() {
this.logger = Logger.getLogger(getClass().getName());
this.defaultLocale = Locale.getDefault();
Locale.setDefault(Locale.ENGLISH);

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.web.reactive.server;
import java.util.Map;
import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.server.WebServerException;
import org.springframework.http.server.reactive.HttpHandler;
import static org.mockito.Mockito.spy;
@@ -70,12 +69,12 @@ public class MockReactiveWebServerFactory extends AbstractReactiveWebServerFacto
}
@Override
public void start() throws WebServerException {
public void start() {
}
@Override
public void stop() throws WebServerException {
public void stop() {
}

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.
@@ -23,7 +23,6 @@ import javax.servlet.ServletContext;
import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredFilter;
import org.springframework.boot.testsupport.web.servlet.MockServletWebServer.RegisteredServlet;
import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.server.WebServerException;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import static org.mockito.Mockito.spy;
@@ -69,7 +68,7 @@ public class MockServletWebServerFactory extends AbstractServletWebServerFactory
}
@Override
public void start() throws WebServerException {
public void start() {
}
}