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

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

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

AbstractFileAssert.doesNotExist介绍

[英]Verifies that the actual File does not exist.

Example:

File parentDir = Files.createTempDirectory("tmpDir").toFile(); 
File tmpDir = new File(parentDir, "subDir"); 
File tmpFile = new File(parentDir, "a.txt"); 
// assertions will pass 
assertThat(tmpDir).doesNotExist(); 
assertThat(tmpFile).doesNotExist(); 
tmpDir.mkdir(); 
tmpFile.createNewFile(); 
// assertions will fail 
assertThat(tmpFile).doesNotExist(); 
assertThat(tmpDir).doesNotExist();

[中]验证实际文件是否不存在。
例子:

File parentDir = Files.createTempDirectory("tmpDir").toFile(); 
File tmpDir = new File(parentDir, "subDir"); 
File tmpFile = new File(parentDir, "a.txt"); 
// assertions will pass 
assertThat(tmpDir).doesNotExist(); 
assertThat(tmpFile).doesNotExist(); 
tmpDir.mkdir(); 
tmpFile.createNewFile(); 
// assertions will fail 
assertThat(tmpFile).doesNotExist(); 
assertThat(tmpDir).doesNotExist();

代码示例

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

@Test
public void reset_deletes_content_of_temp_dir_but_not_temp_dir_itself_if_it_already_exists() throws Exception {
 assertThat(tempDir.mkdir()).isTrue();
 Object tempDirKey = getFileKey(tempDir);
 File fileInTempDir = new File(tempDir, "someFile.txt");
 assertThat(fileInTempDir.createNewFile()).isTrue();
 File subDirInTempDir = new File(tempDir, "subDir");
 assertThat(subDirInTempDir.mkdir()).isTrue();
 underTest.reset();
 assertThat(tempDir).exists();
 assertThat(fileInTempDir).doesNotExist();
 assertThat(subDirInTempDir).doesNotExist();
 assertThat(getFileKey(tempDir)).isEqualTo(tempDirKey);
}

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

@Test
public void extract_only_libs() throws IOException {
 File jar = loadFile("sonar-checkstyle-plugin-2.8.jar");
 underTest.explode(PluginInfo.create(jar));
 assertThat(new File(jar.getParent(), "sonar-checkstyle-plugin-2.8.jar")).exists();
 assertThat(new File(jar.getParent(), "sonar-checkstyle-plugin-2.8.jar_unzip/META-INF/MANIFEST.MF")).doesNotExist();
 assertThat(new File(jar.getParent(), "sonar-checkstyle-plugin-2.8.jar_unzip/org/sonar/plugins/checkstyle/CheckstyleVersion.class")).doesNotExist();
}

代码示例来源:origin: gocd/gocd

@Test
public void shouldNotCreateDesCipherIfCipherFileMissing() {
  assertThat(desCipherFile).doesNotExist();
  GoCipher goCipher = new GoCipher(systemEnvironment);
  assertThat(goCipher.aesEncrypter).isNotNull();
  assertThat(goCipher.desEncrypter).isNull();
}

代码示例来源:origin: eclipse-vertx/vert.x

@Test
public void testWithFile() {
 final File file = Converters.create(File.class, "foo/hello.txt");
 assertThat(file).hasName("hello.txt")
   .doesNotExist();
}

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

@Test
public void deleteQuietly_does_not_fail_if_file_does_not_exist() throws IOException {
 File file = new File(temporaryFolder.newFolder(), "blablabl");
 assertThat(file).doesNotExist();
 FileUtils.deleteQuietly(file);
}

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

@Test
public void deleteQuietly_does_not_fail_if_file_does_not_exist() throws IOException {
 File file = new File(temporaryFolder.newFolder(), "blablabl");
 assertThat(file).doesNotExist();
 FileUtils2.deleteQuietly(file);
}

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

@Test
public void uninstall_dependents() throws Exception {
 File base = copyTestPluginTo("test-base-plugin", fs.getInstalledPluginsDir());
 File extension = copyTestPluginTo("test-require-plugin", fs.getInstalledPluginsDir());
 File uninstallDir = temp.newFolder("uninstallDir");
 underTest.start();
 assertThat(underTest.getPluginInfos()).hasSize(2);
 underTest.uninstall("testbase", uninstallDir);
 assertThat(base).doesNotExist();
 assertThat(extension).doesNotExist();
 assertThat(uninstallDir.list()).containsOnly(base.getName(), extension.getName());
}

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

@Test
public void shouldNotCreateFileIfFailToDownload() throws Exception {
 File toDir = temporaryFolder.newFolder();
 File toFile = new File(toDir, "downloadToFile.txt");
 try {
  int port = new InetSocketAddress("localhost", 0).getPort();
  new DefaultHttpDownloader(new MapSettings().asConfig()).download(new URI("http://localhost:" + port), toFile);
 } catch (SonarException e) {
  assertThat(toFile).doesNotExist();
 }
}

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

@Test
public void downloaded_file_overrides_existing_installed_file_on_startup() throws Exception {
 File installedV1 = copyTestPluginTo("test-base-plugin", fs.getInstalledPluginsDir());
 File downloadedV2 = copyTestPluginTo("test-base-plugin-v2", fs.getDownloadedPluginsDir());
 underTest.start();
 // plugin is moved to extensions/plugins and replaces v1
 assertThat(downloadedV2).doesNotExist();
 assertThat(installedV1).doesNotExist();
 assertThat(new File(fs.getInstalledPluginsDir(), downloadedV2.getName())).exists();
 assertThat(underTest.getPluginInfosByKeys()).containsOnlyKeys("testbase");
 assertThat(underTest.getPluginInfo("testbase").getVersion()).isEqualTo(Version.create("0.2-SNAPSHOT"));
}

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

