package com.nokia.sms;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Slf4j
@TestConfiguration
public class TestConfig {
    public static final int corePoolSize = 100;
    public static final int maximumPoolSize = corePoolSize;

    @Bean
    public ThreadPoolExecutor requestExecutor() {
        ThreadPoolExecutor t = new ThreadPoolExecutor(corePoolSize, maximumPoolSize,
                0L, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<>(), new CustomizableThreadFactory("request-"));
        t.prestartAllCoreThreads();
        return t;
    }
}
