Remove unnecessary throws declaration in tests
See gh-26441
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,7 +22,6 @@ import java.net.URLClassLoader;
|
||||
import javax.management.Attribute;
|
||||
import javax.management.AttributeList;
|
||||
import javax.management.AttributeNotFoundException;
|
||||
import javax.management.InvalidAttributeValueException;
|
||||
import javax.management.MBeanException;
|
||||
import javax.management.MBeanInfo;
|
||||
import javax.management.ReflectionException;
|
||||
@@ -87,7 +86,7 @@ class EndpointMBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void invokeWhenOperationFailedShouldTranslateException() throws MBeanException, ReflectionException {
|
||||
void invokeWhenOperationFailedShouldTranslateException() {
|
||||
TestExposableJmxEndpoint endpoint = new TestExposableJmxEndpoint(new TestJmxOperation((arguments) -> {
|
||||
throw new FatalBeanException("test failure");
|
||||
}));
|
||||
@@ -99,7 +98,7 @@ class EndpointMBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void invokeWhenOperationFailedWithJdkExceptionShouldReuseException() throws MBeanException, ReflectionException {
|
||||
void invokeWhenOperationFailedWithJdkExceptionShouldReuseException() {
|
||||
TestExposableJmxEndpoint endpoint = new TestExposableJmxEndpoint(new TestJmxOperation((arguments) -> {
|
||||
throw new UnsupportedOperationException("test failure");
|
||||
}));
|
||||
@@ -110,7 +109,7 @@ class EndpointMBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void invokeWhenActionNameIsNotAnOperationShouldThrowException() throws MBeanException, ReflectionException {
|
||||
void invokeWhenActionNameIsNotAnOperationShouldThrowException() {
|
||||
EndpointMBean bean = createEndpointMBean();
|
||||
assertThatExceptionOfType(ReflectionException.class)
|
||||
.isThrownBy(() -> bean.invoke("missingOperation", NO_PARAMS, NO_SIGNATURE))
|
||||
@@ -131,7 +130,7 @@ class EndpointMBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void invokeWhenOperationIsInvalidShouldThrowException() throws MBeanException, ReflectionException {
|
||||
void invokeWhenOperationIsInvalidShouldThrowException() {
|
||||
TestJmxOperation operation = new TestJmxOperation() {
|
||||
|
||||
@Override
|
||||
@@ -166,15 +165,14 @@ class EndpointMBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void getAttributeShouldThrowException() throws AttributeNotFoundException, MBeanException, ReflectionException {
|
||||
void getAttributeShouldThrowException() {
|
||||
EndpointMBean bean = createEndpointMBean();
|
||||
assertThatExceptionOfType(AttributeNotFoundException.class).isThrownBy(() -> bean.getAttribute("test"))
|
||||
.withMessageContaining("EndpointMBeans do not support attributes");
|
||||
}
|
||||
|
||||
@Test
|
||||
void setAttributeShouldThrowException()
|
||||
throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
|
||||
void setAttributeShouldThrowException() {
|
||||
EndpointMBean bean = createEndpointMBean();
|
||||
assertThatExceptionOfType(AttributeNotFoundException.class)
|
||||
.isThrownBy(() -> bean.setAttribute(new Attribute("test", "test")))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,7 +51,7 @@ class ControllerEndpointHandlerMappingTests {
|
||||
private final StaticApplicationContext context = new StaticApplicationContext();
|
||||
|
||||
@Test
|
||||
void mappingWithNoPrefix() throws Exception {
|
||||
void mappingWithNoPrefix() {
|
||||
ExposableControllerEndpoint first = firstEndpoint();
|
||||
ExposableControllerEndpoint second = secondEndpoint();
|
||||
ControllerEndpointHandlerMapping mapping = createMapping("", first, second);
|
||||
@@ -62,7 +62,7 @@ class ControllerEndpointHandlerMappingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void mappingWithPrefix() throws Exception {
|
||||
void mappingWithPrefix() {
|
||||
ExposableControllerEndpoint first = firstEndpoint();
|
||||
ExposableControllerEndpoint second = secondEndpoint();
|
||||
ControllerEndpointHandlerMapping mapping = createMapping("actuator", first, second);
|
||||
@@ -75,7 +75,7 @@ class ControllerEndpointHandlerMappingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void mappingWithNoPath() throws Exception {
|
||||
void mappingWithNoPath() {
|
||||
ExposableControllerEndpoint pathless = pathlessEndpoint();
|
||||
ControllerEndpointHandlerMapping mapping = createMapping("actuator", pathless);
|
||||
assertThat(getHandler(mapping, HttpMethod.GET, "/actuator/pathless"))
|
||||
@@ -85,7 +85,7 @@ class ControllerEndpointHandlerMappingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void mappingNarrowedToMethod() throws Exception {
|
||||
void mappingNarrowedToMethod() {
|
||||
ExposableControllerEndpoint first = firstEndpoint();
|
||||
ControllerEndpointHandlerMapping mapping = createMapping("actuator", first);
|
||||
assertThatExceptionOfType(MethodNotAllowedException.class)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -73,7 +73,7 @@ class ControllerEndpointHandlerMappingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void mappingNarrowedToMethod() throws Exception {
|
||||
void mappingNarrowedToMethod() {
|
||||
ExposableControllerEndpoint first = firstEndpoint();
|
||||
ControllerEndpointHandlerMapping mapping = createMapping("actuator", first);
|
||||
assertThatExceptionOfType(HttpRequestMethodNotSupportedException.class)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -227,7 +227,7 @@ class EnvironmentEndpointTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void propertyWithCharSequenceTypeIsConvertedToString() throws Exception {
|
||||
void propertyWithCharSequenceTypeIsConvertedToString() {
|
||||
ConfigurableEnvironment environment = emptyEnvironment();
|
||||
environment.getPropertySources().addFirst(singleKeyPropertySource("test", "foo", new CharSequenceProperty()));
|
||||
EnvironmentDescriptor descriptor = new EnvironmentEndpoint(environment).environment(null);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,7 +50,7 @@ class LogFileWebEndpointWebIntegrationTests {
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
static void setup(@TempDir File temp) throws IOException {
|
||||
static void setup(@TempDir File temp) {
|
||||
tempFile = temp;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -59,13 +59,13 @@ class HeapDumpWebEndpointWebIntegrationTests {
|
||||
}
|
||||
|
||||
@WebEndpointTest
|
||||
void getRequestShouldReturnHeapDumpInResponseBody(WebTestClient client) throws Exception {
|
||||
void getRequestShouldReturnHeapDumpInResponseBody(WebTestClient client) {
|
||||
client.get().uri("/actuator/heapdump").exchange().expectStatus().isOk().expectHeader()
|
||||
.contentType(MediaType.APPLICATION_OCTET_STREAM).expectBody(String.class).isEqualTo("HEAPDUMP");
|
||||
assertHeapDumpFileIsDeleted();
|
||||
}
|
||||
|
||||
private void assertHeapDumpFileIsDeleted() throws InterruptedException {
|
||||
private void assertHeapDumpFileIsDeleted() {
|
||||
Awaitility.waitAtMost(Duration.ofSeconds(5)).until(this.endpoint.file::exists, is(false));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,13 +33,13 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class ThreadDumpEndpointWebIntegrationTests {
|
||||
|
||||
@WebEndpointTest
|
||||
void getRequestWithJsonAcceptHeaderShouldProduceJsonThreadDumpResponse(WebTestClient client) throws Exception {
|
||||
void getRequestWithJsonAcceptHeaderShouldProduceJsonThreadDumpResponse(WebTestClient client) {
|
||||
client.get().uri("/actuator/threaddump").accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk()
|
||||
.expectHeader().contentType(MediaType.APPLICATION_JSON);
|
||||
}
|
||||
|
||||
@WebEndpointTest
|
||||
void getRequestWithTextPlainAcceptHeaderShouldProduceTextPlainResponse(WebTestClient client) throws Exception {
|
||||
void getRequestWithTextPlainAcceptHeaderShouldProduceTextPlainResponse(WebTestClient client) {
|
||||
String response = client.get().uri("/actuator/threaddump").accept(MediaType.TEXT_PLAIN).exchange()
|
||||
.expectStatus().isOk().expectHeader().contentType("text/plain;charset=UTF-8").expectBody(String.class)
|
||||
.returnResult().getResponseBody();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -85,7 +85,7 @@ class WebMvcMetricsIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void rethrownExceptionIsRecordedInMetricTag() throws Exception {
|
||||
void rethrownExceptionIsRecordedInMetricTag() {
|
||||
assertThatExceptionOfType(NestedServletException.class)
|
||||
.isThrownBy(() -> this.mvc.perform(get("/api/rethrownError")).andReturn());
|
||||
assertThat(this.registry.get("http.server.requests").tags("exception", "Exception2", "status", "500").timer()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -99,7 +99,7 @@ class HttpTraceFilterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void statusIsAssumedToBe500WhenChainFails() throws ServletException, IOException {
|
||||
void statusIsAssumedToBe500WhenChainFails() {
|
||||
assertThatIOException().isThrownBy(() -> this.filter.doFilter(new MockHttpServletRequest(),
|
||||
new MockHttpServletResponse(), new MockFilterChain(new HttpServlet() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user