From 8a7d30b24624acb234ea3fa877134e0116a5be01 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期六, 30 八月 2025 21:05:53 +0800
Subject: [PATCH] 重构机床回传文件;撤回后禁用撤回按钮
---
blade-service/blade-mdm/src/test/java/org/springblade/mdm/utils/FileContentUtilTest.java | 29 +++++++++++++++++++++++++++--
1 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/blade-service/blade-mdm/src/test/java/org/springblade/mdm/utils/FileContentUtilTest.java b/blade-service/blade-mdm/src/test/java/org/springblade/mdm/utils/FileContentUtilTest.java
index 2f0c703..5bb149b 100644
--- a/blade-service/blade-mdm/src/test/java/org/springblade/mdm/utils/FileContentUtilTest.java
+++ b/blade-service/blade-mdm/src/test/java/org/springblade/mdm/utils/FileContentUtilTest.java
@@ -1,7 +1,10 @@
package org.springblade.mdm.utils;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Charsets;
@@ -9,6 +12,9 @@
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
public class FileContentUtilTest {
@@ -48,13 +54,32 @@
@Test
public void testReadLineAt() throws IOException {
- String file = "D:/a.txt";
+
+ Path source = Paths.get("src/test/resources/filecontenttest.txt");
int lineIndex = 1;
- FileInputStream fis = new FileInputStream(file);
+ FileInputStream fis = new FileInputStream(source.toFile());
String expected = "绗簩琛�";
String read = FileContentUtil.readLineAt(fis,lineIndex);
Assertions.assertEquals(expected,read);
}
+
+ @Test
+ public void testReplaceReadLineAt(@TempDir Path tempDir) throws IOException {
+ // 鍔犺浇璧勬簮鏂囦欢
+ Path source = Paths.get("src/test/resources/filecontenttest.txt");
+ //File file = new File(classLoader.getResource("filecontenttest.txt").getFile());
+ File testFile = source.toFile();
+ try(FileInputStream fis = new FileInputStream(testFile);) {
+
+ String expected = "newline2";
+ int lineIndex = 1;
+ InputStream ins = FileContentUtil.replaceAtLine(fis, lineIndex, expected);
+ List<String> list = IOUtils.readLines(ins, Charsets.UTF_8);
+ System.out.println(list);
+ Assertions.assertEquals(expected, list.get(lineIndex));
+ }
+
+ }
}
--
Gitblit v1.9.3