热门标签 | 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();
}
}

推荐阅读
  • Explore a common issue encountered when implementing an OAuth 1.0a API, specifically the inability to encode null objects and how to resolve it. ... [详细]
  • 本文详细介绍了Java中org.neo4j.helpers.collection.Iterators.single()方法的功能、使用场景及代码示例,帮助开发者更好地理解和应用该方法。 ... [详细]
  • 本文详细介绍了Java中org.eclipse.ui.forms.widgets.ExpandableComposite类的addExpansionListener()方法,并提供了多个实际代码示例,帮助开发者更好地理解和使用该方法。这些示例来源于多个知名开源项目,具有很高的参考价值。 ... [详细]
  • 本文深入探讨了 Java 中的 Serializable 接口,解释了其实现机制、用途及注意事项,帮助开发者更好地理解和使用序列化功能。 ... [详细]
  • 本文详细介绍了 GWT 中 PopupPanel 类的 onKeyDownPreview 方法,提供了多个代码示例及应用场景,帮助开发者更好地理解和使用该方法。 ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • Java 中的 BigDecimal pow()方法,示例 ... [详细]
  • 本文介绍了Java并发库中的阻塞队列(BlockingQueue)及其典型应用场景。通过具体实例,展示了如何利用LinkedBlockingQueue实现线程间高效、安全的数据传递,并结合线程池和原子类优化性能。 ... [详细]
  • 主要用了2个类来实现的,话不多说,直接看运行结果,然后在奉上源代码1.Index.javaimportjava.awt.Color;im ... [详细]
  • 深入解析Spring Cloud Ribbon负载均衡机制
    本文详细介绍了Spring Cloud中的Ribbon组件如何实现服务调用的负载均衡。通过分析其工作原理、源码结构及配置方式,帮助读者理解Ribbon在分布式系统中的重要作用。 ... [详细]
  • 本文详细介绍了Akka中的BackoffSupervisor机制,探讨其在处理持久化失败和Actor重启时的应用。通过具体示例,展示了如何配置和使用BackoffSupervisor以实现更细粒度的异常处理。 ... [详细]
  • 本文详细介绍了Java编程语言中的核心概念和常见面试问题,包括集合类、数据结构、线程处理、Java虚拟机(JVM)、HTTP协议以及Git操作等方面的内容。通过深入分析每个主题,帮助读者更好地理解Java的关键特性和最佳实践。 ... [详细]
  • 扫描线三巨头 hdu1928hdu 1255  hdu 1542 [POJ 1151]
    学习链接:http:blog.csdn.netlwt36articledetails48908031学习扫描线主要学习的是一种扫描的思想,后期可以求解很 ... [详细]
  • 深入解析Android自定义View面试题
    本文探讨了Android Launcher开发中自定义View的重要性,并通过一道经典的面试题,帮助开发者更好地理解自定义View的实现细节。文章不仅涵盖了基础知识,还提供了实际操作建议。 ... [详细]
  • 本文介绍了如何使用JQuery实现省市二级联动和表单验证。首先,通过change事件监听用户选择的省份,并动态加载对应的城市列表。其次,详细讲解了使用Validation插件进行表单验证的方法,包括内置规则、自定义规则及实时验证功能。 ... [详细]
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社区 版权所有