blob: 9c768aa0b7cc5c8df62843f378c0167ea0ef9738 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>DirTestWatcher (Drill : 1.20.0 API)</title>
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="DirTestWatcher (Drill : 1.20.0 API)";
}
}
catch(err) {
}
//-->
var methods = {"i0":9,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
var tableTab = "tableTab";
var activeTableTab = "activeTableTab";
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/DirTestWatcher.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/apache/drill/test/ConfigBuilder.html" title="class in org.apache.drill.test"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../org/apache/drill/test/DrillAssert.html" title="class in org.apache.drill.test"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/drill/test/DirTestWatcher.html" target="_top">Frames</a></li>
<li><a href="DirTestWatcher.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">org.apache.drill.test</div>
<h2 title="Class DirTestWatcher" class="title">Class DirTestWatcher</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
<li>
<ul class="inheritance">
<li>TestWatcher</li>
<li>
<ul class="inheritance">
<li>org.apache.drill.test.DirTestWatcher</li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>Direct Known Subclasses:</dt>
<dd><a href="../../../../org/apache/drill/test/BaseDirTestWatcher.html" title="class in org.apache.drill.test">BaseDirTestWatcher</a></dd>
</dl>
<hr>
<br>
<pre>public class <span class="typeNameLabel">DirTestWatcher</span>
extends TestWatcher</pre>
<div class="block"><p>
This class is used to create consistently named and safe temp directories for
unit tests.
</p>
<p>
A <a href="../../../../org/apache/drill/test/DirTestWatcher.html" title="class in org.apache.drill.test"><code>DirTestWatcher</code></a> is added to a test by declaring it as a JUnit
<code>Rule</code>. A <code>Rule</code> is a piece of code that
is run before and after every JUnit test marked with the
<code>Test</code> annotation. When the <a href="../../../../org/apache/drill/test/DirTestWatcher.html" title="class in org.apache.drill.test"><code>DirTestWatcher</code></a> is
added to a test class the <a href="../../../../org/apache/drill/test/DirTestWatcher.html" title="class in org.apache.drill.test"><code>DirTestWatcher</code></a> will create a temp directory
before each of your <code>Test</code>s and optionally delete the
temp directory after each of your <code>Test</code>s. The <b>base
temp directory</b> created by the <a href="../../../../org/apache/drill/test/DirTestWatcher.html" title="class in org.apache.drill.test"><code>DirTestWatcher</code></a> is in the
<b>target</b> folder of the maven project and has the form <b>(my test class
fully qualified name)/(my test method name)</b>. So in the context of the
code example below, the temp directory created for each test in <b>target</b>
will be <b>my.proj.MyTestClass/myTestMethod1</b> and
<b>my.proj.MyTestClass/myTestMethod2</b> respectively.
</p>
<p>
The temp directory created by the <a href="../../../../org/apache/drill/test/DirTestWatcher.html" title="class in org.apache.drill.test"><code>DirTestWatcher</code></a> can be used within a
test by simply calling the <a href="../../../../org/apache/drill/test/DirTestWatcher.html#getDir--"><code>getDir()</code></a> method on the
<a href="../../../../org/apache/drill/test/DirTestWatcher.html" title="class in org.apache.drill.test"><code>DirTestWatcher</code></a> within your unit test.
</p>
<p>
By default, the <a href="../../../../org/apache/drill/test/DirTestWatcher.html" title="class in org.apache.drill.test"><code>DirTestWatcher</code></a> deletes the temp directory it creates
at the end of each <code>Test</code>. However, you can create a
<a href="../../../../org/apache/drill/test/DirTestWatcher.html" title="class in org.apache.drill.test"><code>DirTestWatcher</code></a> by doing <code>new DirTestWatcher(false)</code> to disable
the deletion of temp directories after a test. This is useful if you want to
examine files after a test runs.
</p>
<pre>
<code>
package my.proj;
public class MyTestClass {
&#064;Rule
public final DirTestWatcher dirTestWatcher = new DirTestWatcher();
&#064;Test
public void myTestMethod1() {
File dir = dirTestWatcher.getDir();
// Do stuff in the temp directory
}
&#064;Test
public void myTestMethod2() {
File dir = dirTestWatcher.getDir();
// Do stuff in the temp directory
}
}
</code>
</pre>
<p>
<b>Note:</b> In the code sample above, the directories returned by
<a href="../../../../org/apache/drill/test/DirTestWatcher.html#getDir--"><code>getDir()</code></a> in myTestMethod1 and myTestMethod2 are
<b>my.proj.MyTestClass/myTestMethod1</b> and
<b>my.proj.MyTestClass/myTestMethod2</b> respectively.
TODO: need to implement <code>AfterEachCallback</code> and <code>BeforeEachCallback</code> to use it with
JUnit5 @ExtendWith annotation
</p></div>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.summary">
<!-- -->
</a>
<h3>Constructor Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../org/apache/drill/test/DirTestWatcher.html#DirTestWatcher--">DirTestWatcher</a></span>()</code>
<div class="block">Creates a <a href="../../../../org/apache/drill/test/DirTestWatcher.html" title="class in org.apache.drill.test"><code>DirTestWatcher</code></a> that deletes temp directories after the
<code>TestWatcher</code> completes.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colOne"><code><span class="memberNameLink"><a href="../../../../org/apache/drill/test/DirTestWatcher.html#DirTestWatcher-boolean-">DirTestWatcher</a></span>(boolean&nbsp;deleteDirAtEnd)</code>
<div class="block">Creates a <a href="../../../../org/apache/drill/test/DirTestWatcher.html" title="class in org.apache.drill.test"><code>DirTestWatcher</code></a> which can delete or keep the temp
directory after the <code>TestWatcher</code> completes.</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method.summary">
<!-- -->
</a>
<h3>Method Summary</h3>
<table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tr id="i0" class="altColor">
<td class="colFirst"><code>static <a href="https://docs.oracle.com/javase/8/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/drill/test/DirTestWatcher.html#createTempDir-java.io.File-">createTempDir</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;baseDir)</code>&nbsp;</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>protected void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/drill/test/DirTestWatcher.html#failed-java.lang.Throwable-Description-">failed</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html?is-external=true" title="class or interface in java.lang">Throwable</a>&nbsp;e,
Description&nbsp;description)</code>&nbsp;</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>protected void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/drill/test/DirTestWatcher.html#finished-Description-">finished</a></span>(Description&nbsp;description)</code>&nbsp;</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/drill/test/DirTestWatcher.html#getDir--">getDir</a></span>()</code>
<div class="block">Gets the <a href="https://docs.oracle.com/javase/8/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io"><code>File</code></a> object of the current temp directory.</div>
</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/javase/8/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/drill/test/DirTestWatcher.html#makeSubDir-java.nio.file.Path-">makeSubDir</a></span>(<a href="https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a>&nbsp;relativeDirPath)</code>
<div class="block">Creates a sub directory with the given relative path in current temp
directory</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>protected void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../../org/apache/drill/test/DirTestWatcher.html#starting-Description-">starting</a></span>(Description&nbsp;description)</code>&nbsp;</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
<code><a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#clone--" title="class or interface in java.lang">clone</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#equals-java.lang.Object-" title="class or interface in java.lang">equals</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#finalize--" title="class or interface in java.lang">finalize</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#getClass--" title="class or interface in java.lang">getClass</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#hashCode--" title="class or interface in java.lang">hashCode</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notify--" title="class or interface in java.lang">notify</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#notifyAll--" title="class or interface in java.lang">notifyAll</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#toString--" title="class or interface in java.lang">toString</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait--" title="class or interface in java.lang">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-" title="class or interface in java.lang">wait</a>, <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html?is-external=true#wait-long-int-" title="class or interface in java.lang">wait</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor.detail">
<!-- -->
</a>
<h3>Constructor Detail</h3>
<a name="DirTestWatcher--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>DirTestWatcher</h4>
<pre>public&nbsp;DirTestWatcher()</pre>
<div class="block">Creates a <a href="../../../../org/apache/drill/test/DirTestWatcher.html" title="class in org.apache.drill.test"><code>DirTestWatcher</code></a> that deletes temp directories after the
<code>TestWatcher</code> completes.</div>
</li>
</ul>
<a name="DirTestWatcher-boolean-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>DirTestWatcher</h4>
<pre>public&nbsp;DirTestWatcher(boolean&nbsp;deleteDirAtEnd)</pre>
<div class="block">Creates a <a href="../../../../org/apache/drill/test/DirTestWatcher.html" title="class in org.apache.drill.test"><code>DirTestWatcher</code></a> which can delete or keep the temp
directory after the <code>TestWatcher</code> completes.</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>deleteDirAtEnd</code> - When true the temp directory created by the <a href="../../../../org/apache/drill/test/DirTestWatcher.html" title="class in org.apache.drill.test"><code>DirTestWatcher</code></a>
is deleted. When false the temp directory created by the
<a href="../../../../org/apache/drill/test/DirTestWatcher.html" title="class in org.apache.drill.test"><code>DirTestWatcher</code></a> is not deleted.</dd>
</dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method.detail">
<!-- -->
</a>
<h3>Method Detail</h3>
<a name="starting-Description-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>starting</h4>
<pre>protected&nbsp;void&nbsp;starting(Description&nbsp;description)</pre>
</li>
</ul>
<a name="finished-Description-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>finished</h4>
<pre>protected&nbsp;void&nbsp;finished(Description&nbsp;description)</pre>
</li>
</ul>
<a name="failed-java.lang.Throwable-Description-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>failed</h4>
<pre>protected&nbsp;void&nbsp;failed(<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html?is-external=true" title="class or interface in java.lang">Throwable</a>&nbsp;e,
Description&nbsp;description)</pre>
</li>
</ul>
<a name="makeSubDir-java.nio.file.Path-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>makeSubDir</h4>
<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;makeSubDir(<a href="https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html?is-external=true" title="class or interface in java.nio.file">Path</a>&nbsp;relativeDirPath)</pre>
<div class="block">Creates a sub directory with the given relative path in current temp
directory</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>relativeDirPath</code> - The relative path of the sub directory to create in the current
temp directory.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The <a href="https://docs.oracle.com/javase/8/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io"><code>File</code></a> object of the newly created sub directory.</dd>
</dl>
</li>
</ul>
<a name="getDir--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getDir</h4>
<pre>public&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;getDir()</pre>
<div class="block">Gets the <a href="https://docs.oracle.com/javase/8/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io"><code>File</code></a> object of the current temp directory.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>The <a href="https://docs.oracle.com/javase/8/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io"><code>File</code></a> object of the current temp directory.</dd>
</dl>
</li>
</ul>
<a name="createTempDir-java.io.File-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>createTempDir</h4>
<pre>public static&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;createTempDir(<a href="https://docs.oracle.com/javase/8/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;baseDir)</pre>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../overview-summary.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/DirTestWatcher.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../org/apache/drill/test/ConfigBuilder.html" title="class in org.apache.drill.test"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../../org/apache/drill/test/DrillAssert.html" title="class in org.apache.drill.test"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../index.html?org/apache/drill/test/DirTestWatcher.html" target="_top">Frames</a></li>
<li><a href="DirTestWatcher.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright &#169; 2022 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
</body>
</html>