-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTaskflowApplicationTests.java
More file actions
48 lines (40 loc) · 1.88 KB
/
TaskflowApplicationTests.java
File metadata and controls
48 lines (40 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package clap.server;
import clap.server.adapter.outbound.persistense.repository.member.MemberRepository;
import com.redis.testcontainers.RedisContainer;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.elasticsearch.ElasticsearchContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;
import static org.assertj.core.api.Assertions.assertThat;
//@DataElasticsearchTest
@Testcontainers
@SpringBootTest
class TaskflowApplicationTests {
@Autowired
private MemberRepository memberRepository;
@Container
// @ServiceConnection
public static ElasticsearchContainer ES_CONTAINER = new ElasticsearchContainer("docker.elastic.co/elasticsearch/elasticsearch:7.17.5");
@Container
@ServiceConnection
public static RedisContainer REDIS_CONTAINER = new RedisContainer(DockerImageName.parse("redis:6.2.6"));
@DynamicPropertySource
static void configureProperties(DynamicPropertyRegistry registry) {
// Elasticsearch 설정
registry.add("spring.elasticsearch.uris", ES_CONTAINER::getHttpHostAddress);
}
@Test
void contextLoads() {
assertThat(memberRepository.findAll()).isEmpty();
assertThat(ES_CONTAINER.isRunning()).isTrue();
assertThat(REDIS_CONTAINER.isRunning()).isTrue();
System.out.println("Redis: " + REDIS_CONTAINER.getHost() + ":" + REDIS_CONTAINER.getMappedPort(6379));
System.out.println("Elasticsearch URL: " + ES_CONTAINER.getHttpHostAddress());
}
}