Use TemporaryFolder rule.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/080ce0f4
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/080ce0f4
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/080ce0f4

Branch: refs/heads/LOG4J2-1161
Commit: 080ce0f49c88a9e7006932ef0b6555d48c15d738
Parents: 844187e
Author: Matt Sicker <boa...@gmail.com>
Authored: Wed Oct 21 01:45:27 2015 -0500
Committer: Matt Sicker <boa...@gmail.com>
Committed: Wed Oct 21 01:45:27 2015 -0500

----------------------------------------------------------------------
 .../appender/RandomAccessFileManagerTest.java   | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/080ce0f4/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
index e38f5fa..f127db3 100644
--- 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
+++ 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
@@ -23,7 +23,9 @@ import java.io.OutputStream;
 import java.io.RandomAccessFile;
 
 import org.apache.logging.log4j.core.util.NullOutputStream;
+import org.junit.ClassRule;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 import static org.junit.Assert.*;
 
@@ -32,6 +34,9 @@ import static org.junit.Assert.*;
  */
 public class RandomAccessFileManagerTest {
 
+    @ClassRule
+    public static TemporaryFolder folder = new TemporaryFolder();
+
     /**
      * Test method for
      * {@link 
org.apache.logging.log4j.core.appender.RandomAccessFileManager#write(byte[], 
int, int)}
@@ -39,8 +44,7 @@ public class RandomAccessFileManagerTest {
      */
     @Test
     public void testWrite_multiplesOfBufferSize() throws IOException {
-        final File file = File.createTempFile("log4j2", "test");
-        file.deleteOnExit();
+        final File file = folder.newFile();
         try (final RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
             final OutputStream os = NullOutputStream.NULL_OUTPUT_STREAM;
             final RandomAccessFileManager manager = new 
RandomAccessFileManager(raf, file.getName(), os, false,
@@ -61,8 +65,7 @@ public class RandomAccessFileManagerTest {
      */
     @Test
     public void testWrite_dataExceedingBufferSize() throws IOException {
-        final File file = File.createTempFile("log4j2", "test");
-        file.deleteOnExit();
+        final File file = folder.newFile();
         try (final RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
             final OutputStream os = NullOutputStream.NULL_OUTPUT_STREAM;
             final RandomAccessFileManager manager = new 
RandomAccessFileManager(raf, file.getName(), os, false,
@@ -79,8 +82,7 @@ public class RandomAccessFileManagerTest {
     
     @Test
     public void testConfigurableBufferSize() throws IOException {
-        final File file = File.createTempFile("log4j2", "test");
-        file.deleteOnExit();
+        final File file = folder.newFile();
         try (final RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
             final OutputStream os = NullOutputStream.NULL_OUTPUT_STREAM;
             final int bufferSize = 4 * 1024;
@@ -95,8 +97,7 @@ public class RandomAccessFileManagerTest {
 
     @Test
     public void testWrite_dataExceedingMinBufferSize() throws IOException {
-        final File file = File.createTempFile("log4j2", "test");
-        file.deleteOnExit();
+        final File file = folder.newFile();
         try (final RandomAccessFile raf = new RandomAccessFile(file, "rw")) {
             final OutputStream os = NullOutputStream.NULL_OUTPUT_STREAM;
             final int bufferSize = 1;
@@ -115,8 +116,7 @@ public class RandomAccessFileManagerTest {
     @Test
     public void testAppendDoesNotOverwriteExistingFile() throws IOException {
         final boolean isAppend = true;
-        final File file = File.createTempFile("log4j2", "test");
-        file.deleteOnExit();
+        final File file = folder.newFile();
         assertEquals(0, file.length());
 
         final byte[] bytes = new byte[4 * 1024];

Reply via email to