本文整理了Java中org.assertj.core.api.AbstractFileAssert.hasParent()
方法的一些代码示例,展示了AbstractFileAssert.hasParent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractFileAssert.hasParent()
方法的具体详情如下:
包路径:org.assertj.core.api.AbstractFileAssert
类名称:AbstractFileAssert
方法名:hasParent
[英]Verifies that the actual File has given parent.
Example:
File xFile = new File("mulder/xFile");
// assertion will pass
assertThat(xFile).hasParent(new File("mulder"));
// assertion will fail
assertThat(xFile).hasParent(new File("scully"));
[中]验证实际文件是否已指定父级。
例子:
File xFile = new File("mulder/xFile");
// assertion will pass
assertThat(xFile).hasParent(new File("mulder"));
// assertion will fail
assertThat(xFile).hasParent(new File("scully"));
代码示例来源:origin: SonarSource/sonarqube
@Test
public void copy_all_classloader_files_to_dedicated_directory() throws Exception {
File deployDir = temp.newFolder();
when(fs.getDeployedPluginsDir()).thenReturn(deployDir);
File sourceJar = TestProjectUtils.jarOf("test-libs-plugin");
PluginInfo info = PluginInfo.create(sourceJar);
ExplodedPlugin exploded = underTest.explode(info);
// all the files loaded by classloaders (JAR + META-INF/libs/*.jar) are copied to the dedicated directory
// web/deploy/{pluginKey}
File pluginDeployDir = new File(deployDir, "testlibs");
assertThat(exploded.getKey()).isEqualTo("testlibs");
assertThat(exploded.getMain()).isFile().exists().hasParent(pluginDeployDir);
assertThat(exploded.getLibs()).extracting("name").containsOnly("commons-daemon-1.0.15.jar", "commons-email-20030310.165926.jar");
for (File lib : exploded.getLibs()) {
assertThat(lib).exists().isFile();
assertThat(lib.getCanonicalPath()).startsWith(pluginDeployDir.getCanonicalPath());
}
File targetJar = new File(fs.getDeployedPluginsDir(), "testlibs/test-libs-plugin-0.1-SNAPSHOT.jar");
verify(pluginFileSystem).addInstalledPlugin(info, targetJar);
}
}
代码示例来源: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: 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: kolorobot/unit-testing-demo
@Test
public void writesContentToFile() throws IOException {
// arrange
File output = temporaryFolder.newFolder("reports")
.toPath()
.resolve("output.txt")
.toFile();
// act
fileWriter.writeTo(output.getPath(), "test");
// assert
assertThat(output)
.hasContent("test")
.hasExtension("txt")
.hasParent(resolvePath("reports"));
}
代码示例来源: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();
}
内容来源于网络,如有侵权,请联系作者删除!