Skip to content

Commit 08bce08

Browse files
committed
Use text blocks with JUnit Jupiter 5.8.1
See gh-27450
1 parent 6337e08 commit 08bce08

File tree

4 files changed

+86
-86
lines changed

4 files changed

+86
-86
lines changed

spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorTests.java

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ void closeContextAfterTest() {
9090
}
9191

9292
@ParameterizedTest
93-
@CsvSource({
94-
"FixedDelay, 5000",
95-
"FixedDelayInSeconds, 5000",
96-
"FixedDelayInMinutes, 180000"
97-
})
93+
@CsvSource(textBlock = """
94+
FixedDelay, 5_000
95+
FixedDelayInSeconds, 5_000
96+
FixedDelayInMinutes, 180_000
97+
""")
9898
void fixedDelayTask(@NameToClass Class<?> beanClass, long expectedInterval) {
9999
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
100100
BeanDefinition targetDefinition = new RootBeanDefinition(beanClass);
@@ -123,11 +123,11 @@ void fixedDelayTask(@NameToClass Class<?> beanClass, long expectedInterval) {
123123
}
124124

125125
@ParameterizedTest
126-
@CsvSource({
127-
"FixedRate, 3000",
128-
"FixedRateInSeconds, 5000",
129-
"FixedRateInMinutes, 180000"
130-
})
126+
@CsvSource(textBlock = """
127+
FixedRate, 3_000
128+
FixedRateInSeconds, 5_000
129+
FixedRateInMinutes, 180_000
130+
""")
131131
void fixedRateTask(@NameToClass Class<?> beanClass, long expectedInterval) {
132132
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
133133
BeanDefinition targetDefinition = new RootBeanDefinition(beanClass);
@@ -158,11 +158,11 @@ void fixedRateTask(@NameToClass Class<?> beanClass, long expectedInterval) {
158158
}
159159

160160
@ParameterizedTest
161-
@CsvSource({
162-
"FixedRateWithInitialDelay, 1000, 3000",
163-
"FixedRateWithInitialDelayInSeconds, 5000, 3000",
164-
"FixedRateWithInitialDelayInMinutes, 60000, 180000"
165-
})
161+
@CsvSource(textBlock = """
162+
FixedRateWithInitialDelay, 1_000, 3_000
163+
FixedRateWithInitialDelayInSeconds, 5_000, 3_000
164+
FixedRateWithInitialDelayInMinutes, 60_000, 180_000
165+
""")
166166
void fixedRateTaskWithInitialDelay(@NameToClass Class<?> beanClass, long expectedInitialDelay, long expectedInterval) {
167167
BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
168168
BeanDefinition targetDefinition = new RootBeanDefinition(beanClass);
@@ -252,15 +252,15 @@ private void severalFixedRates(StaticApplicationContext context,
252252
assertThat(targetObject).isEqualTo(target);
253253
assertThat(targetMethod.getName()).isEqualTo("fixedRate");
254254
assertThat(task1.getInitialDelay()).isEqualTo(0);
255-
assertThat(task1.getInterval()).isEqualTo(4000L);
255+
assertThat(task1.getInterval()).isEqualTo(4_000L);
256256
IntervalTask task2 = fixedRateTasks.get(1);
257257
ScheduledMethodRunnable runnable2 = (ScheduledMethodRunnable) task2.getRunnable();
258258
targetObject = runnable2.getTarget();
259259
targetMethod = runnable2.getMethod();
260260
assertThat(targetObject).isEqualTo(target);
261261
assertThat(targetMethod.getName()).isEqualTo("fixedRate");
262-
assertThat(task2.getInitialDelay()).isEqualTo(2000L);
263-
assertThat(task2.getInterval()).isEqualTo(4000L);
262+
assertThat(task2.getInitialDelay()).isEqualTo(2_000L);
263+
assertThat(task2.getInterval()).isEqualTo(4_000L);
264264
}
265265

266266
@Test
@@ -407,7 +407,7 @@ void metaAnnotationWithFixedRate() {
407407
Method targetMethod = runnable.getMethod();
408408
assertThat(targetObject).isEqualTo(target);
409409
assertThat(targetMethod.getName()).isEqualTo("checkForUpdates");
410-
assertThat(task.getInterval()).isEqualTo(5000L);
410+
assertThat(task.getInterval()).isEqualTo(5_000L);
411411
}
412412

413413
@Test
@@ -434,8 +434,8 @@ void composedAnnotationWithInitialDelayAndFixedRate() {
434434
Method targetMethod = runnable.getMethod();
435435
assertThat(targetObject).isEqualTo(target);
436436
assertThat(targetMethod.getName()).isEqualTo("checkForUpdates");
437-
assertThat(task.getInterval()).isEqualTo(5000L);
438-
assertThat(task.getInitialDelay()).isEqualTo(1000L);
437+
assertThat(task.getInterval()).isEqualTo(5_000L);
438+
assertThat(task.getInitialDelay()).isEqualTo(1_000L);
439439
}
440440

441441
@Test
@@ -517,12 +517,12 @@ void propertyPlaceholderWithInactiveCron() {
517517
}
518518

519519
@ParameterizedTest
520-
@CsvSource({
521-
"PropertyPlaceholderWithFixedDelay, 5000, 1000, 5000, 1000",
522-
"PropertyPlaceholderWithFixedDelay, PT5S, PT1S, 5000, 1000",
523-
"PropertyPlaceholderWithFixedDelayInSeconds, 5000, 1000, 5000000, 1000000",
524-
"PropertyPlaceholderWithFixedDelayInSeconds, PT5S, PT1S, 5000, 1000"
525-
})
520+
@CsvSource(textBlock = """
521+
PropertyPlaceholderWithFixedDelay, 5000, 1000, 5_000, 1_000
522+
PropertyPlaceholderWithFixedDelay, PT5S, PT1S, 5_000, 1_000
523+
PropertyPlaceholderWithFixedDelayInSeconds, 5000, 1000, 5_000_000, 1_000_000
524+
PropertyPlaceholderWithFixedDelayInSeconds, PT5S, PT1S, 5_000, 1_000
525+
""")
526526
void propertyPlaceholderWithFixedDelay(@NameToClass Class<?> beanClass, String fixedDelay, String initialDelay,
527527
long expectedInterval, long expectedInitialDelay) {
528528

@@ -561,12 +561,12 @@ void propertyPlaceholderWithFixedDelay(@NameToClass Class<?> beanClass, String f
561561
}
562562

563563
@ParameterizedTest
564-
@CsvSource({
565-
"PropertyPlaceholderWithFixedRate, 3000, 1000, 3000, 1000",
566-
"PropertyPlaceholderWithFixedRate, PT3S, PT1S, 3000, 1000",
567-
"PropertyPlaceholderWithFixedRateInSeconds, 3000, 1000, 3000000, 1000000",
568-
"PropertyPlaceholderWithFixedRateInSeconds, PT3S, PT1S, 3000, 1000"
569-
})
564+
@CsvSource(textBlock = """
565+
PropertyPlaceholderWithFixedRate, 3000, 1000, 3_000, 1_000
566+
PropertyPlaceholderWithFixedRate, PT3S, PT1S, 3_000, 1_000
567+
PropertyPlaceholderWithFixedRateInSeconds, 3000, 1000, 3_000_000, 1_000_000
568+
PropertyPlaceholderWithFixedRateInSeconds, PT3S, PT1S, 3_000, 1_000
569+
""")
570570
void propertyPlaceholderWithFixedRate(@NameToClass Class<?> beanClass, String fixedRate, String initialDelay,
571571
long expectedInterval, long expectedInitialDelay) {
572572

@@ -728,7 +728,7 @@ void nonEmptyParamList() {
728728

729729
static class FixedDelay {
730730

731-
@Scheduled(fixedDelay = 5000)
731+
@Scheduled(fixedDelay = 5_000)
732732
void fixedDelay() {
733733
}
734734
}
@@ -750,7 +750,7 @@ void fixedDelay() {
750750

751751
static class FixedRate {
752752

753-
@Scheduled(fixedRate = 3000)
753+
@Scheduled(fixedRate = 3_000)
754754
void fixedRate() {
755755
}
756756
}
@@ -772,7 +772,7 @@ void fixedRate() {
772772

773773
static class FixedRateWithInitialDelay {
774774

775-
@Scheduled(fixedRate = 3000, initialDelay = 1000)
775+
@Scheduled(fixedRate = 3_000, initialDelay = 1_000)
776776
void fixedRate() {
777777
}
778778
}
@@ -794,16 +794,16 @@ void fixedRate() {
794794

795795
static class SeveralFixedRatesWithSchedulesContainerAnnotationTestBean {
796796

797-
@Schedules({@Scheduled(fixedRate = 4000), @Scheduled(fixedRate = 4000, initialDelay = 2000)})
797+
@Schedules({@Scheduled(fixedRate = 4_000), @Scheduled(fixedRate = 4_000, initialDelay = 2_000)})
798798
void fixedRate() {
799799
}
800800
}
801801

802802

803803
static class SeveralFixedRatesWithRepeatedScheduledAnnotationTestBean {
804804

805-
@Scheduled(fixedRate = 4000)
806-
@Scheduled(fixedRate = 4000, initialDelay = 2000)
805+
@Scheduled(fixedRate = 4_000)
806+
@Scheduled(fixedRate = 4_000, initialDelay = 2_000)
807807
void fixedRate() {
808808
}
809809

@@ -819,8 +819,8 @@ static SeveralFixedRatesWithRepeatedScheduledAnnotationTestBean nestedProxy() {
819819

820820
static class FixedRatesBaseBean {
821821

822-
@Scheduled(fixedRate = 4000)
823-
@Scheduled(fixedRate = 4000, initialDelay = 2000)
822+
@Scheduled(fixedRate = 4_000)
823+
@Scheduled(fixedRate = 4_000, initialDelay = 2_000)
824824
void fixedRate() {
825825
}
826826
}
@@ -832,8 +832,8 @@ static class FixedRatesSubBean extends FixedRatesBaseBean {
832832

833833
interface FixedRatesDefaultMethod {
834834

835-
@Scheduled(fixedRate = 4000)
836-
@Scheduled(fixedRate = 4000, initialDelay = 2000)
835+
@Scheduled(fixedRate = 4_000)
836+
@Scheduled(fixedRate = 4_000, initialDelay = 2_000)
837837
default void fixedRate() {
838838
}
839839
}
@@ -916,13 +916,13 @@ void invalid() {
916916

917917
static class NonEmptyParamListTestBean {
918918

919-
@Scheduled(fixedRate = 3000)
919+
@Scheduled(fixedRate = 3_000)
920920
void invalid(String oops) {
921921
}
922922
}
923923

924924

925-
@Scheduled(fixedRate = 5000)
925+
@Scheduled(fixedRate = 5_000)
926926
@Target(ElementType.METHOD)
927927
@Retention(RetentionPolicy.RUNTIME)
928928
private @interface EveryFiveSeconds {
@@ -934,7 +934,7 @@ void invalid(String oops) {
934934
private @interface Hourly {
935935
}
936936

937-
@Scheduled(initialDelay = 1000)
937+
@Scheduled(initialDelay = 1_000)
938938
@Retention(RetentionPolicy.RUNTIME)
939939
private @interface WaitASec {
940940

@@ -956,7 +956,7 @@ void checkForUpdates() {
956956

957957
static class ComposedAnnotationFixedRateTestBean {
958958

959-
@WaitASec(fixedRate = 5000)
959+
@WaitASec(fixedRate = 5_000)
960960
void checkForUpdates() {
961961
}
962962
}

spring-core/src/test/java/org/springframework/util/ClassUtilsTests.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -155,24 +155,24 @@ public Class<?> loadClass(String name) throws ClassNotFoundException {
155155
}
156156

157157
@ParameterizedTest
158-
@CsvSource({
159-
"boolean, boolean",
160-
"byte, byte",
161-
"char, char",
162-
"short, short",
163-
"int, int",
164-
"long, long",
165-
"float, float",
166-
"double, double",
167-
"[Z, boolean[]",
168-
"[B, byte[]",
169-
"[C, char[]",
170-
"[S, short[]",
171-
"[I, int[]",
172-
"[J, long[]",
173-
"[F, float[]",
174-
"[D, double[]"
175-
})
158+
@CsvSource(textBlock = """
159+
boolean, boolean
160+
byte, byte
161+
char, char
162+
short, short
163+
int, int
164+
long, long
165+
float, float
166+
double, double
167+
[Z, boolean[]
168+
[B, byte[]
169+
[C, char[]
170+
[S, short[]
171+
[I, int[]
172+
[J, long[]
173+
[F, float[]
174+
[D, double[]
175+
""")
176176
void resolvePrimitiveClassName(String input, Class<?> output) {
177177
assertThat(ClassUtils.resolvePrimitiveClassName(input)).isEqualTo(output);
178178
}

spring-web/src/test/java/org/springframework/core/convert/support/IntegerToEnumConverterFactoryTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ class IntegerToEnumConverterFactoryTests {
3737

3838

3939
@ParameterizedTest
40-
@CsvSource({
41-
"0, RED",
42-
"1, BLUE",
43-
"2, GREEN"
44-
})
40+
@CsvSource(textBlock = """
41+
0, RED
42+
1, BLUE
43+
2, GREEN
44+
""")
4545
void convertsIntegerToEnum(int index, Color color) {
4646
assertThat(converter.convert(index)).isEqualTo(color);
4747
}

spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/SockJsUrlInfoTests.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,28 @@ void sessionId() throws Exception {
4848
}
4949

5050
@ParameterizedTest
51-
@CsvSource( {
52-
"http, http",
53-
"https, https",
54-
"ws, http",
55-
"wss, https",
56-
})
51+
@CsvSource(textBlock = """
52+
http, http
53+
https, https
54+
ws, http
55+
wss, https
56+
""")
5757
void infoUrl(String scheme, String expectedScheme) throws Exception {
5858
SockJsUrlInfo info = new SockJsUrlInfo(new URI(scheme + "://example.com"));
5959
assertThat(info.getInfoUrl()).isEqualTo(new URI(expectedScheme + "://example.com/info"));
6060
}
6161

6262
@ParameterizedTest
63-
@CsvSource( {
64-
"http, http, XHR_STREAMING",
65-
"http, ws, WEBSOCKET",
66-
"https, https, XHR_STREAMING",
67-
"https, wss, WEBSOCKET",
68-
"ws, http, XHR_STREAMING",
69-
"ws, ws, WEBSOCKET",
70-
"wss, https, XHR_STREAMING",
71-
"wss, wss, WEBSOCKET"
72-
})
63+
@CsvSource(textBlock = """
64+
http, http, XHR_STREAMING
65+
http, ws, WEBSOCKET
66+
https, https, XHR_STREAMING
67+
https, wss, WEBSOCKET
68+
ws, http, XHR_STREAMING
69+
ws, ws, WEBSOCKET
70+
wss, https, XHR_STREAMING
71+
wss, wss, WEBSOCKET
72+
""")
7373
void transportUrl(String scheme, String expectedScheme, TransportType transportType) throws Exception {
7474
SockJsUrlInfo info = new SockJsUrlInfo(new URI(scheme + "://example.com"));
7575
String serverId = info.getServerId();

0 commit comments

Comments
 (0)