Remove setUp and tearDown methods that are no longer necessary after the switch to the TemporaryFolder rule.
MODIFY
src/test/java/org/apache/commons/io/FileDeleteStrategyTestCase.java
src/test/java/org/apache/commons/io/FileDeleteStrategyTestCase.java
import java.io.IOException;
import org.apache.commons.io.testtools.TestUtils;
-import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -160,10 +159,4 @@ public void testToString() {
assertEquals("FileDeleteStrategy[Normal]", FileDeleteStrategy.NORMAL.toString());
assertEquals("FileDeleteStrategy[Force]", FileDeleteStrategy.FORCE.toString());
}
-
- @After
- public void tearDown() throws Exception {
- FileUtils.deleteDirectory(getTestDirectory());
- }
-
}

MODIFY
src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java
src/test/java/org/apache/commons/io/FilenameUtilsTestCase.java
import java.util.Collection;
import org.apache.commons.io.testtools.TestUtils;
-import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
- private File getTestDirectory() {
- return temporaryFolder.getRoot();
- }
-
private static final String SEP = "" + File.separatorChar;
private static final boolean WINDOWS = File.separatorChar == '\\';
@@ -59,9 +54,6 @@ private File getTestDirectory() {
private int testFile1Size;
private int testFile2Size;
- /**
- * @see junit.framework.TestCase#setUp()
- */
@Before
public void setUp() throws Exception {
testFile1 = temporaryFolder.newFile("file1-test.txt");
@@ -103,14 +95,6 @@ public void setUp() throws Exception {
}
}
- /**
- * @see junit.framework.TestCase#tearDown()
- */
- @After
- public void tearDown() throws Exception {
- temporaryFolder.delete();
- }
-
//-----------------------------------------------------------------------
@Test
public void testNormalize() throws Exception {

MODIFY
src/test/java/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java
src/test/java/org/apache/commons/io/comparator/ComparatorAbstractTestCase.java
import java.util.Comparator;
import java.util.List;
-import org.apache.commons.io.FileUtils;
-import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -63,18 +61,6 @@ protected File getTestDirectory() {
/** File which is more than the "lessFile" */
protected File moreFile;
- /** @see junit.framework.TestCase#tearDown() */
- @After
- public void tearDown() throws Exception {
- comparator = null;
- reverse = null;
- equalFile1 = null;
- equalFile2 = null;
- lessFile = null;
- moreFile = null;
- FileUtils.deleteDirectory(getTestDirectory());
- }
-
/**
* Test the comparator.
*/

MODIFY
src/test/java/org/apache/commons/io/filefilter/FileFilterTestCase.java
src/test/java/org/apache/commons/io/filefilter/FileFilterTestCase.java
import org.apache.commons.io.IOCase;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.testtools.TestUtils;
-import org.junit.After;
-import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@@ -68,16 +66,6 @@ private File getTestDirectory() {
private static final boolean WINDOWS = File.separatorChar == '\\';
- @Before
- public void setUp() {
- getTestDirectory();
- }
-
- @After
- public void tearDown() throws Exception {
- FileUtils.deleteDirectory(getTestDirectory());
- }
-
public void assertFiltering(final IOFileFilter filter, final File file, final boolean expected) throws Exception {
// Note. This only tests the (File, String) version if the parent of
// the File passed in is not null

MODIFY
src/test/java/org/apache/commons/io/input/TailerTest.java
src/test/java/org/apache/commons/io/input/TailerTest.java
@@ -70,10 +70,7 @@ private File getTestDirectory() {
public void tearDown() throws Exception {
if (tailer != null) {
tailer.stop();
- TestUtils.sleep(1000);
}
- FileUtils.deleteDirectory(getTestDirectory());
- TestUtils.sleep(1000);
}
@Test

MODIFY
src/test/java/org/apache/commons/io/monitor/AbstractMonitorTestCase.java
src/test/java/org/apache/commons/io/monitor/AbstractMonitorTestCase.java
import org.apache.commons.io.filefilter.FileFilterUtils;
import org.apache.commons.io.filefilter.HiddenFileFilter;
import org.apache.commons.io.filefilter.IOFileFilter;
-import org.junit.After;
import org.junit.Before;
/**
@@ -89,11 +88,6 @@ protected void createObserver(final File file, final FileFilter fileFilter) {
}
}
- @After
- public void tearDown() throws Exception {
- FileUtils.deleteDirectory(testDir);
- }
-
/**
* Check all the Collections are empty
*

MODIFY
src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java
src/test/java/org/apache/commons/io/output/FileWriterWithEncodingTest.java
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
-import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -79,13 +77,6 @@ public void setUp() {
textContent = new String(arr);
}
- @After
- public void tearDown() throws Exception {
- FileUtils.deleteDirectory(getTestDirectory());
- defaultEncoding = null;
- textContent = null;
- }
-
//-----------------------------------------------------------------------
@Test
public void sameEncoding_string_constructor() throws Exception {

MODIFY
src/test/java/org/apache/commons/io/output/LockableFileWriterTest.java
src/test/java/org/apache/commons/io/output/LockableFileWriterTest.java
import java.nio.charset.StandardCharsets;
import java.nio.charset.UnsupportedCharsetException;
-import org.apache.commons.io.FileUtils;
-import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -62,14 +60,6 @@ public void setUp() {
altLockFile = new File(altLockDir, file.getName() + ".lck");
}
- @After
- public void tearDown() throws IOException {
- file.delete();
- lockFile.delete();
- altLockFile.delete();
- FileUtils.deleteDirectory(altLockDir);
- }
-
//-----------------------------------------------------------------------
@Test public void testFileLocked() throws IOException {

Remove setUp and tearDown methods that are no longer necessary after the switch to the TemporaryFolder rule.