Use TemporaryFolder for tests

This commit is contained in:
Adam
2015-10-13 09:37:23 -04:00
parent ec9f22fa33
commit 142e432403
2 changed files with 13 additions and 3 deletions

View File

@@ -4,14 +4,19 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder;
public class DataFileTest public class DataFileTest
{ {
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@Test @Test
public void test1() throws IOException public void test1() throws IOException
{ {
File file = new File("d:/rs/07/test/test.dat"); File file = folder.newFile();
Store store = new Store(); Store store = new Store();
DataFile df = new DataFile(store, 42, file); DataFile df = new DataFile(store, 42, file);
int sector = df.write(3, ByteBuffer.wrap("test".getBytes())); int sector = df.write(3, ByteBuffer.wrap("test".getBytes()));
@@ -27,7 +32,7 @@ public class DataFileTest
byte[] b = new byte[1024]; byte[] b = new byte[1024];
for (int i = 0; i < 1024; ++i) b[i] = (byte) i; for (int i = 0; i < 1024; ++i) b[i] = (byte) i;
File file = new File("d:/rs/07/test/test.dat"); File file = folder.newFile();
Store store = new Store(); Store store = new Store();
DataFile df = new DataFile(store, 42, file); DataFile df = new DataFile(store, 42, file);
int sector = df.write(0x1FFFF, ByteBuffer.wrap(b)); int sector = df.write(0x1FFFF, ByteBuffer.wrap(b));

View File

@@ -3,14 +3,19 @@ package net.runelite.cache.fs;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.TemporaryFolder;
public class IndexFileTest public class IndexFileTest
{ {
@Rule
public TemporaryFolder folder = new TemporaryFolder();
@Test @Test
public void test1() throws IOException public void test1() throws IOException
{ {
File file = new File("d:/rs/07/test/test.dat"); File file = folder.newFile();
Store store = new Store(); Store store = new Store();
IndexFile index = new IndexFile(store, 5, file); IndexFile index = new IndexFile(store, 5, file);
IndexEntry entry = new IndexEntry(index, 7, 8, 9); IndexEntry entry = new IndexEntry(index, 7, 8, 9);