Introduce @EnabledForTestGroups in Spring's test suite
Closes gh-23476
This commit is contained in:
@@ -52,6 +52,7 @@ import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
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.INestedTestBean;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
@@ -112,8 +113,8 @@ public class AspectJAutoProxyCreatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(TestGroup.PERFORMANCE)
|
||||
public void testAspectsAndAdvisorAppliedToPrototypeIsFastEnough() {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
Assume.notLogging(factoryLog);
|
||||
|
||||
ClassPathXmlApplicationContext ac = newContext("aspectsPlusAdvisor.xml");
|
||||
@@ -134,8 +135,8 @@ public class AspectJAutoProxyCreatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(TestGroup.PERFORMANCE)
|
||||
public void testAspectsAndAdvisorNotAppliedToPrototypeIsFastEnough() {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
Assume.notLogging(factoryLog);
|
||||
|
||||
ClassPathXmlApplicationContext ac = newContext("aspectsPlusAdvisor.xml");
|
||||
@@ -156,8 +157,8 @@ public class AspectJAutoProxyCreatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(TestGroup.PERFORMANCE)
|
||||
public void testAspectsAndAdvisorNotAppliedToManySingletonsIsFastEnough() {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
Assume.notLogging(factoryLog);
|
||||
|
||||
GenericApplicationContext ac = new GenericApplicationContext();
|
||||
|
||||
@@ -58,7 +58,7 @@ import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;
|
||||
import org.springframework.aop.target.HotSwappableTargetSource;
|
||||
import org.springframework.aop.target.SingletonTargetSource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.tests.Assume;
|
||||
import org.springframework.tests.EnabledForTestGroups;
|
||||
import org.springframework.tests.TestGroup;
|
||||
import org.springframework.tests.TimeStamped;
|
||||
import org.springframework.tests.aop.advice.CountingAfterReturningAdvice;
|
||||
@@ -163,8 +163,8 @@ public abstract class AbstractAopProxyTests {
|
||||
* CGLIB this will be slow or will run out of memory.
|
||||
*/
|
||||
@Test
|
||||
@EnabledForTestGroups(TestGroup.PERFORMANCE)
|
||||
public void testManyProxies() {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
int howMany = 10000;
|
||||
StopWatch sw = new StopWatch();
|
||||
sw.start("Create " + howMany + " proxies");
|
||||
|
||||
@@ -33,11 +33,12 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.tests.Assume;
|
||||
import org.springframework.tests.TestGroup;
|
||||
import org.springframework.tests.EnabledForTestGroups;
|
||||
import org.springframework.tests.sample.beans.ITestBean;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.tests.TestGroup.PERFORMANCE;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
@@ -45,6 +46,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
* @author Sam Brannen
|
||||
* @since 2.5
|
||||
*/
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public class AnnotationProcessorPerformanceTests {
|
||||
|
||||
private static final Log factoryLog = LogFactory.getLog(DefaultListableBeanFactory.class);
|
||||
@@ -52,7 +54,6 @@ public class AnnotationProcessorPerformanceTests {
|
||||
|
||||
@BeforeAll
|
||||
public static void commonAssumptions() {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
Assume.notLogging(factoryLog);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,13 +52,14 @@ import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.EncodedResource;
|
||||
import org.springframework.tests.Assume;
|
||||
import org.springframework.tests.TestGroup;
|
||||
import org.springframework.tests.EnabledForTestGroups;
|
||||
import org.springframework.tests.sample.beans.TestBean;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.util.SerializationTestUtils;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.tests.TestGroup.PERFORMANCE;
|
||||
|
||||
/**
|
||||
* @author Juergen Hoeller
|
||||
@@ -245,8 +246,8 @@ public class ApplicationContextExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void prototypeCreationIsFastEnough() {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
Assume.notLogging(factoryLog);
|
||||
GenericApplicationContext ac = new GenericApplicationContext();
|
||||
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
|
||||
|
||||
@@ -27,10 +27,10 @@ import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.context.LifecycleProcessor;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.tests.Assume;
|
||||
import org.springframework.tests.TestGroup;
|
||||
import org.springframework.tests.EnabledForTestGroups;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.tests.TestGroup.PERFORMANCE;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -252,9 +252,8 @@ public class DefaultLifecycleProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void smartLifecycleGroupShutdown() throws Exception {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
CopyOnWriteArrayList<Lifecycle> stoppedBeans = new CopyOnWriteArrayList<>();
|
||||
TestSmartLifecycleBean bean1 = TestSmartLifecycleBean.forShutdownTests(1, 300, stoppedBeans);
|
||||
TestSmartLifecycleBean bean2 = TestSmartLifecycleBean.forShutdownTests(3, 100, stoppedBeans);
|
||||
@@ -283,9 +282,8 @@ public class DefaultLifecycleProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void singleSmartLifecycleShutdown() throws Exception {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
CopyOnWriteArrayList<Lifecycle> stoppedBeans = new CopyOnWriteArrayList<>();
|
||||
TestSmartLifecycleBean bean = TestSmartLifecycleBean.forShutdownTests(99, 300, stoppedBeans);
|
||||
StaticApplicationContext context = new StaticApplicationContext();
|
||||
@@ -391,9 +389,8 @@ public class DefaultLifecycleProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void dependentShutdownFirstEvenIfItsPhaseIsLower() throws Exception {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
CopyOnWriteArrayList<Lifecycle> stoppedBeans = new CopyOnWriteArrayList<>();
|
||||
TestSmartLifecycleBean beanMin = TestSmartLifecycleBean.forShutdownTests(Integer.MIN_VALUE, 100, stoppedBeans);
|
||||
TestSmartLifecycleBean bean1 = TestSmartLifecycleBean.forShutdownTests(1, 200, stoppedBeans);
|
||||
@@ -465,9 +462,8 @@ public class DefaultLifecycleProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void dependentShutdownFirstAndIsSmartLifecycle() throws Exception {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
CopyOnWriteArrayList<Lifecycle> stoppedBeans = new CopyOnWriteArrayList<>();
|
||||
TestSmartLifecycleBean beanMin = TestSmartLifecycleBean.forShutdownTests(Integer.MIN_VALUE, 400, stoppedBeans);
|
||||
TestSmartLifecycleBean beanNegative = TestSmartLifecycleBean.forShutdownTests(-99, 100, stoppedBeans);
|
||||
@@ -530,9 +526,8 @@ public class DefaultLifecycleProcessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void dependentShutdownFirstButNotSmartLifecycle() throws Exception {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
CopyOnWriteArrayList<Lifecycle> stoppedBeans = new CopyOnWriteArrayList<>();
|
||||
TestSmartLifecycleBean bean1 = TestSmartLifecycleBean.forShutdownTests(1, 200, stoppedBeans);
|
||||
TestLifecycleBean simpleBean = TestLifecycleBean.forShutdownTests(stoppedBeans);
|
||||
|
||||
@@ -32,10 +32,10 @@ import org.springframework.scheduling.config.IntervalTask;
|
||||
import org.springframework.scheduling.config.ScheduledTaskHolder;
|
||||
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
|
||||
import org.springframework.scheduling.config.TaskManagementConfigUtils;
|
||||
import org.springframework.tests.Assume;
|
||||
import org.springframework.tests.TestGroup;
|
||||
import org.springframework.tests.EnabledForTestGroups;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.tests.TestGroup.PERFORMANCE;
|
||||
|
||||
/**
|
||||
* Tests use of @EnableScheduling on @Configuration classes.
|
||||
@@ -58,9 +58,8 @@ public class EnableSchedulingTests {
|
||||
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void withFixedRateTask() throws InterruptedException {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
ctx = new AnnotationConfigApplicationContext(FixedRateTaskConfig.class);
|
||||
assertThat(ctx.getBean(ScheduledTaskHolder.class).getScheduledTasks().size()).isEqualTo(2);
|
||||
|
||||
@@ -69,9 +68,8 @@ public class EnableSchedulingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void withSubclass() throws InterruptedException {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
ctx = new AnnotationConfigApplicationContext(FixedRateTaskConfigSubclass.class);
|
||||
assertThat(ctx.getBean(ScheduledTaskHolder.class).getScheduledTasks().size()).isEqualTo(2);
|
||||
|
||||
@@ -80,9 +78,8 @@ public class EnableSchedulingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void withExplicitScheduler() throws InterruptedException {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
ctx = new AnnotationConfigApplicationContext(ExplicitSchedulerConfig.class);
|
||||
assertThat(ctx.getBean(ScheduledTaskHolder.class).getScheduledTasks().size()).isEqualTo(1);
|
||||
|
||||
@@ -100,9 +97,8 @@ public class EnableSchedulingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void withExplicitScheduledTaskRegistrar() throws InterruptedException {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
ctx = new AnnotationConfigApplicationContext(ExplicitScheduledTaskRegistrarConfig.class);
|
||||
assertThat(ctx.getBean(ScheduledTaskHolder.class).getScheduledTasks().size()).isEqualTo(1);
|
||||
|
||||
@@ -123,9 +119,8 @@ public class EnableSchedulingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void withAmbiguousTaskSchedulers_andSingleTask_disambiguatedByScheduledTaskRegistrarBean() throws InterruptedException {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
ctx = new AnnotationConfigApplicationContext(
|
||||
SchedulingEnabled_withAmbiguousTaskSchedulers_andSingleTask_disambiguatedByScheduledTaskRegistrar.class);
|
||||
|
||||
@@ -134,9 +129,8 @@ public class EnableSchedulingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void withAmbiguousTaskSchedulers_andSingleTask_disambiguatedBySchedulerNameAttribute() throws InterruptedException {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
ctx = new AnnotationConfigApplicationContext(
|
||||
SchedulingEnabled_withAmbiguousTaskSchedulers_andSingleTask_disambiguatedBySchedulerNameAttribute.class);
|
||||
|
||||
@@ -145,9 +139,8 @@ public class EnableSchedulingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void withTaskAddedVia_configureTasks() throws InterruptedException {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
ctx = new AnnotationConfigApplicationContext(SchedulingEnabled_withTaskAddedVia_configureTasks.class);
|
||||
|
||||
Thread.sleep(100);
|
||||
@@ -155,9 +148,8 @@ public class EnableSchedulingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void withTriggerTask() throws InterruptedException {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
ctx = new AnnotationConfigApplicationContext(TriggerTaskConfig.class);
|
||||
|
||||
Thread.sleep(100);
|
||||
@@ -165,9 +157,8 @@ public class EnableSchedulingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void withInitiallyDelayedFixedRateTask() throws InterruptedException {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
ctx = new AnnotationConfigApplicationContext(FixedRateTaskConfig_withInitialDelay.class);
|
||||
|
||||
Thread.sleep(1950);
|
||||
|
||||
@@ -24,8 +24,7 @@ import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.task.NoOpRunnable;
|
||||
import org.springframework.tests.Assume;
|
||||
import org.springframework.tests.TestGroup;
|
||||
import org.springframework.tests.EnabledForTestGroups;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
@@ -34,6 +33,7 @@ import static org.mockito.Mockito.atLeast;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.springframework.tests.TestGroup.PERFORMANCE;
|
||||
|
||||
/**
|
||||
* @author Rick Evans
|
||||
@@ -44,8 +44,7 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||
@Test
|
||||
public void testThrowsExceptionIfPoolSizeIsLessThanZero() throws Exception {
|
||||
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
factory.setPoolSize(-1));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> factory.setPoolSize(-1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,9 +89,8 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void testOneTimeExecutionIsSetUpAndFiresCorrectly() throws Exception {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
Runnable runnable = mock(Runnable.class);
|
||||
|
||||
ScheduledExecutorFactoryBean factory = new ScheduledExecutorFactoryBean();
|
||||
@@ -107,9 +105,8 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void testFixedRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
Runnable runnable = mock(Runnable.class);
|
||||
|
||||
ScheduledExecutorTask task = new ScheduledExecutorTask(runnable);
|
||||
@@ -126,9 +123,8 @@ public class ScheduledExecutorFactoryBeanTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public void testFixedRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
|
||||
Runnable runnable = mock(Runnable.class);
|
||||
willThrow(new IllegalStateException()).given(runnable).run();
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.scripting.support;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.FatalBeanException;
|
||||
@@ -28,19 +27,20 @@ import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.scripting.Messenger;
|
||||
import org.springframework.scripting.ScriptCompilationException;
|
||||
import org.springframework.scripting.groovy.GroovyScriptFactory;
|
||||
import org.springframework.tests.Assume;
|
||||
import org.springframework.tests.TestGroup;
|
||||
import org.springframework.tests.EnabledForTestGroups;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.springframework.tests.TestGroup.PERFORMANCE;
|
||||
|
||||
/**
|
||||
* @author Rick Evans
|
||||
* @author Juergen Hoeller
|
||||
* @author Chris Beams
|
||||
*/
|
||||
@EnabledForTestGroups(PERFORMANCE)
|
||||
public class ScriptFactoryPostProcessorTests {
|
||||
|
||||
private static final String MESSAGE_TEXT = "Bingo";
|
||||
@@ -77,10 +77,6 @@ public class ScriptFactoryPostProcessorTests {
|
||||
" }\n" +
|
||||
"}";
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
Assume.group(TestGroup.PERFORMANCE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoesNothingWhenPostProcessingNonScriptFactoryTypeBeforeInstantiation() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user