Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

Commit 0716764

Browse files
committed
升级junit
1 parent 76394c7 commit 0716764

File tree

106 files changed

+1275
-1377
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+1275
-1377
lines changed

easyexcel-test/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@
4040
<artifactId>spring-boot-starter-test</artifactId>
4141
<version>2.7.11</version>
4242
</dependency>
43-
<dependency>
44-
<groupId>junit</groupId>
45-
<artifactId>junit</artifactId>
46-
<version>4.13.2</version>
47-
</dependency>
4843

4944
<!-- logback -->
5045
<dependency>

easyexcel-test/src/test/java/com/alibaba/easyexcel/test/core/annotation/AnnotationDataListener.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
import java.util.ArrayList;
55
import java.util.List;
66

7-
import org.junit.Assert;
8-
import org.slf4j.Logger;
9-
import org.slf4j.LoggerFactory;
10-
117
import com.alibaba.excel.context.AnalysisContext;
128
import com.alibaba.excel.event.AnalysisEventListener;
139
import com.alibaba.excel.exception.ExcelCommonException;
1410
import com.alibaba.excel.util.DateUtils;
1511
import com.alibaba.fastjson2.JSON;
1612

13+
import org.junit.jupiter.api.Assertions;
14+
import org.slf4j.Logger;
15+
import org.slf4j.LoggerFactory;
16+
1717
/**
1818
* @author Jiaju Zhuang
1919
*/
@@ -28,14 +28,14 @@ public void invoke(AnnotationData data, AnalysisContext context) {
2828

2929
@Override
3030
public void doAfterAllAnalysed(AnalysisContext context) {
31-
Assert.assertEquals(list.size(), 1);
31+
Assertions.assertEquals(list.size(), 1);
3232
AnnotationData data = list.get(0);
3333
try {
34-
Assert.assertEquals(data.getDate(), DateUtils.parseDate("2020-01-01 01:01:01"));
34+
Assertions.assertEquals(data.getDate(), DateUtils.parseDate("2020-01-01 01:01:01"));
3535
} catch (ParseException e) {
3636
throw new ExcelCommonException("Test Exception", e);
3737
}
38-
Assert.assertEquals(data.getNumber(), 99.99, 0.00);
38+
Assertions.assertEquals(data.getNumber(), 99.99, 0.00);
3939
LOGGER.debug("First row:{}", JSON.toJSONString(list.get(0)));
4040
}
4141
}

easyexcel-test/src/test/java/com/alibaba/easyexcel/test/core/annotation/AnnotationDataTest.java

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
import org.apache.poi.ss.usermodel.Sheet;
1515
import org.apache.poi.ss.usermodel.Workbook;
1616
import org.apache.poi.ss.usermodel.WorkbookFactory;
17-
import org.junit.Assert;
18-
import org.junit.BeforeClass;
19-
import org.junit.FixMethodOrder;
20-
import org.junit.Test;
21-
import org.junit.runners.MethodSorters;
17+
import org.junit.jupiter.api.Assertions;
18+
import org.junit.jupiter.api.BeforeAll;
19+
import org.junit.jupiter.api.MethodOrderer;
20+
import org.junit.jupiter.api.Test;
21+
import org.junit.jupiter.api.TestMethodOrder;
2222

