File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
src/test/java/com/madadipouya/springkafkatest/kafka Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 66import org .apache .kafka .clients .producer .Producer ;
77import org .apache .kafka .clients .producer .ProducerRecord ;
88import org .apache .kafka .common .serialization .StringSerializer ;
9+ import org .junit .jupiter .api .AfterAll ;
910import org .junit .jupiter .api .BeforeAll ;
1011import org .junit .jupiter .api .Test ;
1112import org .junit .jupiter .api .TestInstance ;
2728import static org .mockito .Mockito .timeout ;
2829import static org .mockito .Mockito .verify ;
2930
30- @ SpringBootTest
31- @ EmbeddedKafka ( ports = 9092 )
31+ @ EmbeddedKafka
32+ @ SpringBootTest ( properties = "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}" )
3233@ TestInstance (TestInstance .Lifecycle .PER_CLASS )
3334class UserKafkaConsumerTest {
3435
@@ -85,4 +86,9 @@ void testLogKafkaMessages() throws JsonProcessingException {
8586 assertEquals (0 , partitionArgumentCaptor .getValue ());
8687 assertEquals (0 , offsetArgumentCaptor .getValue ());
8788 }
89+
90+ @ AfterAll
91+ void shutdown () {
92+ producer .close ();
93+ }
8894}
Original file line number Diff line number Diff line change 2828import static org .junit .jupiter .api .Assertions .assertEquals ;
2929import static org .junit .jupiter .api .Assertions .assertNotNull ;
3030
31- @ SpringBootTest
32- @ EmbeddedKafka ( ports = 9092 )
31+ @ EmbeddedKafka
32+ @ SpringBootTest ( properties = "spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}" )
3333@ TestInstance (TestInstance .Lifecycle .PER_CLASS )
3434class UserKafkaProducerTest {
3535
You can’t perform that action at this time.
0 commit comments