Skip to content

Commit

Permalink
fix : 테스트 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hyun2371 committed Jan 17, 2024
1 parent a9c0d78 commit 4078cea
Showing 1 changed file with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.StringRedisTemplate;

@SpringBootTest
class MemberWaitingServiceIntegrationTest {
Expand All @@ -36,9 +34,6 @@ class MemberWaitingServiceIntegrationTest {
@Autowired
private MemberWaitingService memberWaitingService;

@Autowired
private StringRedisTemplate redisTemplate;

private Shop shop;
private CreateWaitingRequest request;

Expand All @@ -53,15 +48,10 @@ void setUp() {
ownerRepository.save(owner);
}

@AfterEach
void clear() {
redisTemplate.delete("s" + shop.getId());
}

@DisplayName("동시에 50개 요청이 들어와도 각각 다른 대기번호를 부여한다.")
@DisplayName("동시에 30개 요청이 들어와도 각각 다른 대기번호를 부여한다.")
@Test
void createWaitingNumberConcurrency() throws InterruptedException {
int threadCount = 50;
int threadCount = 30;
ExecutorService executorService = Executors.newFixedThreadPool(32);
CountDownLatch latch = new CountDownLatch(
threadCount); // 다른 thread에서 수행 중인 작업이 완료될 때까지 대기할 수 있도록 돕는 클래스
Expand All @@ -85,6 +75,6 @@ void createWaitingNumberConcurrency() throws InterruptedException {

int waitingCount = shopRepository.findById(shop.getId()).orElseThrow().getWaitingCount();

assertEquals(50, waitingCount);
assertEquals(30, waitingCount);
}
}

0 comments on commit 4078cea

Please sign in to comment.