Skip to content

Commit d7fcec1

Browse files
committed
Remove the use of a bean override form SampleKafkaApplicationTests
See gh-13609
1 parent 8cc0d55 commit d7fcec1

File tree

1 file changed

+5
-26
lines changed

1 file changed

+5
-26
lines changed

Diff for: spring-boot-samples/spring-boot-sample-kafka/src/test/java/sample/kafka/SampleKafkaApplicationTests.java

+5-26
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,12 @@
1515
*/
1616
package sample.kafka;
1717

18-
import java.util.concurrent.CountDownLatch;
19-
import java.util.concurrent.TimeUnit;
20-
2118
import org.junit.Rule;
2219
import org.junit.Test;
2320
import org.junit.runner.RunWith;
2421

2522
import org.springframework.boot.test.context.SpringBootTest;
26-
import org.springframework.boot.test.context.TestConfiguration;
2723
import org.springframework.boot.test.rule.OutputCapture;
28-
import org.springframework.context.annotation.Bean;
2924
import org.springframework.kafka.test.context.EmbeddedKafka;
3025
import org.springframework.test.context.junit4.SpringRunner;
3126

@@ -43,34 +38,18 @@
4338
@EmbeddedKafka
4439
public class SampleKafkaApplicationTests {
4540

46-
private static final CountDownLatch latch = new CountDownLatch(1);
47-
4841
@Rule
4942
public OutputCapture outputCapture = new OutputCapture();
5043

5144
@Test
5245
public void testVanillaExchange() throws Exception {
53-
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
46+
long end = System.currentTimeMillis() + 10000;
47+
while (!this.outputCapture.toString().contains("A simple test message")
48+
&& System.currentTimeMillis() < end) {
49+
Thread.sleep(250);
50+
}
5451
assertThat(this.outputCapture.toString().contains("A simple test message"))
5552
.isTrue();
5653
}
5754

58-
@TestConfiguration
59-
public static class Config {
60-
61-
@Bean
62-
public Consumer consumer() {
63-
return new Consumer() {
64-
65-
@Override
66-
public void processMessage(SampleMessage message) {
67-
super.processMessage(message);
68-
latch.countDown();
69-
}
70-
71-
};
72-
}
73-
74-
}
75-
7655
}

0 commit comments

Comments
 (0)