-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 테스트 환경에서 캐싱을 사용하도록 하여 환경 통일
- Loading branch information
Showing
5 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package reviewme.support; | ||
|
||
import java.util.Objects; | ||
import org.springframework.cache.Cache; | ||
import org.springframework.cache.CacheManager; | ||
|
||
public class CacheCleaner { | ||
|
||
private final CacheManager cacheManager; | ||
|
||
public CacheCleaner(CacheManager cacheManager) { | ||
this.cacheManager = cacheManager; | ||
} | ||
|
||
public void execute() { | ||
cacheManager.getCacheNames() | ||
.stream() | ||
.map(cacheManager::getCache) | ||
.filter(Objects::nonNull) | ||
.forEach(Cache::clear); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
backend/src/test/java/reviewme/support/CacheCleanerExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package reviewme.support; | ||
|
||
import org.junit.jupiter.api.extension.BeforeEachCallback; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
|
||
public class CacheCleanerExtension implements BeforeEachCallback { | ||
|
||
@Override | ||
public void beforeEach(ExtensionContext extensionContext) { | ||
SpringExtension.getApplicationContext(extensionContext) | ||
.getBean(CacheCleaner.class) | ||
.execute(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ spring: | |
flyway: | ||
enabled: false | ||
cache: | ||
type: none | ||
type: simple | ||
|
||
springdoc: | ||
swagger-ui: | ||
|