Skip to content

Commit

Permalink
升级为junit5
Browse files Browse the repository at this point in the history
  • Loading branch information
ALI1416 committed Mar 22, 2023
1 parent 5c7036c commit 21a107e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
</dependency>
<!-- 仅供测试使用 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
30 changes: 15 additions & 15 deletions src/test/java/cn/z/id/IdTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import cn.z.clock.Clock;
import lombok.extern.slf4j.Slf4j;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;

import java.util.Arrays;
import java.util.Random;
Expand All @@ -20,15 +20,15 @@
* @author ALI[ali-k@foxmail.com]
* @since 1.0.0
**/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
@TestMethodOrder(MethodOrderer.MethodName.class)
@Slf4j
public class IdTest {
class IdTest {

/**
* 直接调用
*/
// @Test
public void test00Normal() {
void test00Normal() {
log.info("ID为:{}", Id.next());
// [main] INFO cn.z.id.Id - 预初始化...
// [main] INFO cn.z.id.Id - 初始化,MACHINE_ID为0,MACHINE_BITS为8,SEQUENCE_BITS为12
Expand All @@ -41,7 +41,7 @@ public void test00Normal() {
* 手动初始化
*/
// @Test
public void test01Init() {
void test01Init() {
Id.init(0, 8, 14);
log.info("ID为:{}", Id.next());
// [main] INFO cn.z.id.Id - 预初始化...
Expand All @@ -59,7 +59,7 @@ public void test01Init() {
* 初始化多次
*/
// @Test
public void test02InitMore() {
void test02InitMore() {
Id.init(0, 8, 13);
Id.init(0, 8, 15);
log.info("ID为:{}", Id.next());
Expand All @@ -79,7 +79,7 @@ public void test02InitMore() {
* 初始化晚了
*/
// @Test
public void test03InitLate() {
void test03InitLate() {
log.info("ID为:{}", Id.next());
Id.init(0, 8, 12);
log.info("ID为:{}", Id.next());
Expand All @@ -96,7 +96,7 @@ public void test03InitLate() {
* 初始化异常
*/
// @Test
public void test04InitException() {
void test04InitException() {
Id.init(1000, 8, 12);
log.info("ID为:{}", Id.next());
// [main] INFO cn.z.id.Id - 预初始化...
Expand All @@ -120,7 +120,7 @@ public void test04InitException() {
* 阻塞
*/
// @Test
public void test05Block() {
void test05Block() {
// 初始化,复现阻塞
Id.init(0, 0, 0);
log.info("ID为:{}", Id.next());
Expand Down Expand Up @@ -148,7 +148,7 @@ public void test05Block() {
* 时钟回拨(需要在1分钟内手动回拨时钟)
*/
// @Test
public void test06Back() {
void test06Back() {
for (int i = 0; i < 60; i++) {
log.info("ID为:{}", Id.next());
try {
Expand All @@ -170,7 +170,7 @@ public void test06Back() {
* 重置初始时间戳(需要在1分钟内手动回拨时钟)
*/
// @Test
public void test07Reset() {
void test07Reset() {
for (int i = 0; i < 60; i++) {
log.info("ID为:{}", Id.next());
try {
Expand Down Expand Up @@ -198,7 +198,7 @@ public void test07Reset() {
* 比较
*/
// @Test
public void test08Compare() {
void test08Compare() {
// 初始化,避免阻塞
Id.init(0, 0, 26);
// [main] INFO cn.z.id.Id - 预初始化...
Expand Down Expand Up @@ -278,7 +278,7 @@ void compare(int count) {
* 工具
*/
@Test
public void test09Util() {
void test09Util() {
Id.init(3, 4, 5);
// 获取配置参数
log.info(Arrays.toString(IdUtil.param())); // [3, 4, 5]
Expand Down

0 comments on commit 21a107e

Please sign in to comment.