Remove the use of a bean override form SampleKafkaApplicationTests

See gh-13609
pull/13483/head
Andy Wilkinson 6 years ago
parent 8cc0d5577e
commit d7fcec1ada

@ -15,17 +15,12 @@
*/
package sample.kafka;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.rule.OutputCapture;
import org.springframework.context.annotation.Bean;
import org.springframework.kafka.test.context.EmbeddedKafka;
import org.springframework.test.context.junit4.SpringRunner;
@ -43,34 +38,18 @@ import static org.assertj.core.api.Assertions.assertThat;
@EmbeddedKafka
public class SampleKafkaApplicationTests {
private static final CountDownLatch latch = new CountDownLatch(1);
@Rule
public OutputCapture outputCapture = new OutputCapture();
@Test
public void testVanillaExchange() throws Exception {
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
long end = System.currentTimeMillis() + 10000;
while (!this.outputCapture.toString().contains("A simple test message")
&& System.currentTimeMillis() < end) {
Thread.sleep(250);
}
assertThat(this.outputCapture.toString().contains("A simple test message"))
.isTrue();
}
@TestConfiguration
public static class Config {
@Bean
public Consumer consumer() {
return new Consumer() {
@Override
public void processMessage(SampleMessage message) {
super.processMessage(message);
latch.countDown();
}
};
}
}
}

Loading…
Cancel
Save