热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

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

本文整理了Java中org.assertj.core.api.AbstractPathAssert.existsNoFollowLinks()方法的一些代码示例,展示了

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

AbstractPathAssert.existsNoFollowLinks介绍

[英]Assert that the tested Path exists, not following symbolic links, by calling Files#exists(Path,LinkOption...)).

This assertion behaves like #exists(), with the difference that it can be used to assert the existence of a symbolic link even if its target is invalid.

Examples:

// fs is a Unix filesystem
// Create a regular file, and a symbolic link pointing to it
final Path existingFile = fs.getPath("somefile");
Files.createFile(existingFile);
final Path symlinkToExistingFile = fs.getPath("symlink");
Files.createSymbolicLink(symlinkToExistingFile, existingFile);
// Create a symbolic link whose target does not exist
final Path nOnExistentPath= fs.getPath("nonexistent");
final Path symlinkTOnonExistentPath= fs.getPath("symlinkToNonExistentPath");
Files.createSymbolicLink(symlinkToNonExistentPath, nonExistentPath);
// The following assertions succeed
assertThat(existingFile).existsNoFollowLinks();
assertThat(symlinkToExistingFile).existsNoFollowLinks();
assertThat(symlinkToNonExistentPath).existsNoFollowLinks();
// The following assertion fails
assertThat(nonExistentPath).existsNoFollowLinks();

[中]通过调用文件#exists(Path,LinkOption…),断言测试路径存在,而不是遵循符号链接。
此断言的行为类似于#exists(),区别在于它可以用于断言符号链接的存在,即使其目标无效。
示例:

// fs is a Unix filesystem
// Create a regular file, and a symbolic link pointing to it
final Path existingFile = fs.getPath("somefile");
Files.createFile(existingFile);
final Path symlinkToExistingFile = fs.getPath("symlink");
Files.createSymbolicLink(symlinkToExistingFile, existingFile);
// Create a symbolic link whose target does not exist
final Path nOnExistentPath= fs.getPath("nonexistent");
final Path symlinkTOnonExistentPath= fs.getPath("symlinkToNonExistentPath");
Files.createSymbolicLink(symlinkToNonExistentPath, nonExistentPath);
// The following assertions succeed
assertThat(existingFile).existsNoFollowLinks();
assertThat(symlinkToExistingFile).existsNoFollowLinks();
assertThat(symlinkToNonExistentPath).existsNoFollowLinks();
// The following assertion fails
assertThat(nonExistentPath).existsNoFollowLinks();

代码示例

代码示例来源:origin: de.pfabulist.lindwurm/niotest

@Test
@Category( { SymLink.class, Writable.class } )
public void testMoveLinkToNonExistingPath() throws IOException {
Files.createSymbolicLink( symLink(), absAB() );
Path to = dirTB().resolve( nameB() );
Files.move( symLink(), to );
assertThat( to ).existsNoFollowLinks();
}

代码示例来源:origin: de.pfabulist.lindwurm/niotest

@Test
@Category( { SymLink.class, Writable.class } )
public void testCreateSymLinkToNonExisting() throws IOException {
Files.createSymbolicLink( link(), absTA() );
assertThat( link() ).existsNoFollowLinks();
}

代码示例来源:origin: de.pfabulist.lindwurm/niotest

@Test
@Category( { SymLink.class } )
public void testBrokenSymLinkNoFollowLinkExists() throws IOException {
Files.createSymbolicLink( symLink(), absTA() );
assertThat( symLink() ).existsNoFollowLinks();
}

代码示例来源:origin: line/centraldogma

/**
* Makes sure {@link GitRepository} can create the legacy format repository, with Git repository format
* version 0 and hexadecimal tag encoding.
*/
@Test
public void legacyFormatCreation() {
final File repoDir0 = tempDir.getRoot();
final GitRepository repo0 = new GitRepository(proj, repoDir0, V0, commonPool(), 0L, Author.SYSTEM);
try {
assertThat(repo0.format()).isSameAs(V0);
assertThat(Paths.get(repoDir0.getPath(), "refs", "heads", "master"))
.existsNoFollowLinks()
.isRegularFile();
} finally {
repo0.internalClose();
}
}

