From 9ceac4d3cd40c4929d203436893b6d6d5e9d5dc7 Mon Sep 17 00:00:00 2001 From: hellozrh <455741807@qq.com> Date: Wed, 18 Jan 2023 14:35:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0assert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/test/java/cn/hutool/poi/excel/ExcelUtilTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hutool-poi/src/test/java/cn/hutool/poi/excel/ExcelUtilTest.java b/hutool-poi/src/test/java/cn/hutool/poi/excel/ExcelUtilTest.java index c274ae1ab..9a3dcf1d4 100644 --- a/hutool-poi/src/test/java/cn/hutool/poi/excel/ExcelUtilTest.java +++ b/hutool-poi/src/test/java/cn/hutool/poi/excel/ExcelUtilTest.java @@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.poi.excel.cell.CellLocation; import cn.hutool.poi.excel.sax.handler.RowHandler; +import org.apache.poi.ss.usermodel.CellStyle; import org.junit.Assert; import org.junit.Test; @@ -75,16 +76,24 @@ public class ExcelUtilTest { @Test public void doAfterAllAnalysedTest() { String path = "readBySax.xls"; + AtomicInteger doAfterAllAnalysedTime = new AtomicInteger(0); try{ ExcelUtil.readBySax(path, -1, new RowHandler() { @Override public void handle(int sheetIndex, long rowIndex, List rowCells) { System.out.println(StrUtil.format("sheetIndex={};rowIndex={},rowCells={}",sheetIndex,rowIndex,rowCells)); } + + @Override + public void doAfterAllAnalysed() { + doAfterAllAnalysedTime.addAndGet(1); + } }); }catch (Exception ex){ ex.printStackTrace(); } + //总共2个sheet页,读取所有sheet时,一共执行doAfterAllAnalysed2次。 + Assert.assertEquals(2, doAfterAllAnalysedTime.intValue()); } }