This commit is contained in:
Stéphane Nicoll 2024-01-15 16:27:16 +01:00
parent fdf187ec46
commit 4d885f9aad
100 changed files with 406 additions and 434 deletions

View File

@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class MockServerHttpResponseTests {
@Test
void cookieHeaderSet() throws Exception {
void cookieHeaderSet() {
ResponseCookie foo11 = ResponseCookie.from("foo1", "bar1").build();
ResponseCookie foo12 = ResponseCookie.from("foo1", "bar2").build();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -62,13 +62,13 @@ class MockFilterChainTests {
}
@Test
void doFilterNullRequest() throws Exception {
void doFilterNullRequest() {
MockFilterChain chain = new MockFilterChain();
assertThatIllegalArgumentException().isThrownBy(() -> chain.doFilter(null, this.response));
}
@Test
void doFilterNullResponse() throws Exception {
void doFilterNullResponse() {
MockFilterChain chain = new MockFilterChain();
assertThatIllegalArgumentException().isThrownBy(() -> chain.doFilter(this.request, null));
}
@ -143,7 +143,7 @@ class MockFilterChainTests {
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
public void init(FilterConfig filterConfig) {
}
@Override

View File

@ -114,7 +114,7 @@ class MockHttpServletRequestTests {
}
@Test
void getContentAsStringWithoutSettingCharacterEncoding() throws IOException {
void getContentAsStringWithoutSettingCharacterEncoding() {
assertThatIllegalStateException().isThrownBy(
request::getContentAsString)
.withMessageContaining("Cannot get content as a String for a null character encoding");
@ -145,14 +145,14 @@ class MockHttpServletRequestTests {
}
@Test // SPR-16505
void getInputStreamTwice() throws IOException {
void getInputStreamTwice() {
byte[] bytes = "body".getBytes(Charset.defaultCharset());
request.setContent(bytes);
assertThat(request.getInputStream()).isSameAs(request.getInputStream());
}
@Test // SPR-16499
void getReaderAfterGettingInputStream() throws IOException {
void getReaderAfterGettingInputStream() {
request.getInputStream();
assertThatIllegalStateException().isThrownBy(
request::getReader)

View File

@ -35,7 +35,7 @@ class MockPageContextTests {
private final MockPageContext ctx = new MockPageContext();
@Test
void setAttributeWithNoScopeUsesPageScope() throws Exception {
void setAttributeWithNoScopeUsesPageScope() {
ctx.setAttribute(key, value);
assertThat(ctx.getAttribute(key, PageContext.PAGE_SCOPE)).isEqualTo(value);
assertThat(ctx.getAttribute(key, PageContext.APPLICATION_SCOPE)).isNull();
@ -44,7 +44,7 @@ class MockPageContextTests {
}
@Test
void removeAttributeWithNoScopeSpecifiedRemovesValueFromAllScopes() throws Exception {
void removeAttributeWithNoScopeSpecifiedRemovesValueFromAllScopes() {
ctx.setAttribute(key, value, PageContext.APPLICATION_SCOPE);
ctx.removeAttribute(key);

View File

@ -46,11 +46,11 @@ class ProfileValueUtilsTests {
System.setProperty(NAME, VALUE);
}
private void assertClassIsEnabled(Class<?> testClass) throws Exception {
private void assertClassIsEnabled(Class<?> testClass) {
assertThat(ProfileValueUtils.isTestEnabledInThisEnvironment(testClass)).as("Test class [" + testClass + "] should be enabled.").isTrue();
}
private void assertClassIsDisabled(Class<?> testClass) throws Exception {
private void assertClassIsDisabled(Class<?> testClass) {
assertThat(ProfileValueUtils.isTestEnabledInThisEnvironment(testClass)).as("Test class [" + testClass + "] should be disabled.").isFalse();
}
@ -81,7 +81,7 @@ class ProfileValueUtilsTests {
// -------------------------------------------------------------------
@Test
void isTestEnabledInThisEnvironmentForProvidedClass() throws Exception {
void isTestEnabledInThisEnvironmentForProvidedClass() {
assertClassIsEnabled(NonAnnotated.class);
assertClassIsEnabled(EnabledAnnotatedSingleValue.class);
assertClassIsEnabled(EnabledAnnotatedMultiValue.class);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 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 DynamicPropertySourceIntegrationTests {
System.setProperty(TEST_CONTAINER_IP, "system");
}
static DemoContainer container = new DemoContainer();
static final DemoContainer container = new DemoContainer();
@DynamicPropertySource
static void containerProperties(DynamicPropertyRegistry registry) {

View File

@ -241,7 +241,7 @@ class MergedContextConfigurationTests {
void equalsBasics() {
MergedContextConfiguration mergedConfig = new MergedContextConfiguration(null, null, null, null, null);
assertThat(mergedConfig).isEqualTo(mergedConfig);
assertThat(mergedConfig).isNotNull();
assertThat(mergedConfig).isNotEqualTo(null);
assertThat(mergedConfig).isNotEqualTo(1);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
class TestContextConcurrencyTests {
private static Set<String> expectedMethods = stream(TestCase.class.getDeclaredMethods())
private static final Set<String> expectedMethods = stream(TestCase.class.getDeclaredMethods())
.map(Method::getName)
.collect(toCollection(TreeSet::new));
@ -122,7 +122,7 @@ class TestContextConcurrencyTests {
@Override
public void beforeTestMethod(TestContext testContext) throws Exception {
public void beforeTestMethod(TestContext testContext) {
String name = testContext.getTestMethod().getName();
actualMethods.add(name);
testContext.setAttribute("method", name);
@ -130,7 +130,7 @@ class TestContextConcurrencyTests {
}
@Override
public void afterTestMethod(TestContext testContext) throws Exception {
public void afterTestMethod(TestContext testContext) {
assertThat(testContext.getAttribute("method")).isEqualTo(this.methodName.get());
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -83,7 +83,7 @@ class TestContextManagerMethodInvokerTests {
}
@Override
public void prepareTestInstance(TestContext testContext) throws Exception {
public void prepareTestInstance(TestContext testContext) {
assertThat(testContext.getMethodInvoker()).isSameAs(customMethodInvoker);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
@ -36,23 +36,23 @@ import static org.assertj.core.api.Assertions.fail;
class TestContextManagerSuppressedExceptionsTests {
@Test
void afterTestExecution() throws Exception {
void afterTestExecution() {
test("afterTestExecution", FailingAfterTestExecutionTestCase.class,
(tcm, c, m) -> tcm.afterTestExecution(this, m, null));
}
@Test
void afterTestMethod() throws Exception {
void afterTestMethod() {
test("afterTestMethod", FailingAfterTestMethodTestCase.class,
(tcm, c, m) -> tcm.afterTestMethod(this, m, null));
}
@Test
void afterTestClass() throws Exception {
void afterTestClass() {
test("afterTestClass", FailingAfterTestClassTestCase.class, (tcm, c, m) -> tcm.afterTestClass());
}
private void test(String useCase, Class<?> testClass, Callback callback) throws Exception {
private void test(String useCase, Class<?> testClass, Callback callback) {
TestContextManager testContextManager = new TestContextManager(testClass);
assertThat(testContextManager.getTestExecutionListeners().size()).as("Registered TestExecutionListeners").isEqualTo(2);

View File

@ -134,13 +134,13 @@ class TestExecutionListenersTests {
@Test
void nonInheritedDefaultListeners() {
assertRegisteredListeners(NonInheritedDefaultListenersTestCase.class, asList(QuuxTestExecutionListener.class));
assertRegisteredListeners(NonInheritedDefaultListenersTestCase.class, List.of(QuuxTestExecutionListener.class));
}
@Test
void inheritedDefaultListeners() {
assertRegisteredListeners(InheritedDefaultListenersTestCase.class, asList(QuuxTestExecutionListener.class));
assertRegisteredListeners(SubInheritedDefaultListenersTestCase.class, asList(QuuxTestExecutionListener.class));
assertRegisteredListeners(InheritedDefaultListenersTestCase.class, List.of(QuuxTestExecutionListener.class));
assertRegisteredListeners(SubInheritedDefaultListenersTestCase.class, List.of(QuuxTestExecutionListener.class));
assertRegisteredListeners(SubSubInheritedDefaultListenersTestCase.class,
asList(QuuxTestExecutionListener.class, EnigmaTestExecutionListener.class));
}

View File

@ -292,7 +292,7 @@ class TestContextAotGeneratorIntegrationTests extends AbstractAotTests {
assertThat(messageService.generateMessage()).isEqualTo(expectedMessage);
}
private void assertContextForJdbcTests(ApplicationContext context) throws Exception {
private void assertContextForJdbcTests(ApplicationContext context) {
assertThat(context.getEnvironment().getProperty("test.engine")).as("Environment").isNotNull();
assertThat(context.getBean(DataSource.class)).as("DataSource").isNotNull();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -21,7 +21,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.aot.AotDetector;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.TestPropertySource;
@ -52,7 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class DisabledInAotRuntimeClassLevelTests {
@Test
void test(@Autowired ApplicationContext context, @Autowired MessageService messageService,
void test(@Autowired MessageService messageService,
@Value("${disabledInAotMode}") String disabledInAotMode) {
assertThat(AotDetector.useGeneratedArtifacts()).as("Should be disabled in AOT mode").isFalse();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -21,7 +21,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.aot.AotDetector;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.TestPropertySource;
@ -49,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class DisabledInAotRuntimeMethodLevelTests {
@Test
void test(@Autowired ApplicationContext context, @Autowired MessageService messageService,
void test(@Autowired MessageService messageService,
@Value("${disabledInAotMode}") String disabledInAotMode) {
assertThat(messageService.generateMessage()).isEqualTo("Hello, AOT!");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -67,7 +67,7 @@ class ClassLevelDirtiesContextTestNGTests {
}
@Test
void verifyDirtiesContextBehavior() throws Exception {
void verifyDirtiesContextBehavior() {
assertBehaviorForCleanTestCase();

View File

@ -155,7 +155,6 @@ class LruContextCacheTests {
return new MergedContextConfiguration(null, null, new Class<?>[] { clazz }, null, null);
}
@SuppressWarnings("unchecked")
private static void assertCacheContents(DefaultContextCache cache, String... expectedNames) {
assertThat(cache).extracting("contextMap", as(map(MergedContextConfiguration.class, ApplicationContext.class)))
.satisfies(contextMap -> {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -62,31 +62,31 @@ class MethodLevelDirtiesContextTests {
@Test
@Order(1)
void basics() throws Exception {
void basics() {
performAssertions(1);
}
@Test
@Order(2)
@DirtiesContext(methodMode = BEFORE_METHOD)
void dirtyContextBeforeTestMethod() throws Exception {
void dirtyContextBeforeTestMethod() {
performAssertions(2);
}
@Test
@Order(3)
@DirtiesContext
void dirtyContextAfterTestMethod() throws Exception {
void dirtyContextAfterTestMethod() {
performAssertions(2);
}
@Test
@Order(4)
void backToBasics() throws Exception {
void backToBasics() {
performAssertions(3);
}
private void performAssertions(int expectedContextCreationCount) throws Exception {
private void performAssertions(int expectedContextCreationCount) {
assertThat(this.context).as("context must not be null").isNotNull();
assertThat(this.context.isActive()).as("context must be active").isTrue();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.test.context.configuration.interfaces;
import java.util.List;
import org.springframework.test.context.BootstrapWith;
import org.springframework.test.context.ContextCustomizer;
import org.springframework.test.context.ContextCustomizerFactory;
import org.springframework.test.context.configuration.interfaces.BootstrapWithTestInterface.CustomTestContextBootstrapper;
import org.springframework.test.context.support.DefaultTestContextBootstrapper;
@ -38,9 +37,8 @@ interface BootstrapWithTestInterface {
@Override
protected List<ContextCustomizerFactory> getContextCustomizerFactories() {
return singletonList(
(ContextCustomizerFactory) (testClass, configAttributes) -> (ContextCustomizer) (context,
mergedConfig) -> context.getBeanFactory().registerSingleton("foo", "foo"));
return singletonList((testClass, configAttributes) ->
(context,mergedConfig) -> context.getBeanFactory().registerSingleton("foo", "foo"));
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Sam Brannen
* @since 6.1
*/
@SpringJUnitConfig({})
@SpringJUnitConfig
@CustomizeWithFruit
@CustomizeWithFoo
@CustomizeWithBar

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Sam Brannen
* @since 6.1
*/
@SpringJUnitConfig({})
@SpringJUnitConfig
@CustomizeWithFruit
@CustomizeWithFoo
@ContextCustomizerFactories(EnigmaContextCustomizerFactory.class)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Phillip Webb
* @since 4.3
*/
@SpringJUnitConfig({})
@SpringJUnitConfig
@CustomizeWithFoo
@BootstrapWith(EnigmaTestContextBootstrapper.class)
@CustomizeWithBar

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -28,7 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Sam Brannen
* @since 6.1
*/
@SpringJUnitConfig({})
@SpringJUnitConfig
@CustomizeWithFruit
@CustomizeWithFoo
class LocalContextCustomizerRegistrationTests {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Sam Brannen
* @since 6.1
*/
@SpringJUnitConfig({})
@SpringJUnitConfig
@ContextCustomizerFactories(factories = {FooContextCustomizerFactory.class, BarContextCustomizerFactory.class},
mergeMode = MergeMode.REPLACE_DEFAULTS)
class ReplaceDefaultsContextCustomizerTests {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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 ExpressionUsageTests {
@Test
void testSpr5906() throws Exception {
void testSpr5906() {
// verify the property values have been evaluated as expressions
assertThat(props.getProperty("user.name")).isEqualTo("Dave");
assertThat(props.getProperty("username")).isEqualTo("Andy");
@ -60,7 +60,7 @@ class ExpressionUsageTests {
}
@Test
void testSpr5847() throws Exception {
void testSpr5847() {
assertThat(andy2.getName()).isEqualTo("Andy");
assertThat(andy.getName()).isEqualTo("Andy");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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,7 +33,7 @@ import org.springframework.test.context.ApplicationContextFailureProcessor;
*/
public class TrackingApplicationContextFailureProcessor implements ApplicationContextFailureProcessor {
public static List<LoadFailure> loadFailures = Collections.synchronizedList(new ArrayList<>());
public static final List<LoadFailure> loadFailures = Collections.synchronizedList(new ArrayList<>());
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 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.
@ -41,7 +41,6 @@ import static org.assertj.core.api.Assertions.assertThat;
class GroovyControlGroupTests {
@Test
@SuppressWarnings("resource")
void verifyScriptUsingGenericGroovyApplicationContext() {
ApplicationContext ctx = new GenericGroovyApplicationContext(getClass(), "context.groovy");

View File

@ -157,7 +157,7 @@ class MergedSqlConfigTests {
}
@Test
void globalConfigWithEmptyCommentPrefix() throws Exception {
void globalConfigWithEmptyCommentPrefix() {
SqlConfig sqlConfig = GlobalConfigWithWithEmptyCommentPrefixClass.class.getAnnotation(SqlConfig.class);
assertThatIllegalArgumentException()
@ -166,7 +166,7 @@ class MergedSqlConfigTests {
}
@Test
void globalConfigWithEmptyCommentPrefixes() throws Exception {
void globalConfigWithEmptyCommentPrefixes() {
SqlConfig sqlConfig = GlobalConfigWithWithEmptyCommentPrefixesClass.class.getAnnotation(SqlConfig.class);
assertThatIllegalArgumentException()
@ -175,7 +175,7 @@ class MergedSqlConfigTests {
}
@Test
void globalConfigWithDuplicatedCommentPrefixes() throws Exception {
void globalConfigWithDuplicatedCommentPrefixes() {
SqlConfig sqlConfig = GlobalConfigWithWithDuplicatedCommentPrefixesClass.class.getAnnotation(SqlConfig.class);
assertThatIllegalArgumentException()

View File

@ -135,7 +135,7 @@ class SqlScriptsTestExecutionListenerTests {
.withMessage("@SQL execution phase AFTER_TEST_CLASS cannot be used on methods");
}
private void assertExceptionContains(String msg) throws Exception {
private void assertExceptionContains(String msg) {
assertThatIllegalStateException()
.isThrownBy(() -> listener.beforeTestMethod(testContext))
.withMessageContaining(msg);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2024 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.
@ -42,7 +42,7 @@ import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass
*/
class DisabledIfAndDirtiesContextTests {
private static AtomicBoolean contextClosed = new AtomicBoolean();
private static final AtomicBoolean contextClosed = new AtomicBoolean();
@BeforeEach

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2024 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.
@ -42,7 +42,7 @@ import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass
*/
class EnabledIfAndDirtiesContextTests {
private static AtomicBoolean contextClosed = new AtomicBoolean();
private static final AtomicBoolean contextClosed = new AtomicBoolean();
@BeforeEach

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -135,7 +135,7 @@ class FailingBeforeAndAfterMethodsSpringExtensionTests {
private static class AlwaysFailingPrepareTestInstanceTestExecutionListener implements TestExecutionListener {
@Override
public void prepareTestInstance(TestContext testContext) throws Exception {
public void prepareTestInstance(TestContext testContext) {
fail("always failing prepareTestInstance()");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
@ -70,7 +70,7 @@ class ConstructorInjectionNestedTests {
}
@Test
void nestedTest() throws Exception {
void nestedTest() {
assertThat(foo).isEqualTo("foo");
assertThat(bar).isEqualTo("bar");
}
@ -87,7 +87,7 @@ class ConstructorInjectionNestedTests {
}
@Test
void nestedTest() throws Exception {
void nestedTest() {
assertThat(foo).isEqualTo("foo");
assertThat(bar).isEqualTo("bar");
}
@ -104,7 +104,7 @@ class ConstructorInjectionNestedTests {
}
@Test
void nestedTest() throws Exception {
void nestedTest() {
assertThat(foo).isEqualTo("foo");
assertThat(bar).isEqualTo("bar");
}
@ -123,7 +123,7 @@ class ConstructorInjectionNestedTests {
}
@Test
void nestedTest() throws Exception {
void nestedTest() {
assertThat(foo).isEqualTo("foo");
assertThat(bar).isEqualTo("bar");
assertThat(answer).isEqualTo(42);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -82,7 +82,7 @@ class ContextHierarchyNestedTests {
@Test
void nestedTest() throws Exception {
void nestedTest() {
assertThat(this.context).as("local ApplicationContext").isNotNull();
assertThat(this.context.getParent()).as("parent ApplicationContext").isNull();
@ -107,7 +107,7 @@ class ContextHierarchyNestedTests {
@Test
void nestedTest() throws Exception {
void nestedTest() {
assertThat(this.context).as("local ApplicationContext").isNotNull();
assertThat(this.context.getParent()).as("parent ApplicationContext").isNotNull();
@ -135,7 +135,7 @@ class ContextHierarchyNestedTests {
@Test
void nestedTest() throws Exception {
void nestedTest() {
assertThat(this.context).as("local ApplicationContext").isNotNull();
assertThat(this.context.getParent()).as("parent ApplicationContext").isNotNull();
@ -160,7 +160,7 @@ class ContextHierarchyNestedTests {
@Test
void nestedTest() throws Exception {
void nestedTest() {
assertThat(this.context).as("local ApplicationContext").isNotNull();
assertThat(this.context.getParent()).as("parent ApplicationContext").isNotNull();
assertThat(this.context.getParent().getParent()).as("grandparent ApplicationContext").isNotNull();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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 DynamicPropertySourceNestedTests {
private static final String TEST_CONTAINER_PORT = "DynamicPropertySourceNestedTests.test.container.port";
static DemoContainer container = new DemoContainer();
static final DemoContainer container = new DemoContainer();
@DynamicPropertySource
static void containerProperties(DynamicPropertyRegistry registry) {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 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 @@ public class JUnitTestingUtils {
*/
public static void runTestsAndAssertCounters(Computer computer, int expectedStartedCount, int expectedFailedCount,
int expectedFinishedCount, int expectedIgnoredCount, int expectedAssumptionFailedCount,
Class<?>... testClasses) throws Exception {
Class<?>... testClasses) {
JUnitCore junit = new JUnitCore();
TrackingRunListener listener = new TrackingRunListener();

View File

@ -16,7 +16,6 @@
package org.springframework.test.context.junit4;
import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.concurrent.atomic.AtomicInteger;
@ -99,7 +98,7 @@ public class RepeatedSpringRunnerTests {
@TestExecutionListeners({})
public abstract static class AbstractRepeatedTestCase {
protected void incrementInvocationCount() throws IOException {
protected void incrementInvocationCount() {
invocationCount.incrementAndGet();
}
}
@ -108,7 +107,7 @@ public class RepeatedSpringRunnerTests {
@Test
@Timed(millis = 10000)
public void nonAnnotated() throws Exception {
public void nonAnnotated() {
incrementInvocationCount();
}
}
@ -118,7 +117,7 @@ public class RepeatedSpringRunnerTests {
@Test
@Repeat
@Timed(millis = 10000)
public void defaultRepeatValue() throws Exception {
public void defaultRepeatValue() {
incrementInvocationCount();
}
}
@ -128,7 +127,7 @@ public class RepeatedSpringRunnerTests {
@Test
@Repeat(-5)
@Timed(millis = 10000)
public void negativeRepeatValue() throws Exception {
public void negativeRepeatValue() {
incrementInvocationCount();
}
}
@ -137,7 +136,7 @@ public class RepeatedSpringRunnerTests {
@Test
@Repeat(5)
public void repeatedFiveTimes() throws Exception {
public void repeatedFiveTimes() {
incrementInvocationCount();
}
}
@ -151,7 +150,7 @@ public class RepeatedSpringRunnerTests {
@Test
@RepeatedFiveTimes
public void repeatedFiveTimes() throws Exception {
public void repeatedFiveTimes() {
incrementInvocationCount();
}
}
@ -165,7 +164,7 @@ public class RepeatedSpringRunnerTests {
@Test
@Timed(millis = 1000)
@Repeat(5)
public void repeatedFiveTimesButDoesNotExceedTimeout() throws Exception {
public void repeatedFiveTimesButDoesNotExceedTimeout() {
incrementInvocationCount();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -78,7 +78,7 @@ public class SpringJUnit4ClassRunnerAppCtxTests implements ApplicationContextAwa
/**
* Default resource path for the application context configuration for
* {@link SpringJUnit4ClassRunnerAppCtxTests}: {@value #DEFAULT_CONTEXT_RESOURCE_PATH}
* {@link SpringJUnit4ClassRunnerAppCtxTests}: {@value}
*/
public static final String DEFAULT_CONTEXT_RESOURCE_PATH =
"/org/springframework/test/context/junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml";

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2024 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.
@ -63,17 +63,17 @@ public class TrackingRunListener extends RunListener {
}
@Override
public void testFailure(Failure failure) throws Exception {
public void testFailure(Failure failure) {
this.testFailureCount.incrementAndGet();
}
@Override
public void testStarted(Description description) throws Exception {
public void testStarted(Description description) {
this.testStartedCount.incrementAndGet();
}
@Override
public void testFinished(Description description) throws Exception {
public void testFinished(Description description) {
this.testFinishedCount.incrementAndGet();
}
@ -83,7 +83,7 @@ public class TrackingRunListener extends RunListener {
}
@Override
public void testIgnored(Description description) throws Exception {
public void testIgnored(Description description) {
this.testIgnoredCount.incrementAndGet();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 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 @@ public class HybridContextLoaderTests {
// Note: the XML bean definition for "enigma" always wins since
// ConfigurationClassBeanDefinitionReader.isOverriddenByExistingDefinition()
// lets XML bean definitions override those "discovered" later via an
// lets XML bean definitions override those "discovered" later via a
// @Bean method.
assertThat(enigma).isEqualTo("enigma from XML");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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 @@ public class NestedTestsWithSpringRulesTests extends SpringRuleConfigurer {
@Test
public void nestedTest() throws Exception {
public void nestedTest() {
assertThat(foo).isEqualTo("foo");
assertThat(bar).isEqualTo("bar");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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 @@ public class HibernateSessionFlushingTests extends AbstractTransactionalJUnit4Sp
}
@Test
public void updateSamWithNullDriversLicenseWithSessionFlush() throws Throwable {
public void updateSamWithNullDriversLicenseWithSessionFlush() {
updateSamWithNullDriversLicense();
assertThatExceptionOfType(ConstraintViolationException.class).isThrownBy(() -> {
// Manual flush is required to avoid false positive in test

View File

@ -16,7 +16,6 @@
package org.springframework.test.context.junit4.rules;
import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@ -79,7 +78,7 @@ public class RepeatedSpringRuleTests extends RepeatedSpringRunnerTests {
public final SpringMethodRule springMethodRule = new SpringMethodRule();
protected void incrementInvocationCount() throws IOException {
protected void incrementInvocationCount() {
invocationCount.incrementAndGet();
}
}
@ -88,7 +87,7 @@ public class RepeatedSpringRuleTests extends RepeatedSpringRunnerTests {
@Test
@Timed(millis = 10000)
public void nonAnnotated() throws Exception {
public void nonAnnotated() {
incrementInvocationCount();
}
}
@ -98,7 +97,7 @@ public class RepeatedSpringRuleTests extends RepeatedSpringRunnerTests {
@Test
@Repeat
@Timed(millis = 10000)
public void defaultRepeatValue() throws Exception {
public void defaultRepeatValue() {
incrementInvocationCount();
}
}
@ -108,7 +107,7 @@ public class RepeatedSpringRuleTests extends RepeatedSpringRunnerTests {
@Test
@Repeat(-5)
@Timed(millis = 10000)
public void negativeRepeatValue() throws Exception {
public void negativeRepeatValue() {
incrementInvocationCount();
}
}
@ -117,7 +116,7 @@ public class RepeatedSpringRuleTests extends RepeatedSpringRunnerTests {
@Test
@Repeat(5)
public void repeatedFiveTimes() throws Exception {
public void repeatedFiveTimes() {
incrementInvocationCount();
}
}
@ -131,7 +130,7 @@ public class RepeatedSpringRuleTests extends RepeatedSpringRunnerTests {
@Test
@RepeatedFiveTimes
public void repeatedFiveTimes() throws Exception {
public void repeatedFiveTimes() {
incrementInvocationCount();
}
}
@ -145,7 +144,7 @@ public class RepeatedSpringRuleTests extends RepeatedSpringRunnerTests {
@Test
@Timed(millis = 1000)
@Repeat(5)
public void repeatedFiveTimesButDoesNotExceedTimeout() throws Exception {
public void repeatedFiveTimesButDoesNotExceedTimeout() {
incrementInvocationCount();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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 @@ public class Jsr250LifecycleTests {
}
@After
public void tearDown() throws Exception {
public void tearDown() {
logger.info("tearDown()");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2024 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.
@ -43,7 +43,6 @@ import org.junit.runners.Suite.SuiteClasses;
* @author Sam Brannen
* @since 3.2
*/
@SuppressWarnings("javadoc")
@RunWith(Suite.class)
@SuiteClasses({ TestClass1.class, TestClass2.class, TestClass3.class, TestClass4.class })
public class Spr8849Tests {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 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.
@ -122,7 +122,7 @@ public abstract class AbstractTransactionalAnnotatedConfigClassTests {
}
@After
public void tearDown() throws Exception {
public void tearDown() {
assertNumRowsInPersonTable((isActualTransactionActive() ? 3 : 0), "after a test method");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
@ -87,7 +87,7 @@ public class AnnotatedConfigClassesWithoutAtConfigurationTests {
@Test
public void testSPR_9051() throws Exception {
public void testSPR_9051() {
assertThat(enigma).isNotNull();
assertThat(lifecycleBean).isNotNull();
assertThat(lifecycleBean.isInitialized()).isTrue();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 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.
@ -78,7 +78,7 @@ public class TransactionalAnnotatedConfigClassWithAtConfigurationTests extends
@Before
public void compareDataSources() throws Exception {
public void compareDataSources() {
// NOTE: the two DataSource instances ARE the same!
assertThat(dataSourceViaInjection).isSameAs(dataSourceFromTxManager);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 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.
@ -104,7 +104,7 @@ public class TransactionalAnnotatedConfigClassesWithoutAtConfigurationTests exte
@Before
public void compareDataSources() throws Exception {
public void compareDataSources() {
// NOTE: the two DataSource instances are NOT the same!
assertThat(dataSourceViaInjection).isNotSameAs(dataSourceFromTxManager);
}

View File

@ -42,13 +42,13 @@ public class SpringFailOnTimeoutTests {
@Test
public void nullNextStatement() throws Throwable {
public void nullNextStatement() {
assertThatIllegalArgumentException().isThrownBy(() ->
new SpringFailOnTimeout(null, 1));
}
@Test
public void negativeTimeout() throws Throwable {
public void negativeTimeout() {
assertThatIllegalArgumentException().isThrownBy(() ->
new SpringFailOnTimeout(statement, -1));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -58,7 +58,7 @@ abstract class AbstractContextConfigurationUtilsTests {
static final String[] EMPTY_STRING_ARRAY = new String[0];
static final Set<Class<? extends ApplicationContextInitializer<?>>>
EMPTY_INITIALIZER_CLASSES = Collections.<Class<? extends ApplicationContextInitializer<?>>> emptySet();
EMPTY_INITIALIZER_CLASSES = Collections.emptySet();
MergedContextConfiguration buildMergedContextConfiguration(Class<?> testClass) {

View File

@ -79,12 +79,10 @@ class AnnotationConfigContextLoaderTests {
AnnotatedFooConfigInnerClassTestCase.class, EMPTY_STRING_ARRAY,
new Class<?>[] {AnnotatedFooConfigInnerClassTestCase.FooConfig.class},
EMPTY_STRING_ARRAY, contextLoader);
ApplicationContext context = contextLoader.loadContextForAotProcessing(mergedConfig);
assertThat(context).isInstanceOf(ConfigurableApplicationContext.class);
ConfigurableApplicationContext cac = (ConfigurableApplicationContext) context;
assertThat(cac.isActive()).as("ApplicationContext is active").isFalse();
ConfigurableApplicationContext context = contextLoader.loadContextForAotProcessing(mergedConfig);
assertThat(context.isActive()).as("ApplicationContext is active").isFalse();
assertThat(Arrays.stream(context.getBeanDefinitionNames())).anyMatch(name -> name.contains("FooConfig"));
cac.close();
context.close();
}
@Test

View File

@ -99,12 +99,12 @@ class DelegatingSmartContextLoaderTests {
}
@Test
void loadContextWithNullConfig() throws Exception {
void loadContextWithNullConfig() {
assertThatIllegalArgumentException().isThrownBy(() -> loader.loadContext((MergedContextConfiguration) null));
}
@Test
void loadContextWithoutLocationsAndConfigurationClasses() throws Exception {
void loadContextWithoutLocationsAndConfigurationClasses() {
MergedContextConfiguration mergedConfig = new MergedContextConfiguration(
getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader);
assertThatIllegalStateException()
@ -117,7 +117,7 @@ class DelegatingSmartContextLoaderTests {
* @since 4.1
*/
@Test
void loadContextWithLocationsAndConfigurationClasses() throws Exception {
void loadContextWithLocationsAndConfigurationClasses() {
MergedContextConfiguration mergedConfig = new MergedContextConfiguration(getClass(),
new String[] {"test.xml"}, new Class<?>[] {getClass()}, EMPTY_STRING_ARRAY, loader);
assertThatIllegalStateException()

View File

@ -325,7 +325,7 @@ class DirtiesContextTestExecutionListenerTests {
verify(testContext, times(1)).markApplicationContextDirty(EXHAUSTIVE);
}
private void assertAfterMethod(Class<?> clazz) throws NoSuchMethodException, Exception {
private void assertAfterMethod(Class<?> clazz) throws Exception {
BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(clazz);
given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("test"));
beforeListener.beforeTestMethod(testContext);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -58,7 +58,7 @@ class DynamicPropertiesContextCustomizerTests {
}
@Test
void nullPropertyNameResultsInException() throws Exception {
void nullPropertyNameResultsInException() {
DynamicPropertiesContextCustomizer customizer = customizerFor("nullName");
ConfigurableApplicationContext context = new StaticApplicationContext();
assertThatIllegalArgumentException()
@ -67,7 +67,7 @@ class DynamicPropertiesContextCustomizerTests {
}
@Test
void emptyPropertyNameResultsInException() throws Exception {
void emptyPropertyNameResultsInException() {
DynamicPropertiesContextCustomizer customizer = customizerFor("emptyName");
ConfigurableApplicationContext context = new StaticApplicationContext();
assertThatIllegalArgumentException()
@ -76,7 +76,7 @@ class DynamicPropertiesContextCustomizerTests {
}
@Test
void nullValueSupplierResultsInException() throws Exception {
void nullValueSupplierResultsInException() {
DynamicPropertiesContextCustomizer customizer = customizerFor("nullValueSupplier");
ConfigurableApplicationContext context = new StaticApplicationContext();
assertThatIllegalArgumentException()
@ -85,7 +85,7 @@ class DynamicPropertiesContextCustomizerTests {
}
@Test
void customizeContextAddsPropertySource() throws Exception {
void customizeContextAddsPropertySource() {
ConfigurableApplicationContext context = new StaticApplicationContext();
DynamicPropertiesContextCustomizer customizer = customizerFor("valid1", "valid2");
customizer.customizeContext(context, mock());

View File

@ -30,19 +30,18 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
class DynamicValuesPropertySourceTests {
@SuppressWarnings("serial")
private final DynamicValuesPropertySource source = new DynamicValuesPropertySource("test",
Map.of("a", () -> "A", "b", () -> "B"));
@Test
void getPropertyReturnsSuppliedProperty() throws Exception {
void getPropertyReturnsSuppliedProperty() {
assertThat(this.source.getProperty("a")).isEqualTo("A");
assertThat(this.source.getProperty("b")).isEqualTo("B");
}
@Test
void getPropertyWhenMissingReturnsNull() throws Exception {
void getPropertyWhenMissingReturnsNull() {
assertThat(this.source.getProperty("c")).isNull();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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 GenericXmlContextLoaderResourceLocationsTests {
@ParameterizedTest(name = "[{index}] {0}")
@MethodSource("contextConfigurationLocationsData")
void assertContextConfigurationLocations(Class<?> testClass, String[] expectedLocations) throws Exception {
void assertContextConfigurationLocations(Class<?> testClass, String[] expectedLocations) {
ContextConfiguration contextConfig = testClass.getAnnotation(ContextConfiguration.class);
String[] configuredLocations = contextConfig.value();
ContextConfigurationAttributes configAttributes =

View File

@ -35,7 +35,7 @@ class GenericXmlContextLoaderTests {
@Test
void configMustNotContainAnnotatedClasses() throws Exception {
void configMustNotContainAnnotatedClasses() {
GenericXmlContextLoader loader = new GenericXmlContextLoader();
MergedContextConfiguration mergedConfig = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY,
new Class<?>[] { getClass() }, EMPTY_STRING_ARRAY, loader);

View File

@ -184,7 +184,7 @@ class TestPropertySourceUtilsTests {
@Test
void addPropertiesFilesToEnvironmentWithNullContext() {
assertThatIllegalArgumentException()
.isThrownBy(() -> addPropertiesFilesToEnvironment((ConfigurableApplicationContext) null, FOO_LOCATIONS))
.isThrownBy(() -> addPropertiesFilesToEnvironment(null, FOO_LOCATIONS))
.withMessageContaining("'context' must not be null");
}
@ -198,7 +198,7 @@ class TestPropertySourceUtilsTests {
@Test
void addPropertiesFilesToEnvironmentWithNullEnvironment() {
assertThatIllegalArgumentException()
.isThrownBy(() -> addPropertiesFilesToEnvironment((ConfigurableEnvironment) null, mock(), FOO_LOCATIONS))
.isThrownBy(() -> addPropertiesFilesToEnvironment(null, mock(), FOO_LOCATIONS))
.withMessageContaining("'environment' must not be null");
}
@ -287,7 +287,6 @@ class TestPropertySourceUtilsTests {
}
@Test
@SuppressWarnings("rawtypes")
void addInlinedPropertiesToEnvironmentWithEmptyProperty() {
ConfigurableEnvironment environment = new MockEnvironment();
MutablePropertySources propertySources = environment.getPropertySources();
@ -296,8 +295,8 @@ class TestPropertySourceUtilsTests {
addInlinedPropertiesToEnvironment(environment, " ");
assertThat(propertySources).hasSize(1);
PropertySource<?> propertySource = propertySources.get(INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
assertThat(propertySource).isInstanceOf(MapPropertySource.class);
assertThat(((MapPropertySource) propertySource).getSource()).isEmpty();
assertThat(propertySource).isInstanceOfSatisfying(MapPropertySource.class,
mps -> assertThat(mps.getSource()).isEmpty());
}
@Test

View File

@ -127,7 +127,7 @@ class AnnotationConfigTransactionalTestNGSpringContextTests
}
@BeforeMethod
void setUp() throws Exception {
void setUp() {
numSetUpCalls++;
if (isActualTransactionActive()) {
numSetUpCallsInTransaction++;
@ -144,7 +144,7 @@ class AnnotationConfigTransactionalTestNGSpringContextTests
}
@AfterMethod
void tearDown() throws Exception {
void tearDown() {
numTearDownCalls++;
if (isActualTransactionActive()) {
numTearDownCallsInTransaction++;

View File

@ -32,7 +32,7 @@ class GenericXmlWebContextLoaderTests {
@Test
void configMustNotContainAnnotatedClasses() throws Exception {
void configMustNotContainAnnotatedClasses() {
GenericXmlWebContextLoader loader = new GenericXmlWebContextLoader();
@SuppressWarnings("deprecation")
WebMergedContextConfiguration mergedConfig = new WebMergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY,

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 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.
@ -48,7 +48,7 @@ class RequestAndSessionScopedBeansWacTests {
@Test
void requestScope() throws Exception {
void requestScope() {
String beanName = "requestScopedTestBean";
String contextPath = "/path";
@ -63,7 +63,7 @@ class RequestAndSessionScopedBeansWacTests {
}
@Test
void sessionScope() throws Exception {
void sessionScope() {
String beanName = "sessionScopedTestBean";
assertThat(session.getAttribute(beanName)).isNull();

View File

@ -56,27 +56,27 @@ class JsonPathExpectationsHelperTests {
@Test
void exists() throws Exception {
void exists() {
new JsonPathExpectationsHelper("$.str").exists(CONTENT);
}
@Test
void existsForAnEmptyArray() throws Exception {
void existsForAnEmptyArray() {
new JsonPathExpectationsHelper("$.emptyArray").exists(CONTENT);
}
@Test
void existsForAnEmptyMap() throws Exception {
void existsForAnEmptyMap() {
new JsonPathExpectationsHelper("$.emptyMap").exists(CONTENT);
}
@Test
void existsForIndefinitePathWithResults() throws Exception {
void existsForIndefinitePathWithResults() {
new JsonPathExpectationsHelper("$.familyMembers[?(@.name == 'Bart')]").exists(SIMPSONS);
}
@Test
void existsForIndefinitePathWithEmptyResults() throws Exception {
void existsForIndefinitePathWithEmptyResults() {
String expression = "$.familyMembers[?(@.name == 'Dilbert')]";
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathExpectationsHelper(expression).exists(SIMPSONS))
@ -84,12 +84,12 @@ class JsonPathExpectationsHelperTests {
}
@Test
void doesNotExist() throws Exception {
void doesNotExist() {
new JsonPathExpectationsHelper("$.bogus").doesNotExist(CONTENT);
}
@Test
void doesNotExistForAnEmptyArray() throws Exception {
void doesNotExistForAnEmptyArray() {
String expression = "$.emptyArray";
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathExpectationsHelper(expression).doesNotExist(CONTENT))
@ -97,7 +97,7 @@ class JsonPathExpectationsHelperTests {
}
@Test
void doesNotExistForAnEmptyMap() throws Exception {
void doesNotExistForAnEmptyMap() {
String expression = "$.emptyMap";
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathExpectationsHelper(expression).doesNotExist(CONTENT))
@ -105,7 +105,7 @@ class JsonPathExpectationsHelperTests {
}
@Test
void doesNotExistForIndefinitePathWithResults() throws Exception {
void doesNotExistForIndefinitePathWithResults() {
String expression = "$.familyMembers[?(@.name == 'Bart')]";
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathExpectationsHelper(expression).doesNotExist(SIMPSONS))
@ -113,32 +113,32 @@ class JsonPathExpectationsHelperTests {
}
@Test
void doesNotExistForIndefinitePathWithEmptyResults() throws Exception {
void doesNotExistForIndefinitePathWithEmptyResults() {
new JsonPathExpectationsHelper("$.familyMembers[?(@.name == 'Dilbert')]").doesNotExist(SIMPSONS);
}
@Test
void assertValueIsEmptyForAnEmptyString() throws Exception {
void assertValueIsEmptyForAnEmptyString() {
new JsonPathExpectationsHelper("$.emptyString").assertValueIsEmpty(CONTENT);
}
@Test
void assertValueIsEmptyForAnEmptyArray() throws Exception {
void assertValueIsEmptyForAnEmptyArray() {
new JsonPathExpectationsHelper("$.emptyArray").assertValueIsEmpty(CONTENT);
}
@Test
void assertValueIsEmptyForAnEmptyMap() throws Exception {
void assertValueIsEmptyForAnEmptyMap() {
new JsonPathExpectationsHelper("$.emptyMap").assertValueIsEmpty(CONTENT);
}
@Test
void assertValueIsEmptyForIndefinitePathWithEmptyResults() throws Exception {
void assertValueIsEmptyForIndefinitePathWithEmptyResults() {
new JsonPathExpectationsHelper("$.familyMembers[?(@.name == 'Dilbert')]").assertValueIsEmpty(SIMPSONS);
}
@Test
void assertValueIsEmptyForIndefinitePathWithResults() throws Exception {
void assertValueIsEmptyForIndefinitePathWithResults() {
String expression = "$.familyMembers[?(@.name == 'Bart')]";
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathExpectationsHelper(expression).assertValueIsEmpty(SIMPSONS))
@ -146,7 +146,7 @@ class JsonPathExpectationsHelperTests {
}
@Test
void assertValueIsEmptyForWhitespace() throws Exception {
void assertValueIsEmptyForWhitespace() {
String expression = "$.whitespace";
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathExpectationsHelper(expression).assertValueIsEmpty(CONTENT))
@ -154,37 +154,37 @@ class JsonPathExpectationsHelperTests {
}
@Test
void assertValueIsNotEmptyForString() throws Exception {
void assertValueIsNotEmptyForString() {
new JsonPathExpectationsHelper("$.str").assertValueIsNotEmpty(CONTENT);
}
@Test
void assertValueIsNotEmptyForNumber() throws Exception {
void assertValueIsNotEmptyForNumber() {
new JsonPathExpectationsHelper("$.num").assertValueIsNotEmpty(CONTENT);
}
@Test
void assertValueIsNotEmptyForBoolean() throws Exception {
void assertValueIsNotEmptyForBoolean() {
new JsonPathExpectationsHelper("$.bool").assertValueIsNotEmpty(CONTENT);
}
@Test
void assertValueIsNotEmptyForArray() throws Exception {
void assertValueIsNotEmptyForArray() {
new JsonPathExpectationsHelper("$.arr").assertValueIsNotEmpty(CONTENT);
}
@Test
void assertValueIsNotEmptyForMap() throws Exception {
void assertValueIsNotEmptyForMap() {
new JsonPathExpectationsHelper("$.colorMap").assertValueIsNotEmpty(CONTENT);
}
@Test
void assertValueIsNotEmptyForIndefinitePathWithResults() throws Exception {
void assertValueIsNotEmptyForIndefinitePathWithResults() {
new JsonPathExpectationsHelper("$.familyMembers[?(@.name == 'Bart')]").assertValueIsNotEmpty(SIMPSONS);
}
@Test
void assertValueIsNotEmptyForIndefinitePathWithEmptyResults() throws Exception {
void assertValueIsNotEmptyForIndefinitePathWithEmptyResults() {
String expression = "$.familyMembers[?(@.name == 'Dilbert')]";
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathExpectationsHelper(expression).assertValueIsNotEmpty(SIMPSONS))
@ -192,7 +192,7 @@ class JsonPathExpectationsHelperTests {
}
@Test
void assertValueIsNotEmptyForAnEmptyString() throws Exception {
void assertValueIsNotEmptyForAnEmptyString() {
String expression = "$.emptyString";
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathExpectationsHelper(expression).assertValueIsNotEmpty(CONTENT))
@ -200,7 +200,7 @@ class JsonPathExpectationsHelperTests {
}
@Test
void assertValueIsNotEmptyForAnEmptyArray() throws Exception {
void assertValueIsNotEmptyForAnEmptyArray() {
String expression = "$.emptyArray";
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathExpectationsHelper(expression).assertValueIsNotEmpty(CONTENT))
@ -208,7 +208,7 @@ class JsonPathExpectationsHelperTests {
}
@Test
void assertValueIsNotEmptyForAnEmptyMap() throws Exception {
void assertValueIsNotEmptyForAnEmptyMap() {
String expression = "$.emptyMap";
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathExpectationsHelper(expression).assertValueIsNotEmpty(CONTENT))
@ -263,32 +263,32 @@ class JsonPathExpectationsHelperTests {
}
@Test
void assertValue() throws Exception {
void assertValue() {
new JsonPathExpectationsHelper("$.num").assertValue(CONTENT, 5);
}
@Test // SPR-14498
void assertValueWithNumberConversion() throws Exception {
void assertValueWithNumberConversion() {
new JsonPathExpectationsHelper("$.num").assertValue(CONTENT, 5.0);
}
@Test // SPR-14498
void assertValueWithNumberConversionAndMatcher() throws Exception {
void assertValueWithNumberConversionAndMatcher() {
new JsonPathExpectationsHelper("$.num").assertValue(CONTENT, is(5.0), Double.class);
}
@Test
void assertValueIsString() throws Exception {
void assertValueIsString() {
new JsonPathExpectationsHelper("$.str").assertValueIsString(CONTENT);
}
@Test
void assertValueIsStringForAnEmptyString() throws Exception {
void assertValueIsStringForAnEmptyString() {
new JsonPathExpectationsHelper("$.emptyString").assertValueIsString(CONTENT);
}
@Test
void assertValueIsStringForNonString() throws Exception {
void assertValueIsStringForNonString() {
String expression = "$.bool";
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathExpectationsHelper(expression).assertValueIsString(CONTENT))
@ -296,12 +296,12 @@ class JsonPathExpectationsHelperTests {
}
@Test
void assertValueIsNumber() throws Exception {
void assertValueIsNumber() {
new JsonPathExpectationsHelper("$.num").assertValueIsNumber(CONTENT);
}
@Test
void assertValueIsNumberForNonNumber() throws Exception {
void assertValueIsNumberForNonNumber() {
String expression = "$.bool";
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathExpectationsHelper(expression).assertValueIsNumber(CONTENT))
@ -309,12 +309,12 @@ class JsonPathExpectationsHelperTests {
}
@Test
void assertValueIsBoolean() throws Exception {
void assertValueIsBoolean() {
new JsonPathExpectationsHelper("$.bool").assertValueIsBoolean(CONTENT);
}
@Test
void assertValueIsBooleanForNonBoolean() throws Exception {
void assertValueIsBooleanForNonBoolean() {
String expression = "$.num";
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathExpectationsHelper(expression).assertValueIsBoolean(CONTENT))
@ -322,17 +322,17 @@ class JsonPathExpectationsHelperTests {
}
@Test
void assertValueIsArray() throws Exception {
void assertValueIsArray() {
new JsonPathExpectationsHelper("$.arr").assertValueIsArray(CONTENT);
}
@Test
void assertValueIsArrayForAnEmptyArray() throws Exception {
void assertValueIsArrayForAnEmptyArray() {
new JsonPathExpectationsHelper("$.emptyArray").assertValueIsArray(CONTENT);
}
@Test
void assertValueIsArrayForNonArray() throws Exception {
void assertValueIsArrayForNonArray() {
String expression = "$.str";
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathExpectationsHelper(expression).assertValueIsArray(CONTENT))
@ -340,17 +340,17 @@ class JsonPathExpectationsHelperTests {
}
@Test
void assertValueIsMap() throws Exception {
void assertValueIsMap() {
new JsonPathExpectationsHelper("$.colorMap").assertValueIsMap(CONTENT);
}
@Test
void assertValueIsMapForAnEmptyMap() throws Exception {
void assertValueIsMapForAnEmptyMap() {
new JsonPathExpectationsHelper("$.emptyMap").assertValueIsMap(CONTENT);
}
@Test
void assertValueIsMapForNonMap() throws Exception {
void assertValueIsMapForNonMap() {
String expression = "$.str";
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathExpectationsHelper(expression).assertValueIsMap(CONTENT))

View File

@ -62,61 +62,61 @@ class ReflectionTestUtilsTests {
}
@Test
void setFieldWithNullTargetObject() throws Exception {
void setFieldWithNullTargetObject() {
assertThatIllegalArgumentException()
.isThrownBy(() -> setField((Object) null, "id", 99L))
.withMessageStartingWith("Either targetObject or targetClass");
}
@Test
void getFieldWithNullTargetObject() throws Exception {
void getFieldWithNullTargetObject() {
assertThatIllegalArgumentException()
.isThrownBy(() -> getField((Object) null, "id"))
.withMessageStartingWith("Either targetObject or targetClass");
}
@Test
void setFieldWithNullTargetClass() throws Exception {
void setFieldWithNullTargetClass() {
assertThatIllegalArgumentException()
.isThrownBy(() -> setField((Class<?>) null, "id", 99L))
.isThrownBy(() -> setField(null, "id", 99L))
.withMessageStartingWith("Either targetObject or targetClass");
}
@Test
void getFieldWithNullTargetClass() throws Exception {
void getFieldWithNullTargetClass() {
assertThatIllegalArgumentException()
.isThrownBy(() -> getField((Class<?>) null, "id"))
.isThrownBy(() -> getField(null, "id"))
.withMessageStartingWith("Either targetObject or targetClass");
}
@Test
void setFieldWithNullNameAndNullType() throws Exception {
void setFieldWithNullNameAndNullType() {
assertThatIllegalArgumentException()
.isThrownBy(() -> setField(person, null, 99L, null))
.withMessageStartingWith("Either name or type");
}
@Test
void setFieldWithBogusName() throws Exception {
void setFieldWithBogusName() {
assertThatIllegalArgumentException()
.isThrownBy(() -> setField(person, "bogus", 99L, long.class))
.withMessageStartingWith("Could not find field 'bogus'");
}
@Test
void setFieldWithWrongType() throws Exception {
void setFieldWithWrongType() {
assertThatIllegalArgumentException()
.isThrownBy(() -> setField(person, "id", 99L, String.class))
.withMessageStartingWith("Could not find field");
}
@Test
void setFieldAndGetFieldForStandardUseCases() throws Exception {
void setFieldAndGetFieldForStandardUseCases() {
assertSetFieldAndGetFieldBehavior(this.person);
}
@Test
void setFieldAndGetFieldViaJdkDynamicProxy() throws Exception {
void setFieldAndGetFieldViaJdkDynamicProxy() {
ProxyFactory pf = new ProxyFactory(this.person);
pf.addInterface(Person.class);
Person proxy = (Person) pf.getProxy();
@ -125,7 +125,7 @@ class ReflectionTestUtilsTests {
}
@Test
void setFieldAndGetFieldViaCglibProxy() throws Exception {
void setFieldAndGetFieldViaCglibProxy() {
ProxyFactory pf = new ProxyFactory(this.person);
pf.setProxyTargetClass(true);
Person proxy = (Person) pf.getProxy();
@ -172,7 +172,7 @@ class ReflectionTestUtilsTests {
}
@Test
void setFieldWithNullValuesForNonPrimitives() throws Exception {
void setFieldWithNullValuesForNonPrimitives() {
// Fields must be non-null to start with
setField(person, "name", "Tom");
setField(person, "eyeColor", "blue", String.class);
@ -192,22 +192,22 @@ class ReflectionTestUtilsTests {
}
@Test
void setFieldWithNullValueForPrimitiveLong() throws Exception {
void setFieldWithNullValueForPrimitiveLong() {
assertThatIllegalArgumentException().isThrownBy(() -> setField(person, "id", null, long.class));
}
@Test
void setFieldWithNullValueForPrimitiveInt() throws Exception {
void setFieldWithNullValueForPrimitiveInt() {
assertThatIllegalArgumentException().isThrownBy(() -> setField(person, "age", null, int.class));
}
@Test
void setFieldWithNullValueForPrimitiveBoolean() throws Exception {
void setFieldWithNullValueForPrimitiveBoolean() {
assertThatIllegalArgumentException().isThrownBy(() -> setField(person, "likesPets", null, boolean.class));
}
@Test
void setStaticFieldViaClass() throws Exception {
void setStaticFieldViaClass() {
setField(StaticFields.class, "publicField", "xxx");
setField(StaticFields.class, "privateField", "yyy");
@ -216,7 +216,7 @@ class ReflectionTestUtilsTests {
}
@Test
void setStaticFieldViaClassWithExplicitType() throws Exception {
void setStaticFieldViaClassWithExplicitType() {
setField(StaticFields.class, "publicField", "xxx", String.class);
setField(StaticFields.class, "privateField", "yyy", String.class);
@ -225,7 +225,7 @@ class ReflectionTestUtilsTests {
}
@Test
void setStaticFieldViaInstance() throws Exception {
void setStaticFieldViaInstance() {
StaticFields staticFields = new StaticFields();
setField(staticFields, null, "publicField", "xxx", null);
setField(staticFields, null, "privateField", "yyy", null);
@ -235,20 +235,20 @@ class ReflectionTestUtilsTests {
}
@Test
void getStaticFieldViaClass() throws Exception {
void getStaticFieldViaClass() {
assertThat(getField(StaticFields.class, "publicField")).as("public static field").isEqualTo("public");
assertThat(getField(StaticFields.class, "privateField")).as("private static field").isEqualTo("private");
}
@Test
void getStaticFieldViaInstance() throws Exception {
void getStaticFieldViaInstance() {
StaticFields staticFields = new StaticFields();
assertThat(getField(staticFields, "publicField")).as("public static field").isEqualTo("public");
assertThat(getField(staticFields, "privateField")).as("private static field").isEqualTo("private");
}
@Test
void invokeSetterMethodAndInvokeGetterMethodWithExplicitMethodNames() throws Exception {
void invokeSetterMethodAndInvokeGetterMethodWithExplicitMethodNames() {
invokeSetterMethod(person, "setId", 1L, long.class);
invokeSetterMethod(person, "setName", "Jerry", String.class);
invokeSetterMethod(person, "setAge", 33, int.class);
@ -272,7 +272,7 @@ class ReflectionTestUtilsTests {
}
@Test
void invokeSetterMethodAndInvokeGetterMethodWithJavaBeanPropertyNames() throws Exception {
void invokeSetterMethodAndInvokeGetterMethodWithJavaBeanPropertyNames() {
invokeSetterMethod(person, "id", 99L, long.class);
invokeSetterMethod(person, "name", "Tom");
invokeSetterMethod(person, "age", 42);
@ -296,7 +296,7 @@ class ReflectionTestUtilsTests {
}
@Test
void invokeSetterMethodWithNullValuesForNonPrimitives() throws Exception {
void invokeSetterMethodWithNullValuesForNonPrimitives() {
invokeSetterMethod(person, "name", null, String.class);
invokeSetterMethod(person, "eyeColor", null, String.class);
invokeSetterMethod(person, "favoriteNumber", null, Number.class);
@ -307,17 +307,17 @@ class ReflectionTestUtilsTests {
}
@Test
void invokeSetterMethodWithNullValueForPrimitiveLong() throws Exception {
void invokeSetterMethodWithNullValueForPrimitiveLong() {
assertThatIllegalArgumentException().isThrownBy(() -> invokeSetterMethod(person, "id", null, long.class));
}
@Test
void invokeSetterMethodWithNullValueForPrimitiveInt() throws Exception {
void invokeSetterMethodWithNullValueForPrimitiveInt() {
assertThatIllegalArgumentException().isThrownBy(() -> invokeSetterMethod(person, "age", null, int.class));
}
@Test
void invokeSetterMethodWithNullValueForPrimitiveBoolean() throws Exception {
void invokeSetterMethodWithNullValueForPrimitiveBoolean() {
assertThatIllegalArgumentException().isThrownBy(() -> invokeSetterMethod(person, "likesPets", null, boolean.class));
}
@ -338,7 +338,6 @@ class ReflectionTestUtilsTests {
@Test
void invokeMethodWithPrimitiveVarArgsAsSingleArgument() {
// IntelliJ IDEA 11 won't accept int assignment here
Integer sum = invokeMethod(component, "add", new int[] { 1, 2, 3, 4 });
assertThat(sum).as("add(1,2,3,4)").isEqualTo(10);
}
@ -427,7 +426,7 @@ class ReflectionTestUtilsTests {
@Test
void invokeStaticMethodWithNullTargetClass() {
assertThatIllegalArgumentException()
.isThrownBy(() -> invokeMethod((Class<?>) null, null))
.isThrownBy(() -> invokeMethod(null, null))
.withMessage("Target class must not be null");
}
@ -482,7 +481,7 @@ class ReflectionTestUtilsTests {
@Test
void invokeStaticMethodWithNullTargetObjectAndNullTargetClass() {
assertThatIllegalArgumentException()
.isThrownBy(() -> invokeMethod((Object) null, (Class<?>) null, "id"))
.isThrownBy(() -> invokeMethod(null, (Class<?>) null, "id"))
.withMessage("Either 'targetObject' or 'targetClass' for the method must be specified");
}

View File

@ -36,7 +36,7 @@ class XmlExpectationsHelperTests {
}
@Test
void assertXmlEqualExceptionForIncorrectValue() throws Exception {
void assertXmlEqualExceptionForIncorrectValue() {
String control = "<root><field1>f1</field1><field2>f2</field2></root>";
String test = "<root><field1>notf1</field1><field2>f2</field2></root>";
XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper();
@ -54,7 +54,7 @@ class XmlExpectationsHelperTests {
}
@Test
void assertXmlEqualExceptionForMoreEntries() throws Exception {
void assertXmlEqualExceptionForMoreEntries() {
String control = "<root><field1>f1</field1><field2>f2</field2></root>";
String test = "<root><field1>f1</field1><field2>f2</field2><field3>f3</field3></root>";
XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper();
@ -65,7 +65,7 @@ class XmlExpectationsHelperTests {
}
@Test
void assertXmlEqualExceptionForLessEntries() throws Exception {
void assertXmlEqualExceptionForLessEntries() {
String control = "<root><field1>f1</field1><field2>f2</field2><field3>f3</field3></root>";
String test = "<root><field1>f1</field1><field2>f2</field2></root>";
XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper();

View File

@ -48,7 +48,7 @@ class SimpleRequestExpectationManagerTests {
@Test
void unexpectedRequest() throws Exception {
void unexpectedRequest() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> this.manager.validateRequest(createRequest(GET, "/foo")))
.withMessage("""
@ -58,7 +58,7 @@ class SimpleRequestExpectationManagerTests {
}
@Test
void zeroExpectedRequests() throws Exception {
void zeroExpectedRequests() {
this.manager.verify();
}
@ -94,7 +94,7 @@ class SimpleRequestExpectationManagerTests {
this.manager.expectRequest(min(1), requestTo("/bar")).andExpect(method(GET)).andRespond(withSuccess());
this.manager.validateRequest(createRequest(GET, "/foo"));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> this.manager.verify())
.isThrownBy(this.manager::verify)
.withMessage("""
Further request(s) expected leaving 1 unsatisfied expectation(s).
1 request(s) executed:
@ -144,7 +144,7 @@ class SimpleRequestExpectationManagerTests {
this.manager.validateRequest(createRequest(GET, "/bar"));
this.manager.validateRequest(createRequest(GET, "/foo"));
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> this.manager.verify())
.isThrownBy(this.manager::verify)
.withMessageContaining("""
3 request(s) executed:
GET /foo
@ -154,7 +154,7 @@ class SimpleRequestExpectationManagerTests {
}
@Test
void repeatedRequestsNotInOrder() throws Exception {
void repeatedRequestsNotInOrder() {
this.manager.expectRequest(twice(), requestTo("/foo")).andExpect(method(GET)).andRespond(withSuccess());
this.manager.expectRequest(twice(), requestTo("/bar")).andExpect(method(GET)).andRespond(withSuccess());
this.manager.expectRequest(twice(), requestTo("/baz")).andExpect(method(GET)).andRespond(withSuccess());

View File

@ -49,7 +49,7 @@ public class ContentRequestMatchersTests {
}
@Test
public void testContentTypeNoMatch1() throws Exception {
public void testContentTypeNoMatch1() {
this.request.getHeaders().setContentType(MediaType.APPLICATION_JSON);
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
@ -57,7 +57,7 @@ public class ContentRequestMatchersTests {
}
@Test
public void testContentTypeNoMatch2() throws Exception {
public void testContentTypeNoMatch2() {
this.request.getHeaders().setContentType(MediaType.APPLICATION_JSON);
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->

View File

@ -58,7 +58,7 @@ public class JsonPathRequestMatchersTests {
@Test
public void valueWithMismatch() throws Exception {
public void valueWithMismatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathRequestMatchers("$.str").value("bogus").match(request));
}
@ -84,7 +84,7 @@ public class JsonPathRequestMatchersTests {
}
@Test
public void valueWithMatcherAndMismatch() throws Exception {
public void valueWithMatcherAndMismatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathRequestMatchers("$.str").value(equalTo("bogus")).match(request));
}
@ -105,7 +105,7 @@ public class JsonPathRequestMatchersTests {
}
@Test
public void existsNoMatch() throws Exception {
public void existsNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathRequestMatchers("$.bogus").exists().match(request));
}
@ -116,19 +116,19 @@ public class JsonPathRequestMatchersTests {
}
@Test
public void doesNotExistNoMatch() throws Exception {
public void doesNotExistNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathRequestMatchers("$.str").doesNotExist().match(request));
}
@Test
public void doesNotExistForAnEmptyArray() throws Exception {
public void doesNotExistForAnEmptyArray() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathRequestMatchers("$.emptyArray").doesNotExist().match(request));
}
@Test
public void doesNotExistForAnEmptyMap() throws Exception {
public void doesNotExistForAnEmptyMap() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathRequestMatchers("$.emptyMap").doesNotExist().match(request));
}
@ -174,19 +174,19 @@ public class JsonPathRequestMatchersTests {
}
@Test
public void isNotEmptyForAnEmptyString() throws Exception {
public void isNotEmptyForAnEmptyString() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathRequestMatchers("$.emptyString").isNotEmpty().match(request));
}
@Test
public void isNotEmptyForAnEmptyArray() throws Exception {
public void isNotEmptyForAnEmptyArray() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathRequestMatchers("$.emptyArray").isNotEmpty().match(request));
}
@Test
public void isNotEmptyForAnEmptyMap() throws Exception {
public void isNotEmptyForAnEmptyMap() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathRequestMatchers("$.emptyMap").isNotEmpty().match(request));
}
@ -202,7 +202,7 @@ public class JsonPathRequestMatchersTests {
}
@Test
public void isArrayNoMatch() throws Exception {
public void isArrayNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathRequestMatchers("$.str").isArray().match(request));
}
@ -218,7 +218,7 @@ public class JsonPathRequestMatchersTests {
}
@Test
public void isMapNoMatch() throws Exception {
public void isMapNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathRequestMatchers("$.str").isMap().match(request));
}
@ -229,7 +229,7 @@ public class JsonPathRequestMatchersTests {
}
@Test
public void isBooleanNoMatch() throws Exception {
public void isBooleanNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathRequestMatchers("$.str").isBoolean().match(request));
}
@ -240,7 +240,7 @@ public class JsonPathRequestMatchersTests {
}
@Test
public void isNumberNoMatch() throws Exception {
public void isNumberNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathRequestMatchers("$.str").isNumber().match(request));
}
@ -251,7 +251,7 @@ public class JsonPathRequestMatchersTests {
}
@Test
public void isStringNoMatch() throws Exception {
public void isStringNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathRequestMatchers("$.arr").isString().match(request));
}

View File

@ -51,7 +51,7 @@ public class XpathRequestMatchersTests {
}
@Test
public void testNodeMatcherNoMatch() throws Exception {
public void testNodeMatcherNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new XpathRequestMatchers("/foo/bar", null).node(Matchers.nullValue()).match(this.request));
}
@ -62,7 +62,7 @@ public class XpathRequestMatchersTests {
}
@Test
public void testExistsNoMatch() throws Exception {
public void testExistsNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new XpathRequestMatchers("/foo/Bar", null).exists().match(this.request));
}
@ -73,7 +73,7 @@ public class XpathRequestMatchersTests {
}
@Test
public void testDoesNotExistNoMatch() throws Exception {
public void testDoesNotExistNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new XpathRequestMatchers("/foo/bar", null).doesNotExist().match(this.request));
}
@ -84,7 +84,7 @@ public class XpathRequestMatchersTests {
}
@Test
public void testNodeCountNoMatch() throws Exception {
public void testNodeCountNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new XpathRequestMatchers("/foo/bar", null).nodeCount(1).match(this.request));
}
@ -95,7 +95,7 @@ public class XpathRequestMatchersTests {
}
@Test
public void testStringNoMatch() throws Exception {
public void testStringNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new XpathRequestMatchers("/foo/bar[1]", null).string("112").match(this.request));
}
@ -106,7 +106,7 @@ public class XpathRequestMatchersTests {
}
@Test
public void testNumberNoMatch() throws Exception {
public void testNumberNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new XpathRequestMatchers("/foo/bar[1]", null).number(111.1).match(this.request));
}
@ -117,7 +117,7 @@ public class XpathRequestMatchersTests {
}
@Test
public void testBooleanNoMatch() throws Exception {
public void testBooleanNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new XpathRequestMatchers("/foo/bar[2]", null).booleanValue(false).match(this.request));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.test.web.client.samples.matchers;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -190,7 +189,7 @@ public class XpathRequestMatchersIntegrationTests {
executeAndVerify();
}
private void executeAndVerify() throws URISyntaxException {
private void executeAndVerify() {
this.restTemplate.put(URI.create("/composers"), this.people);
this.mockServer.verify();
}

View File

@ -93,8 +93,7 @@ class StatusAssertionTests {
assertions.is1xxInformational();
// Wrong series
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
assertions.is2xxSuccessful());
assertThatExceptionOfType(AssertionError.class).isThrownBy(assertions::is2xxSuccessful);
}
@Test
@ -105,8 +104,7 @@ class StatusAssertionTests {
assertions.is2xxSuccessful();
// Wrong series
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
assertions.is5xxServerError());
assertThatExceptionOfType(AssertionError.class).isThrownBy(assertions::is5xxServerError);
}
@Test
@ -117,8 +115,7 @@ class StatusAssertionTests {
assertions.is3xxRedirection();
// Wrong series
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
assertions.is2xxSuccessful());
assertThatExceptionOfType(AssertionError.class).isThrownBy(assertions::is2xxSuccessful);
}
@Test
@ -129,8 +126,7 @@ class StatusAssertionTests {
assertions.is4xxClientError();
// Wrong series
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
assertions.is2xxSuccessful());
assertThatExceptionOfType(AssertionError.class).isThrownBy(assertions::is2xxSuccessful);
}
@Test
@ -141,8 +137,7 @@ class StatusAssertionTests {
assertions.is5xxServerError();
// Wrong series
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
assertions.is2xxSuccessful());
assertThatExceptionOfType(AssertionError.class).isThrownBy(assertions::is2xxSuccessful);
}
@Test

View File

@ -439,7 +439,7 @@ public class HtmlUnitRequestBuilderTests {
}
@Test
void buildRequestPathInfo() throws Exception {
void buildRequestPathInfo() {
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
assertThat(actualRequest.getPathInfo()).isNull();
@ -466,7 +466,7 @@ public class HtmlUnitRequestBuilderTests {
}
@Test
void buildRequestProtocol() throws Exception {
void buildRequestProtocol() {
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
assertThat(actualRequest.getProtocol()).isEqualTo("HTTP/1.1");
@ -534,14 +534,14 @@ public class HtmlUnitRequestBuilderTests {
}
@Test
void buildRequestRemoteAddr() throws Exception {
void buildRequestRemoteAddr() {
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
assertThat(actualRequest.getRemoteAddr()).isEqualTo("127.0.0.1");
}
@Test
void buildRequestRemoteHost() throws Exception {
void buildRequestRemoteHost() {
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
assertThat(actualRequest.getRemoteAddr()).isEqualTo("127.0.0.1");
@ -574,7 +574,7 @@ public class HtmlUnitRequestBuilderTests {
}
@Test
void buildRequestRequestedSessionId() throws Exception {
void buildRequestRequestedSessionId() {
String sessionId = "session-id";
webRequest.setAdditionalHeader("Cookie", "JSESSIONID=" + sessionId);
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
@ -583,7 +583,7 @@ public class HtmlUnitRequestBuilderTests {
}
@Test
void buildRequestRequestedSessionIdNull() throws Exception {
void buildRequestRequestedSessionIdNull() {
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
assertThat(actualRequest.getRequestedSessionId()).isNull();
@ -618,7 +618,7 @@ public class HtmlUnitRequestBuilderTests {
}
@Test
void buildRequestServerName() throws Exception {
void buildRequestServerName() {
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
assertThat(actualRequest.getServerName()).isEqualTo("example.com");
@ -641,14 +641,14 @@ public class HtmlUnitRequestBuilderTests {
}
@Test
void buildRequestServletContext() throws Exception {
void buildRequestServletContext() {
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
assertThat(actualRequest.getServletContext()).isEqualTo(servletContext);
}
@Test
void buildRequestServletPath() throws Exception {
void buildRequestServletPath() {
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
assertThat(actualRequest.getServletPath()).isEqualTo("/this/here");
@ -665,7 +665,7 @@ public class HtmlUnitRequestBuilderTests {
}
@Test
void buildRequestSession() throws Exception {
void buildRequestSession() {
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
HttpSession newSession = actualRequest.getSession();
@ -682,7 +682,7 @@ public class HtmlUnitRequestBuilderTests {
}
@Test
void buildRequestSessionWithExistingSession() throws Exception {
void buildRequestSessionWithExistingSession() {
String sessionId = "session-id";
webRequest.setAdditionalHeader("Cookie", "JSESSIONID=" + sessionId);
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
@ -703,7 +703,7 @@ public class HtmlUnitRequestBuilderTests {
}
@Test
void buildRequestSessionTrue() throws Exception {
void buildRequestSessionTrue() {
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
HttpSession session = actualRequest.getSession(true);
@ -711,7 +711,7 @@ public class HtmlUnitRequestBuilderTests {
}
@Test
void buildRequestSessionFalseIsNull() throws Exception {
void buildRequestSessionFalseIsNull() {
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
HttpSession session = actualRequest.getSession(false);
@ -719,7 +719,7 @@ public class HtmlUnitRequestBuilderTests {
}
@Test
void buildRequestSessionFalseWithExistingSession() throws Exception {
void buildRequestSessionFalseWithExistingSession() {
String sessionId = "session-id";
webRequest.setAdditionalHeader("Cookie", "JSESSIONID=" + sessionId);
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
@ -729,14 +729,14 @@ public class HtmlUnitRequestBuilderTests {
}
@Test
void buildRequestSessionIsNew() throws Exception {
void buildRequestSessionIsNew() {
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
assertThat(actualRequest.getSession().isNew()).isTrue();
}
@Test
void buildRequestSessionIsNewFalse() throws Exception {
void buildRequestSessionIsNewFalse() {
String sessionId = "session-id";
webRequest.setAdditionalHeader("Cookie", "JSESSIONID=" + sessionId);
@ -746,7 +746,7 @@ public class HtmlUnitRequestBuilderTests {
}
@Test
void buildRequestSessionInvalidate() throws Exception {
void buildRequestSessionInvalidate() {
String sessionId = "session-id";
webRequest.setAdditionalHeader("Cookie", "JSESSIONID=" + sessionId);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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 @@ public class MockMvcWebConnectionTests {
}
@Test
public void contextPathEmpty() throws IOException {
public void contextPathEmpty() {
this.webClient.setWebConnection(new MockMvcWebConnection(this.mockMvc, this.webClient, ""));
// Empty context path (root context) should not match to a URL with a context path
assertThatExceptionOfType(FailingHttpStatusCodeException.class).isThrownBy(() ->
@ -89,15 +89,13 @@ public class MockMvcWebConnectionTests {
}
@Test
@SuppressWarnings("resource")
public void contextPathDoesNotStartWithSlash() throws IOException {
public void contextPathDoesNotStartWithSlash() {
assertThatIllegalArgumentException().isThrownBy(() ->
new MockMvcWebConnection(this.mockMvc, this.webClient, "context"));
}
@Test
@SuppressWarnings("resource")
public void contextPathEndsWithSlash() throws IOException {
public void contextPathEndsWithSlash() {
assertThatIllegalArgumentException().isThrownBy(() ->
new MockMvcWebConnection(this.mockMvc, this.webClient, "/context/"));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
@ -64,7 +64,7 @@ public class MockWebResponseBuilderTests {
}
@Test
public void constructorWithNullResponse() throws Exception {
public void constructorWithNullResponse() {
assertThatIllegalArgumentException().isThrownBy(() ->
new MockWebResponseBuilder(0L, new WebRequest(new URL("http://company.example:80/test/this/here")), null));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.test.web.servlet.htmlunit.webdriver;
import java.io.IOException;
import com.gargoylesoftware.htmlunit.util.Cookie;
import jakarta.servlet.http.HttpServletRequest;
import org.junit.jupiter.api.Test;
@ -68,7 +66,7 @@ class MockMvcHtmlUnitDriverBuilderTests {
}
@Test
void mockMvcSetupWithCustomDriverDelegate() throws Exception {
void mockMvcSetupWithCustomDriverDelegate() {
WebConnectionHtmlUnitDriver otherDriver = new WebConnectionHtmlUnitDriver();
this.driver = MockMvcHtmlUnitDriverBuilder.mockMvcSetup(this.mockMvc).withDelegate(otherDriver).build();
@ -76,7 +74,7 @@ class MockMvcHtmlUnitDriverBuilderTests {
}
@Test
void mockMvcSetupWithDefaultDriverDelegate() throws Exception {
void mockMvcSetupWithDefaultDriverDelegate() {
this.driver = MockMvcHtmlUnitDriverBuilder.mockMvcSetup(this.mockMvc).build();
assertMockMvcUsed("http://localhost/test");
@ -95,7 +93,7 @@ class MockMvcHtmlUnitDriverBuilderTests {
}
@Test // SPR-14066
void cookieManagerShared() throws Exception {
void cookieManagerShared() {
WebConnectionHtmlUnitDriver otherDriver = new WebConnectionHtmlUnitDriver();
this.mockMvc = MockMvcBuilders.standaloneSetup(new CookieController()).build();
this.driver = MockMvcHtmlUnitDriverBuilder.mockMvcSetup(this.mockMvc).withDelegate(otherDriver).build();
@ -107,11 +105,11 @@ class MockMvcHtmlUnitDriverBuilderTests {
}
private void assertMockMvcUsed(String url) throws Exception {
private void assertMockMvcUsed(String url) {
assertThat(get(url)).contains(EXPECTED_BODY);
}
private String get(String url) throws IOException {
private String get(String url) {
this.driver.get(url);
return this.driver.getPageSource();
}

View File

@ -18,7 +18,6 @@ package org.springframework.test.web.servlet.request;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.Principal;
import java.util.ArrayList;
import java.util.Arrays;
@ -96,7 +95,7 @@ class MockHttpServletRequestBuilderTests {
}
@Test // SPR-13435
void requestUriWithDoubleSlashes() throws URISyntaxException {
void requestUriWithDoubleSlashes() {
this.builder = new MockHttpServletRequestBuilder(GET, URI.create("/test//currentlyValid/0"));
MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);
@ -311,7 +310,7 @@ class MockHttpServletRequestBuilderTests {
}
@Test // SPR-13801
void requestParameterFromMultiValueMap() throws Exception {
void requestParameterFromMultiValueMap() {
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("foo", "bar");
params.add("foo", "baz");
@ -324,7 +323,7 @@ class MockHttpServletRequestBuilderTests {
}
@Test
void requestParameterFromRequestBodyFormData() throws Exception {
void requestParameterFromRequestBodyFormData() {
String contentType = "application/x-www-form-urlencoded;charset=UTF-8";
String body = "name+1=value+1&name+2=value+A&name+2=value+B&name+3";

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
@ -38,7 +38,7 @@ class ContentResultMatchersTests {
}
@Test
void typeNoMatch() throws Exception {
void typeNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new ContentResultMatchers().contentType("text/plain").match(getStubMvcResult(CONTENT)));
}
@ -49,7 +49,7 @@ class ContentResultMatchersTests {
}
@Test
void stringNoMatch() throws Exception {
void stringNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new ContentResultMatchers().encoding("bogus").match(getStubMvcResult(CONTENT)));
}
@ -61,7 +61,7 @@ class ContentResultMatchersTests {
}
@Test
void stringMatcherNoMatch() throws Exception {
void stringMatcherNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new ContentResultMatchers().string(Matchers.equalTo("bogus")).match(getStubMvcResult(CONTENT)));
}
@ -72,7 +72,7 @@ class ContentResultMatchersTests {
}
@Test
void bytesNoMatch() throws Exception {
void bytesNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new ContentResultMatchers().bytes("bogus".getBytes()).match(getStubMvcResult(CONTENT)));
}
@ -90,13 +90,13 @@ class ContentResultMatchersTests {
}
@Test
void jsonLenientNoMatch() throws Exception {
void jsonLenientNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new ContentResultMatchers().json("{\n\"fooo\":\"bar\"\n}").match(getStubMvcResult(CONTENT)));
}
@Test
void jsonStrictNoMatch() throws Exception {
void jsonStrictNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new ContentResultMatchers().json("{\"foo\":\"bar\", \"foo array\":[\"bar\",\"foo\"]}", true).match(getStubMvcResult(CONTENT)));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 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 FlashAttributeResultMatchersTests {
}
@Test
public void attributeExists_doesntExist() throws Exception {
public void attributeExists_doesntExist() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new FlashAttributeResultMatchers().attributeExists("bad").match(getStubMvcResult()));
}
@ -45,7 +45,7 @@ public class FlashAttributeResultMatchersTests {
}
@Test
public void attribute_incorrectValue() throws Exception {
public void attribute_incorrectValue() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new FlashAttributeResultMatchers().attribute("good", "not good").match(getStubMvcResult()));
}
@ -53,8 +53,7 @@ public class FlashAttributeResultMatchersTests {
private StubMvcResult getStubMvcResult() {
FlashMap flashMap = new FlashMap();
flashMap.put("good", "good");
StubMvcResult mvcResult = new StubMvcResult(null, null, null, null, null, flashMap, null);
return mvcResult;
return new StubMvcResult(null, null, null, null, null, flashMap, null);
}
}

View File

@ -66,14 +66,14 @@ class JsonPathResultMatchersTests {
@Test
void valueWithValueMismatch() throws Exception {
void valueWithValueMismatch() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> new JsonPathResultMatchers("$.str").value("bogus").match(stubMvcResult))
.withMessage("JSON path \"$.str\" expected:<bogus> but was:<foo>");
}
@Test
void valueWithTypeMismatch() throws Exception {
void valueWithTypeMismatch() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> new JsonPathResultMatchers("$.str").value("bogus".getBytes()).match(stubMvcResult))
.withMessage("At JSON path \"$.str\", value <foo> of type <java.lang.String> cannot be converted to type <byte[]>");
@ -105,7 +105,7 @@ class JsonPathResultMatchersTests {
}
@Test
void valueWithMatcherAndMismatch() throws Exception {
void valueWithMatcherAndMismatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathResultMatchers("$.str").value(Matchers.equalTo("bogus")).match(stubMvcResult));
}
@ -126,7 +126,7 @@ class JsonPathResultMatchersTests {
}
@Test
void existsNoMatch() throws Exception {
void existsNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathResultMatchers("$.bogus").exists().match(stubMvcResult));
}
@ -137,19 +137,19 @@ class JsonPathResultMatchersTests {
}
@Test
void doesNotExistNoMatch() throws Exception {
void doesNotExistNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathResultMatchers("$.str").doesNotExist().match(stubMvcResult));
}
@Test
void doesNotExistForAnEmptyArray() throws Exception {
void doesNotExistForAnEmptyArray() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathResultMatchers("$.emptyArray").doesNotExist().match(stubMvcResult));
}
@Test
void doesNotExistForAnEmptyMap() throws Exception {
void doesNotExistForAnEmptyMap() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathResultMatchers("$.emptyMap").doesNotExist().match(stubMvcResult));
}
@ -195,19 +195,19 @@ class JsonPathResultMatchersTests {
}
@Test
void isNotEmptyForAnEmptyString() throws Exception {
void isNotEmptyForAnEmptyString() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathResultMatchers("$.emptyString").isNotEmpty().match(stubMvcResult));
}
@Test
void isNotEmptyForAnEmptyArray() throws Exception {
void isNotEmptyForAnEmptyArray() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathResultMatchers("$.emptyArray").isNotEmpty().match(stubMvcResult));
}
@Test
void isNotEmptyForAnEmptyMap() throws Exception {
void isNotEmptyForAnEmptyMap() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathResultMatchers("$.emptyMap").isNotEmpty().match(stubMvcResult));
}
@ -223,7 +223,7 @@ class JsonPathResultMatchersTests {
}
@Test
void isArrayNoMatch() throws Exception {
void isArrayNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathResultMatchers("$.bar").isArray().match(stubMvcResult));
}
@ -239,7 +239,7 @@ class JsonPathResultMatchersTests {
}
@Test
void isMapNoMatch() throws Exception {
void isMapNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathResultMatchers("$.str").isMap().match(stubMvcResult));
}
@ -250,7 +250,7 @@ class JsonPathResultMatchersTests {
}
@Test
void isBooleanNoMatch() throws Exception {
void isBooleanNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathResultMatchers("$.str").isBoolean().match(stubMvcResult));
}
@ -261,7 +261,7 @@ class JsonPathResultMatchersTests {
}
@Test
void isNumberNoMatch() throws Exception {
void isNumberNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathResultMatchers("$.str").isNumber().match(stubMvcResult));
}
@ -272,7 +272,7 @@ class JsonPathResultMatchersTests {
}
@Test
void isStringNoMatch() throws Exception {
void isStringNoMatch() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
new JsonPathResultMatchers("$.arr").isString().match(stubMvcResult));
}

View File

@ -45,33 +45,33 @@ public class MockMvcResultMatchersTests {
}
@Test
public void redirectNonMatching() throws Exception {
public void redirectNonMatching() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> redirectedUrl("/resource/2").match(redirectedUrlStub("/resource/1")))
.withMessageEndingWith("expected:</resource/2> but was:</resource/1>");
}
@Test
public void redirectNonMatchingBecauseNotRedirect() throws Exception {
public void redirectNonMatchingBecauseNotRedirect() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> redirectedUrl("/resource/1").match(forwardedUrlStub("/resource/1")))
.withMessageEndingWith("expected:</resource/1> but was:<null>");
}
@Test
public void redirectWithUrlTemplate() throws Exception {
public void redirectWithUrlTemplate() {
assertThatCode(() -> redirectedUrlTemplate("/orders/{orderId}/items/{itemId}", 1, 2).match(redirectedUrlStub("/orders/1/items/2")))
.doesNotThrowAnyException();
}
@Test
public void redirectWithMatchingPattern() throws Exception {
public void redirectWithMatchingPattern() {
assertThatCode(() -> redirectedUrlPattern("/resource/*").match(redirectedUrlStub("/resource/1")))
.doesNotThrowAnyException();
}
@Test
public void redirectWithNonMatchingPattern() throws Exception {
public void redirectWithNonMatchingPattern() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> redirectedUrlPattern("/resource/").match(redirectedUrlStub("/resource/1")))
.withMessage("'/resource/' is not an Ant-style path pattern");
@ -105,25 +105,25 @@ public class MockMvcResultMatchersTests {
}
@Test
public void forwardWithQueryString() throws Exception {
public void forwardWithQueryString() {
assertThatCode(() -> forwardedUrl("/api/resource/1?arg=value").match(forwardedUrlStub("/api/resource/1?arg=value")))
.doesNotThrowAnyException();
}
@Test
public void forwardWithUrlTemplate() throws Exception {
public void forwardWithUrlTemplate() {
assertThatCode(() -> forwardedUrlTemplate("/orders/{orderId}/items/{itemId}", 1, 2).match(forwardedUrlStub("/orders/1/items/2")))
.doesNotThrowAnyException();
}
@Test
public void forwardWithMatchingPattern() throws Exception {
public void forwardWithMatchingPattern() {
assertThatCode(() -> forwardedUrlPattern("/api/**/?").match(forwardedUrlStub("/api/resource/1")))
.doesNotThrowAnyException();
}
@Test
public void forwardWithNonMatchingPattern() throws Exception {
public void forwardWithNonMatchingPattern() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> forwardedUrlPattern("/resource/").match(forwardedUrlStub("/resource/1")))
.withMessage("'/resource/' is not an Ant-style path pattern");

View File

@ -45,7 +45,7 @@ class ModelResultMatchersTests {
@BeforeEach
void setUp() throws Exception {
void setUp() {
ModelAndView mav = new ModelAndView("view", "good", "good");
BindingResult bindingResult = new BeanPropertyBindingResult("good", "good");
mav.addObject(BindingResult.MODEL_KEY_PREFIX + "good", bindingResult);
@ -69,7 +69,7 @@ class ModelResultMatchersTests {
}
@Test
void attributeExists_doesNotExist() throws Exception {
void attributeExists_doesNotExist() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.matchers.attributeExists("bad").match(this.mvcResult));
}
@ -80,7 +80,7 @@ class ModelResultMatchersTests {
}
@Test
void attributeDoesNotExist_doesExist() throws Exception {
void attributeDoesNotExist_doesExist() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.matchers.attributeDoesNotExist("good").match(this.mvcResultWithError));
}
@ -91,7 +91,7 @@ class ModelResultMatchersTests {
}
@Test
void attribute_notEqual() throws Exception {
void attribute_notEqual() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.matchers.attribute("good", is("bad")).match(this.mvcResult));
}
@ -102,7 +102,7 @@ class ModelResultMatchersTests {
}
@Test
void hasNoErrors_withErrors() throws Exception {
void hasNoErrors_withErrors() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.matchers.hasNoErrors().match(this.mvcResultWithError));
}
@ -118,14 +118,14 @@ class ModelResultMatchersTests {
}
@Test
void attributeErrorCount_withWrongErrorCount() throws Exception {
void attributeErrorCount_withWrongErrorCount() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> this.matchers.attributeErrorCount("date", 2).match(this.mvcResultWithError))
.withMessage("Binding/validation error count for attribute 'date', expected:<2> but was:<1>");
}
@Test
void attributeHasErrors_withoutErrors() throws Exception {
void attributeHasErrors_withoutErrors() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.matchers.attributeHasErrors("good").match(this.mvcResultWithError));
}
@ -136,13 +136,13 @@ class ModelResultMatchersTests {
}
@Test
void attributeHasNoErrors_withoutAttribute() throws Exception {
void attributeHasNoErrors_withoutAttribute() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.matchers.attributeHasNoErrors("missing").match(this.mvcResultWithError));
}
@Test
void attributeHasNoErrors_withErrors() throws Exception {
void attributeHasNoErrors_withErrors() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.matchers.attributeHasNoErrors("date").match(this.mvcResultWithError));
}
@ -153,19 +153,19 @@ class ModelResultMatchersTests {
}
@Test
void attributeHasFieldErrors_withoutAttribute() throws Exception {
void attributeHasFieldErrors_withoutAttribute() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.matchers.attributeHasFieldErrors("missing", "bad").match(this.mvcResult));
}
@Test
void attributeHasFieldErrors_withoutErrorsForAttribute() throws Exception {
void attributeHasFieldErrors_withoutErrorsForAttribute() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.matchers.attributeHasFieldErrors("date", "time").match(this.mvcResult));
}
@Test
void attributeHasFieldErrors_withoutErrorsForField() throws Exception {
void attributeHasFieldErrors_withoutErrorsForField() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.matchers.attributeHasFieldErrors("date", "good", "time").match(this.mvcResultWithError));
}
@ -176,7 +176,7 @@ class ModelResultMatchersTests {
}
@Test
void attributeHasFieldErrorCode_withoutErrorOnField() throws Exception {
void attributeHasFieldErrorCode_withoutErrorOnField() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.matchers.attributeHasFieldErrorCode("date", "time", "incorrectError").match(this.mvcResultWithError));
}
@ -187,7 +187,7 @@ class ModelResultMatchersTests {
}
@Test
void attributeHasFieldErrorCode_startsWith_withoutErrorOnField() throws Exception {
void attributeHasFieldErrorCode_startsWith_withoutErrorOnField() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.matchers.attributeHasFieldErrorCode("date", "time", startsWith("inc")).match(this.mvcResultWithError));
}

View File

@ -145,7 +145,6 @@ class PrintingResultHandlerTests {
}
@Test
@SuppressWarnings("removal")
void printResponse() throws Exception {
Cookie enigmaCookie = new Cookie("enigma", "42");
enigmaCookie.setHttpOnly(true);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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 AsyncTests {
}
@Test
void completableFutureWithImmediateValue() throws Exception {
void completableFutureWithImmediateValue() {
this.testClient.get()
.uri("/1?completableFutureWithImmediateValue=true")
.exchange()

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 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.
@ -197,7 +197,7 @@ public class FilterTests {
}
}
private class ContinueFilter extends OncePerRequestFilter {
private static class ContinueFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request,
@ -235,11 +235,11 @@ public class FilterTests {
}
}
private class RedirectFilter extends OncePerRequestFilter {
private static class RedirectFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
FilterChain filterChain) throws ServletException, IOException {
FilterChain filterChain) throws IOException {
response.sendRedirect("/login");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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 @@ public class MultipartControllerTests {
@Test
public void multipartRequestWithSingleFile() throws Exception {
public void multipartRequestWithSingleFile() {
byte[] fileContent = "bar".getBytes(StandardCharsets.UTF_8);
Map<String, String> json = Collections.singletonMap("name", "yeeeah");
@ -88,7 +88,7 @@ public class MultipartControllerTests {
}
@Test
public void multipartRequestWithFileArray() throws Exception {
public void multipartRequestWithFileArray() {
byte[] fileContent = "bar".getBytes(StandardCharsets.UTF_8);
Map<String, String> json = Collections.singletonMap("name", "yeeeah");
@ -112,7 +112,7 @@ public class MultipartControllerTests {
}
@Test
public void multipartRequestWithOptionalFile() throws Exception {
public void multipartRequestWithOptionalFile() {
byte[] fileContent = "bar".getBytes(StandardCharsets.UTF_8);
Map<String, String> json = Collections.singletonMap("name", "yeeeah");
@ -128,7 +128,7 @@ public class MultipartControllerTests {
}
@Test
public void multipartRequestWithOptionalFileNotPresent() throws Exception {
public void multipartRequestWithOptionalFileNotPresent() {
Map<String, String> json = Collections.singletonMap("name", "yeeeah");
MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();
@ -142,7 +142,7 @@ public class MultipartControllerTests {
}
@Test
public void multipartRequestWithOptionalFileArray() throws Exception {
public void multipartRequestWithOptionalFileArray() {
byte[] fileContent = "bar".getBytes(StandardCharsets.UTF_8);
Map<String, String> json = Collections.singletonMap("name", "yeeeah");
@ -159,7 +159,7 @@ public class MultipartControllerTests {
}
@Test
public void multipartRequestWithOptionalFileArrayNotPresent() throws Exception {
public void multipartRequestWithOptionalFileArrayNotPresent() {
Map<String, String> json = Collections.singletonMap("name", "yeeeah");
MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();
@ -173,7 +173,7 @@ public class MultipartControllerTests {
}
@Test
public void multipartRequestWithOptionalFileList() throws Exception {
public void multipartRequestWithOptionalFileList() {
byte[] fileContent = "bar".getBytes(StandardCharsets.UTF_8);
Map<String, String> json = Collections.singletonMap("name", "yeeeah");
@ -190,7 +190,7 @@ public class MultipartControllerTests {
}
@Test
public void multipartRequestWithOptionalFileListNotPresent() throws Exception {
public void multipartRequestWithOptionalFileListNotPresent() {
Map<String, String> json = Collections.singletonMap("name", "yeeeah");
MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();
@ -204,7 +204,7 @@ public class MultipartControllerTests {
}
@Test
public void multipartRequestWithServletParts() throws Exception {
public void multipartRequestWithServletParts() {
byte[] fileContent = "bar".getBytes(StandardCharsets.UTF_8);
Map<String, String> json = Collections.singletonMap("name", "yeeeah");
@ -220,7 +220,7 @@ public class MultipartControllerTests {
}
@Test
public void multipartRequestWrapped() throws Exception {
public void multipartRequestWrapped() {
Map<String, String> json = Collections.singletonMap("name", "yeeeah");
MultipartBodyBuilder bodyBuilder = new MultipartBodyBuilder();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 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,13 +50,12 @@ public class RequestParameterTests {
@Controller
private class PersonController {
private static class PersonController {
@RequestMapping(value="/search")
@ResponseBody
public Person get(@RequestParam String name) {
Person person = new Person(name);
return person;
return new Person(name);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
@ -136,7 +136,7 @@ class ContentAssertionTests {
@RequestMapping(path="/handleUtf8", produces="text/plain;charset=UTF-8")
@ResponseBody
String handleWithCharset() {
return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01"; // "Hello world! (Japanese)
return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01"; // "Hello world!" (Japanese)
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 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.
@ -131,7 +131,7 @@ public class JsonPathAssertionTests {
@RestController
private class MusicController {
private static class MusicController {
@RequestMapping("/music/people")
public MultiValueMap<String, Person> get() {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
@ -170,8 +170,8 @@ public class XpathAssertionTests {
private static class MusicController {
@RequestMapping(value = "/music/people")
public @ResponseBody
PeopleWrapper getPeople() {
@ResponseBody
public PeopleWrapper getPeople() {
List<Person> composers = Arrays.asList(
new Person("Johann Sebastian Bach").setSomeDouble(21),
@ -219,7 +219,7 @@ public class XpathAssertionTests {
@Controller
public class BlogFeedController {
public static class BlogFeedController {
@RequestMapping(value = "/blog.atom", method = {GET, HEAD})
@ResponseBody

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 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.
@ -174,7 +174,7 @@ public class FilterTests {
}
}
private class ContinueFilter extends OncePerRequestFilter {
private static class ContinueFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request,
@ -212,11 +212,11 @@ public class FilterTests {
}
}
private class RedirectFilter extends OncePerRequestFilter {
private static class RedirectFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
FilterChain filterChain) throws ServletException, IOException {
FilterChain filterChain) throws IOException {
response.sendRedirect("/login");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
@ -244,14 +244,14 @@ class MultipartControllerTests {
@PostMapping("/multipartfile")
public String processMultipartFile(@RequestParam(required = false) MultipartFile file,
@RequestPart(required = false) Map<String, String> json) throws IOException {
@RequestPart(required = false) Map<String, String> json) {
return "redirect:/index";
}
@PutMapping("/multipartfile-via-put")
public String processMultipartFileViaHttpPut(@RequestParam(required = false) MultipartFile file,
@RequestPart(required = false) Map<String, String> json) throws IOException {
@RequestPart(required = false) Map<String, String> json) {
return processMultipartFile(file, json);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 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,13 +50,12 @@ public class RequestParameterTests {
@Controller
private class PersonController {
private static class PersonController {
@RequestMapping(value="/search")
@ResponseBody
public Person get(@RequestParam String name) {
Person person = new Person(name);
return person;
return new Person(name);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
@ -121,7 +121,7 @@ public class ContentAssertionTests {
@GetMapping(path="/handleUtf8", produces="text/plain;charset=UTF-8")
String handleWithCharset() {
return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01"; // "Hello world! (Japanese)
return "\u3053\u3093\u306b\u3061\u306f\u4e16\u754c\uff01"; // "Hello world!" (Japanese)
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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 @@ public class CookieAssertionTests {
.addInterceptors(new LocaleChangeInterceptor())
.addInterceptors(new HandlerInterceptor() {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
response.addCookie(cookie);
return true;
}
@ -125,7 +125,7 @@ public class CookieAssertionTests {
}
@Test
void testSameSiteNotEquals() throws Exception {
void testSameSiteNotEquals() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.mockMvc.perform(get("/")).andExpect(cookie()
.sameSite(COOKIE_WITH_ATTRIBUTES_NAME, "Str")))

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2024 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 @@ public class FlashAttributeAssertionTests {
@Test
void attributeCountWithWrongCount() throws Exception {
void attributeCountWithWrongCount() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> this.mockMvc.perform(post("/persons")).andExpect(flash().attributeCount(1)))
.withMessage("FlashMap size expected:<1> but was:<3>");

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 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 @@ public class HandlerAssertionTests {
}
@Test
public void methodCallOnNonMock() throws Exception {
public void methodCallOnNonMock() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.mockMvc.perform(get("/")).andExpect(handler().methodCall("bogus")))
.withMessageContaining("The supplied object [bogus] is not an instance of")

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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.
@ -158,7 +158,7 @@ public class HeaderAssertionTests {
}
@Test
public void existsFail() throws Exception {
public void existsFail() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.mockMvc.perform(get("/persons/1")).andExpect(header().exists("X-Custom-Header")));
}
@ -169,13 +169,13 @@ public class HeaderAssertionTests {
}
@Test // SPR-10771
public void doesNotExistFail() throws Exception {
public void doesNotExistFail() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.mockMvc.perform(get("/persons/1")).andExpect(header().doesNotExist(LAST_MODIFIED)));
}
@Test
public void longValueWithIncorrectResponseHeaderValue() throws Exception {
public void longValueWithIncorrectResponseHeaderValue() {
assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
this.mockMvc.perform(get("/persons/1")).andExpect(header().longValue("X-Rate-Limiting", 1)));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 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.
@ -124,7 +124,7 @@ public class JsonPathAssertionTests {
@RestController
private class MusicController {
private static class MusicController {
@RequestMapping("/music/people")
public MultiValueMap<String, Person> get() {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 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.
@ -87,7 +87,8 @@ public class XmlContentAssertionTests {
private static class MusicController {
@RequestMapping(value="/music/people")
public @ResponseBody PeopleWrapper getPeople() {
@ResponseBody
public PeopleWrapper getPeople() {
List<Person> composers = Arrays.asList(
new Person("Johann Sebastian Bach").setSomeDouble(21),

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2024 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.
@ -171,7 +171,8 @@ public class XpathAssertionTests {
private static class MusicController {
@RequestMapping(value="/music/people")
public @ResponseBody PeopleWrapper getPeople() {
@ResponseBody
public PeopleWrapper getPeople() {
List<Person> composers = Arrays.asList(
new Person("Johann Sebastian Bach").setSomeDouble(21),
@ -219,7 +220,7 @@ public class XpathAssertionTests {
@Controller
public class BlogFeedController {
public static class BlogFeedController {
@RequestMapping(value="/blog.atom", method = { GET, HEAD })
@ResponseBody

View File

@ -22,7 +22,6 @@ import jakarta.servlet.DispatcherType;
import jakarta.servlet.Filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.FilterConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import org.junit.jupiter.api.BeforeEach;
@ -289,7 +288,7 @@ public class MockMvcFilterDecoratorTests {
private boolean destroy;
@Override
public void init(FilterConfig filterConfig) throws ServletException {
public void init(FilterConfig filterConfig) {
this.filterConfig = filterConfig;
}