Migrate rest of test suite from JUnit 4 to JUnit Jupiter

This commit migrates the rest of Spring's test suite to JUnit Jupiter,
except spring-test which will be migrated in a separate commit.

See gh-23451
This commit is contained in:
Sam Brannen
2019-08-13 12:57:37 +02:00
parent 3df85c783f
commit 3f3e41923f
1487 changed files with 5428 additions and 4782 deletions

View File

@@ -22,7 +22,7 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.persistence.PersistenceException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.dao.DataAccessException;

View File

@@ -21,7 +21,7 @@ import javax.persistence.PersistenceException;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator;
import org.springframework.aop.framework.Advised;

View File

@@ -16,7 +16,7 @@
package org.springframework.dao.support;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.dao.OptimisticLockingFailureException;

View File

@@ -24,7 +24,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.function.Consumer;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.IncorrectResultSizeDataAccessException;

View File

@@ -24,7 +24,7 @@ import javax.resource.cci.InteractionSpec;
import javax.resource.cci.LocalTransaction;
import javax.resource.cci.Record;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.jca.cci.connection.CciLocalTransactionManager;

View File

@@ -30,7 +30,7 @@ import javax.resource.cci.Record;
import javax.resource.cci.RecordFactory;
import javax.resource.cci.ResultSet;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.jca.cci.connection.ConnectionSpecConnectionFactoryAdapter;
import org.springframework.jca.cci.connection.NotSupportedRecordFactory;

View File

@@ -24,7 +24,7 @@ import javax.resource.cci.InteractionSpec;
import javax.resource.cci.Record;
import javax.resource.cci.RecordFactory;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.jca.cci.core.RecordCreator;
import org.springframework.jca.cci.object.MappingRecordOperation;

View File

