Require JUnit 4.9 or higher in the TCF

Prior to this commit, the Spring TestContext Framework (TCF) was
compatible with JUnit 4.5 or higher.

This commit effectively raises the minimum version of JUnit that is
officially supported by the TCF to JUnit 4.9, thereby aligning with
similar upgrades made in the Spring Framework 4.0 release (i.e.,
upgrading minimum requirements on third-party libraries to versions
released mid 2010 or later).

Issue: SPR-11908
This commit is contained in:
Sam Brannen
2014-06-24 23:41:51 +02:00
parent 2d892da641
commit b4e16eacc5
14 changed files with 102 additions and 165 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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,25 +16,21 @@
package org.springframework.test.context;
import static org.junit.Assert.*;
import java.util.Comparator;
import java.util.List;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.InitializationError;
import org.junit.runners.MethodSorters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.SpringRunnerContextCacheTests.OrderedMethodsSpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
import static org.junit.Assert.*;
/**
* JUnit 4 based unit test which verifies correct {@link ContextCache
* application context caching} in conjunction with the
@@ -46,7 +42,8 @@ import org.springframework.test.context.support.DirtiesContextTestExecutionListe
* @since 2.5
* @see ContextCacheTests
*/
@RunWith(OrderedMethodsSpringJUnit4ClassRunner.class)
@RunWith(SpringJUnit4ClassRunner.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class })
@ContextConfiguration("junit4/SpringJUnit4ClassRunnerAppCtxTests-context.xml")
public class SpringRunnerContextCacheTests {
@@ -130,31 +127,4 @@ public class SpringRunnerContextCacheTests {
SpringRunnerContextCacheTests.dirtiedApplicationContext, this.applicationContext);
}
/**
* @since 3.2
*/
public static class OrderedMethodsSpringJUnit4ClassRunner extends SpringJUnit4ClassRunner {
public OrderedMethodsSpringJUnit4ClassRunner(Class<?> clazz) throws InitializationError {
super(clazz);
}
@Override
protected List<FrameworkMethod> computeTestMethods() {
List<FrameworkMethod> testMethods = super.computeTestMethods();
java.util.Collections.sort(testMethods, new Comparator<FrameworkMethod>() {
@Override
public int compare(FrameworkMethod method1, FrameworkMethod method2) {
return method1.getName().compareTo(method2.getName());
}
});
return testMethods;
}
}
}