本文整理了Java中org.assertj.core.api.AbstractPathAssert.isRegularFile()
方法的一些代码示例,展示了AbstractPathAssert.isRegularFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractPathAssert.isRegularFile()
方法的具体详情如下:
包路径:org.assertj.core.api.AbstractPathAssert
类名称:AbstractPathAssert
方法名:isRegularFile
[英]Assert that the tested Path is a regular file.
Note that this method will follow symbolic links. If you are a Unix user and wish to assert that a path is a symbolic link instead, use #isSymbolicLink().
This assertion first asserts the existence of the path (using #exists()) then checks whether the path is a regular file.
Examples:
// fs is a Unix filesystem
// Create a regular file, and a symbolic link to that regular file
final Path existingFile = fs.getPath("existingFile");
final Path symlinkToExistingFile = fs.getPath("symlinkToExistingFile");
Files.createFile(existingFile);
Files.createSymbolicLink(symlinkToExistingFile, existingFile);
// Create a directory, and a symbolic link to that directory
final Path dir = fs.getPath("dir");
final Path dirSymlink = fs.getPath("dirSymlink");
Files.createDirectories(dir);
Files.createSymbolicLink(dirSymlink, dir);
// Create a nonexistent entry, and a symbolic link to that entry
final Path nonExistentPath = fs.getPath("nonexistent");
final Path symlinkToNonExistentPath = fs.getPath("symlinkToNonExistentPath");
Files.createSymbolicLink(symlinkToNonExistentPath, nonExistentPath);
// the following assertions succeed:
assertThat(existingFile).isRegularFile();
assertThat(symlinkToExistingFile).isRegularFile();
// the following assertions fail because paths do not exist:
assertThat(nonExistentPath).isRegularFile();
assertThat(symlinkToNonExistentPath).isRegularFile();
// the following assertions fail because paths exist but are not regular files:
assertThat(dir).isRegularFile();
assertThat(dirSymlink).isRegularFile();
[中]断言测试路径是常规文件。
请注意,此方法将遵循符号链接。如果您是Unix用户,并且希望声明路径是符号链接,请使用#isSymbolicLink()。
此断言首先断言路径的存在(使用#exists()),然后检查路径是否为常规文件。
示例:
// fs is a Unix filesystem
// Create a regular file, and a symbolic link to that regular file
final Path existingFile = fs.getPath("existingFile");
final Path symlinkToExistingFile = fs.getPath("symlinkToExistingFile");
Files.createFile(existingFile);
Files.createSymbolicLink(symlinkToExistingFile, existingFile);
// Create a directory, and a symbolic link to that directory
final Path dir = fs.getPath("dir");
final Path dirSymlink = fs.getPath("dirSymlink");
Files.createDirectories(dir);
Files.createSymbolicLink(dirSymlink, dir);
// Create a nonexistent entry, and a symbolic link to that entry
final Path nonExistentPath = fs.getPath("nonexistent");
final Path symlinkToNonExistentPath = fs.getPath("symlinkToNonExistentPath");
Files.createSymbolicLink(symlinkToNonExistentPath, nonExistentPath);
// the following assertions succeed:
assertThat(existingFile).isRegularFile();
assertThat(symlinkToExistingFile).isRegularFile();
// the following assertions fail because paths do not exist:
assertThat(nonExistentPath).isRegularFile();
assertThat(symlinkToNonExistentPath).isRegularFile();
// the following assertions fail because paths exist but are not regular files:
assertThat(dir).isRegularFile();
assertThat(dirSymlink).isRegularFile();
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldGenerateCategoriesJson() throws Exception {
assertThat(output.resolve("data/categories.json"))
.isRegularFile();
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldGenerateWidgetDurationJson() throws Exception {
assertThat(output.resolve("widgets/duration.json"))
.isRegularFile();
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldGenerateWidgetExecutorsJson() throws Exception {
assertThat(output.resolve("widgets/executors.json"))
.isRegularFile();
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldGenerateIndexHtml() throws Exception {
assertThat(output.resolve("index.html"))
.isRegularFile();
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldGenerateTimelineJson() throws Exception {
assertThat(output.resolve("data/timeline.json"))
.isRegularFile();
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldGenerateWidgetCategoriesJson() throws Exception {
assertThat(output.resolve("widgets/categories.json"))
.isRegularFile();
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldGenerateWidgetLaunchJson() throws Exception {
assertThat(output.resolve("widgets/launch.json"))
.isRegularFile();
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldGenerateWidgetSuitesJson() throws Exception {
assertThat(output.resolve("widgets/suites.json"))
.isRegularFile();
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldGenerateXunitJson() throws Exception {
assertThat(output.resolve("data/suites.json"))
.isRegularFile();
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldGenerateWidgetHistoryTrendJson() throws Exception {
assertThat(output.resolve("widgets/history-trend.json"))
.isRegularFile();
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldGenerateWidgetSeverityJson() throws Exception {
assertThat(output.resolve("widgets/severity.json"))
.isRegularFile();
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldGenerateHistory() throws Exception {
assertThat(output.resolve("history/history.json"))
.isRegularFile();
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldGenerateWidgetEnvironmentJson() throws Exception {
assertThat(output.resolve("widgets/environment.json"))
.isRegularFile();
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldGenerateWidgetStatusJson() throws Exception {
assertThat(output.resolve("widgets/status-chart.json"))
.isRegularFile();
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldGenerateWidgetSummaryJson() throws Exception {
assertThat(output.resolve("widgets/summary.json"))
.isRegularFile();
}
代码示例来源:origin: allure-framework/allure2
@Test
public void shouldGenerateWidgetDurationTrendJson() throws Exception {
assertThat(output.resolve("widgets/duration-trend.json"))
.isRegularFile();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void deleteQuietly_deletes_symbolicLink() throws IOException {
assumeTrue(SystemUtils.IS_OS_UNIX);
Path folder = temporaryFolder.newFolder().toPath();
Path file1 = Files.createFile(folder.resolve("file1.txt"));
Path symLink = Files.createSymbolicLink(folder.resolve("link1"), file1);
assertThat(file1).isRegularFile();
assertThat(symLink).isSymbolicLink();
FileUtils.deleteQuietly(symLink.toFile());
assertThat(symLink).doesNotExist();
assertThat(file1).isRegularFile();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void deleteQuietly_deletes_symbolicLink() throws IOException {
assumeTrue(SystemUtils.IS_OS_UNIX);
Path folder = temporaryFolder.newFolder().toPath();
Path file1 = Files.createFile(folder.resolve("file1.txt"));
Path symLink = Files.createSymbolicLink(folder.resolve("link1"), file1);
assertThat(file1).isRegularFile();
assertThat(symLink).isSymbolicLink();
FileUtils2.deleteQuietly(symLink.toFile());
assertThat(symLink).doesNotExist();
assertThat(file1).isRegularFile();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void deleteDirectory_throws_IOE_if_file_is_symbolicLink() throws IOException {
assumeTrue(SystemUtils.IS_OS_UNIX);
Path folder = temporaryFolder.newFolder().toPath();
Path file1 = Files.createFile(folder.resolve("file1.txt"));
Path symLink = Files.createSymbolicLink(folder.resolve("link1"), file1);
assertThat(file1).isRegularFile();
assertThat(symLink).isSymbolicLink();
expectedException.expect(IOException.class);
expectedException.expectMessage("Directory '" + symLink.toFile().getAbsolutePath() + "' is a symbolic link");
FileUtils2.deleteDirectory(symLink.toFile());
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void deleteDirectory_throws_IOE_if_file_is_symbolicLink() throws IOException {
assumeTrue(SystemUtils.IS_OS_UNIX);
Path folder = temporaryFolder.newFolder().toPath();
Path file1 = Files.createFile(folder.resolve("file1.txt"));
Path symLink = Files.createSymbolicLink(folder.resolve("link1"), file1);
assertThat(file1).isRegularFile();
assertThat(symLink).isSymbolicLink();
expectedException.expect(IOException.class);
expectedException.expectMessage("Directory '" + symLink.toFile().getAbsolutePath() + "' is a symbolic link");
FileUtils.deleteDirectory(symLink.toFile());
}
内容来源于网络,如有侵权,请联系作者删除!