chore: Fix unit test failure on Windows

This commit is contained in:
Robin Shen 2025-06-14 11:19:43 +08:00
parent fbe90e4213
commit 7b36bcfa15

View File

@ -2,11 +2,13 @@ package io.onedev.server.util;
import com.google.common.io.Resources;
import org.junit.Test;
import org.mozilla.universalchardet.Constants;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class ContentDetectorTest {
@ -14,7 +16,8 @@ public class ContentDetectorTest {
public void detectCharset() {
try (var is = Resources.getResource(ContentDetectorTest.class, "iso-8859-1.txt").openStream()) {
var bytes = IOUtils.toByteArray(is);
assertEquals(StandardCharsets.ISO_8859_1, ContentDetector.detectCharset(bytes));
var charset = ContentDetector.detectCharset(bytes);
assertTrue(charset.equals(StandardCharsets.ISO_8859_1) || charset.name().equals("windows-1252"));
} catch (IOException e) {
throw new RuntimeException(e);
}