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); } }