Skip to content

Commit

Permalink
add: test for config
Browse files Browse the repository at this point in the history
  • Loading branch information
JingkaiTang committed Dec 5, 2024
1 parent bcea493 commit ae461af
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.tencent.trpc.core.worker.WorkerPoolManager;
import java.util.HashMap;
import java.util.Map;

import org.junit.Assert;
import org.junit.Test;

public class ThreadPoolConfigTest {
Expand All @@ -36,6 +38,7 @@ public void test() {
config.setNamePrefix("namePrefix");
config.setUseFiber(Boolean.TRUE);
config.setShareSchedule(Boolean.TRUE);
config.setUseVirtualThread(Boolean.FALSE);
assertFalse(config.isAllowCoreThreadTimeOut());
assertEquals(50, config.getCloseTimeout());
assertEquals(40, config.getCorePoolSize());
Expand Down Expand Up @@ -82,4 +85,19 @@ public void testParse() {
assertTrue(config.useFiber());
assertTrue(config.isShareSchedule());
}

@Test
public void testValidate() {
ThreadPoolConfig config = new ThreadPoolConfig();
config.setCorePoolSize(-1);
Assert.assertThrows(IllegalArgumentException.class, config::validate);
config.setCorePoolSize(0);
config.setQueueSize(-1);
Assert.assertThrows(IllegalArgumentException.class, config::validate);
config.setQueueSize(0);
config.setCloseTimeout(-1);
Assert.assertThrows(IllegalArgumentException.class, config::validate);
config.setCloseTimeout(0);
config.validate();
}
}

0 comments on commit ae461af

Please sign in to comment.