Skip to content

Commit 288461a

Browse files
committed
Introduce @EnabledForTestGroups in Spring's test suite
Closes gh-23476
1 parent bbe3383 commit 288461a

File tree

33 files changed

+244
-181
lines changed

33 files changed

+244
-181
lines changed

spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818

1919
import org.junit.jupiter.api.Test;
2020

21-
import org.springframework.tests.Assume;
22-
import org.springframework.tests.TestGroup;
21+
import org.springframework.tests.EnabledForTestGroups;
2322

2423
import static org.assertj.core.api.Assertions.assertThat;
24+
import static org.springframework.tests.TestGroup.PERFORMANCE;
2525

2626
/**
2727
* @author Rob Harrop
@@ -77,9 +77,8 @@ public void testWithNoRefreshCheck() throws Exception {
7777
}
7878

7979
@Test
80+
@EnabledForTestGroups(PERFORMANCE)
8081
public void testRefreshOverTime() throws Exception {
81-
Assume.group(TestGroup.PERFORMANCE);
82-
8382
CountingRefreshableTargetSource ts = new CountingRefreshableTargetSource(true);
8483
ts.setRefreshCheckDelay(100);
8584

spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
import org.springframework.core.convert.support.GenericConversionService;
5050
import org.springframework.lang.Nullable;
5151
import org.springframework.tests.Assume;
52-
import org.springframework.tests.TestGroup;
52+
import org.springframework.tests.EnabledForTestGroups;
5353
import org.springframework.tests.sample.beans.BooleanTestBean;
5454
import org.springframework.tests.sample.beans.ITestBean;
5555
import org.springframework.tests.sample.beans.IndexedTestBean;
@@ -62,6 +62,7 @@
6262
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
6363
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
6464
import static org.assertj.core.api.Assertions.within;
65+
import static org.springframework.tests.TestGroup.PERFORMANCE;
6566

6667
/**
6768
* Shared tests for property accessors.
@@ -960,8 +961,8 @@ public void setPrimitiveArrayProperty() {
960961
}
961962

962963
@Test
964+
@EnabledForTestGroups(PERFORMANCE)
963965
public void setPrimitiveArrayPropertyLargeMatching() {
964-
Assume.group(TestGroup.PERFORMANCE);
965966
Assume.notLogging(LogFactory.getLog(AbstractPropertyAccessorTests.class));
966967

967968
PrimitiveArrayBean target = new PrimitiveArrayBean();

spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
3434
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
3535
import org.springframework.beans.propertyeditors.CustomDateEditor;
36-
import org.springframework.tests.Assume;
36+
import org.springframework.tests.EnabledForTestGroups;
3737
import org.springframework.tests.TestGroup;
3838

3939
import static org.assertj.core.api.Assertions.assertThat;
@@ -45,6 +45,7 @@
4545
* @author Chris Beams
4646
* @since 10.03.2004
4747
*/
48+
@EnabledForTestGroups(TestGroup.PERFORMANCE)
4849
public class ConcurrentBeanFactoryTests {
4950

5051
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd");
@@ -73,8 +74,6 @@ public class ConcurrentBeanFactoryTests {
7374

7475
@BeforeEach
7576
public void setup() throws Exception {
76-
Assume.group(TestGroup.PERFORMANCE);
77-
7877
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
7978
new XmlBeanDefinitionReader(factory).loadBeanDefinitions(
8079
qualifiedResource(ConcurrentBeanFactoryTests.class, "context.xml"));

spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
import org.springframework.core.io.UrlResource;
8989
import org.springframework.lang.Nullable;
9090
import org.springframework.tests.Assume;
91+
import org.springframework.tests.EnabledForTestGroups;
9192
import org.springframework.tests.TestGroup;
9293
import org.springframework.tests.sample.beans.DependenciesBean;
9394
import org.springframework.tests.sample.beans.DerivedTestBean;
@@ -2292,8 +2293,8 @@ public void testPrototypeWithArrayConversionForFactoryMethod() {
22922293
}
22932294

22942295
@Test
2296+
@EnabledForTestGroups(TestGroup.PERFORMANCE)
22952297
public void testPrototypeCreationIsFastEnough() {
2296-
Assume.group(TestGroup.PERFORMANCE);
22972298
Assume.notLogging(factoryLog);
22982299
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
22992300
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -2310,8 +2311,8 @@ public void testPrototypeCreationIsFastEnough() {
23102311
}
23112312

23122313
@Test
2314+
@EnabledForTestGroups(TestGroup.PERFORMANCE)
23132315
public void testPrototypeCreationWithDependencyCheckIsFastEnough() {
2314-
Assume.group(TestGroup.PERFORMANCE);
23152316
Assume.notLogging(factoryLog);
23162317
RootBeanDefinition rbd = new RootBeanDefinition(LifecycleBean.class);
23172318
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -2331,8 +2332,8 @@ public void testPrototypeCreationWithDependencyCheckIsFastEnough() {
23312332

23322333
@Test
23332334
@Disabled // TODO re-enable when ConstructorResolver TODO sorted out
2335+
@EnabledForTestGroups(TestGroup.PERFORMANCE)
23342336
public void testPrototypeCreationWithConstructorArgumentsIsFastEnough() {
2335-
Assume.group(TestGroup.PERFORMANCE);
23362337
Assume.notLogging(factoryLog);
23372338
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
23382339
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -2353,8 +2354,8 @@ public void testPrototypeCreationWithConstructorArgumentsIsFastEnough() {
23532354
}
23542355

23552356
@Test
2357+
@EnabledForTestGroups(TestGroup.PERFORMANCE)
23562358
public void testPrototypeCreationWithResolvedConstructorArgumentsIsFastEnough() {
2357-
Assume.group(TestGroup.PERFORMANCE);
23582359
Assume.notLogging(factoryLog);
23592360
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
23602361
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -2375,8 +2376,8 @@ public void testPrototypeCreationWithResolvedConstructorArgumentsIsFastEnough()
23752376
}
23762377

23772378
@Test
2379+
@EnabledForTestGroups(TestGroup.PERFORMANCE)
23782380
public void testPrototypeCreationWithPropertiesIsFastEnough() {
2379-
Assume.group(TestGroup.PERFORMANCE);
23802381
Assume.notLogging(factoryLog);
23812382
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
23822383
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -2397,8 +2398,8 @@ public void testPrototypeCreationWithPropertiesIsFastEnough() {
23972398
}
23982399

23992400
@Test
2401+
@EnabledForTestGroups(TestGroup.PERFORMANCE)
24002402
public void testPrototypeCreationWithResolvedPropertiesIsFastEnough() {
2401-
Assume.group(TestGroup.PERFORMANCE);
24022403
Assume.notLogging(factoryLog);
24032404
RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
24042405
rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
@@ -2419,8 +2420,8 @@ public void testPrototypeCreationWithResolvedPropertiesIsFastEnough() {
24192420
}
24202421

24212422
@Test
2423+
@EnabledForTestGroups(TestGroup.PERFORMANCE)
24222424
public void testSingletonLookupByNameIsFastEnough() {
2423-
Assume.group(TestGroup.PERFORMANCE);
24242425
Assume.notLogging(factoryLog);
24252426
lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class));
24262427
lbf.freezeConfiguration();
@@ -2435,8 +2436,8 @@ public void testSingletonLookupByNameIsFastEnough() {
24352436
}
24362437

24372438
@Test
2439+
@EnabledForTestGroups(TestGroup.PERFORMANCE)
24382440
public void testSingletonLookupByTypeIsFastEnough() {
2439-
Assume.group(TestGroup.PERFORMANCE);
24402441
Assume.notLogging(factoryLog);
24412442
lbf.registerBeanDefinition("test", new RootBeanDefinition(TestBean.class));
24422443
lbf.freezeConfiguration();
@@ -2797,9 +2798,8 @@ public void testNonPublicEnum() {
27972798
*/
27982799
@Test
27992800
@Timeout(1)
2801+
@EnabledForTestGroups(TestGroup.PERFORMANCE)
28002802
public void testByTypeLookupIsFastEnough() {
2801-
Assume.group(TestGroup.PERFORMANCE);
2802-
28032803
for (int i = 0; i < 1000; i++) {
28042804
lbf.registerBeanDefinition("a" + i, new RootBeanDefinition(A.class));
28052805
}
@@ -2814,8 +2814,8 @@ public void testByTypeLookupIsFastEnough() {
28142814

28152815
@Test
28162816
@Timeout(1)
2817+
@EnabledForTestGroups(TestGroup.PERFORMANCE)
28172818
public void testRegistrationOfManyBeanDefinitionsIsFastEnough() {
2818-
Assume.group(TestGroup.PERFORMANCE);
28192819
lbf.registerBeanDefinition("b", new RootBeanDefinition(B.class));
28202820
// lbf.getBean("b");
28212821

@@ -2826,8 +2826,8 @@ public void testRegistrationOfManyBeanDefinitionsIsFastEnough() {
28262826

28272827
@Test
28282828
@Timeout(1)
2829+
@EnabledForTestGroups(TestGroup.PERFORMANCE)
28292830
public void testRegistrationOfManySingletonsIsFastEnough() {
2830-
Assume.group(TestGroup.PERFORMANCE);
28312831
lbf.registerBeanDefinition("b", new RootBeanDefinition(B.class));
28322832
// lbf.getBean("b");
28332833

spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@
4949
import org.springframework.core.annotation.Order;
5050
import org.springframework.core.io.ClassPathResource;
5151
import org.springframework.core.io.UrlResource;
52-
import org.springframework.tests.Assume;
53-
import org.springframework.tests.TestGroup;
52+
import org.springframework.tests.EnabledForTestGroups;
5453
import org.springframework.tests.sample.beans.GenericBean;
5554
import org.springframework.tests.sample.beans.GenericIntegerBean;
5655
import org.springframework.tests.sample.beans.GenericSetOfIntegerBean;
5756
import org.springframework.tests.sample.beans.TestBean;
5857

5958
import static org.assertj.core.api.Assertions.assertThat;
6059
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
60+
import static org.springframework.tests.TestGroup.LONG_RUNNING;
6161

6262
/**
6363
* @author Juergen Hoeller
@@ -651,9 +651,8 @@ public void testGenericallyTypedSetOfIntegerBean() {
651651
}
652652

653653
@Test
654+
@EnabledForTestGroups(LONG_RUNNING)
654655
public void testSetBean() throws Exception {
655-
Assume.group(TestGroup.LONG_RUNNING);
656-
657656
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
658657
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
659658
new ClassPathResource("genericBeanTests.xml", getClass()));

spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
import org.junit.jupiter.api.Test;
2323

24-
import org.springframework.tests.Assume;
25-
import org.springframework.tests.TestGroup;
2624
import org.springframework.tests.sample.beans.TestBean;
2725

2826
import static org.assertj.core.api.Assertions.assertThat;
@@ -38,8 +36,6 @@ public class PagedListHolderTests {
3836
@Test
3937
@SuppressWarnings({ "rawtypes", "unchecked" })
4038
public void testPagedListHolder() {
41-
Assume.group(TestGroup.LONG_RUNNING);
42-
4339
TestBean tb1 = new TestBean();
4440
tb1.setName("eva");
4541
tb1.setAge(25);

spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheCacheTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
import org.junit.jupiter.api.Test;
2727

2828
import org.springframework.cache.AbstractCacheTests;
29-
import org.springframework.tests.Assume;
30-
import org.springframework.tests.TestGroup;
29+
import org.springframework.tests.EnabledForTestGroups;
3130

3231
import static org.assertj.core.api.Assertions.assertThat;
32+
import static org.springframework.tests.TestGroup.LONG_RUNNING;
3333

3434
/**
3535
* @author Costin Leau
@@ -73,9 +73,8 @@ protected Ehcache getNativeCache() {
7373

7474

7575
@Test
76+
@EnabledForTestGroups(LONG_RUNNING)
7677
public void testExpiredElements() throws Exception {
77-
Assume.group(TestGroup.LONG_RUNNING);
78-
7978
String key = "brancusi";
8079
String value = "constantin";
8180
Element brancusi = new Element(key, value);

spring-context-support/src/test/java/org/springframework/scheduling/quartz/QuartzSupportTests.java

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@
3737
import org.springframework.context.support.StaticApplicationContext;
3838
import org.springframework.core.task.TaskExecutor;
3939
import org.springframework.jdbc.core.JdbcTemplate;
40-
import org.springframework.tests.Assume;
41-
import org.springframework.tests.TestGroup;
40+
import org.springframework.tests.EnabledForTestGroups;
4241
import org.springframework.tests.sample.beans.TestBean;
4342

4443
import static org.assertj.core.api.Assertions.assertThat;
4544
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
4645
import static org.mockito.BDDMockito.given;
4746
import static org.mockito.Mockito.mock;
4847
import static org.mockito.Mockito.verify;
48+
import static org.springframework.tests.TestGroup.PERFORMANCE;
4949

5050
/**
5151
* @author Juergen Hoeller
@@ -95,9 +95,8 @@ protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String sc
9595
}
9696

9797
@Test
98+
@EnabledForTestGroups(PERFORMANCE)
9899
public void schedulerWithTaskExecutor() throws Exception {
99-
Assume.group(TestGroup.PERFORMANCE);
100-
101100
CountingTaskExecutor taskExecutor = new CountingTaskExecutor();
102101
DummyJob.count = 0;
103102

@@ -137,9 +136,8 @@ public void jobDetailWithRunnableInsteadOfJob() {
137136
}
138137

139138
@Test
139+
@EnabledForTestGroups(PERFORMANCE)
140140
public void schedulerWithQuartzJobBean() throws Exception {
141-
Assume.group(TestGroup.PERFORMANCE);
142-
143141
DummyJob.param = 0;
144142
DummyJob.count = 0;
145143

@@ -171,9 +169,8 @@ public void schedulerWithQuartzJobBean() throws Exception {
171169
}
172170

173171
@Test
172+
@EnabledForTestGroups(PERFORMANCE)
174173
public void schedulerWithSpringBeanJobFactory() throws Exception {
175-
Assume.group(TestGroup.PERFORMANCE);
176-
177174
DummyJob.param = 0;
178175
DummyJob.count = 0;
179176

@@ -207,9 +204,8 @@ public void schedulerWithSpringBeanJobFactory() throws Exception {
207204
}
208205

209206
@Test
207+
@EnabledForTestGroups(PERFORMANCE)
210208
public void schedulerWithSpringBeanJobFactoryAndParamMismatchNotIgnored() throws Exception {
211-
Assume.group(TestGroup.PERFORMANCE);
212-
213209
DummyJob.param = 0;
214210
DummyJob.count = 0;
215211

@@ -244,8 +240,8 @@ public void schedulerWithSpringBeanJobFactoryAndParamMismatchNotIgnored() throws
244240
}
245241

246242
@Test
243+
@EnabledForTestGroups(PERFORMANCE)
247244
public void schedulerWithSpringBeanJobFactoryAndQuartzJobBean() throws Exception {
248-
Assume.group(TestGroup.PERFORMANCE);
249245
DummyJobBean.param = 0;
250246
DummyJobBean.count = 0;
251247

@@ -278,8 +274,8 @@ public void schedulerWithSpringBeanJobFactoryAndQuartzJobBean() throws Exception
278274
}
279275

280276
@Test
277+
@EnabledForTestGroups(PERFORMANCE)
281278
public void schedulerWithSpringBeanJobFactoryAndJobSchedulingData() throws Exception {
282-
Assume.group(TestGroup.PERFORMANCE);
283279
DummyJob.param = 0;
284280
DummyJob.count = 0;
285281

@@ -327,8 +323,8 @@ public void multipleSchedulersWithQuartzProperties() throws Exception {
327323
}
328324

329325
@Test
326+
@EnabledForTestGroups(PERFORMANCE)
330327
public void twoAnonymousMethodInvokingJobDetailFactoryBeans() throws Exception {
331-
Assume.group(TestGroup.PERFORMANCE);
332328
ClassPathXmlApplicationContext ctx = context("multipleAnonymousMethodInvokingJobDetailFB.xml");
333329
Thread.sleep(3000);
334330
try {
@@ -346,8 +342,8 @@ public void twoAnonymousMethodInvokingJobDetailFactoryBeans() throws Exception {
346342
}
347343

348344
@Test
345+
@EnabledForTestGroups(PERFORMANCE)
349346
public void schedulerAccessorBean() throws Exception {
350-
Assume.group(TestGroup.PERFORMANCE);
351347
ClassPathXmlApplicationContext ctx = context("schedulerAccessorBean.xml");
352348
Thread.sleep(3000);
353349
try {
@@ -401,8 +397,6 @@ public void schedulerRepositoryExposure() throws Exception {
401397
*/
402398
@Test
403399
public void schedulerWithHsqlDataSource() throws Exception {
404-
// Assume.group(TestGroup.PERFORMANCE);
405-
406400
DummyJob.param = 0;
407401
DummyJob.count = 0;
408402

0 commit comments

Comments
 (0)