Introduce @EnabledForTestGroups in Spring's test suite

Closes gh-23476
This commit is contained in:
Sam Brannen
2019-08-17 14:27:35 +02:00
parent bbe33832cf
commit 288461a541
33 changed files with 244 additions and 181 deletions

View File

@@ -49,7 +49,7 @@ import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.lang.Nullable;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import org.springframework.tests.EnabledForTestGroups;
import org.springframework.tests.sample.beans.BooleanTestBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.IndexedTestBean;
@@ -62,6 +62,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.within;
import static org.springframework.tests.TestGroup.PERFORMANCE;
/**
* Shared tests for property accessors.
@@ -960,8 +961,8 @@ public abstract class AbstractPropertyAccessorTests {
}
@Test
@EnabledForTestGroups(PERFORMANCE)
public void setPrimitiveArrayPropertyLargeMatching() {
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(LogFactory.getLog(AbstractPropertyAccessorTests.class));
PrimitiveArrayBean target = new PrimitiveArrayBean();

View File

@@ -33,7 +33,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.tests.Assume;
import org.springframework.tests.EnabledForTestGroups;
import org.springframework.tests.TestGroup;
import static org.assertj.core.api.Assertions.assertThat;
@@ -45,6 +45,7 @@ import static org.springframework.tests.TestResourceUtils.qualifiedResource;
* @author Chris Beams
* @since 10.03.2004
*/
@EnabledForTestGroups(TestGroup.PERFORMANCE)
public class ConcurrentBeanFactoryTests {
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd");
@@ -73,8 +74,6 @@ public class ConcurrentBeanFactoryTests {
@BeforeEach
public void setup() throws Exception {
Assume.group(TestGroup.PERFORMANCE);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
qualifiedResource(ConcurrentBeanFactoryTests.class, "context.xml"));

View File

@@ -88,6 +88,7 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.lang.Nullable;
import org.springframework.tests.Assume;
import org.springframework.tests.EnabledForTestGroups;
import org.springframework.tests.TestGroup;
import org.springframework.tests.sample.beans.DependenciesBean;
import org.springframework.tests.sample.beans.DerivedTestBean;
@@ -2292,8 +2293,8 @@ public class DefaultListableBeanFactoryTests {
}
@Test
@EnabledForTestGroups(TestGroup.PERFORMANCE)
public void testPrototypeCreationIsFastEnough() {
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -2310,8 +2311,8 @@ public class DefaultListableBeanFactoryTests {
}
@Test
@EnabledForTestGroups(TestGroup.PERFORMANCE)
public void testPrototypeCreationWithDependencyCheckIsFastEnough() {
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
RootBeanDefinition rbd = new RootBeanDefinition(LifecycleBean.class);
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -2331,8 +2332,8 @@ public class DefaultListableBeanFactoryTests {
@Test
@Disabled // TODO re-enable when ConstructorResolver TODO sorted out
@EnabledForTestGroups(TestGroup.PERFORMANCE)
public void testPrototypeCreationWithConstructorArgumentsIsFastEnough() {
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -2353,8 +2354,8 @@ public class DefaultListableBeanFactoryTests {
}
@Test
@EnabledForTestGroups(TestGroup.PERFORMANCE)
public void testPrototypeCreationWithResolvedConstructorArgumentsIsFastEnough() {
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -2375,8 +2376,8 @@ public class DefaultListableBeanFactoryTests {
}
@Test
@EnabledForTestGroups(TestGroup.PERFORMANCE)
public void testPrototypeCreationWithPropertiesIsFastEnough() {
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -2397,8 +2398,8 @@ public class DefaultListableBeanFactoryTests {
}
@Test
@EnabledForTestGroups(TestGroup.PERFORMANCE)
public void testPrototypeCreationWithResolvedPropertiesIsFastEnough() {
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -2419,8 +2420,8 @@ public class DefaultListableBeanFactoryTests {
}
@Test
@EnabledForTestGroups(TestGroup.PERFORMANCE)
public void testSingletonLookupByNameIsFastEnough() {
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class));
lbf.freezeConfiguration();
@@ -2435,8 +2436,8 @@ public class DefaultListableBeanFactoryTests {
}
@Test
@EnabledForTestGroups(TestGroup.PERFORMANCE)
public void testSingletonLookupByTypeIsFastEnough() {
Assume.group(TestGroup.PERFORMANCE);
Assume.notLogging(factoryLog);
lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class));
lbf.freezeConfiguration();
@@ -2797,9 +2798,8 @@ public class DefaultListableBeanFactoryTests {
*/
@Test
@Timeout(1)
@EnabledForTestGroups(TestGroup.PERFORMANCE)
public void testByTypeLookupIsFastEnough() {
Assume.group(TestGroup.PERFORMANCE);
for (int i = 0; i < 1000; i++) {
lbf.registerBeanDefinition("a" + i, new RootBeanDefinition(A.class));
}
@@ -2814,8 +2814,8 @@ public class DefaultListableBeanFactoryTests {
@Test
@Timeout(1)
@EnabledForTestGroups(TestGroup.PERFORMANCE)
public void testRegistrationOfManyBeanDefinitionsIsFastEnough() {
Assume.group(TestGroup.PERFORMANCE);
lbf.registerBeanDefinition("b", new RootBeanDefinition(B.class));
// lbf.getBean("b");
@@ -2826,8 +2826,8 @@ public class DefaultListableBeanFactoryTests {
@Test
@Timeout(1)
@EnabledForTestGroups(TestGroup.PERFORMANCE)
public void testRegistrationOfManySingletonsIsFastEnough() {
Assume.group(TestGroup.PERFORMANCE);
lbf.registerBeanDefinition("b", new RootBeanDefinition(B.class));
// lbf.getBean("b");

View File

@@ -49,8 +49,7 @@ import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.annotation.Order;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.UrlResource;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import org.springframework.tests.EnabledForTestGroups;
import org.springframework.tests.sample.beans.GenericBean;
import org.springframework.tests.sample.beans.GenericIntegerBean;
import org.springframework.tests.sample.beans.GenericSetOfIntegerBean;
@@ -58,6 +57,7 @@ import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.springframework.tests.TestGroup.LONG_RUNNING;
/**
* @author Juergen Hoeller
@@ -651,9 +651,8 @@ public class BeanFactoryGenericsTests {
}
@Test
@EnabledForTestGroups(LONG_RUNNING)
public void testSetBean() throws Exception {
Assume.group(TestGroup.LONG_RUNNING);
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
new ClassPathResource("genericBeanTests.xml", getClass()));

View File

@@ -21,8 +21,6 @@ import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.tests.Assume;
import org.springframework.tests.TestGroup;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
@@ -38,8 +36,6 @@ public class PagedListHolderTests {
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void testPagedListHolder() {
Assume.group(TestGroup.LONG_RUNNING);
TestBean tb1 = new TestBean();
tb1.setName("eva");
tb1.setAge(25);