@@ -19,7 +19,7 @@ package org.springframework.jca.support;
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.ManagedConnectionFactory;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@@ -20,8 +20,8 @@ import javax.transaction.Status;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.tests.mock.jndi.ExpectedLookupTemplate;
import org.springframework.transaction.jta.JtaTransactionManager;
@@ -218,7 +218,7 @@ public class JndiJtaTransactionManagerTests {
* Prevent any side-effects due to this test modifying ThreadLocals that might
* affect subsequent tests when all tests are run in the same JVM, as with Eclipse.
*/
@After
@AfterEach
public void tearDown() {
assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue();
assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse();

View File

@@ -26,8 +26,8 @@ import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.tests.transaction.MockJtaTransaction;
@@ -1190,7 +1190,7 @@ public class JtaTransactionManagerTests {
* Prevent any side-effects due to this test modifying ThreadLocals that might
* affect subsequent tests when all tests are run in the same JVM, as with Eclipse.
*/
@After
@AfterEach
public void tearDown() {
assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue();
assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse();

View File

@@ -16,8 +16,8 @@
package org.springframework.transaction;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springframework.transaction.support.DefaultTransactionStatus;
@@ -283,7 +283,7 @@ public class TransactionSupportTests {
}
@After
@AfterEach
public void clear() {
assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue();
assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse();

View File

@@ -16,8 +16,8 @@
package org.springframework.transaction;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
import org.springframework.beans.factory.parsing.ComponentDefinition;
@@ -40,7 +40,7 @@ public class TxNamespaceHandlerEventTests {
private CollectingReaderEventListener eventListener = new CollectingReaderEventListener();
@Before
@BeforeEach
public void setUp() throws Exception {
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory);
reader.setEventListener(this.eventListener);

View File

@@ -18,8 +18,8 @@ package org.springframework.transaction;
import java.lang.reflect.Method;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.context.ApplicationContext;
@@ -46,7 +46,7 @@ public class TxNamespaceHandlerTests {
private Method setAgeMethod;
@Before
@BeforeEach
public void setup() throws Exception {
this.context = new ClassPathXmlApplicationContext("txNamespaceHandlerTests.xml", getClass());
this.getAgeMethod = ITestBean.class.getMethod("getAge");

View File

@@ -25,7 +25,7 @@ import javax.ejb.TransactionAttributeType;
import groovy.lang.GroovyObject;
import groovy.lang.MetaClass;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.ProxyFactory;

View File

@@ -17,7 +17,7 @@
package org.springframework.transaction.annotation;
import io.vavr.control.Try;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.tests.transaction.CallCountingTransactionManager;

View File

@@ -22,8 +22,8 @@ import java.util.Map;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.context.ConfigurableApplicationContext;
@@ -48,7 +48,7 @@ public class AnnotationTransactionNamespaceHandlerTests {
private final ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
"org/springframework/transaction/annotation/annotationTransactionNamespaceHandlerTests.xml");
@After
@AfterEach
public void tearDown() {
this.context.close();
}

View File

@@ -19,7 +19,7 @@ package org.springframework.transaction.annotation;
import java.util.Collection;
import java.util.Map;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Autowired;

View File

@@ -20,7 +20,7 @@ import java.io.Serializable;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.support.RootBeanDefinition;

View File

@@ -18,7 +18,7 @@ package org.springframework.transaction.event;
import java.lang.reflect.Method;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.context.PayloadApplicationEvent;
import org.springframework.context.event.ApplicationListenerMethodAdapter;

View File

@@ -26,8 +26,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
@@ -71,7 +71,7 @@ public class TransactionalEventListenerTests {
private TransactionTemplate transactionTemplate;
@After
@AfterEach
public void closeContext() {
if (this.context != null) {
this.context.close();

View File

@@ -18,8 +18,8 @@ package org.springframework.transaction.interceptor;
import java.lang.reflect.Method;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@@ -54,7 +54,7 @@ public abstract class AbstractReactiveTransactionAspectTests {
protected Method exceptionalMethod;
@Before
@BeforeEach
public void setup() throws Exception {
getNameMethod = TestBean.class.getMethod("getName");
setNameMethod = TestBean.class.getMethod("setName", String.class);

View File

@@ -18,8 +18,8 @@ package org.springframework.transaction.interceptor;
import java.lang.reflect.Method;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.tests.sample.beans.ITestBean;
@@ -65,7 +65,7 @@ public abstract class AbstractTransactionAspectTests {
protected Method exceptionalMethod;
@Before
@BeforeEach
public void setup() throws Exception {
getNameMethod = ITestBean.class.getMethod("getName");
setNameMethod = ITestBean.class.getMethod("setName", String.class);

View File

@@ -22,8 +22,8 @@ import java.util.Map;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.aop.support.StaticMethodMatcherPointcut;
@@ -59,7 +59,7 @@ public class BeanFactoryTransactionTests {
private DefaultListableBeanFactory factory;
@Before
@BeforeEach
public void setUp() {
this.factory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(this.factory).loadBeanDefinitions(

View File

@@ -18,7 +18,7 @@ package org.springframework.transaction.interceptor;
import java.io.IOException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.FatalBeanException;

View File

@@ -22,7 +22,7 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.transaction.TransactionDefinition;

View File

@@ -19,7 +19,7 @@ package org.springframework.transaction.interceptor;
import java.io.IOException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.transaction.TransactionDefinition;

View File

@@ -18,7 +18,7 @@ package org.springframework.transaction.interceptor;
import java.util.Properties;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.util.SerializationTestUtils;

View File

@@ -18,7 +18,7 @@ package org.springframework.transaction.interceptor;
import java.lang.reflect.Method;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.transaction.TransactionDefinition;

View File

@@ -19,7 +19,7 @@ package org.springframework.transaction.interceptor;
import java.io.IOException;
import java.util.Properties;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.transaction.TransactionDefinition;

View File

@@ -19,7 +19,7 @@ package org.springframework.transaction.interceptor;
import java.io.Serializable;
import java.util.Properties;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.BeanFactory;

View File

@@ -23,7 +23,7 @@ import javax.transaction.UserTransaction;
import com.ibm.wsspi.uow.UOWAction;
import com.ibm.wsspi.uow.UOWException;
import com.ibm.wsspi.uow.UOWManager;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.tests.mock.jndi.ExpectedLookupTemplate;

View File

@@ -16,7 +16,7 @@
package org.springframework.transaction.reactive;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;

View File

@@ -16,7 +16,7 @@
package org.springframework.transaction.reactive;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;

View File

@@ -19,7 +19,7 @@ package org.springframework.transaction.support;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.tests.mock.jndi.SimpleNamingContextBuilder;
import org.springframework.transaction.jta.JtaTransactionManager;

View File

@@ -19,7 +19,7 @@ package org.springframework.transaction.support;
import java.util.HashSet;
import java.util.Set;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.support.GenericBeanDefinition;