本文整理汇总了Java中org.junit.rules.TemporaryFolder.getRoot方法的典型用法代码示例。如果您正苦于以下问题:Java TemporaryFolder.getRoot方法的具体用法?Java TemporaryFolder.getRoot怎么用?Java TemporaryFolder.getRoot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.junit.rules.TemporaryFolder
的用法示例。
在下文中一共展示了TemporaryFolder.getRoot方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyTestFile
import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
public static File copyTestFile(String source, TemporaryFolder root, String target) {
File targetFile = new File(root.getRoot(), target);
targetFile.getParentFile().mkdirs();
try (OutputStream stream = new FileOutputStream(targetFile)) {
Resources.copy(WhoCalled.$.getCallingClass().getResource(source), stream);
return targetFile;
} catch (IOException e) {
throw new AssertionError(e);
}
}
示例2: setupTest
import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
@Before
public void setupTest() throws IOException {
TemporaryFolder f = new TemporaryFolder();
f.create();
_temp_folder = f.getRoot();
System.out.println("created temporary folder: " + _temp_folder.getAbsolutePath());
}
示例3: init
import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
@BeforeClass
public static void init() throws IOException {
TemporaryFolder f = new TemporaryFolder();
f.create();
File temp_folder = f.getRoot();
System.out.println("created temporary folder: " + temp_folder.getAbsolutePath());
UURI uuri = UURIFactory.getInstance("http://localtest/test");
curi = new CrawlURI(uuri);
l = new DecesiveValueLogger2();
l.setPath(new ConfigPath("test", temp_folder.getAbsolutePath()));
l.start();
}
示例4: getRandomFile
import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
public static File getRandomFile(final int length, final String extension, final TemporaryFolder tempFolder)
{
try
{
return tempFolder.newFile( String.format( "%s%s", HeadlessTestUtility.getRandomString( length ),
extension ) );
}
catch( final IOException ignored )
{
// do nothing
}
return tempFolder.getRoot();
}
示例5: createScript
import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
private static File createScript(TemporaryFolder baseDir, String[] lines) throws IOException {
File directory = baseDir.getRoot();
Files.createDirectories(Paths.get(directory.getPath(), "foo")).toFile();
File script = Files.createFile(Paths.get(directory.getPath(), "foo", "modelRun.R")).toFile();
PrintWriter writer = new PrintWriter(script);
for (String line : lines) {
writer.println(line);
}
writer.close();
return script;
}
示例6: mockBucket
import org.junit.rules.TemporaryFolder; //导入方法依赖的package包/类
/**
* Constructs a mock bucket.
* @param name Bucket name.
* @throws IOException In case of failure.
* @return The mock bucket.
*/
private MkBucket mockBucket(final String name) throws IOException {
final TemporaryFolder folder = new TemporaryFolder();
folder.create();
return new MkBucket(folder.getRoot(), name);
}