mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix test
This commit is contained in:
parent
163ce2a67c
commit
b048cc7fd7
@ -2,7 +2,6 @@ package cn.hutool.core.lang;
|
||||
|
||||
import cn.hutool.core.collection.ConcurrentHashSet;
|
||||
import cn.hutool.core.exceptions.UtilException;
|
||||
import cn.hutool.core.thread.ConcurrencyTester;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@ -56,10 +55,10 @@ public class SnowflakeTest {
|
||||
@Ignore
|
||||
public void uniqueTest(){
|
||||
// 测试并发环境下生成ID是否重复
|
||||
Snowflake snowflake = IdUtil.createSnowflake(0, 0);
|
||||
Snowflake snowflake = IdUtil.getSnowflake(0, 0);
|
||||
|
||||
Set<Long> ids = new ConcurrentHashSet<>();
|
||||
ConcurrencyTester tester = ThreadUtil.concurrencyTest(100, () -> {
|
||||
ThreadUtil.concurrencyTest(100, () -> {
|
||||
for (int i = 0; i < 5000; i++) {
|
||||
if(false == ids.add(snowflake.nextId())){
|
||||
throw new UtilException("重复ID!");
|
||||
|
@ -68,8 +68,8 @@ public class IdUtilTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createSnowflakeTest() {
|
||||
Snowflake snowflake = IdUtil.createSnowflake(1, 1);
|
||||
public void getSnowflakeTest() {
|
||||
Snowflake snowflake = IdUtil.getSnowflake(1, 1);
|
||||
long id = snowflake.nextId();
|
||||
Assert.assertTrue(id > 0);
|
||||
}
|
||||
@ -78,7 +78,7 @@ public class IdUtilTest {
|
||||
@Ignore
|
||||
public void snowflakeBenchTest() {
|
||||
final Set<Long> set = new ConcurrentHashSet<>();
|
||||
final Snowflake snowflake = IdUtil.createSnowflake(1, 1);
|
||||
final Snowflake snowflake = IdUtil.getSnowflake(1, 1);
|
||||
|
||||
//线程数
|
||||
int threadCount = 100;
|
||||
|
Loading…
x
Reference in New Issue
Block a user