@Test
public void clean_deletes_non_empty_directory() throws Exception {
 File dir = temp.newFolder();
 FileUtils.touch(new File(dir, "foo.txt"));
 DefaultTempFolder underTest = new DefaultTempFolder(dir);
 underTest.clean();
 assertThat(dir).doesNotExist();
}

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

@Test
 public void clean_does_not_fail_if_directory_has_already_been_deleted() throws Exception {
  File dir = temp.newFolder();

  DefaultTempFolder underTest = new DefaultTempFolder(dir);
  underTest.clean();
  assertThat(dir).doesNotExist();

  // second call does not fail, nor log ERROR logs
  underTest.clean();

  assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty();
 }
}

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

@Test
public void install_downloaded_plugins_on_startup() throws Exception {
 File downloadedJar = copyTestPluginTo("test-base-plugin", fs.getDownloadedPluginsDir());
 underTest.start();
 // plugin is moved to extensions/plugins then loaded
 assertThat(downloadedJar).doesNotExist();
 assertThat(new File(fs.getInstalledPluginsDir(), downloadedJar.getName())).isFile().exists();
 assertThat(underTest.getPluginInfosByKeys()).containsOnlyKeys("testbase");
}

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

@Test
 public void should_stop_and_clean_temp_dir() {
  File tempDir = cachesManager.tempDir();
  assertThat(tempDir).isDirectory().exists();
  assertThat(cachesManager.persistit()).isNotNull();
  assertThat(cachesManager.persistit().isInitialized()).isTrue();

  cachesManager.stop();

  assertThat(tempDir).doesNotExist();
  assertThat(cachesManager.tempDir()).isNull();
  assertThat(cachesManager.persistit()).isNull();
 }
}

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

@Test
public void dont_uninstall_non_existing_files() throws IOException {
 File base = copyTestPluginTo("test-base-plugin", fs.getInstalledPluginsDir());
 File extension = copyTestPluginTo("test-require-plugin", fs.getInstalledPluginsDir());
 File uninstallDir = temp.newFolder("uninstallDir");
 underTest.start();
 assertThat(underTest.getPluginInfos()).hasSize(2);
 underTest.uninstall("testbase", uninstallDir);
 assertThat(underTest.getPluginInfos()).hasSize(2);
 underTest.uninstall("testbase", uninstallDir);
 assertThat(base).doesNotExist();
 assertThat(extension).doesNotExist();
 assertThat(uninstallDir.list()).containsOnly(base.getName(), extension.getName());
}

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

@Test
 public void do_not_write_warnings_report_when_empty() throws IOException {
  File outputDir = temp.newFolder();
  ScannerReportWriter writer = new ScannerReportWriter(outputDir);

  underTest.publish(writer);

  assertThat(writer.getFileStructure().analysisWarnings()).doesNotExist();

  ScannerReportReader reader = new ScannerReportReader(outputDir);
  List<ScannerReport.AnalysisWarning> warnings = Lists.newArrayList(reader.readAnalysisWarnings());

  assertThat(warnings).isEmpty();
 }
}

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

@Test
public void shouldNotDumpInIssuesMode() throws Exception {
 when(analysisMode.isIssues()).thenReturn(true);
 ScannerReportWriter writer = new ScannerReportWriter(temp.newFolder());
 publisher.init(writer);
 assertThat(writer.getFileStructure().analysisLog()).doesNotExist();
}

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

@Test
public void blacklisted_plugin_is_automatically_uninstalled_on_startup() throws Exception {
 underTest.setBlacklistedPluginKeys(ImmutableSet.of("testbase", "issuesreport"));
 File jar = copyTestPluginTo("test-base-plugin", fs.getInstalledPluginsDir());
 underTest.start();
 // plugin is not installed and file is deleted
 assertThat(underTest.getPluginInfos()).isEmpty();
 assertThat(jar).doesNotExist();
}

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

@Test
public void uninstall() throws Exception {
 File installedJar = copyTestPluginTo("test-base-plugin", fs.getInstalledPluginsDir());
 File uninstallDir = temp.newFolder("uninstallDir");
 underTest.start();
 assertThat(underTest.getPluginInfosByKeys()).containsOnlyKeys("testbase");
 underTest.uninstall("testbase", uninstallDir);
 assertThat(installedJar).doesNotExist();
 // still up. Will be dropped after next startup
 assertThat(underTest.getPluginInfosByKeys()).containsOnlyKeys("testbase");
 assertThat(uninstallDir.list()).containsOnly(installedJar.getName());
}

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

@Test
public void createTempFolderWithName() throws Exception {
 File rootTempFolder = temp.newFolder();
 DefaultTempFolder underTest = new DefaultTempFolder(rootTempFolder);
 File dir = underTest.newDir("sample");
 assertThat(dir).exists().isDirectory();
 assertThat(new File(rootTempFolder, "sample")).isEqualTo(dir);
 new TempFolderCleaner(underTest).stop();
 assertThat(rootTempFolder).doesNotExist();
}

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

@Test
public void createTempFolderAndFile() throws Exception {
 File rootTempFolder = temp.newFolder();
 DefaultTempFolder underTest = new DefaultTempFolder(rootTempFolder);
 File dir = underTest.newDir();
 assertThat(dir).exists().isDirectory();
 File file = underTest.newFile();
 assertThat(file).exists().isFile();
 new TempFolderCleaner(underTest).stop();
 assertThat(rootTempFolder).doesNotExist();
}

相关文章