Deprecate JUnit 4 support in the TestContext framework
Build and Deploy Snapshot / Build and Deploy Snapshot (push) Has been cancelled Details
Deploy Docs / Dispatch docs deployment (push) Has been cancelled Details
Build and Deploy Snapshot / Verify (push) Has been cancelled Details

Closes gh-34794
This commit is contained in:
Sam Brannen 2025-04-26 08:53:24 +02:00
parent 2db1a63a92
commit c74fc7ec90
61 changed files with 215 additions and 65 deletions

View File

@ -1,6 +1,13 @@
[[integration-testing-annotations-junit4]]
= Spring JUnit 4 Testing Annotations
[WARNING]
====
JUnit 4 support is deprecated since Spring Framework 7.0 in favor of the
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-extension[`SpringExtension`]
and JUnit Jupiter.
====
The following annotations are supported only when used in conjunction with the
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit4-runner[SpringRunner],
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit4-rules[Spring's JUnit 4 rules], or
@ -206,6 +213,3 @@ Kotlin::
----
<1> Repeat this test ten times.
======

View File

@ -483,6 +483,13 @@ Kotlin::
[[testcontext-junit4-runner]]
=== Spring JUnit 4 Runner
[WARNING]
====
JUnit 4 support is deprecated since Spring Framework 7.0 in favor of the
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-extension[`SpringExtension`]
and JUnit Jupiter.
====
The Spring TestContext Framework offers full integration with JUnit 4 through a custom
runner (supported on JUnit 4.12 or higher). By annotating test classes with
`@RunWith(SpringJUnit4ClassRunner.class)` or the shorter `@RunWith(SpringRunner.class)`
@ -538,6 +545,13 @@ be configured through `@ContextConfiguration`.
[[testcontext-junit4-rules]]
=== Spring JUnit 4 Rules
[WARNING]
====
JUnit 4 support is deprecated since Spring Framework 7.0 in favor of the
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-extension[`SpringExtension`]
and JUnit Jupiter.
====
The `org.springframework.test.context.junit4.rules` package provides the following JUnit
4 rules (supported on JUnit 4.12 or higher):
@ -607,6 +621,13 @@ Kotlin::
[[testcontext-support-classes-junit4]]
=== JUnit 4 Base Classes
[WARNING]
====
JUnit 4 support is deprecated since Spring Framework 7.0 in favor of the
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-extension[`SpringExtension`]
for JUnit Jupiter.
====
The `org.springframework.test.context.junit4` package provides the following support
classes for JUnit 4-based test cases (supported on JUnit 4.12 or higher):

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@ -94,11 +94,15 @@ import java.lang.annotation.Target;
* @see org.springframework.test.context.junit4.statements.ProfileValueChecker
* @see org.springframework.context.annotation.Profile
* @see org.springframework.test.context.ActiveProfiles
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@Deprecated(since = "7.0")
public @interface IfProfileValue {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2025 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.
@ -40,7 +40,11 @@ import org.jspecify.annotations.Nullable;
* @see ProfileValueSourceConfiguration
* @see IfProfileValue
* @see ProfileValueUtils
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Deprecated(since = "7.0")
public interface ProfileValueSource {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -37,11 +37,15 @@ import java.lang.annotation.Target;
* @see ProfileValueSource
* @see IfProfileValue
* @see ProfileValueUtils
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@Deprecated(since = "7.0")
public @interface ProfileValueSourceConfiguration {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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,9 @@ import org.springframework.util.StringUtils;
* @see ProfileValueSource
* @see ProfileValueSourceConfiguration
* @see IfProfileValue
* @deprecated since Spring Framework 7.0 with no replacement
*/
@Deprecated(since = "7.0")
public abstract class ProfileValueUtils {
private static final Log logger = LogFactory.getLog(ProfileValueUtils.class);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2025 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,10 +44,14 @@ import java.lang.annotation.Target;
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
* @see org.springframework.test.context.junit4.rules.SpringMethodRule
* @see org.springframework.test.context.junit4.statements.SpringRepeat
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Deprecated(since = "7.0")
public @interface Repeat {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@ -25,7 +25,11 @@ import org.springframework.util.Assert;
* @author Rod Johnson
* @author Sam Brannen
* @since 2.0
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Deprecated(since = "7.0")
public final class SystemProfileValueSource implements ProfileValueSource {
private static final SystemProfileValueSource INSTANCE = new SystemProfileValueSource();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2025 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.
@ -25,7 +25,10 @@ import org.springframework.core.annotation.AnnotatedElementUtils;
*
* @author Sam Brannen
* @since 4.2
* @see org.springframework.test.context.TestContextAnnotationUtils
* @deprecated since Spring Framework 7.0 with no replacement
*/
@Deprecated(since = "7.0")
public abstract class TestAnnotationUtils {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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,10 +43,14 @@ import java.lang.annotation.Target;
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
* @see org.springframework.test.context.junit4.rules.SpringMethodRule
* @see org.springframework.test.context.junit4.statements.SpringFailOnTimeout
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Deprecated(since = "7.0")
public @interface Timed {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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,8 +62,12 @@ import org.springframework.test.context.TestExecutionListeners;
* @see TestExecutionListeners
* @see AbstractTransactionalJUnit4SpringContextTests
* @see org.springframework.test.context.testng.AbstractTestNGSpringContextTests
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@RunWith(SpringRunner.class)
@Deprecated(since = "7.0")
public abstract class AbstractJUnit4SpringContextTests implements ApplicationContextAware {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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,8 +78,12 @@ import org.springframework.util.Assert;
* @see org.springframework.test.context.transaction.AfterTransaction
* @see org.springframework.test.jdbc.JdbcTestUtils
* @see org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Transactional
@Deprecated(since = "7.0")
public abstract class AbstractTransactionalJUnit4SpringContextTests extends AbstractJUnit4SpringContextTests {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2025 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.
@ -93,7 +93,11 @@ import org.springframework.util.ReflectionUtils;
* @see AbstractTransactionalJUnit4SpringContextTests
* @see org.springframework.test.context.junit4.rules.SpringClassRule
* @see org.springframework.test.context.junit4.rules.SpringMethodRule
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Deprecated(since = "7.0")
public class SpringJUnit4ClassRunner extends BlockJUnit4ClassRunner {
private static final Log logger = LogFactory.getLog(SpringJUnit4ClassRunner.class);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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,11 @@ import org.junit.runners.model.InitializationError;
* @see SpringJUnit4ClassRunner
* @see org.springframework.test.context.junit4.rules.SpringClassRule
* @see org.springframework.test.context.junit4.rules.SpringMethodRule
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Deprecated(since = "7.0")
public final class SpringRunner extends SpringJUnit4ClassRunner {
/**

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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.
@ -81,7 +81,11 @@ import org.springframework.util.Assert;
* @see SpringMethodRule
* @see org.springframework.test.context.TestContextManager
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Deprecated(since = "7.0")
public class SpringClassRule implements TestRule {
private static final Log logger = LogFactory.getLog(SpringClassRule.class);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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.
@ -95,7 +95,11 @@ import org.springframework.test.context.junit4.statements.SpringRepeat;
* @see SpringClassRule
* @see org.springframework.test.context.TestContextManager
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Deprecated(since = "7.0")
public class SpringMethodRule implements MethodRule {
private static final Log logger = LogFactory.getLog(SpringMethodRule.class);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -39,7 +39,11 @@ import org.springframework.util.Assert;
* @see #evaluate()
* @see IfProfileValue
* @see ProfileValueUtils
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Deprecated(since = "7.0")
public class ProfileValueChecker extends Statement {
private final Statement next;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2025 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,7 +36,11 @@ import org.springframework.test.context.TestContextManager;
* @since 3.0
* @see #evaluate()
* @see RunBeforeTestClassCallbacks
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Deprecated(since = "7.0")
public class RunAfterTestClassCallbacks extends Statement {
private final Statement next;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -37,7 +37,11 @@ import org.springframework.test.context.TestContextManager;
* @since 5.0
* @see #evaluate()
* @see RunBeforeTestExecutionCallbacks
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Deprecated(since = "7.0")
public class RunAfterTestExecutionCallbacks extends Statement {
private final Statement next;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -37,7 +37,11 @@ import org.springframework.test.context.TestContextManager;
* @since 3.0
* @see #evaluate()
* @see RunBeforeTestMethodCallbacks
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Deprecated(since = "7.0")
public class RunAfterTestMethodCallbacks extends Statement {
private final Statement next;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2025 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,11 @@ import org.springframework.test.context.TestContextManager;
* @since 3.0
* @see #evaluate()
* @see RunAfterTestMethodCallbacks
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Deprecated(since = "7.0")
public class RunBeforeTestClassCallbacks extends Statement {
private final Statement next;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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,11 @@ import org.springframework.test.context.TestContextManager;
* @since 5.0
* @see #evaluate()
* @see RunAfterTestExecutionCallbacks
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Deprecated(since = "7.0")
public class RunBeforeTestExecutionCallbacks extends Statement {
private final Statement next;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2025 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.
@ -32,7 +32,11 @@ import org.springframework.test.context.TestContextManager;
* @since 3.0
* @see #evaluate()
* @see RunAfterTestMethodCallbacks
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Deprecated(since = "7.0")
public class RunBeforeTestMethodCallbacks extends Statement {
private final Statement next;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2025 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.
@ -29,7 +29,11 @@ import org.springframework.test.context.TestContextManager;
* @author Sam Brannen
* @since 4.2
* @see #evaluate()
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Deprecated(since = "7.0")
public class RunPrepareTestInstanceCallbacks extends Statement {
private final Statement next;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2025 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,11 @@ import org.springframework.util.Assert;
* @author Sam Brannen
* @since 3.0
* @see #evaluate()
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Deprecated(since = "7.0")
public class SpringFailOnTimeout extends Statement {
private final Statement next;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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.
@ -32,7 +32,11 @@ import org.springframework.test.annotation.TestAnnotationUtils;
* @author Sam Brannen
* @since 3.0
* @see #evaluate()
* @deprecated since Spring Framework 7.0 in favor of the
* {@link org.springframework.test.context.junit.jupiter.SpringExtension SpringExtension}
* and JUnit Jupiter
*/
@Deprecated(since = "7.0")
public class SpringRepeat extends Statement {
protected static final Log logger = LogFactory.getLog(SpringRepeat.class);

View File

@ -31,6 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Sam Brannen
* @since 3.0
*/
@SuppressWarnings("deprecation")
class ProfileValueUtilsTests {
private static final String NON_ANNOTATED_METHOD = "nonAnnotatedMethod";
@ -140,7 +141,6 @@ class ProfileValueUtilsTests {
@Test
void isTestEnabledInThisEnvironmentForProvidedProfileValueSourceMethodAndClass() throws Exception {
ProfileValueSource profileValueSource = SystemProfileValueSource.getInstance();
assertMethodIsEnabled(profileValueSource, NON_ANNOTATED_METHOD, NonAnnotated.class);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2025 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.
@ -46,6 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
// Override the default loader configured by the CustomXmlBootstrapper
@ContextConfiguration(classes = BasicTestConfiguration.class, loader = AnnotationConfigContextLoader.class)
@TestPropertySource
@SuppressWarnings("deprecation")
public class BasicSpringVintageTests {
@Autowired

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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,6 +41,7 @@ import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppC
@ContextConfiguration(classes = WebTestConfiguration.class)
@WebAppConfiguration
@TestPropertySource(properties = "test.engine = vintage")
@SuppressWarnings("deprecation")
public class WebSpringVintageTests {
MockMvc mockMvc;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@ContextConfiguration("test-config.xml")
@TestPropertySource(properties = "test.engine = vintage")
@SuppressWarnings("deprecation")
public class XmlSpringVintageTests {
@Autowired

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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,6 +35,7 @@ import static org.assertj.core.api.Assertions.fail;
@TestExecutionListeners(ClassLevelDisabledSpringRunnerTests.CustomTestExecutionListener.class)
@IfProfileValue(name = "ClassLevelDisabledSpringRunnerTests.profile_value.name", value = "enigmaX")
@DisabledInAotMode("@IfProfileValue is not supported for AOT processing")
@SuppressWarnings("deprecation")
public class ClassLevelDisabledSpringRunnerTests {
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2025 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,6 +44,7 @@ import static org.springframework.transaction.support.TransactionSynchronization
* @since 2.5
*/
@ContextConfiguration
@SuppressWarnings("deprecation")
public class ConcreteTransactionalJUnit4SpringContextTests extends AbstractTransactionalJUnit4SpringContextTests
implements BeanNameAware, InitializingBean {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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,6 +49,7 @@ import static org.assertj.core.api.Assertions.fail;
@RunWith(SpringRunner.class)
@TestExecutionListeners({})
@DisabledInAotMode("Does not load an ApplicationContext and thus not supported for AOT processing")
@SuppressWarnings("deprecation")
public class EnabledAndIgnoredSpringRunnerTests {
protected static final String NAME = "EnabledAndIgnoredSpringRunnerTests.profile_value.name";

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2025 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,13 +28,14 @@ import org.springframework.test.context.TestExecutionListeners;
import static org.springframework.test.context.junit4.JUnitTestingUtils.runTestsAndAssertCounters;
/**
* Verifies proper handling of JUnit's {@link Test#expected() &#064;Test(expected = ...)}
* Verifies proper handling of JUnit's {@link Test#expected() @Test(expected = ...)}
* support in conjunction with the {@link SpringRunner}.
*
* @author Sam Brannen
* @since 3.0
*/
@RunWith(JUnit4.class)
@SuppressWarnings("deprecation")
public class ExpectedExceptionSpringRunnerTests {
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2025 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,6 +50,7 @@ import static org.springframework.test.context.junit4.JUnitTestingUtils.runTests
* @since 2.5
*/
@RunWith(Parameterized.class)
@SuppressWarnings("deprecation")
public class FailingBeforeAndAfterMethodsSpringRunnerTests {
protected final Class<?> clazz;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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,6 +38,7 @@ import org.springframework.test.context.aot.DisabledInAotMode;
*/
@ProfileValueSourceConfiguration(HardCodedProfileValueSourceSpringRunnerTests.HardCodedProfileValueSource.class)
@DisabledInAotMode("Because EnabledAndIgnoredSpringRunnerTests is disabled in AOT mode")
@SuppressWarnings("deprecation")
public class HardCodedProfileValueSourceSpringRunnerTests extends EnabledAndIgnoredSpringRunnerTests {
@BeforeClass

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@ -47,6 +47,7 @@ import static org.springframework.test.context.junit4.JUnitTestingUtils.runTests
* @since 3.0
*/
@RunWith(Parameterized.class)
@SuppressWarnings("deprecation")
public class RepeatedSpringRunnerTests {
protected static final AtomicInteger invocationCount = new AtomicInteger();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2025 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,6 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@TestExecutionListeners({})
@DisabledInAotMode("Does not load an ApplicationContext and thus not supported for AOT processing")
@SuppressWarnings("deprecation")
public class SpringJUnit47ClassRunnerRuleTests {
@Rule
@ -53,4 +54,5 @@ public class SpringJUnit47ClassRunnerRuleTests {
public void testB() {
assertThat(name.getMethodName()).isEqualTo("testB");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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,6 +36,7 @@ import static org.assertj.core.api.Assertions.assertThatException;
* @author Rick Evans
* @since 2.5
*/
@SuppressWarnings("deprecation")
public class SpringJUnit4ClassRunnerTests {
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,15 +22,12 @@ import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.aot.DisabledInAotMode;
/**
* <p>
* Simple unit test to verify that {@link SpringRunner} does not
* hinder correct functionality of standard JUnit 4.4+ testing features.
* </p>
* <p>
* Note that {@link TestExecutionListeners @TestExecutionListeners} is
* Simple unit test to verify that the {@link SpringRunner} does not
* hinder correct functionality of standard JUnit 4 testing features.
*
* <p>Note that {@link TestExecutionListeners @TestExecutionListeners} is
* explicitly configured with an empty list, thus disabling all default
* listeners.
* </p>
*
* @author Sam Brannen
* @since 2.5
@ -39,6 +36,7 @@ import org.springframework.test.context.aot.DisabledInAotMode;
@RunWith(SpringRunner.class)
@TestExecutionListeners({})
@DisabledInAotMode("Does not load an ApplicationContext and thus not supported for AOT processing")
@SuppressWarnings("deprecation")
public class StandardJUnit4FeaturesSpringRunnerTests extends StandardJUnit4FeaturesTests {
/* All tests are in the parent class... */

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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,6 +43,7 @@ import static org.springframework.test.context.junit4.JUnitTestingUtils.runTests
* @since 3.0
*/
@RunWith(JUnit4.class)
@SuppressWarnings("deprecation")
public class TimedSpringRunnerTests {
protected Class<?> getTestCase() {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2025 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.
@ -40,6 +40,7 @@ import static org.springframework.test.transaction.TransactionAssert.assertThatT
@RunWith(SpringRunner.class)
@ContextConfiguration("/org/springframework/test/context/transaction/transactionalTests-context.xml")
@Transactional
@SuppressWarnings("deprecation")
public class TimedTransactionalSpringRunnerTests {
@Test

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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,6 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(SpringRunner.class)
@RecordApplicationEvents
@SuppressWarnings("deprecation")
public class JUnit4ApplicationEventsAsyncIntegrationTests {
@Rule

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2025 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,6 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(SpringRunner.class)
@RecordApplicationEvents
@SuppressWarnings("deprecation")
public class JUnit4ApplicationEventsIntegrationTests {
@Rule

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2025 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.
@ -29,6 +29,7 @@ import org.springframework.test.context.junit4.rules.SpringMethodRule;
* @author Sam Brannen
* @since 5.0
*/
@SuppressWarnings("deprecation")
public abstract class SpringRuleConfigurer {
@ClassRule

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Sam Brannen
* @since 5.0
*/
@SuppressWarnings("deprecation")
public class AutowiredRuleSpr15927Tests {
@ClassRule

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2025 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,6 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @see Subclass2AppCtxRuleTests
*/
@ContextConfiguration
@SuppressWarnings("deprecation")
public class BaseAppCtxRuleTests {
@ClassRule

View File

@ -41,6 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(JUnit4.class)
@ContextConfiguration
@SuppressWarnings("deprecation")
public class BasicAnnotationConfigWacSpringRuleTests extends AbstractBasicWacTests {
@ClassRule

View File

@ -51,6 +51,7 @@ import static org.springframework.test.transaction.TransactionAssert.assertThatT
@RunWith(JUnit4.class)
@ContextConfiguration("/org/springframework/test/context/transaction/transactionalTests-context.xml")
@Transactional
@SuppressWarnings("deprecation")
public class BeforeAndAfterTransactionAnnotationSpringRuleTests {
private static final String JANE = "jane";

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2025 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.
@ -32,6 +32,7 @@ import org.springframework.test.context.junit4.ClassLevelDisabledSpringRunnerTes
* @since 4.2
*/
@RunWith(JUnit4.class)
@SuppressWarnings("deprecation")
public class ClassLevelDisabledSpringRuleTests extends ClassLevelDisabledSpringRunnerTests {
@ClassRule

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2025 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.
@ -32,6 +32,7 @@ import org.springframework.test.context.junit4.EnabledAndIgnoredSpringRunnerTest
* @since 4.2
*/
@RunWith(JUnit4.class)
@SuppressWarnings("deprecation")
public class EnabledAndIgnoredSpringRuleTests extends EnabledAndIgnoredSpringRunnerTests {
@ClassRule

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2025 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,6 +42,7 @@ import static org.assertj.core.api.Assertions.fail;
* @author Sam Brannen
* @since 4.2
*/
@SuppressWarnings("deprecation")
public class FailingBeforeAndAfterMethodsSpringRuleTests extends FailingBeforeAndAfterMethodsSpringRunnerTests {
@Parameters(name = "{0}")

View File

@ -35,6 +35,7 @@ import static org.mockito.Mockito.when;
* @author Sam Brannen
* @see <a href="https://github.com/spring-projects/spring-boot/issues/27693">gh-27693</a>
*/
@SuppressWarnings("deprecation")
public class MockitoBeanAndSpringMethodRuleWithRepeatJUnit4IntegrationTests {
private static int invocations;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2025 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.
@ -47,6 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@RunWith(Parameterized.class)
@ContextConfiguration("../ParameterizedDependencyInjectionTests-context.xml")
@SuppressWarnings("deprecation")
public class ParameterizedSpringRuleTests {
private static final AtomicInteger invocationCount = new AtomicInteger();

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2025 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.
@ -65,6 +65,7 @@ import static org.springframework.test.transaction.TransactionAssert.assertThatT
@RunWith(JUnit4.class)
@ContextConfiguration
@Transactional
@SuppressWarnings("deprecation")
public class ProgrammaticTxMgmtSpringRuleTests {
@ClassRule

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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.
@ -40,6 +40,7 @@ import org.springframework.test.context.junit4.RepeatedSpringRunnerTests;
* @author Sam Brannen
* @since 4.2
*/
@SuppressWarnings("deprecation")
public class RepeatedSpringRuleTests extends RepeatedSpringRunnerTests {
@Parameters(name = "{0}")

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2025 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,6 +35,7 @@ import static org.assertj.core.api.Assertions.fail;
* @author Sam Brannen
* @since 4.2
*/
@SuppressWarnings("deprecation")
public class TimedSpringRuleTests extends TimedSpringRunnerTests {
// All tests are in superclass.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -39,6 +39,7 @@ import static org.springframework.test.transaction.TransactionAssert.assertThatT
* @since 4.2
*/
@RunWith(JUnit4.class)
@SuppressWarnings("deprecation")
public class TimedTransactionalSpringRuleTests extends TimedTransactionalSpringRunnerTests {
@ClassRule

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2025 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,6 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@Sql({ "../../jdbc/schema.sql", "../../jdbc/data.sql" })
@DirtiesContext
@SuppressWarnings("deprecation")
public class TransactionalSqlScriptsSpringRuleTests {
@ClassRule

View File

@ -36,6 +36,7 @@ import static org.mockito.Mockito.mock;
* @author Sam Brannen
* @since 4.3.17
*/
@SuppressWarnings("deprecation")
public class SpringFailOnTimeoutTests {
private final Statement statement = mock();

View File

@ -46,6 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@ContextConfiguration
@WebAppConfiguration
@SuppressWarnings("deprecation")
public class JUnit4SpringContextWebTests extends AbstractJUnit4SpringContextTests implements ServletContextAware {
@Configuration