本文整理匯總了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);
}