代码示例来源:origin: line/centraldogma

/**
* Makes sure {@link GitRepository} can create the modern format repository, with Git repository format
* version 1 and simple tag encoding.
*/
@Test
public void modernFormatCreation() {
final File repoDir1 = tempDir.getRoot();
final GitRepository repo1 = new GitRepository(proj, repoDir1, commonPool(), 0L, Author.SYSTEM);
try {
assertThat(repo1.format()).isSameAs(V1);
assertThat(Paths.get(repoDir1.getPath(), "refs", "heads", "master"))
.existsNoFollowLinks()
.isRegularFile();
} finally {
repo1.internalClose();
}
}

推荐阅读
  • IjustinheritedsomewebpageswhichusesMooTools.IneverusedMooTools.NowIneedtoaddsomef ... [详细]
  • 在Docker中,将主机目录挂载到容器中作为volume使用时,常常会遇到文件权限问题。这是因为容器内外的UID不同所导致的。本文介绍了解决这个问题的方法,包括使用gosu和suexec工具以及在Dockerfile中配置volume的权限。通过这些方法,可以避免在使用Docker时出现无写权限的情况。 ... [详细]
  • eclipse学习(第三章:ssh中的Hibernate)——11.Hibernate的缓存(2级缓存,get和load)
    本文介绍了eclipse学习中的第三章内容,主要讲解了ssh中的Hibernate的缓存,包括2级缓存和get方法、load方法的区别。文章还涉及了项目实践和相关知识点的讲解。 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • MyBatis多表查询与动态SQL使用
    本文介绍了MyBatis多表查询与动态SQL的使用方法,包括一对一查询和一对多查询。同时还介绍了动态SQL的使用,包括if标签、trim标签、where标签、set标签和foreach标签的用法。文章还提供了相关的配置信息和示例代码。 ... [详细]
  • 本文介绍了利用ARMA模型对平稳非白噪声序列进行建模的步骤及代码实现。首先对观察值序列进行样本自相关系数和样本偏自相关系数的计算,然后根据这些系数的性质选择适当的ARMA模型进行拟合,并估计模型中的位置参数。接着进行模型的有效性检验,如果不通过则重新选择模型再拟合,如果通过则进行模型优化。最后利用拟合模型预测序列的未来走势。文章还介绍了绘制时序图、平稳性检验、白噪声检验、确定ARMA阶数和预测未来走势的代码实现。 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • sklearn数据集库中的常用数据集类型介绍
    本文介绍了sklearn数据集库中常用的数据集类型,包括玩具数据集和样本生成器。其中详细介绍了波士顿房价数据集,包含了波士顿506处房屋的13种不同特征以及房屋价格,适用于回归任务。 ... [详细]
  • 关键词:Golang, Cookie, 跟踪位置, net/http/cookiejar, package main, golang.org/x/net/publicsuffix, io/ioutil, log, net/http, net/http/cookiejar ... [详细]
  • 本文介绍了Android 7的学习笔记总结,包括最新的移动架构视频、大厂安卓面试真题和项目实战源码讲义。同时还分享了开源的完整内容,并提醒读者在使用FileProvider适配时要注意不同模块的AndroidManfiest.xml中配置的xml文件名必须不同,否则会出现问题。 ... [详细]
  • [转载]从零开始学习OpenGL ES之四 – 光效
    继续我们的iPhoneOpenGLES之旅,我们将讨论光效。目前,我们没有加入任何光效。幸运的是,OpenGL在没有设置光效的情况下仍然可 ... [详细]
  • 详解 Python 的二元算术运算,为什么说减法只是语法糖?[Python常见问题]
    原题|UnravellingbinaryarithmeticoperationsinPython作者|BrettCannon译者|豌豆花下猫(“Python猫 ... [详细]
  • QuestionThereareatotalofncoursesyouhavetotake,labeledfrom0ton-1.Somecoursesmayhaveprerequi ... [详细]
author-avatar
醉苏芳华
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有