feat: 项目整体命名修改cache-schema-checker
All checks were successful
缓存序列化结构检查 / cache-schema-check (push) Has been skipped
All checks were successful
缓存序列化结构检查 / cache-schema-check (push) Has been skipped
This commit is contained in:
33
src/test/java/com/codechecker/cache/TestSupport.java
vendored
Normal file
33
src/test/java/com/codechecker/cache/TestSupport.java
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.codechecker.cache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
/**
|
||||
* 测试通用工具:加载 classpath 下的 fixture 文本。
|
||||
*/
|
||||
public final class TestSupport {
|
||||
|
||||
private TestSupport() {
|
||||
}
|
||||
|
||||
public static String fixture(String path) {
|
||||
try (InputStream in = TestSupport.class.getClassLoader().getResourceAsStream(path)) {
|
||||
if (in == null) {
|
||||
throw new IllegalArgumentException("fixture 不存在: " + path);
|
||||
}
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
byte[] chunk = new byte[8192];
|
||||
int read;
|
||||
while ((read = in.read(chunk)) != -1) {
|
||||
buffer.write(chunk, 0, read);
|
||||
}
|
||||
return new String(buffer.toByteArray(), StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user