Skip to content

Commit 2401a0f

Browse files
committed
GH-9996: Remove deprecated in SF @Repeat usage
Related to: #9996 The `@Repeat` in Spring Framework is deprecated in favor of JUnit Jupiter `@RepeatedTest`. However, that looks like we don't need to repeat our tests at all. * Some other minor clear up in the affected classes
1 parent 85fc64b commit 2401a0f

File tree

4 files changed

+20
-35
lines changed

4 files changed

+20
-35
lines changed

spring-integration-file/src/test/java/org/springframework/integration/file/FileReadingMessageSourceIntegrationTests.java

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@
2525
import org.junit.jupiter.api.Test;
2626
import org.junit.jupiter.api.io.TempDir;
2727

28-
import org.springframework.beans.DirectFieldAccessor;
2928
import org.springframework.beans.factory.annotation.Autowired;
29+
import org.springframework.integration.test.util.TestUtils;
3030
import org.springframework.messaging.Message;
3131
import org.springframework.test.annotation.DirtiesContext;
32-
import org.springframework.test.annotation.Repeat;
3332
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
3433

3534
import static org.assertj.core.api.Assertions.assertThat;
@@ -66,8 +65,7 @@ public void cleanupInputDir() {
6665

6766
@Test
6867
public void configured() {
69-
DirectFieldAccessor accessor = new DirectFieldAccessor(pollableFileSource);
70-
assertThat(accessor.getPropertyValue("directory")).isEqualTo(inputDir);
68+
assertThat(TestUtils.getPropertyValue(this.pollableFileSource, "directory")).isEqualTo(inputDir);
7169
}
7270

7371
@Test
@@ -107,7 +105,6 @@ public void inputDirExhausted() {
107105
}
108106

109107
@Test
110-
@Repeat(5)
111108
public void concurrentProcessing() {
112109
CountDownLatch go = new CountDownLatch(1);
113110
Runnable successfulConsumer = () -> {
@@ -148,26 +145,21 @@ public void concurrentProcessing() {
148145
* @return a latch that will be counted down once all threads have run their
149146
* runnable.
150147
*/
151-
private CountDownLatch doConcurrently(int numberOfThreads, final Runnable runnable, final CountDownLatch start) {
148+
private CountDownLatch doConcurrently(int numberOfThreads, Runnable runnable, CountDownLatch start) {
152149
final CountDownLatch started = new CountDownLatch(numberOfThreads);
153150
final CountDownLatch done = new CountDownLatch(numberOfThreads);
154151
for (int i = 0; i < numberOfThreads; i++) {
155-
new Thread(new Runnable() {
156-
157-
@Override
158-
public void run() {
159-
started.countDown();
160-
try {
161-
started.await();
162-
start.await();
163-
}
164-
catch (InterruptedException e) {
165-
Thread.currentThread().interrupt();
166-
}
167-
runnable.run();
168-
done.countDown();
152+
new Thread(() -> {
153+
started.countDown();
154+
try {
155+
started.await();
156+
start.await();
169157
}
170-
158+
catch (InterruptedException e) {
159+
Thread.currentThread().interrupt();
160+
}
161+
runnable.run();
162+
done.countDown();
171163
}).start();
172164
}
173165
return done;

spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/mysql/MySqlJdbcMessageStoreTests.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
import org.springframework.messaging.Message;
5050
import org.springframework.messaging.support.GenericMessage;
5151
import org.springframework.test.annotation.DirtiesContext;
52-
import org.springframework.test.annotation.Repeat;
5352
import org.springframework.test.annotation.Rollback;
5453
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
5554
import org.springframework.transaction.PlatformTransactionManager;
@@ -263,7 +262,7 @@ public void testRemoveMessageGroup() {
263262

264263
String uuidGroupId = UUIDConverter.getUUID(groupId).toString();
265264
assertThat(template.queryForList(
266-
"SELECT * from INT_GROUP_TO_MESSAGE where GROUP_KEY = '" + uuidGroupId + "'").size() == 0).isTrue();
265+
"SELECT * from INT_GROUP_TO_MESSAGE where GROUP_KEY = '" + uuidGroupId + "'")).isEmpty();
267266
}
268267

269268
@Test
@@ -400,7 +399,6 @@ public void testMessagePollingFromTheGroup() throws Exception {
400399
@Test
401400
@Transactional
402401
@Rollback(false)
403-
@Repeat(20)
404402
public void testSameMessageToMultipleGroups() {
405403
final String group1Id = "group1";
406404
final String group2Id = "group2";
@@ -440,7 +438,6 @@ public void testSameMessageToMultipleGroups() {
440438
@Test
441439
@Transactional
442440
@Rollback(false)
443-
@Repeat(20)
444441
public void testSameMessageAndGroupToMultipleRegions() {
445442
final String groupId = "myGroup";
446443
final String region1 = "region1";
@@ -545,7 +542,8 @@ PlatformTransactionManager transactionManager() {
545542
DataSourceInitializer dataSourceInitializer() {
546543
DataSourceInitializer dataSourceInitializer = new DataSourceInitializer();
547544
dataSourceInitializer.setDataSource(dataSource());
548-
dataSourceInitializer.setDatabasePopulator(new ResourceDatabasePopulator(this.dropSchemaScript, this.createSchemaScript));
545+
dataSourceInitializer.setDatabasePopulator(
546+
new ResourceDatabasePopulator(this.dropSchemaScript, this.createSchemaScript));
549547
return dataSourceInitializer;
550548
}
551549

spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/oracle/OracleJdbcMessageStoreTests.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import org.springframework.messaging.Message;
4646
import org.springframework.messaging.support.GenericMessage;
4747
import org.springframework.test.annotation.DirtiesContext;
48-
import org.springframework.test.annotation.Repeat;
4948
import org.springframework.test.annotation.Rollback;
5049
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
5150
import org.springframework.transaction.PlatformTransactionManager;
@@ -260,7 +259,7 @@ public void testRemoveMessageGroup() {
260259

261260
String uuidGroupId = UUIDConverter.getUUID(groupId).toString();
262261
assertThat(template.queryForList(
263-
"SELECT * from INT_GROUP_TO_MESSAGE where GROUP_KEY = '" + uuidGroupId + "'").size() == 0).isTrue();
262+
"SELECT * from INT_GROUP_TO_MESSAGE where GROUP_KEY = '" + uuidGroupId + "'")).isEmpty();
264263
}
265264

266265
@Test
@@ -397,7 +396,6 @@ public void testMessagePollingFromTheGroup() throws Exception {
397396
@Test
398397
@Transactional
399398
@Rollback(false)
400-
@Repeat(20)
401399
public void testSameMessageToMultipleGroups() {
402400
final String group1Id = "group1";
403401
final String group2Id = "group2";
@@ -437,7 +435,6 @@ public void testSameMessageToMultipleGroups() {
437435
@Test
438436
@Transactional
439437
@Rollback(false)
440-
@Repeat(20)
441438
public void testSameMessageAndGroupToMultipleRegions() {
442439
final String groupId = "myGroup";
443440
final String region1 = "region1";

spring-integration-jdbc/src/test/java/org/springframework/integration/jdbc/store/JdbcMessageStoreChannelIntegrationTests.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.springframework.messaging.MessageDeliveryException;
3737
import org.springframework.messaging.support.GenericMessage;
3838
import org.springframework.test.annotation.DirtiesContext;
39-
import org.springframework.test.annotation.Repeat;
4039
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
4140
import org.springframework.transaction.PlatformTransactionManager;
4241
import org.springframework.transaction.support.DefaultTransactionDefinition;
@@ -98,7 +97,7 @@ public void tearDown() {
9897
public void testSendAndActivate() throws Exception {
9998
input.send(new GenericMessage<>("foo"));
10099
Service.await(10000);
101-
assertThat(Service.messages.size()).isEqualTo(1);
100+
assertThat(Service.messages).hasSize(1);
102101
}
103102

104103
@Test
@@ -124,7 +123,6 @@ public void testSendAndActivateWithRollback() throws Exception {
124123
}
125124

126125
@Test
127-
@Repeat(2)
128126
public void testTransactionalSendAndReceive() throws Exception {
129127

130128
boolean result = new TransactionTemplate(transactionManager).execute(status -> {
@@ -168,7 +166,7 @@ public void testTransactionalSendAndReceive() throws Exception {
168166

169167
protected void waitForMessage() throws InterruptedException {
170168
int n = 0;
171-
while (Service.messages.size() == 0) {
169+
while (Service.messages.isEmpty()) {
172170
if (n++ > 200) {
173171
fail("Message not received by Service");
174172
}
@@ -223,7 +221,7 @@ public void testSameTransactionSendAndReceive() {
223221
assertThat(Service.messages.size()).isEqualTo(0);
224222

225223
// If the poll blocks in the RDBMS there is no way for the queue to respect the timeout
226-
assertThat(stopWatch.getTotalTimeMillis() < 1000).as("Timed out waiting for receive").isTrue();
224+
assertThat(stopWatch.getTotalTimeMillis()).as("Timed out waiting for receive").isLessThan(1000);
227225

228226
}
229227

0 commit comments

Comments
 (0)