org.assertj.core.api.AbstractFileAssert.isAbsolute()方法的使用及代码示例

x33g5p2x  于11个月前 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(27)

本文整理了Java中org.assertj.core.api.AbstractFileAssert.isAbsolute()方法的一些代码示例,展示了AbstractFileAssert.isAbsolute()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractFileAssert.isAbsolute()方法的具体详情如下:
包路径:org.assertj.core.api.AbstractFileAssert
类名称:AbstractFileAssert
方法名:isAbsolute

AbstractFileAssert.isAbsolute介绍

[英]Verifies that the actual File is an absolute path.

Example:

File absoluteFile = File.createTempFile("tmp", "txt"); 
// assertions will pass 
assertThat(absoluteFile).isAbsolute(); 
File relativeFile = new File("./test"); 
// assertion will fail 
assertThat(relativeFile).isAbsolute();

[中]验证实际文件是否为绝对路径。
例子:

File absoluteFile = File.createTempFile("tmp", "txt"); 
// assertions will pass 
assertThat(absoluteFile).isAbsolute(); 
File relativeFile = new File("./test"); 
// assertion will fail 
assertThat(relativeFile).isAbsolute();

代码示例

代码示例来源:origin: ehcache/ehcache3

@Test
 public void test() {
  String value = System.getProperty("kitInstallationPath");
  assertThat(new File(value)).exists();
  assertThat(new File(value)).isAbsolute();
  assertThat(new File(value).toString()).doesNotContain("..");
 }
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void test_directories() throws Exception {
 assertThat(fs.baseDir()).isAbsolute().isDirectory().exists();
 assertThat(fs.baseDir().getCanonicalPath()).isEqualTo(basedir.getCanonicalPath());
 File workdir = temp.newFolder();
 fs.setWorkDir(workdir.toPath());
 assertThat(fs.workDir()).isAbsolute().isDirectory().exists();
 assertThat(fs.workDir().getCanonicalPath()).isEqualTo(workdir.getCanonicalPath());
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void test() throws Exception {
 File baseDir = temp.newFolder();
 DefaultInputDir inputDir = new DefaultInputDir("ABCDE", "src")
  .setModuleBaseDir(baseDir.toPath());
 assertThat(inputDir.key()).isEqualTo("ABCDE:src");
 assertThat(inputDir.file().getAbsolutePath()).isEqualTo(new File(baseDir, "src").getAbsolutePath());
 assertThat(inputDir.relativePath()).isEqualTo("src");
 assertThat(new File(inputDir.relativePath())).isRelative();
 assertThat(inputDir.absolutePath()).endsWith("src");
 assertThat(new File(inputDir.absolutePath())).isAbsolute();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void test() throws Exception {
 Metadata metadata = new Metadata(42, 42, "", new int[0], new int[0], 10);
 DefaultInputFile inputFile = new DefaultInputFile(indexedFile, (f) -> f.setMetadata(metadata))
  .setStatus(InputFile.Status.ADDED)
  .setCharset(StandardCharsets.ISO_8859_1);
 assertThat(inputFile.absolutePath()).endsWith("Foo.php");
 assertThat(inputFile.filename()).isEqualTo("Foo.php");
 assertThat(inputFile.uri()).hasPath(baseDir.resolve(PROJECT_RELATIVE_PATH).toUri().getPath());
 assertThat(new File(inputFile.absolutePath())).isAbsolute();
 assertThat(inputFile.language()).isEqualTo("php");
 assertThat(inputFile.status()).isEqualTo(InputFile.Status.ADDED);
 assertThat(inputFile.type()).isEqualTo(InputFile.Type.TEST);
 assertThat(inputFile.lines()).isEqualTo(42);
 assertThat(inputFile.charset()).isEqualTo(StandardCharsets.ISO_8859_1);
 assertThat(inputFile.getModuleRelativePath()).isEqualTo(MODULE_RELATIVE_PATH);
 assertThat(inputFile.getProjectRelativePath()).isEqualTo(PROJECT_RELATIVE_PATH);
 sensorStrategy.setGlobal(false);
 assertThat(inputFile.relativePath()).isEqualTo(MODULE_RELATIVE_PATH);
 assertThat(new File(inputFile.relativePath())).isRelative();
 sensorStrategy.setGlobal(true);
 assertThat(inputFile.relativePath()).isEqualTo(PROJECT_RELATIVE_PATH);
 assertThat(new File(inputFile.relativePath())).isRelative();
}

相关文章