SnowflakeUtilTest.java 779 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
package com.kwan.springbootkwan.utils;

import com.kwan.springbootkwan.SpringBootKwanApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@ContextConfiguration(classes = SpringBootKwanApplication.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class SnowflakeUtilTest {
    @Test
    public void testName() {
        // 传入机器ID和数据中心ID
        SnowflakeUtil snowflake = new SnowflakeUtil(1, 1);
        long id = snowflake.nextId();
        System.out.println("Generated ID: " + id);
    }
}