Commit a52e759b authored by Stephen Nimmo's avatar Stephen Nimmo
Browse files

Added TopicAdminServiceTest to test topic creation with testcontainers

parent a2763692
Pipeline #69455 failed with stages
in 3 minutes and 19 seconds
......@@ -113,6 +113,11 @@
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka-test</artifactId>
......
......@@ -27,7 +27,6 @@ import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
@Component
public class StorageClientFactory extends AbstractFactoryBean<IStorageFactory> {
......
package org.opengroup.osdu.streaming.service;
import org.apache.kafka.clients.admin.NewTopic;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.opengroup.osdu.streaming.model.StreamRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.testcontainers.containers.KafkaContainer;
import org.testcontainers.utility.DockerImageName;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class TopicAdminServiceTest {
@ClassRule
public static KafkaContainer kafka =
new KafkaContainer(DockerImageName.parse("confluentinc/cp-kafka:5.4.3"));
@Autowired
private TopicAdminService topicAdminService;
@Test
public void topicCreation() {
StreamRecord streamRecord = new StreamRecord();
streamRecord.setKind("test");
NewTopic newTopic = topicAdminService.createTopic(streamRecord);
assertThat(newTopic).isNotNull();
assertThat(newTopic.name()).isEqualTo("test");
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment