package cn.com.poc.utils;

import cn.com.poc.common.utils.MD5Utils;
import cn.com.yict.framemax.core.spring.SingleContextInitializer;
import cn.hutool.crypto.digest.MD5;
import org.junit.runner.RunWith;
import org.junit.Test;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;

import java.io.*;
import java.nio.file.Files;

/**
 * @author alex.yao
 * @date 2025/6/18
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(initializers = SingleContextInitializer.class)
@WebAppConfiguration
public class MD5UtilsTest {

    @Test
    public void test_md5() throws IOException {
        //计算文件MD5值
        File file = new File("C:\\Users\\52747\\Documents\\dataset\\22222（中文版）.pdf");
        InputStream inputStream = Files.newInputStream(file.toPath());
        byte[] bytes = new byte[inputStream.available()];
        inputStream.read(bytes);
        String md5 = MD5.create().digestHex(bytes);
        System.out.println(md5);
    }
}