2323
/**
2424
* @author Jiaju Zhuang
2525
*/
26-
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
26+
@TestMethodOrder(MethodOrderer.MethodName.class)
2727
public class AnnotationDataTest {
2828

2929
private static File file07;
@@ -32,7 +32,7 @@ public class AnnotationDataTest {
3232
private static File fileStyle07;
3333
private static File fileStyle03;
3434

35-
@BeforeClass
35+
@BeforeAll
3636
public static void init() {
3737
file07 = TestFileUtil.createNewFile("annotation07.xlsx");
3838
file03 = TestFileUtil.createNewFile("annotation03.xls");
@@ -74,24 +74,24 @@ private void writeStyle(File file) throws Exception {
7474

7575
Row row0 = sheet.getRow(0);
7676
Cell cell00 = row0.getCell(0);
77-
Assert.assertArrayEquals(new byte[] {-1, 0, -1}, StyleTestUtils.getFillForegroundColor(cell00));
78-
Assert.assertArrayEquals(new byte[] {-1, -52, 0}, StyleTestUtils.getFontColor(cell00, workbook));
79-
Assert.assertEquals(40, StyleTestUtils.getFontHeightInPoints(cell00, workbook));
77+
Assertions.assertArrayEquals(new byte[] {-1, 0, -1}, StyleTestUtils.getFillForegroundColor(cell00));
78+
Assertions.assertArrayEquals(new byte[] {-1, -52, 0}, StyleTestUtils.getFontColor(cell00, workbook));
79+
Assertions.assertEquals(40, StyleTestUtils.getFontHeightInPoints(cell00, workbook));
8080

8181
Cell cell01 = row0.getCell(1);
82-
Assert.assertArrayEquals(new byte[] {-1, 0, 0}, StyleTestUtils.getFillForegroundColor(cell01));
83-
Assert.assertArrayEquals(new byte[] {0, -1, -1}, StyleTestUtils.getFontColor(cell01, workbook));
84-
Assert.assertEquals(20, StyleTestUtils.getFontHeightInPoints(cell01, workbook));
82+
Assertions.assertArrayEquals(new byte[] {-1, 0, 0}, StyleTestUtils.getFillForegroundColor(cell01));
83+
Assertions.assertArrayEquals(new byte[] {0, -1, -1}, StyleTestUtils.getFontColor(cell01, workbook));
84+
Assertions.assertEquals(20, StyleTestUtils.getFontHeightInPoints(cell01, workbook));
8585

8686
Row row1 = sheet.getRow(1);
8787
Cell cell10 = row1.getCell(0);
88-
Assert.assertArrayEquals(new byte[] {0, -52, -1}, StyleTestUtils.getFillForegroundColor(cell10));
89-
Assert.assertArrayEquals(new byte[] {0, 0, -1}, StyleTestUtils.getFontColor(cell10, workbook));
90-
Assert.assertEquals(50, StyleTestUtils.getFontHeightInPoints(cell10, workbook));
88+
Assertions.assertArrayEquals(new byte[] {0, -52, -1}, StyleTestUtils.getFillForegroundColor(cell10));
89+
Assertions.assertArrayEquals(new byte[] {0, 0, -1}, StyleTestUtils.getFontColor(cell10, workbook));
90+
Assertions.assertEquals(50, StyleTestUtils.getFontHeightInPoints(cell10, workbook));
9191
Cell cell11 = row1.getCell(1);
92-
Assert.assertArrayEquals(new byte[] {0, -128, 0}, StyleTestUtils.getFillForegroundColor(cell11));
93-
Assert.assertArrayEquals(new byte[] {-64, -64, -64}, StyleTestUtils.getFontColor(cell11, workbook));
94-
Assert.assertEquals(30, StyleTestUtils.getFontHeightInPoints(cell11, workbook));
92+
Assertions.assertArrayEquals(new byte[] {0, -128, 0}, StyleTestUtils.getFillForegroundColor(cell11));
93+
Assertions.assertArrayEquals(new byte[] {-64, -64, -64}, StyleTestUtils.getFontColor(cell11, workbook));
94+
Assertions.assertEquals(30, StyleTestUtils.getFontHeightInPoints(cell11, workbook));
9595
}
9696

9797
private void readAndWrite(File file) throws Exception {
@@ -103,13 +103,13 @@ private void readAndWrite(File file) throws Exception {
103103

104104
Workbook workbook = WorkbookFactory.create(file);
105105
Sheet sheet = workbook.getSheetAt(0);
106-
Assert.assertEquals(50 * 256, sheet.getColumnWidth(0), 0);
106+
Assertions.assertEquals(50 * 256, sheet.getColumnWidth(0), 0);
107107

108108
Row row0 = sheet.getRow(0);
109-
Assert.assertEquals(1000, row0.getHeight(), 0);
109+
Assertions.assertEquals(1000, row0.getHeight(), 0);
110110

111111
Row row1 = sheet.getRow(1);
112-
Assert.assertEquals(2000, row1.getHeight(), 0);
112+
Assertions.assertEquals(2000, row1.getHeight(), 0);
113113
}
114114

115115
private List<AnnotationStyleData> dataStyle() throws Exception {

easyexcel-test/src/test/java/com/alibaba/easyexcel/test/core/annotation/AnnotationIndexAndNameDataListener.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import java.util.ArrayList;
44
import java.util.List;
55

6-
import org.junit.Assert;
7-
import org.slf4j.Logger;
8-
import org.slf4j.LoggerFactory;
9-
106
import com.alibaba.excel.context.AnalysisContext;
117
import com.alibaba.excel.event.AnalysisEventListener;
128
import com.alibaba.fastjson2.JSON;
139

10+
import org.junit.jupiter.api.Assertions;
11+
import org.slf4j.Logger;
12+
import org.slf4j.LoggerFactory;
13+
1414
/**
1515
* @author Jiaju Zhuang
1616
*/
@@ -25,12 +25,12 @@ public void invoke(AnnotationIndexAndNameData data, AnalysisContext context) {
2525

2626
@Override
2727
public void doAfterAllAnalysed(AnalysisContext context) {
28-
Assert.assertEquals(list.size(), 1);
28+
Assertions.assertEquals(list.size(), 1);
2929
AnnotationIndexAndNameData data = list.get(0);
30-
Assert.assertEquals(data.getIndex0(), "第0个");
31-
Assert.assertEquals(data.getIndex1(), "第1个");
32-
Assert.assertEquals(data.getIndex2(), "第2个");
33-
Assert.assertEquals(data.getIndex4(), "第4个");
30+
Assertions.assertEquals(data.getIndex0(), "第0个");
31+
Assertions.assertEquals(data.getIndex1(), "第1个");
32+
Assertions.assertEquals(data.getIndex2(), "第2个");
33+
Assertions.assertEquals(data.getIndex4(), "第4个");
3434
LOGGER.debug("First row:{}", JSON.toJSONString(list.get(0)));
3535
}
3636
}

easyexcel-test/src/test/java/com/alibaba/easyexcel/test/core/annotation/AnnotationIndexAndNameDataTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77
import com.alibaba.easyexcel.test.util.TestFileUtil;
88
import com.alibaba.excel.EasyExcel;
99

10-
import org.junit.BeforeClass;
11-
import org.junit.FixMethodOrder;
12-
import org.junit.Test;
13-
import org.junit.runners.MethodSorters;
10+
import org.junit.jupiter.api.BeforeAll;
11+
import org.junit.jupiter.api.MethodOrderer;
12+
import org.junit.jupiter.api.Test;
13+
import org.junit.jupiter.api.TestMethodOrder;
1414

1515
/**
1616
* Annotation data test
1717
*
1818
* @author Jiaju Zhuang
1919
*/
20-
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
20+
@TestMethodOrder(MethodOrderer.MethodName.class)
2121
public class AnnotationIndexAndNameDataTest {
2222

2323
private static File file07;
2424
private static File file03;
2525
private static File fileCsv;
2626

27-
@BeforeClass
27+
@BeforeAll
2828
public static void init() {
2929
file07 = TestFileUtil.createNewFile("annotationIndexAndName07.xlsx");
3030
file03 = TestFileUtil.createNewFile("annotationIndexAndName03.xls");

easyexcel-test/src/test/java/com/alibaba/easyexcel/test/core/bom/BomDataTest.java

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,32 @@
11
package com.alibaba.easyexcel.test.core.bom;
22

3-
import com.alibaba.easyexcel.test.core.simple.SimpleData;
4-
import com.alibaba.easyexcel.test.demo.read.DemoData;
3+
import java.io.File;
4+
import java.io.FileOutputStream;
5+
import java.nio.charset.Charset;
6+
import java.util.List;
7+
import java.util.Map;
8+
59
import com.alibaba.easyexcel.test.util.TestFileUtil;
610
import com.alibaba.excel.EasyExcel;
711
import com.alibaba.excel.context.AnalysisContext;
812
import com.alibaba.excel.metadata.data.ReadCellData;
9-
import com.alibaba.excel.read.listener.PageReadListener;
1013
import com.alibaba.excel.read.listener.ReadListener;
1114
import com.alibaba.excel.support.ExcelTypeEnum;
1215
import com.alibaba.excel.util.ListUtils;
13-
import com.alibaba.fastjson2.JSON;
1416

1517
import lombok.extern.slf4j.Slf4j;
1618
import org.apache.commons.compress.utils.Lists;
17-
import org.junit.Assert;
18-
import org.junit.FixMethodOrder;
19-
import org.junit.Test;
20-
import org.junit.runners.MethodSorters;
21-
22-
import java.io.File;
23-
import java.io.FileOutputStream;
24-
import java.nio.charset.Charset;
25-
import java.util.ArrayList;
26-
import java.util.List;
27-
import java.util.Map;
19+
import org.junit.jupiter.api.Assertions;
20+
import org.junit.jupiter.api.MethodOrderer;
21+
import org.junit.jupiter.api.Test;
22+
import org.junit.jupiter.api.TestMethodOrder;
2823

2924
/**
3025
* bom test
3126
*
3227
* @author Jiaju Zhuang
3328
*/
34-
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
29+
@TestMethodOrder(MethodOrderer.MethodName.class)
3530
@Slf4j
3631
public class BomDataTest {
3732

@@ -72,7 +67,7 @@ private void readAndWriteCsv(File file, String charsetName, Boolean withBom) thr
7267
@Override
7368
public void invokeHead(Map<Integer, ReadCellData<?>> headMap, AnalysisContext context) {
7469
String head = headMap.get(0).getStringValue();
75-
Assert.assertEquals("姓名", head);
70+
Assertions.assertEquals("姓名", head);
7671
}
7772

7873
@Override
@@ -82,10 +77,10 @@ public void invoke(BomData data, AnalysisContext context) {
8277

8378
@Override
8479
public void doAfterAllAnalysed(AnalysisContext context) {
85-
Assert.assertEquals(dataList.size(), 10);
80+
Assertions.assertEquals(dataList.size(), 10);
8681
BomData bomData = dataList.get(0);
87-
Assert.assertEquals("姓名0", bomData.getName());
88-
Assert.assertEquals(20, (long)bomData.getAge());
82+
Assertions.assertEquals("姓名0", bomData.getName());
83+
Assertions.assertEquals(20, (long)bomData.getAge());
8984
}
9085
})
9186
.charset(charset)
@@ -100,7 +95,7 @@ private void readCsv(File file) {
10095
@Override
10196
public void invokeHead(Map<Integer, ReadCellData<?>> headMap, AnalysisContext context) {
10297
String head = headMap.get(0).getStringValue();
103-
Assert.assertEquals("姓名", head);
98+
Assertions.assertEquals("姓名", head);
10499
}
105100

106101
@Override
@@ -110,10 +105,10 @@ public void invoke(BomData data, AnalysisContext context) {
110105

111106
@Override
112107
public void doAfterAllAnalysed(AnalysisContext context) {
113-
Assert.assertEquals(dataList.size(), 10);
108+
Assertions.assertEquals(dataList.size(), 10);
114109
BomData bomData = dataList.get(0);
115-
Assert.assertEquals("姓名0", bomData.getName());
116-
Assert.assertEquals(20L, (long)bomData.getAge());
110+
Assertions.assertEquals("姓名0", bomData.getName());
111+
Assertions.assertEquals(20L, (long)bomData.getAge());
117112
}
118113
}).sheet().doRead();
119114
}

0 commit comments

Comments
 (0)