-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test-fileServer-增加检查文件夹测试,清理由单元测试产生的临时文件
- Loading branch information
1 parent
de34acd
commit c5e725a
Showing
5 changed files
with
62 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
muyun-boot/src/test/java/net/ximatai/muyun/test/fileserver/TestFolderExists.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package net.ximatai.muyun.test.fileserver; | ||
|
||
import io.quarkus.test.common.QuarkusTestResource; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import jakarta.inject.Inject; | ||
import net.ximatai.muyun.fileserver.FileServerConfig; | ||
import net.ximatai.muyun.test.testcontainers.PostgresTestResource; | ||
import org.junit.jupiter.api.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
@QuarkusTest | ||
@QuarkusTestResource(value = PostgresTestResource.class, restrictToAnnotatedClass = true) | ||
public class TestFolderExists { | ||
|
||
final Logger logger = LoggerFactory.getLogger(getClass()); | ||
|
||
@Inject | ||
FileServerConfig config; | ||
|
||
private String getUploadPath() { | ||
String uploadPath = config.uploadPath(); | ||
if (!uploadPath.endsWith("/") && !uploadPath.endsWith("\\")) { | ||
uploadPath = uploadPath + "/"; | ||
} | ||
return uploadPath; | ||
} | ||
|
||
@Test | ||
void testFolder() { | ||
String folderPath = getUploadPath(); | ||
Path path = Paths.get(folderPath); | ||
|
||
try { | ||
if (Files.notExists(path)) { | ||
Files.createDirectories(path); | ||
System.out.println("文件夹已创建: " + folderPath); | ||
} else { | ||
System.out.println("文件夹已存在: " + folderPath); | ||
} | ||
} catch (Exception e) { | ||
logger.error("创建文件夹失败", e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters