Deprecate JUnit 4 support in the TestContext framework

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
@@ -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 {
/**
@@ -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 {
/**
@@ -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 {
/**
@@ -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);
@@ -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 {
/**
@@ -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();
@@ -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 {
/**
@@ -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 {
/**
@@ -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 {
/**
@@ -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 {
/**
@@ -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);
@@ -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 {
/**
@@ -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);
@@ -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);
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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);