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

x33g5p2x  于2022-01-15 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(68)

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

AbstractFileAssert.hasName介绍

[英]Verifies that the actual File has given name.

Example:

File xFile = new File("somewhere/xFile.java"); 
File xDirectory = new File("somewhere/xDirectory"); 
// assertion will pass 
assertThat(xFile).hasName("xFile.java"); 
assertThat(xDirectory).hasName("xDirectory"); 
// assertion will fail 
assertThat(xFile).hasName("xFile"); 
assertThat(xDirectory).hasName("somewhere");

[中]验证实际文件是否具有给定名称。
例子:

File xFile = new File("somewhere/xFile.java"); 
File xDirectory = new File("somewhere/xDirectory"); 
// assertion will pass 
assertThat(xFile).hasName("xFile.java"); 
assertThat(xDirectory).hasName("xDirectory"); 
// assertion will fail 
assertThat(xFile).hasName("xFile"); 
assertThat(xDirectory).hasName("somewhere");

代码示例

代码示例来源: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: apache/geode

@Test
public void securityFileContainsSSLPropsAndNoUseSSL() throws Exception {
 properties.setProperty(SSL_KEYSTORE, "keystore");
 result = gfshParserRule.executeCommandWithInstance(connectCommand,
   "connect --security-properties-file=test");
 // will try to load from this file
 verify(connectCommand).loadProperties(any(), fileCaptor.capture());
 assertThat(fileCaptor.getValue()).hasName("test");
 // it will prompt for missing properties
 verify(gfsh, times(6)).readText(any());
 verify(gfsh, times(2)).readPassword(any());
}

代码示例来源:origin: apache/geode

@Test
public void securityFileContainsNoSSLPropsAndNoUseSSL() throws Exception {
 result = gfshParserRule.executeCommandWithInstance(connectCommand,
   "connect --security-properties-file=test");
 // will try to load from this file
 verify(connectCommand).loadProperties(any(), fileCaptor.capture());
 assertThat(fileCaptor.getValue()).hasName("test");
 // it will prompt for missing properties
 verify(gfsh, times(0)).readText(any());
 verify(gfsh, times(0)).readPassword(any());
}

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

@Test
public void getFlowDir() throws Exception {
 final String FLOW_NAME = "embedded";
 final File flowDir = ExecutionsTestUtil.getFlowDir(FLOW_NAME);
 assertThat(flowDir).exists();
 assertThat(flowDir).hasName(FLOW_NAME);
}

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

@Test
public void getFlowFile() throws Exception {
 final String FLOW_NAME = "logtest";
 final String FILE_NAME = "largeLog1.log";
 final File testFile = ExecutionsTestUtil.getFlowFile(FLOW_NAME, FILE_NAME);
 assertThat(testFile).exists();
 assertThat(testFile).hasName(FILE_NAME);
}

代码示例来源:origin: apache/geode

@Test
public void connectUseLegacySecurityPropertiesFile() throws Exception {
 properties.setProperty(JMX_MANAGER_SSL_KEYSTORE, "jmx-keystore");
 result = gfshParserRule.executeCommandWithInstance(connectCommand,
   "connect --security-properties-file=test --key-store=keystore --key-store-password=password");
 // wil try to load from this file
 verify(connectCommand).loadProperties(fileCaptor.capture());
 assertThat(fileCaptor.getValue()).hasName("test");
 // it will not prompt for missing properties
 verify(gfsh, times(0)).readText(any());
 verify(gfsh, times(0)).readPassword(any());
 // the command option will be ignored
 assertThat(properties).hasSize(1);
 assertThat(properties.get(JMX_MANAGER_SSL_KEYSTORE)).isEqualTo("jmx-keystore");
}

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

@Test
public void explode_jar_to_temp_directory() {
 PluginInfo info = PluginInfo.create(plugin1Jar());
 ExplodedPlugin exploded = underTest.explode(info);
 // all the files loaded by classloaders (JAR + META-INF/libs/*.jar) are copied to a dedicated temp directory
 File copiedJar = exploded.getMain();
 assertThat(exploded.getKey()).isEqualTo("test");
 assertThat(copiedJar).isFile().exists();
 assertThat(copiedJar.getParentFile()).isDirectory().hasName("test");
 assertThat(copiedJar.getParentFile().getParentFile()).isDirectory().hasName("ce-exploded-plugins");
}

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

