Skip to content

Commit

Permalink
Minor test improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
tstavinoha committed Jun 17, 2021
1 parent 7d944ad commit 6db583a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.infobip.testcontainers.spring.kafka;

import static com.infobip.testcontainers.spring.kafka.Listener.TOPIC;
import static org.assertj.core.api.BDDAssertions.then;
import static org.awaitility.Awaitility.await;

Expand All @@ -22,8 +23,6 @@
@SpringBootTest(classes = Main.class)
class KafkaContainerInitializerTest {

final static String TOPIC_NAME = "test-topic";

private final KafkaTemplate<String, String> kafkaTemplate;
private final Listener listener;

Expand All @@ -33,7 +32,7 @@ void shouldCreateContainer() throws InterruptedException, ExecutionException, Ti
String givenValue = this.getClass().getName();

// when
SendResult<?, ?> actual = kafkaTemplate.send(TOPIC_NAME, "key", givenValue)
SendResult<?, ?> actual = kafkaTemplate.send(TOPIC, "key", givenValue)
.completable()
.get(10, TimeUnit.SECONDS);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.infobip.testcontainers.spring.kafka;

import static com.infobip.testcontainers.spring.kafka.Listener.TOPIC;
import static org.assertj.core.api.BDDAssertions.then;
import static org.awaitility.Awaitility.await;

Expand All @@ -23,8 +24,6 @@
@SpringBootTest(classes = Main.class)
class KafkaContainerInitializerWithStaticPortTest {

final static String TOPIC_NAME = "test-topic";

private final KafkaTemplate<String, String> kafkaTemplate;
private final Listener listener;
private final KafkaProperties kafkaProperties;
Expand All @@ -35,7 +34,7 @@ void shouldCreateContainer() throws InterruptedException, ExecutionException, Ti
String givenValue = this.getClass().getName();

// when
SendResult<?, ?> actual = kafkaTemplate.send(TOPIC_NAME, "key", givenValue)
SendResult<?, ?> actual = kafkaTemplate.send(TOPIC, "key", givenValue)
.completable()
.get(10, TimeUnit.SECONDS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
@Component
class Listener {

public static final String TOPIC = "test-topic";

private final AtomicReference<String> value = new AtomicReference<>();

@KafkaListener(topics = KafkaContainerInitializerTest.TOPIC_NAME)
@KafkaListener(topics = TOPIC)
public void handle(@Payload String value) {
this.value.set(value);
}
Expand Down

0 comments on commit 6db583a

Please sign in to comment.