Testing Excel Header Reading and Cache Implementation in alibaba/easyexcel
This test suite validates Excel file reading functionality in EasyExcel, specifically focusing on header parsing and caching mechanisms. It implements core tests for handling Excel files with different header configurations and demonstrates cache optimization using Ehcache.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
alibaba/easyexcel
easyexcel-test/src/test/java/com/alibaba/easyexcel/test/temp/read/HeadReadTest.java
package com.alibaba.easyexcel.test.temp.read;
import java.io.File;
import com.alibaba.easyexcel.test.util.TestFileUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.cache.Ehcache;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 临时测试
*
* @author Jiaju Zhuang
**/
public class HeadReadTest {
private static final Logger LOGGER = LoggerFactory.getLogger(HeadReadTest.class);
@Test
public void test() throws Exception {
File file = TestFileUtil.readUserHomeFile("test/t2.xlsx");
EasyExcel.read(file, HeadReadData.class, new HeadListener()).ignoreEmptyRow(false).sheet(0).doRead();
}
@Test
public void testCache() throws Exception {
File file = new File("D:\\test\\headt1.xls");
EasyExcel.read(file, HeadReadData.class, new HDListener()).readCache(new Ehcache(20)).sheet(0).doRead();
LOGGER.info("------------------");
EasyExcel.read(file, HeadReadData.class, new HDListener()).readCache(new Ehcache(20)).sheet(0).doRead();
LOGGER.info("------------------");
EasyExcel.read(file, HeadReadData.class, new HDListener()).readCache(new Ehcache(20)).sheet(0).doRead();
}
}