@Test
public void plugins_do_not_overlap() {
 PluginInfo info1 = PluginInfo.create(plugin1Jar());
 PluginInfo info2 = PluginInfo.create(plugin2Jar());
 ExplodedPlugin exploded1 = underTest.explode(info1);
 ExplodedPlugin exploded2 = underTest.explode(info2);
 assertThat(exploded1.getKey()).isEqualTo("test");
 assertThat(exploded1.getMain()).isFile().exists().hasName("sonar-test-plugin-0.1-SNAPSHOT.jar");
 assertThat(exploded2.getKey()).isEqualTo("test2");
 assertThat(exploded2.getMain()).isFile().exists().hasName("sonar-test2-plugin-0.1-SNAPSHOT.jar");
}

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

@Test
public void copy_and_use_existing_packed_jar_if_compression_enabled() throws IOException {
 File jar = touch(temp.newFolder(), "sonar-foo-plugin.jar");
 File packedJar = touch(jar.getParentFile(), "sonar-foo-plugin.pack.gz");
 PluginInfo info = new PluginInfo("foo").setJarFile(jar);
 // the JAR is copied somewhere else in order to be loaded by classloaders
 File loadedJar = touch(temp.newFolder(), "sonar-foo-plugin.jar");
 settings.setProperty(PROPERTY_PLUGIN_COMPRESSION_ENABLE, true);
 PluginFileSystem underTest = new PluginFileSystem(settings.asConfig());
 underTest.addInstalledPlugin(info, loadedJar);
 assertThat(underTest.getInstalledFiles()).hasSize(1);
 InstalledPlugin installedPlugin = underTest.getInstalledPlugin("foo").get();
 assertThat(installedPlugin.getPluginInfo()).isSameAs(info);
 assertThat(installedPlugin.getLoadedJar().getFile().toPath()).isEqualTo(loadedJar.toPath());
 assertThat(installedPlugin.getCompressedJar().getFile())
  .exists()
  .isFile()
  .hasName(packedJar.getName())
  .hasParent(loadedJar.getParentFile())
  .hasSameContentAs(packedJar);
}

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

@Test
public void compress_jar_if_compression_enabled() throws IOException {
 File jar = touch(temp.newFolder(), "sonar-foo-plugin.jar");
 PluginInfo info = new PluginInfo("foo").setJarFile(jar);
 // the JAR is copied somewhere else in order to be loaded by classloaders
 File loadedJar = touch(temp.newFolder(), "sonar-foo-plugin.jar");
 settings.setProperty(PROPERTY_PLUGIN_COMPRESSION_ENABLE, true);
 PluginFileSystem underTest = new PluginFileSystem(settings.asConfig());
 underTest.addInstalledPlugin(info, loadedJar);
 assertThat(underTest.getInstalledFiles()).hasSize(1);
 InstalledPlugin installedPlugin = underTest.getInstalledPlugin("foo").get();
 assertThat(installedPlugin.getPluginInfo()).isSameAs(info);
 assertThat(installedPlugin.getLoadedJar().getFile().toPath()).isEqualTo(loadedJar.toPath());
 assertThat(installedPlugin.getCompressedJar().getFile())
  .exists()
  .isFile()
  .hasName("sonar-foo-plugin.pack.gz")
  .hasParent(loadedJar.getParentFile());
}

代码示例来源:origin: io.vertx/vertx-core

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

代码示例来源:origin: dhleong/intellivim

public void testNewFQN() {
  final Project project = getProject();
  final File expectedDir = new File(project.getBaseDir().getPath(),
      "src/org/intellivim/test");
  assertThat(expectedDir).doesNotExist();
  final SimpleResult result = (SimpleResult) new JavaNewCommand(project,
      "class", "org.intellivim.test.NewlyCreated").execute();
  assertSuccess(result);
  LocationResult location = result.getResult();
  System.out.println("Created: " + location);
  assertThat(location).isNotNull();
  assertThat(expectedDir).exists();
  final File createdFile = new File(location.file);
  assertThat(createdFile)
      .exists()
      .hasParent(expectedDir)
      .hasName("NewlyCreated.java");
  // cleanup
  createdFile.delete();
  expectedDir.delete();
}

相关文章