Skip to content

Commit

Permalink
[FIX] EmbeddedRedisConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
jhhong0509 committed May 2, 2021
1 parent bfbd2b4 commit b595f71
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
import javax.annotation.PreDestroy;

@Configuration
@Profile("local")
@Profile("test")
public class EmbeddedRedisConfig {

private final RedisServer redisServer;

public EmbeddedRedisConfig(@Value("${spring.redis.port}") int redisPort) {
@Value("${spring.redis.port}")
int redisPort;

public EmbeddedRedisConfig() {
this.redisServer = RedisServer.builder()
.setting("maxheap 128M")
.build();
Expand All @@ -27,7 +30,8 @@ public void runRedis() {

@PreDestroy
public void stopRedis() {
redisServer.stop();
if(redisServer != null)
redisServer.stop();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.dsmpear.main.user_backend_v2;

import com.dsmpear.main.user_backend_v2.config.EmbeddedRedisConfig;
import com.dsmpear.main.user_backend_v2.entity.user.UserRepository;
import com.dsmpear.main.user_backend_v2.entity.verifynumber.VerifyNumber;
import com.dsmpear.main.user_backend_v2.entity.verifynumber.VerifyNumberRepository;
import com.dsmpear.main.user_backend_v2.payload.request.EmailVerifyRequest;
Expand All @@ -10,7 +12,11 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Import;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
Expand All @@ -23,6 +29,7 @@
@ExtendWith(SpringExtension.class)
@SpringBootTest
@ActiveProfiles("test")
@EnableAutoConfiguration
public class EmailControllerTest {

private MockMvc mvc;
Expand Down

0 comments on commit b595f71

Please sign in to comment.